@primer/components 0.0.0-2021927173554 → 0.0.0-2021927175656
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/CHANGELOG.md +8 -4
- package/dist/browser.esm.js +2 -2
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -2
- package/dist/browser.umd.js.map +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib/Autocomplete/Autocomplete.d.ts +12 -10
- package/lib/Autocomplete/AutocompleteInput.d.ts +12 -10
- package/lib/Button/Button.d.ts +6 -6
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +5 -5
- package/lib/Button/ButtonDanger.d.ts +6 -6
- package/lib/Button/ButtonInvisible.d.ts +6 -6
- package/lib/Button/ButtonOutline.d.ts +6 -6
- package/lib/Button/ButtonPrimary.d.ts +6 -6
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +4 -4
- package/lib/DatePicker/DatePicker.d.ts +48 -0
- package/lib/DatePicker/DatePicker.js +100 -0
- package/lib/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib/DatePicker/DatePickerAnchor.js +182 -0
- package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib/DatePicker/DatePickerOverlay.js +39 -0
- package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib/DatePicker/DatePickerPanel.js +126 -0
- package/lib/DatePicker/Day.d.ts +14 -0
- package/lib/DatePicker/Day.js +192 -0
- package/lib/DatePicker/Month.d.ts +9 -0
- package/lib/DatePicker/Month.js +120 -0
- package/lib/DatePicker/index.d.ts +2 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/useDatePicker.d.ts +88 -0
- package/lib/DatePicker/useDatePicker.js +383 -0
- package/lib/Dialog.d.ts +4 -4
- package/lib/Dropdown.d.ts +18 -18
- package/lib/DropdownMenu/DropdownButton.d.ts +7 -7
- package/lib/FilterList.d.ts +3 -3
- package/lib/Flash.d.ts +1 -1
- package/lib/Label.d.ts +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +32 -30
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +12 -10
- package/lib/Timeline.d.ts +4 -4
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/_TextInputWrapper.d.ts +1 -1
- package/lib/hooks/useDebounce.d.ts +2 -0
- package/lib/hooks/useDebounce.js +24 -0
- package/lib/sx.d.ts +2 -8
- package/lib/theme-preval.js +2 -2
- package/lib/theme.d.ts +0 -100
- package/lib/utils/testing.d.ts +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +12 -10
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +12 -10
- package/lib-esm/Button/Button.d.ts +6 -6
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +5 -5
- package/lib-esm/Button/ButtonDanger.d.ts +6 -6
- package/lib-esm/Button/ButtonInvisible.d.ts +6 -6
- package/lib-esm/Button/ButtonOutline.d.ts +6 -6
- package/lib-esm/Button/ButtonPrimary.d.ts +6 -6
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +4 -4
- package/lib-esm/DatePicker/DatePicker.d.ts +48 -0
- package/lib-esm/DatePicker/DatePicker.js +83 -0
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib-esm/DatePicker/DatePickerAnchor.js +155 -0
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib-esm/DatePicker/DatePickerOverlay.js +24 -0
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib-esm/DatePicker/DatePickerPanel.js +100 -0
- package/lib-esm/DatePicker/Day.d.ts +14 -0
- package/lib-esm/DatePicker/Day.js +169 -0
- package/lib-esm/DatePicker/Month.d.ts +9 -0
- package/lib-esm/DatePicker/Month.js +96 -0
- package/lib-esm/DatePicker/index.d.ts +2 -0
- package/lib-esm/DatePicker/index.js +1 -0
- package/lib-esm/DatePicker/useDatePicker.d.ts +88 -0
- package/lib-esm/DatePicker/useDatePicker.js +355 -0
- package/lib-esm/Dialog.d.ts +4 -4
- package/lib-esm/Dropdown.d.ts +18 -18
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +7 -7
- package/lib-esm/FilterList.d.ts +3 -3
- package/lib-esm/Flash.d.ts +1 -1
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +32 -30
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +12 -10
- package/lib-esm/Timeline.d.ts +4 -4
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/_TextInputWrapper.d.ts +1 -1
- package/lib-esm/hooks/useDebounce.d.ts +2 -0
- package/lib-esm/hooks/useDebounce.js +16 -0
- package/lib-esm/sx.d.ts +2 -8
- package/lib-esm/theme-preval.js +2 -2
- package/lib-esm/theme.d.ts +0 -100
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package.json +9 -8
@@ -3,9 +3,8 @@ import { SxProp } from '../sx';
|
|
3
3
|
import { ComponentProps } from '../utils/types';
|
4
4
|
declare const ButtonInvisible: import("styled-components").StyledComponent<"button", any, {
|
5
5
|
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
6
|
-
variant?: "
|
6
|
+
variant?: "large" | "medium" | "small" | undefined;
|
7
7
|
} & import("styled-system").FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
8
|
-
disabled?: boolean | undefined;
|
9
8
|
color?: string | undefined;
|
10
9
|
fontSize?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
11
10
|
translate?: "yes" | "no" | undefined;
|
@@ -56,7 +55,7 @@ declare const ButtonInvisible: import("styled-components").StyledComponent<"butt
|
|
56
55
|
results?: number | undefined;
|
57
56
|
security?: string | undefined;
|
58
57
|
unselectable?: "on" | "off" | undefined;
|
59
|
-
inputMode?: "
|
58
|
+
inputMode?: "none" | "text" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
60
59
|
is?: string | undefined;
|
61
60
|
'aria-activedescendant'?: string | undefined;
|
62
61
|
'aria-atomic'?: boolean | "true" | "false" | undefined;
|
@@ -71,7 +70,7 @@ declare const ButtonInvisible: import("styled-components").StyledComponent<"butt
|
|
71
70
|
'aria-describedby'?: string | undefined;
|
72
71
|
'aria-details'?: string | undefined;
|
73
72
|
'aria-disabled'?: boolean | "true" | "false" | undefined;
|
74
|
-
'aria-dropeffect'?: "
|
73
|
+
'aria-dropeffect'?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
75
74
|
'aria-errormessage'?: string | undefined;
|
76
75
|
'aria-expanded'?: boolean | "true" | "false" | undefined;
|
77
76
|
'aria-flowto'?: string | undefined;
|
@@ -269,14 +268,15 @@ declare const ButtonInvisible: import("styled-components").StyledComponent<"butt
|
|
269
268
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
|
270
269
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
271
270
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
272
|
-
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
273
271
|
autoFocus?: boolean | undefined;
|
272
|
+
disabled?: boolean | undefined;
|
274
273
|
formAction?: string | undefined;
|
275
274
|
formEncType?: string | undefined;
|
276
275
|
formMethod?: string | undefined;
|
277
276
|
formNoValidate?: boolean | undefined;
|
278
277
|
formTarget?: string | undefined;
|
279
|
-
|
278
|
+
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
279
|
+
variant?: "large" | "medium" | "small" | undefined;
|
280
280
|
} & {
|
281
281
|
theme?: any;
|
282
282
|
} & import("styled-system").FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("../constants").SystemCommonProps & import("../constants").SystemLayoutProps & SxProp, never>;
|
@@ -3,9 +3,8 @@ import { SxProp } from '../sx';
|
|
3
3
|
import { ComponentProps } from '../utils/types';
|
4
4
|
declare const ButtonOutline: import("styled-components").StyledComponent<"button", any, {
|
5
5
|
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
6
|
-
variant?: "
|
6
|
+
variant?: "large" | "medium" | "small" | undefined;
|
7
7
|
} & import("styled-system").FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
8
|
-
disabled?: boolean | undefined;
|
9
8
|
color?: string | undefined;
|
10
9
|
fontSize?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
11
10
|
translate?: "yes" | "no" | undefined;
|
@@ -56,7 +55,7 @@ declare const ButtonOutline: import("styled-components").StyledComponent<"button
|
|
56
55
|
results?: number | undefined;
|
57
56
|
security?: string | undefined;
|
58
57
|
unselectable?: "on" | "off" | undefined;
|
59
|
-
inputMode?: "
|
58
|
+
inputMode?: "none" | "text" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
60
59
|
is?: string | undefined;
|
61
60
|
'aria-activedescendant'?: string | undefined;
|
62
61
|
'aria-atomic'?: boolean | "true" | "false" | undefined;
|
@@ -71,7 +70,7 @@ declare const ButtonOutline: import("styled-components").StyledComponent<"button
|
|
71
70
|
'aria-describedby'?: string | undefined;
|
72
71
|
'aria-details'?: string | undefined;
|
73
72
|
'aria-disabled'?: boolean | "true" | "false" | undefined;
|
74
|
-
'aria-dropeffect'?: "
|
73
|
+
'aria-dropeffect'?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
75
74
|
'aria-errormessage'?: string | undefined;
|
76
75
|
'aria-expanded'?: boolean | "true" | "false" | undefined;
|
77
76
|
'aria-flowto'?: string | undefined;
|
@@ -269,14 +268,15 @@ declare const ButtonOutline: import("styled-components").StyledComponent<"button
|
|
269
268
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
|
270
269
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
271
270
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
272
|
-
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
273
271
|
autoFocus?: boolean | undefined;
|
272
|
+
disabled?: boolean | undefined;
|
274
273
|
formAction?: string | undefined;
|
275
274
|
formEncType?: string | undefined;
|
276
275
|
formMethod?: string | undefined;
|
277
276
|
formNoValidate?: boolean | undefined;
|
278
277
|
formTarget?: string | undefined;
|
279
|
-
|
278
|
+
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
279
|
+
variant?: "large" | "medium" | "small" | undefined;
|
280
280
|
} & {
|
281
281
|
theme?: any;
|
282
282
|
} & import("styled-system").FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("../constants").SystemCommonProps & import("../constants").SystemLayoutProps & SxProp, never>;
|
@@ -3,9 +3,8 @@ import { SxProp } from '../sx';
|
|
3
3
|
import { ComponentProps } from '../utils/types';
|
4
4
|
export declare const ButtonPrimary: import("styled-components").StyledComponent<"button", any, {
|
5
5
|
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
6
|
-
variant?: "
|
6
|
+
variant?: "large" | "medium" | "small" | undefined;
|
7
7
|
} & import("styled-system").FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
8
|
-
disabled?: boolean | undefined;
|
9
8
|
color?: string | undefined;
|
10
9
|
fontSize?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
11
10
|
translate?: "yes" | "no" | undefined;
|
@@ -56,7 +55,7 @@ export declare const ButtonPrimary: import("styled-components").StyledComponent<
|
|
56
55
|
results?: number | undefined;
|
57
56
|
security?: string | undefined;
|
58
57
|
unselectable?: "on" | "off" | undefined;
|
59
|
-
inputMode?: "
|
58
|
+
inputMode?: "none" | "text" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
60
59
|
is?: string | undefined;
|
61
60
|
'aria-activedescendant'?: string | undefined;
|
62
61
|
'aria-atomic'?: boolean | "true" | "false" | undefined;
|
@@ -71,7 +70,7 @@ export declare const ButtonPrimary: import("styled-components").StyledComponent<
|
|
71
70
|
'aria-describedby'?: string | undefined;
|
72
71
|
'aria-details'?: string | undefined;
|
73
72
|
'aria-disabled'?: boolean | "true" | "false" | undefined;
|
74
|
-
'aria-dropeffect'?: "
|
73
|
+
'aria-dropeffect'?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
75
74
|
'aria-errormessage'?: string | undefined;
|
76
75
|
'aria-expanded'?: boolean | "true" | "false" | undefined;
|
77
76
|
'aria-flowto'?: string | undefined;
|
@@ -269,14 +268,15 @@ export declare const ButtonPrimary: import("styled-components").StyledComponent<
|
|
269
268
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
|
270
269
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
271
270
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
272
|
-
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
273
271
|
autoFocus?: boolean | undefined;
|
272
|
+
disabled?: boolean | undefined;
|
274
273
|
formAction?: string | undefined;
|
275
274
|
formEncType?: string | undefined;
|
276
275
|
formMethod?: string | undefined;
|
277
276
|
formNoValidate?: boolean | undefined;
|
278
277
|
formTarget?: string | undefined;
|
279
|
-
|
278
|
+
as?: string | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
|
279
|
+
variant?: "large" | "medium" | "small" | undefined;
|
280
280
|
} & {
|
281
281
|
theme?: any;
|
282
282
|
} & import("styled-system").FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("../constants").SystemCommonProps & import("../constants").SystemLayoutProps & SxProp, never>;
|
package/lib-esm/CircleBadge.d.ts
CHANGED
@@ -5,7 +5,7 @@ import { SxProp } from './sx';
|
|
5
5
|
import { ComponentProps } from './utils/types';
|
6
6
|
declare const CircleBadge: import("styled-components").StyledComponent<"div", any, {
|
7
7
|
inline?: boolean | undefined;
|
8
|
-
variant?: "
|
8
|
+
variant?: "large" | "medium" | "small" | undefined;
|
9
9
|
size?: number | undefined;
|
10
10
|
} & SystemCommonProps & SxProp, never>;
|
11
11
|
declare const CircleBadgeIcon: import("styled-components").StyledComponent<({ icon: IconComponent, ...rest }: {
|
@@ -15,7 +15,7 @@ export declare type CircleBadgeProps = ComponentProps<typeof CircleBadge>;
|
|
15
15
|
export declare type CircleBadgeIconProps = ComponentProps<typeof CircleBadgeIcon>;
|
16
16
|
declare const _default: string & import("styled-components").StyledComponentBase<"div", any, {
|
17
17
|
inline?: boolean | undefined;
|
18
|
-
variant?: "
|
18
|
+
variant?: "large" | "medium" | "small" | undefined;
|
19
19
|
size?: number | undefined;
|
20
20
|
} & SystemCommonProps & SxProp, never> & import("hoist-non-react-statics").NonReactStatics<never, {}> & {
|
21
21
|
Icon: import("styled-components").StyledComponent<({ icon: IconComponent, ...rest }: {
|
@@ -13,7 +13,6 @@ declare namespace CircleOcticon {
|
|
13
13
|
var defaultProps: {
|
14
14
|
size: number;
|
15
15
|
lineHeight?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
16
|
-
border?: import("styled-system").ResponsiveValue<import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
17
16
|
alignContent?: import("styled-system").ResponsiveValue<import("csstype").Property.AlignContent, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
18
17
|
alignItems?: import("styled-system").ResponsiveValue<import("csstype").Property.AlignItems, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
19
18
|
alignSelf?: import("styled-system").ResponsiveValue<import("csstype").Property.AlignSelf, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -89,6 +88,7 @@ declare namespace CircleOcticon {
|
|
89
88
|
zIndex?: import("styled-system").ResponsiveValue<import("csstype").Property.ZIndex, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
90
89
|
background?: import("styled-system").ResponsiveValue<import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
91
90
|
backgroundPosition?: import("styled-system").ResponsiveValue<import("csstype").Property.BackgroundPosition<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
91
|
+
border?: import("styled-system").ResponsiveValue<import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
92
92
|
borderBottom?: import("styled-system").ResponsiveValue<import("csstype").Property.BorderBottom<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
93
93
|
borderColor?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
94
94
|
borderLeft?: import("styled-system").ResponsiveValue<import("csstype").Property.BorderLeft<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -151,7 +151,7 @@ declare namespace CircleOcticon {
|
|
151
151
|
results?: number | undefined;
|
152
152
|
security?: string | undefined;
|
153
153
|
unselectable?: "on" | "off" | undefined;
|
154
|
-
inputMode?: "
|
154
|
+
inputMode?: "none" | "text" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
155
155
|
is?: string | undefined;
|
156
156
|
'aria-activedescendant'?: string | undefined;
|
157
157
|
'aria-atomic'?: boolean | "true" | "false" | undefined;
|
@@ -166,7 +166,7 @@ declare namespace CircleOcticon {
|
|
166
166
|
'aria-describedby'?: string | undefined;
|
167
167
|
'aria-details'?: string | undefined;
|
168
168
|
'aria-disabled'?: boolean | "true" | "false" | undefined;
|
169
|
-
'aria-dropeffect'?: "
|
169
|
+
'aria-dropeffect'?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
170
170
|
'aria-errormessage'?: string | undefined;
|
171
171
|
'aria-expanded'?: boolean | "true" | "false" | undefined;
|
172
172
|
'aria-flowto'?: string | undefined;
|
@@ -384,7 +384,7 @@ declare namespace CircleOcticon {
|
|
384
384
|
paddingY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
385
385
|
borderX?: import("styled-system").ResponsiveValue<import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
386
386
|
borderY?: import("styled-system").ResponsiveValue<import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
387
|
-
sx?: import("
|
387
|
+
sx?: import("@styled-system/css").SystemStyleObject | undefined;
|
388
388
|
theme?: any;
|
389
389
|
};
|
390
390
|
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { OverlayProps } from '../Overlay';
|
3
|
+
import { FocusTrapHookSettings } from '../hooks/useFocusTrap';
|
4
|
+
import { FocusZoneHookSettings } from '../hooks/useFocusZone';
|
5
|
+
import { DatePickerConfiguration, Selection } from './useDatePicker';
|
6
|
+
declare type OpenGesture = 'anchor-click' | 'anchor-key-press';
|
7
|
+
declare type CloseGesture = 'anchor-click' | 'click-outside' | 'escape';
|
8
|
+
export interface DatePickerProps extends DatePickerConfiguration {
|
9
|
+
/**
|
10
|
+
* An override to the internal ref that will be spread on to the renderAnchor
|
11
|
+
*/
|
12
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
13
|
+
/**
|
14
|
+
* Settings to apply to the Focus Zone on the internal `Overlay` component.
|
15
|
+
*/
|
16
|
+
focusTrapSettings?: Partial<FocusTrapHookSettings>;
|
17
|
+
/**
|
18
|
+
* Settings to apply to the Focus Zone on the internal `Overlay` component.
|
19
|
+
*/
|
20
|
+
focusZoneSettings?: Partial<FocusZoneHookSettings>;
|
21
|
+
initialValue?: 'today' | Date | string | null;
|
22
|
+
iconOnly?: boolean;
|
23
|
+
placeholder?: string;
|
24
|
+
/**
|
25
|
+
* Determines whether the overlay portion of the component should be shown or not
|
26
|
+
*/
|
27
|
+
open?: boolean;
|
28
|
+
/**
|
29
|
+
* A callback which is called whenever the overlay is currently closed and an "open gesture" is detected.
|
30
|
+
*/
|
31
|
+
onOpen?: (gesture: OpenGesture) => unknown;
|
32
|
+
/**
|
33
|
+
* A callback which is called whenever the overlay is currently open and a "close gesture" is detected.
|
34
|
+
*/
|
35
|
+
onClose?: (gesture: CloseGesture) => unknown;
|
36
|
+
/**
|
37
|
+
* Props to be spread on the internal `Overlay` component.
|
38
|
+
*/
|
39
|
+
overlayProps?: Partial<OverlayProps>;
|
40
|
+
/**
|
41
|
+
* A custom function component used to render the anchor element.
|
42
|
+
* Will receive the selected text as `children` prop when an item is activated.
|
43
|
+
*/
|
44
|
+
renderAnchor: <T extends React.HTMLAttributes<HTMLElement>>(props: T) => JSX.Element;
|
45
|
+
value?: Selection;
|
46
|
+
}
|
47
|
+
export declare const DatePicker: React.FC<DatePickerProps>;
|
48
|
+
export {};
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
2
|
+
import { DatePickerAnchor } from './DatePickerAnchor';
|
3
|
+
import { DatePickerProvider } from './useDatePicker';
|
4
|
+
import { DatePickerOverlay } from './DatePickerOverlay';
|
5
|
+
export const DatePicker = ({
|
6
|
+
anchorVariant,
|
7
|
+
anchorRef: externalAnchorRef,
|
8
|
+
confirmation,
|
9
|
+
dateFormat,
|
10
|
+
focusTrapSettings,
|
11
|
+
focusZoneSettings,
|
12
|
+
iconPlacement,
|
13
|
+
maxDate,
|
14
|
+
maxRange,
|
15
|
+
maxSelections,
|
16
|
+
minDate,
|
17
|
+
onOpen: onOpenExternal,
|
18
|
+
onClose: onCloseExternal,
|
19
|
+
open,
|
20
|
+
overlayProps,
|
21
|
+
placeholder,
|
22
|
+
renderAnchor,
|
23
|
+
selection,
|
24
|
+
value,
|
25
|
+
view,
|
26
|
+
weekStartsOn
|
27
|
+
}) => {
|
28
|
+
const anchorRef = useRef(null);
|
29
|
+
const [isOpen, setIsOpen] = useState(false);
|
30
|
+
const datePickerConfiguration = {
|
31
|
+
anchorVariant,
|
32
|
+
confirmation,
|
33
|
+
dateFormat,
|
34
|
+
iconPlacement,
|
35
|
+
maxDate,
|
36
|
+
maxRange,
|
37
|
+
maxSelections,
|
38
|
+
minDate,
|
39
|
+
placeholder,
|
40
|
+
selection,
|
41
|
+
view,
|
42
|
+
weekStartsOn
|
43
|
+
};
|
44
|
+
|
45
|
+
const onOpen = gesture => {
|
46
|
+
setIsOpen(true);
|
47
|
+
onOpenExternal === null || onOpenExternal === void 0 ? void 0 : onOpenExternal(gesture);
|
48
|
+
};
|
49
|
+
|
50
|
+
const onClose = gesture => {
|
51
|
+
setIsOpen(false);
|
52
|
+
onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal(gesture);
|
53
|
+
};
|
54
|
+
|
55
|
+
const toggleIsOpen = () => {
|
56
|
+
if (isOpen) {
|
57
|
+
setIsOpen(false);
|
58
|
+
onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal('anchor-click');
|
59
|
+
} else {
|
60
|
+
setIsOpen(true);
|
61
|
+
onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal('anchor-click');
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
return /*#__PURE__*/React.createElement(DatePickerProvider, {
|
66
|
+
configuration: datePickerConfiguration,
|
67
|
+
value: value,
|
68
|
+
closePicker: () => setIsOpen(false)
|
69
|
+
}, /*#__PURE__*/React.createElement(DatePickerAnchor, {
|
70
|
+
ref: anchorRef,
|
71
|
+
onAction: toggleIsOpen
|
72
|
+
}), /*#__PURE__*/React.createElement(DatePickerOverlay, {
|
73
|
+
anchorRef: externalAnchorRef !== null && externalAnchorRef !== void 0 ? externalAnchorRef : anchorRef,
|
74
|
+
renderAnchor: renderAnchor,
|
75
|
+
open: open !== null && open !== void 0 ? open : isOpen,
|
76
|
+
onOpen: onOpen,
|
77
|
+
onClose: onClose,
|
78
|
+
overlayProps: overlayProps,
|
79
|
+
focusTrapSettings: focusTrapSettings,
|
80
|
+
focusZoneSettings: focusZoneSettings
|
81
|
+
}));
|
82
|
+
};
|
83
|
+
DatePicker.displayName = "DatePicker";
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export interface DatePickerAnchorProps {
|
3
|
+
onAction?: (event?: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
4
|
+
}
|
5
|
+
export declare const DatePickerAnchor: React.ForwardRefExoticComponent<DatePickerAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import { CalendarIcon } from '@primer/octicons-react';
|
2
|
+
import styled from 'styled-components';
|
3
|
+
import React, { useCallback, useState } from 'react';
|
4
|
+
import Button, { ButtonInvisible } from '../Button';
|
5
|
+
import Text from '../Text';
|
6
|
+
import { get } from '../constants';
|
7
|
+
import StyledOcticon from '../StyledOcticon';
|
8
|
+
import useDatePicker from './useDatePicker';
|
9
|
+
import TextInput from '../TextInput';
|
10
|
+
import Box from '../Box';
|
11
|
+
import { isBefore } from 'date-fns';
|
12
|
+
const DatePickerAnchorButton = styled(Button).withConfig({
|
13
|
+
displayName: "DatePickerAnchor__DatePickerAnchorButton",
|
14
|
+
componentId: "sc-8gpb9d-0"
|
15
|
+
})(["align-items:center;display:flex;flex-direction:row;justify-content:space-between;max-width:350px;overflow:hidden;& ", " ~ svg{margin-left:", ";}& svg ~ ", "{margin-left:", ";}"], Text, get('space.2'), Text, get('space.2'));
|
16
|
+
const INVALID_DATE = 'Invalid Date';
|
17
|
+
export const DatePickerAnchor = /*#__PURE__*/React.forwardRef(({
|
18
|
+
onAction
|
19
|
+
}, ref) => {
|
20
|
+
const {
|
21
|
+
configuration: {
|
22
|
+
anchorVariant,
|
23
|
+
iconPlacement,
|
24
|
+
selection
|
25
|
+
},
|
26
|
+
disabled,
|
27
|
+
formattedDate,
|
28
|
+
onDateInput
|
29
|
+
} = useDatePicker();
|
30
|
+
const [inputValue, setInputValue] = useState(formattedDate);
|
31
|
+
const keyPressHandler = useCallback(event => {
|
32
|
+
if (disabled) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
|
36
|
+
if ([' ', 'Enter'].includes(event.key)) {
|
37
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(event);
|
38
|
+
}
|
39
|
+
}, [disabled, onAction]);
|
40
|
+
const clickHandler = useCallback(event => {
|
41
|
+
if (disabled) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(event);
|
46
|
+
}, [disabled, onAction]);
|
47
|
+
const onInputChangeHandler = useCallback(e => {
|
48
|
+
const value = e.currentTarget.value;
|
49
|
+
if (!value) return;
|
50
|
+
|
51
|
+
if (selection === 'range') {
|
52
|
+
var _values$, _values$2, _values$3, _values$4, _values$5, _values$6;
|
53
|
+
|
54
|
+
const values = value.split(' - ');
|
55
|
+
const dates = isBefore(new Date((_values$ = values[0]) === null || _values$ === void 0 ? void 0 : _values$.trim()), new Date((_values$2 = values[1]) === null || _values$2 === void 0 ? void 0 : _values$2.trim())) ? {
|
56
|
+
from: new Date((_values$3 = values[0]) === null || _values$3 === void 0 ? void 0 : _values$3.trim()),
|
57
|
+
to: new Date((_values$4 = values[1]) === null || _values$4 === void 0 ? void 0 : _values$4.trim())
|
58
|
+
} : {
|
59
|
+
from: new Date((_values$5 = values[1]) === null || _values$5 === void 0 ? void 0 : _values$5.trim()),
|
60
|
+
to: new Date((_values$6 = values[0]) === null || _values$6 === void 0 ? void 0 : _values$6.trim())
|
61
|
+
};
|
62
|
+
setInputValue(value);
|
63
|
+
|
64
|
+
if (dates.from.toString() !== INVALID_DATE && dates.to.toString() !== INVALID_DATE) {
|
65
|
+
onDateInput(dates);
|
66
|
+
}
|
67
|
+
} else if (selection === 'multi') {
|
68
|
+
const values = value.split(',');
|
69
|
+
const dates = [];
|
70
|
+
|
71
|
+
for (const date of values) {
|
72
|
+
dates.push(new Date(date.trim()));
|
73
|
+
}
|
74
|
+
|
75
|
+
setInputValue(value);
|
76
|
+
|
77
|
+
if (dates.every(d => d.toString() !== INVALID_DATE)) {
|
78
|
+
onDateInput(dates);
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
const date = new Date(value);
|
82
|
+
setInputValue(value);
|
83
|
+
if (date.toString() !== INVALID_DATE) onDateInput(date);
|
84
|
+
}
|
85
|
+
}, [onDateInput, selection]);
|
86
|
+
|
87
|
+
const onBlurHandler = () => {
|
88
|
+
setInputValue(formattedDate);
|
89
|
+
};
|
90
|
+
|
91
|
+
if (anchorVariant === 'input') {
|
92
|
+
const calendarButton = side => /*#__PURE__*/React.createElement(ButtonInvisible, {
|
93
|
+
onClick: clickHandler,
|
94
|
+
sx: {
|
95
|
+
width: '32px',
|
96
|
+
px: '6px',
|
97
|
+
position: 'absolute',
|
98
|
+
[side]: '1px',
|
99
|
+
top: '1px'
|
100
|
+
}
|
101
|
+
}, /*#__PURE__*/React.createElement(StyledOcticon, {
|
102
|
+
icon: CalendarIcon
|
103
|
+
}));
|
104
|
+
|
105
|
+
const inputSx = () => {
|
106
|
+
if (iconPlacement === 'start') {
|
107
|
+
return {
|
108
|
+
pl: 5,
|
109
|
+
pr: 2
|
110
|
+
};
|
111
|
+
} else if (iconPlacement === 'end') {
|
112
|
+
return {
|
113
|
+
pl: 2,
|
114
|
+
pr: 5
|
115
|
+
};
|
116
|
+
} else {
|
117
|
+
return {};
|
118
|
+
}
|
119
|
+
};
|
120
|
+
|
121
|
+
return /*#__PURE__*/React.createElement(Box, {
|
122
|
+
ref: ref,
|
123
|
+
sx: {
|
124
|
+
position: 'relative',
|
125
|
+
display: 'flex',
|
126
|
+
flex: 1
|
127
|
+
}
|
128
|
+
}, iconPlacement === 'start' && calendarButton('left'), /*#__PURE__*/React.createElement(TextInput, {
|
129
|
+
value: inputValue,
|
130
|
+
onChange: onInputChangeHandler,
|
131
|
+
sx: inputSx(),
|
132
|
+
onBlur: onBlurHandler
|
133
|
+
}), iconPlacement === 'end' && calendarButton('right'));
|
134
|
+
}
|
135
|
+
|
136
|
+
const calendarIcon = () => /*#__PURE__*/React.createElement(StyledOcticon, {
|
137
|
+
icon: CalendarIcon,
|
138
|
+
color: "fg.muted",
|
139
|
+
sx: {
|
140
|
+
my: '2px'
|
141
|
+
}
|
142
|
+
});
|
143
|
+
|
144
|
+
return /*#__PURE__*/React.createElement(Box, {
|
145
|
+
ref: ref
|
146
|
+
}, /*#__PURE__*/React.createElement(DatePickerAnchorButton, {
|
147
|
+
onClick: clickHandler,
|
148
|
+
onKeyPress: keyPressHandler
|
149
|
+
}, iconPlacement === 'start' && calendarIcon(), anchorVariant !== 'icon-only' && /*#__PURE__*/React.createElement(Text, {
|
150
|
+
sx: {
|
151
|
+
overflow: 'hidden',
|
152
|
+
textOverflow: 'ellipsis'
|
153
|
+
}
|
154
|
+
}, formattedDate), iconPlacement === 'end' && calendarIcon()));
|
155
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
import React from 'react';
|
4
|
+
import useDatePicker from './useDatePicker';
|
5
|
+
import { AnchoredOverlay } from '../AnchoredOverlay';
|
6
|
+
import { DatePickerPanel } from './DatePickerPanel';
|
7
|
+
export const DatePickerOverlay = ({
|
8
|
+
onClose,
|
9
|
+
...rest
|
10
|
+
}) => {
|
11
|
+
const {
|
12
|
+
revertValue
|
13
|
+
} = useDatePicker();
|
14
|
+
|
15
|
+
const onOverlayClose = gesture => {
|
16
|
+
revertValue();
|
17
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(gesture);
|
18
|
+
};
|
19
|
+
|
20
|
+
return /*#__PURE__*/React.createElement(AnchoredOverlay, _extends({
|
21
|
+
onClose: onOverlayClose
|
22
|
+
}, rest), /*#__PURE__*/React.createElement(DatePickerPanel, null));
|
23
|
+
};
|
24
|
+
DatePickerOverlay.displayName = "DatePickerOverlay";
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import { addMonths, subMonths } from 'date-fns';
|
2
|
+
import React, { useMemo } from 'react';
|
3
|
+
import Box from '../Box';
|
4
|
+
import { Month } from './Month';
|
5
|
+
import styled from 'styled-components';
|
6
|
+
import { get } from '../constants';
|
7
|
+
import useDatePicker from './useDatePicker';
|
8
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '@primer/octicons-react';
|
9
|
+
import StyledOcticon from '../StyledOcticon';
|
10
|
+
import Button, { ButtonPrimary } from '../Button';
|
11
|
+
const DatePickerPanelContainer = styled(Box).withConfig({
|
12
|
+
displayName: "DatePickerPanel__DatePickerPanelContainer",
|
13
|
+
componentId: "sc-19upxpo-0"
|
14
|
+
})(["align-items:stretch;display:flex;flex-direction:column;"]);
|
15
|
+
const DatePickerPanelMonths = styled(Box).withConfig({
|
16
|
+
displayName: "DatePickerPanel__DatePickerPanelMonths",
|
17
|
+
componentId: "sc-19upxpo-1"
|
18
|
+
})(["align-items:flex-start;display:flex;flex-direction:row;gap:", ";padding:", ";position:relative;"], get('space.6'), get('space.3'));
|
19
|
+
const DatePickerPanelFooter = styled(Box).withConfig({
|
20
|
+
displayName: "DatePickerPanel__DatePickerPanelFooter",
|
21
|
+
componentId: "sc-19upxpo-2"
|
22
|
+
})(["align-items:flex-start;border-top:1px solid;border-top-color:", ";display:flex;gap:", ";padding-top:12px;padding-bottom:12px;padding-left:", ";padding-right:", ";flex-direction:row;justify-content:space-between;position:relative;"], get('colors.border.default'), get('space.6'), get('space.3'), get('space.3'));
|
23
|
+
const ArrowButton = styled(Button).withConfig({
|
24
|
+
displayName: "DatePickerPanel__ArrowButton",
|
25
|
+
componentId: "sc-19upxpo-3"
|
26
|
+
})(["position:absolute;width:40px;height:28px;top:12px;", ";"], props => `${props.side}: ${get('space.3')(props)}`);
|
27
|
+
export const DatePickerPanel = () => {
|
28
|
+
const {
|
29
|
+
configuration,
|
30
|
+
saveValue,
|
31
|
+
revertValue,
|
32
|
+
currentViewingDate,
|
33
|
+
goToMonth,
|
34
|
+
nextMonth,
|
35
|
+
previousMonth
|
36
|
+
} = useDatePicker();
|
37
|
+
const previousDisabled = useMemo(() => {
|
38
|
+
const {
|
39
|
+
minDate
|
40
|
+
} = configuration;
|
41
|
+
if (!minDate) return false;
|
42
|
+
const previous = subMonths(currentViewingDate, 1);
|
43
|
+
|
44
|
+
if (minDate.getFullYear() >= previous.getFullYear() && minDate.getMonth() > previous.getMonth()) {
|
45
|
+
return true;
|
46
|
+
}
|
47
|
+
|
48
|
+
return false;
|
49
|
+
}, [configuration, currentViewingDate]);
|
50
|
+
const nextDisabled = useMemo(() => {
|
51
|
+
const {
|
52
|
+
maxDate,
|
53
|
+
view
|
54
|
+
} = configuration;
|
55
|
+
if (!maxDate) return false;
|
56
|
+
const next = addMonths(currentViewingDate, view === '2-month' ? 2 : 1);
|
57
|
+
|
58
|
+
if (maxDate.getFullYear() <= next.getFullYear() && maxDate.getMonth() < next.getMonth()) {
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
|
62
|
+
return false;
|
63
|
+
}, [configuration, currentViewingDate]);
|
64
|
+
return /*#__PURE__*/React.createElement(DatePickerPanelContainer, null, /*#__PURE__*/React.createElement(DatePickerPanelMonths, null, /*#__PURE__*/React.createElement(ArrowButton, {
|
65
|
+
variant: "small",
|
66
|
+
side: "left",
|
67
|
+
onClick: previousMonth,
|
68
|
+
disabled: previousDisabled
|
69
|
+
}, /*#__PURE__*/React.createElement(StyledOcticon, {
|
70
|
+
icon: ChevronLeftIcon,
|
71
|
+
color: "fg.muted"
|
72
|
+
})), /*#__PURE__*/React.createElement(Month, {
|
73
|
+
month: currentViewingDate.getMonth(),
|
74
|
+
year: currentViewingDate.getFullYear()
|
75
|
+
}), configuration.view === '2-month' && /*#__PURE__*/React.createElement(Month, {
|
76
|
+
month: addMonths(currentViewingDate, 1).getMonth(),
|
77
|
+
year: addMonths(currentViewingDate, 1).getFullYear()
|
78
|
+
}), /*#__PURE__*/React.createElement(ArrowButton, {
|
79
|
+
variant: "small",
|
80
|
+
side: "right",
|
81
|
+
onClick: nextMonth,
|
82
|
+
disabled: nextDisabled
|
83
|
+
}, /*#__PURE__*/React.createElement(StyledOcticon, {
|
84
|
+
icon: ChevronRightIcon,
|
85
|
+
color: "fg.muted"
|
86
|
+
}))), /*#__PURE__*/React.createElement(DatePickerPanelFooter, null, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
|
87
|
+
variant: "small",
|
88
|
+
sx: {
|
89
|
+
mr: 1
|
90
|
+
},
|
91
|
+
onClick: () => revertValue()
|
92
|
+
}, "Reset"), /*#__PURE__*/React.createElement(Button, {
|
93
|
+
variant: "small",
|
94
|
+
onClick: () => goToMonth(new Date())
|
95
|
+
}, "Today")), configuration.confirmation && /*#__PURE__*/React.createElement(ButtonPrimary, {
|
96
|
+
variant: "small",
|
97
|
+
onClick: () => saveValue()
|
98
|
+
}, "Apply")));
|
99
|
+
};
|
100
|
+
DatePickerPanel.displayName = "DatePickerPanel";
|