grommet 2.41.0 → 2.43.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/all/stories/Colors.js +6 -6
- package/components/Accordion/stories/CustomThemed/Rich.tsx +1 -1
- 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/Box/stories/Background.js +4 -10
- package/components/Button/Button.js +1 -0
- package/components/Button/StyledButton.js +3 -2
- package/components/Calendar/Calendar.js +96 -59
- package/components/Calendar/StyledCalendar.js +89 -7
- package/components/Calendar/utils.js +16 -2
- package/components/Card/stories/Simple.js +2 -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/Cards.js +3 -2
- package/components/Data/stories/Infinite.js +2 -2
- package/components/Data/stories/OnSelect.js +2 -2
- package/components/Data/stories/Properties.js +3 -2
- package/components/Data/stories/SpaceX.js +2 -2
- package/components/Data/stories/StarWars.js +1 -1
- package/components/DataFilter/DataFilter.js +1 -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/FileInput/index.d.ts +2 -3
- package/components/FormField/FormField.js +9 -2
- package/components/FormField/stories/ThresholdValidation.js +5 -1
- package/components/Grommet/index.d.ts +19 -1
- package/components/Grommet/propTypes.js +18 -0
- package/components/Grommet/stories/Theme.js +1 -1
- package/components/Grommet/stories/Vars.js +2 -2
- package/components/Layer/Layer.js +1 -1
- package/components/Layer/index.d.ts +2 -0
- package/components/List/List.js +43 -13
- package/components/List/stories/RenderedList.js +1 -1
- package/components/Meter/Circle.js +2 -2
- package/components/Meter/Meter.js +36 -17
- package/components/Meter/index.d.ts +18 -0
- package/components/Meter/propTypes.js +18 -0
- 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/Pagination/stories/CustomThemed/Custom.tsx +8 -2
- package/components/Pagination/stories/NumberEdgePages.js +2 -0
- package/components/Pagination/stories/NumberMiddlePages.js +2 -0
- package/components/Pagination/stories/Simple.js +4 -2
- package/components/Pagination/stories/Size.js +3 -0
- package/components/Pagination/stories/Steps.js +3 -0
- package/components/RadioButton/RadioButton.js +14 -3
- package/components/RadioButton/stories/Children.js +16 -3
- package/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/components/RadioButtonGroup/stories/Children.js +13 -1
- package/components/Select/Select.js +7 -3
- package/components/Select/SelectContainer.js +41 -34
- package/components/Select/index.d.ts +1 -1
- package/components/Select/utils.js +13 -2
- package/components/SelectMultiple/SelectMultiple.js +10 -0
- 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/Tabs/stories/Scrollable.js +2 -1
- package/components/Tag/Tag.js +11 -7
- package/components/TextInput/TextInput.js +7 -2
- package/components/ToggleGroup/StyledToggleGroup.js +12 -5
- package/components/ToggleGroup/ToggleGroup.js +21 -10
- package/components/WorldMap/WorldMap.js +1 -1
- package/es6/all/stories/Colors.js +6 -6
- package/es6/components/Accordion/stories/CustomThemed/Rich.tsx +1 -1
- 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/Box/stories/Background.js +4 -10
- package/es6/components/Button/Button.js +1 -0
- package/es6/components/Button/StyledButton.js +4 -3
- package/es6/components/Calendar/Calendar.js +95 -59
- package/es6/components/Calendar/StyledCalendar.js +90 -8
- package/es6/components/Calendar/utils.js +15 -1
- package/es6/components/Card/stories/Simple.js +3 -3
- 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/Cards.js +4 -3
- package/es6/components/Data/stories/Infinite.js +2 -2
- package/es6/components/Data/stories/OnSelect.js +2 -2
- package/es6/components/Data/stories/Properties.js +4 -3
- package/es6/components/Data/stories/SpaceX.js +2 -2
- package/es6/components/Data/stories/StarWars.js +1 -1
- package/es6/components/DataFilter/DataFilter.js +1 -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/FileInput/index.d.ts +2 -3
- package/es6/components/FormField/FormField.js +10 -3
- package/es6/components/FormField/stories/ThresholdValidation.js +5 -1
- package/es6/components/Grommet/index.d.ts +19 -1
- package/es6/components/Grommet/propTypes.js +18 -0
- package/es6/components/Grommet/stories/Theme.js +1 -1
- package/es6/components/Grommet/stories/Vars.js +2 -2
- package/es6/components/Layer/Layer.js +1 -1
- package/es6/components/Layer/index.d.ts +2 -0
- package/es6/components/List/List.js +43 -13
- package/es6/components/List/stories/RenderedList.js +1 -1
- package/es6/components/Meter/Circle.js +2 -2
- package/es6/components/Meter/Meter.js +37 -18
- package/es6/components/Meter/index.d.ts +18 -0
- package/es6/components/Meter/propTypes.js +18 -0
- 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/Pagination/stories/CustomThemed/Custom.tsx +8 -2
- package/es6/components/Pagination/stories/NumberEdgePages.js +2 -0
- package/es6/components/Pagination/stories/NumberMiddlePages.js +2 -0
- package/es6/components/Pagination/stories/Simple.js +4 -2
- package/es6/components/Pagination/stories/Size.js +3 -0
- package/es6/components/Pagination/stories/Steps.js +3 -0
- package/es6/components/RadioButton/RadioButton.js +15 -4
- package/es6/components/RadioButton/stories/Children.js +16 -3
- package/es6/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es6/components/RadioButtonGroup/stories/Children.js +12 -1
- package/es6/components/Select/Select.js +8 -4
- package/es6/components/Select/SelectContainer.js +41 -34
- package/es6/components/Select/index.d.ts +1 -1
- package/es6/components/Select/utils.js +15 -3
- package/es6/components/SelectMultiple/SelectMultiple.js +10 -0
- 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/Tabs/stories/Scrollable.js +2 -1
- package/es6/components/Tag/Tag.js +11 -7
- package/es6/components/TextInput/TextInput.js +7 -2
- 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/languages/default.json +18 -0
- package/es6/themes/base.d.ts +204 -6
- package/es6/themes/base.js +165 -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 +17 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +18 -0
- package/package.json +36 -36
- package/themes/base.d.ts +204 -6
- package/themes/base.js +165 -1
- package/utils/background.js +1 -1
- package/utils/index.js +6 -0
- package/utils/styles.js +9 -1
- package/utils/useId.js +22 -0
- package/components/CheckBox/stories/InsideButton.js +0 -38
- package/es6/components/CheckBox/stories/InsideButton.js +0 -32
|
@@ -18,13 +18,13 @@ var customTheme = {
|
|
|
18
18
|
blue: '#00C8FF',
|
|
19
19
|
green: '#17EBA0',
|
|
20
20
|
teal: '#82FFF2',
|
|
21
|
-
purple: '#
|
|
22
|
-
red: '#
|
|
21
|
+
purple: '#694b75',
|
|
22
|
+
red: '#914049',
|
|
23
23
|
orange: '#FFBC44',
|
|
24
|
-
yellow: '#
|
|
24
|
+
yellow: '#faf6d4',
|
|
25
25
|
// you can also point to existing grommet colors
|
|
26
26
|
brightGreen: 'accent-1',
|
|
27
|
-
|
|
27
|
+
dark: 'dark-1',
|
|
28
28
|
// Changing default text color,
|
|
29
29
|
// all colors could be either a string or a dark and light object
|
|
30
30
|
text: {
|
|
@@ -42,8 +42,8 @@ export var Colors = function Colors() {
|
|
|
42
42
|
gap: "medium",
|
|
43
43
|
pad: "small"
|
|
44
44
|
}, /*#__PURE__*/React.createElement(Text, null, "Custom color purple"), /*#__PURE__*/React.createElement(Text, {
|
|
45
|
-
color: "
|
|
46
|
-
}, "Inline custom color
|
|
45
|
+
color: "dark"
|
|
46
|
+
}, "Inline custom dark color"), /*#__PURE__*/React.createElement(Paragraph, {
|
|
47
47
|
color: "red"
|
|
48
48
|
}, "Wrapping your application with the Grommet component that is pointing to your customTheme object as shown on the example, will allow you full access to your custom colors across your application. You can override any Grommet color that is mentioned in the docs in a similar fashion."), /*#__PURE__*/React.createElement(Anchor, {
|
|
49
49
|
href: "https://github.com/grommet/grommet/wiki/Color-Properties"
|
|
@@ -2,7 +2,7 @@ var _excluded = ["children", "header", "id", "label", "onClick", "onMouseOut", "
|
|
|
2
2
|
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); }
|
|
3
3
|
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; }
|
|
4
4
|
import React, { forwardRef, useContext, useMemo, useState } from 'react';
|
|
5
|
-
import { normalizeColor, parseMetricToNum } from '../../utils';
|
|
5
|
+
import { normalizeColor, parseMetricToNum, useId } from '../../utils';
|
|
6
6
|
import { Box } from '../Box';
|
|
7
7
|
import { Button } from '../Button';
|
|
8
8
|
import { Collapsible } from '../Collapsible';
|
|
@@ -10,13 +10,6 @@ import { Heading } from '../Heading';
|
|
|
10
10
|
import { AccordionContext } from '../Accordion/AccordionContext';
|
|
11
11
|
import { AccordionPanelPropTypes } from './propTypes';
|
|
12
12
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
13
|
-
|
|
14
|
-
// Ideally we should use `useId` from react but this is only available
|
|
15
|
-
// in React 18 and we want to keep compatibility with React 17 and 16.
|
|
16
|
-
function getUID() {
|
|
17
|
-
var timestamp = Date.now() + Math.random();
|
|
18
|
-
return "grommet-accordion-button-" + timestamp;
|
|
19
|
-
}
|
|
20
13
|
var AccordionPanel = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
21
14
|
var children = _ref.children,
|
|
22
15
|
header = _ref.header,
|
|
@@ -28,7 +21,7 @@ var AccordionPanel = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
28
21
|
_onFocus = _ref.onFocus,
|
|
29
22
|
_onBlur = _ref.onBlur,
|
|
30
23
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
|
-
var panelButtonId =
|
|
24
|
+
var panelButtonId = useId();
|
|
32
25
|
var _useThemeValue = useThemeValue(),
|
|
33
26
|
theme = _useThemeValue.theme;
|
|
34
27
|
var _useContext = useContext(AccordionContext),
|
|
@@ -110,7 +110,7 @@ var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
110
110
|
if (firstIndex === undefined) {
|
|
111
111
|
firstIndex = index;
|
|
112
112
|
} else {
|
|
113
|
-
contents.push(
|
|
113
|
+
contents.push(/*#__PURE__*/React.createElement(StyledBoxGap
|
|
114
114
|
// eslint-disable-next-line react/no-array-index-key
|
|
115
115
|
, _extends({
|
|
116
116
|
key: "gap-" + index,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _FLEX_MAP;
|
|
2
2
|
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); }
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { alignContentStyle, alignStyle, backgroundStyle, borderStyle, breakpointStyle, edgeStyle, fillStyle, focusStyle, genericStyles, getBreakpointStyle, getHoverIndicatorStyle, heightStyle, overflowStyle, parseMetricToNum, responsiveBorderStyle, widthStyle } from '../../utils';
|
|
4
|
+
import { alignContentStyle, alignStyle, backgroundStyle, borderStyle, breakpointStyle, edgeStyle, elevationStyle, fillStyle, focusStyle, genericStyles, getBreakpointStyle, getHoverIndicatorStyle, heightStyle, overflowStyle, parseMetricToNum, responsiveBorderStyle, widthStyle } from '../../utils';
|
|
5
5
|
import { roundStyle, styledComponentsConfig } from '../../utils/styles';
|
|
6
6
|
import { animationBounds, animationObjectStyle } from '../../utils/animation';
|
|
7
7
|
var BASIS_MAP = {
|
|
@@ -32,11 +32,6 @@ var directionStyle = function directionStyle(direction, theme) {
|
|
|
32
32
|
}
|
|
33
33
|
return styles;
|
|
34
34
|
};
|
|
35
|
-
var elevationStyle = function elevationStyle(elevation) {
|
|
36
|
-
return css(["box-shadow:", ";"], function (props) {
|
|
37
|
-
return props.theme.global.elevation[props.theme.dark ? 'dark' : 'light'][elevation];
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
35
|
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);
|
|
41
36
|
var flexGrowShrinkProp = function flexGrowShrinkProp(flex) {
|
|
42
37
|
if (typeof flex === 'boolean' || typeof flex === 'string') {
|
|
@@ -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 };
|
|
@@ -26,6 +26,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
26
26
|
background: backgroundDoc,
|
|
27
27
|
basis: PropTypes.oneOfType([PropTypes.oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', 'full', '1/2', '1/3', '2/3', '1/4', '2/4', '3/4', 'auto']), PropTypes.string]),
|
|
28
28
|
border: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['top', 'left', 'bottom', 'right', 'start', 'end', 'horizontal', 'vertical', 'all', 'between']), BORDER_SHAPE, PropTypes.arrayOf(BORDER_SHAPE)]),
|
|
29
|
+
cssGap: PropTypes.bool,
|
|
29
30
|
direction: PropTypes.oneOf(['row', 'column', 'row-responsive', 'row-reverse', 'column-reverse']),
|
|
30
31
|
elevation: elevationPropType,
|
|
31
32
|
flex: PropTypes.oneOfType([PropTypes.oneOf(['grow', 'shrink']), PropTypes.bool, PropTypes.shape({
|
|
@@ -56,9 +56,7 @@ export var BackgroundBox = function BackgroundBox() {
|
|
|
56
56
|
dark: true
|
|
57
57
|
},
|
|
58
58
|
pad: "medium"
|
|
59
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
60
|
-
color: "brand"
|
|
61
|
-
}, "force dark background")), /*#__PURE__*/React.createElement(Box, {
|
|
59
|
+
}, /*#__PURE__*/React.createElement(Text, null, "force dark background")), /*#__PURE__*/React.createElement(Box, {
|
|
62
60
|
background: "dark-1",
|
|
63
61
|
pad: "medium"
|
|
64
62
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -72,15 +70,13 @@ export var BackgroundBox = function BackgroundBox() {
|
|
|
72
70
|
}, "force light background"))), /*#__PURE__*/React.createElement(Box, {
|
|
73
71
|
background: {
|
|
74
72
|
color: {
|
|
75
|
-
dark: '
|
|
73
|
+
dark: 'dark-2',
|
|
76
74
|
light: 'lightgrey'
|
|
77
75
|
},
|
|
78
76
|
dark: true
|
|
79
77
|
},
|
|
80
78
|
pad: "medium"
|
|
81
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
82
|
-
color: "brand"
|
|
83
|
-
}, "force dark background with color as object")), /*#__PURE__*/React.createElement(Box, {
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Text, null, "force dark background with color as object")), /*#__PURE__*/React.createElement(Box, {
|
|
84
80
|
background: "dark-1",
|
|
85
81
|
pad: "medium"
|
|
86
82
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -92,9 +88,7 @@ export var BackgroundBox = function BackgroundBox() {
|
|
|
92
88
|
dark: false
|
|
93
89
|
},
|
|
94
90
|
pad: "medium"
|
|
95
|
-
}, /*#__PURE__*/React.createElement(Text,
|
|
96
|
-
color: "brand"
|
|
97
|
-
}, "force light background with color as object"))))
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Text, null, "force light background with color as object"))))
|
|
98
92
|
// </Grommet>
|
|
99
93
|
);
|
|
100
94
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { activeStyle, backgroundStyle, disabledStyle, edgeStyle, focusStyle, unfocusStyle, genericStyles, getHoverIndicatorStyle, normalizeColor } from '../../utils';
|
|
3
|
-
import { styledComponentsConfig } from '../../utils/styles';
|
|
3
|
+
import { elevationStyle, styledComponentsConfig } from '../../utils/styles';
|
|
4
4
|
var radiusStyle = function radiusStyle(props) {
|
|
5
5
|
// border.radius shouldn't impact an only-icon rendering.
|
|
6
6
|
var isIconOnly = props.hasIcon && !props.hasLabel;
|
|
@@ -23,10 +23,11 @@ var padStyle = function padStyle(props) {
|
|
|
23
23
|
return css(["", " ", ""], props.theme.button.padding.vertical, props.theme.button.padding.horizontal);
|
|
24
24
|
};
|
|
25
25
|
var basicStyle = function basicStyle(props) {
|
|
26
|
-
return css(["border:", " solid ", ";border-radius:", ";color:", ";padding:", ";", ""], props.theme.button.border.width, normalizeColor(props.colorValue || props.theme.button.border.color || 'control', props.theme), radiusStyle(props), normalizeColor(props.theme.button.color || 'text', props.theme), padStyle(props), fontStyle(props));
|
|
26
|
+
return css(["border:", " solid ", ";border-radius:", ";", " color:", ";padding:", ";", ""], props.theme.button.border.width, normalizeColor(props.colorValue || props.theme.button.border.color || 'control', props.theme), radiusStyle(props), props.theme.button.elevation && elevationStyle(props.theme.button.elevation), normalizeColor(props.theme.button.color || 'text', props.theme), padStyle(props), fontStyle(props));
|
|
27
27
|
};
|
|
28
28
|
var primaryStyle = function primaryStyle(props) {
|
|
29
|
-
|
|
29
|
+
var _props$theme$button$p, _props$theme$button$p2;
|
|
30
|
+
return css(["", " border-radius:", ";", " ", ""], backgroundStyle(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) && 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);
|
|
30
31
|
};
|
|
31
32
|
function getHoverColor(props) {
|
|
32
33
|
if (props.colorValue) {
|
|
@@ -2,6 +2,7 @@ var _excluded = ["activeDate", "animate", "bounds", "children", "date", "dates",
|
|
|
2
2
|
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; }
|
|
3
3
|
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); }
|
|
4
4
|
import React, { forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
5
6
|
import { AnnounceContext } from '../../contexts/AnnounceContext';
|
|
6
7
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
7
8
|
import { Box } from '../Box';
|
|
@@ -15,6 +16,7 @@ import { StyledCalendar, StyledDay, StyledDayContainer, StyledWeek, StyledWeeks,
|
|
|
15
16
|
import { addDays, addMonths, betweenDates, daysApart, endOfMonth, handleOffset, sameDayOrAfter, sameDayOrBefore, startOfMonth, subtractDays, subtractMonths, withinDates } from './utils';
|
|
16
17
|
import { setHoursWithOffset } from '../../utils/dates';
|
|
17
18
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
19
|
+
import { useKeyboard } from '../../utils';
|
|
18
20
|
var headingPadMap = {
|
|
19
21
|
small: 'xsmall',
|
|
20
22
|
medium: 'small',
|
|
@@ -149,12 +151,16 @@ var _getOutputFormat = function getOutputFormat(dates) {
|
|
|
149
151
|
};
|
|
150
152
|
export { _getOutputFormat as getOutputFormat };
|
|
151
153
|
var millisecondsPerYear = 31557600000;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
|
|
155
|
+
// when caller opts in to day hover styling, apply all state styles
|
|
156
|
+
// on CalendarDay instead of active state on CalendarDayButton
|
|
157
|
+
var CalendarDayButton = styled(Button).withConfig({
|
|
158
|
+
displayName: "Calendar__CalendarDayButton",
|
|
159
|
+
componentId: "sc-1chaf9i-0"
|
|
160
|
+
})(["", ""], function (props) {
|
|
161
|
+
var _props$theme$calendar;
|
|
162
|
+
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;';
|
|
163
|
+
});
|
|
158
164
|
var CalendarDay = function CalendarDay(_ref) {
|
|
159
165
|
var children = _ref.children,
|
|
160
166
|
fill = _ref.fill,
|
|
@@ -162,30 +168,46 @@ var CalendarDay = function CalendarDay(_ref) {
|
|
|
162
168
|
isInRange = _ref.isInRange,
|
|
163
169
|
isSelected = _ref.isSelected,
|
|
164
170
|
otherMonth = _ref.otherMonth,
|
|
171
|
+
rangePosition = _ref.rangePosition,
|
|
165
172
|
_ref$buttonProps = _ref.buttonProps,
|
|
166
173
|
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps;
|
|
167
174
|
var _useThemeValue = useThemeValue(),
|
|
168
175
|
passThemeFlag = _useThemeValue.passThemeFlag;
|
|
176
|
+
var usingKeyboard = useKeyboard();
|
|
169
177
|
return /*#__PURE__*/React.createElement(StyledDayContainer, {
|
|
170
178
|
role: "gridcell",
|
|
171
|
-
sizeProp: size,
|
|
172
|
-
fillContainer: fill
|
|
173
|
-
}, /*#__PURE__*/React.createElement(CalendarDayButton, _extends({
|
|
174
|
-
fill: fill
|
|
175
|
-
}, buttonProps), /*#__PURE__*/React.createElement(StyledDay, _extends({
|
|
176
|
-
disabledProp: buttonProps.disabled,
|
|
177
179
|
inRange: isInRange,
|
|
178
|
-
otherMonth: otherMonth,
|
|
179
180
|
isSelected: isSelected,
|
|
181
|
+
rangePosition: rangePosition,
|
|
180
182
|
sizeProp: size,
|
|
181
183
|
fillContainer: fill
|
|
182
|
-
},
|
|
184
|
+
}, /*#__PURE__*/React.createElement(CalendarDayButton, _extends({
|
|
185
|
+
fill: fill,
|
|
186
|
+
tabIndex: -1,
|
|
187
|
+
plain: true
|
|
188
|
+
}, buttonProps), function (_ref2) {
|
|
189
|
+
var active = _ref2.active,
|
|
190
|
+
hover = _ref2.hover;
|
|
191
|
+
return /*#__PURE__*/React.createElement(StyledDay
|
|
192
|
+
// only apply active styling when using keyboard
|
|
193
|
+
// otherwise apply hover styling
|
|
194
|
+
, _extends({
|
|
195
|
+
active: usingKeyboard ? active : undefined,
|
|
196
|
+
disabledProp: buttonProps.disabled,
|
|
197
|
+
hover: hover,
|
|
198
|
+
inRange: isInRange,
|
|
199
|
+
isSelected: isSelected,
|
|
200
|
+
otherMonth: otherMonth,
|
|
201
|
+
sizeProp: size,
|
|
202
|
+
fillContainer: fill
|
|
203
|
+
}, passThemeFlag), children);
|
|
204
|
+
}));
|
|
183
205
|
};
|
|
184
|
-
var CalendarCustomDay = function CalendarCustomDay(
|
|
185
|
-
var children =
|
|
186
|
-
fill =
|
|
187
|
-
size =
|
|
188
|
-
buttonProps =
|
|
206
|
+
var CalendarCustomDay = function CalendarCustomDay(_ref3) {
|
|
207
|
+
var children = _ref3.children,
|
|
208
|
+
fill = _ref3.fill,
|
|
209
|
+
size = _ref3.size,
|
|
210
|
+
buttonProps = _ref3.buttonProps;
|
|
189
211
|
if (!buttonProps) {
|
|
190
212
|
return /*#__PURE__*/React.createElement(StyledDayContainer, {
|
|
191
213
|
role: "gridcell",
|
|
@@ -201,34 +223,34 @@ var CalendarCustomDay = function CalendarCustomDay(_ref2) {
|
|
|
201
223
|
fill: fill
|
|
202
224
|
}, buttonProps), children));
|
|
203
225
|
};
|
|
204
|
-
var Calendar = /*#__PURE__*/forwardRef(function (
|
|
205
|
-
var activeDateProp =
|
|
206
|
-
|
|
207
|
-
animate =
|
|
208
|
-
boundsProp =
|
|
209
|
-
children =
|
|
210
|
-
dateProp =
|
|
211
|
-
datesProp =
|
|
212
|
-
daysOfWeek =
|
|
213
|
-
disabled =
|
|
214
|
-
initialFocus =
|
|
215
|
-
fill =
|
|
216
|
-
|
|
217
|
-
firstDayOfWeek =
|
|
218
|
-
header =
|
|
219
|
-
|
|
220
|
-
locale =
|
|
221
|
-
messages =
|
|
222
|
-
onReference =
|
|
223
|
-
onSelect =
|
|
224
|
-
range =
|
|
225
|
-
referenceProp =
|
|
226
|
-
|
|
227
|
-
showAdjacentDays =
|
|
228
|
-
|
|
229
|
-
size =
|
|
230
|
-
timestampProp =
|
|
231
|
-
rest = _objectWithoutPropertiesLoose(
|
|
226
|
+
var Calendar = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
227
|
+
var activeDateProp = _ref4.activeDate,
|
|
228
|
+
_ref4$animate = _ref4.animate,
|
|
229
|
+
animate = _ref4$animate === void 0 ? true : _ref4$animate,
|
|
230
|
+
boundsProp = _ref4.bounds,
|
|
231
|
+
children = _ref4.children,
|
|
232
|
+
dateProp = _ref4.date,
|
|
233
|
+
datesProp = _ref4.dates,
|
|
234
|
+
daysOfWeek = _ref4.daysOfWeek,
|
|
235
|
+
disabled = _ref4.disabled,
|
|
236
|
+
initialFocus = _ref4.initialFocus,
|
|
237
|
+
fill = _ref4.fill,
|
|
238
|
+
_ref4$firstDayOfWeek = _ref4.firstDayOfWeek,
|
|
239
|
+
firstDayOfWeek = _ref4$firstDayOfWeek === void 0 ? 0 : _ref4$firstDayOfWeek,
|
|
240
|
+
header = _ref4.header,
|
|
241
|
+
_ref4$locale = _ref4.locale,
|
|
242
|
+
locale = _ref4$locale === void 0 ? 'en-US' : _ref4$locale,
|
|
243
|
+
messages = _ref4.messages,
|
|
244
|
+
onReference = _ref4.onReference,
|
|
245
|
+
onSelect = _ref4.onSelect,
|
|
246
|
+
range = _ref4.range,
|
|
247
|
+
referenceProp = _ref4.reference,
|
|
248
|
+
_ref4$showAdjacentDay = _ref4.showAdjacentDays,
|
|
249
|
+
showAdjacentDays = _ref4$showAdjacentDay === void 0 ? true : _ref4$showAdjacentDay,
|
|
250
|
+
_ref4$size = _ref4.size,
|
|
251
|
+
size = _ref4$size === void 0 ? 'medium' : _ref4$size,
|
|
252
|
+
timestampProp = _ref4.timestamp,
|
|
253
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
232
254
|
var _useThemeValue2 = useThemeValue(),
|
|
233
255
|
theme = _useThemeValue2.theme,
|
|
234
256
|
passThemeFlag = _useThemeValue2.passThemeFlag;
|
|
@@ -571,7 +593,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
571
593
|
var day = new Date(displayBounds[0]);
|
|
572
594
|
var days = [];
|
|
573
595
|
while (days.length < 7) {
|
|
574
|
-
days.push(
|
|
596
|
+
days.push(/*#__PURE__*/React.createElement(StyledDayContainer, {
|
|
575
597
|
role: "gridcell",
|
|
576
598
|
key: days.length,
|
|
577
599
|
sizeProp: size,
|
|
@@ -597,7 +619,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
597
619
|
var _loop = function _loop() {
|
|
598
620
|
if (day.getDay() === firstDayOfWeek) {
|
|
599
621
|
if (days) {
|
|
600
|
-
weeks.push(
|
|
622
|
+
weeks.push(/*#__PURE__*/React.createElement(StyledWeek, {
|
|
601
623
|
role: "row",
|
|
602
624
|
key: day.getTime(),
|
|
603
625
|
fillContainer: fill
|
|
@@ -607,7 +629,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
607
629
|
}
|
|
608
630
|
var otherMonth = day.getMonth() !== reference.getMonth();
|
|
609
631
|
if (!showAdjacentDays && otherMonth) {
|
|
610
|
-
days.push(
|
|
632
|
+
days.push(/*#__PURE__*/React.createElement(StyledDayContainer, {
|
|
611
633
|
key: day.getTime(),
|
|
612
634
|
sizeProp: size,
|
|
613
635
|
fillContainer: fill
|
|
@@ -629,7 +651,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
629
651
|
we know that all days in the array are from the next month. */
|
|
630
652
|
days.length < day.getDate()) {
|
|
631
653
|
blankWeek = true;
|
|
632
|
-
days.push(
|
|
654
|
+
days.push(/*#__PURE__*/React.createElement(StyledDayContainer, {
|
|
633
655
|
key: day.getTime(),
|
|
634
656
|
sizeProp: size,
|
|
635
657
|
fillContainer: fill
|
|
@@ -642,18 +664,22 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
642
664
|
// this.dayRefs[dateObject] = React.createRef();
|
|
643
665
|
var selected = false;
|
|
644
666
|
var inRange = false;
|
|
645
|
-
var
|
|
667
|
+
var rangePosition;
|
|
668
|
+
var _withinDates = withinDates(day, range ? normalizeRange(value, activeDate) : value),
|
|
669
|
+
selectedState = _withinDates[0];
|
|
646
670
|
if (selectedState === 2) {
|
|
647
671
|
selected = true;
|
|
672
|
+
var _withinDates2 = withinDates(day, range ? normalizeRange(value, activeDate) : value);
|
|
673
|
+
rangePosition = _withinDates2[1];
|
|
648
674
|
} else if (selectedState === 1) {
|
|
649
675
|
inRange = true;
|
|
650
676
|
}
|
|
651
|
-
var dayDisabled = withinDates(day, _normalizeInput(disabled)) || bounds && !betweenDates(day, _normalizeInput(bounds));
|
|
677
|
+
var dayDisabled = withinDates(day, _normalizeInput(disabled))[0] || bounds && !betweenDates(day, _normalizeInput(bounds));
|
|
652
678
|
if (!firstDayInMonth && !dayDisabled && day.getMonth() === reference.getMonth()) {
|
|
653
679
|
firstDayInMonth = dateObject;
|
|
654
680
|
}
|
|
655
681
|
if (!children) {
|
|
656
|
-
days.push(
|
|
682
|
+
days.push(/*#__PURE__*/React.createElement(CalendarDay, {
|
|
657
683
|
key: day.getTime(),
|
|
658
684
|
buttonProps: {
|
|
659
685
|
a11yTitle: day.toDateString(),
|
|
@@ -672,11 +698,12 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
672
698
|
isInRange: inRange,
|
|
673
699
|
isSelected: selected,
|
|
674
700
|
otherMonth: day.getMonth() !== reference.getMonth(),
|
|
701
|
+
rangePosition: rangePosition,
|
|
675
702
|
size: size,
|
|
676
703
|
fill: fill
|
|
677
704
|
}, day.getDate()));
|
|
678
705
|
} else {
|
|
679
|
-
days.push(
|
|
706
|
+
days.push(/*#__PURE__*/React.createElement(CalendarCustomDay, {
|
|
680
707
|
key: day.getTime(),
|
|
681
708
|
buttonProps: onSelect ? {
|
|
682
709
|
a11yTitle: day.toDateString(),
|
|
@@ -707,7 +734,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
707
734
|
while (day.getTime() < displayBounds[1].getTime()) {
|
|
708
735
|
_loop();
|
|
709
736
|
}
|
|
710
|
-
weeks.push(
|
|
737
|
+
weeks.push(/*#__PURE__*/React.createElement(StyledWeek
|
|
711
738
|
// if a week contains only blank days, for screen reader accessibility
|
|
712
739
|
// we don't want to set role="row"
|
|
713
740
|
, {
|
|
@@ -752,10 +779,19 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
752
779
|
},
|
|
753
780
|
previousInBound: betweenDates(previousMonth, bounds),
|
|
754
781
|
nextInBound: betweenDates(nextMonth, bounds)
|
|
755
|
-
}) : renderCalendarHeader(previousMonth, nextMonth),
|
|
782
|
+
}) : renderCalendarHeader(previousMonth, nextMonth), /*#__PURE__*/React.createElement(Box, {
|
|
783
|
+
fill: true,
|
|
784
|
+
role: "grid"
|
|
785
|
+
}, daysOfWeek && renderDaysOfWeek(), /*#__PURE__*/React.createElement(Keyboard, {
|
|
756
786
|
onEnter: function onEnter() {
|
|
757
787
|
return active !== undefined ? _onClick(active) : undefined;
|
|
758
788
|
},
|
|
789
|
+
onSpace: function onSpace(event) {
|
|
790
|
+
event.preventDefault();
|
|
791
|
+
if (active !== undefined) {
|
|
792
|
+
_onClick(active);
|
|
793
|
+
}
|
|
794
|
+
},
|
|
759
795
|
onUp: function onUp(event) {
|
|
760
796
|
event.preventDefault();
|
|
761
797
|
event.stopPropagation(); // so the page doesn't scroll
|
|
@@ -786,7 +822,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
786
822
|
}
|
|
787
823
|
}, /*#__PURE__*/React.createElement(StyledWeeksContainer, _extends({
|
|
788
824
|
tabIndex: 0,
|
|
789
|
-
role: "
|
|
825
|
+
role: "rowgroup",
|
|
790
826
|
"aria-label": reference.toLocaleDateString(locale, {
|
|
791
827
|
month: 'long',
|
|
792
828
|
year: 'numeric'
|
|
@@ -810,7 +846,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
810
846
|
slide: slide,
|
|
811
847
|
sizeProp: size,
|
|
812
848
|
fillContainer: fill
|
|
813
|
-
}, passThemeFlag), weeks)))));
|
|
849
|
+
}, passThemeFlag), weeks))))));
|
|
814
850
|
});
|
|
815
851
|
Calendar.displayName = 'Calendar';
|
|
816
852
|
Calendar.propTypes = CalendarPropTypes;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled, { css, keyframes } from 'styled-components';
|
|
2
|
-
import { backgroundStyle, focusStyle, genericStyles, kindPartStyles, parseMetricToNum, styledComponentsConfig } from '../../utils';
|
|
2
|
+
import { backgroundStyle, focusStyle, genericStyles, kindPartStyles, normalizeColor, parseMetricToNum, roundStyle, styledComponentsConfig } from '../../utils';
|
|
3
|
+
import { activeStyle } from '../../utils/background';
|
|
3
4
|
var sizeStyle = function sizeStyle(props) {
|
|
4
5
|
var data = props.theme.calendar[props.sizeProp];
|
|
5
6
|
var width = props.fillContainer ? '100%' : props.theme.global.size[props.sizeProp];
|
|
@@ -45,6 +46,21 @@ var slideStyle = function slideStyle(props) {
|
|
|
45
46
|
var weeksSizeStyle = function weeksSizeStyle() {
|
|
46
47
|
return css(["display:flex;flex-direction:column;height:100%;"]);
|
|
47
48
|
};
|
|
49
|
+
|
|
50
|
+
// fallback to medium if no size-specific styles
|
|
51
|
+
var rangeRoundStyle = function rangeRoundStyle(props) {
|
|
52
|
+
var _props$theme$calendar5, _props$theme$calendar6;
|
|
53
|
+
var themeObj;
|
|
54
|
+
if (props.isSelected) {
|
|
55
|
+
var _props$theme$calendar, _props$theme$calendar2, _props$theme$calendar3, _props$theme$calendar4;
|
|
56
|
+
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);
|
|
57
|
+
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);
|
|
58
|
+
if (props.rangePosition === 'start' && rangeStart) {
|
|
59
|
+
themeObj = rangeStart;
|
|
60
|
+
} else if (props.rangePosition === 'end' && rangeEnd) themeObj = rangeEnd;
|
|
61
|
+
} 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);
|
|
62
|
+
return themeObj && [roundStyle(themeObj, props.responsive, props.theme), 'overflow: hidden;'];
|
|
63
|
+
};
|
|
48
64
|
var StyledWeeks = styled.div.withConfig(styledComponentsConfig).withConfig({
|
|
49
65
|
displayName: "StyledCalendar__StyledWeeks",
|
|
50
66
|
componentId: "sc-1y4xhmp-2"
|
|
@@ -65,27 +81,93 @@ var StyledWeek = styled.div.withConfig(styledComponentsConfig).withConfig({
|
|
|
65
81
|
var StyledDayContainer = styled.div.withConfig(styledComponentsConfig).withConfig({
|
|
66
82
|
displayName: "StyledCalendar__StyledDayContainer",
|
|
67
83
|
componentId: "sc-1y4xhmp-4"
|
|
68
|
-
})(["flex:0 1 auto;", ""], function (props) {
|
|
84
|
+
})(["flex:0 1 auto;", " ", " ", ""], function (props) {
|
|
69
85
|
return props.fillContainer && 'width: 14.3%;';
|
|
86
|
+
}, function (props) {
|
|
87
|
+
var _props$theme$calendar7;
|
|
88
|
+
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) && backgroundStyle(props.theme.calendar.range.background, props.theme);
|
|
89
|
+
}, function (props) {
|
|
90
|
+
return rangeRoundStyle(props);
|
|
70
91
|
});
|
|
71
92
|
var daySizeStyle = function daySizeStyle(props) {
|
|
72
93
|
var data = props.theme.calendar[props.sizeProp];
|
|
73
94
|
return css(["width:", ";height:", ";"], props.fillContainer ? '100%' : data.daySize, props.fillContainer ? '100%' : data.daySize);
|
|
74
95
|
};
|
|
96
|
+
var dayStyle = function dayStyle(props) {
|
|
97
|
+
var backgroundObj;
|
|
98
|
+
var colorObj;
|
|
99
|
+
if (props.isSelected) {
|
|
100
|
+
var _props$theme$calendar8, _props$theme$calendar9;
|
|
101
|
+
backgroundObj = ((_props$theme$calendar8 = props.theme.calendar.day) == null || (_props$theme$calendar8 = _props$theme$calendar8.selected) == null ? void 0 : _props$theme$calendar8.background) || 'control';
|
|
102
|
+
colorObj = (_props$theme$calendar9 = props.theme.calendar.day) == null || (_props$theme$calendar9 = _props$theme$calendar9.selected) == null ? void 0 : _props$theme$calendar9.color;
|
|
103
|
+
} else if (props.inRange) {
|
|
104
|
+
var _props$theme$calendar10, _props$theme$calendar11, _props$theme$calendar12, _props$theme$calendar13;
|
|
105
|
+
// for backwards compatability, only apply this if caller hasn't specified
|
|
106
|
+
// range specific rounding
|
|
107
|
+
// if they have, background will be applied to StyledDayContainer
|
|
108
|
+
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) || {
|
|
109
|
+
color: 'control',
|
|
110
|
+
opacity: 'weak'
|
|
111
|
+
});
|
|
112
|
+
colorObj = (_props$theme$calendar13 = props.theme.calendar.day) == null || (_props$theme$calendar13 = _props$theme$calendar13.inRange) == null ? void 0 : _props$theme$calendar13.color;
|
|
113
|
+
} else {
|
|
114
|
+
var _props$theme$calendar14, _props$theme$calendar15;
|
|
115
|
+
backgroundObj = (_props$theme$calendar14 = props.theme.calendar.day) == null ? void 0 : _props$theme$calendar14.background;
|
|
116
|
+
colorObj = (_props$theme$calendar15 = props.theme.calendar.day) == null ? void 0 : _props$theme$calendar15.color;
|
|
117
|
+
}
|
|
118
|
+
if (colorObj && !backgroundObj) return "color: " + normalizeColor(colorObj, props.theme) + ";";
|
|
119
|
+
return backgroundStyle(backgroundObj, props.theme, colorObj);
|
|
120
|
+
};
|
|
121
|
+
var dayHoverStyle = function dayHoverStyle(props) {
|
|
122
|
+
var backgroundObj;
|
|
123
|
+
var colorObj;
|
|
124
|
+
if (props.isSelected) {
|
|
125
|
+
var _props$theme$calendar16, _props$theme$calendar17;
|
|
126
|
+
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;
|
|
127
|
+
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;
|
|
128
|
+
} else if (props.inRange) {
|
|
129
|
+
var _props$theme$calendar18, _props$theme$calendar19;
|
|
130
|
+
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;
|
|
131
|
+
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;
|
|
132
|
+
} else {
|
|
133
|
+
var _props$theme$calendar20, _props$theme$calendar21;
|
|
134
|
+
backgroundObj = (_props$theme$calendar20 = props.theme.calendar.day) == null || (_props$theme$calendar20 = _props$theme$calendar20.hover) == null ? void 0 : _props$theme$calendar20.background;
|
|
135
|
+
colorObj = (_props$theme$calendar21 = props.theme.calendar.day) == null || (_props$theme$calendar21 = _props$theme$calendar21.hover) == null ? void 0 : _props$theme$calendar21.color;
|
|
136
|
+
}
|
|
137
|
+
if (colorObj && !backgroundObj) return "color: " + normalizeColor(colorObj, props.theme) + ";";
|
|
138
|
+
return backgroundStyle(backgroundObj, props.theme, colorObj);
|
|
139
|
+
};
|
|
140
|
+
var dayFontStyle = function dayFontStyle(props) {
|
|
141
|
+
var fontWeight;
|
|
142
|
+
if (props.isSelected) {
|
|
143
|
+
var _props$theme$calendar22;
|
|
144
|
+
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;
|
|
145
|
+
} else if (props.inRange) {
|
|
146
|
+
var _props$theme$calendar23;
|
|
147
|
+
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;
|
|
148
|
+
}
|
|
149
|
+
return fontWeight && "font-weight: " + fontWeight + ";";
|
|
150
|
+
};
|
|
75
151
|
var StyledDay = styled.div.withConfig(styledComponentsConfig).withConfig({
|
|
76
152
|
displayName: "StyledCalendar__StyledDay",
|
|
77
153
|
componentId: "sc-1y4xhmp-5"
|
|
78
|
-
})(["display:flex;justify-content:center;align-items:center;", " ", " ", " ", " ", " ", ""], function (props) {
|
|
154
|
+
})(["display:flex;justify-content:center;align-items:center;", " ", " ", " ", " ", " ", " ", " ", " ", ""], function (props) {
|
|
79
155
|
return daySizeStyle(props);
|
|
80
156
|
}, function (props) {
|
|
81
|
-
return
|
|
82
|
-
color: 'control',
|
|
83
|
-
opacity: 'weak'
|
|
84
|
-
}, props.theme);
|
|
157
|
+
return dayStyle(props);
|
|
85
158
|
}, function (props) {
|
|
86
159
|
return props.otherMonth && 'opacity: 0.5;';
|
|
87
160
|
}, function (props) {
|
|
88
|
-
return props
|
|
161
|
+
return dayFontStyle(props);
|
|
162
|
+
}, function (props) {
|
|
163
|
+
var _props$theme$calendar24, _props$theme$calendar25;
|
|
164
|
+
// fallback to medium if no size-specific styles
|
|
165
|
+
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);
|
|
166
|
+
return round && roundStyle(round, props.responsive, props.theme);
|
|
167
|
+
}, function (props) {
|
|
168
|
+
return props.active && activeStyle;
|
|
169
|
+
}, function (props) {
|
|
170
|
+
return props.hover && dayHoverStyle(props);
|
|
89
171
|
}, function (props) {
|
|
90
172
|
return (
|
|
91
173
|
// when theme uses kind Buttons, since we use children for Button,
|