@pedidopago/ui 1.12.10 → 1.12.12
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/index.d.ts +1 -1
- 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 +1 -0
- package/dist/components/DateInput/types.d.ts.map +1 -1
- package/dist/components/TimeInput/constants.d.ts +7 -3
- package/dist/components/TimeInput/constants.d.ts.map +1 -1
- package/dist/components/TimeInput/constants.js +1 -1
- package/dist/components/TimeInput/index.d.ts.map +1 -1
- package/dist/components/TimeInput/index.js +2 -2
- package/dist/components/TimeInput/types.d.ts +1 -0
- package/dist/components/TimeInput/types.d.ts.map +1 -1
- package/dist/components/TimeInput/utils.d.ts +2 -1
- package/dist/components/TimeInput/utils.d.ts.map +1 -1
- package/dist/components/TimeInput/utils.js +3 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DateInputProps } from './types';
|
|
3
|
-
export declare function DateInput({ label, placeholder, alert, helperText, value, locales, localeOptions, onChange, disabled, disableWeekendDays, iconColor, ...rest }: DateInputProps): JSX.Element;
|
|
3
|
+
export declare function DateInput({ label, placeholder, alert, helperText, value, locales, localeOptions, onChange, disabled, disableWeekendDays, iconColor, showRemoveButton, ...rest }: DateInputProps): 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,cAAc,EAAa,MAAM,SAAS,CAAC;AAEpD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,WAAW,EACX,KAAK,EACL,UAAU,EACV,KAAK,EACL,OAAiB,EACjB,aAAa,EACb,QAAQ,EACR,QAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateInput/index.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAEpD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,WAAW,EACX,KAAK,EACL,UAAU,EACV,KAAK,EACL,OAAiB,EACjB,aAAa,EACb,QAAQ,EACR,QAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,cAAc,eAkGhB"}
|
|
@@ -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 _react=require("react"),_framerMotion=require("framer-motion"),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_DatePicker=_interopRequireDefault(require("../DatePicker")),_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"];// Libs
|
|
1
|
+
"use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateInput=DateInput;var _react=require("react"),_framerMotion=require("framer-motion"),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_DatePicker=_interopRequireDefault(require("../DatePicker")),_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"];// 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)}var label=_ref.label,placeholder=_ref.placeholder,alert=_ref.alert,helperText=_ref.helperText,value=_ref.value,_ref$locales=_ref.locales,locales=void 0===_ref$locales?"pt-BR":_ref$locales,localeOptions=_ref.localeOptions,onChange=_ref.onChange,_ref$disabled=_ref.disabled,disabled=void 0!==_ref$disabled&&_ref$disabled,disableWeekendDays=_ref.disableWeekendDays,iconColor=_ref.iconColor,rest=_objectWithoutProperties(_ref,_excluded),containerRef=(0,_react.useRef)(null),_useState=(0,_react.useState)(),_useState2=_slicedToArray(_useState,2),currentValue=_useState2[0],setCurrentValue=_useState2[1],_useState3=(0,_react.useState)(!0),_useState4=_slicedToArray(_useState3,2),isFirstClickDateInput=_useState4[0],setIsFirstClickDateInput=_useState4[1],_useState5=(0,_react.useState)(!1),_useState6=_slicedToArray(_useState5,2),datePickerOpen=_useState6[0],setDatePickerOpen=_useState6[1];(0,_react.useEffect)(function(){setCurrentValue(value)},[value]),(0,_useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen,"child_element");var toggleOptionsAreaView=(0,_react.useCallback)(function(event){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
|
|
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(null)}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(){setCurrentValue(value)},[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:selectDate,disableWeekendDays:disableWeekendDays,isFirstClickDateInput:isFirstClickDateInput,setIsFirstClickDateInput:setIsFirstClickDateInput},rest))})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/DateInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAExE,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IAC3C,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/DateInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAExE,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IAC3C,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const TWENTY_FOUR_HOUR_LIST: string[];
|
|
2
|
+
export declare const AM_PM_HOUR_LIST: string[];
|
|
3
3
|
export declare const MINUTE_LIST: string[];
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const TIME_PERIODS: string[];
|
|
5
|
+
export declare const MAX_VALID_TIME = 2359;
|
|
6
|
+
export declare const MAX_VALID_HOUR = 23;
|
|
7
|
+
export declare const MAX_TIME_TO_PAD_END_WITH_ZERO = 236;
|
|
8
|
+
export declare const MAX_MINUTE_FIRST_DIGIT = 6;
|
|
5
9
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,UAAmC,CAAC;AAGtE,eAAO,MAAM,eAAe,UAA6B,CAAC;AAG1D,eAAO,MAAM,WAAW,UAAyB,CAAC;AAElD,eAAO,MAAM,YAAY,UAAyB,CAAC;AAEnD,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TWENTY_FOUR_HOUR_LIST=exports.TIME_PERIODS=exports.MINUTE_LIST=exports.MAX_VALID_TIME=exports.MAX_VALID_HOUR=exports.MAX_TIME_TO_PAD_END_WITH_ZERO=exports.MAX_MINUTE_FIRST_DIGIT=exports.AM_PM_HOUR_LIST=void 0;var TWENTY_FOUR_HOURS=Array.from({length:24},function(_,i){return i.toString().padStart(2,"0")}),TWENTY_FOUR_HOUR_LIST=["-"].concat(TWENTY_FOUR_HOURS,["-"]);exports.TWENTY_FOUR_HOUR_LIST=TWENTY_FOUR_HOUR_LIST;var AM_PM_HOURS=Array.from({length:12},function(_,i){return(i+1).toString().padStart(2,"0")}),AM_PM_HOUR_LIST=["-"].concat(AM_PM_HOURS,["-"]);exports.AM_PM_HOUR_LIST=AM_PM_HOUR_LIST;var MINUTES=Array.from({length:60},function(_,i){return i.toString().padStart(2,"0")}),MINUTE_LIST=["-"].concat(MINUTES,["-"]);exports.MINUTE_LIST=MINUTE_LIST;var TIME_PERIODS=["-","AM","PM","-"];exports.TIME_PERIODS=TIME_PERIODS;var MAX_VALID_TIME=2359;exports.MAX_VALID_TIME=MAX_VALID_TIME;var MAX_VALID_HOUR=23;exports.MAX_VALID_HOUR=MAX_VALID_HOUR;var MAX_TIME_TO_PAD_END_WITH_ZERO=236;exports.MAX_TIME_TO_PAD_END_WITH_ZERO=MAX_TIME_TO_PAD_END_WITH_ZERO;var MAX_MINUTE_FIRST_DIGIT=6;exports.MAX_MINUTE_FIRST_DIGIT=MAX_MINUTE_FIRST_DIGIT;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EAKpB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EAKpB,MAAM,OAAO,CAAC;AA4Bf,OAAO,EAAE,cAAc,EAAc,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,eAAO,MAAM,SAAS,uKA0QrB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
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.TimeInput=void 0;var _react=require("react"),_framerMotion=require("framer-motion"),_Button=_interopRequireDefault(require("../Button")),_Flex=_interopRequireDefault(require("../Flex")),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_Typography=_interopRequireDefault(require("../Typography")),_Modal=require("../Modal"),_Observer=require("../Observer"),_useDraggableScroll4=require("../../shared/hooks/useDraggableScroll"),_utils=require("./utils"),_styles=require("./styles"),_constants=require("./constants"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","helperText","alert","variant"];// Libs
|
|
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.TimeInput=void 0;var _react=require("react"),_framerMotion=require("framer-motion"),_Button=_interopRequireDefault(require("../Button")),_Flex=_interopRequireDefault(require("../Flex")),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_Typography=_interopRequireDefault(require("../Typography")),_Modal=require("../Modal"),_Observer=require("../Observer"),_useDraggableScroll4=require("../../shared/hooks/useDraggableScroll"),_utils=require("./utils"),_styles=require("./styles"),_constants=require("./constants"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","helperText","alert","variant","showRemoveButton"];// Libs
|
|
2
2
|
// Components
|
|
3
3
|
// Hooks
|
|
4
4
|
// Utils
|
|
5
5
|
// Styles
|
|
6
6
|
// Types
|
|
7
7
|
// Constants
|
|
8
|
-
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}var TimeInput=/*#__PURE__*/(0,_react.forwardRef)(function(_ref,ref){function handleOnClose(){setIsModalOpen(function(oldState){return!oldState})}var _ref$label=_ref.label,label=void 0===_ref$label?"":_ref$label,_ref$placeholder=_ref.placeholder,placeholder=void 0===_ref$placeholder?"":_ref$placeholder,helperText=_ref.helperText,alert=_ref.alert,_ref$variant=_ref.variant,variant=void 0===_ref$variant?"24_hours":_ref$variant,rest=_objectWithoutProperties(_ref,_excluded),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isModalOpen=_useState2[0],setIsModalOpen=_useState2[1],timeInputRef=(0,_react.useRef)(null),mainContainer=(0,_react.useRef)(null),hourContainerRef=(0,_react.useRef)(null),minuteContainerRef=(0,_react.useRef)(null),hourElementRef=(0,_react.useRef)(null),minuteElementRef=(0,_react.useRef)(null),timePeriodContainerRef=(0,_react.useRef)(null),_useState3=(0,_react.useState)("00:00"),_useState4=_slicedToArray(_useState3,2),selectedTime=_useState4[0],setSelectedTime=_useState4[1],_useState5=(0,_react.useState)(),_useState6=_slicedToArray(_useState5,2),timeValue=_useState6[0],setTimeValue=_useState6[1],_useState7=(0,_react.useState)("PM"),_useState8=_slicedToArray(_useState7,2),selectedPeriod=_useState8[0],setSelectedPeriod=_useState8[1],_useState9=(0,_react.useState)(),_useState10=_slicedToArray(_useState9,2),periodValue=_useState10[0],setPeriodValue=_useState10[1],HOUR_LIST="24_hours"===variant?_constants.TWENTYFOUR_HOUR_LIST:_constants.AMPM_HOUR_LIST,observerOptions=(0,_utils.setObserverOptions)(mainContainer),isAMPMVariant="am_pm"===variant,_useDraggableScroll=(0,_useDraggableScroll4.useDraggableScroll)(hourContainerRef,{direction:"vertical"}),onMouseDownHour=_useDraggableScroll.onMouseDown,_useDraggableScroll2=(0,_useDraggableScroll4.useDraggableScroll)(minuteContainerRef,{direction:"vertical"}),onMouseDownMinute=_useDraggableScroll2.onMouseDown,_useDraggableScroll3=(0,_useDraggableScroll4.useDraggableScroll)(timePeriodContainerRef,{direction:"vertical"}),onMouseDownTimePeriod=_useDraggableScroll3.onMouseDown;return(0,_react.useImperativeHandle)(ref,function(){return timeInputRef.current}),(0,_react.useEffect)(function(){hourContainerRef.current&&minuteContainerRef.current&&timeValue&&(0,_utils.handleScrollIntoView)(hourContainerRef,minuteContainerRef,timeValue,timePeriodContainerRef)},[isModalOpen]),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.TimeInputContainer,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Input.default,_objectSpread(_objectSpread({"data-testid":"time-input",ref:timeInputRef,leftIcon:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"clock",color:"neutral.neutral5"}),onLeftIconClick:function(){var _timeInputRef$current,_timeInputRef$current2;setSelectedTime(null===(_timeInputRef$current=timeInputRef.current)||void 0===_timeInputRef$current?void 0:_timeInputRef$current.value),setTimeValue(null===(_timeInputRef$current2=timeInputRef.current)||void 0===_timeInputRef$current2?void 0:_timeInputRef$current2.value),rest.disabled||setIsModalOpen(function(oldState){return!oldState})},rightIcon:/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.AnimatePresence,{mode:"wait",children:timeValue?/*#__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(){setTimeValue(""),setSelectedTime(""),(0,_utils.handleSetNativeInputValue)(timeInputRef,"")},label:label,type:"24_hours"===variant?"tel":"text",placeholder:placeholder||"HH:MM ".concat("am_pm"===variant?"AM/PM":""),helperText:helperText,alert:alert,disabled:!!rest.disabled,tabIndex:rest.disabled?-1:0,className:rest.className,style:rest.style},rest),{},{onChange:function onChange(event){var _rest$onChange;event.currentTarget.value=(0,_utils.onChangeFormatter)(event,isAMPMVariant),setTimeValue(event.currentTarget.value),setSelectedTime(event.currentTarget.value),(0,_utils.handleSetNativeInputValue)(timeInputRef,event.currentTarget.value),null===(_rest$onChange=rest.onChange)||void 0===_rest$onChange?void 0:_rest$onChange.call(rest,event)}})),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Modal.Modal,{maxWidth:"min(400px, 90%)",maxHeight:"370px",open:isModalOpen,onClose:handleOnClose,children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",alignItems:"center",spacing:"8",style:{padding:"2em",width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.ClockContent,{ref:mainContainer,variant:variant,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DigitContainer,{ref:hourContainerRef,onMouseDown:onMouseDownHour,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"hour_separator",ref:hourElementRef}),HOUR_LIST.map(function(hour,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Observer.Observer,{onObserved:function onObserved(){setSelectedTime(function(state){var _state$split=state.split(":"),_state$split2=_slicedToArray(_state$split,2),minute=_state$split2[1];return"".concat(hour,":").concat(minute)})},observerOptions:observerOptions,children:/*#__PURE__*/(0,_jsxRuntime.jsx)("li",{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6","data-input-hour":hour,children:hour})})},"hour-".concat(index))})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"comma",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6",children:":"})}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DigitContainer,{ref:minuteContainerRef,onMouseDown:onMouseDownMinute,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"minutes_separator",ref:minuteElementRef}),_constants.MINUTE_LIST.map(function(minute,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Observer.Observer,{onObserved:function onObserved(){setSelectedTime(function(state){var _state$split3=state.split(":"),_state$split4=_slicedToArray(_state$split3,1),hour=_state$split4[0];return"".concat(hour,":").concat(minute)})},observerOptions:observerOptions,children:/*#__PURE__*/(0,_jsxRuntime.jsx)("li",{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6","data-input-minute":minute,children:minute})})},"minute-".concat(index))})]}),isAMPMVariant&&/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DigitContainer,{ref:timePeriodContainerRef,onMouseDown:onMouseDownTimePeriod,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"ampm_separator",ref:minuteElementRef}),_constants.TIMEPERIODS.map(function(period,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Observer.Observer,{onObserved:function onObserved(){setSelectedPeriod(period)},observerOptions:observerOptions,children:/*#__PURE__*/(0,_jsxRuntime.jsx)("li",{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6","data-input-period":period,children:period})})},"am-pm-".concat(index))})]})]}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"row",alignItems:"center",spacing:"4",style:{width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Button.default,{variant:"outline",bgColor:"tertiary.default",textColor:"tertiary.focus",fullWidth:!0,onClick:handleOnClose,children:"Cancelar"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Button.default,{fullWidth:!0,onClick:function(){var timeFormatted=selectedTime;if(isAMPMVariant?(setPeriodValue(periodValue),timeFormatted="".concat(selectedTime," ").concat(selectedPeriod),setTimeValue(timeFormatted)):setTimeValue(timeFormatted),timeInputRef.current){var _nativeInputValueSett,nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value");null===nativeInputValueSetter||void 0===nativeInputValueSetter||null===(_nativeInputValueSett=nativeInputValueSetter.set)||void 0===_nativeInputValueSett?void 0:_nativeInputValueSett.call(timeInputRef.current,timeFormatted);var event=new Event("input",{bubbles:!0});timeInputRef.current.dispatchEvent(event)}setIsModalOpen(!1)},"data-testid":"time-input-confirm-button",children:"Ok"})]})]})})]})});exports.TimeInput=TimeInput,TimeInput.displayName="TimeInput";
|
|
8
|
+
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}var TimeInput=/*#__PURE__*/(0,_react.forwardRef)(function(_ref,ref){function handleOnClose(){setIsModalOpen(function(oldState){return!oldState})}function handleReset(){setTimeValue(""),setSelectedTime(""),(0,_utils.handleSetNativeInputValue)(timeInputRef,"")}var _ref$label=_ref.label,label=void 0===_ref$label?"":_ref$label,_ref$placeholder=_ref.placeholder,placeholder=void 0===_ref$placeholder?"":_ref$placeholder,helperText=_ref.helperText,alert=_ref.alert,_ref$variant=_ref.variant,variant=void 0===_ref$variant?"24_hours":_ref$variant,showRemoveButton=_ref.showRemoveButton,rest=_objectWithoutProperties(_ref,_excluded),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isModalOpen=_useState2[0],setIsModalOpen=_useState2[1],timeInputRef=(0,_react.useRef)(null),mainContainer=(0,_react.useRef)(null),hourContainerRef=(0,_react.useRef)(null),minuteContainerRef=(0,_react.useRef)(null),hourElementRef=(0,_react.useRef)(null),minuteElementRef=(0,_react.useRef)(null),timePeriodContainerRef=(0,_react.useRef)(null),_useState3=(0,_react.useState)("00:00"),_useState4=_slicedToArray(_useState3,2),selectedTime=_useState4[0],setSelectedTime=_useState4[1],_useState5=(0,_react.useState)(),_useState6=_slicedToArray(_useState5,2),timeValue=_useState6[0],setTimeValue=_useState6[1],_useState7=(0,_react.useState)("PM"),_useState8=_slicedToArray(_useState7,2),selectedPeriod=_useState8[0],setSelectedPeriod=_useState8[1],_useState9=(0,_react.useState)(),_useState10=_slicedToArray(_useState9,2),periodValue=_useState10[0],setPeriodValue=_useState10[1],HOUR_LIST="24_hours"===variant?_constants.TWENTY_FOUR_HOUR_LIST:_constants.AM_PM_HOUR_LIST,observerOptions=(0,_utils.setObserverOptions)(mainContainer),isAmPmVariant="am_pm"===variant,_useDraggableScroll=(0,_useDraggableScroll4.useDraggableScroll)(hourContainerRef,{direction:"vertical"}),onMouseDownHour=_useDraggableScroll.onMouseDown,_useDraggableScroll2=(0,_useDraggableScroll4.useDraggableScroll)(minuteContainerRef,{direction:"vertical"}),onMouseDownMinute=_useDraggableScroll2.onMouseDown,_useDraggableScroll3=(0,_useDraggableScroll4.useDraggableScroll)(timePeriodContainerRef,{direction:"vertical"}),onMouseDownTimePeriod=_useDraggableScroll3.onMouseDown;return(0,_react.useImperativeHandle)(ref,function(){return timeInputRef.current}),(0,_react.useEffect)(function(){hourContainerRef.current&&minuteContainerRef.current&&timeValue&&(0,_utils.handleScrollIntoView)(hourContainerRef,minuteContainerRef,timeValue,timePeriodContainerRef)},[isModalOpen]),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.TimeInputContainer,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Input.default,_objectSpread(_objectSpread({"data-testid":"time-input",ref:timeInputRef,leftIcon:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"clock",color:"neutral.neutral5"}),onLeftIconClick:function(){var _timeInputRef$current,_timeInputRef$current2;setSelectedTime(null===(_timeInputRef$current=timeInputRef.current)||void 0===_timeInputRef$current?void 0:_timeInputRef$current.value),setTimeValue(null===(_timeInputRef$current2=timeInputRef.current)||void 0===_timeInputRef$current2?void 0:_timeInputRef$current2.value),rest.disabled||setIsModalOpen(function(oldState){return!oldState})},rightIcon:showRemoveButton&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_framerMotion.AnimatePresence,{mode:"wait",children:timeValue?/*#__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()},label:label,type:"24_hours"===variant?"tel":"text",placeholder:placeholder||"HH:MM ".concat("am_pm"===variant?"AM/PM":""),helperText:helperText,alert:alert,disabled:!!rest.disabled,tabIndex:rest.disabled?-1:0,className:rest.className,style:rest.style},rest),{},{onChange:function onChange(event){var _rest$onChange;event.currentTarget.value=(0,_utils.onChangeFormatter)(event,isAmPmVariant),setTimeValue(event.currentTarget.value),setSelectedTime(event.currentTarget.value),(0,_utils.handleSetNativeInputValue)(timeInputRef,event.currentTarget.value),null===(_rest$onChange=rest.onChange)||void 0===_rest$onChange?void 0:_rest$onChange.call(rest,event)},onBlur:function onBlur(event){event.currentTarget.value=(0,_utils.onBlurTimeInputFormatter)(event)}})),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Modal.Modal,{maxWidth:"min(400px, 90%)",maxHeight:"370px",open:isModalOpen,onClose:handleOnClose,children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",alignItems:"center",spacing:"8",style:{padding:"2em",width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.ClockContent,{ref:mainContainer,variant:variant,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DigitContainer,{ref:hourContainerRef,onMouseDown:onMouseDownHour,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"hour_separator",ref:hourElementRef}),HOUR_LIST.map(function(hour,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Observer.Observer,{onObserved:function onObserved(){setSelectedTime(function(state){var _state$split=state.split(":"),_state$split2=_slicedToArray(_state$split,2),minute=_state$split2[1];return"".concat(hour,":").concat(minute)})},observerOptions:observerOptions,children:/*#__PURE__*/(0,_jsxRuntime.jsx)("li",{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6","data-input-hour":hour,children:hour})})},"hour-".concat(index))})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"comma",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6",children:":"})}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DigitContainer,{ref:minuteContainerRef,onMouseDown:onMouseDownMinute,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"minutes_separator",ref:minuteElementRef}),_constants.MINUTE_LIST.map(function(minute,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Observer.Observer,{onObserved:function onObserved(){setSelectedTime(function(state){var _state$split3=state.split(":"),_state$split4=_slicedToArray(_state$split3,1),hour=_state$split4[0];return"".concat(hour,":").concat(minute)})},observerOptions:observerOptions,children:/*#__PURE__*/(0,_jsxRuntime.jsx)("li",{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6","data-input-minute":minute,children:minute})})},"minute-".concat(index))})]}),isAmPmVariant&&/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.DigitContainer,{ref:timePeriodContainerRef,onMouseDown:onMouseDownTimePeriod,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"ampm_separator",ref:minuteElementRef}),_constants.TIME_PERIODS.map(function(period,index){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Observer.Observer,{onObserved:function onObserved(){setSelectedPeriod(period)},observerOptions:observerOptions,children:/*#__PURE__*/(0,_jsxRuntime.jsx)("li",{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{fontSize:"xl",fontWeight:"600",color:"neutral.neutral6","data-input-period":period,children:period})})},"am-pm-".concat(index))})]})]}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"row",alignItems:"center",spacing:"4",style:{width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Button.default,{variant:"outline",bgColor:"tertiary.default",textColor:"tertiary.focus",fullWidth:!0,onClick:handleOnClose,children:"Cancelar"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Button.default,{fullWidth:!0,onClick:function(){var timeFormatted=selectedTime;if(isAmPmVariant?(setPeriodValue(periodValue),timeFormatted="".concat(selectedTime," ").concat(selectedPeriod),setTimeValue(timeFormatted)):setTimeValue(timeFormatted),timeInputRef.current){var _nativeInputValueSett,nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value");null===nativeInputValueSetter||void 0===nativeInputValueSetter||null===(_nativeInputValueSett=nativeInputValueSetter.set)||void 0===_nativeInputValueSett?void 0:_nativeInputValueSett.call(timeInputRef.current,timeFormatted);var event=new Event("input",{bubbles:!0});timeInputRef.current.dispatchEvent(event)}setIsModalOpen(!1)},"data-testid":"time-input-confirm-button",children:"Ok"})]})]})})]})});exports.TimeInput=TimeInput,TimeInput.displayName="TimeInput";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC"}
|
|
@@ -6,5 +6,6 @@ export declare function setObserverOptions(mainContainer: RefObject<HTMLDivEleme
|
|
|
6
6
|
threshold: number;
|
|
7
7
|
rootMargin: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function onChangeFormatter(event: React.FormEvent<HTMLInputElement> | React.ChangeEvent<HTMLInputElement>,
|
|
9
|
+
export declare function onChangeFormatter(event: React.FormEvent<HTMLInputElement> | React.ChangeEvent<HTMLInputElement>, isAmPmVariant: boolean): string;
|
|
10
|
+
export declare function onBlurTimeInputFormatter(event: React.FormEvent<HTMLInputElement>): string;
|
|
10
11
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/TimeInput/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUlC,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,SAAS,CAAC,cAAc,CAAC,EAC3C,kBAAkB,EAAE,SAAS,CAAC,cAAc,CAAC,EAC7C,UAAU,EAAE,MAAM,EAClB,sBAAsB,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,QAkCnD;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,SAAS,CAAC,gBAAgB,CAAC,EACzC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,QAU5C;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC;;;;EAM1E;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAC9E,aAAa,EAAE,OAAO,UAiDvB;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,UA8BhF"}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleScrollIntoView=handleScrollIntoView,exports.handleSetNativeInputValue=handleSetNativeInputValue,exports.onChangeFormatter=onChangeFormatter,exports.setObserverOptions=setObserverOptions;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}
|
|
1
|
+
"use strict";var _constants=require("./constants");Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleScrollIntoView=handleScrollIntoView,exports.handleSetNativeInputValue=handleSetNativeInputValue,exports.onBlurTimeInputFormatter=onBlurTimeInputFormatter,exports.onChangeFormatter=onChangeFormatter,exports.setObserverOptions=setObserverOptions;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}// Libs
|
|
2
|
+
// Constants
|
|
3
|
+
function handleScrollIntoView(hourContainerRef,minuteContainerRef,inputValue,timePeriodContainerRef){var _hourContainerRef$cur,_minuteContainerRef$c,_inputValue$split=inputValue.split(/:| /),_inputValue$split2=_slicedToArray(_inputValue$split,3),hour=_inputValue$split2[0],minute=_inputValue$split2[1],period=_inputValue$split2[2],targetHourEl=null===(_hourContainerRef$cur=hourContainerRef.current)||void 0===_hourContainerRef$cur?void 0:_hourContainerRef$cur.querySelector("[data-input-hour=\"".concat(null===hour||void 0===hour?void 0:hour.padStart(2,"0"),"\"]")),targetMinuteEl=null===(_minuteContainerRef$c=minuteContainerRef.current)||void 0===_minuteContainerRef$c?void 0:_minuteContainerRef$c.querySelector("[data-input-minute=\"".concat(null===minute||void 0===minute?void 0:minute.padEnd(2,"0"),"\"]"));if((targetHourEl||targetMinuteEl)&&(null===targetHourEl||void 0===targetHourEl?void 0:targetHourEl.scrollIntoView({behavior:"auto",block:"center"}),null===targetMinuteEl||void 0===targetMinuteEl?void 0:targetMinuteEl.scrollIntoView({behavior:"auto",block:"center"})),timePeriodContainerRef&&period){var _timePeriodContainerR,targetTimePeriodEl=null===(_timePeriodContainerR=timePeriodContainerRef.current)||void 0===_timePeriodContainerR?void 0:_timePeriodContainerR.querySelector("[data-input-period=\"".concat(period,"\"]"));targetTimePeriodEl&&targetTimePeriodEl.scrollIntoView({behavior:"auto",block:"center"})}}function handleSetNativeInputValue(timeInputRef,value){var _nativeInputValueSett;if(timeInputRef.current){var nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value");null===nativeInputValueSetter||void 0===nativeInputValueSetter||null===(_nativeInputValueSett=nativeInputValueSetter.set)||void 0===_nativeInputValueSett?void 0:_nativeInputValueSett.call(timeInputRef.current,value);var event=new Event("input",{bubbles:!0});timeInputRef.current.dispatchEvent(event)}}function setObserverOptions(mainContainer){return{root:null===mainContainer||void 0===mainContainer?void 0:mainContainer.current,threshold:1,rootMargin:"-40px"}}function onChangeFormatter(event,isAmPmVariant){return void 0===event.currentTarget.value||":"===event.currentTarget.value?"":isAmPmVariant?(event.currentTarget.value=(event.currentTarget.value+"").replace(/(\d{2})(\d{2})/,function(match,hours,minutes){var formattedHours=hours,formattedMinutes=minutes;return 2===formattedHours.length&&(formattedHours=Math.min(parseInt(formattedHours,10),12).toString().padStart(2,"0")),2===formattedMinutes.length&&(formattedMinutes=Math.min(parseInt(formattedMinutes,10),59).toString().padStart(2,"0")),"".concat(formattedHours,":").concat(formattedMinutes)}).replace(/(:\d{2})\d*$/,function(match){var minutesMatch=match.substring(1),formattedMinutes=Math.min(parseInt(minutesMatch,10),59).toString().padStart(2,"0");return":".concat(formattedMinutes)}).substring(0,11),event.currentTarget.value):(event.currentTarget.value+"").replace(/\D/g,"").replace(/(\d{2})(\d)/,function(match,hours,minutes){var formattedHours=hours;return 2===formattedHours.length&&(formattedHours=Math.min(parseInt(formattedHours,10),23).toString().padStart(2,"0")),"".concat(formattedHours,":").concat(minutes)}).replace(/(:\d{2})\d*$/,function(match){var minutesMatch=match.substring(1),formattedMinutes=Math.min(parseInt(minutesMatch,10),59).toString().padStart(2,"0");return":".concat(formattedMinutes)}).substring(0,5)}function onBlurTimeInputFormatter(event){var value=event.currentTarget.value,sanitizedValue=value.replace(/\D/g,"");if(4===sanitizedValue.length)return value;var numericValue=+sanitizedValue;if(numericValue>_constants.MAX_VALID_TIME)return"23:59";var shouldPadEndWithZero=3===sanitizedValue.length&&numericValue<_constants.MAX_TIME_TO_PAD_END_WITH_ZERO;if(shouldPadEndWithZero){var hours=sanitizedValue.substring(0,2),minutes=+sanitizedValue[2]>=_constants.MAX_MINUTE_FIRST_DIGIT?"59":sanitizedValue.substring(2).padEnd(2,"0");return"".concat(hours,":").concat(minutes)}return numericValue>_constants.MAX_VALID_HOUR?"23:59":1===sanitizedValue.length?"0".concat(value,":00"):2===sanitizedValue.length?"".concat(value,":00"):value}
|