@pedidopago/ui 1.10.5 → 1.10.6
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/Carousel/index.d.ts.map +1 -1
- package/dist/components/Carousel/index.js +1 -1
- package/dist/components/NewSelect/Examples/index.js +1 -1
- package/dist/components/NewSelect/{multiple → Multiple}/Examples/index.d.ts.map +1 -1
- package/dist/components/NewSelect/{multiple → Multiple}/index.d.ts.map +1 -1
- package/dist/components/NewSelect/{single → Single}/Examples/index.d.ts.map +1 -1
- package/dist/components/NewSelect/{single → Single}/index.d.ts.map +1 -1
- package/dist/components/NewSelect/{single → Single}/index.js +1 -1
- package/dist/components/NewSelect/index.js +1 -1
- package/package.json +1 -1
- /package/dist/components/NewSelect/{multiple → Multiple}/Examples/index.d.ts +0 -0
- /package/dist/components/NewSelect/{multiple → Multiple}/Examples/index.js +0 -0
- /package/dist/components/NewSelect/{multiple → Multiple}/index.d.ts +0 -0
- /package/dist/components/NewSelect/{multiple → Multiple}/index.js +0 -0
- /package/dist/components/NewSelect/{single → Single}/Examples/index.d.ts +0 -0
- /package/dist/components/NewSelect/{single → Single}/Examples/index.js +0 -0
- /package/dist/components/NewSelect/{single → Single}/index.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Carousel/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,wBAAgB,QAAQ,CAAC,EACvB,GAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,WAAW,EACX,GAAG,QAAQ,EACZ,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Carousel/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,wBAAgB,QAAQ,CAAC,EACvB,GAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,WAAW,EACX,GAAG,QAAQ,EACZ,EAAE,aAAa,eAuTf"}
|
|
@@ -1 +1 @@
|
|
|
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.Carousel=Carousel;var _react=require("react"),_classnames=_interopRequireDefault(require("classnames")),_Icon=_interopRequireDefault(require("../Icon")),_styles=require("./styles"),_formatters=require("../../utils/formatters"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["gap","hideArrowButtons","children","buttonShadow","leftButton","rightButton"];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 Carousel(_ref){function hideRightButton(hide){rightButtonRef.current&&(hide?rightButtonRef.current.classList.add("hide"):rightButtonRef.current.classList.remove("hide"))}function hideLeftButton(hide){leftButtonRef.current&&(hide?leftButtonRef.current.classList.add("hide"):leftButtonRef.current.classList.remove("hide"))}function beginMomentumTracking(){cancelMomentumTracking(),momentumID=requestAnimationFrame(momentumLoop)}function cancelMomentumTracking(){cancelAnimationFrame(momentumID)}function onMomentumEnd(){if(sliderRef.current){var maxScroll=sliderRef.current.scrollWidth-sliderRef.current.clientWidth,isEndOfScroll=sliderRef.current.scrollLeft>=maxScroll;isMaxScroll.current=isEndOfScroll,hideRightButton(isEndOfScroll),hideLeftButton(0===sliderRef.current.scrollLeft)}}function momentumLoop(){if(sliderRef.current){var _sliderRef$current;sliderRef.current.scrollLeft+=2*velX,velX*=.95;var disableMomentum=isMaxScroll.current||0===(null===(_sliderRef$current=sliderRef.current)||void 0===_sliderRef$current?void 0:_sliderRef$current.scrollLeft);.75<Math.abs(velX)&&!disableMomentum?(hideLeftButton(!0),hideRightButton(!0),momentumID=requestAnimationFrame(momentumLoop)):onMomentumEnd()}}function changeScrollLeft(scrollLeft){sliderRef.current&&sliderRef.current.scrollTo({behavior:"smooth",left:scrollLeft})}function moveLeftItem(){if(sliderRef.current)for(var childs=sliderRef.current.childNodes,sliderWidth=sliderRef.current.offsetWidth,i=0;i<childs.length;i++){var child=childs[i],itemTotalOffset=child.offsetLeft+child.offsetWidth,isPrevVisibleItem=itemTotalOffset>sliderRef.current.scrollLeft;if(isPrevVisibleItem){var prevChild=childs[i-1];if(!prevChild)return void changeScrollLeft(0);var isLargeItem=prevChild.offsetWidth>(0,_formatters.halfDivisor)(sliderWidth);isLargeItem?changeScrollLeft(prevChild.offsetLeft):changeScrollLeft(prevChild.offsetLeft+(0,_formatters.halfDivisor)(prevChild.offsetWidth));break}}}function moveRightItem(){if(sliderRef.current)for(var childs=sliderRef.current.childNodes,sliderWidth=sliderRef.current.offsetWidth,i=1;i<childs.length;i++){var child=childs[i],itemTotalOffset=child.offsetLeft+child.offsetWidth,isNextVisibleItem=itemTotalOffset>sliderRef.current.scrollLeft+sliderWidth;if(isNextVisibleItem){var nextSibling=child.nextSibling||child,nextSiblingWidth=nextSibling.offsetWidth||0,isLargeItem=nextSiblingWidth>(0,_formatters.halfDivisor)(sliderWidth),nextSiblingLeft=(null===nextSibling||void 0===nextSibling?void 0:nextSibling.offsetLeft)||0;if(isLargeItem)return void changeScrollLeft(child.offsetLeft);if(!child.nextSibling)return void changeScrollLeft(nextSiblingLeft+nextSiblingWidth-sliderWidth);changeScrollLeft(nextSiblingLeft+(0,_formatters.halfDivisor)(nextSiblingWidth)-sliderWidth);break}}}var startX,initialScrollLeft,momentumID,_ref$gap=_ref.gap,gap=void 0===_ref$gap?16:_ref$gap,hideArrowButtons=_ref.hideArrowButtons,children=_ref.children,buttonShadow=_ref.buttonShadow,leftButton=_ref.leftButton,rightButton=_ref.rightButton,divProps=_objectWithoutProperties(_ref,_excluded),rightButtonRef=(0,_react.useRef)(null),leftButtonRef=(0,_react.useRef)(null),sliderRef=(0,_react.useRef)(null),isMaxScroll=(0,_react.useRef)(!1),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),itemsHasNoOverflow=_useState2[0],setItemsHasNoOverflow=_useState2[1],isDragging=!1,velX=0,moveCarousel=function moveCarousel(direction){sliderRef.current&&(hideRightButton(!1),hideLeftButton(!1),"left"===direction?moveLeftItem():moveRightItem())};(0,_react.useEffect)(function(){if(sliderRef.current){var _sliderRef$current2,lastChild=null===(_sliderRef$current2=sliderRef.current)||void 0===_sliderRef$current2?void 0:_sliderRef$current2.querySelector(".item-".concat(_react.Children.count(children))),lastChildOffsetLeft=(null===lastChild||void 0===lastChild?void 0:lastChild.offsetLeft)||0,lastChildWidth=(null===lastChild||void 0===lastChild?void 0:lastChild.offsetWidth)||0,hasNoOverflow=lastChildOffsetLeft+lastChildWidth<sliderRef.current.offsetWidth;setItemsHasNoOverflow(hasNoOverflow)}},[sliderRef.current]),(0,_react.useEffect)(function(){sliderRef.current&&hideRightButton(!1)},[sliderRef]);var customLeftButton=null===leftButton||void 0===leftButton?void 0:leftButton(function(){return moveCarousel("left")}),customRightButton=null===rightButton||void 0===rightButton?void 0:rightButton(function(){return moveCarousel("right")});return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",_objectSpread(_objectSpread({style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"}},divProps),{},{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.SliderContainer,{onTouchMove:function onTouchMove(){hideLeftButton(!0),hideRightButton(!0)},onTouchEnd:beginMomentumTracking,className:"slider_container",style:{gap:gap+"px"},ref:sliderRef,onMouseDown:function handleMouseDown(event){isDragging=!0,sliderRef.current&&(startX=event.pageX-sliderRef.current.offsetLeft,initialScrollLeft=sliderRef.current.scrollLeft,cancelMomentumTracking())},onMouseUp:function handleMouseUp(){if(isDragging=!1,sliderRef.current){hideLeftButton(!1),beginMomentumTracking(),hideRightButton(isMaxScroll.current);var isStartOfScroll=0===sliderRef.current.scrollLeft;hideLeftButton(isStartOfScroll)}},onMouseMove:function handleMouseMove(e){if(isDragging&&(e.preventDefault(),sliderRef.current)){hideRightButton(!0),hideLeftButton(!0);var x=e.pageX-sliderRef.current.offsetLeft,walk=x-startX,prevScrollLeft=sliderRef.current.scrollLeft;sliderRef.current.scrollLeft=initialScrollLeft-walk,velX=sliderRef.current.scrollLeft-prevScrollLeft}},onWheel:function handleWheel(){cancelMomentumTracking()},onScroll:function handleScroll(event){var element=event.currentTarget,maxScroll=element.scrollWidth-element.clientWidth,isEndOfScroll=element.scrollLeft>=maxScroll;isMaxScroll.current=!1,isEndOfScroll?(isMaxScroll.current=!0,hideRightButton(!0)):0===element.scrollLeft&&hideLeftButton(!0)},onMouseLeave:function handleMouseLeave(){isDragging=!1},children:_react.Children.map(children,function(child,index){var childElement=child;return/*#__PURE__*/(0,_react.cloneElement)(childElement,_objectSpread(_objectSpread({},child.props),{},{className:"item-".concat(index+1," carousel_item ").concat(child.props.className||"")}))})}),!hideArrowButtons&&/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.ContainerButton,{className:(0,_classnames.default)("left_button hide",{button_shadow:buttonShadow,hide:itemsHasNoOverflow}),ref:leftButtonRef,children:customLeftButton||/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DefaultButton,{onClick:function onClick(){return moveCarousel("left")},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-left",color:"neutral.neutral6",size:"18px"})})}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.ContainerButton,{className:(0,_classnames.default)("right_button",{button_shadow:buttonShadow,hide:itemsHasNoOverflow}),ref:rightButtonRef,children:customRightButton||/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DefaultButton,{onClick:function onClick(){return moveCarousel("right")},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-right",color:"neutral.neutral6",size:"18px"})})})]})]}))}
|
|
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.Carousel=Carousel;var _react=require("react"),_classnames=_interopRequireDefault(require("classnames")),_Icon=_interopRequireDefault(require("../Icon")),_styles=require("./styles"),_formatters=require("../../utils/formatters"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["gap","hideArrowButtons","children","buttonShadow","leftButton","rightButton"];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 Carousel(_ref){function hideRightButton(hide){rightButtonRef.current&&(hide?rightButtonRef.current.classList.add("hide"):rightButtonRef.current.classList.remove("hide"))}function hideLeftButton(hide){leftButtonRef.current&&(hide?leftButtonRef.current.classList.add("hide"):leftButtonRef.current.classList.remove("hide"))}function beginMomentumTracking(){cancelMomentumTracking(),momentumID=requestAnimationFrame(momentumLoop)}function cancelMomentumTracking(){cancelAnimationFrame(momentumID)}function handleHideButtons(){if(sliderRef.current){var maxScroll=sliderRef.current.scrollWidth-sliderRef.current.clientWidth,isEndOfScroll=sliderRef.current.scrollLeft>=maxScroll;isMaxScroll.current=isEndOfScroll,hideRightButton(isEndOfScroll),hideLeftButton(0===sliderRef.current.scrollLeft)}}function onMomentumEnd(){handleHideButtons()}function momentumLoop(){if(sliderRef.current){var _sliderRef$current;sliderRef.current.scrollLeft+=2*velX,velX*=.95;var disableMomentum=isMaxScroll.current||0===(null===(_sliderRef$current=sliderRef.current)||void 0===_sliderRef$current?void 0:_sliderRef$current.scrollLeft);.75<Math.abs(velX)&&!disableMomentum?(hideLeftButton(!0),hideRightButton(!0),momentumID=requestAnimationFrame(momentumLoop)):onMomentumEnd()}}function changeScrollLeft(scrollLeft){sliderRef.current&&sliderRef.current.scrollTo({behavior:"smooth",left:scrollLeft})}function moveLeftItem(){if(sliderRef.current)for(var childs=sliderRef.current.childNodes,sliderWidth=sliderRef.current.offsetWidth,i=0;i<childs.length;i++){var child=childs[i],itemTotalOffset=child.offsetLeft+child.offsetWidth,isPrevVisibleItem=itemTotalOffset>sliderRef.current.scrollLeft;if(isPrevVisibleItem){var prevChild=childs[i-1];if(!prevChild)return void changeScrollLeft(0);var isLargeItem=prevChild.offsetWidth>(0,_formatters.halfDivisor)(sliderWidth);isLargeItem?changeScrollLeft(prevChild.offsetLeft):changeScrollLeft(prevChild.offsetLeft+(0,_formatters.halfDivisor)(prevChild.offsetWidth));break}}}function moveRightItem(){if(sliderRef.current)for(var childs=sliderRef.current.childNodes,sliderWidth=sliderRef.current.offsetWidth,i=1;i<childs.length;i++){var child=childs[i],itemTotalOffset=child.offsetLeft+child.offsetWidth,isNextVisibleItem=itemTotalOffset>sliderRef.current.scrollLeft+sliderWidth;if(isNextVisibleItem){var nextSibling=child.nextSibling||child,nextSiblingWidth=nextSibling.offsetWidth||0,isLargeItem=nextSiblingWidth>(0,_formatters.halfDivisor)(sliderWidth),nextSiblingLeft=(null===nextSibling||void 0===nextSibling?void 0:nextSibling.offsetLeft)||0;if(isLargeItem)return void changeScrollLeft(child.offsetLeft);if(!child.nextSibling)return void changeScrollLeft(nextSiblingLeft+nextSiblingWidth-sliderWidth);changeScrollLeft(nextSiblingLeft+(0,_formatters.halfDivisor)(nextSiblingWidth)-sliderWidth);break}}}var startX,initialScrollLeft,momentumID,_ref$gap=_ref.gap,gap=void 0===_ref$gap?16:_ref$gap,hideArrowButtons=_ref.hideArrowButtons,children=_ref.children,buttonShadow=_ref.buttonShadow,leftButton=_ref.leftButton,rightButton=_ref.rightButton,divProps=_objectWithoutProperties(_ref,_excluded),rightButtonRef=(0,_react.useRef)(null),leftButtonRef=(0,_react.useRef)(null),sliderRef=(0,_react.useRef)(null),isMaxScroll=(0,_react.useRef)(!1),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),itemsHasNoOverflow=_useState2[0],setItemsHasNoOverflow=_useState2[1],isDragging=!1,velX=0,moveCarousel=function moveCarousel(direction){sliderRef.current&&(hideRightButton(!1),hideLeftButton(!1),"left"===direction?moveLeftItem():moveRightItem())};(0,_react.useEffect)(function(){if(sliderRef.current){var _sliderRef$current2,lastChild=null===(_sliderRef$current2=sliderRef.current)||void 0===_sliderRef$current2?void 0:_sliderRef$current2.querySelector(".item-".concat(_react.Children.count(children))),lastChildOffsetLeft=(null===lastChild||void 0===lastChild?void 0:lastChild.offsetLeft)||0,lastChildWidth=(null===lastChild||void 0===lastChild?void 0:lastChild.offsetWidth)||0,hasNoOverflow=lastChildOffsetLeft+lastChildWidth<sliderRef.current.offsetWidth;setItemsHasNoOverflow(hasNoOverflow)}},[sliderRef.current]),(0,_react.useEffect)(function(){sliderRef.current&&hideRightButton(!1)},[sliderRef]);var customLeftButton=null===leftButton||void 0===leftButton?void 0:leftButton(function(){return moveCarousel("left")}),customRightButton=null===rightButton||void 0===rightButton?void 0:rightButton(function(){return moveCarousel("right")});return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",_objectSpread(_objectSpread({style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"}},divProps),{},{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.SliderContainer,{onTouchMove:function onTouchMove(){hideLeftButton(!0),hideRightButton(!0)},onTouchEnd:beginMomentumTracking,className:"slider_container",style:{gap:gap+"px"},ref:sliderRef,onMouseDown:function handleMouseDown(event){isDragging=!0,sliderRef.current&&(startX=event.pageX-sliderRef.current.offsetLeft,initialScrollLeft=sliderRef.current.scrollLeft,cancelMomentumTracking())},onMouseUp:function handleMouseUp(){if(isDragging=!1,sliderRef.current){hideLeftButton(!1),beginMomentumTracking(),hideRightButton(isMaxScroll.current);var isStartOfScroll=0===sliderRef.current.scrollLeft;hideLeftButton(isStartOfScroll)}},onMouseMove:function handleMouseMove(e){if(isDragging&&(e.preventDefault(),sliderRef.current)){hideRightButton(!0),hideLeftButton(!0);var x=e.pageX-sliderRef.current.offsetLeft,walk=x-startX,prevScrollLeft=sliderRef.current.scrollLeft;sliderRef.current.scrollLeft=initialScrollLeft-walk,velX=sliderRef.current.scrollLeft-prevScrollLeft}},onWheel:function handleWheel(){cancelMomentumTracking()},onScroll:function handleScroll(event){var element=event.currentTarget,maxScroll=element.scrollWidth-element.clientWidth,isEndOfScroll=element.scrollLeft>=maxScroll;isMaxScroll.current=!1,isEndOfScroll?(isMaxScroll.current=!0,hideRightButton(!0)):0===element.scrollLeft&&hideLeftButton(!0)},onMouseLeave:function handleMouseLeave(){isDragging=!1,handleHideButtons()},children:_react.Children.map(children,function(child,index){var childElement=child;return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"item-".concat(index+1," carousel_item"),children:childElement})})}),!hideArrowButtons&&/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.ContainerButton,{className:(0,_classnames.default)("left_button hide",{button_shadow:buttonShadow,hide:itemsHasNoOverflow}),ref:leftButtonRef,children:customLeftButton||/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DefaultButton,{onClick:function onClick(){return moveCarousel("left")},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-left",color:"neutral.neutral6",size:"18px"})})}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.ContainerButton,{className:(0,_classnames.default)("right_button",{button_shadow:buttonShadow,hide:itemsHasNoOverflow}),ref:rightButtonRef,children:customRightButton||/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.DefaultButton,{onClick:function onClick(){return moveCarousel("right")},children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-right",color:"neutral.neutral6",size:"18px"})})})]})]}))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WithBooleanOptions=WithBooleanOptions,exports.WithCustomRender=WithCustomRender,exports.WithDefaultValue=WithDefaultValue,exports.WithInputSearch=WithInputSearch,exports.WithNumberOptions=WithNumberOptions;var _Flex=_interopRequireDefault(require("../../../components/Flex")),_Typography=_interopRequireDefault(require("../../Typography")),_Examples=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WithBooleanOptions=WithBooleanOptions,exports.WithCustomRender=WithCustomRender,exports.WithDefaultValue=WithDefaultValue,exports.WithInputSearch=WithInputSearch,exports.WithNumberOptions=WithNumberOptions;var _Flex=_interopRequireDefault(require("../../../components/Flex")),_Typography=_interopRequireDefault(require("../../Typography")),_Examples=require("../Multiple/Examples"),_Examples2=require("../Single/Examples"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function WithDefaultValue(){return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"2.5rem",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral3",fontSize:"lg",fontWeight:"600",children:"Com loading e valor default"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples.MultipleWithDefaultValue,{}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples2.SingleWithDefaultValue,{})]})}function WithCustomRender(){return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"2.5rem",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral3",fontSize:"lg",fontWeight:"600",children:"Com exibi\xE7\xE3o de op\xE7\xE3o selecionada customizado"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples.MultipleWithChip,{}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples2.SingleWithChip,{})]})}function WithNumberOptions(){return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"2.5rem",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral3",fontSize:"lg",fontWeight:"600",children:"Com valores num\xE9ricos"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples.MultipleNumberOptions,{}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples2.SingleNumberOptions,{})]})}function WithInputSearch(){return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"2.5rem",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral3",fontSize:"lg",fontWeight:"600",children:"Com input de pesquisa"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples.MultipleSearchInput,{}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples2.SingleSearchInput,{})]})}function WithBooleanOptions(){return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"2.5rem",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral3",fontSize:"lg",fontWeight:"600",children:"Com valores boleanos"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples.MultipleBooleanOptions,{}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Examples2.SingleBooleanOptions,{})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/NewSelect/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/NewSelect/Multiple/Examples/index.tsx"],"names":[],"mappings":";AAYA,wBAAgB,wBAAwB,gBA4CvC;AAED,wBAAgB,gBAAgB,gBA6C/B;AACD,wBAAgB,mBAAmB,gBAkClC;AAED,wBAAgB,qBAAqB,gBA0BpC;AAED,wBAAgB,sBAAsB,gBAuBrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/NewSelect/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/NewSelect/Multiple/index.tsx"],"names":[],"mappings":";AAqBA,OAAO,EAAgB,yBAAyB,EAAe,MAAM,UAAU,CAAC;AAGhF,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,GAAG,IAAI,EACR,EAAE,yBAAyB,CAAC,CAAC,CAAC,eAoM9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/NewSelect/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/NewSelect/Single/Examples/index.tsx"],"names":[],"mappings":";AAYA,wBAAgB,sBAAsB,gBAsCrC;AAED,wBAAgB,cAAc,gBA+C7B;AACD,wBAAgB,iBAAiB,gBAiChC;AAED,wBAAgB,mBAAmB,gBAuBlC;AAED,wBAAgB,oBAAoB,gBAoBnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/NewSelect/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/NewSelect/Single/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,EAAgB,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEjE,wBAAgB,eAAe,CAAC,CAAC,EAAE,EACjC,KAAU,EACV,WAAgB,EAChB,KAAK,EACL,UAAU,EACV,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,aAAa,EACb,sBAAsB,EACtB,GAAG,IAAI,EACR,EAAE,uBAAuB,CAAC,CAAC,CAAC,eAuI5B"}
|
|
@@ -1 +1 @@
|
|
|
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.NewSingleSelect=NewSingleSelect;var _react=require("react"),_Flex=_interopRequireDefault(require("../../Flex")),_Icon=_interopRequireDefault(require("../../Icon")),_ReactPortal=require("../../ReactPortal"),_SelectItem=require("../components/SelectItem"),_useReposition=require("../../../shared/hooks/useReposition"),_useOnClickOutside=require("../../../shared/hooks/useOnClickOutside"),_utils=require("../utils.ts"),_styles=require("../components/OptionsSelect/styles"),_styles2=require("../styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","variant","children","value","onClose","onOpen","onChange","renderOptions","optionsContainerStyles"];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 NewSingleSelect(_ref){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,onChange=_ref.onChange,renderOptions=_ref.renderOptions,optionsContainerStyles=_ref.optionsContainerStyles,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),selectedOption=_useState4[0],setSelectedOption=_useState4[1],optionsModalRef=(0,_react.useRef)(null),textPlaceholder=selectedOption?null===selectedOption||void 0===selectedOption?void 0:selectedOption.label:placeholder;(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]);return(0,_react.useEffect)(function(){value||setSelectedOption(void 0)},[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":!!textPlaceholder||!!placeholder,alert:alert,tabIndex:rest.disabled?-1:0,onClick:function onClick(){return setIsOpenOptions(!isOpenOptions)},className:rest.className,style:rest.style,ref:containerRef,children:[label&&"unstyled"!==variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)("label",{children:label}),"function"==typeof renderOptions&&selectedOption?/*#__PURE__*/(0,_jsxRuntime.jsx)(function SelectedOptionsWithCustomComponent(){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:null===renderOptions||void 0===renderOptions?void 0:renderOptions(null===selectedOption||void 0===selectedOption?void 0:selectedOption.value)})},{},"custom-option-selected-".concat(textPlaceholder)):/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.SelectedOptionSpan,{hasSelectedOption:!!selectedOption,children:textPlaceholder}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{className:"select_container_icon",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-down",color:"neutral.neutral5"})})]}),/*#__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)(_jsxRuntime.Fragment,{children:child});var _selectItemUtils=(0,_utils.selectItemUtils)(),getSelectItemInfos=_selectItemUtils.getSelectItemInfos,childElement=child;return/*#__PURE__*/(0,_react.cloneElement)(childElement,{ref:function ref(node){if(node){var _getSelectItemInfos=getSelectItemInfos(node),selectItemValue=_getSelectItemInfos.selectItemValue;selectItemValue===value&&(null===selectedOption||void 0===selectedOption?void 0:selectedOption.value)!==selectItemValue&&setSelectedOption({label:node.innerText,value:selectItemValue})}},onClick:function onClick(event){var _childElement$props,_childElement$props$o;if(null===(_childElement$props=childElement.props)||void 0===_childElement$props||null===(_childElement$props$o=_childElement$props.onClick)||void 0===_childElement$props$o?void 0:_childElement$props$o.call(_childElement$props,event),event.currentTarget.classList.contains("select-item")){setIsOpenOptions(!1),null===onChange||void 0===onChange?void 0:onChange(childElement.props.value);var _getSelectItemInfos2=getSelectItemInfos(),selectItemNode=_getSelectItemInfos2.selectItemNode;setSelectedOption({label:(null===selectItemNode||void 0===selectItemNode?void 0:selectItemNode.innerText)||"",value:childElement.props.value})}}})})})}),!!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.NewSingleSelect=NewSingleSelect;var _react=require("react"),_Flex=_interopRequireDefault(require("../../Flex")),_Icon=_interopRequireDefault(require("../../Icon")),_ReactPortal=require("../../ReactPortal"),_SelectItem=require("../components/SelectItem"),_useReposition=require("../../../shared/hooks/useReposition"),_useOnClickOutside=require("../../../shared/hooks/useOnClickOutside"),_utils=require("../utils.ts"),_styles=require("../components/OptionsSelect/styles"),_styles2=require("../styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","variant","children","value","onClose","onOpen","onChange","renderOptions","optionsContainerStyles"];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 NewSingleSelect(_ref){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,onChange=_ref.onChange,renderOptions=_ref.renderOptions,optionsContainerStyles=_ref.optionsContainerStyles,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),selectedOption=_useState4[0],setSelectedOption=_useState4[1],optionsModalRef=(0,_react.useRef)(null),textPlaceholder=selectedOption?null===selectedOption||void 0===selectedOption?void 0:selectedOption.label:placeholder;(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]);return(0,_react.useEffect)(function(){value||setSelectedOption(void 0)},[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":!!textPlaceholder||!!placeholder,alert:alert,tabIndex:rest.disabled?-1:0,onClick:function onClick(){return setIsOpenOptions(!isOpenOptions)},className:rest.className,style:rest.style,ref:containerRef,children:[label&&"unstyled"!==variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)("label",{children:label}),"function"==typeof renderOptions&&selectedOption?/*#__PURE__*/(0,_jsxRuntime.jsx)(function SelectedOptionsWithCustomComponent(){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:null===renderOptions||void 0===renderOptions?void 0:renderOptions(null===selectedOption||void 0===selectedOption?void 0:selectedOption.value)})},{},"custom-option-selected-".concat(textPlaceholder)):/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.SelectedOptionSpan,{hasSelectedOption:!!selectedOption,children:textPlaceholder}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{className:"select_container_icon",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-down",color:"neutral.neutral5"})})]}),/*#__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)(_jsxRuntime.Fragment,{children:child});var _selectItemUtils=(0,_utils.selectItemUtils)(),getSelectItemInfos=_selectItemUtils.getSelectItemInfos,childElement=child;return/*#__PURE__*/(0,_react.cloneElement)(childElement,{ref:function ref(node){if(node){var _getSelectItemInfos=getSelectItemInfos(node),selectItemValue=_getSelectItemInfos.selectItemValue;selectItemValue===value&&(null===selectedOption||void 0===selectedOption?void 0:selectedOption.value)!==selectItemValue&&setSelectedOption({label:node.innerText,value:selectItemValue})}},onClick:function onClick(event){var _childElement$props,_childElement$props$o;if(null===(_childElement$props=childElement.props)||void 0===_childElement$props||null===(_childElement$props$o=_childElement$props.onClick)||void 0===_childElement$props$o?void 0:_childElement$props$o.call(_childElement$props,event),event.currentTarget.classList.contains("select-item")){setIsOpenOptions(!1),null===onChange||void 0===onChange?void 0:onChange(childElement.props.value);var _getSelectItemInfos2=getSelectItemInfos(),selectItemNode=_getSelectItemInfos2.selectItemNode;void 0!==childElement.props.value&&setSelectedOption({label:(null===selectItemNode||void 0===selectItemNode?void 0:selectItemNode.innerText)||"",value:childElement.props.value})}}})})})}),!!helperText&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.HelperText,{alert:alert,children:helperText})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewSelect=NewSelect;var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewSelect=NewSelect;var _Multiple=require("./Multiple"),_Single=require("./Single"),_jsxRuntime=require("react/jsx-runtime");function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)source=null==arguments[i]?{}:arguments[i],i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))});return target}function _defineProperty(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return"symbol"===_typeof(key)?key:key+""}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===hint?String:Number)(input)}function NewSelect(props){return props.multiple?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Multiple.NewMultipleSelect,_objectSpread({},props)):/*#__PURE__*/(0,_jsxRuntime.jsx)(_Single.NewSingleSelect,_objectSpread({},props))}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|