@primer/components 0.0.0-202191252016 → 0.0.0-2021913173522

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 (151) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/browser.esm.js +851 -747
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +484 -380
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/List.d.ts +2 -1
  7. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
  8. package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
  9. package/lib/Autocomplete/Autocomplete.d.ts +304 -0
  10. package/lib/Autocomplete/Autocomplete.js +145 -0
  11. package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
  12. package/lib/Autocomplete/AutocompleteContext.js +11 -0
  13. package/lib/Autocomplete/AutocompleteInput.d.ts +292 -0
  14. package/lib/Autocomplete/AutocompleteInput.js +157 -0
  15. package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
  16. package/lib/Autocomplete/AutocompleteMenu.js +224 -0
  17. package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  18. package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
  19. package/lib/Autocomplete/index.d.ts +2 -0
  20. package/lib/Autocomplete/index.js +15 -0
  21. package/lib/FilteredActionList/FilteredActionList.js +5 -31
  22. package/lib/Overlay.d.ts +1 -0
  23. package/lib/Overlay.js +3 -1
  24. package/lib/SelectMenu/SelectMenu.d.ts +10 -10
  25. package/lib/TextInput.d.ts +5 -13
  26. package/lib/TextInput.js +4 -46
  27. package/lib/TextInputWithTokens.d.ts +323 -0
  28. package/lib/TextInputWithTokens.js +244 -0
  29. package/lib/Token/AvatarToken.d.ts +7 -0
  30. package/lib/Token/AvatarToken.js +64 -0
  31. package/lib/Token/IssueLabelToken.d.ts +14 -0
  32. package/lib/Token/IssueLabelToken.js +144 -0
  33. package/lib/Token/Token.d.ts +15 -0
  34. package/lib/Token/Token.js +94 -0
  35. package/lib/Token/TokenBase.d.ts +31 -0
  36. package/lib/Token/TokenBase.js +108 -0
  37. package/lib/Token/_RemoveTokenButton.d.ts +12 -0
  38. package/lib/Token/_RemoveTokenButton.js +77 -0
  39. package/lib/Token/_TokenTextContainer.d.ts +3 -0
  40. package/lib/Token/_TokenTextContainer.js +17 -0
  41. package/lib/Token/index.d.ts +3 -0
  42. package/lib/Token/index.js +31 -0
  43. package/lib/_TextInputWrapper.d.ts +10 -0
  44. package/lib/_TextInputWrapper.js +51 -0
  45. package/lib/_UnstyledTextInput.d.ts +2 -0
  46. package/lib/_UnstyledTextInput.js +20 -0
  47. package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
  48. package/lib/behaviors/scrollIntoViewingArea.js +39 -0
  49. package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
  50. package/lib/hooks/useOpenAndCloseFocus.js +7 -2
  51. package/lib/hooks/useOverlay.d.ts +2 -1
  52. package/lib/hooks/useOverlay.js +4 -2
  53. package/lib/index.d.ts +5 -0
  54. package/lib/index.js +36 -0
  55. package/lib/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
  56. package/lib/{DatePicker/DatePickerPanel.js → utils/types/AriaRole.js} +0 -0
  57. package/lib/utils/types/ComponentProps.d.ts +9 -0
  58. package/lib/utils/{types.js → types/ComponentProps.js} +0 -0
  59. package/lib/utils/types/Flatten.d.ts +4 -0
  60. package/lib/utils/types/Flatten.js +1 -0
  61. package/lib/utils/types/MandateProps.d.ts +3 -0
  62. package/lib/utils/types/MandateProps.js +1 -0
  63. package/lib/utils/types/Merge.d.ts +19 -0
  64. package/lib/utils/types/Merge.js +1 -0
  65. package/lib/utils/types/index.d.ts +5 -0
  66. package/lib/utils/types/index.js +70 -0
  67. package/lib-esm/ActionList/List.d.ts +2 -1
  68. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
  69. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
  70. package/lib-esm/Autocomplete/Autocomplete.d.ts +304 -0
  71. package/lib-esm/Autocomplete/Autocomplete.js +123 -0
  72. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
  73. package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
  74. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +292 -0
  75. package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
  76. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
  77. package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
  78. package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  79. package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
  80. package/lib-esm/Autocomplete/index.d.ts +2 -0
  81. package/lib-esm/Autocomplete/index.js +1 -0
  82. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
  83. package/lib-esm/Overlay.d.ts +1 -0
  84. package/lib-esm/Overlay.js +3 -1
  85. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -10
  86. package/lib-esm/TextInput.d.ts +5 -13
  87. package/lib-esm/TextInput.js +4 -37
  88. package/lib-esm/TextInputWithTokens.d.ts +323 -0
  89. package/lib-esm/TextInputWithTokens.js +219 -0
  90. package/lib-esm/Token/AvatarToken.d.ts +7 -0
  91. package/lib-esm/Token/AvatarToken.js +43 -0
  92. package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
  93. package/lib-esm/Token/IssueLabelToken.js +124 -0
  94. package/lib-esm/Token/Token.d.ts +15 -0
  95. package/lib-esm/Token/Token.js +73 -0
  96. package/lib-esm/Token/TokenBase.d.ts +31 -0
  97. package/lib-esm/Token/TokenBase.js +87 -0
  98. package/lib-esm/Token/_RemoveTokenButton.d.ts +12 -0
  99. package/lib-esm/Token/_RemoveTokenButton.js +60 -0
  100. package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
  101. package/lib-esm/Token/_TokenTextContainer.js +6 -0
  102. package/lib-esm/Token/index.d.ts +3 -0
  103. package/lib-esm/Token/index.js +3 -0
  104. package/lib-esm/_TextInputWrapper.d.ts +10 -0
  105. package/lib-esm/_TextInputWrapper.js +31 -0
  106. package/lib-esm/_UnstyledTextInput.d.ts +2 -0
  107. package/lib-esm/_UnstyledTextInput.js +7 -0
  108. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
  109. package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
  110. package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
  111. package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
  112. package/lib-esm/hooks/useOverlay.d.ts +2 -1
  113. package/lib-esm/hooks/useOverlay.js +4 -2
  114. package/lib-esm/index.d.ts +5 -0
  115. package/lib-esm/index.js +3 -0
  116. package/lib-esm/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
  117. package/lib-esm/utils/{types.js → types/AriaRole.js} +0 -0
  118. package/lib-esm/utils/types/ComponentProps.d.ts +9 -0
  119. package/lib-esm/utils/types/ComponentProps.js +1 -0
  120. package/lib-esm/utils/types/Flatten.d.ts +4 -0
  121. package/lib-esm/utils/types/Flatten.js +1 -0
  122. package/lib-esm/utils/types/MandateProps.d.ts +3 -0
  123. package/lib-esm/utils/types/MandateProps.js +1 -0
  124. package/lib-esm/utils/types/Merge.d.ts +19 -0
  125. package/lib-esm/utils/types/Merge.js +1 -0
  126. package/lib-esm/utils/types/index.d.ts +5 -0
  127. package/lib-esm/utils/types/index.js +5 -0
  128. package/package.json +2 -2
  129. package/lib/DatePicker/DatePicker.d.ts +0 -44
  130. package/lib/DatePicker/DatePicker.js +0 -72
  131. package/lib/DatePicker/DatePickerAnchor.d.ts +0 -10
  132. package/lib/DatePicker/DatePickerAnchor.js +0 -83
  133. package/lib/DatePicker/DatePickerPanel.d.ts +0 -0
  134. package/lib/DatePicker/Day.d.ts +0 -13
  135. package/lib/DatePicker/Day.js +0 -126
  136. package/lib/DatePicker/Month.d.ts +0 -9
  137. package/lib/DatePicker/Month.js +0 -97
  138. package/lib/DatePicker/index.d.ts +0 -2
  139. package/lib/DatePicker/index.js +0 -13
  140. package/lib-esm/DatePicker/DatePicker.d.ts +0 -44
  141. package/lib-esm/DatePicker/DatePicker.js +0 -55
  142. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -10
  143. package/lib-esm/DatePicker/DatePickerAnchor.js +0 -59
  144. package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -0
  145. package/lib-esm/DatePicker/DatePickerPanel.js +0 -0
  146. package/lib-esm/DatePicker/Day.d.ts +0 -13
  147. package/lib-esm/DatePicker/Day.js +0 -104
  148. package/lib-esm/DatePicker/Month.d.ts +0 -9
  149. package/lib-esm/DatePicker/Month.js +0 -74
  150. package/lib-esm/DatePicker/index.d.ts +0 -2
  151. package/lib-esm/DatePicker/index.js +0 -1
