@pedidopago/ui 1.16.49 → 1.16.51
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/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/constants.d.ts +2 -0
- package/dist/components/DatePicker/constants.d.ts.map +1 -0
- package/dist/components/DatePicker/constants.js +2 -0
- 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 +6 -5
- package/dist/components/DatePicker/types.d.ts.map +1 -1
- package/dist/components/NewSelect/Multiple/index.d.ts.map +1 -1
- package/dist/components/NewSelect/Multiple/index.js +7 -1
- package/package.json +1 -1
|
@@ -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, }: 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, }: 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":"
|
|
1
|
+
{"version":3,"file":"DatePickerContent.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/components/DatePickerContent.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,iBAAiB,4RAoB3B,sBAAsB,4CAuQxB,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"),_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,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,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||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}/* eslint-disable no-console */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,handleChangeSelectDate=function(newDate){handleChangeDate(newDate),handleChange(newDate)},date=dateProp||new Date,checkIfIsCurrentDateOutOfRangeLimit=(0,_react.useCallback)(function(currentDate){if(!startDate||!rangeLimit)return!1;var RANGE_LIMIT_IN_MILLISECONDS=rangeLimit*_constants.DAY_IN_MILLISECONDS,newDate=startDate.getTime()+RANGE_LIMIT_IN_MILLISECONDS;return currentDate.getTime()>newDate},[startDate,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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAW,CAAC"}
|
|
@@ -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, }: 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, }: 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,wMAcb,eAAe,4CAwPjB,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,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 setStartDate(newDate),setEndDate(null),resetFirstClick(!1);if(startDate){if(newDate<startDate)return setStartDate(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};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(){return!!(firstCalendarDate&&secondCalendarDate)&&((null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getMonth())-1===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getMonth())||0===(null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getMonth())&&11===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getMonth()))}(),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,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 setStartDate(newDate),setEndDate(null),resetFirstClick(!1);if(startDate){if(newDate<startDate)return setStartDate(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};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(){return!!(firstCalendarDate&&secondCalendarDate)&&((null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getMonth())-1===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getMonth())||0===(null===secondCalendarDate||void 0===secondCalendarDate?void 0:secondCalendarDate.getMonth())&&11===(null===firstCalendarDate||void 0===firstCalendarDate?void 0:firstCalendarDate.getMonth()))}(),disableWeekendDays:disableWeekendDays,fullSize:fullSize}))]})})})})},_default=DatePicker;exports.default=_default;
|
|
@@ -21,18 +21,18 @@ export type DatePickerProps = {
|
|
|
21
21
|
*/
|
|
22
22
|
minDate?: Date | number | string;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
24
|
+
* Callback function that is called when the date picker's value changes.
|
|
25
|
+
* @param {Date} date - The new date.
|
|
26
26
|
*/
|
|
27
27
|
maxDate?: Date | number | string;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {Date} date - The new date.
|
|
29
|
+
* Allow expand the component width to full size.
|
|
31
30
|
*/
|
|
32
31
|
fullSize?: boolean;
|
|
33
32
|
/**
|
|
34
|
-
* Allow
|
|
33
|
+
* Allow set the days limit between min and max dates.
|
|
35
34
|
*/
|
|
35
|
+
rangeLimit?: number;
|
|
36
36
|
onChange?: (date: Date | [Date, Date]) => void;
|
|
37
37
|
color?: GlobalColorsProps | (string & {});
|
|
38
38
|
disableWeekendDays?: boolean;
|
|
@@ -65,6 +65,7 @@ export type DatePickerContentProps = {
|
|
|
65
65
|
hideNextMonthButton?: boolean;
|
|
66
66
|
hidePrevMonthButton?: boolean;
|
|
67
67
|
disableWeekendDays?: boolean;
|
|
68
|
+
rangeLimit?: number;
|
|
68
69
|
};
|
|
69
70
|
export type DateYearPickerProps = {
|
|
70
71
|
date: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAErF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAErF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExD;;;OAGG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;IAC/C,KAAK,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC1C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wBAAwB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACnD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,gBAAgB,GAAG;QACzB,aAAa,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;KAClD,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACjC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,OAAO,CAAC;IAC7C,eAAe,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;IAC7C,YAAY,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;IACtC,gBAAgB,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;IAC1C,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,eAAe,CAAC;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;CACrB,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":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/NewSelect/Multiple/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/NewSelect/Multiple/index.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAgB,yBAAyB,EAAe,MAAM,UAAU,CAAC;AAKhF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EACnC,KAAU,EACV,WAAgB,EAChB,KAAK,EACL,UAAU,EACV,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,EACP,MAAM,EACN,aAAa,EACb,QAAQ,EACR,sBAAsB,EACtB,UAAU,EAAE,WAAW,EACvB,GAAG,IAAI,EACR,EAAE,yBAAyB,CAAC,CAAC,CAAC,2CAwN9B"}
|
|
@@ -1 +1,7 @@
|
|
|
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.NewMultipleSelect=NewMultipleSelect;var _react=require("react"),_classnames=_interopRequireDefault(require("classnames")),_Flex=_interopRequireDefault(require("../../Flex")),_Icon=_interopRequireDefault(require("../../Icon")),_ReactPortal=require("../../ReactPortal"),_styles=require("../components/OptionsSelect/styles"),_SelectItem=require("../components/SelectItem"),_useReposition=require("../../../shared/hooks/useReposition"),_useOnClickOutside=require("../../../shared/hooks/useOnClickOutside"),_utils=require("../utils.ts"),_styles2=require("../styles"),_formatters=require("../../../utils/formatters"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","variant","children","value","onClose","onOpen","renderOptions","onChange","optionsContainerStyles","dataTestId"];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 _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 _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 _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 NewMultipleSelect(_ref){function changeMultipleOption(valueOption,node){if(void 0===valueOption)return setSelectedOptions([]),setIsOpenOptions(!1),void(null===onChange||void 0===onChange?void 0:onChange([]));var findOption=selectedOptions.find(function(option){return option.value===valueOption});if(findOption)removeOption(valueOption);else{var newValues=selectedOptions.map(function(option){return option.value});null===onChange||void 0===onChange?void 0:onChange([].concat(_toConsumableArray(newValues),[valueOption]));var newSelectedOption={label:(null===node||void 0===node?void 0:node.innerText)||"",value:valueOption};setSelectedOptions([].concat(_toConsumableArray(selectedOptions),[newSelectedOption]))}}function removeOption(optionToRemove){var newSelectedOptions=null===selectedOptions||void 0===selectedOptions?void 0:selectedOptions.filter(function(option){return option.value!==optionToRemove});setSelectedOptions(newSelectedOptions);var newValues=newSelectedOptions.map(function(option){return option.value});null===onChange||void 0===onChange?void 0:onChange(newValues)}var _containerRef$current,_ref$label=_ref.label,label=void 0===_ref$label?"":_ref$label,_ref$placeholder=_ref.placeholder,placeholder=void 0===_ref$placeholder?"":_ref$placeholder,alert=_ref.alert,helperText=_ref.helperText,variant=_ref.variant,children=_ref.children,value=_ref.value,onClose=_ref.onClose,onOpen=_ref.onOpen,renderOptions=_ref.renderOptions,onChange=_ref.onChange,optionsContainerStyles=_ref.optionsContainerStyles,_dataTestId=_ref.dataTestId,rest=_objectWithoutProperties(_ref,_excluded),containerRef=(0,_react.useRef)(null),selectRef=(0,_react.useRef)(null),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isOpenOptions=_useState2[0],setIsOpenOptions=_useState2[1],_useState3=(0,_react.useState)([]),_useState4=_slicedToArray(_useState3,2),selectedOptions=_useState4[0],setSelectedOptions=_useState4[1],optionsModalRef=(0,_react.useRef)(null),dataTestId=_dataTestId||label?"multiple-select-".concat((0,_formatters.convertToKebabCase)(label)):"multiple-select";(0,_react.useEffect)(function(){function handler(){setIsOpenOptions(!1)}if(isOpenOptions){var _document;null===onOpen||void 0===onOpen?void 0:onOpen(),null===(_document=document)||void 0===_document?void 0:_document.addEventListener("scroll",handler)}else{var _document2;null===onClose||void 0===onClose?void 0:onClose(),null===(_document2=document)||void 0===_document2?void 0:_document2.removeEventListener("scroll",handler)}return function(){var _document3;return null===(_document3=document)||void 0===_document3?void 0:_document3.removeEventListener("scroll",handler)}},[isOpenOptions]),(0,_useOnClickOutside.useOnClickOutside)([containerRef,optionsModalRef],function(){isOpenOptions&&setIsOpenOptions(!1)});var positionsSelect=(0,_useReposition.useReposition)({containerRef:optionsModalRef,triggerRef:selectRef},[children]),SelectedOptionsWithCustomComponent=function(_ref2){var option=_ref2.option;return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:null===renderOptions||void 0===renderOptions?void 0:renderOptions(option,function(){return removeOption(option.value)})})},newSelectedOptions=[];return(0,_react.useEffect)(function(){var isValueArrayEmpty=Array.isArray(value)&&0===(null===value||void 0===value?void 0:value.length);(!value||isValueArrayEmpty)&&setSelectedOptions([])},[value]),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{ref:selectRef,style:{width:"100%"},children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",style:{width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectContainer,{"data-disabled":rest.disabled,"data-variant":variant,"data-label-in-top":!!(null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions[0])||!!placeholder,alert:alert,tabIndex:rest.disabled?-1:0,onClick:function onClick(){return setIsOpenOptions(!isOpenOptions)},className:rest.className,style:rest.style,ref:containerRef,"data-testid":dataTestId,children:[label&&"unstyled"!==variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)("label",{title:label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"container_selected_options",children:null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions[0]?selectedOptions.map(function(option,index){return"function"==typeof renderOptions?/*#__PURE__*/(0,_jsxRuntime.jsx)(SelectedOptionsWithCustomComponent,{option:option},"custom-option-selected-".concat(index)):/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectedOptionSpan,{hasSelectedOption:!0,children:[null===option||void 0===option?void 0:option.label,1<selectedOptions.length&&index<selectedOptions.length-1&&","]},index)}):/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.SelectedOptionSpan,{title:"placeholder",children:placeholder})}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{className:"select_container_icon",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-down"})})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_ReactPortal.ReactPortal,{wrapperId:"portal-root",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.OptionsContainer,{ref:optionsModalRef,open:isOpenOptions,style:_objectSpread(_objectSpread({maxWidth:"".concat(null===(_containerRef$current=containerRef.current)||void 0===_containerRef$current?void 0:_containerRef$current.getBoundingClientRect().width,"px")},optionsContainerStyles),{},{left:positionsSelect.left,top:positionsSelect.top}),children:_react.Children.map(children,function(child,index){var isSelectItemElement=(null===child||void 0===child?void 0:child.type)===_SelectItem.SelectItem;if(!/*#__PURE__*/(0,_react.isValidElement)(child)||!isSelectItemElement)return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{children:child});var childElement=child,_selectItemUtils=(0,_utils.selectItemUtils)(),getSelectItemInfos=_selectItemUtils.getSelectItemInfos,isSelectedOption=!!(null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions.find(function(option){var _childElement$props;return option.value===(null===(_childElement$props=childElement.props)||void 0===_childElement$props?void 0:_childElement$props.value)})),className=(0,_classnames.default)({selected:isSelectedOption});return/*#__PURE__*/(0,_react.cloneElement)(childElement,{ref:function ref(node){if(node){var _getSelectItemInfos=getSelectItemInfos(node),selectItemValue=_getSelectItemInfos.selectItemValue,selectItemNode=_getSelectItemInfos.selectItemNode;if(null!==value&&void 0!==value&&value.includes(selectItemValue)){var option={label:(null===selectItemNode||void 0===selectItemNode?void 0:selectItemNode.innerText)||"",value:selectItemValue};newSelectedOptions.push(option)}if(value){var allNewOptionsAreSelected=selectedOptions.every(function(item){return null===value||void 0===value?void 0:value.includes(item.value)})&&selectedOptions.length===newSelectedOptions.length;_react.Children.count(children)!==index+1||allNewOptionsAreSelected||setSelectedOptions(newSelectedOptions)}}},onClick:function onClick(event){var _childElement$props2,_childElement$props2$;if(null===(_childElement$props2=childElement.props)||void 0===_childElement$props2||null===(_childElement$props2$=_childElement$props2.onClick)||void 0===_childElement$props2$?void 0:_childElement$props2$.call(_childElement$props2,event),event.currentTarget.classList.contains("select-item")){var _getSelectItemInfos2=getSelectItemInfos(),selectItemNode=_getSelectItemInfos2.selectItemNode;changeMultipleOption(childElement.props.value,selectItemNode)}},className:className})})})}),!!helperText&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.HelperText,{alert:alert,children:helperText})]})})}
|
|
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.NewMultipleSelect=NewMultipleSelect;var _react=require("react"),_classnames=_interopRequireDefault(require("classnames")),_Flex=_interopRequireDefault(require("../../Flex")),_Icon=_interopRequireDefault(require("../../Icon")),_ReactPortal=require("../../ReactPortal"),_styles=require("../components/OptionsSelect/styles"),_SelectItem=require("../components/SelectItem"),_useDebounce=require("../../../shared/hooks/useDebounce"),_useReposition=require("../../../shared/hooks/useReposition"),_useOnClickOutside=require("../../../shared/hooks/useOnClickOutside"),_utils=require("../utils.ts"),_formatters=require("../../../utils/formatters"),_styles2=require("../styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","variant","children","value","onClose","onOpen","renderOptions","onChange","optionsContainerStyles","dataTestId"];// Libs
|
|
2
|
+
// Components
|
|
3
|
+
// Hooks
|
|
4
|
+
// Utils
|
|
5
|
+
// Types
|
|
6
|
+
// Styles
|
|
7
|
+
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 _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 _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 _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 NewMultipleSelect(_ref){function changeMultipleOption(valueOption,node){if(void 0===valueOption)return setSelectedOptions([]),setIsOpenOptions(!1),void(null===onChange||void 0===onChange?void 0:onChange([]));var findOption=selectedOptions.find(function(option){return option.value===valueOption});if(findOption)removeOption(valueOption);else{var newValues=selectedOptions.map(function(option){return option.value});null===onChange||void 0===onChange?void 0:onChange([].concat(_toConsumableArray(newValues),[valueOption]));var newSelectedOption={label:(null===node||void 0===node?void 0:node.innerText)||"",value:valueOption};setSelectedOptions([].concat(_toConsumableArray(selectedOptions),[newSelectedOption]))}}function removeOption(optionToRemove){var newSelectedOptions=null===selectedOptions||void 0===selectedOptions?void 0:selectedOptions.filter(function(option){return option.value!==optionToRemove});setSelectedOptions(newSelectedOptions);var newValues=newSelectedOptions.map(function(option){return option.value});null===onChange||void 0===onChange?void 0:onChange(newValues)}var _containerRef$current,_ref$label=_ref.label,label=void 0===_ref$label?"":_ref$label,_ref$placeholder=_ref.placeholder,placeholder=void 0===_ref$placeholder?"":_ref$placeholder,alert=_ref.alert,helperText=_ref.helperText,variant=_ref.variant,children=_ref.children,value=_ref.value,onClose=_ref.onClose,onOpen=_ref.onOpen,renderOptions=_ref.renderOptions,onChange=_ref.onChange,optionsContainerStyles=_ref.optionsContainerStyles,_dataTestId=_ref.dataTestId,rest=_objectWithoutProperties(_ref,_excluded),isSettingDefaultValue=(0,_react.useRef)(!1),containerRef=(0,_react.useRef)(null),selectRef=(0,_react.useRef)(null),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isOpenOptions=_useState2[0],setIsOpenOptions=_useState2[1],_useState3=(0,_react.useState)([]),_useState4=_slicedToArray(_useState3,2),selectedOptions=_useState4[0],setSelectedOptions=_useState4[1],optionsModalRef=(0,_react.useRef)(null),dataTestId=_dataTestId||label?"multiple-select-".concat((0,_formatters.convertToKebabCase)(label)):"multiple-select";(0,_react.useEffect)(function(){function handler(){setIsOpenOptions(!1)}if(isOpenOptions){var _document;null===onOpen||void 0===onOpen?void 0:onOpen(),null===(_document=document)||void 0===_document?void 0:_document.addEventListener("scroll",handler)}else{var _document2;null===onClose||void 0===onClose?void 0:onClose(),null===(_document2=document)||void 0===_document2?void 0:_document2.removeEventListener("scroll",handler)}return function(){var _document3;return null===(_document3=document)||void 0===_document3?void 0:_document3.removeEventListener("scroll",handler)}},[isOpenOptions]),(0,_useOnClickOutside.useOnClickOutside)([containerRef,optionsModalRef],function(){isOpenOptions&&setIsOpenOptions(!1)});var positionsSelect=(0,_useReposition.useReposition)({containerRef:optionsModalRef,triggerRef:selectRef},[children]),SelectedOptionsWithCustomComponent=function(_ref2){var option=_ref2.option;return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:null===renderOptions||void 0===renderOptions?void 0:renderOptions(option,function(){return removeOption(option.value)})})},newSelectedOptions=[];(0,_react.useEffect)(function(){var isValueArrayEmpty=Array.isArray(value)&&0===(null===value||void 0===value?void 0:value.length);(!value||isValueArrayEmpty)&&setSelectedOptions([])},[value]);var valueSetterDebounce=(0,_useDebounce.useDebounce)(function(newSelectedOptions){isSettingDefaultValue.current=!0,setSelectedOptions(newSelectedOptions)},0,!1);return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{ref:selectRef,style:{width:"100%"},children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",style:{width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectContainer,{"data-disabled":rest.disabled,"data-variant":variant,"data-label-in-top":!!(null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions[0])||!!placeholder,alert:alert,tabIndex:rest.disabled?-1:0,onClick:function onClick(){return setIsOpenOptions(!isOpenOptions)},className:rest.className,style:rest.style,ref:containerRef,"data-testid":dataTestId,children:[label&&"unstyled"!==variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)("label",{title:label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"container_selected_options",children:null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions[0]?selectedOptions.map(function(option,index){return"function"==typeof renderOptions?/*#__PURE__*/(0,_jsxRuntime.jsx)(SelectedOptionsWithCustomComponent,{option:option},"custom-option-selected-".concat(index)):/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectedOptionSpan,{hasSelectedOption:!0,children:[null===option||void 0===option?void 0:option.label,1<selectedOptions.length&&index<selectedOptions.length-1&&","]},index)}):/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.SelectedOptionSpan,{title:"placeholder",children:placeholder})}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{className:"select_container_icon",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-down"})})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_ReactPortal.ReactPortal,{wrapperId:"portal-root",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.OptionsContainer,{ref:optionsModalRef,open:isOpenOptions,style:_objectSpread(_objectSpread({maxWidth:"".concat(null===(_containerRef$current=containerRef.current)||void 0===_containerRef$current?void 0:_containerRef$current.getBoundingClientRect().width,"px")},optionsContainerStyles),{},{left:positionsSelect.left,top:positionsSelect.top}),children:_react.Children.map(children,function(child){var isSelectItemElement=(null===child||void 0===child?void 0:child.type)===_SelectItem.SelectItem;if(!/*#__PURE__*/(0,_react.isValidElement)(child)||!isSelectItemElement)return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{children:child});var childElement=child,_selectItemUtils=(0,_utils.selectItemUtils)(),getSelectItemInfos=_selectItemUtils.getSelectItemInfos,isSelectedOption=!!(null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions.find(function(option){var _childElement$props;return option.value===(null===(_childElement$props=childElement.props)||void 0===_childElement$props?void 0:_childElement$props.value)})),className=(0,_classnames.default)({selected:isSelectedOption});return/*#__PURE__*/(0,_react.cloneElement)(childElement,{ref:function ref(node){if(node){var _getSelectItemInfos=getSelectItemInfos(node),selectItemValue=_getSelectItemInfos.selectItemValue,selectItemNode=_getSelectItemInfos.selectItemNode;if(null!==value&&void 0!==value&&value.includes(selectItemValue)){var option={label:(null===selectItemNode||void 0===selectItemNode?void 0:selectItemNode.innerText)||"",value:selectItemValue};newSelectedOptions.push(option)}var allNewOptionsAreSelected=selectedOptions.every(function(item){return null===value||void 0===value?void 0:value.includes(item.value)})&&selectedOptions.length===newSelectedOptions.length;allNewOptionsAreSelected&&(isSettingDefaultValue.current=!1),!value||isSettingDefaultValue.current||allNewOptionsAreSelected||valueSetterDebounce(newSelectedOptions)}},onClick:function onClick(event){var _childElement$props2,_childElement$props2$;if(null===(_childElement$props2=childElement.props)||void 0===_childElement$props2||null===(_childElement$props2$=_childElement$props2.onClick)||void 0===_childElement$props2$?void 0:_childElement$props2$.call(_childElement$props2,event),event.currentTarget.classList.contains("select-item")){var _getSelectItemInfos2=getSelectItemInfos(),selectItemNode=_getSelectItemInfos2.selectItemNode;changeMultipleOption(childElement.props.value,selectItemNode)}},className:className})})})}),!!helperText&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.HelperText,{alert:alert,children:helperText})]})})}
|