tailwindui-mza
Version:
A package for some base ui component ( **not have ui just logic** ).
3 lines (2 loc) • 2.14 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-transition-group"),a=require("date-fns-jalali");function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var o=[1,2,3,4,5,6,7,8,9,10,11,12];exports.Collapse=function(e){var a,o,u=e.duration,s=void 0===u?500:u,l=t.useRef(null),f=t.useRef(null),h={transition:"height "+s+"ms",height:0,overflow:"hidden"},c={entering:{height:(null==(a=f.current)?void 0:a.clientHeight)||0},entered:{height:(null==(o=f.current)?void 0:o.clientHeight)||0},exiting:{height:0},exited:{height:0},unmounted:{}};return n.createElement(r.Transition,{nodeRef:l,in:e.in,timeout:s},(function(t){return n.createElement("div",{ref:l,style:i({},h,c[t])},n.createElement("div",{ref:f},e.children))}))},exports.useCalenderJalali=function(e){void 0===e&&(e={});var n=e.defaultDate,r=e.yearsOptions,i=t.useState(n||new Date),u=i[0],s=i[1],l=t.useState(n?a.getYear(n):""),f=l[0],h=l[1],c=t.useMemo((function(){return a.getDaysInMonth(a.newDate(a.getYear(u),a.getMonth(u),1))}),[u]),g=t.useMemo((function(){return a.eachYearOfInterval(r&&r&&r.from<r.to?{start:a.newDate(r.from,1,6),end:a.newDate(r.to,1,6)}:{start:a.newDate(1300,1,6),end:a.newDate(1500,1,6)}).map((function(e){return+a.format(e,"yyyy")}))}),[r]),d=t.useMemo((function(){return a.eachDayOfInterval({start:a.newDate(a.getYear(u),a.getMonth(u),1),end:a.newDate(a.getYear(u),a.getMonth(u),c)})}),[u,c]);return{activeDate:u,yearsList:g,monthList:o,dayList:d,yearValue:f,onChangeYear:function(e){if(!(e.toString().length>4||e===f||isNaN(e)||"number"!=typeof e))if(4!==e.toString().length)h(e||"");else{var t=!r||r.from<=e&&r.to>=e;if(a.isExists(e,5,5)&&t){var n=a.setYear(u,e);s(n),h(e)}else h("")}},onChangeMonth:function(e){if(0<e&&e<=12){var t=a.setMonth(u,e-1);s(t)}},onChangeDay:function(e){a.isDate(e)&&s(e)}}};
//# sourceMappingURL=tailwindui-mza.cjs.production.min.js.map
;