@primer/components 0.0.0-202192801738 → 0.0.0-20219283497

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.
Files changed (134) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/browser.esm.js +436 -439
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +440 -443
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Item.d.ts +6 -0
  7. package/lib/ActionList/Item.js +5 -1
  8. package/lib/ActionMenu.js +2 -2
  9. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  10. package/lib/Autocomplete/Autocomplete.d.ts +11 -13
  11. package/lib/Autocomplete/AutocompleteInput.d.ts +11 -13
  12. package/lib/Button/Button.d.ts +11 -11
  13. package/lib/Button/ButtonBase.d.ts +1 -1
  14. package/lib/Button/ButtonClose.d.ts +29 -29
  15. package/lib/Button/ButtonDanger.d.ts +11 -11
  16. package/lib/Button/ButtonInvisible.d.ts +11 -11
  17. package/lib/Button/ButtonOutline.d.ts +11 -11
  18. package/lib/Button/ButtonPrimary.d.ts +11 -11
  19. package/lib/Button/ButtonStyles.js +1 -1
  20. package/lib/CircleBadge.d.ts +2 -2
  21. package/lib/CircleOcticon.d.ts +33 -33
  22. package/lib/Dialog/Dialog.d.ts +4 -4
  23. package/lib/Dialog/Dialog.js +12 -22
  24. package/lib/Dialog.d.ts +35 -35
  25. package/lib/Dropdown.d.ts +87 -165
  26. package/lib/Dropdown.js +6 -5
  27. package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
  28. package/lib/FilterList.d.ts +26 -26
  29. package/lib/Label.d.ts +1 -1
  30. package/lib/NewButton/button.d.ts +581 -0
  31. package/lib/NewButton/button.js +297 -0
  32. package/lib/NewButton/counter.d.ts +6 -0
  33. package/lib/NewButton/counter.js +33 -0
  34. package/lib/NewButton/index.d.ts +4 -0
  35. package/lib/NewButton/index.js +21 -0
  36. package/lib/Position.d.ts +4 -4
  37. package/lib/ProgressBar.d.ts +1 -1
  38. package/lib/SelectMenu/SelectMenu.d.ts +151 -153
  39. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  40. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  41. package/lib/TextInputWithTokens.d.ts +11 -13
  42. package/lib/Timeline.d.ts +33 -33
  43. package/lib/Token/AvatarToken.d.ts +1 -1
  44. package/lib/Token/IssueLabelToken.d.ts +1 -1
  45. package/lib/Token/Token.d.ts +1 -1
  46. package/lib/_TextInputWrapper.d.ts +1 -1
  47. package/lib/constants.js +3 -1
  48. package/lib/index.d.ts +2 -0
  49. package/lib/index.js +8 -0
  50. package/lib/theme-preval.js +2 -2
  51. package/lib/utils/testing.d.ts +1 -1
  52. package/lib-esm/ActionList/Item.d.ts +6 -0
  53. package/lib-esm/ActionList/Item.js +5 -1
  54. package/lib-esm/ActionMenu.js +2 -2
  55. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  56. package/lib-esm/Autocomplete/Autocomplete.d.ts +11 -13
  57. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +11 -13
  58. package/lib-esm/Button/Button.d.ts +11 -11
  59. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  60. package/lib-esm/Button/ButtonClose.d.ts +29 -29
  61. package/lib-esm/Button/ButtonDanger.d.ts +11 -11
  62. package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
  63. package/lib-esm/Button/ButtonOutline.d.ts +11 -11
  64. package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
  65. package/lib-esm/Button/ButtonStyles.js +1 -1
  66. package/lib-esm/CircleBadge.d.ts +2 -2
  67. package/lib-esm/CircleOcticon.d.ts +33 -33
  68. package/lib-esm/Dialog/Dialog.d.ts +4 -4
  69. package/lib-esm/Dialog/Dialog.js +12 -21
  70. package/lib-esm/Dialog.d.ts +35 -35
  71. package/lib-esm/Dropdown.d.ts +87 -165
  72. package/lib-esm/Dropdown.js +4 -3
  73. package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
  74. package/lib-esm/FilterList.d.ts +26 -26
  75. package/lib-esm/Label.d.ts +1 -1
  76. package/lib-esm/NewButton/button.d.ts +581 -0
  77. package/lib-esm/NewButton/button.js +273 -0
  78. package/lib-esm/NewButton/counter.d.ts +6 -0
  79. package/lib-esm/NewButton/counter.js +21 -0
  80. package/lib-esm/NewButton/index.d.ts +4 -0
  81. package/lib-esm/NewButton/index.js +3 -0
  82. package/lib-esm/Position.d.ts +4 -4
  83. package/lib-esm/ProgressBar.d.ts +1 -1
  84. package/lib-esm/SelectMenu/SelectMenu.d.ts +151 -153
  85. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  86. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  87. package/lib-esm/TextInputWithTokens.d.ts +11 -13
  88. package/lib-esm/Timeline.d.ts +33 -33
  89. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  90. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  91. package/lib-esm/Token/Token.d.ts +1 -1
  92. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  93. package/lib-esm/constants.js +3 -1
  94. package/lib-esm/index.d.ts +2 -0
  95. package/lib-esm/index.js +1 -0
  96. package/lib-esm/theme-preval.js +2 -2
  97. package/lib-esm/utils/testing.d.ts +1 -1
  98. package/package.json +13 -14
  99. package/lib/DatePicker/DatePicker.d.ts +0 -48
  100. package/lib/DatePicker/DatePicker.js +0 -104
  101. package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
  102. package/lib/DatePicker/DatePickerAnchor.js +0 -182
  103. package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
  104. package/lib/DatePicker/DatePickerOverlay.js +0 -48
  105. package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
  106. package/lib/DatePicker/DatePickerPanel.js +0 -126
  107. package/lib/DatePicker/Day.d.ts +0 -14
  108. package/lib/DatePicker/Day.js +0 -190
  109. package/lib/DatePicker/Month.d.ts +0 -9
  110. package/lib/DatePicker/Month.js +0 -120
  111. package/lib/DatePicker/index.d.ts +0 -2
  112. package/lib/DatePicker/index.js +0 -13
  113. package/lib/DatePicker/useDatePicker.d.ts +0 -88
  114. package/lib/DatePicker/useDatePicker.js +0 -438
  115. package/lib/hooks/useDebounce.d.ts +0 -2
  116. package/lib/hooks/useDebounce.js +0 -24
  117. package/lib-esm/DatePicker/DatePicker.d.ts +0 -48
  118. package/lib-esm/DatePicker/DatePicker.js +0 -87
  119. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
  120. package/lib-esm/DatePicker/DatePickerAnchor.js +0 -155
  121. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
  122. package/lib-esm/DatePicker/DatePickerOverlay.js +0 -29
  123. package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
  124. package/lib-esm/DatePicker/DatePickerPanel.js +0 -100
  125. package/lib-esm/DatePicker/Day.d.ts +0 -14
  126. package/lib-esm/DatePicker/Day.js +0 -167
  127. package/lib-esm/DatePicker/Month.d.ts +0 -9
  128. package/lib-esm/DatePicker/Month.js +0 -96
  129. package/lib-esm/DatePicker/index.d.ts +0 -2
  130. package/lib-esm/DatePicker/index.js +0 -1
  131. package/lib-esm/DatePicker/useDatePicker.d.ts +0 -88
  132. package/lib-esm/DatePicker/useDatePicker.js +0 -408
  133. package/lib-esm/hooks/useDebounce.d.ts +0 -2
  134. package/lib-esm/hooks/useDebounce.js +0 -16
