@primer/components 0.0.0-202192602912 → 0.0.0-20219266052
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 +4 -8
- package/dist/browser.esm.js +3 -3
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +3 -3
- package/dist/browser.umd.js.map +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
- package/lib/Autocomplete/Autocomplete.d.ts +11 -13
- package/lib/Autocomplete/AutocompleteInput.d.ts +11 -13
- package/lib/Button/Button.d.ts +11 -11
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +29 -29
- package/lib/Button/ButtonDanger.d.ts +11 -11
- package/lib/Button/ButtonInvisible.d.ts +11 -11
- package/lib/Button/ButtonOutline.d.ts +11 -11
- package/lib/Button/ButtonPrimary.d.ts +11 -11
- package/lib/Button/ButtonStyles.js +1 -1
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +33 -33
- package/lib/Dialog.d.ts +35 -35
- package/lib/Dropdown.d.ts +110 -110
- package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib/FilterList.d.ts +26 -26
- package/lib/Label.d.ts +1 -1
- package/lib/NewButton/button.d.ts +24 -0
- package/lib/NewButton/button.js +292 -0
- package/lib/NewButton/counter.d.ts +6 -0
- package/lib/NewButton/counter.js +33 -0
- package/lib/NewButton/index.d.ts +4 -0
- package/lib/NewButton/index.js +21 -0
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +151 -153
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +11 -13
- package/lib/Timeline.d.ts +33 -33
- 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/constants.js +3 -1
- package/lib/theme-preval.js +2 -2
- package/lib/utils/testing.d.ts +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
- package/lib-esm/Autocomplete/Autocomplete.d.ts +11 -13
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +11 -13
- package/lib-esm/Button/Button.d.ts +11 -11
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +29 -29
- package/lib-esm/Button/ButtonDanger.d.ts +11 -11
- package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
- package/lib-esm/Button/ButtonOutline.d.ts +11 -11
- package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
- package/lib-esm/Button/ButtonStyles.js +1 -1
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +33 -33
- package/lib-esm/Dialog.d.ts +35 -35
- package/lib-esm/Dropdown.d.ts +110 -110
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib-esm/FilterList.d.ts +26 -26
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/NewButton/button.d.ts +24 -0
- package/lib-esm/NewButton/button.js +268 -0
- package/lib-esm/NewButton/counter.d.ts +6 -0
- package/lib-esm/NewButton/counter.js +21 -0
- package/lib-esm/NewButton/index.d.ts +4 -0
- package/lib-esm/NewButton/index.js +3 -0
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +151 -153
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +11 -13
- package/lib-esm/Timeline.d.ts +33 -33
- 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/constants.js +3 -1
- package/lib-esm/theme-preval.js +2 -2
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package.json +8 -9
- package/lib/DatePicker/DatePicker.d.ts +0 -48
- package/lib/DatePicker/DatePicker.js +0 -92
- package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
- package/lib/DatePicker/DatePickerAnchor.js +0 -158
- package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
- package/lib/DatePicker/DatePickerOverlay.js +0 -39
- package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
- package/lib/DatePicker/DatePickerPanel.js +0 -126
- package/lib/DatePicker/Day.d.ts +0 -14
- package/lib/DatePicker/Day.js +0 -174
- package/lib/DatePicker/Month.d.ts +0 -9
- package/lib/DatePicker/Month.js +0 -107
- package/lib/DatePicker/index.d.ts +0 -2
- package/lib/DatePicker/index.js +0 -13
- package/lib/DatePicker/useDatePicker.d.ts +0 -83
- package/lib/DatePicker/useDatePicker.js +0 -375
- package/lib/hooks/useDebounce.d.ts +0 -2
- package/lib/hooks/useDebounce.js +0 -24
- package/lib-esm/DatePicker/DatePicker.d.ts +0 -48
- package/lib-esm/DatePicker/DatePicker.js +0 -75
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
- package/lib-esm/DatePicker/DatePickerAnchor.js +0 -132
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
- package/lib-esm/DatePicker/DatePickerOverlay.js +0 -24
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
- package/lib-esm/DatePicker/DatePickerPanel.js +0 -100
- package/lib-esm/DatePicker/Day.d.ts +0 -14
- package/lib-esm/DatePicker/Day.js +0 -151
- package/lib-esm/DatePicker/Month.d.ts +0 -9
- package/lib-esm/DatePicker/Month.js +0 -83
- package/lib-esm/DatePicker/index.d.ts +0 -2
- package/lib-esm/DatePicker/index.js +0 -1
- package/lib-esm/DatePicker/useDatePicker.d.ts +0 -83
- package/lib-esm/DatePicker/useDatePicker.js +0 -347
- package/lib-esm/hooks/useDebounce.d.ts +0 -2
- package/lib-esm/hooks/useDebounce.js +0 -16
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-20219266052",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -43,16 +43,20 @@
|
|
43
43
|
"author": "GitHub, Inc.",
|
44
44
|
"license": "MIT",
|
45
45
|
"dependencies": {
|
46
|
-
"@primer/octicons-react": "^
|
47
|
-
"@primer/primitives": "
|
46
|
+
"@primer/octicons-react": "^13.0.0",
|
47
|
+
"@primer/primitives": "5.1.0",
|
48
48
|
"@radix-ui/react-polymorphic": "0.0.14",
|
49
49
|
"@react-aria/ssr": "3.1.0",
|
50
50
|
"@styled-system/css": "5.1.5",
|
51
51
|
"@styled-system/props": "5.1.5",
|
52
52
|
"@styled-system/theme-get": "5.1.2",
|
53
|
+
"@types/history": "4.7.8",
|
54
|
+
"@types/styled-components": "5.1.11",
|
55
|
+
"@types/styled-system": "5.1.12",
|
56
|
+
"@types/styled-system__css": "5.0.16",
|
57
|
+
"@types/styled-system__theme-get": "5.0.1",
|
53
58
|
"classnames": "2.3.1",
|
54
59
|
"color2k": "1.2.4",
|
55
|
-
"date-fns": "2.25.0",
|
56
60
|
"deepmerge": "4.2.2",
|
57
61
|
"focus-visible": "5.2.0",
|
58
62
|
"styled-system": "5.1.5"
|
@@ -81,11 +85,6 @@
|
|
81
85
|
"@testing-library/react": "11.2.7",
|
82
86
|
"@testing-library/react-hooks": "7.0.2",
|
83
87
|
"@testing-library/user-event": "13.1.9",
|
84
|
-
"@types/history": "4.7.9",
|
85
|
-
"@types/styled-components": "5.1.15",
|
86
|
-
"@types/styled-system": "5.1.13",
|
87
|
-
"@types/styled-system__css": "5.0.16",
|
88
|
-
"@types/styled-system__theme-get": "5.0.1",
|
89
88
|
"@types/chroma-js": "2.1.3",
|
90
89
|
"@types/enzyme": "3.10.9",
|
91
90
|
"@types/jest": "26.0.23",
|
@@ -1,48 +0,0 @@
|
|
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 {};
|
@@ -1,92 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.DatePicker = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
|
-
var _DatePickerAnchor = require("./DatePickerAnchor");
|
11
|
-
|
12
|
-
var _useDatePicker = require("./useDatePicker");
|
13
|
-
|
14
|
-
var _DatePickerOverlay = require("./DatePickerOverlay");
|
15
|
-
|
16
|
-
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); }
|
17
|
-
|
18
|
-
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; }
|
19
|
-
|
20
|
-
const DatePicker = ({
|
21
|
-
anchorVariant,
|
22
|
-
anchorRef: externalAnchorRef,
|
23
|
-
confirmation,
|
24
|
-
dateFormat,
|
25
|
-
focusTrapSettings,
|
26
|
-
focusZoneSettings,
|
27
|
-
maxDate,
|
28
|
-
minDate,
|
29
|
-
onOpen: onOpenExternal,
|
30
|
-
onClose: onCloseExternal,
|
31
|
-
open,
|
32
|
-
overlayProps,
|
33
|
-
renderAnchor,
|
34
|
-
selection,
|
35
|
-
value,
|
36
|
-
view,
|
37
|
-
weekStartsOn
|
38
|
-
}) => {
|
39
|
-
const buttonRef = (0, _react.useRef)(null);
|
40
|
-
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
41
|
-
const datePickerConfiguration = {
|
42
|
-
anchorVariant,
|
43
|
-
confirmation,
|
44
|
-
dateFormat,
|
45
|
-
maxDate,
|
46
|
-
minDate,
|
47
|
-
selection,
|
48
|
-
view,
|
49
|
-
weekStartsOn
|
50
|
-
};
|
51
|
-
|
52
|
-
const onOpen = gesture => {
|
53
|
-
setIsOpen(true);
|
54
|
-
onOpenExternal === null || onOpenExternal === void 0 ? void 0 : onOpenExternal(gesture);
|
55
|
-
};
|
56
|
-
|
57
|
-
const onClose = gesture => {
|
58
|
-
setIsOpen(false);
|
59
|
-
onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal(gesture);
|
60
|
-
};
|
61
|
-
|
62
|
-
const toggleIsOpen = () => {
|
63
|
-
if (isOpen) {
|
64
|
-
setIsOpen(false);
|
65
|
-
onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal('anchor-click');
|
66
|
-
} else {
|
67
|
-
setIsOpen(true);
|
68
|
-
onCloseExternal === null || onCloseExternal === void 0 ? void 0 : onCloseExternal('anchor-click');
|
69
|
-
}
|
70
|
-
};
|
71
|
-
|
72
|
-
return /*#__PURE__*/_react.default.createElement(_useDatePicker.DatePickerProvider, {
|
73
|
-
configuration: datePickerConfiguration,
|
74
|
-
value: value,
|
75
|
-
closePicker: () => setIsOpen(false)
|
76
|
-
}, /*#__PURE__*/_react.default.createElement(_DatePickerAnchor.DatePickerAnchor, {
|
77
|
-
ref: buttonRef,
|
78
|
-
onAction: toggleIsOpen
|
79
|
-
}), /*#__PURE__*/_react.default.createElement(_DatePickerOverlay.DatePickerOverlay, {
|
80
|
-
anchorRef: externalAnchorRef !== null && externalAnchorRef !== void 0 ? externalAnchorRef : buttonRef,
|
81
|
-
renderAnchor: renderAnchor,
|
82
|
-
open: open !== null && open !== void 0 ? open : isOpen,
|
83
|
-
onOpen: onOpen,
|
84
|
-
onClose: onClose,
|
85
|
-
overlayProps: overlayProps,
|
86
|
-
focusTrapSettings: focusTrapSettings,
|
87
|
-
focusZoneSettings: focusZoneSettings
|
88
|
-
}));
|
89
|
-
};
|
90
|
-
|
91
|
-
exports.DatePicker = DatePicker;
|
92
|
-
DatePicker.displayName = "DatePicker";
|
@@ -1,5 +0,0 @@
|
|
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>>;
|
@@ -1,158 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.DatePickerAnchor = void 0;
|
7
|
-
|
8
|
-
var _octiconsReact = require("@primer/octicons-react");
|
9
|
-
|
10
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
11
|
-
|
12
|
-
var _react = _interopRequireWildcard(require("react"));
|
13
|
-
|
14
|
-
var _Button = _interopRequireWildcard(require("../Button"));
|
15
|
-
|
16
|
-
var _Text = _interopRequireDefault(require("../Text"));
|
17
|
-
|
18
|
-
var _constants = require("../constants");
|
19
|
-
|
20
|
-
var _StyledOcticon = _interopRequireDefault(require("../StyledOcticon"));
|
21
|
-
|
22
|
-
var _useDatePicker = _interopRequireDefault(require("./useDatePicker"));
|
23
|
-
|
24
|
-
var _TextInput = _interopRequireDefault(require("../TextInput"));
|
25
|
-
|
26
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
27
|
-
|
28
|
-
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); }
|
29
|
-
|
30
|
-
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; }
|
31
|
-
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
|
-
|
34
|
-
const DatePickerAnchorButton = (0, _styledComponents.default)(_Button.default).withConfig({
|
35
|
-
displayName: "DatePickerAnchor__DatePickerAnchorButton",
|
36
|
-
componentId: "sc-8gpb9d-0"
|
37
|
-
})(["align-items:center;display:flex;flex-direction:row;justify-content:space-between;max-width:350px;overflow:hidden;& ", "{margin-left:", ";}"], _Text.default, (0, _constants.get)('space.2'));
|
38
|
-
|
39
|
-
const DatePickerAnchor = /*#__PURE__*/_react.default.forwardRef(({
|
40
|
-
onAction
|
41
|
-
}, ref) => {
|
42
|
-
const {
|
43
|
-
configuration: {
|
44
|
-
anchorVariant,
|
45
|
-
iconPlacement,
|
46
|
-
selection
|
47
|
-
},
|
48
|
-
disabled,
|
49
|
-
formattedDate
|
50
|
-
} = (0, _useDatePicker.default)();
|
51
|
-
const keyPressHandler = (0, _react.useCallback)(event => {
|
52
|
-
if (disabled) {
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
|
56
|
-
if ([' ', 'Enter'].includes(event.key)) {
|
57
|
-
onAction === null || onAction === void 0 ? void 0 : onAction(event);
|
58
|
-
}
|
59
|
-
}, [disabled, onAction]);
|
60
|
-
const clickHandler = (0, _react.useCallback)(event => {
|
61
|
-
if (disabled) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
|
65
|
-
onAction === null || onAction === void 0 ? void 0 : onAction(event);
|
66
|
-
}, [disabled, onAction]);
|
67
|
-
const onInputChangeHandler = (0, _react.useCallback)(e => {
|
68
|
-
const value = e.currentTarget.value;
|
69
|
-
if (!value) return;
|
70
|
-
|
71
|
-
if (selection === 'range') {
|
72
|
-
var _values$, _values$2;
|
73
|
-
|
74
|
-
const values = value.split(' - ');
|
75
|
-
const dates = {
|
76
|
-
from: new Date((_values$ = values[0]) === null || _values$ === void 0 ? void 0 : _values$.trim()),
|
77
|
-
to: new Date((_values$2 = values[1]) === null || _values$2 === void 0 ? void 0 : _values$2.trim())
|
78
|
-
};
|
79
|
-
console.log(dates);
|
80
|
-
} else if (selection === 'multi') {
|
81
|
-
const values = value.split(',');
|
82
|
-
const dates = [];
|
83
|
-
|
84
|
-
for (const date of values) {
|
85
|
-
dates.push(new Date(date.trim()));
|
86
|
-
}
|
87
|
-
|
88
|
-
console.log(dates);
|
89
|
-
} else {
|
90
|
-
const date = new Date(value);
|
91
|
-
console.log(date);
|
92
|
-
}
|
93
|
-
}, [selection]);
|
94
|
-
|
95
|
-
if (anchorVariant === 'input') {
|
96
|
-
const calendarButton = side => /*#__PURE__*/_react.default.createElement(_Button.ButtonInvisible, {
|
97
|
-
onClick: clickHandler,
|
98
|
-
sx: {
|
99
|
-
width: '32px',
|
100
|
-
px: '6px',
|
101
|
-
position: 'absolute',
|
102
|
-
[side]: '1px',
|
103
|
-
top: '1px'
|
104
|
-
}
|
105
|
-
}, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
|
106
|
-
icon: _octiconsReact.CalendarIcon
|
107
|
-
}));
|
108
|
-
|
109
|
-
const inputSx = () => {
|
110
|
-
if (iconPlacement === 'start') {
|
111
|
-
return {
|
112
|
-
pl: 5,
|
113
|
-
pr: 2
|
114
|
-
};
|
115
|
-
} else if (iconPlacement === 'end') {
|
116
|
-
return {
|
117
|
-
pl: 2,
|
118
|
-
pr: 5
|
119
|
-
};
|
120
|
-
} else {
|
121
|
-
return {};
|
122
|
-
}
|
123
|
-
};
|
124
|
-
|
125
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
126
|
-
ref: ref,
|
127
|
-
sx: {
|
128
|
-
position: 'relative',
|
129
|
-
display: 'flex',
|
130
|
-
flex: 1
|
131
|
-
}
|
132
|
-
}, iconPlacement === 'start' && calendarButton('left'), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
133
|
-
defaultValue: formattedDate,
|
134
|
-
onChange: onInputChangeHandler,
|
135
|
-
sx: inputSx()
|
136
|
-
}), iconPlacement === 'end' && calendarButton('right'));
|
137
|
-
}
|
138
|
-
|
139
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
140
|
-
ref: ref
|
141
|
-
}, /*#__PURE__*/_react.default.createElement(DatePickerAnchorButton, {
|
142
|
-
onClick: clickHandler,
|
143
|
-
onKeyPress: keyPressHandler
|
144
|
-
}, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
|
145
|
-
icon: _octiconsReact.CalendarIcon,
|
146
|
-
color: "fg.muted",
|
147
|
-
sx: {
|
148
|
-
my: '2px'
|
149
|
-
}
|
150
|
-
}), anchorVariant !== 'icon-only' && /*#__PURE__*/_react.default.createElement(_Text.default, {
|
151
|
-
sx: {
|
152
|
-
overflow: 'hidden',
|
153
|
-
textOverflow: 'ellipsis'
|
154
|
-
}
|
155
|
-
}, formattedDate)));
|
156
|
-
});
|
157
|
-
|
158
|
-
exports.DatePickerAnchor = DatePickerAnchor;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.DatePickerOverlay = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _useDatePicker = _interopRequireDefault(require("./useDatePicker"));
|
11
|
-
|
12
|
-
var _AnchoredOverlay = require("../AnchoredOverlay");
|
13
|
-
|
14
|
-
var _DatePickerPanel = require("./DatePickerPanel");
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
|
-
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); }
|
19
|
-
|
20
|
-
const DatePickerOverlay = ({
|
21
|
-
onClose,
|
22
|
-
...rest
|
23
|
-
}) => {
|
24
|
-
const {
|
25
|
-
revertValue
|
26
|
-
} = (0, _useDatePicker.default)();
|
27
|
-
|
28
|
-
const onOverlayClose = gesture => {
|
29
|
-
revertValue();
|
30
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(gesture);
|
31
|
-
};
|
32
|
-
|
33
|
-
return /*#__PURE__*/_react.default.createElement(_AnchoredOverlay.AnchoredOverlay, _extends({
|
34
|
-
onClose: onOverlayClose
|
35
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_DatePickerPanel.DatePickerPanel, null));
|
36
|
-
};
|
37
|
-
|
38
|
-
exports.DatePickerOverlay = DatePickerOverlay;
|
39
|
-
DatePickerOverlay.displayName = "DatePickerOverlay";
|
@@ -1,126 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.DatePickerPanel = void 0;
|
7
|
-
|
8
|
-
var _dateFns = require("date-fns");
|
9
|
-
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
11
|
-
|
12
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
13
|
-
|
14
|
-
var _Month = require("./Month");
|
15
|
-
|
16
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
17
|
-
|
18
|
-
var _constants = require("../constants");
|
19
|
-
|
20
|
-
var _useDatePicker = _interopRequireDefault(require("./useDatePicker"));
|
21
|
-
|
22
|
-
var _octiconsReact = require("@primer/octicons-react");
|
23
|
-
|
24
|
-
var _StyledOcticon = _interopRequireDefault(require("../StyledOcticon"));
|
25
|
-
|
26
|
-
var _Button = _interopRequireWildcard(require("../Button"));
|
27
|
-
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
|
-
|
30
|
-
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); }
|
31
|
-
|
32
|
-
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; }
|
33
|
-
|
34
|
-
const DatePickerPanelContainer = (0, _styledComponents.default)(_Box.default).withConfig({
|
35
|
-
displayName: "DatePickerPanel__DatePickerPanelContainer",
|
36
|
-
componentId: "sc-19upxpo-0"
|
37
|
-
})(["align-items:stretch;display:flex;flex-direction:column;"]);
|
38
|
-
const DatePickerPanelMonths = (0, _styledComponents.default)(_Box.default).withConfig({
|
39
|
-
displayName: "DatePickerPanel__DatePickerPanelMonths",
|
40
|
-
componentId: "sc-19upxpo-1"
|
41
|
-
})(["align-items:flex-start;display:flex;flex-direction:row;gap:", ";padding:", ";position:relative;"], (0, _constants.get)('space.6'), (0, _constants.get)('space.3'));
|
42
|
-
const DatePickerPanelFooter = (0, _styledComponents.default)(_Box.default).withConfig({
|
43
|
-
displayName: "DatePickerPanel__DatePickerPanelFooter",
|
44
|
-
componentId: "sc-19upxpo-2"
|
45
|
-
})(["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;"], (0, _constants.get)('colors.border.default'), (0, _constants.get)('space.6'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'));
|
46
|
-
const ArrowButton = (0, _styledComponents.default)(_Button.default).withConfig({
|
47
|
-
displayName: "DatePickerPanel__ArrowButton",
|
48
|
-
componentId: "sc-19upxpo-3"
|
49
|
-
})(["position:absolute;width:40px;height:28px;top:12px;", ";"], props => `${props.side}: ${(0, _constants.get)('space.3')(props)}`);
|
50
|
-
|
51
|
-
const DatePickerPanel = () => {
|
52
|
-
const {
|
53
|
-
configuration,
|
54
|
-
saveValue,
|
55
|
-
revertValue,
|
56
|
-
currentViewingDate,
|
57
|
-
goToMonth,
|
58
|
-
nextMonth,
|
59
|
-
previousMonth
|
60
|
-
} = (0, _useDatePicker.default)();
|
61
|
-
const previousDisabled = (0, _react.useMemo)(() => {
|
62
|
-
const {
|
63
|
-
minDate
|
64
|
-
} = configuration;
|
65
|
-
if (!minDate) return false;
|
66
|
-
const previous = (0, _dateFns.subMonths)(currentViewingDate, 1);
|
67
|
-
|
68
|
-
if (minDate.getFullYear() >= previous.getFullYear() && minDate.getMonth() > previous.getMonth()) {
|
69
|
-
return true;
|
70
|
-
}
|
71
|
-
|
72
|
-
return false;
|
73
|
-
}, [configuration, currentViewingDate]);
|
74
|
-
const nextDisabled = (0, _react.useMemo)(() => {
|
75
|
-
const {
|
76
|
-
maxDate,
|
77
|
-
view
|
78
|
-
} = configuration;
|
79
|
-
if (!maxDate) return false;
|
80
|
-
const next = (0, _dateFns.addMonths)(currentViewingDate, view === '2-month' ? 2 : 1);
|
81
|
-
|
82
|
-
if (maxDate.getFullYear() <= next.getFullYear() && maxDate.getMonth() < next.getMonth()) {
|
83
|
-
return true;
|
84
|
-
}
|
85
|
-
|
86
|
-
return false;
|
87
|
-
}, [configuration, currentViewingDate]);
|
88
|
-
return /*#__PURE__*/_react.default.createElement(DatePickerPanelContainer, null, /*#__PURE__*/_react.default.createElement(DatePickerPanelMonths, null, /*#__PURE__*/_react.default.createElement(ArrowButton, {
|
89
|
-
variant: "small",
|
90
|
-
side: "left",
|
91
|
-
onClick: previousMonth,
|
92
|
-
disabled: previousDisabled
|
93
|
-
}, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
|
94
|
-
icon: _octiconsReact.ChevronLeftIcon,
|
95
|
-
color: "fg.muted"
|
96
|
-
})), /*#__PURE__*/_react.default.createElement(_Month.Month, {
|
97
|
-
month: currentViewingDate.getMonth(),
|
98
|
-
year: currentViewingDate.getFullYear()
|
99
|
-
}), configuration.view === '2-month' && /*#__PURE__*/_react.default.createElement(_Month.Month, {
|
100
|
-
month: (0, _dateFns.addMonths)(currentViewingDate, 1).getMonth(),
|
101
|
-
year: (0, _dateFns.addMonths)(currentViewingDate, 1).getFullYear()
|
102
|
-
}), /*#__PURE__*/_react.default.createElement(ArrowButton, {
|
103
|
-
variant: "small",
|
104
|
-
side: "right",
|
105
|
-
onClick: nextMonth,
|
106
|
-
disabled: nextDisabled
|
107
|
-
}, /*#__PURE__*/_react.default.createElement(_StyledOcticon.default, {
|
108
|
-
icon: _octiconsReact.ChevronRightIcon,
|
109
|
-
color: "fg.muted"
|
110
|
-
}))), /*#__PURE__*/_react.default.createElement(DatePickerPanelFooter, null, /*#__PURE__*/_react.default.createElement(_Box.default, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
111
|
-
variant: "small",
|
112
|
-
sx: {
|
113
|
-
mr: 1
|
114
|
-
},
|
115
|
-
onClick: () => revertValue()
|
116
|
-
}, "Reset"), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
117
|
-
variant: "small",
|
118
|
-
onClick: () => goToMonth(new Date())
|
119
|
-
}, "Today")), configuration.confirmation && /*#__PURE__*/_react.default.createElement(_Button.ButtonPrimary, {
|
120
|
-
variant: "small",
|
121
|
-
onClick: () => saveValue()
|
122
|
-
}, "Apply")));
|
123
|
-
};
|
124
|
-
|
125
|
-
exports.DatePickerPanel = DatePickerPanel;
|
126
|
-
DatePickerPanel.displayName = "DatePickerPanel";
|
package/lib/DatePicker/Day.d.ts
DELETED
@@ -1,14 +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
|
-
import { DaySelection } from './useDatePicker';
|
6
|
-
export interface DayProps extends FontSizeProps, SystemCommonProps, SxProp, SystemLayoutProps {
|
7
|
-
blocked?: boolean;
|
8
|
-
disabled?: boolean;
|
9
|
-
onAction?: (date: Date, event?: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
10
|
-
selected?: DaySelection;
|
11
|
-
date: Date;
|
12
|
-
}
|
13
|
-
export declare const Day: React.FC<DayProps>;
|
14
|
-
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>;
|