@pedidopago/ui 1.17.11 → 1.17.13
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/DateInput/dateInput.test.js +1 -1
- package/dist/components/DateInput/index.d.ts +2 -2
- package/dist/components/DateInput/index.d.ts.map +1 -1
- package/dist/components/DateInput/index.js +2 -2
- package/dist/components/DateInput/types.d.ts +2 -1
- package/dist/components/DateInput/types.d.ts.map +1 -1
- package/dist/components/DatePicker/components/DatePickerContent.d.ts +1 -1
- package/dist/components/DatePicker/components/DatePickerContent.d.ts.map +1 -1
- package/dist/components/DatePicker/components/DatePickerContent.js +2 -2
- package/dist/components/DatePicker/datepicker.test.js +2 -1
- package/dist/components/DatePicker/index.d.ts +1 -1
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DatePicker/types.d.ts +15 -0
- package/dist/components/DatePicker/types.d.ts.map +1 -1
- package/dist/components/Icon/data/illustrations.d.ts.map +1 -1
- package/dist/components/Icon/data/illustrations.js +1 -1
- package/dist/components/Icon/types.d.ts +1 -1
- package/dist/components/Icon/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
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()})});
|
|
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()}),it("should render with availableDays prop",function(){var _setup4=setup({value:new Date,onChange:jest.fn(),availableDays:{sunday:!1,monday:!0,tuesday:!0,wednesday:!0,thursday:!0,friday:!0,saturday:!1}}),container=_setup4.container;expect(container).toBeInTheDocument()}),it("should render with availableDays as null",function(){var _setup5=setup({value:new Date,onChange:jest.fn(),availableDays:null}),container=_setup5.container;expect(container).toBeInTheDocument()})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateInputProps } from './types';
|
|
2
1
|
import { DatePickerTypes } from '../DatePicker/types';
|
|
3
|
-
|
|
2
|
+
import { DateInputProps } from './types';
|
|
3
|
+
export declare function DateInput<T extends DatePickerTypes>({ label, placeholder, alert, helperText, value, locales, localeOptions, onChange, disabled, disableWeekendDays, iconColor, showRemoveButton, availableDays, ...rest }: DateInputProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateInput/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateInput/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAEpD,wBAAgB,SAAS,CAAC,CAAC,SAAS,eAAe,EAAE,EACnD,KAAK,EACL,WAAW,EACX,KAAK,EACL,UAAU,EACV,KAAK,EACL,OAAiB,EACjB,aAAa,EACb,QAAQ,EACR,QAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,CAAC,CAAC,2CAsGnB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
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 _framerMotion=require("framer-motion"),_react=require("react"),_DatePicker=_interopRequireDefault(require("../DatePicker")),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_Modal=require("../Modal"),_useDisableBodyScroll=require("../../shared/hooks/useDisableBodyScroll"),_styles=require("./styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","value","locales","localeOptions","onChange","disabled","disableWeekendDays","iconColor","showRemoveButton","availableDays"];// Libs
|
|
2
2
|
// Components
|
|
3
3
|
// Hooks
|
|
4
4
|
// Styles
|
|
5
5
|
// Types
|
|
6
|
-
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){function selectDate(value){setCurrentValue(value),setDatePickerOpen(!1),null===onChange||void 0===onChange?void 0:onChange(value)}function handleReset(){selectDate(void 0)}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,showRemoveButton=_ref.showRemoveButton,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(){return value?Array.isArray(value)?setCurrentValue([new Date(value[0]),new Date(value[1])]):void setCurrentValue(value):setCurrentValue(void 0)},[value]),(0,_useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen,"child_element");var toggleOptionsAreaView=(0,_react.useCallback)(function(event){var _event$stopPropagatio;null===event||void 0===event||null===(_event$stopPropagatio=event.stopPropagation)||void 0===_event$stopPropagatio?void 0:_event$stopPropagatio.call(event),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}),onLeftIconClick:function onLeftIconClick(){return toggleOptionsAreaView({})},rightIcon:showRemoveButton&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.AnimatePresence,{mode:"wait",children:currentValue?/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.motion.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.2,ease:"easeInOut"},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"trash-2",color:"error.default"})}):void 0}),onRightIconClick:function onRightIconClick(){showRemoveButton&&handleReset()},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,{portalNameId:"date-input-portal",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){return selectDate(value)},disableWeekendDays:disableWeekendDays,isFirstClickDateInput:isFirstClickDateInput,setIsFirstClickDateInput:setIsFirstClickDateInput},rest))})]})}
|
|
6
|
+
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){function selectDate(value){setCurrentValue(value),setDatePickerOpen(!1),null===onChange||void 0===onChange?void 0:onChange(value)}function handleReset(){selectDate(void 0)}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,showRemoveButton=_ref.showRemoveButton,availableDays=_ref.availableDays,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(){return value?Array.isArray(value)?setCurrentValue([new Date(value[0]),new Date(value[1])]):void setCurrentValue(value):setCurrentValue(void 0)},[value]),(0,_useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen,"child_element");var toggleOptionsAreaView=(0,_react.useCallback)(function(event){var _event$stopPropagatio;null===event||void 0===event||null===(_event$stopPropagatio=event.stopPropagation)||void 0===_event$stopPropagatio?void 0:_event$stopPropagatio.call(event),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}),onLeftIconClick:function onLeftIconClick(){return toggleOptionsAreaView({})},rightIcon:showRemoveButton&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.AnimatePresence,{mode:"wait",children:currentValue?/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.motion.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.2,ease:"easeInOut"},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"trash-2",color:"error.default"})}):void 0}),onRightIconClick:function onRightIconClick(){showRemoveButton&&handleReset()},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,{portalNameId:"date-input-portal",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){return selectDate(value)},disableWeekendDays:disableWeekendDays,isFirstClickDateInput:isFirstClickDateInput,setIsFirstClickDateInput:setIsFirstClickDateInput,availableDays:availableDays},rest))})]})}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlobalColorsProps } from '../../shared/theme';
|
|
2
|
-
import { DatePickerProps, DatePickerTypes } from '../DatePicker/types';
|
|
2
|
+
import { AvailableDays, DatePickerProps, DatePickerTypes } from '../DatePicker/types';
|
|
3
3
|
import { InputAlertTypes } from '../Input/types';
|
|
4
4
|
export type AuxType<T> = T | undefined;
|
|
5
5
|
export type ValueDate<T> = T extends 'date' ? AuxType<Date> : AuxType<[Date, Date]>;
|
|
@@ -18,5 +18,6 @@ export interface DateInputProps<T extends DatePickerTypes> extends Omit<DatePick
|
|
|
18
18
|
disableWeekendDays?: boolean;
|
|
19
19
|
iconColor?: GlobalColorsProps | (string & {});
|
|
20
20
|
showRemoveButton?: boolean;
|
|
21
|
+
availableDays?: AvailableDays;
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/DateInput/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EA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E,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DatePickerContentProps } from '../types';
|
|
2
|
-
export declare const DatePickerContent: ({ type, date: dateProp, startDate, endDate, isInTheRange, maxDate, minDate, handleChange, handleMouseOver, handleChangeDate, variant, enableYearPicker, handleToggleYearPicker, hideNextMonthButton, hidePrevMonthButton, disableWeekendDays, showSelectedDate, fullSize, rangeLimit, isFirstClick, }: DatePickerContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DatePickerContent: ({ type, date: dateProp, startDate, endDate, isInTheRange, maxDate, minDate, handleChange, handleMouseOver, handleChangeDate, variant, enableYearPicker, handleToggleYearPicker, hideNextMonthButton, hidePrevMonthButton, disableWeekendDays, showSelectedDate, fullSize, rangeLimit, isFirstClick, availableDays, }: DatePickerContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=DatePickerContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerContent.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/components/DatePickerContent.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"DatePickerContent.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/components/DatePickerContent.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,iBAAiB,yTAsB3B,sBAAsB,4CA8RxB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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"),_react=require("react"),_constants=require("../constants"),_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,_ref$fullSize=_ref.fullSize,fullSize=void 0!==_ref$fullSize&&_ref$fullSize,rangeLimit=_ref.rangeLimit,isFirstClick=_ref.isFirstClick,handleChangeSelectDate=function(newDate){handleChangeDate(newDate),handleChange(newDate)},date=dateProp||new Date,checkIfIsCurrentDateOutOfRangeLimit=(0,_react.useCallback)(function(currentDate){if(isFirstClick||!maxDate||!rangeLimit)return!1;var RANGE_LIMIT_IN_MILLISECONDS=rangeLimit*_constants.DAY_IN_MILLISECONDS,newDate=startDate&&(null===startDate||void 0===startDate?void 0:startDate.getTime())+RANGE_LIMIT_IN_MILLISECONDS;return newDate&¤tDate.getTime()>newDate},[isFirstClick,startDate,maxDate,rangeLimit]),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,fullSize:fullSize,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerHeader,{fullSize:fullSize,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,{fullSize:fullSize,children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerBodyTable,{role:"table",fullSize:fullSize,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,fullSize:fullSize,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||checkIfIsCurrentDateOutOfRangeLimit(cellDate)||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,fullSize:fullSize,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
|
+
"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"),_react=require("react"),_constants=require("../constants"),_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,_ref$fullSize=_ref.fullSize,fullSize=void 0!==_ref$fullSize&&_ref$fullSize,rangeLimit=_ref.rangeLimit,isFirstClick=_ref.isFirstClick,availableDays=_ref.availableDays,handleChangeSelectDate=function(newDate){handleChangeDate(newDate),handleChange(newDate)},date=dateProp||new Date,checkIfDayIsAvailable=(0,_react.useCallback)(function(currentDate){if(!availableDays)return!0;var dayOfWeek=currentDate.getDay();return availableDays[["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][dayOfWeek]]},[availableDays]),checkIfIsCurrentDateOutOfRangeLimit=(0,_react.useCallback)(function(currentDate){if(isFirstClick||!maxDate||!rangeLimit)return!1;var RANGE_LIMIT_IN_MILLISECONDS=rangeLimit*_constants.DAY_IN_MILLISECONDS,newDate=startDate&&(null===startDate||void 0===startDate?void 0:startDate.getTime())+RANGE_LIMIT_IN_MILLISECONDS;return newDate&¤tDate.getTime()>newDate},[isFirstClick,startDate,maxDate,rangeLimit]),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,fullSize:fullSize,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerHeader,{fullSize:fullSize,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,{fullSize:fullSize,children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DatePickerBodyTable,{role:"table",fullSize:fullSize,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,fullSize:fullSize,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()),isDayNotAvailable=!checkIfDayIsAvailable(cellDate),isDisabled=0===day||checkIfIsCurrentDateOutOfRangeLimit(cellDate)||minDate&&cellDate.getTime()<minDate.getTime()||maxDate&&cellDate.getTime()>maxDate.getTime()||outOfCurrentMonthInRange||isWeekendDay||isDayNotAvailable,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,fullSize:fullSize,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 +1,2 @@
|
|
|
1
|
-
"use strict";var _testUtils=require("../../shared/tests/test-utils");require("@testing-library/jest-dom");var _=_interopRequireDefault(require(".")),_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)(_.default,_objectSpread({},props)))};describe("DatePicker",function(){it("should it render the datepicker component",function(){var _setup=setup({value:new Date,onChange:jest.fn()}),container=_setup.container;expect(container).toBeInTheDocument()}),it("should it render the datepicker as range type",function(){var _setup2=setup({value:new Date,onChange:jest.fn(),type:"range"}),container=_setup2.container;expect(container).toBeInTheDocument()}),it("should it render the datepicker as extended variant",function(){var _setup3=setup({value:new Date,onChange:jest.fn(),variant:"extended"}),container=_setup3.container;expect(container).toBeInTheDocument()}),it("should it render the datepicker with minimum and maximum dates",function(){var _setup4=setup({value:new Date,onChange:jest.fn(),minDate:new Date,maxDate:new Date}),container=_setup4.container;expect(container).toBeInTheDocument()}),it("should it call the onChange function with one date value",function(){var onChange=jest.fn(),_setup5=setup({value:new Date,onChange:onChange}),container=_setup5.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should it call the onChange function with two date values in range type",function(){var onChange=jest.fn(),_setup6=setup({value:new Date,onChange:onChange,type:"range"}),container=_setup6.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),dateCells[25].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should it call the onChange function with one date value in the extended variant",function(){var onChange=jest.fn(),_setup7=setup({value:new Date,onChange:onChange,variant:"extended"}),container=_setup7.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should it call the onChange function with two date values in the extended variant",function(){var onChange=jest.fn(),_setup8=setup({value:new Date,onChange:onChange,type:"range",variant:"extended"}),container=_setup8.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),dateCells[60].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()})});
|
|
1
|
+
"use strict";var _testUtils=require("../../shared/tests/test-utils");require("@testing-library/jest-dom");var _=_interopRequireDefault(require(".")),_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)(_.default,_objectSpread({},props)))};describe("DatePicker",function(){it("should it render the datepicker component",function(){var _setup=setup({value:new Date,onChange:jest.fn()}),container=_setup.container;expect(container).toBeInTheDocument()}),it("should it render the datepicker as range type",function(){var _setup2=setup({value:new Date,onChange:jest.fn(),type:"range"}),container=_setup2.container;expect(container).toBeInTheDocument()}),it("should it render the datepicker as extended variant",function(){var _setup3=setup({value:new Date,onChange:jest.fn(),variant:"extended"}),container=_setup3.container;expect(container).toBeInTheDocument()}),it("should it render the datepicker with minimum and maximum dates",function(){var _setup4=setup({value:new Date,onChange:jest.fn(),minDate:new Date,maxDate:new Date}),container=_setup4.container;expect(container).toBeInTheDocument()}),it("should it call the onChange function with one date value",function(){var onChange=jest.fn(),_setup5=setup({value:new Date,onChange:onChange}),container=_setup5.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should it call the onChange function with two date values in range type",function(){var onChange=jest.fn(),_setup6=setup({value:new Date,onChange:onChange,type:"range"}),container=_setup6.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),dateCells[25].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should it call the onChange function with one date value in the extended variant",function(){var onChange=jest.fn(),_setup7=setup({value:new Date,onChange:onChange,variant:"extended"}),container=_setup7.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should it call the onChange function with two date values in the extended variant",function(){var onChange=jest.fn(),_setup8=setup({value:new Date,onChange:onChange,type:"range",variant:"extended"}),container=_setup8.container,dateCells=document.querySelectorAll("td[role=\"gridcell\"]");dateCells[20].dispatchEvent(new MouseEvent("click",{bubbles:!0})),dateCells[60].dispatchEvent(new MouseEvent("click",{bubbles:!0})),expect(container).toBeInTheDocument(),expect(onChange).toHaveBeenCalled()}),it("should disable specific days when availableDays prop is provided",function(){var onChange=jest.fn(),_setup9=setup({value:new Date,onChange:onChange,availableDays:{sunday:!1,monday:!0,tuesday:!0,wednesday:!0,thursday:!0,friday:!0,saturday:!1}}),container=_setup9.container;expect(container).toBeInTheDocument();// Verificar se as células de domingo e sábado estão desabilitadas
|
|
2
|
+
var dateCells=document.querySelectorAll("td[role=\"gridcell\"]"),disabledCells=Array.from(dateCells).filter(function(cell){return"true"===cell.getAttribute("aria-disabled")});expect(disabledCells.length).toBeGreaterThan(0)}),it("should allow all days when availableDays is null",function(){var onChange=jest.fn(),_setup10=setup({value:new Date,onChange:onChange,availableDays:null}),container=_setup10.container;expect(container).toBeInTheDocument()})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DatePickerProps } from './types';
|
|
2
|
-
declare const DatePicker: ({ value, onChange, minDate: minDateProp, maxDate: maxDateProp, variant, color, type, disableWeekendDays, isFirstClickDateInput, setIsFirstClickDateInput, enableYearPicker, fullSize, rangeLimit, onChangeStartDate, onChangeEndDate, }: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const DatePicker: ({ value, onChange, minDate: minDateProp, maxDate: maxDateProp, variant, color, type, disableWeekendDays, isFirstClickDateInput, setIsFirstClickDateInput, enableYearPicker, fullSize, rangeLimit, onChangeStartDate, onChangeEndDate, availableDays, }: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default DatePicker;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,QAAA,MAAM,UAAU,2PAiBb,eAAe,4CAgQjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// Components
|
|
3
3
|
// Styles
|
|
4
4
|
// Types
|
|
5
|
-
var DatePicker=function(_ref){function resetFirstClick(value){setIsFirstClick(value),null===setIsFirstClickDateInput||void 0===setIsFirstClickDateInput?void 0:setIsFirstClickDateInput(value)}var value=_ref.value,onChange=_ref.onChange,minDateProp=_ref.minDate,maxDateProp=_ref.maxDate,_ref$variant=_ref.variant,variant=void 0===_ref$variant?"compact":_ref$variant,color=_ref.color,_ref$type=_ref.type,type=void 0===_ref$type?"date":_ref$type,disableWeekendDays=_ref.disableWeekendDays,isFirstClickDateInput=_ref.isFirstClickDateInput,setIsFirstClickDateInput=_ref.setIsFirstClickDateInput,enableYearPicker=_ref.enableYearPicker,_ref$fullSize=_ref.fullSize,fullSize=void 0!==_ref$fullSize&&_ref$fullSize,rangeLimit=_ref.rangeLimit,onChangeStartDate=_ref.onChangeStartDate,onChangeEndDate=_ref.onChangeEndDate,date=(0,_react2.useMemo)(function(){return new Date},[]),minDate=new Date(minDateProp),maxDate=new Date(maxDateProp),_useState=(0,_react2.useState)(isFirstClickDateInput||!0),_useState2=_slicedToArray(_useState,2),isFirstClick=_useState2[0],setIsFirstClick=_useState2[1],_useState3=(0,_react2.useState)(function(){return value?Array.isArray(value)?new Date(value[0]):new Date(value):maxDateProp&&minDateProp?maxDate<=date?new Date(maxDate.getFullYear(),maxDate.getMonth()-1):null:minDateProp?minDate>date?minDate:null:maxDateProp?maxDate<date?new Date(maxDate.getFullYear(),maxDate.getMonth()-("compact"===variant?0:1)):null:null}),_useState4=_slicedToArray(_useState3,2),startDate=_useState4[0],setStartDate=_useState4[1],_useState5=(0,_react2.useState)(value?Array.isArray(value)?new Date(value[1]):new Date(value):startDate),_useState6=_slicedToArray(_useState5,2),endDate=_useState6[0],setEndDate=_useState6[1],endDateMonth=endDate?endDate.getMonth():null,startDateMonth=startDate?startDate.getMonth():null,_useState7=(0,_react2.useState)(function(){if(endDate&&endDateMonth&&startDateMonth){if(Array.isArray(value)&&null!==value&&void 0!==value&&value[1])return maxDateProp?startDateMonth===endDateMonth&&endDateMonth===maxDate.getMonth()?endDate:startDateMonth===endDateMonth?new Date(endDate.getFullYear(),endDateMonth+1):endDate:startDateMonth===endDateMonth?new Date(endDate.getFullYear(),endDateMonth+1):endDate;if(maxDateProp&&maxDate.getMonth()===startDateMonth)return maxDate;if(startDate)return new Date(startDate.getFullYear(),startDateMonth+1,1)}return new Date(new Date().getFullYear(),new Date().getMonth()+1,1)}),_useState8=_slicedToArray(_useState7,2),secondCalendarDate=_useState8[0],setSecondCalendarDate=_useState8[1],_useState9=(0,_react2.useState)(function(){return secondCalendarDate&&"extended"===variant&&secondCalendarDate.getMonth()===maxDate.getMonth()?Array.isArray(value)&&startDateMonth!==endDateMonth?startDate:new Date(secondCalendarDate.getFullYear(),secondCalendarDate.getMonth()-1):startDate?startDateMonth&&new Date(startDate.getFullYear(),startDateMonth):new Date}),_useState10=_slicedToArray(_useState9,2),firstCalendarDate=_useState10[0],setFirstCalendarDate=_useState10[1],_useState11=(0,_react2.useState)(!1),_useState12=_slicedToArray(_useState11,2),openYearPicker=_useState12[0],setOpenYearPicker=_useState12[1];(0,_react2.useEffect)(function(){isFirstClick&&!startDate&&(setStartDate(null),setEndDate(null))},[isFirstClick]);var firstCalendarLimit=secondCalendarDate&&new Date(secondCalendarDate.getFullYear(),secondCalendarDate.getMonth(),0),DatePickerContentProps={variant:variant,type:type,startDate:startDate,endDate:endDate,isInTheRange:function isInTheRange(currentDate){if(startDate&&endDate){var start=startDate.getTime(),end=endDate.getTime(),current=currentDate&¤tDate.getTime();return current>start&¤t<end}return!1},handleMouseOver:function handleMouseOver(currentDate){if(startDate){var tableRows=document.querySelectorAll("tbody tr[role=\"row\"]");tableRows.forEach(function(row){var rowCells=row.querySelectorAll("td");rowCells.forEach(function(cell){var cellDate=new Date(cell.getAttribute("data-date")+"");cellDate.getTime()===currentDate.setHours(0,0,0,0)&&+cellDate>+endDate?cell.classList.add("is-current"):cell.classList.remove("is-current"),cellDate<=currentDate&&cellDate>startDate&&!endDate?cell.classList.add("is-hover"):cell.classList.remove("is-hover")})})}},handleChange:function handleChange(newDate){if("date"===type)return setStartDate(newDate),null===onChange||void 0===onChange?void 0:onChange(newDate),resetFirstClick(!1);if(isFirstClick)return null===onChangeStartDate||void 0===onChangeStartDate?void 0:onChangeStartDate(newDate),setStartDate(newDate),setEndDate(null),resetFirstClick(!1);if(startDate){if(newDate<startDate)return null===onChangeStartDate||void 0===onChangeStartDate?void 0:onChangeStartDate(newDate),setStartDate(newDate);null===onChangeEndDate||void 0===onChangeEndDate?void 0:onChangeEndDate(newDate),setEndDate(newDate),null===onChange||void 0===onChange?void 0:onChange([startDate,newDate]),setIsFirstClick(!0)}},minDate:minDate&&new Date(minDate),maxDate:maxDate&&new Date(maxDate),showSelectedDate:!isFirstClickDateInput,handleToggleYearPicker:function handleToggleYearPicker(){setOpenYearPicker(!openYearPicker)},enableYearPicker:enableYearPicker,rangeLimit:rangeLimit,isFirstClick:isFirstClick};return/*#__PURE__*/(0,_jsxRuntime.jsx)(_react.ThemeProvider,{theme:{colorSelected:color||"primary.default"},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerContentContainer,{isExtended:"extended"===variant,fullSize:fullSize,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.AnimatePresence,{mode:"wait",children:openYearPicker?/*#__PURE__*/(0,_jsxRuntime.jsx)(_DateYearPicker.DateYearPicker,{date:firstCalendarDate,minDate:minDate,maxDate:maxDate,handleChangeDate:function handleChangeDate(newDate){setFirstCalendarDate(function(){return new Date(newDate.getFullYear(),newDate.getMonth(),1)}),setOpenYearPicker(!1)}}):/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_DatePickerContent.DatePickerContent,_objectSpread(_objectSpread({},DatePickerContentProps),{},{date:firstCalendarDate,minDate:DatePickerContentProps.minDate,maxDate:"extended"!==variant||maxDate?"extended"===variant?maxDate&&firstCalendarLimit&&new Date(maxDate).getTime()<firstCalendarLimit.getTime()?DatePickerContentProps.maxDate:firstCalendarLimit:DatePickerContentProps.maxDate:firstCalendarLimit,disableWeekendDays:disableWeekendDays,handleChangeDate:function handleChangeDate(newDate){return setFirstCalendarDate(newDate)},fullSize:fullSize})),"extended"===variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_DatePickerContent.DatePickerContent,_objectSpread(_objectSpread({},DatePickerContentProps),{},{date:secondCalendarDate,minDate:DatePickerContentProps.minDate,maxDate:DatePickerContentProps.maxDate,handleChangeDate:function handleChangeDate(newDate){setSecondCalendarDate(newDate)},hidePrevMonthButton:function(){if(firstCalendarDate&&secondCalendarDate){var isSecondCalendarNextMonth=(null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getMonth())-1===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getMonth()),isBothSameYear=(null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getFullYear())===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getFullYear());return isSecondCalendarNextMonth&&isBothSameYear}return!1}(),disableWeekendDays:disableWeekendDays,fullSize:fullSize}))]})})})})},_default=DatePicker;exports.default=_default;
|
|
5
|
+
var DatePicker=function(_ref){function resetFirstClick(value){setIsFirstClick(value),null===setIsFirstClickDateInput||void 0===setIsFirstClickDateInput?void 0:setIsFirstClickDateInput(value)}var value=_ref.value,onChange=_ref.onChange,minDateProp=_ref.minDate,maxDateProp=_ref.maxDate,_ref$variant=_ref.variant,variant=void 0===_ref$variant?"compact":_ref$variant,color=_ref.color,_ref$type=_ref.type,type=void 0===_ref$type?"date":_ref$type,disableWeekendDays=_ref.disableWeekendDays,isFirstClickDateInput=_ref.isFirstClickDateInput,setIsFirstClickDateInput=_ref.setIsFirstClickDateInput,enableYearPicker=_ref.enableYearPicker,_ref$fullSize=_ref.fullSize,fullSize=void 0!==_ref$fullSize&&_ref$fullSize,rangeLimit=_ref.rangeLimit,onChangeStartDate=_ref.onChangeStartDate,onChangeEndDate=_ref.onChangeEndDate,availableDays=_ref.availableDays,date=(0,_react2.useMemo)(function(){return new Date},[]),minDate=new Date(minDateProp),maxDate=new Date(maxDateProp),_useState=(0,_react2.useState)(isFirstClickDateInput||!0),_useState2=_slicedToArray(_useState,2),isFirstClick=_useState2[0],setIsFirstClick=_useState2[1],_useState3=(0,_react2.useState)(function(){return value?Array.isArray(value)?new Date(value[0]):new Date(value):maxDateProp&&minDateProp?maxDate<=date?new Date(maxDate.getFullYear(),maxDate.getMonth()-1):null:minDateProp?minDate>date?minDate:null:maxDateProp?maxDate<date?new Date(maxDate.getFullYear(),maxDate.getMonth()-("compact"===variant?0:1)):null:null}),_useState4=_slicedToArray(_useState3,2),startDate=_useState4[0],setStartDate=_useState4[1],_useState5=(0,_react2.useState)(value?Array.isArray(value)?new Date(value[1]):new Date(value):startDate),_useState6=_slicedToArray(_useState5,2),endDate=_useState6[0],setEndDate=_useState6[1],endDateMonth=endDate?endDate.getMonth():null,startDateMonth=startDate?startDate.getMonth():null,_useState7=(0,_react2.useState)(function(){if(endDate&&endDateMonth&&startDateMonth){if(Array.isArray(value)&&null!==value&&void 0!==value&&value[1])return maxDateProp?startDateMonth===endDateMonth&&endDateMonth===maxDate.getMonth()?endDate:startDateMonth===endDateMonth?new Date(endDate.getFullYear(),endDateMonth+1):endDate:startDateMonth===endDateMonth?new Date(endDate.getFullYear(),endDateMonth+1):endDate;if(maxDateProp&&maxDate.getMonth()===startDateMonth)return maxDate;if(startDate)return new Date(startDate.getFullYear(),startDateMonth+1,1)}return new Date(new Date().getFullYear(),new Date().getMonth()+1,1)}),_useState8=_slicedToArray(_useState7,2),secondCalendarDate=_useState8[0],setSecondCalendarDate=_useState8[1],_useState9=(0,_react2.useState)(function(){return secondCalendarDate&&"extended"===variant&&secondCalendarDate.getMonth()===maxDate.getMonth()?Array.isArray(value)&&startDateMonth!==endDateMonth?startDate:new Date(secondCalendarDate.getFullYear(),secondCalendarDate.getMonth()-1):startDate?startDateMonth&&new Date(startDate.getFullYear(),startDateMonth):new Date}),_useState10=_slicedToArray(_useState9,2),firstCalendarDate=_useState10[0],setFirstCalendarDate=_useState10[1],_useState11=(0,_react2.useState)(!1),_useState12=_slicedToArray(_useState11,2),openYearPicker=_useState12[0],setOpenYearPicker=_useState12[1];(0,_react2.useEffect)(function(){isFirstClick&&!startDate&&(setStartDate(null),setEndDate(null))},[isFirstClick]);var firstCalendarLimit=secondCalendarDate&&new Date(secondCalendarDate.getFullYear(),secondCalendarDate.getMonth(),0),DatePickerContentProps={variant:variant,type:type,startDate:startDate,endDate:endDate,isInTheRange:function isInTheRange(currentDate){if(startDate&&endDate){var start=startDate.getTime(),end=endDate.getTime(),current=currentDate&¤tDate.getTime();return current>start&¤t<end}return!1},handleMouseOver:function handleMouseOver(currentDate){if(startDate){var tableRows=document.querySelectorAll("tbody tr[role=\"row\"]");tableRows.forEach(function(row){var rowCells=row.querySelectorAll("td");rowCells.forEach(function(cell){var cellDate=new Date(cell.getAttribute("data-date")+"");cellDate.getTime()===currentDate.setHours(0,0,0,0)&&+cellDate>+endDate?cell.classList.add("is-current"):cell.classList.remove("is-current"),cellDate<=currentDate&&cellDate>startDate&&!endDate?cell.classList.add("is-hover"):cell.classList.remove("is-hover")})})}},handleChange:function handleChange(newDate){if("date"===type)return setStartDate(newDate),null===onChange||void 0===onChange?void 0:onChange(newDate),resetFirstClick(!1);if(isFirstClick)return null===onChangeStartDate||void 0===onChangeStartDate?void 0:onChangeStartDate(newDate),setStartDate(newDate),setEndDate(null),resetFirstClick(!1);if(startDate){if(newDate<startDate)return null===onChangeStartDate||void 0===onChangeStartDate?void 0:onChangeStartDate(newDate),setStartDate(newDate);null===onChangeEndDate||void 0===onChangeEndDate?void 0:onChangeEndDate(newDate),setEndDate(newDate),null===onChange||void 0===onChange?void 0:onChange([startDate,newDate]),setIsFirstClick(!0)}},minDate:minDate&&new Date(minDate),maxDate:maxDate&&new Date(maxDate),showSelectedDate:!isFirstClickDateInput,handleToggleYearPicker:function handleToggleYearPicker(){setOpenYearPicker(!openYearPicker)},enableYearPicker:enableYearPicker,rangeLimit:rangeLimit,isFirstClick:isFirstClick,availableDays:availableDays};return/*#__PURE__*/(0,_jsxRuntime.jsx)(_react.ThemeProvider,{theme:{colorSelected:color||"primary.default"},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DatePickerContentContainer,{isExtended:"extended"===variant,fullSize:fullSize,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.AnimatePresence,{mode:"wait",children:openYearPicker?/*#__PURE__*/(0,_jsxRuntime.jsx)(_DateYearPicker.DateYearPicker,{date:firstCalendarDate,minDate:minDate,maxDate:maxDate,handleChangeDate:function handleChangeDate(newDate){setFirstCalendarDate(function(){return new Date(newDate.getFullYear(),newDate.getMonth(),1)}),setOpenYearPicker(!1)}}):/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_DatePickerContent.DatePickerContent,_objectSpread(_objectSpread({},DatePickerContentProps),{},{date:firstCalendarDate,minDate:DatePickerContentProps.minDate,maxDate:"extended"!==variant||maxDate?"extended"===variant?maxDate&&firstCalendarLimit&&new Date(maxDate).getTime()<firstCalendarLimit.getTime()?DatePickerContentProps.maxDate:firstCalendarLimit:DatePickerContentProps.maxDate:firstCalendarLimit,disableWeekendDays:disableWeekendDays,handleChangeDate:function handleChangeDate(newDate){return setFirstCalendarDate(newDate)},fullSize:fullSize})),"extended"===variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_DatePickerContent.DatePickerContent,_objectSpread(_objectSpread({},DatePickerContentProps),{},{date:secondCalendarDate,minDate:DatePickerContentProps.minDate,maxDate:DatePickerContentProps.maxDate,handleChangeDate:function handleChangeDate(newDate){setSecondCalendarDate(newDate)},hidePrevMonthButton:function(){if(firstCalendarDate&&secondCalendarDate){var isSecondCalendarNextMonth=(null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getMonth())-1===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getMonth()),isBothSameYear=(null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getFullYear())===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getFullYear());return isSecondCalendarNextMonth&&isBothSameYear}return!1}(),disableWeekendDays:disableWeekendDays,fullSize:fullSize}))]})})})})},_default=DatePicker;exports.default=_default;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { ExtendThemeProps, GlobalColorsProps } from '../../shared/theme/theme.types';
|
|
2
2
|
export type DatePickerTypes = 'date' | 'range';
|
|
3
|
+
export type AvailableDays = {
|
|
4
|
+
sunday: boolean;
|
|
5
|
+
monday: boolean;
|
|
6
|
+
tuesday: boolean;
|
|
7
|
+
wednesday: boolean;
|
|
8
|
+
thursday: boolean;
|
|
9
|
+
friday: boolean;
|
|
10
|
+
saturday: boolean;
|
|
11
|
+
} | null;
|
|
3
12
|
export type DatePickerProps = {
|
|
4
13
|
/**
|
|
5
14
|
* Sets the date picker's type.
|
|
@@ -49,6 +58,11 @@ export type DatePickerProps = {
|
|
|
49
58
|
setIsFirstClickDateInput?: (prev: boolean) => void;
|
|
50
59
|
isFirstClickDateInput?: boolean;
|
|
51
60
|
enableYearPicker?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Sets which days of the week are available for selection.
|
|
63
|
+
* @default null (all days available)
|
|
64
|
+
*/
|
|
65
|
+
availableDays?: AvailableDays;
|
|
52
66
|
};
|
|
53
67
|
export type GenericStyledProps = {
|
|
54
68
|
theme?: ExtendThemeProps & {
|
|
@@ -77,6 +91,7 @@ export type DatePickerContentProps = {
|
|
|
77
91
|
disableWeekendDays?: boolean;
|
|
78
92
|
rangeLimit?: number;
|
|
79
93
|
isFirstClick?: boolean;
|
|
94
|
+
availableDays?: AvailableDays;
|
|
80
95
|
};
|
|
81
96
|
export type DateYearPickerProps = {
|
|
82
97
|
date: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sour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C;IACvB,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAC7C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,gBAAgB,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;IAC1C,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"illustrations.d.ts","sourceRoot":"","sources":["../../../../src/components/Icon/data/illustrations.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;
|
|
1
|
+
{"version":3,"file":"illustrations.d.ts","sourceRoot":"","sources":["../../../../src/components/Icon/data/illustrations.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;GAib9B,CAAC"}
|