@@ -1,190 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.BlankDay = exports.Day = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
- var _Box = _interopRequireDefault(require("../Box"));
13
-
14
- var _Text = _interopRequireDefault(require("../Text"));
15
-
16
- var _constants = require("../constants");
17
-
18
- var _useDatePicker = _interopRequireDefault(require("./useDatePicker"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
- const DayBaseComponent = (0, _styledComponents.default)(_Box.default).withConfig({
27
- displayName: "Day__DayBaseComponent",
28
- componentId: "sc-1japneh-0"
29
- })(["align-content:center;display:flex;justify-content:center;min-width:38px;min-height:38px;padding:", ";"], (0, _constants.get)('space.1'));
30
- const states = {
31
- blocked: {
32
- background: (0, _constants.get)('colors.neutral.subtle'),
33
- borderRadius: (0, _constants.get)('radii.2'),
34
- color: (0, _constants.get)('colors.fg.subtle')
35
- },
36
- disabled: {
37
- background: (0, _constants.get)('colors.canvas.primary'),
38
- borderRadius: (0, _constants.get)('radii.2'),
39
- color: (0, _constants.get)('colors.fg.subtle')
40
- },
41
- selected: {
42
- default: {
43
- background: (0, _constants.get)('colors.accent.emphasis'),
44
- borderRadius: (0, _constants.get)('radii.2'),
45
- color: (0, _constants.get)('colors.fg.onEmphasis'),
46
- todayColor: (0, _constants.get)('colors.fg.onEmphasis')
47
- },
48
- start: {
49
- background: (0, _constants.get)('colors.accent.emphasis'),
50
- borderRadius: '4px 0 0 4px',
51
- color: (0, _constants.get)('colors.fg.onEmphasis'),
52
- todayColor: (0, _constants.get)('colors.fg.onEmphasis')
53
- },
54
- middle: {
55
- background: (0, _constants.get)('colors.accent.subtle'),
56
- borderRadius: '0',
57
- color: (0, _constants.get)('colors.fg.default'),
58
- todayColor: (0, _constants.get)('colors.accent.fg')
59
- },
60
- end: {
61
- background: (0, _constants.get)('colors.accent.emphasis'),
62
- borderRadius: '0 4px 4px 0',
63
- color: (0, _constants.get)('colors.fg.onEmphasis'),
64
- todayColor: (0, _constants.get)('colors.fg.onEmphasis')
65
- }
66
- },
67
- default: {
68
- normal: {
69
- background: (0, _constants.get)('colors.canvas.primary'),
70
- borderRadius: (0, _constants.get)('radii.2'),
71
- color: (0, _constants.get)('colors.fg.default'),
72
- todayColor: (0, _constants.get)('colors.accent.fg')
73
- },
74
- hover: {
75
- background: (0, _constants.get)('colors.neutral.muted'),
76
- borderRadius: (0, _constants.get)('radii.2'),
77
- color: (0, _constants.get)('colors.fg.default'),
78
- todayColor: (0, _constants.get)('colors.accent.fg')
79
- },
80
- pressed: {
81
- background: (0, _constants.get)('colors.neutral.emphasis'),
82
- borderRadius: (0, _constants.get)('radii.2'),
83
- color: (0, _constants.get)('colors.fg.onEmphasis'),
84
- todayColor: (0, _constants.get)('colors.fg.onEmphasis')
85
- }
86
- }
87
- };
88
-
89
- const getStateStyles = (props, prop, state) => {
90
- const {
91
- blocked,
92
- disabled,
93
- selected,
94
- today
95
- } = props;
96
-
97
- if (blocked) {
98
- return states.blocked[prop];
99
- } else if (disabled) {
100
- return states.disabled[prop];
101
- } else if (selected) {
102
- switch (selected) {
103
- case 'start':
104
- return today && prop === 'color' ? states.selected.start['todayColor'] : states.selected.start[prop];
105
-
106
- case 'middle':
107
- return today && prop === 'color' ? states.selected.middle['todayColor'] : states.selected.middle[prop];
108
-
109
- case 'end':
110
- return today && prop === 'color' ? states.selected.end['todayColor'] : states.selected.end[prop];
111
-
112
- default:
113
- return today && prop === 'color' ? states.selected.default['todayColor'] : states.selected.default[prop];
114
- }
115
- } else {
116
- return today && prop === 'color' ? states.default[state]['todayColor'] : states.default[state][prop];
117
- }
118
- };
119
-
120
- const DayComponent = (0, _styledComponents.default)(DayBaseComponent).attrs(props => ({
121
- background: getStateStyles(props, 'background', 'normal'),
122
- borderRadius: getStateStyles(props, 'borderRadius', 'normal'),
123
- textColor: getStateStyles(props, 'color', 'normal'),
124
- backgroundHover: getStateStyles(props, 'background', 'hover'),
125
- textColorHover: getStateStyles(props, 'color', 'hover'),
126
- backgroundPressed: getStateStyles(props, 'background', 'pressed'),
127
- textColorPressed: getStateStyles(props, 'color', 'pressed')
128
- })).withConfig({
129
- displayName: "Day__DayComponent",
130
- componentId: "sc-1japneh-1"
131
- })(["background-color:", ";border-radius:", ";transition:0.1s background-color ease;& ", "{align-self:center;color:", ";display:flex;font-family:", ";font-size:", ";justify-self:center;user-select:none;transition:0.1s color ease;}&:hover{background-color:", ";cursor:pointer;transition:0.05s background-color ease;& ", "{color:", ";transition:0.1s color ease;}}&:active{background-color:", ";box-shadow:inset ", ";transition:0.1s background-color ease,0.1s box-shadow ease,0.1s color ease;& ", "{color:", ";transition:0.1s color ease;}}"], props => props.background, props => props.borderRadius, _Text.default, props => props.textColor, (0, _constants.get)('fonts.mono'), (0, _constants.get)('fontSizes.0'), props => props.backgroundHover, _Text.default, props => props.textColorHover, props => props.backgroundPressed, (0, _constants.get)('shadows.shadow.medium'), _Text.default, props => props.textColorPressed);
132
-
133
- const Day = ({
134
- date,
135
- onAction
136
- }) => {
137
- const {
138
- onDayFocus,
139
- onSelection,
140
- disabled,
141
- blocked,
142
- selected,
143
- today
144
- } = (0, _useDatePicker.default)(date);
145
- const keyPressHandler = (0, _react.useCallback)(event => {
146
- if (disabled) {
147
- return;
148
- }
149
-
150
- if ([' ', 'Enter'].includes(event.key)) {
151
- onSelection(date);
152
- onAction === null || onAction === void 0 ? void 0 : onAction(date, event);
153
- }
154
- }, [disabled, onSelection, onAction, date]);
155
- const clickHandler = (0, _react.useCallback)(event => {
156
- if (disabled) {
157
- return;
158
- }
159
-
160
- onSelection(date);
161
- onAction === null || onAction === void 0 ? void 0 : onAction(date, event);
162
- }, [disabled, onSelection, date, onAction]);
163
- const todayStyles = (0, _react.useMemo)(() => today ? {
164
- border: '2px solid',
165
- padding: '4px 6px',
166
- borderRadius: '16px',
167
- fontWeight: 'bold'
168
- } : {}, [today]);
169
- return /*#__PURE__*/_react.default.createElement(DayComponent, {
170
- role: "button",
171
- blocked: blocked,
172
- disabled: disabled,
173
- selected: selected,
174
- today: today,
175
- onClick: clickHandler,
176
- onMouseEnter: () => onDayFocus(date),
177
- onFocus: () => onDayFocus(date),
178
- onKeyPress: keyPressHandler
179
- }, /*#__PURE__*/_react.default.createElement(_Text.default, {
180
- sx: todayStyles
181
- }, date.getDate()));
182
- };
183
-
184
- exports.Day = Day;
185
- Day.displayName = "Day";
186
- const BlankDay = (0, _styledComponents.default)(DayBaseComponent).withConfig({
187
- displayName: "Day__BlankDay",
188
- componentId: "sc-1japneh-2"
189
- })(["background-color:", ";"], (0, _constants.get)('colors.canvas.primary'));
190
- exports.BlankDay = BlankDay;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { FontSizeProps } from 'styled-system';
3
- import { SystemCommonProps, SystemLayoutProps } from '../constants';
4
- import { SxProp } from '../sx';
5
- export interface MonthProps extends FontSizeProps, SystemCommonProps, SxProp, SystemLayoutProps {
6
- month: number;
7
- year: number;
8
- }
9
- export declare const Month: React.FC<MonthProps>;
@@ -1,120 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Month = void 0;
7
-
8
- var _dateFns = require("date-fns");
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- var _Box = _interopRequireDefault(require("../Box"));
15
-
16
- var _Text = _interopRequireDefault(require("../Text"));
17
-
18
- var _constants = require("../constants");
19
-
20
- var _Day = require("./Day");
21
-
22
- var _useDatePicker = _interopRequireDefault(require("./useDatePicker"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
- const weekdayEnum = {
31
- Sunday: 0,
32
- Monday: 1,
33
- Tuesday: 2,
34
- Wednesday: 3,
35
- Thursday: 4,
36
- Friday: 5,
37
- Saturday: 6
38
- };
39
- const MonthComponent = (0, _styledComponents.default)(_Box.default).withConfig({
40
- displayName: "Month__MonthComponent",
41
- componentId: "l6j7o0-0"
42
- })(["display:grid;grid-auto-rows:min-content;grid-template-columns:repeat(1fr,7);grid-template-rows:1fr;gap:0px 0px;grid-template-areas:'month month month month month month month' 'sunday monday tuesday wednesday thursday friday saturday';justify-items:stretch;align-items:stretch;"]);
43
- const MonthTitle = (0, _styledComponents.default)(_Text.default).withConfig({
44
- displayName: "Month__MonthTitle",
45
- componentId: "l6j7o0-1"
46
- })(["font-size:", ";font-weight:", ";grid-area:month;justify-self:center;"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('fontWeights.bold'));
47
- const WeekdayHeader = (0, _styledComponents.default)(_Text.default).withConfig({
48
- displayName: "Month__WeekdayHeader",
49
- componentId: "l6j7o0-2"
50
- })(["color:", ";font-family:", ";font-size:", ";justify-self:center;padding:", " 0 ", ";"], (0, _constants.get)('colors.fg.subtle'), (0, _constants.get)('fonts.mono'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('space.3'), (0, _constants.get)('space.2'));
51
-
52
- const Month = ({
53
- month,
54
- year
55
- }) => {
56
- const {
57
- configuration
58
- } = (0, _useDatePicker.default)();
59
- const [selectedDay, setSelectedDay] = (0, _react.useState)(null);
60
- const getTitle = (0, _react.useMemo)(() => `${(0, _dateFns.format)(new Date(year, month), 'MMMM yyyy')}`, [month, year]);
61
- const weekdayHeaders = (0, _react.useMemo)(() => {
62
- var _configuration$weekSt;
63
-
64
- const now = new Date(year, month);
65
- const weekOptions = {
66
- weekStartsOn: weekdayEnum[(_configuration$weekSt = configuration.weekStartsOn) !== null && _configuration$weekSt !== void 0 ? _configuration$weekSt : 'Sunday']
67
- };
68
- return (0, _dateFns.eachDayOfInterval)({
69
- start: (0, _dateFns.startOfWeek)(now, weekOptions),
70
- end: (0, _dateFns.endOfWeek)(now, weekOptions)
71
- }).map(d => /*#__PURE__*/_react.default.createElement(WeekdayHeader, {
72
- key: `weekday-${d}-header`
73
- }, (0, _dateFns.format)(d, 'EEEEEE')));
74
- }, [configuration.weekStartsOn, month, year]);
75
-
76
- const dayAction = date => {
77
- setSelectedDay(date);
78
- };
79
-
80
- const dayComponents = (0, _react.useMemo)(() => {
81
- var _configuration$weekSt2, _configuration$weekSt3;
82
-
83
- const components = [];
84
- const firstDay = new Date(year, month, 1);
85
- const preBlanks = (firstDay.getDay() + (7 - weekdayEnum[(_configuration$weekSt2 = configuration.weekStartsOn) !== null && _configuration$weekSt2 !== void 0 ? _configuration$weekSt2 : 'Sunday'])) % 7;
86
-
87
- for (let i = 0; i < preBlanks; i++) {
88
- components.push( /*#__PURE__*/_react.default.createElement(_Day.BlankDay, {
89
- key: `month-pre-blank-${i}`
90
- }));
91
- }
92
-
93
- for (let i = 1; i <= (0, _dateFns.getDaysInMonth)(firstDay); i++) {
94
- const date = new Date(year, month, i);
95
- components.push( /*#__PURE__*/_react.default.createElement(_Day.Day, {
96
- key: `day-component-${date.toString()}`,
97
- date: date,
98
- selected: selectedDay ? (0, _dateFns.isEqual)(date, selectedDay) : false,
99
- onAction: dayAction
100
- }));
101
- }
102
-
103
- const lastDay = (0, _dateFns.lastDayOfMonth)(firstDay);
104
- const postBlanks = (lastDay.getDay() + (7 - weekdayEnum[(_configuration$weekSt3 = configuration.weekStartsOn) !== null && _configuration$weekSt3 !== void 0 ? _configuration$weekSt3 : 'Sunday'])) % 7;
105
-
106
- for (let i = 6; i > postBlanks; i--) {
107
- components.push( /*#__PURE__*/_react.default.createElement(_Day.BlankDay, {
108
- key: `month-post-blank-${i}`
109
- }));
110
- }
111
-
112
- return components;
113
- }, [configuration.weekStartsOn, month, selectedDay, year]);
114
- return /*#__PURE__*/_react.default.createElement(MonthComponent, {
115
- role: "grid"
116
- }, /*#__PURE__*/_react.default.createElement(MonthTitle, null, getTitle), weekdayHeaders, dayComponents);
117
- };
118
-
119
- exports.Month = Month;
120
- Month.displayName = "Month";
@@ -1,2 +0,0 @@
1
- export { DatePicker } from './DatePicker';
2
- export type { DatePickerProps } from './DatePicker';
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "DatePicker", {
7
- enumerable: true,
8
- get: function () {
9
- return _DatePicker.DatePicker;
10
- }
11
- });
12
-
13
- var _DatePicker = require("./DatePicker");
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
- export declare type AnchorVariant = 'input' | 'button' | 'icon-only';
3
- export declare type DateFormat = 'short' | 'long' | string;
4
- export declare type SelectionVariant = 'single' | 'multi' | 'range';
5
- export interface DatePickerConfiguration {
6
- anchorVariant?: AnchorVariant;
7
- blockedDates?: Array<Date>;
8
- confirmation?: boolean;
9
- confirmUnsavedClose?: boolean;
10
- dateFormat?: DateFormat;
11
- disableWeekends?: boolean;
12
- iconPlacement?: 'start' | 'end' | 'none';
13
- maxDate?: Date | null;
14
- maxSelections?: number;
15
- maxRangeSize?: number;
16
- minDate?: Date | null;
17
- placeholder?: string;
18
- rangeIncrement?: number;
19
- variant?: SelectionVariant;
20
- view?: '1-month' | '2-month';
21
- weekStartsOn?: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday';
22
- }
23
- export declare type RangeSelection = {
24
- from: Date;
25
- to: Date | null;
26
- };
27
- export declare type StringRangeSelection = {
28
- from: string;
29
- to: string;
30
- };
31
- export interface DatePickerContext {
32
- disabled?: boolean;
33
- configuration: DatePickerConfiguration;
34
- currentViewingDate: Date;
35
- goToMonth: (date: Date) => void;
36
- hoverRange?: RangeSelection | null;
37
- selection?: Selection;
38
- softSelection?: Partial<RangeSelection> | null;
39
- selectionActive?: boolean;
40
- formattedDate: string;
41
- nextMonth: () => void;
42
- onClose: () => void;
43
- onDateInput: (updatedSelection: Selection) => void;
44
- onDayFocus: (date: Date) => void;
45
- onSelection: (date: Date) => void;
46
- previousMonth: () => void;
47
- revertValue: () => void;
48
- saveValue: (selection?: Selection) => void;
49
- }
50
- export declare type Selection = Date | Array<Date> | RangeSelection | null;
51
- export declare type StringSelection = string | Array<string> | {
52
- to: string;
53
- from: string;
54
- } | null;
55
- export declare type DaySelection = boolean | 'start' | 'middle' | 'end';
56
- declare const useDatePicker: (date?: Date | undefined) => {
57
- blocked: boolean | undefined;
58
- disabled: boolean;
59
- selected: DaySelection;
60
- today: boolean;
61
- configuration: DatePickerConfiguration;
62
- currentViewingDate: Date;
63
- goToMonth: (date: Date) => void;
64
- hoverRange?: RangeSelection | null | undefined;
65
- selection?: Selection | undefined;
66
- softSelection?: Partial<RangeSelection> | null | undefined;
67
- selectionActive?: boolean | undefined;
68
- formattedDate: string;
69
- nextMonth: () => void;
70
- onClose: () => void;
71
- onDateInput: (updatedSelection: Selection) => void;
72
- onDayFocus: (date: Date) => void;
73
- onSelection: (date: Date) => void;
74
- previousMonth: () => void;
75
- revertValue: () => void;
76
- saveValue: (selection?: Selection | undefined) => void;
77
- };
78
- export default useDatePicker;
79
- export interface DatePickerProviderProps {
80
- closePicker?: () => void;
81
- configuration?: DatePickerConfiguration;
82
- value?: Selection | StringSelection;
83
- }
84
- export declare function isSingleSelection(selection: Selection): selection is Date;
85
- export declare function isMultiSelection(selection: Selection | StringSelection): selection is Array<Date> | Array<string>;
86
- export declare function isRangeSelection(selection: Selection | StringSelection): selection is RangeSelection | StringRangeSelection;
87
- export declare function isStringRangeSelection(selection: StringSelection): selection is StringRangeSelection;
88
- export declare const DatePickerProvider: React.FC<DatePickerProviderProps>;