@@ -1,55 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
- import { AnchoredOverlay } from '../AnchoredOverlay';
3
- import { DatePickerAnchor } from './DatePickerAnchor';
4
- import { addDays } from 'date-fns';
5
- export const DatePicker = ({
6
- anchorRef: externalAnchorRef,
7
- focusTrapSettings,
8
- focusZoneSettings,
9
- onOpen: onOpenExternal,
10
- onClose: onCloseExternal,
11
- open,
12
- overlayProps,
13
- renderAnchor,
14
- value
15
- }) => {
16
- const buttonRef = useRef(null);
17
- const [isOpen, setIsOpen] = useState(false);
18
-
19
- const onOpen = gesture => {
20
- setIsOpen(true);
21
- onOpenExternal === null || onOpenExternal === void 0 ? void 0 : onOpenExternal(gesture);
22
- };
23
-
24
- const onClose = gesture => {
25
- setIsOpen(false);
26
- onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal(gesture);
27
- };
28
-
29
- const toggleIsOpen = () => {
30
- if (isOpen) {
31
- setIsOpen(false);
32
- onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal('anchor-click');
33
- } else {
34
- setIsOpen(true);
35
- onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal('anchor-click');
36
- }
37
- };
38
-
39
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DatePickerAnchor, {
40
- ref: buttonRef,
41
- fromDate: new Date(),
42
- toDate: addDays(new Date(), 7),
43
- dateFormat: "short",
44
- onAction: toggleIsOpen
45
- }), /*#__PURE__*/React.createElement(AnchoredOverlay, {
46
- anchorRef: externalAnchorRef !== null && externalAnchorRef !== void 0 ? externalAnchorRef : buttonRef,
47
- renderAnchor: renderAnchor,
48
- open: open !== null && open !== void 0 ? open : isOpen,
49
- onOpen: onOpen,
50
- onClose: onClose,
51
- overlayProps: overlayProps,
52
- focusTrapSettings: focusTrapSettings,
53
- focusZoneSettings: focusZoneSettings
54
- }, value));
55
- };
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- export interface DatePickerAnchorProps {
3
- dateFormat?: 'short' | 'long' | string;
4
- disabled?: boolean;
5
- fromDate: Date;
6
- iconOnly?: boolean;
7
- onAction?: (event?: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
8
- toDate?: Date;
9
- }
10
- export declare const DatePickerAnchor: React.ForwardRefExoticComponent<DatePickerAnchorProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,59 +0,0 @@
1
- import { CalendarIcon } from '@primer/octicons-react';
2
- import styled from 'styled-components';
3
- import { format } from 'date-fns';
4
- import React, { useCallback, useMemo } from 'react';
5
- import Button from '../Button';
6
- import Text from '../Text';
7
- import { get } from '../constants';
8
- import { StyledOcticon } from '..';
9
- const DatePickerAnchorButton = styled(Button).withConfig({
10
- displayName: "DatePickerAnchor__DatePickerAnchorButton",
11
- componentId: "sc-8gpb9d-0"
12
- })(["align-items:center;display:flex;flex-direction:row;justify-content:space-between;& ", "{margin-left:", ";}"], Text, get('space.2'));
13
- export const DatePickerAnchor = /*#__PURE__*/React.forwardRef(({
14
- dateFormat = 'short',
15
- disabled,
16
- fromDate,
17
- iconOnly = false,
18
- onAction,
19
- toDate
20
- }, ref) => {
21
- const formattedDate = useMemo(() => {
22
- if (iconOnly) return;
23
-
24
- if (dateFormat === 'short') {
25
- return /*#__PURE__*/React.createElement(Text, null, `${format(fromDate, 'MMM d')}${toDate ? ' - ' : ''}${toDate ? format(toDate, 'MMM d') : ''}`);
26
- } else if (dateFormat === 'long') {
27
- return /*#__PURE__*/React.createElement(Text, null, `${format(fromDate, 'MMM d, yyyy')}${toDate ? ' - ' : ''}${toDate ? format(toDate, 'MMM d, yyyy') : ''}`);
28
- } else {
29
- return /*#__PURE__*/React.createElement(Text, null, `${format(fromDate, dateFormat)}${toDate ? ' - ' : ''}${toDate ? format(toDate, dateFormat) : ''}`);
30
- }
31
- }, [dateFormat, fromDate, iconOnly, toDate]);
32
- const keyPressHandler = useCallback(event => {
33
- if (disabled) {
34
- return;
35
- }
36
-
37
- if ([' ', 'Enter'].includes(event.key)) {
38
- onAction === null || onAction === void 0 ? void 0 : onAction(event);
39
- }
40
- }, [disabled, onAction]);
41
- const clickHandler = useCallback(event => {
42
- if (disabled) {
43
- return;
44
- }
45
-
46
- onAction === null || onAction === void 0 ? void 0 : onAction(event);
47
- }, [disabled, onAction]);
48
- return /*#__PURE__*/React.createElement(DatePickerAnchorButton, {
49
- ref: ref,
50
- onClick: clickHandler,
51
- onKeyPress: keyPressHandler
52
- }, /*#__PURE__*/React.createElement(StyledOcticon, {
53
- icon: CalendarIcon,
54
- color: "fg.muted",
55
- sx: {
56
- my: '2px'
57
- }
58
- }), formattedDate);
59
- });
File without changes
File without changes
@@ -1,13 +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 DayProps extends FontSizeProps, SystemCommonProps, SxProp, SystemLayoutProps {
6
- blocked?: boolean;
7
- disabled?: boolean;
8
- onAction?: (date: Date, event?: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
9
- selected?: boolean;
10
- date: Date;
11
- }
12
- export declare const Day: React.FC<DayProps>;
13
- export declare const BlankDay: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp, never>;
@@ -1,104 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import styled from 'styled-components';
3
- import Box from '../Box';
4
- import Text from '../Text';
5
- import { get } from '../constants';
6
- const DayBaseComponent = styled(Box).withConfig({
7
- displayName: "Day__DayBaseComponent",
8
- componentId: "sc-1japneh-0"
9
- })(["align-content:center;display:flex;justify-content:center;min-width:38px;min-height:38px;padding:", ";"], get('space.1'));
10
- const states = {
11
- blocked: {
12
- background: get('colors.neutral.subtle'),
13
- color: get('colors.fg.subtle')
14
- },
15
- disabled: {
16
- background: get('colors.canvas.primary'),
17
- color: get('colors.fg.subtle')
18
- },
19
- selected: {
20
- background: get('colors.accent.emphasis'),
21
- color: get('colors.fg.onEmphasis')
22
- },
23
- default: {
24
- normal: {
25
- background: get('colors.canvas.primary'),
26
- color: get('colors.fg.default')
27
- },
28
- hover: {
29
- background: get('colors.neutral.muted'),
30
- color: get('colors.fg.default')
31
- },
32
- pressed: {
33
- background: get('colors.neutral.emphasis'),
34
- color: get('colors.fg.onEmphasis')
35
- }
36
- }
37
- };
38
-
39
- const getStateColors = (props, prop, state) => {
40
- const {
41
- blocked,
42
- disabled,
43
- selected
44
- } = props;
45
-
46
- if (blocked) {
47
- return states.blocked[prop];
48
- } else if (disabled) {
49
- return states.disabled[prop];
50
- } else if (selected) {
51
- return states.selected[prop];
52
- } else {
53
- return states.default[state][prop];
54
- }
55
- };
56
-
57
- const DayComponent = styled(DayBaseComponent).attrs(props => ({
58
- background: getStateColors(props, 'background', 'normal'),
59
- textColor: getStateColors(props, 'color', 'normal'),
60
- backgroundHover: getStateColors(props, 'background', 'hover'),
61
- textColorHover: getStateColors(props, 'color', 'hover'),
62
- backgroundPressed: getStateColors(props, 'background', 'pressed'),
63
- textColorPressed: getStateColors(props, 'color', 'pressed')
64
- })).withConfig({
65
- displayName: "Day__DayComponent",
66
- componentId: "sc-1japneh-1"
67
- })(["background-color:", ";border-radius:", ";transition:0.2s background-color ease;& ", "{align-self:center;color:", ";display:flex;font-family:", ";font-size:", ";justify-self:center;user-select:none;transition:0.2s 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, get('radii.2'), Text, props => props.textColor, get('fonts.mono'), get('fontSizes.0'), props => props.backgroundHover, Text, props => props.textColorHover, props => props.backgroundPressed, get('shadows.shadow.medium'), Text, props => props.textColorPressed);
68
- export const Day = ({
69
- blocked,
70
- disabled,
71
- date,
72
- onAction,
73
- selected
74
- }) => {
75
- const keyPressHandler = useCallback(event => {
76
- if (disabled) {
77
- return;
78
- }
79
-
80
- if ([' ', 'Enter'].includes(event.key)) {
81
- onAction === null || onAction === void 0 ? void 0 : onAction(date, event);
82
- }
83
- }, [disabled, onAction, date]);
84
- const clickHandler = useCallback(event => {
85
- if (disabled) {
86
- return;
87
- }
88
-
89
- onAction === null || onAction === void 0 ? void 0 : onAction(date, event);
90
- }, [disabled, onAction, date]);
91
- return /*#__PURE__*/React.createElement(DayComponent, {
92
- role: "button",
93
- blocked: blocked,
94
- disabled: disabled,
95
- selected: selected,
96
- onClick: clickHandler,
97
- onKeyPress: keyPressHandler
98
- }, /*#__PURE__*/React.createElement(Text, null, date.getDate()));
99
- };
100
- Day.displayName = "Day";
101
- export const BlankDay = styled(DayBaseComponent).withConfig({
102
- displayName: "Day__BlankDay",
103
- componentId: "sc-1japneh-2"
104
- })(["background-color:", ";"], get('colors.canvas.primary'));
@@ -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,74 +0,0 @@
1
- import { format, isEqual, lastDayOfMonth, getDaysInMonth, eachDayOfInterval, startOfWeek, endOfWeek } from 'date-fns';
2
- import React, { useMemo, useState } from 'react';
3
- import styled from 'styled-components';
4
- import Box from '../Box';
5
- import Text from '../Text';
6
- import { get } from '../constants';
7
- import { BlankDay, Day } from './Day';
8
- const MonthComponent = styled(Box).withConfig({
9
- displayName: "Month__MonthComponent",
10
- componentId: "l6j7o0-0"
11
- })(["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;"]);
12
- const MonthTitle = styled(Text).withConfig({
13
- displayName: "Month__MonthTitle",
14
- componentId: "l6j7o0-1"
15
- })(["font-size:", ";font-weight:", ";grid-area:month;justify-self:center;"], get('fontSizes.1'), get('fontWeights.bold'));
16
- const WeekdayHeader = styled(Text).withConfig({
17
- displayName: "Month__WeekdayHeader",
18
- componentId: "l6j7o0-2"
19
- })(["color:", ";font-family:", ";font-size:", ";justify-self:center;padding:", " 0 ", ";"], get('colors.fg.subtle'), get('fonts.mono'), get('fontSizes.0'), get('space.3'), get('space.2'));
20
- export const Month = ({
21
- month,
22
- year
23
- }) => {
24
- const [selectedDay, setSelectedDay] = useState(null);
25
- const getTitle = useMemo(() => `${format(new Date(year, month), 'MMMM yyyy')}`, [month, year]);
26
- const weekdayHeaders = useMemo(() => {
27
- const now = new Date(year, month);
28
- return eachDayOfInterval({
29
- start: startOfWeek(now),
30
- end: endOfWeek(now)
31
- }).map(d => /*#__PURE__*/React.createElement(WeekdayHeader, {
32
- key: `weekday-${d}-header`
33
- }, format(d, 'EEEEEE')));
34
- }, [month, year]);
35
-
36
- const dayAction = date => {
37
- setSelectedDay(date);
38
- };
39
-
40
- const dayComponents = useMemo(() => {
41
- const components = [];
42
- const firstDay = new Date(year, month, 1);
43
-
44
- for (let i = 0; i < firstDay.getDay(); i++) {
45
- components.push( /*#__PURE__*/React.createElement(BlankDay, {
46
- key: `month-pre-blank-${i}`
47
- }));
48
- }
49
-
50
- for (let i = 1; i <= getDaysInMonth(firstDay); i++) {
51
- const date = new Date(year, month, i);
52
- components.push( /*#__PURE__*/React.createElement(Day, {
53
- key: `day-component-${date.toString()}`,
54
- date: date,
55
- selected: selectedDay ? isEqual(date, selectedDay) : false,
56
- onAction: dayAction
57
- }));
58
- }
59
-
60
- const lastDay = lastDayOfMonth(firstDay);
61
-
62
- for (let i = 6; i > lastDay.getDay(); i--) {
63
- components.push( /*#__PURE__*/React.createElement(BlankDay, {
64
- key: `month-post-blank-${i}`
65
- }));
66
- }
67
-
68
- return components;
69
- }, [month, selectedDay, year]);
70
- return /*#__PURE__*/React.createElement(MonthComponent, {
71
- role: "grid"
72
- }, /*#__PURE__*/React.createElement(MonthTitle, null, getTitle), weekdayHeaders, dayComponents);
73
- };
74
- Month.displayName = "Month";
@@ -1,2 +0,0 @@
1
- export { DatePicker } from './DatePicker';
2
- export type { DatePickerProps } from './DatePicker';
@@ -1 +0,0 @@
1
- export { DatePicker } from './DatePicker';