@pedidopago/ui 1.7.26 → 1.8.1
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/dist/components/Alert/alert.test.js +1 -85
- package/dist/components/Alert/index.js +1 -63
- package/dist/components/Alert/styles.js +1 -32
- package/dist/components/Avatar/avatar.test.js +1 -67
- package/dist/components/Avatar/index.js +1 -94
- package/dist/components/Avatar/styles.js +1 -51
- package/dist/components/Badge/badge.test.js +1 -71
- package/dist/components/Badge/index.js +2 -43
- package/dist/components/Badge/styles.js +1 -33
- package/dist/components/Button/Button.test.js +1 -154
- package/dist/components/Button/index.js +1 -87
- package/dist/components/Button/styles.js +1 -112
- package/dist/components/Card/card.test.js +1 -30
- package/dist/components/Card/index.js +1 -44
- package/dist/components/Card/styles.js +1 -16
- package/dist/components/CheckboxInput/checkbox-input.test.js +1 -170
- package/dist/components/CheckboxInput/components/MultipleCheckbox.js +1 -205
- package/dist/components/CheckboxInput/index.js +1 -94
- package/dist/components/CheckboxInput/styles.js +1 -34
- package/dist/components/ChoiceList/index.d.ts +5 -0
- package/dist/components/ChoiceList/index.d.ts.map +1 -0
- package/dist/components/ChoiceList/index.js +1 -0
- package/dist/components/ChoiceList/styles.d.ts +22 -0
- package/dist/components/ChoiceList/styles.d.ts.map +1 -0
- package/dist/components/ChoiceList/styles.js +1 -0
- package/dist/components/ChoiceList/types.d.ts +24 -0
- package/dist/components/ChoiceList/types.d.ts.map +1 -0
- package/dist/components/ChoiceList/types.js +1 -0
- package/dist/components/CollapseCard/ExpandButton/index.js +1 -40
- package/dist/components/CollapseCard/ExpandButton/styles.js +1 -16
- package/dist/components/CollapseCard/expand-button.test.js +1 -161
- package/dist/components/CollapseCard/index.js +1 -98
- package/dist/components/CollapseCard/styles.js +1 -26
- package/dist/components/ColorPicker/colorpicker.test.js +1 -64
- package/dist/components/ColorPicker/components/ColorHue.js +1 -44
- package/dist/components/ColorPicker/components/ColorInput.js +1 -63
- package/dist/components/ColorPicker/components/ColorPickerBox.js +1 -52
- package/dist/components/ColorPicker/components/ColorPointer.js +1 -25
- package/dist/components/ColorPicker/components/ColorSelector.js +1 -107
- package/dist/components/ColorPicker/hooks/useCachedCallback.js +1 -16
- package/dist/components/ColorPicker/hooks/useHsva.js +1 -53
- package/dist/components/ColorPicker/index.js +1 -93
- package/dist/components/ColorPicker/styles.js +1 -46
- package/dist/components/ColorPicker/utils/checkers.js +1 -55
- package/dist/components/ColorPicker/utils/conversors.js +2 -243
- package/dist/components/ColorPicker/utils/parsers.js +10 -108
- package/dist/components/ComposeIcon/index.js +2 -48
- package/dist/components/ComposeIcon/styles.js +1 -53
- package/dist/components/DateInput/DateInput-example.js +7 -45
- package/dist/components/DateInput/components/ModalWrapper/index.js +1 -35
- package/dist/components/DateInput/components/ModalWrapper/styles.js +1 -21
- package/dist/components/DateInput/dateInput.test.js +2 -43
- package/dist/components/DateInput/index.js +2 -104
- package/dist/components/DateInput/styles.js +1 -18
- package/dist/components/DatePicker/components/DatePickerContent.js +2 -222
- package/dist/components/DatePicker/components/DateYearPicker.js +1 -102
- package/dist/components/DatePicker/datepicker.test.js +1 -120
- package/dist/components/DatePicker/index.js +1 -236
- package/dist/components/DatePicker/styles.js +1 -88
- package/dist/components/DatePicker/utils/getMonthName.js +1 -11
- package/dist/components/Dialog/dialog-example.js +1 -46
- package/dist/components/Dialog/dialog.test.js +1 -68
- package/dist/components/Dialog/index.js +2 -100
- package/dist/components/Dialog/styles.js +1 -31
- package/dist/components/Dropzone/dropzone.test.js +1 -69
- package/dist/components/Dropzone/index.js +1 -289
- package/dist/components/Dropzone/styles.js +1 -75
- package/dist/components/Dropzone/utils/accepts.js +2 -27
- package/dist/components/EmojiPicker/Emote/index.js +2 -24
- package/dist/components/EmojiPicker/Emote/styles.js +1 -27
- package/dist/components/EmojiPicker/EmotePickerData/constants.js +1 -51
- package/dist/components/EmojiPicker/EmotePickerData/index.js +2 -159
- package/dist/components/EmojiPicker/EmotePickerData/styles.js +1 -57
- package/dist/components/EmojiPicker/EmotePickerData/utils.js +1 -41
- package/dist/components/EmojiPicker/Example/EmotePickerExample.js +1 -43
- package/dist/components/EmojiPicker/animation.js +1 -43
- package/dist/components/EmojiPicker/index.js +1 -169
- package/dist/components/EmojiPicker/styles.js +1 -21
- package/dist/components/Flex/flex.test.js +1 -336
- package/dist/components/Flex/index.js +1 -49
- package/dist/components/Flex/styles.js +1 -25
- package/dist/components/Grid/grid.test.js +1 -134
- package/dist/components/Grid/index.js +1 -51
- package/dist/components/Grid/styles.js +1 -48
- package/dist/components/Icon/data/beauty.js +2 -206
- package/dist/components/Icon/data/dash.js +2 -2
- package/dist/components/Icon/data/ecommerce.js +2 -94
- package/dist/components/Icon/data/form.js +2 -248
- package/dist/components/Icon/data/health.js +2 -255
- package/dist/components/Icon/data/illustrations.js +2 -318
- package/dist/components/Icon/data/men.js +2 -52
- package/dist/components/Icon/data/payment.js +2 -94
- package/dist/components/Icon/data/pedidoPago.js +2 -45
- package/dist/components/Icon/data/physicalPerfomance.js +2 -283
- package/dist/components/Icon/data/social.js +2 -24
- package/dist/components/Icon/data/status.js +2 -115
- package/dist/components/Icon/data/summer.js +2 -52
- package/dist/components/Icon/data/woman.js +2 -80
- package/dist/components/Icon/icon.test.js +1 -57
- package/dist/components/Icon/index.js +1 -53
- package/dist/components/Icon/scripts/build.js +9 -104
- package/dist/components/Icon/scripts/extractor.js +2 -33
- package/dist/components/Icon/scripts/run-build.js +2 -7
- package/dist/components/Icon/scripts/writers.js +3 -34
- package/dist/components/Icon/styles.js +1 -22
- package/dist/components/Icon/utils/allIcons.js +1 -28
- package/dist/components/Icon/utils/iconExists.js +1 -13
- package/dist/components/IconItem/IconItem.test.js +1 -58
- package/dist/components/IconItem/index.js +1 -52
- package/dist/components/IconItem/styles.js +1 -43
- package/dist/components/Illustration/illustration.test.js +4 -50
- package/dist/components/Illustration/index.js +2 -65
- package/dist/components/Illustration/styles.js +1 -65
- package/dist/components/ImageItem/imageFake.js +1 -25
- package/dist/components/ImageItem/index.js +2 -66
- package/dist/components/ImageItem/input.test.js +1 -85
- package/dist/components/ImageItem/styles.js +1 -61
- package/dist/components/Input/index.js +1 -163
- package/dist/components/Input/input.test.js +1 -120
- package/dist/components/Input/styles.js +1 -177
- package/dist/components/Label/index.js +1 -45
- package/dist/components/Label/label.test.js +1 -83
- package/dist/components/Label/styles.js +1 -21
- package/dist/components/List/index.js +1 -39
- package/dist/components/List/list.test.js +1 -64
- package/dist/components/List/styles.js +1 -23
- package/dist/components/Modal/ModalExample.js +1 -70
- package/dist/components/Modal/index.js +1 -145
- package/dist/components/Modal/modal.test.js +1 -179
- package/dist/components/Modal/styles.js +1 -33
- package/dist/components/MultipleSelect/MultipleSelect.test.js +1 -334
- package/dist/components/MultipleSelect/animations.js +1 -25
- package/dist/components/MultipleSelect/components/InputWrapper/index.js +1 -26
- package/dist/components/MultipleSelect/components/OptionsArea/index.js +1 -244
- package/dist/components/MultipleSelect/components/OptionsArea/styles.js +1 -68
- package/dist/components/MultipleSelect/components/SelectArea/ButtonsArea.js +1 -27
- package/dist/components/MultipleSelect/components/SelectArea/SelectAreaWrapper.js +1 -37
- package/dist/components/MultipleSelect/components/SelectArea/SelectedOptionsArea.js +1 -49
- package/dist/components/MultipleSelect/components/SelectArea/index.js +1 -100
- package/dist/components/MultipleSelect/components/SelectArea/styles.js +1 -36
- package/dist/components/MultipleSelect/components/index.js +1 -38
- package/dist/components/MultipleSelect/index.js +1 -209
- package/dist/components/NewSelect/Examples/constants.js +1 -56
- package/dist/components/NewSelect/Examples/index.js +1 -161
- package/dist/components/NewSelect/components/Chip/index.js +1 -36
- package/dist/components/NewSelect/components/Chip/styles.js +1 -24
- package/dist/components/NewSelect/components/OptionsSelect/styles.js +1 -21
- package/dist/components/NewSelect/components/SelectInputSearch/index.js +1 -24
- package/dist/components/NewSelect/components/SelectItem/index.js +1 -22
- package/dist/components/NewSelect/components/SelectItem/styles.js +1 -24
- package/dist/components/NewSelect/index.js +1 -18
- package/dist/components/NewSelect/multiple/index.js +1 -246
- package/dist/components/NewSelect/newSelect.test.js +1 -108
- package/dist/components/NewSelect/single/index.js +1 -183
- package/dist/components/NewSelect/styles.js +1 -44
- package/dist/components/Observer/index.js +1 -59
- package/dist/components/Observer/observer.test.js +2 -43
- package/dist/components/Pagination/hooks/usePagination.js +1 -57
- package/dist/components/Pagination/index.js +1 -174
- package/dist/components/Pagination/pagination.test.js +1 -118
- package/dist/components/Pagination/styles.js +1 -78
- package/dist/components/Progress/Circle/index.js +1 -102
- package/dist/components/Progress/Circle/styles.js +1 -69
- package/dist/components/Progress/Linear/index.js +1 -62
- package/dist/components/Progress/Linear/styles.js +1 -66
- package/dist/components/Progress/getSteps.js +1 -17
- package/dist/components/Progress/index.js +1 -39
- package/dist/components/Progress/progress.test.js +1 -109
- package/dist/components/Radio/components/RadioGroup/index.d.ts +5 -0
- package/dist/components/Radio/components/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/Radio/components/RadioGroup/index.js +1 -0
- package/dist/components/Radio/components/RadioGroup/styles.d.ts +19 -0
- package/dist/components/Radio/components/RadioGroup/styles.d.ts.map +1 -0
- package/dist/components/Radio/components/RadioGroup/styles.js +1 -0
- package/dist/components/Radio/components/RadioGroup/types.d.ts +17 -0
- package/dist/components/Radio/components/RadioGroup/types.d.ts.map +1 -0
- package/dist/components/Radio/components/RadioGroup/types.js +1 -0
- package/dist/components/Radio/index.d.ts +5 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Radio/index.js +1 -0
- package/dist/components/Radio/styles.d.ts +10 -0
- package/dist/components/Radio/styles.d.ts.map +1 -0
- package/dist/components/Radio/styles.js +1 -0
- package/dist/components/Radio/types.d.ts +6 -0
- package/dist/components/Radio/types.d.ts.map +1 -0
- package/dist/components/Radio/types.js +1 -0
- package/dist/components/Rating/index.js +1 -133
- package/dist/components/Rating/rating.test.js +1 -63
- package/dist/components/Rating/styles.js +1 -27
- package/dist/components/ReactPortal/index.js +1 -43
- package/dist/components/ReactPortal/reactPortal.test.js +1 -21
- package/dist/components/ReactPortal/utils/createWrapperAndApprendToBody.js +1 -12
- package/dist/components/Select/components/OptionsSelect/index.js +1 -73
- package/dist/components/Select/components/OptionsSelect/styles.js +1 -21
- package/dist/components/Select/index.js +4 -247
- package/dist/components/Select/select.test.js +1 -58
- package/dist/components/Select/styles.js +1 -46
- package/dist/components/Skeleton/index.js +1 -28
- package/dist/components/Skeleton/skeleton.test.js +1 -90
- package/dist/components/Skeleton/styles.js +1 -27
- package/dist/components/Slider/SliderExample.js +1 -52
- package/dist/components/Slider/components/SliderPointer.js +1 -39
- package/dist/components/Slider/components/SliderRail.js +1 -116
- package/dist/components/Slider/components/SliderSelector.js +1 -173
- package/dist/components/Slider/hooks/useEventCallback.js +1 -16
- package/dist/components/Slider/index.js +1 -137
- package/dist/components/Slider/slider.test.js +1 -121
- package/dist/components/Slider/styles.js +1 -69
- package/dist/components/Spinner/index.js +1 -26
- package/dist/components/Spinner/spinner.test.js +1 -45
- package/dist/components/Spinner/styles.js +1 -23
- package/dist/components/Steps/components/StepIcon/index.js +1 -50
- package/dist/components/Steps/components/StepIcon/styles.js +1 -42
- package/dist/components/Steps/components/StepIcon/utils.js +1 -22
- package/dist/components/Steps/index.js +1 -116
- package/dist/components/Steps/steps.test.js +1 -53
- package/dist/components/Steps/styles.js +1 -96
- package/dist/components/Steps/utils.js +1 -15
- package/dist/components/Switch/index.js +1 -73
- package/dist/components/Switch/styles.js +1 -58
- package/dist/components/Switch/switch.test.js +2 -115
- package/dist/components/Table/components/MenuItem.js +1 -59
- package/dist/components/Table/components/TableSkeleton.js +1 -39
- package/dist/components/Table/components/animations.js +1 -24
- package/dist/components/Table/index.js +2 -253
- package/dist/components/Table/styles.js +1 -49
- package/dist/components/Table/table.test.js +1 -114
- package/dist/components/Tabs/TabsExample.js +1 -64
- package/dist/components/Tabs/components/Tab.js +1 -49
- package/dist/components/Tabs/components/TabPanel.js +1 -25
- package/dist/components/Tabs/components/Tabs.js +1 -107
- package/dist/components/Tabs/index.js +1 -26
- package/dist/components/Tabs/styles.js +1 -61
- package/dist/components/Tabs/tabs.test.js +1 -146
- package/dist/components/Tag/index.js +1 -53
- package/dist/components/Tag/styles.js +1 -34
- package/dist/components/Tag/tag.test.js +1 -64
- package/dist/components/TextAreaInput/index.js +1 -74
- package/dist/components/TextAreaInput/styles.js +1 -53
- package/dist/components/TextAreaInput/text-area-input.test.js +1 -81
- package/dist/components/Thumbnail/index.js +1 -125
- package/dist/components/Thumbnail/styles.js +1 -47
- package/dist/components/Thumbnail/thumbnail.test.js +1 -66
- package/dist/components/Thumbnail/utils/index.js +1 -27
- package/dist/components/Thumbnail/utils/validate-file-size.js +1 -10
- package/dist/components/Thumbnail/utils/validate-file-type.js +1 -9
- package/dist/components/TimeInput/constants.js +1 -29
- package/dist/components/TimeInput/index.js +1 -288
- package/dist/components/TimeInput/styles.js +1 -34
- package/dist/components/TimeInput/utils.js +1 -94
- package/dist/components/Timeline/components/Timeline.js +1 -17
- package/dist/components/Timeline/components/TimelineContent.js +1 -61
- package/dist/components/Timeline/components/TimelineItem.js +1 -25
- package/dist/components/Timeline/components/TimelineSeparator.js +1 -20
- package/dist/components/Timeline/index.js +1 -33
- package/dist/components/Timeline/styles.js +1 -37
- package/dist/components/Timeline/timeline.test.js +1 -138
- package/dist/components/Toast/button-example.js +1 -31
- package/dist/components/Toast/components/Toast.js +1 -79
- package/dist/components/Toast/contexts/ToastProvider.js +1 -72
- package/dist/components/Toast/hooks/useToast.js +1 -18
- package/dist/components/Toast/index.js +1 -111
- package/dist/components/Toast/styles.js +1 -36
- package/dist/components/Toast/toast.test.js +1 -129
- package/dist/components/Tooltip/components/TooltipLabel.js +1 -71
- package/dist/components/Tooltip/example.js +1 -27
- package/dist/components/Tooltip/index.js +1 -187
- package/dist/components/Tooltip/styles.js +1 -20
- package/dist/components/Typography/index.js +1 -37
- package/dist/components/Typography/styles.js +1 -15
- package/dist/components/Typography/typography.test.js +1 -288
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -548
- package/dist/shared/animations/opacityAnimation.js +1 -21
- package/dist/shared/assets/emotes.js +1 -1
- package/dist/shared/components/FocusLock/index.js +5 -86
- package/dist/shared/formatters/format-number.js +5 -41
- package/dist/shared/global.js +1 -8
- package/dist/shared/hooks/devices.js +1 -14
- package/dist/shared/hooks/useBreakpoints.js +2 -95
- package/dist/shared/hooks/useDebounce.js +1 -35
- package/dist/shared/hooks/useDevices.js +2 -42
- package/dist/shared/hooks/useDisableBodyScroll.js +5 -52
- package/dist/shared/hooks/useDraggableScroll/index.js +5 -65
- package/dist/shared/hooks/useKeyPress.js +1 -18
- package/dist/shared/hooks/useObserver.js +2 -29
- package/dist/shared/hooks/useOnClickOutside.js +1 -30
- package/dist/shared/hooks/useReposition/index.js +2 -53
- package/dist/shared/hooks/useSystemTheme.js +1 -38
- package/dist/shared/hooks/useWindowSize.js +1 -36
- package/dist/shared/tests/test-utils.js +1 -31
- package/dist/shared/theme/button-example.js +1 -31
- package/dist/shared/theme/contexts/ThemeContext.js +1 -90
- package/dist/shared/theme/hooks/useColorMode.js +1 -18
- package/dist/shared/theme/hooks/useColorModeValue.js +1 -13
- package/dist/shared/theme/hooks/useTheme.js +1 -17
- package/dist/shared/theme/index.js +1 -67
- package/dist/shared/theme/objects/breakpoints.js +1 -15
- package/dist/shared/theme/objects/colors.js +1 -177
- package/dist/shared/theme/objects/shadows.js +1 -19
- package/dist/shared/theme/objects/sizes.js +6 -33
- package/dist/shared/theme/objects/spaces.js +1 -75
- package/dist/shared/theme/objects/transitions.js +1 -10
- package/dist/shared/theme/objects/typography.js +1 -20
- package/dist/shared/theme/objects/z-indexes.js +1 -20
- package/dist/shared/theme/theme.js +1 -36
- package/dist/shared/theme/theme.test.js +1 -94
- package/dist/shared/theme/utils/extendTheme.js +1 -25
- package/dist/shared/theme/utils/localStorageController.js +1 -21
- package/dist/styled.d.js +1 -3
- package/dist/utils/GenerateKey.js +3 -18
- package/dist/utils/brightnessColorChange.js +2 -17
- package/dist/utils/colorCheck.js +6 -64
- package/dist/utils/colorFunctions.js +1 -39
- package/dist/utils/colorToGray.js +2 -64
- package/dist/utils/customColorMode.js +1 -11
- package/dist/utils/file.js +5 -124
- package/dist/utils/formatters/bytes.js +2 -17
- package/dist/utils/formatters/capitalize.js +2 -11
- package/dist/utils/formatters/cep.js +3 -18
- package/dist/utils/formatters/cnpj.js +4 -38
- package/dist/utils/formatters/color.js +12 -101
- package/dist/utils/formatters/cpf.js +16 -85
- package/dist/utils/formatters/credit-card.js +5 -54
- package/dist/utils/formatters/email.js +1 -8
- package/dist/utils/formatters/index.js +1 -170
- package/dist/utils/formatters/name.js +4 -31
- package/dist/utils/formatters/number.js +5 -14
- package/dist/utils/formatters/passport.js +5 -33
- package/dist/utils/formatters/phone.js +17 -214
- package/dist/utils/formatters/price.js +3 -21
- package/dist/utils/formatters/rg.js +3 -18
- package/dist/utils/formatters/strings.js +4 -27
- package/dist/utils/fuctionsColors.js +1 -39
- package/dist/utils/generateUUID.js +1 -13
- package/dist/utils/getColorValue.js +2 -23
- package/dist/utils/getSvg.js +1 -17
- package/dist/utils/getValuesBySize.js +1 -9
- package/dist/utils/invertColor.js +4 -40
- package/package.json +2 -1
|
@@ -1,43 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _testUtils = require("../../shared/tests/test-utils");
|
|
4
|
-
require("@testing-library/jest-dom");
|
|
5
|
-
var _DateInputExample = _interopRequireDefault(require("./DateInput-example"));
|
|
6
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
-
var setup = function setup(props) {
|
|
15
|
-
return (0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateInputExample.default, _objectSpread({}, props)));
|
|
16
|
-
};
|
|
17
|
-
describe('DateInput', function () {
|
|
18
|
-
it('should it render the datepicker component', function () {
|
|
19
|
-
var _setup = setup(),
|
|
20
|
-
container = _setup.container;
|
|
21
|
-
expect(container).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
it('should set a value in DateInput', function () {
|
|
24
|
-
var _setup2 = setup({
|
|
25
|
-
type: 'date',
|
|
26
|
-
label: 'label',
|
|
27
|
-
// value:
|
|
28
|
-
onChange: jest.fn()
|
|
29
|
-
}),
|
|
30
|
-
container = _setup2.container;
|
|
31
|
-
expect(container).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
it('should render the datepicker with minimum and maximum dates', function () {
|
|
34
|
-
var _setup3 = setup({
|
|
35
|
-
value: new Date(),
|
|
36
|
-
onChange: jest.fn(),
|
|
37
|
-
minDate: new Date(),
|
|
38
|
-
maxDate: new Date()
|
|
39
|
-
}),
|
|
40
|
-
container = _setup3.container;
|
|
41
|
-
expect(container).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
1
|
+
"use strict";var _testUtils=require("../../shared/tests/test-utils");require("@testing-library/jest-dom");var _DateInputExample=_interopRequireDefault(require("./DateInput-example")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)source=null==arguments[i]?{}:arguments[i],i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))});return target}function _defineProperty(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return"symbol"===_typeof(key)?key:key+""}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===hint?String:Number)(input)}var setup=function(props){return(0,_testUtils.render)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_DateInputExample.default,_objectSpread({},props)))};describe("DateInput",function(){it("should it render the datepicker component",function(){var _setup=setup(),container=_setup.container;expect(container).toBeInTheDocument()}),it("should set a value in DateInput",function(){var _setup2=setup({type:"date",label:"label",// value:
|
|
2
|
+
onChange:jest.fn()}),container=_setup2.container;expect(container).toBeInTheDocument()}),it("should render the datepicker with minimum and maximum dates",function(){var _setup3=setup({value:new Date,onChange:jest.fn(),minDate:new Date,maxDate:new Date}),container=_setup3.container;expect(container).toBeInTheDocument()})});
|
|
@@ -1,107 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.DateInput = DateInput;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _styles = require("./styles");
|
|
10
|
-
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
11
|
-
var _Input = _interopRequireDefault(require("../Input"));
|
|
12
|
-
var _DatePicker = _interopRequireDefault(require("../DatePicker"));
|
|
13
|
-
var _Modal = require("../Modal");
|
|
14
|
-
var _useDisableBodyScroll = require("../../shared/hooks/useDisableBodyScroll");
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
var _excluded = ["label", "placeholder", "alert", "helperText", "value", "locales", "localeOptions", "onChange", "disabled", "disableWeekendDays", "iconColor"]; // React
|
|
1
|
+
"use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateInput=DateInput;var _react=require("react"),_styles=require("./styles"),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_DatePicker=_interopRequireDefault(require("../DatePicker")),_Modal=require("../Modal"),_useDisableBodyScroll=require("../../shared/hooks/useDisableBodyScroll"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","value","locales","localeOptions","onChange","disabled","disableWeekendDays","iconColor"];// React
|
|
17
2
|
// Styles
|
|
18
3
|
// Components
|
|
19
4
|
// hooks
|
|
20
|
-
function _interopRequireDefault(obj)
|
|
21
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
25
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
26
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
30
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
31
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
33
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
34
|
-
function DateInput(_ref) {
|
|
35
|
-
var label = _ref.label,
|
|
36
|
-
placeholder = _ref.placeholder,
|
|
37
|
-
alert = _ref.alert,
|
|
38
|
-
helperText = _ref.helperText,
|
|
39
|
-
value = _ref.value,
|
|
40
|
-
_ref$locales = _ref.locales,
|
|
41
|
-
locales = _ref$locales === void 0 ? 'pt-BR' : _ref$locales,
|
|
42
|
-
localeOptions = _ref.localeOptions,
|
|
43
|
-
onChange = _ref.onChange,
|
|
44
|
-
_ref$disabled = _ref.disabled,
|
|
45
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
46
|
-
disableWeekendDays = _ref.disableWeekendDays,
|
|
47
|
-
iconColor = _ref.iconColor,
|
|
48
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
-
var containerRef = (0, _react.useRef)(null);
|
|
50
|
-
var _useState = (0, _react.useState)(),
|
|
51
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
-
currentValue = _useState2[0],
|
|
53
|
-
setCurrentValue = _useState2[1];
|
|
54
|
-
var _useState3 = (0, _react.useState)(true),
|
|
55
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
-
isFirstClickDateInput = _useState4[0],
|
|
57
|
-
setIsFirstClickDateInput = _useState4[1];
|
|
58
|
-
var _useState5 = (0, _react.useState)(false),
|
|
59
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
-
datePickerOpen = _useState6[0],
|
|
61
|
-
setDatePickerOpen = _useState6[1];
|
|
62
|
-
function selectDate(value) {
|
|
63
|
-
setCurrentValue(value);
|
|
64
|
-
setDatePickerOpen(false);
|
|
65
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
66
|
-
}
|
|
67
|
-
(0, _react.useEffect)(function () {
|
|
68
|
-
setCurrentValue(value);
|
|
69
|
-
}, [value]);
|
|
70
|
-
(0, _useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen, 'child_element');
|
|
71
|
-
var toggleOptionsAreaView = (0, _react.useCallback)(function (event) {
|
|
72
|
-
event.stopPropagation();
|
|
73
|
-
if (!disabled) setDatePickerOpen(!datePickerOpen);
|
|
74
|
-
}, [datePickerOpen, disabled]);
|
|
75
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DateInputContainer, {
|
|
76
|
-
ref: containerRef,
|
|
77
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, {
|
|
78
|
-
label: label,
|
|
79
|
-
readOnly: true,
|
|
80
|
-
placeholder: placeholder,
|
|
81
|
-
helperText: helperText,
|
|
82
|
-
alert: alert,
|
|
83
|
-
withIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
84
|
-
name: "calendar",
|
|
85
|
-
color: iconColor
|
|
86
|
-
}),
|
|
87
|
-
disabled: disabled,
|
|
88
|
-
tabIndex: disabled ? -1 : 0,
|
|
89
|
-
value: currentValue ? Array.isArray(currentValue) ? String(currentValue[0]) !== String(currentValue[1]) ? "".concat(new Date(currentValue[0]).toLocaleDateString(locales, localeOptions), " - ").concat(new Date(currentValue[1]).toLocaleDateString(locales, localeOptions)) : new Date(currentValue[0]).toLocaleDateString(locales, localeOptions) : new Date(currentValue).toLocaleDateString(locales, localeOptions) : '',
|
|
90
|
-
onClick: toggleOptionsAreaView
|
|
91
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.Modal, {
|
|
92
|
-
maxWidth: "max-content",
|
|
93
|
-
maxHeight: "max-content",
|
|
94
|
-
onClose: function onClose() {
|
|
95
|
-
return setDatePickerOpen(false);
|
|
96
|
-
},
|
|
97
|
-
open: datePickerOpen,
|
|
98
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.default, _objectSpread({
|
|
99
|
-
value: currentValue,
|
|
100
|
-
onChange: selectDate,
|
|
101
|
-
disableWeekendDays: disableWeekendDays,
|
|
102
|
-
isFirstClickDateInput: isFirstClickDateInput,
|
|
103
|
-
setIsFirstClickDateInput: setIsFirstClickDateInput
|
|
104
|
-
}, rest))
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
107
|
-
}
|
|
5
|
+
function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)source=null==arguments[i]?{}:arguments[i],i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))});return target}function _defineProperty(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return"symbol"===_typeof(key)?key:key+""}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===hint?String:Number)(input)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,i,target=_objectWithoutPropertiesLoose(source,excluded);if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],0<=excluded.indexOf(key)||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};var key,i,target={},sourceKeys=Object.keys(source);for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],0<=excluded.indexOf(key)||(target[key]=source[key]);return target}function DateInput(_ref){var label=_ref.label,placeholder=_ref.placeholder,alert=_ref.alert,helperText=_ref.helperText,value=_ref.value,_ref$locales=_ref.locales,locales=void 0===_ref$locales?"pt-BR":_ref$locales,localeOptions=_ref.localeOptions,onChange=_ref.onChange,_ref$disabled=_ref.disabled,disabled=void 0!==_ref$disabled&&_ref$disabled,disableWeekendDays=_ref.disableWeekendDays,iconColor=_ref.iconColor,rest=_objectWithoutProperties(_ref,_excluded),containerRef=(0,_react.useRef)(null),_useState=(0,_react.useState)(),_useState2=_slicedToArray(_useState,2),currentValue=_useState2[0],setCurrentValue=_useState2[1],_useState3=(0,_react.useState)(!0),_useState4=_slicedToArray(_useState3,2),isFirstClickDateInput=_useState4[0],setIsFirstClickDateInput=_useState4[1],_useState5=(0,_react.useState)(!1),_useState6=_slicedToArray(_useState5,2),datePickerOpen=_useState6[0],setDatePickerOpen=_useState6[1];(0,_react.useEffect)(function(){setCurrentValue(value)},[value]),(0,_useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen,"child_element");var toggleOptionsAreaView=(0,_react.useCallback)(function(event){event.stopPropagation(),disabled||setDatePickerOpen(!datePickerOpen)},[datePickerOpen,disabled]);return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DateInputContainer,{ref:containerRef,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Input.default,{label:label,readOnly:!0,placeholder:placeholder,helperText:helperText,alert:alert,withIcon:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"calendar",color:iconColor}),disabled:disabled,tabIndex:disabled?-1:0,value:currentValue?Array.isArray(currentValue)?currentValue[0]+""===currentValue[1]+""?new Date(currentValue[0]).toLocaleDateString(locales,localeOptions):"".concat(new Date(currentValue[0]).toLocaleDateString(locales,localeOptions)," - ").concat(new Date(currentValue[1]).toLocaleDateString(locales,localeOptions)):new Date(currentValue).toLocaleDateString(locales,localeOptions):"",onClick:toggleOptionsAreaView}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Modal.Modal,{maxWidth:"max-content",maxHeight:"max-content",onClose:function onClose(){return setDatePickerOpen(!1)},open:datePickerOpen,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_DatePicker.default,_objectSpread({value:currentValue,onChange:function(value){setCurrentValue(value),setDatePickerOpen(!1),null===onChange||void 0===onChange?void 0:onChange(value)},disableWeekendDays:disableWeekendDays,isFirstClickDateInput:isFirstClickDateInput,setIsFirstClickDateInput:setIsFirstClickDateInput},rest))})]})}
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Overlay = exports.DateInputContainer = void 0;
|
|
7
|
-
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
8
|
-
var _react = require("@emotion/react");
|
|
9
|
-
var _templateObject, _templateObject2;
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
12
|
-
var DateInputContainer = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n position: relative;\n\n input {\n cursor: pointer;\n caret-color: transparent;\n }\n"])));
|
|
13
|
-
exports.DateInputContainer = DateInputContainer;
|
|
14
|
-
var Overlay = _styled.default.div(function (props) {
|
|
15
|
-
var theme = props.theme;
|
|
16
|
-
return (0, _react.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: fixed;\n left: 0px;\n right: 0px;\n top: 0px;\n bottom: 0px;\n z-index: ", ";\n\n background: ", ";\n opacity: 0;\n\n transition: opacity ease ", ";\n "])), theme.zIndex.level24, theme.colors.neutral.neutral5, theme.transition.speed);
|
|
17
|
-
});
|
|
18
|
-
exports.Overlay = Overlay;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Overlay=exports.DateInputContainer=void 0;var _templateObject,_templateObject2,_styled=_interopRequireDefault(require("@emotion/styled")),_react=require("@emotion/react");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _taggedTemplateLiteral(strings,raw){return raw||(raw=strings.slice(0)),Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))}var DateInputContainer=_styled.default.div(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n width: 100%;\n position: relative;\n\n input {\n cursor: pointer;\n caret-color: transparent;\n }\n"])));exports.DateInputContainer=DateInputContainer;var Overlay=_styled.default.div(function(props){var theme=props.theme;return(0,_react.css)(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n position: fixed;\n left: 0px;\n right: 0px;\n top: 0px;\n bottom: 0px;\n z-index: ",";\n\n background: ",";\n opacity: 0;\n\n transition: opacity ease ",";\n "])),theme.zIndex.level24,theme.colors.neutral.neutral5,theme.transition.speed)});exports.Overlay=Overlay;
|
|
@@ -1,222 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DatePickerContent = void 0;
|
|
7
|
-
var _framerMotion = require("framer-motion");
|
|
8
|
-
var _Icon = _interopRequireDefault(require("../../Icon"));
|
|
9
|
-
var _styles = require("../styles");
|
|
10
|
-
var _getMonthName = require("../utils/getMonthName");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
-
var DatePickerContent = function DatePickerContent(_ref) {
|
|
20
|
-
var type = _ref.type,
|
|
21
|
-
dateProp = _ref.date,
|
|
22
|
-
startDate = _ref.startDate,
|
|
23
|
-
endDate = _ref.endDate,
|
|
24
|
-
isInTheRange = _ref.isInTheRange,
|
|
25
|
-
maxDate = _ref.maxDate,
|
|
26
|
-
minDate = _ref.minDate,
|
|
27
|
-
handleChange = _ref.handleChange,
|
|
28
|
-
handleMouseOver = _ref.handleMouseOver,
|
|
29
|
-
handleChangeDate = _ref.handleChangeDate,
|
|
30
|
-
variant = _ref.variant,
|
|
31
|
-
enableYearPicker = _ref.enableYearPicker,
|
|
32
|
-
handleToggleYearPicker = _ref.handleToggleYearPicker,
|
|
33
|
-
hideNextMonthButton = _ref.hideNextMonthButton,
|
|
34
|
-
hidePrevMonthButton = _ref.hidePrevMonthButton,
|
|
35
|
-
disableWeekendDays = _ref.disableWeekendDays,
|
|
36
|
-
showSelectedDate = _ref.showSelectedDate;
|
|
37
|
-
var handleChangeSelectDate = function handleChangeSelectDate(newDate) {
|
|
38
|
-
handleChangeDate(newDate);
|
|
39
|
-
handleChange(newDate);
|
|
40
|
-
};
|
|
41
|
-
var date = dateProp || new Date();
|
|
42
|
-
var handleChangeMonth = function handleChangeMonth(month, to) {
|
|
43
|
-
if (maxDate || minDate) {
|
|
44
|
-
var newDate = new Date(date);
|
|
45
|
-
newDate.setMonth(newDate.getMonth() + (to === 'up' ? 1 : -1));
|
|
46
|
-
handleChangeDate(newDate);
|
|
47
|
-
}
|
|
48
|
-
var newMonth = to === 'up' ? month + 1 > 11 ? 0 : month + 1 : month - 1 < 0 ? 11 : month - 1;
|
|
49
|
-
var newYear = to === 'up' ? month + 1 > 11 && date.getFullYear() + 1 : to === 'down' && month - 1 < 0 && date.getFullYear() - 1;
|
|
50
|
-
handleChangeDate(new Date(newYear || date.getFullYear(), newMonth, 1));
|
|
51
|
-
};
|
|
52
|
-
var getMonthDays = function getMonthDays(month, year) {
|
|
53
|
-
var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
54
|
-
if (month === 1) {
|
|
55
|
-
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
|
|
56
|
-
return new Array(29).fill(0).map(function (_, index) {
|
|
57
|
-
return index + 1;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return new Array(days[month]).fill(0).map(function (_, index) {
|
|
62
|
-
return index + 1;
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
var getMonthDaysWithWeekDays = function getMonthDaysWithWeekDays(month, year) {
|
|
66
|
-
var isExtended = variant === 'extended';
|
|
67
|
-
var days = getMonthDays(month, year);
|
|
68
|
-
var firstDay = new Date(year, month, 1).getDay();
|
|
69
|
-
var lastDay = new Date(year, month + 1, 0).getDay();
|
|
70
|
-
var daysWithPrevMonthDays = new Array(firstDay).fill(0).map(function (_, index) {
|
|
71
|
-
var checkYear = month === 0 ? year - 1 : year;
|
|
72
|
-
var checkMonth = month === 0 ? 11 : month - 1;
|
|
73
|
-
var prevMonthDays = getMonthDays(checkMonth, checkYear);
|
|
74
|
-
return !isExtended ? prevMonthDays[prevMonthDays.length - index - 1] : _;
|
|
75
|
-
});
|
|
76
|
-
var daysWithNextMonthDays = new Array(6 - lastDay).fill(0).map(function (_, index) {
|
|
77
|
-
return !isExtended ? index + 1 : _;
|
|
78
|
-
});
|
|
79
|
-
var allDaysWithWeekDays = [].concat(_toConsumableArray(daysWithPrevMonthDays.reverse()), _toConsumableArray(days), _toConsumableArray(daysWithNextMonthDays));
|
|
80
|
-
var groupedDaysWithWeekDays = [];
|
|
81
|
-
for (var i = 0; i < allDaysWithWeekDays.length; i += 7) {
|
|
82
|
-
groupedDaysWithWeekDays.push(allDaysWithWeekDays.slice(i, i + 7));
|
|
83
|
-
}
|
|
84
|
-
return groupedDaysWithWeekDays;
|
|
85
|
-
};
|
|
86
|
-
var isHiddenArrowBack = (minDate === null || minDate === void 0 ? void 0 : minDate.getMonth()) === date.getMonth() && (minDate === null || minDate === void 0 ? void 0 : minDate.getFullYear()) === date.getFullYear();
|
|
87
|
-
var isHiddenArrowNext = (maxDate === null || maxDate === void 0 ? void 0 : maxDate.getMonth()) === date.getMonth() && (maxDate === null || maxDate === void 0 ? void 0 : maxDate.getFullYear()) === date.getFullYear();
|
|
88
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
|
|
89
|
-
initial: {
|
|
90
|
-
opacity: 0
|
|
91
|
-
},
|
|
92
|
-
animate: {
|
|
93
|
-
opacity: 1
|
|
94
|
-
},
|
|
95
|
-
exit: {
|
|
96
|
-
opacity: 0
|
|
97
|
-
},
|
|
98
|
-
transition: {
|
|
99
|
-
duration: 0.2
|
|
100
|
-
},
|
|
101
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DatePickerContainer, {
|
|
102
|
-
tabIndex: -1,
|
|
103
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DatePickerHeader, {
|
|
104
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerHeaderButton, {
|
|
105
|
-
type: "button",
|
|
106
|
-
onClick: function onClick() {
|
|
107
|
-
return handleChangeMonth(date.getMonth(), 'down');
|
|
108
|
-
},
|
|
109
|
-
isHidden: isHiddenArrowBack || hidePrevMonthButton,
|
|
110
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
111
|
-
name: "arrow-left"
|
|
112
|
-
})
|
|
113
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DatePickerHeaderTitle, {
|
|
114
|
-
onClick: function onClick() {
|
|
115
|
-
return enableYearPicker && (handleToggleYearPicker === null || handleToggleYearPicker === void 0 ? void 0 : handleToggleYearPicker());
|
|
116
|
-
},
|
|
117
|
-
enableYearPicker: enableYearPicker,
|
|
118
|
-
children: [(0, _getMonthName.getMonthName)(date.getMonth()), " ", date.getFullYear(), enableYearPicker && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
119
|
-
name: "edit",
|
|
120
|
-
size: "15px"
|
|
121
|
-
})]
|
|
122
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerHeaderButton, {
|
|
123
|
-
type: "button",
|
|
124
|
-
onClick: function onClick() {
|
|
125
|
-
return handleChangeMonth(date.getMonth(), 'up');
|
|
126
|
-
},
|
|
127
|
-
isHidden: isHiddenArrowNext || hideNextMonthButton,
|
|
128
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
129
|
-
name: "arrow-right"
|
|
130
|
-
})
|
|
131
|
-
})]
|
|
132
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerBody, {
|
|
133
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DatePickerBodyTable, {
|
|
134
|
-
role: "table",
|
|
135
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
|
|
136
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("tr", {
|
|
137
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
138
|
-
children: "D"
|
|
139
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
140
|
-
children: "S"
|
|
141
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
142
|
-
children: "T"
|
|
143
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
144
|
-
children: "Q"
|
|
145
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
146
|
-
children: "Q"
|
|
147
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
148
|
-
children: "S"
|
|
149
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
150
|
-
children: "S"
|
|
151
|
-
})]
|
|
152
|
-
})
|
|
153
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
|
|
154
|
-
children: getMonthDaysWithWeekDays(date.getMonth(), date.getFullYear()).map(function (days, rowIndex) {
|
|
155
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerTableRow, {
|
|
156
|
-
role: "row",
|
|
157
|
-
isRange: type === 'range',
|
|
158
|
-
children: days.map(function (day, dayIndex) {
|
|
159
|
-
var monthDaysLength = getMonthDaysWithWeekDays(date.getMonth(), date.getFullYear()).length;
|
|
160
|
-
var isPreviousMonth = !!(rowIndex === 0 && day > 7);
|
|
161
|
-
var isNextMonth = !!(rowIndex === monthDaysLength - 1 && day < 7);
|
|
162
|
-
var dateMonth = isPreviousMonth ? date.getMonth() - 1 : isNextMonth ? date.getMonth() + 1 : date.getMonth();
|
|
163
|
-
var cellDate = new Date(date.getFullYear(), dateMonth, day);
|
|
164
|
-
var cellTitle = cellDate.toLocaleDateString();
|
|
165
|
-
var isToday = cellDate.getTime() === Date.now();
|
|
166
|
-
var isStartDateOfRange =
|
|
167
|
-
// setHours(0, 0, 0, 0) set the time to midnight
|
|
168
|
-
startDate ? cellDate.getTime() === startDate.setHours(0, 0, 0, 0) : false;
|
|
169
|
-
var isEndDateOfRange = endDate && cellDate.getTime() === endDate.getTime();
|
|
170
|
-
var outOfCurrentMonthInRange = type === 'range' && (isPreviousMonth || isNextMonth);
|
|
171
|
-
var isWeekendDay = disableWeekendDays ? cellDate.getDay() === 0 || cellDate.getDay() === 6 : false;
|
|
172
|
-
var isDisabled = day === 0 || minDate && cellDate.getTime() < minDate.getTime() || maxDate && cellDate.getTime() > maxDate.getTime() || outOfCurrentMonthInRange || isWeekendDay;
|
|
173
|
-
var isExtended = variant === 'extended';
|
|
174
|
-
var removeZeros = days.filter(function (day) {
|
|
175
|
-
return day !== 0;
|
|
176
|
-
});
|
|
177
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerTableCell, {
|
|
178
|
-
role: "gridcell",
|
|
179
|
-
title: cellTitle,
|
|
180
|
-
"data-date": cellDate,
|
|
181
|
-
isTheSameDate: !!endDate && !!startDate && cellDate.getTime() === endDate.getTime() && cellDate.getTime() === (startDate === null || startDate === void 0 ? void 0 : startDate.getTime()),
|
|
182
|
-
tabIndex: -1,
|
|
183
|
-
disabled: isDisabled,
|
|
184
|
-
"aria-label": cellDate.toLocaleDateString('pt-BR', {
|
|
185
|
-
weekday: 'short',
|
|
186
|
-
year: '2-digit',
|
|
187
|
-
month: '2-digit',
|
|
188
|
-
day: '2-digit'
|
|
189
|
-
}),
|
|
190
|
-
"aria-selected": type === 'range' ? isStartDateOfRange || isEndDateOfRange || isInTheRange(cellDate) : isStartDateOfRange,
|
|
191
|
-
"aria-disabled": isDisabled,
|
|
192
|
-
isInTheRange: type === 'range' && isInTheRange(cellDate),
|
|
193
|
-
isStartDateOfRange: type === 'range' && isStartDateOfRange,
|
|
194
|
-
isEndDateOfRange: type === 'range' && !!isEndDateOfRange,
|
|
195
|
-
isToday: isToday,
|
|
196
|
-
isSelected: isStartDateOfRange,
|
|
197
|
-
isPrevNextMonth: isPreviousMonth || isNextMonth,
|
|
198
|
-
isFirstDayOfMonth: isExtended && rowIndex === 0 && day === 1,
|
|
199
|
-
showSelectedDate: showSelectedDate,
|
|
200
|
-
isLastDayOfMonth: isExtended && rowIndex === monthDaysLength - 1 && day === removeZeros[removeZeros.length - 1],
|
|
201
|
-
onMouseEnter: function onMouseEnter() {
|
|
202
|
-
if (type === 'range') {
|
|
203
|
-
handleMouseOver(cellDate);
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
onClick: function onClick() {
|
|
207
|
-
handleChangeSelectDate(cellDate);
|
|
208
|
-
},
|
|
209
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerTableCellSpan, {
|
|
210
|
-
children: day !== 0 && !outOfCurrentMonthInRange && day
|
|
211
|
-
})
|
|
212
|
-
}, dayIndex);
|
|
213
|
-
})
|
|
214
|
-
}, rowIndex);
|
|
215
|
-
})
|
|
216
|
-
})]
|
|
217
|
-
})
|
|
218
|
-
})]
|
|
219
|
-
})
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
exports.DatePickerContent = DatePickerContent;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DatePickerContent=void 0;var _framerMotion=require("framer-motion"),_Icon=_interopRequireDefault(require("../../Icon")),_styles=require("../styles"),_getMonthName=require("../utils/getMonthName"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&null!=iter[Symbol.iterator]||null!=iter["@@iterator"])return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}var DatePickerContent=function(_ref){var type=_ref.type,dateProp=_ref.date,startDate=_ref.startDate,endDate=_ref.endDate,isInTheRange=_ref.isInTheRange,maxDate=_ref.maxDate,minDate=_ref.minDate,handleChange=_ref.handleChange,handleMouseOver=_ref.handleMouseOver,handleChangeDate=_ref.handleChangeDate,variant=_ref.variant,enableYearPicker=_ref.enableYearPicker,handleToggleYearPicker=_ref.handleToggleYearPicker,hideNextMonthButton=_ref.hideNextMonthButton,hidePrevMonthButton=_ref.hidePrevMonthButton,disableWeekendDays=_ref.disableWeekendDays,showSelectedDate=_ref.showSelectedDate,handleChangeSelectDate=function(newDate){handleChangeDate(newDate),handleChange(newDate)},date=dateProp||new Date,handleChangeMonth=function(month,to){if(maxDate||minDate){var newDate=new Date(date);newDate.setMonth(newDate.getMonth()+("up"===to?1:-1)),handleChangeDate(newDate)}var newMonth="up"===to?11<month+1?0:month+1:0>month-1?11:month-1,newYear="up"===to?11<month+1&&date.getFullYear()+1:"down"==to&&0>month-1&&date.getFullYear()-1;handleChangeDate(new Date(newYear||date.getFullYear(),newMonth,1))},getMonthDays=function(month,year){return 1===month&&(0==year%4&&0!=year%100||0==year%400)?Array(29).fill(0).map(function(_,index){return index+1}):Array([31,28,31,30,31,30,31,31,30,31,30,31][month]).fill(0).map(function(_,index){return index+1})},getMonthDaysWithWeekDays=function(month,year){for(var isExtended="extended"===variant,days=getMonthDays(month,year),firstDay=new Date(year,month,1).getDay(),lastDay=new Date(year,month+1,0).getDay(),daysWithPrevMonthDays=Array(firstDay).fill(0).map(function(_,index){var checkYear=0===month?year-1:year,checkMonth=0===month?11:month-1,prevMonthDays=getMonthDays(checkMonth,checkYear);return isExtended?_:prevMonthDays[prevMonthDays.length-index-1]}),daysWithNextMonthDays=Array(6-lastDay).fill(0).map(function(_,index){return isExtended?_:index+1}),allDaysWithWeekDays=[].concat(_toConsumableArray(daysWithPrevMonthDays.reverse()),_toConsumableArray(days),_toConsumableArray(daysWithNextMonthDays)),groupedDaysWithWeekDays=[],i=0;i<allDaysWithWeekDays.length;i+=7)groupedDaysWithWeekDays.push(allDaysWithWeekDays.slice(i,i+7));return groupedDaysWithWeekDays},isHiddenArrowBack=(null===minDate||void 0===minDate?void 0:minDate.getMonth())===date.getMonth()&&(null===minDate||void 0===minDate?void 0:minDate.getFullYear())===date.getFullYear(),isHiddenArrowNext=(null===maxDate||void 0===maxDate?void 0:maxDate.getMonth())===date.getMonth()&&(null===maxDate||void 0===maxDate?void 0:maxDate.getFullYear())===date.getFullYear();return/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerContainer,{tabIndex:-1,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerHeader,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerHeaderButton,{type:"button",onClick:function onClick(){return handleChangeMonth(date.getMonth(),"down")},isHidden:isHiddenArrowBack||hidePrevMonthButton,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"arrow-left"})}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerHeaderTitle,{onClick:function onClick(){return enableYearPicker&&(null===handleToggleYearPicker||void 0===handleToggleYearPicker?void 0:handleToggleYearPicker())},enableYearPicker:enableYearPicker,children:[(0,_getMonthName.getMonthName)(date.getMonth())," ",date.getFullYear(),enableYearPicker&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"edit",size:"15px"})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerHeaderButton,{type:"button",onClick:function onClick(){return handleChangeMonth(date.getMonth(),"up")},isHidden:isHiddenArrowNext||hideNextMonthButton,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"arrow-right"})})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerBody,{children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerBodyTable,{role:"table",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("thead",{children:/*#__PURE__*/(0,_jsxRuntime.jsxs)("tr",{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"D"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"S"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"T"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"Q"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"Q"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"S"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("th",{children:"S"})]})}),/*#__PURE__*/(0,_jsxRuntime.jsx)("tbody",{children:getMonthDaysWithWeekDays(date.getMonth(),date.getFullYear()).map(function(days,rowIndex){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerTableRow,{role:"row",isRange:"range"===type,children:days.map(function(day,dayIndex){var monthDaysLength=getMonthDaysWithWeekDays(date.getMonth(),date.getFullYear()).length,isPreviousMonth=!!(0===rowIndex&&7<day),isNextMonth=!!(rowIndex===monthDaysLength-1&&7>day),dateMonth=isPreviousMonth?date.getMonth()-1:isNextMonth?date.getMonth()+1:date.getMonth(),cellDate=new Date(date.getFullYear(),dateMonth,day),cellTitle=cellDate.toLocaleDateString(),isToday=cellDate.getTime()===Date.now(),isStartDateOfRange=// setHours(0, 0, 0, 0) set the time to midnight
|
|
2
|
+
!!startDate&&cellDate.getTime()===startDate.setHours(0,0,0,0),isEndDateOfRange=endDate&&cellDate.getTime()===endDate.getTime(),outOfCurrentMonthInRange="range"===type&&(isPreviousMonth||isNextMonth),isWeekendDay=!!disableWeekendDays&&(0===cellDate.getDay()||6===cellDate.getDay()),isDisabled=0===day||minDate&&cellDate.getTime()<minDate.getTime()||maxDate&&cellDate.getTime()>maxDate.getTime()||outOfCurrentMonthInRange||isWeekendDay,isExtended="extended"===variant,removeZeros=days.filter(function(day){return 0!==day});return/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerTableCell,{role:"gridcell",title:cellTitle,"data-date":cellDate,isTheSameDate:!!endDate&&!!startDate&&cellDate.getTime()===endDate.getTime()&&cellDate.getTime()===(null===startDate||void 0===startDate?void 0:startDate.getTime()),tabIndex:-1,disabled:isDisabled,"aria-label":cellDate.toLocaleDateString("pt-BR",{weekday:"short",year:"2-digit",month:"2-digit",day:"2-digit"}),"aria-selected":"range"===type?isStartDateOfRange||isEndDateOfRange||isInTheRange(cellDate):isStartDateOfRange,"aria-disabled":isDisabled,isInTheRange:"range"===type&&isInTheRange(cellDate),isStartDateOfRange:"range"===type&&isStartDateOfRange,isEndDateOfRange:"range"===type&&!!isEndDateOfRange,isToday:isToday,isSelected:isStartDateOfRange,isPrevNextMonth:isPreviousMonth||isNextMonth,isFirstDayOfMonth:isExtended&&0===rowIndex&&1===day,showSelectedDate:showSelectedDate,isLastDayOfMonth:isExtended&&rowIndex===monthDaysLength-1&&day===removeZeros[removeZeros.length-1],onMouseEnter:function onMouseEnter(){"range"===type&&handleMouseOver(cellDate)},onClick:function onClick(){handleChangeSelectDate(cellDate)},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerTableCellSpan,{children:0!==day&&!outOfCurrentMonthInRange&&day})},dayIndex)})},rowIndex)})})]})})]})})};exports.DatePickerContent=DatePickerContent;
|
|
@@ -1,102 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DateYearPicker = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _framerMotion = require("framer-motion");
|
|
9
|
-
var _Icon = _interopRequireDefault(require("../../Icon"));
|
|
10
|
-
var _styles = require("../styles");
|
|
11
|
-
var _getMonthName = require("../utils/getMonthName");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
19
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
-
var DateYearPicker = function DateYearPicker(_ref) {
|
|
21
|
-
var date = _ref.date,
|
|
22
|
-
handleChangeDate = _ref.handleChangeDate,
|
|
23
|
-
maxDate = _ref.maxDate,
|
|
24
|
-
minDate = _ref.minDate;
|
|
25
|
-
var _useState = (0, _react.useState)(date.getFullYear()),
|
|
26
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
-
years = _useState2[0],
|
|
28
|
-
setYears = _useState2[1];
|
|
29
|
-
var _useState3 = (0, _react.useState)(0),
|
|
30
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
31
|
-
year = _useState4[0],
|
|
32
|
-
setYear = _useState4[1];
|
|
33
|
-
var yearsInterval = new Array(20).fill(0).map(function (_, index) {
|
|
34
|
-
return years - 5 + index;
|
|
35
|
-
});
|
|
36
|
-
var handleSelectMonth = function handleSelectMonth(month) {
|
|
37
|
-
handleChangeDate(new Date(year, month, 1));
|
|
38
|
-
};
|
|
39
|
-
var enableToBackYears = String(minDate) !== 'Invalid Date' ? new Date(minDate).getFullYear() < yearsInterval[0] : true;
|
|
40
|
-
var enableToNextYears = String(maxDate) !== 'Invalid Date' ? new Date(maxDate).getFullYear() > yearsInterval[yearsInterval.length - 1] : true;
|
|
41
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
|
|
42
|
-
initial: {
|
|
43
|
-
opacity: 0
|
|
44
|
-
},
|
|
45
|
-
animate: {
|
|
46
|
-
opacity: 1
|
|
47
|
-
},
|
|
48
|
-
exit: {
|
|
49
|
-
opacity: 0
|
|
50
|
-
},
|
|
51
|
-
transition: {
|
|
52
|
-
duration: 0.2
|
|
53
|
-
},
|
|
54
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DateYearPickerContainer, {
|
|
55
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.DatePickerHeader, {
|
|
56
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerHeaderButton, {
|
|
57
|
-
isHidden: !enableToBackYears,
|
|
58
|
-
type: "button",
|
|
59
|
-
onClick: function onClick() {
|
|
60
|
-
setYears(years - 10);
|
|
61
|
-
setYear(0);
|
|
62
|
-
},
|
|
63
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
64
|
-
name: "arrow-left"
|
|
65
|
-
})
|
|
66
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerHeaderTitle, {
|
|
67
|
-
children: year === 0 ? "".concat(years - 5, "-").concat(years + 14) : year
|
|
68
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DatePickerHeaderButton, {
|
|
69
|
-
isHidden: !enableToNextYears,
|
|
70
|
-
type: "button",
|
|
71
|
-
onClick: function onClick() {
|
|
72
|
-
setYears(years + 10);
|
|
73
|
-
setYear(0);
|
|
74
|
-
},
|
|
75
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
76
|
-
name: "arrow-right"
|
|
77
|
-
})
|
|
78
|
-
})]
|
|
79
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DateYearPickerBody, {
|
|
80
|
-
children: year === 0 ? yearsInterval.map(function (yearInterval) {
|
|
81
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DateYearPickerCell, {
|
|
82
|
-
disabled: yearInterval < new Date(minDate).getFullYear() || yearInterval > new Date(maxDate).getFullYear(),
|
|
83
|
-
onClick: function onClick() {
|
|
84
|
-
return setYear(yearInterval);
|
|
85
|
-
},
|
|
86
|
-
isSelected: date.getFullYear() === yearInterval,
|
|
87
|
-
children: yearInterval
|
|
88
|
-
}, yearInterval);
|
|
89
|
-
}) : new Array(12).fill(0).map(function (_, index) {
|
|
90
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.DateYearPickerCell, {
|
|
91
|
-
disabled: index < new Date(minDate).getMonth() || index > new Date(maxDate).getMonth(),
|
|
92
|
-
onClick: function onClick() {
|
|
93
|
-
return handleSelectMonth(index);
|
|
94
|
-
},
|
|
95
|
-
children: (0, _getMonthName.getMonthName)(index).substring(0, 3).toUpperCase()
|
|
96
|
-
}, index);
|
|
97
|
-
})
|
|
98
|
-
})]
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
exports.DateYearPicker = DateYearPicker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateYearPicker=void 0;var _react=require("react"),_framerMotion=require("framer-motion"),_Icon=_interopRequireDefault(require("../../Icon")),_styles=require("../styles"),_getMonthName=require("../utils/getMonthName"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}var DateYearPicker=function(_ref){var date=_ref.date,handleChangeDate=_ref.handleChangeDate,maxDate=_ref.maxDate,minDate=_ref.minDate,_useState=(0,_react.useState)(date.getFullYear()),_useState2=_slicedToArray(_useState,2),years=_useState2[0],setYears=_useState2[1],_useState3=(0,_react.useState)(0),_useState4=_slicedToArray(_useState3,2),year=_useState4[0],setYear=_useState4[1],yearsInterval=Array(20).fill(0).map(function(_,index){return years-5+index}),handleSelectMonth=function(month){handleChangeDate(new Date(year,month,1))},enableToBackYears=!("Invalid Date"!==minDate+"")||new Date(minDate).getFullYear()<yearsInterval[0],enableToNextYears=!("Invalid Date"!==maxDate+"")||new Date(maxDate).getFullYear()>yearsInterval[yearsInterval.length-1];return/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DateYearPickerContainer,{children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerHeader,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerHeaderButton,{isHidden:!enableToBackYears,type:"button",onClick:function onClick(){setYears(years-10),setYear(0)},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"arrow-left"})}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerHeaderTitle,{children:0===year?"".concat(years-5,"-").concat(years+14):year}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerHeaderButton,{isHidden:!enableToNextYears,type:"button",onClick:function onClick(){setYears(years+10),setYear(0)},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"arrow-right"})})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DateYearPickerBody,{children:0===year?yearsInterval.map(function(yearInterval){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DateYearPickerCell,{disabled:yearInterval<new Date(minDate).getFullYear()||yearInterval>new Date(maxDate).getFullYear(),onClick:function onClick(){return setYear(yearInterval)},isSelected:date.getFullYear()===yearInterval,children:yearInterval},yearInterval)}):Array(12).fill(0).map(function(_,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DateYearPickerCell,{disabled:index<new Date(minDate).getMonth()||index>new Date(maxDate).getMonth(),onClick:function onClick(){return handleSelectMonth(index)},children:(0,_getMonthName.getMonthName)(index).substring(0,3).toUpperCase()},index)})})]})})};exports.DateYearPicker=DateYearPicker;
|