baseui 10.2.1 → 10.6.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/button/styled-components.js +1 -1
- package/button/styled-components.js.flow +4 -1
- package/data-table/data-table.js +13 -3
- package/data-table/data-table.js.flow +20 -4
- package/data-table/types.js.flow +2 -1
- package/datepicker/calendar-header.js +227 -95
- package/datepicker/calendar-header.js.flow +270 -139
- package/datepicker/constants.js +4 -2
- package/datepicker/constants.js.flow +2 -0
- package/datepicker/day.js +1 -0
- package/datepicker/day.js.flow +1 -0
- package/datepicker/index.d.ts +1 -0
- package/datepicker/types.js.flow +1 -0
- package/datepicker/utils/calendar-header-helpers.js +51 -0
- package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
- package/dnd-list/index.js.flow +2 -1
- package/drawer/close-icon.js +3 -2
- package/drawer/close-icon.js.flow +2 -2
- package/drawer/drawer.js +5 -2
- package/drawer/drawer.js.flow +2 -2
- package/es/button/styled-components.js +1 -1
- package/es/data-table/data-table.js +13 -3
- package/es/datepicker/calendar-header.js +184 -84
- package/es/datepicker/constants.js +2 -1
- package/es/datepicker/day.js +1 -0
- package/es/datepicker/utils/calendar-header-helpers.js +34 -0
- package/es/dnd-list/index.js +2 -1
- package/es/drawer/close-icon.js +3 -2
- package/es/drawer/drawer.js +5 -2
- package/es/list/list-heading.js +17 -6
- package/es/map-marker/constants.js +69 -0
- package/es/map-marker/fixed-marker.js +98 -0
- package/es/map-marker/floating-marker.js +65 -0
- package/es/map-marker/index.js +9 -0
- package/es/map-marker/pin-head.js +108 -0
- package/es/map-marker/styled-components.js +156 -0
- package/es/map-marker/types.js +8 -0
- package/es/popover/stateful-container.js +4 -0
- package/es/rating/emoticon-rating.js +3 -1
- package/es/rating/star-rating.js +3 -1
- package/es/select/select-component.js +20 -6
- package/es/select/styled-components.js +34 -4
- package/es/snackbar/snackbar-context.js +16 -4
- package/es/spinner/styled-components.js +1 -1
- package/es/table-semantic/styled-components.js +6 -4
- package/es/table-semantic/table-builder.js +3 -0
- package/es/themes/dark-theme/color-component-tokens.js +1 -1
- package/es/themes/dark-theme/color-semantic-tokens.js +8 -7
- package/es/themes/light-theme/color-component-tokens.js +9 -9
- package/es/themes/light-theme/color-semantic-tokens.js +3 -2
- package/es/tokens/colors.js +2 -2
- package/es/tooltip/styled-components.js +8 -0
- package/esm/button/styled-components.js +1 -1
- package/esm/data-table/data-table.js +13 -3
- package/esm/datepicker/calendar-header.js +226 -95
- package/esm/datepicker/constants.js +2 -1
- package/esm/datepicker/day.js +1 -0
- package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
- package/esm/dnd-list/index.js +2 -1
- package/esm/drawer/close-icon.js +3 -2
- package/esm/drawer/drawer.js +5 -2
- package/esm/list/list-heading.js +17 -6
- package/esm/map-marker/constants.js +62 -0
- package/esm/map-marker/fixed-marker.js +137 -0
- package/esm/map-marker/floating-marker.js +94 -0
- package/esm/map-marker/index.js +9 -0
- package/esm/map-marker/pin-head.js +144 -0
- package/esm/map-marker/styled-components.js +168 -0
- package/esm/map-marker/types.js +8 -0
- package/esm/popover/stateful-container.js +4 -0
- package/esm/rating/emoticon-rating.js +2 -2
- package/esm/rating/star-rating.js +2 -2
- package/esm/select/select-component.js +19 -6
- package/esm/select/styled-components.js +28 -4
- package/esm/snackbar/snackbar-context.js +16 -4
- package/esm/spinner/styled-components.js +1 -1
- package/esm/table-semantic/styled-components.js +6 -4
- package/esm/table-semantic/table-builder.js +3 -0
- package/esm/themes/dark-theme/color-component-tokens.js +1 -1
- package/esm/themes/dark-theme/color-semantic-tokens.js +8 -7
- package/esm/themes/light-theme/color-component-tokens.js +9 -9
- package/esm/themes/light-theme/color-semantic-tokens.js +3 -2
- package/esm/tokens/colors.js +2 -2
- package/esm/tooltip/styled-components.js +8 -0
- package/index.d.ts +1 -0
- package/link/index.d.ts +1 -0
- package/list/index.d.ts +36 -0
- package/list/list-heading.js +24 -7
- package/list/list-heading.js.flow +17 -8
- package/map-marker/constants.js +82 -0
- package/map-marker/constants.js.flow +74 -0
- package/map-marker/fixed-marker.js +152 -0
- package/map-marker/fixed-marker.js.flow +137 -0
- package/map-marker/floating-marker.js +109 -0
- package/map-marker/floating-marker.js.flow +102 -0
- package/map-marker/index.d.ts +104 -0
- package/map-marker/index.js +55 -0
- package/map-marker/index.js.flow +23 -0
- package/map-marker/package.json +4 -0
- package/map-marker/pin-head.js +159 -0
- package/map-marker/pin-head.js.flow +155 -0
- package/map-marker/styled-components.js +184 -0
- package/map-marker/styled-components.js.flow +177 -0
- package/map-marker/types.js +11 -0
- package/map-marker/types.js.flow +114 -0
- package/menu/index.d.ts +7 -0
- package/menu/types.js.flow +12 -0
- package/package.json +3 -2
- package/popover/stateful-container.js +4 -0
- package/popover/stateful-container.js.flow +3 -0
- package/rating/emoticon-rating.js +2 -2
- package/rating/emoticon-rating.js.flow +4 -1
- package/rating/star-rating.js +2 -2
- package/rating/star-rating.js.flow +4 -1
- package/select/select-component.js +19 -6
- package/select/select-component.js.flow +19 -6
- package/select/styled-components.js +28 -4
- package/select/styled-components.js.flow +30 -2
- package/select/types.js.flow +9 -0
- package/snackbar/snackbar-context.js +15 -4
- package/snackbar/snackbar-context.js.flow +15 -3
- package/spinner/styled-components.js +1 -1
- package/spinner/styled-components.js.flow +1 -1
- package/table-semantic/index.d.ts +1 -0
- package/table-semantic/styled-components.js +6 -4
- package/table-semantic/styled-components.js.flow +6 -4
- package/table-semantic/table-builder.js +3 -0
- package/table-semantic/table-builder.js.flow +3 -0
- package/theme.ts +2 -0
- package/themes/dark-theme/color-component-tokens.js +1 -1
- package/themes/dark-theme/color-component-tokens.js.flow +1 -1
- package/themes/dark-theme/color-semantic-tokens.js +8 -7
- package/themes/dark-theme/color-semantic-tokens.js.flow +7 -6
- package/themes/light-theme/color-component-tokens.js +9 -9
- package/themes/light-theme/color-component-tokens.js.flow +9 -9
- package/themes/light-theme/color-semantic-tokens.js +3 -2
- package/themes/light-theme/color-semantic-tokens.js.flow +2 -1
- package/themes/types.js.flow +1 -0
- package/tokens/colors.js +2 -2
- package/tokens/colors.js.flow +2 -2
- package/tooltip/styled-components.js +8 -0
- package/tooltip/styled-components.js.flow +8 -0
|
@@ -48,7 +48,7 @@ var BaseButton = (0, _index.styled)('button', function (_ref) {
|
|
|
48
48
|
cursor: 'pointer',
|
|
49
49
|
':disabled': {
|
|
50
50
|
cursor: 'not-allowed',
|
|
51
|
-
backgroundColor: $theme.colors.buttonDisabledFill,
|
|
51
|
+
backgroundColor: $kind === _constants.KIND.minimal || $kind === _constants.KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
|
|
52
52
|
color: $theme.colors.buttonDisabledText
|
|
53
53
|
},
|
|
54
54
|
marginLeft: 0,
|
|
@@ -46,7 +46,10 @@ export const BaseButton = styled<SharedStylePropsT>(
|
|
|
46
46
|
cursor: 'pointer',
|
|
47
47
|
':disabled': {
|
|
48
48
|
cursor: 'not-allowed',
|
|
49
|
-
backgroundColor:
|
|
49
|
+
backgroundColor:
|
|
50
|
+
$kind === KIND.minimal || $kind === KIND.tertiary
|
|
51
|
+
? 'transparent'
|
|
52
|
+
: $theme.colors.buttonDisabledFill,
|
|
50
53
|
color: $theme.colors.buttonDisabledText,
|
|
51
54
|
},
|
|
52
55
|
marginLeft: 0,
|
package/data-table/data-table.js
CHANGED
|
@@ -445,11 +445,12 @@ var InnerTableElement = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
445
445
|
viewState = EMPTY;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
var highlightedRow = ctx.rows[ctx.rowHighlightIndex - 1];
|
|
448
449
|
return /*#__PURE__*/React.createElement("div", {
|
|
449
450
|
ref: ref,
|
|
450
451
|
"data-baseweb": "data-table",
|
|
451
452
|
style: props.style
|
|
452
|
-
}, /*#__PURE__*/React.createElement(Headers, null), viewState === LOADING && /*#__PURE__*/React.createElement(LoadingOrEmptyMessage, null, ctx.loadingMessage), viewState === EMPTY && /*#__PURE__*/React.createElement(LoadingOrEmptyMessage, null, ctx.emptyMessage), viewState === RENDERING && props.children, ctx.rowActions && Boolean(ctx.rowActions.length) && ctx.rowHighlightIndex > 0 && Boolean(
|
|
453
|
+
}, /*#__PURE__*/React.createElement(Headers, null), viewState === LOADING && /*#__PURE__*/React.createElement(LoadingOrEmptyMessage, null, ctx.loadingMessage), viewState === EMPTY && /*#__PURE__*/React.createElement(LoadingOrEmptyMessage, null, ctx.emptyMessage), viewState === RENDERING && props.children, ctx.rowActions && Boolean(ctx.rowActions.length) && ctx.rowHighlightIndex > 0 && Boolean(highlightedRow) && !ctx.isScrollingX && /*#__PURE__*/React.createElement("div", {
|
|
453
454
|
style: {
|
|
454
455
|
alignItems: 'center',
|
|
455
456
|
backgroundColor: theme.colors.backgroundTertiary,
|
|
@@ -463,7 +464,12 @@ var InnerTableElement = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
463
464
|
left: theme.direction === 'rtl' ? 0 : 'initial',
|
|
464
465
|
top: (ctx.rowHighlightIndex - 1) * ctx.rowHeight + HEADER_ROW_HEIGHT
|
|
465
466
|
}
|
|
466
|
-
}, ctx.rowActions.map(function (rowAction) {
|
|
467
|
+
}, (typeof ctx.rowActions === 'function' ? ctx.rowActions(highlightedRow) : ctx.rowActions).map(function (rowAction) {
|
|
468
|
+
if (rowAction.renderButton) {
|
|
469
|
+
var RowActionButton = rowAction.renderButton;
|
|
470
|
+
return /*#__PURE__*/React.createElement(RowActionButton, null);
|
|
471
|
+
}
|
|
472
|
+
|
|
467
473
|
var RowActionIcon = rowAction.renderIcon;
|
|
468
474
|
return /*#__PURE__*/React.createElement(_index.Button, {
|
|
469
475
|
alt: rowAction.label,
|
|
@@ -480,7 +486,11 @@ var InnerTableElement = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
480
486
|
overrides: {
|
|
481
487
|
BaseButton: {
|
|
482
488
|
style: {
|
|
483
|
-
marginLeft: theme.sizing.scale300
|
|
489
|
+
marginLeft: theme.sizing.scale300,
|
|
490
|
+
paddingTop: theme.sizing.scale100,
|
|
491
|
+
paddingRight: theme.sizing.scale100,
|
|
492
|
+
paddingBottom: theme.sizing.scale100,
|
|
493
|
+
paddingLeft: theme.sizing.scale100
|
|
484
494
|
}
|
|
485
495
|
}
|
|
486
496
|
}
|
|
@@ -53,7 +53,7 @@ type HeaderContextT = {|
|
|
|
53
53
|
onSelectNone: () => void,
|
|
54
54
|
onSort: number => void,
|
|
55
55
|
resizableColumnWidths: boolean,
|
|
56
|
-
rowActions: RowActionT[],
|
|
56
|
+
rowActions: RowActionT[] | (RowT => RowActionT[]),
|
|
57
57
|
rowHeight: number,
|
|
58
58
|
rowHighlightIndex: number,
|
|
59
59
|
rows: RowT[],
|
|
@@ -554,6 +554,8 @@ const InnerTableElement = React.forwardRef<
|
|
|
554
554
|
viewState = EMPTY;
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
+
const highlightedRow = ctx.rows[ctx.rowHighlightIndex - 1];
|
|
558
|
+
|
|
557
559
|
return (
|
|
558
560
|
<div ref={ref} data-baseweb="data-table" style={props.style}>
|
|
559
561
|
<Headers />
|
|
@@ -571,7 +573,7 @@ const InnerTableElement = React.forwardRef<
|
|
|
571
573
|
{ctx.rowActions &&
|
|
572
574
|
Boolean(ctx.rowActions.length) &&
|
|
573
575
|
ctx.rowHighlightIndex > 0 &&
|
|
574
|
-
Boolean(
|
|
576
|
+
Boolean(highlightedRow) &&
|
|
575
577
|
!ctx.isScrollingX && (
|
|
576
578
|
<div
|
|
577
579
|
style={{
|
|
@@ -589,7 +591,15 @@ const InnerTableElement = React.forwardRef<
|
|
|
589
591
|
(ctx.rowHighlightIndex - 1) * ctx.rowHeight + HEADER_ROW_HEIGHT,
|
|
590
592
|
}}
|
|
591
593
|
>
|
|
592
|
-
{ctx.rowActions
|
|
594
|
+
{(typeof ctx.rowActions === 'function'
|
|
595
|
+
? ctx.rowActions(highlightedRow)
|
|
596
|
+
: ctx.rowActions
|
|
597
|
+
).map(rowAction => {
|
|
598
|
+
if (rowAction.renderButton) {
|
|
599
|
+
const RowActionButton = rowAction.renderButton;
|
|
600
|
+
return <RowActionButton />;
|
|
601
|
+
}
|
|
602
|
+
|
|
593
603
|
const RowActionIcon = rowAction.renderIcon;
|
|
594
604
|
return (
|
|
595
605
|
<Button
|
|
@@ -606,7 +616,13 @@ const InnerTableElement = React.forwardRef<
|
|
|
606
616
|
shape={BUTTON_SHAPES.round}
|
|
607
617
|
overrides={{
|
|
608
618
|
BaseButton: {
|
|
609
|
-
style: {
|
|
619
|
+
style: {
|
|
620
|
+
marginLeft: theme.sizing.scale300,
|
|
621
|
+
paddingTop: theme.sizing.scale100,
|
|
622
|
+
paddingRight: theme.sizing.scale100,
|
|
623
|
+
paddingBottom: theme.sizing.scale100,
|
|
624
|
+
paddingLeft: theme.sizing.scale100,
|
|
625
|
+
},
|
|
610
626
|
},
|
|
611
627
|
}}
|
|
612
628
|
>
|
package/data-table/types.js.flow
CHANGED
|
@@ -87,6 +87,7 @@ export type RowActionT = {|
|
|
|
87
87
|
label: string,
|
|
88
88
|
onClick: ({event: SyntheticEvent<HTMLButtonElement>, row: RowT}) => mixed,
|
|
89
89
|
renderIcon: React.AbstractComponent<{|size: number|}>,
|
|
90
|
+
renderButton?: React.AbstractComponent<{||}>,
|
|
90
91
|
|};
|
|
91
92
|
|
|
92
93
|
export type StatefulDataTablePropsT = {|
|
|
@@ -107,7 +108,7 @@ export type StatefulDataTablePropsT = {|
|
|
|
107
108
|
onSelectionChange?: (RowT[]) => mixed,
|
|
108
109
|
resizableColumnWidths?: boolean,
|
|
109
110
|
rows: RowT[],
|
|
110
|
-
rowActions?: RowActionT[],
|
|
111
|
+
rowActions?: RowActionT[] | (RowT => RowActionT[]),
|
|
111
112
|
rowHeight?: number,
|
|
112
113
|
rowHighlightIndex?: number,
|
|
113
114
|
searchable?: boolean,
|
|
@@ -9,16 +9,18 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chevronRight = _interopRequireDefault(require("../icon/chevron-right.js"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chevronLeft = _interopRequireDefault(require("../icon/chevron-left.js"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chevronDown = _interopRequireDefault(require("../icon/chevron-down.js"));
|
|
17
17
|
|
|
18
18
|
var _dateFnsAdapter = _interopRequireDefault(require("./utils/date-fns-adapter.js"));
|
|
19
19
|
|
|
20
20
|
var _dateHelpers = _interopRequireDefault(require("./utils/date-helpers.js"));
|
|
21
21
|
|
|
22
|
+
var _calendarHeaderHelpers = require("./utils/calendar-header-helpers.js");
|
|
23
|
+
|
|
22
24
|
var _index = require("../menu/index.js");
|
|
23
25
|
|
|
24
26
|
var _index2 = require("../popover/index.js");
|
|
@@ -55,6 +57,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
55
57
|
|
|
56
58
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
57
59
|
|
|
60
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
61
|
+
|
|
62
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
63
|
+
|
|
58
64
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
59
65
|
|
|
60
66
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -93,10 +99,6 @@ var DIRECTION = {
|
|
|
93
99
|
PREVIOUS: 'previous'
|
|
94
100
|
};
|
|
95
101
|
|
|
96
|
-
function yearMonthToId(year, month) {
|
|
97
|
-
return "".concat(year, "-").concat(month);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
102
|
function idToYearMonth(id) {
|
|
101
103
|
return id.split('-').map(Number);
|
|
102
104
|
}
|
|
@@ -115,14 +117,13 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
115
117
|
|
|
116
118
|
_defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
|
|
117
119
|
|
|
118
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
120
|
+
_defineProperty(_assertThisInitialized(_this), "monthItems", void 0);
|
|
119
121
|
|
|
120
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
121
|
-
|
|
122
|
-
_defineProperty(_assertThisInitialized(_this), "maxYear", void 0);
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "yearItems", void 0);
|
|
123
123
|
|
|
124
124
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
125
|
-
|
|
125
|
+
isMonthDropdownOpen: false,
|
|
126
|
+
isYearDropdownOpen: false,
|
|
126
127
|
isFocusVisible: false
|
|
127
128
|
});
|
|
128
129
|
|
|
@@ -130,17 +131,94 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
130
131
|
return _this.props.date || _this.dateHelpers.date();
|
|
131
132
|
});
|
|
132
133
|
|
|
133
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
134
|
-
var
|
|
134
|
+
_defineProperty(_assertThisInitialized(_this), "getYearItems", function () {
|
|
135
|
+
var date = _this.getDateProp();
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
var maxDate = _this.props.maxDate;
|
|
138
|
+
var minDate = _this.props.minDate;
|
|
139
|
+
var maxYear = maxDate ? _this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
140
|
+
var minYear = minDate ? _this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
141
|
+
|
|
142
|
+
var selectedMonth = _this.dateHelpers.getMonth(date); // TODO: this logic can be optimized to only run when minDate / maxDate change
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
_this.yearItems = Array.from({
|
|
146
|
+
length: maxYear - minYear + 1
|
|
147
|
+
}, function (_, i) {
|
|
148
|
+
return minYear + i;
|
|
149
|
+
}).map(function (year) {
|
|
150
|
+
return {
|
|
151
|
+
id: year.toString(),
|
|
152
|
+
label: year.toString()
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
var monthOfMaxDate = maxDate ? _this.dateHelpers.getMonth(maxDate) : MAX_MONTH;
|
|
156
|
+
var monthOfMinDate = minDate ? _this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [0,1,.... monthOfMaxDate]
|
|
157
|
+
|
|
158
|
+
var maxYearMonths = Array.from({
|
|
159
|
+
length: monthOfMaxDate + 1
|
|
160
|
+
}, function (x, i) {
|
|
161
|
+
return i;
|
|
162
|
+
}); // Generates array like [monthOfMinDate, ...., 10, 11]
|
|
163
|
+
|
|
164
|
+
var minYearMonths = Array.from({
|
|
165
|
+
length: 12 - monthOfMinDate
|
|
166
|
+
}, function (x, i) {
|
|
167
|
+
return i + monthOfMinDate;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (selectedMonth > maxYearMonths[maxYearMonths.length - 1]) {
|
|
171
|
+
var lastIdx = _this.yearItems.length - 1;
|
|
172
|
+
_this.yearItems[lastIdx] = _objectSpread(_objectSpread({}, _this.yearItems[lastIdx]), {}, {
|
|
173
|
+
disabled: true
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (selectedMonth < minYearMonths[0]) {
|
|
178
|
+
_this.yearItems[0] = _objectSpread(_objectSpread({}, _this.yearItems[0]), {}, {
|
|
179
|
+
disabled: true
|
|
140
180
|
});
|
|
141
181
|
}
|
|
142
182
|
});
|
|
143
183
|
|
|
184
|
+
_defineProperty(_assertThisInitialized(_this), "getMonthItems", function () {
|
|
185
|
+
var date = _this.getDateProp();
|
|
186
|
+
|
|
187
|
+
var year = _this.dateHelpers.getYear(date);
|
|
188
|
+
|
|
189
|
+
var maxDate = _this.props.maxDate;
|
|
190
|
+
var minDate = _this.props.minDate;
|
|
191
|
+
var maxYear = maxDate ? _this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
192
|
+
var minYear = minDate ? _this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
193
|
+
var monthOfMaxDate = maxDate ? _this.dateHelpers.getMonth(maxDate) : MAX_MONTH; // Generates array like [0,1,.... monthOfMaxDate]
|
|
194
|
+
|
|
195
|
+
var maxYearMonths = Array.from({
|
|
196
|
+
length: monthOfMaxDate + 1
|
|
197
|
+
}, function (x, i) {
|
|
198
|
+
return i;
|
|
199
|
+
});
|
|
200
|
+
var monthOfMinDate = minDate ? _this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [monthOfMinDate, ...., 10, 11]
|
|
201
|
+
|
|
202
|
+
var minYearMonths = Array.from({
|
|
203
|
+
length: 12 - monthOfMinDate
|
|
204
|
+
}, function (x, i) {
|
|
205
|
+
return i + monthOfMinDate;
|
|
206
|
+
});
|
|
207
|
+
var maxMinYearMonthsIntersection = maxYearMonths.filter(function (year) {
|
|
208
|
+
return minYearMonths.includes(year);
|
|
209
|
+
});
|
|
210
|
+
var filterMonthsList = year === maxYear && year === minYear ? maxMinYearMonthsIntersection : year === maxYear ? maxYearMonths : year === minYear ? minYearMonths : null;
|
|
211
|
+
|
|
212
|
+
var formatMonthLabel = function formatMonthLabel(month) {
|
|
213
|
+
return _this.dateHelpers.getMonthInLocale(month, _this.props.locale);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
_this.monthItems = (0, _calendarHeaderHelpers.getFilteredMonthItems)({
|
|
217
|
+
filterMonthsList: filterMonthsList,
|
|
218
|
+
formatMonthLabel: formatMonthLabel
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
144
222
|
_defineProperty(_assertThisInitialized(_this), "increaseMonth", function () {
|
|
145
223
|
if (_this.props.onMonthChange) {
|
|
146
224
|
// $FlowFixMe
|
|
@@ -208,9 +286,9 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
208
286
|
}
|
|
209
287
|
});
|
|
210
288
|
|
|
211
|
-
_defineProperty(_assertThisInitialized(_this), "renderPreviousMonthButton", function (
|
|
212
|
-
var locale =
|
|
213
|
-
theme =
|
|
289
|
+
_defineProperty(_assertThisInitialized(_this), "renderPreviousMonthButton", function (_ref2) {
|
|
290
|
+
var locale = _ref2.locale,
|
|
291
|
+
theme = _ref2.theme;
|
|
214
292
|
|
|
215
293
|
var date = _this.getDateProp();
|
|
216
294
|
|
|
@@ -244,7 +322,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
244
322
|
PrevButton = _getOverrides2[0],
|
|
245
323
|
prevButtonProps = _getOverrides2[1];
|
|
246
324
|
|
|
247
|
-
var _getOverrides3 = (0, _overrides.getOverrides)(overrides.PrevButtonIcon, theme.direction === 'rtl' ?
|
|
325
|
+
var _getOverrides3 = (0, _overrides.getOverrides)(overrides.PrevButtonIcon, theme.direction === 'rtl' ? _chevronRight.default : _chevronLeft.default),
|
|
248
326
|
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
249
327
|
PrevButtonIcon = _getOverrides4[0],
|
|
250
328
|
prevButtonIconProps = _getOverrides4[1];
|
|
@@ -274,9 +352,9 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
274
352
|
}, prevButtonIconProps)));
|
|
275
353
|
});
|
|
276
354
|
|
|
277
|
-
_defineProperty(_assertThisInitialized(_this), "renderNextMonthButton", function (
|
|
278
|
-
var locale =
|
|
279
|
-
theme =
|
|
355
|
+
_defineProperty(_assertThisInitialized(_this), "renderNextMonthButton", function (_ref3) {
|
|
356
|
+
var locale = _ref3.locale,
|
|
357
|
+
theme = _ref3.theme;
|
|
280
358
|
|
|
281
359
|
var date = _this.getDateProp();
|
|
282
360
|
|
|
@@ -310,7 +388,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
310
388
|
NextButton = _getOverrides6[0],
|
|
311
389
|
nextButtonProps = _getOverrides6[1];
|
|
312
390
|
|
|
313
|
-
var _getOverrides7 = (0, _overrides.getOverrides)(overrides.NextButtonIcon, theme.direction === 'rtl' ?
|
|
391
|
+
var _getOverrides7 = (0, _overrides.getOverrides)(overrides.NextButtonIcon, theme.direction === 'rtl' ? _chevronLeft.default : _chevronRight.default),
|
|
314
392
|
_getOverrides8 = _slicedToArray(_getOverrides7, 2),
|
|
315
393
|
NextButtonIcon = _getOverrides8[0],
|
|
316
394
|
nextButtonIconProps = _getOverrides8[1];
|
|
@@ -345,7 +423,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
345
423
|
});
|
|
346
424
|
|
|
347
425
|
_defineProperty(_assertThisInitialized(_this), "canArrowsOpenDropdown", function (event) {
|
|
348
|
-
if (!_this.state.
|
|
426
|
+
if (!_this.state.isMonthDropdownOpen && !_this.state.isYearDropdownOpen) {
|
|
349
427
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
350
428
|
return true;
|
|
351
429
|
}
|
|
@@ -357,10 +435,12 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
357
435
|
_defineProperty(_assertThisInitialized(_this), "renderMonthYearDropdown", function () {
|
|
358
436
|
var date = _this.getDateProp();
|
|
359
437
|
|
|
438
|
+
var month = _this.dateHelpers.getMonth(date);
|
|
439
|
+
|
|
440
|
+
var year = _this.dateHelpers.getYear(date);
|
|
441
|
+
|
|
360
442
|
var _this$props3 = _this.props,
|
|
361
443
|
locale = _this$props3.locale,
|
|
362
|
-
maxDate = _this$props3.maxDate,
|
|
363
|
-
minDate = _this$props3.minDate,
|
|
364
444
|
_this$props3$override = _this$props3.overrides,
|
|
365
445
|
overrides = _this$props3$override === void 0 ? {} : _this$props3$override;
|
|
366
446
|
|
|
@@ -395,115 +475,144 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
395
475
|
menuProps && menuProps.overrides); // $FlowFixMe
|
|
396
476
|
|
|
397
477
|
menuProps.overrides = menuOverrides;
|
|
398
|
-
var defaultMonths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
399
|
-
var maxYear = maxDate ? _this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
400
|
-
var minYear = minDate ? _this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
401
|
-
var maxDateMonth = maxDate ? _this.dateHelpers.getMonth(maxDate) : MAX_MONTH; // Generates array like [0,1,.... maxDateMonth]
|
|
402
478
|
|
|
403
|
-
var
|
|
404
|
-
|
|
405
|
-
}, function (x, i) {
|
|
406
|
-
return i;
|
|
479
|
+
var initialMonthIndex = _this.monthItems.findIndex(function (month) {
|
|
480
|
+
return month.id === _this.dateHelpers.getMonth(date).toString();
|
|
407
481
|
});
|
|
408
|
-
var minDateMonth = minDate ? _this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [minDateMonth, ...., 10, 11]
|
|
409
482
|
|
|
410
|
-
var
|
|
411
|
-
|
|
412
|
-
}, function (x, i) {
|
|
413
|
-
return i + minDateMonth;
|
|
483
|
+
var initialYearIndex = _this.yearItems.findIndex(function (year) {
|
|
484
|
+
return year.id === _this.dateHelpers.getYear(date).toString();
|
|
414
485
|
});
|
|
415
486
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
487
|
+
var monthTitle = "".concat(_this.dateHelpers.getMonthInLocale(_this.dateHelpers.getMonth(date), locale));
|
|
488
|
+
var yearTitle = "".concat(_this.dateHelpers.getYear(date));
|
|
489
|
+
return _this.isMultiMonthHorizontal() ? /*#__PURE__*/React.createElement("div", null, "".concat(monthTitle, " ").concat(yearTitle)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
490
|
+
placement: "bottom",
|
|
491
|
+
autoFocus: true,
|
|
492
|
+
focusLock: true,
|
|
493
|
+
isOpen: _this.state.isMonthDropdownOpen,
|
|
494
|
+
onClick: function onClick() {
|
|
495
|
+
_this.setState(function (prev) {
|
|
496
|
+
return {
|
|
497
|
+
isMonthDropdownOpen: !prev.isMonthDropdownOpen
|
|
498
|
+
};
|
|
499
|
+
});
|
|
500
|
+
},
|
|
501
|
+
onClickOutside: function onClickOutside() {
|
|
502
|
+
return _this.setState({
|
|
503
|
+
isMonthDropdownOpen: false
|
|
504
|
+
});
|
|
505
|
+
},
|
|
506
|
+
onEsc: function onEsc() {
|
|
507
|
+
return _this.setState({
|
|
508
|
+
isMonthDropdownOpen: false
|
|
509
|
+
});
|
|
510
|
+
},
|
|
511
|
+
content: function content() {
|
|
512
|
+
return /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
|
|
513
|
+
initialState: {
|
|
514
|
+
highlightedIndex: initialMonthIndex,
|
|
515
|
+
isFocused: true
|
|
516
|
+
},
|
|
517
|
+
items: _this.monthItems,
|
|
518
|
+
onItemSelect: function onItemSelect(_ref4) {
|
|
519
|
+
var item = _ref4.item,
|
|
520
|
+
event = _ref4.event;
|
|
521
|
+
event.preventDefault();
|
|
522
|
+
var month = idToYearMonth(item.id);
|
|
523
|
+
|
|
524
|
+
var updatedDate = _this.dateHelpers.set(date, {
|
|
525
|
+
year: year,
|
|
526
|
+
month: month
|
|
527
|
+
});
|
|
420
528
|
|
|
421
|
-
|
|
422
|
-
|
|
529
|
+
_this.props.onMonthChange && _this.props.onMonthChange({
|
|
530
|
+
date: updatedDate
|
|
531
|
+
});
|
|
423
532
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
533
|
+
_this.setState({
|
|
534
|
+
isMonthDropdownOpen: false
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
}, menuProps));
|
|
538
|
+
}
|
|
539
|
+
}, popoverProps), /*#__PURE__*/React.createElement(MonthYearSelectButton, _extends({
|
|
540
|
+
"aria-live": "polite",
|
|
541
|
+
type: "button",
|
|
542
|
+
$isFocusVisible: _this.state.isFocusVisible,
|
|
543
|
+
onKeyUp: function onKeyUp(event) {
|
|
544
|
+
if (_this.canArrowsOpenDropdown(event)) {
|
|
545
|
+
_this.setState({
|
|
546
|
+
isMonthDropdownOpen: true
|
|
427
547
|
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
onKeyDown: function onKeyDown(event) {
|
|
551
|
+
if (_this.canArrowsOpenDropdown(event)) {
|
|
552
|
+
// disables page scroll
|
|
553
|
+
event.preventDefault();
|
|
434
554
|
}
|
|
435
555
|
|
|
436
|
-
|
|
437
|
-
_this.
|
|
438
|
-
|
|
439
|
-
label: "".concat(_this.dateHelpers.getMonthInLocale(month, locale), " ").concat(i)
|
|
556
|
+
if (event.key === 'Tab') {
|
|
557
|
+
_this.setState({
|
|
558
|
+
isMonthDropdownOpen: false
|
|
440
559
|
});
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
for (var i = minYear; i <= maxYear; i++) {
|
|
445
|
-
_loop(i);
|
|
560
|
+
}
|
|
446
561
|
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
562
|
+
}, monthYearSelectButtonProps), monthTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(_chevronDown.default, {
|
|
563
|
+
title: "",
|
|
564
|
+
overrides: {
|
|
565
|
+
Svg: {
|
|
566
|
+
props: {
|
|
567
|
+
role: 'presentation'
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
})))), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
455
572
|
placement: "bottom",
|
|
456
|
-
autoFocus: true,
|
|
457
573
|
focusLock: true,
|
|
458
|
-
isOpen: _this.state.
|
|
574
|
+
isOpen: _this.state.isYearDropdownOpen,
|
|
459
575
|
onClick: function onClick() {
|
|
460
576
|
_this.setState(function (prev) {
|
|
461
577
|
return {
|
|
462
|
-
|
|
578
|
+
isYearDropdownOpen: !prev.isYearDropdownOpen
|
|
463
579
|
};
|
|
464
580
|
});
|
|
465
581
|
},
|
|
466
582
|
onClickOutside: function onClickOutside() {
|
|
467
583
|
return _this.setState({
|
|
468
|
-
|
|
584
|
+
isYearDropdownOpen: false
|
|
469
585
|
});
|
|
470
586
|
},
|
|
471
587
|
onEsc: function onEsc() {
|
|
472
588
|
return _this.setState({
|
|
473
|
-
|
|
589
|
+
isYearDropdownOpen: false
|
|
474
590
|
});
|
|
475
591
|
},
|
|
476
592
|
content: function content() {
|
|
477
593
|
return /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
|
|
478
594
|
initialState: {
|
|
479
|
-
highlightedIndex:
|
|
595
|
+
highlightedIndex: initialYearIndex,
|
|
480
596
|
isFocused: true
|
|
481
597
|
},
|
|
482
|
-
items: _this.
|
|
598
|
+
items: _this.yearItems,
|
|
483
599
|
onItemSelect: function onItemSelect(_ref5) {
|
|
484
600
|
var item = _ref5.item,
|
|
485
601
|
event = _ref5.event;
|
|
486
602
|
event.preventDefault();
|
|
487
|
-
|
|
488
|
-
var _idToYearMonth = idToYearMonth(item.id),
|
|
489
|
-
_idToYearMonth2 = _slicedToArray(_idToYearMonth, 2),
|
|
490
|
-
year = _idToYearMonth2[0],
|
|
491
|
-
month = _idToYearMonth2[1];
|
|
603
|
+
var year = idToYearMonth(item.id);
|
|
492
604
|
|
|
493
605
|
var updatedDate = _this.dateHelpers.set(date, {
|
|
494
606
|
year: year,
|
|
495
607
|
month: month
|
|
496
608
|
});
|
|
497
609
|
|
|
498
|
-
_this.props.onMonthChange && _this.props.onMonthChange({
|
|
499
|
-
date: updatedDate
|
|
500
|
-
});
|
|
501
610
|
_this.props.onYearChange && _this.props.onYearChange({
|
|
502
611
|
date: updatedDate
|
|
503
612
|
});
|
|
504
613
|
|
|
505
614
|
_this.setState({
|
|
506
|
-
|
|
615
|
+
isYearDropdownOpen: false
|
|
507
616
|
});
|
|
508
617
|
}
|
|
509
618
|
}, menuProps));
|
|
@@ -515,7 +624,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
515
624
|
onKeyUp: function onKeyUp(event) {
|
|
516
625
|
if (_this.canArrowsOpenDropdown(event)) {
|
|
517
626
|
_this.setState({
|
|
518
|
-
|
|
627
|
+
isYearDropdownOpen: true
|
|
519
628
|
});
|
|
520
629
|
}
|
|
521
630
|
},
|
|
@@ -527,11 +636,11 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
527
636
|
|
|
528
637
|
if (event.key === 'Tab') {
|
|
529
638
|
_this.setState({
|
|
530
|
-
|
|
639
|
+
isYearDropdownOpen: false
|
|
531
640
|
});
|
|
532
641
|
}
|
|
533
642
|
}
|
|
534
|
-
}, monthYearSelectButtonProps),
|
|
643
|
+
}, monthYearSelectButtonProps), yearTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(_chevronDown.default, {
|
|
535
644
|
title: "",
|
|
536
645
|
overrides: {
|
|
537
646
|
Svg: {
|
|
@@ -540,15 +649,38 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
540
649
|
}
|
|
541
650
|
}
|
|
542
651
|
}
|
|
543
|
-
}))));
|
|
652
|
+
})))));
|
|
544
653
|
});
|
|
545
654
|
|
|
546
655
|
_this.dateHelpers = new _dateHelpers.default(props.adapter);
|
|
547
|
-
_this.
|
|
656
|
+
_this.monthItems = [];
|
|
657
|
+
_this.yearItems = [];
|
|
548
658
|
return _this;
|
|
549
659
|
}
|
|
550
660
|
|
|
551
661
|
_createClass(CalendarHeader, [{
|
|
662
|
+
key: "componentDidMount",
|
|
663
|
+
value: function componentDidMount() {
|
|
664
|
+
this.getYearItems();
|
|
665
|
+
this.getMonthItems();
|
|
666
|
+
}
|
|
667
|
+
}, {
|
|
668
|
+
key: "componentDidUpdate",
|
|
669
|
+
value: function componentDidUpdate(prevProps) {
|
|
670
|
+
var selectedMonthDidChange = this.dateHelpers.getMonth(this.props.date) !== this.dateHelpers.getMonth(prevProps.date);
|
|
671
|
+
var selectedYearDidChange = this.dateHelpers.getYear(this.props.date) !== this.dateHelpers.getYear(prevProps.date);
|
|
672
|
+
|
|
673
|
+
if (selectedMonthDidChange) {
|
|
674
|
+
// re-calculate yearItems
|
|
675
|
+
this.getYearItems();
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (selectedYearDidChange) {
|
|
679
|
+
// re-calculate monthItems
|
|
680
|
+
this.getMonthItems();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}, {
|
|
552
684
|
key: "render",
|
|
553
685
|
value: function render() {
|
|
554
686
|
var _this2 = this;
|