@instincthub/react-ui 0.1.58 → 0.1.59
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/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addYears.js +2 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addYears.js.map +1 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subYears.js +2 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subYears.js.map +1 -0
- package/dist/src/assets/css/ui/dropdown-styles.css +23 -0
- package/dist/src/components/forms/DateRangePicker.js +1 -1
- package/dist/src/components/ui/Dropdown.js +1 -1
- package/dist/src/types/components/ui/Dropdown.d.ts +0 -57
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addYears.js","sources":["../../../../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addYears.js"],"sourcesContent":["import { addMonths } from \"./addMonths.js\";\n\n/**\n * The {@link addYears} function options.\n */\n\n/**\n * @name addYears\n * @category Year Helpers\n * @summary Add the specified number of years to the given date.\n *\n * @description\n * Add the specified number of years to the given date.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n * @typeParam ResultDate - The result `Date` type.\n *\n * @param date - The date to be changed\n * @param amount - The amount of years to be added.\n * @param options - The options\n *\n * @returns The new date with the years added\n *\n * @example\n * // Add 5 years to 1 September 2014:\n * const result = addYears(new Date(2014, 8, 1), 5)\n * //=> Sun Sep 01 2019 00:00:00\n */\nexport function addYears(date, amount, options) {\n return addMonths(date, amount * 12, options);\n}\n\n// Fallback for modularized imports:\nexport default addYears;\n"],"names":["addYears","date","amount","options","addMonths"],"mappings":"2CA4BO,SAASA,EAASC,EAAMC,EAAQC,GACrC,OAAOC,EAAUH,EAAe,GAATC,EAAaC,EACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subYears.js","sources":["../../../../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subYears.js"],"sourcesContent":["import { addYears } from \"./addYears.js\";\n\n/**\n * The {@link subYears} function options.\n */\n\n/**\n * @name subYears\n * @category Year Helpers\n * @summary Subtract the specified number of years from the given date.\n *\n * @description\n * Subtract the specified number of years from the given date.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The date to be changed\n * @param amount - The amount of years to be subtracted.\n * @param options - An object with options\n *\n * @returns The new date with the years subtracted\n *\n * @example\n * // Subtract 5 years from 1 September 2014:\n * const result = subYears(new Date(2014, 8, 1), 5)\n * //=> Tue Sep 01 2009 00:00:00\n */\nexport function subYears(date, amount, options) {\n return addYears(date, -amount, options);\n}\n\n// Fallback for modularized imports:\nexport default subYears;\n"],"names":["subYears","date","amount","options","addYears"],"mappings":"yCA4BO,SAASA,EAASC,EAAMC,EAAQC,GACrC,OAAOC,EAASH,GAAOC,EAAQC,EACjC"}
|
|
@@ -88,6 +88,26 @@
|
|
|
88
88
|
left: 0;
|
|
89
89
|
right: auto;
|
|
90
90
|
z-index: 1200;
|
|
91
|
+
/*
|
|
92
|
+
* The menu's max-height is set inline from the space the trigger actually
|
|
93
|
+
* has. Laying it out as a column lets the search box keep its natural height
|
|
94
|
+
* and hands the remainder to the options list, which then scrolls. Without
|
|
95
|
+
* this the list kept its own flat 250px and the menu's `overflow: hidden`
|
|
96
|
+
* clipped whatever the search box pushed past the bottom, with no way to
|
|
97
|
+
* reach it.
|
|
98
|
+
*/
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.ihub-dropdown-menu-portal .ihub-dropdown-search {
|
|
104
|
+
flex: 0 0 auto;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.ihub-dropdown-menu-portal .ihub-dropdown-options {
|
|
108
|
+
flex: 1 1 auto;
|
|
109
|
+
max-height: none;
|
|
110
|
+
min-height: 0;
|
|
91
111
|
}
|
|
92
112
|
|
|
93
113
|
@keyframes ihub-dropdown-appear {
|
|
@@ -126,6 +146,9 @@
|
|
|
126
146
|
.ihub-dropdown-options {
|
|
127
147
|
max-height: 250px;
|
|
128
148
|
overflow-y: auto;
|
|
149
|
+
/* Do not chain to the page at the ends of the list: that would scroll the
|
|
150
|
+
trigger out from under the menu the user is still reading. */
|
|
151
|
+
overscroll-behavior: contain;
|
|
129
152
|
}
|
|
130
153
|
|
|
131
154
|
.ihub-dropdown-option {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as t}from"react/jsx-runtime";import a from"@mui/icons-material/CalendarMonthOutlined";import r,{useState as d,useRef as i,useMemo as o,useEffect as l,useCallback as u}from"react";import{endOfWeek as s}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfWeek.js";import{startOfWeek as c}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfWeek.js";import{endOfMonth as m}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfMonth.js";import{subDays as f}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subDays.js";import{formatDate as p}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/format.js";import{startOfDay as h}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfDay.js";import{isBefore as b}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isBefore.js";import{isAfter as v}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isAfter.js";import{startOfMonth as y}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfMonth.js";import{getDay as D}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDay.js";import{getDaysInMonth as N}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDaysInMonth.js";import{isSameDay as M}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isSameDay.js";import{isValid as _}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isValid.js";import{subMonths as g}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subMonths.js";import{addMonths as k}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addMonths.js";var w=function(e){if(!e)return null;var n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(n){var t=Number(n[1]),a=Number(n[2])-1,r=Number(n[3]),d=new Date(t,a,r);return d.getFullYear()!==t||d.getMonth()!==a||d.getDate()!==r?null:_(d)?d:null}var i=new Date(e);return _(i)?h(i):null},j=function(_){var j=_.label,C=_.startLabel,O=void 0===C?"From":C,T=_.endLabel,x=void 0===T?"To":T,L=_.value,F=_.onChange,P=_.required,E=void 0!==P&&P,S=_.minDate,A=_.maxDate,W=_.disabledDates,B=void 0===W?[]:W,I=_.dateFormat,K=void 0===I?"yyyy-MM-dd":I,q=_.placeholder,Y=_.errorMessage,H=_.className,Q=void 0===H?"":H,V=_.name,z=_.id,G=_.disabled,J=void 0!==G&&G,R=_.showCalendarIcon,U=void 0===R||R,X=_.showQuickActions,Z=void 0===X||X,$=_.ariaLabel,ee=d(w(null==L?void 0:L.startDate)),ne=e(ee,2),te=ne[0],ae=ne[1],re=d(w(null==L?void 0:L.endDate)),de=e(re,2),ie=de[0],oe=de[1],le=d(null),ue=e(le,2),se=ue[0],ce=ue[1],me=d(!1),fe=e(me,2),pe=fe[0],he=fe[1],be=d(w(null==L?void 0:L.startDate)||new Date),ve=e(be,2),ye=ve[0],De=ve[1],Ne=d("start"),Me=e(Ne,2),_e=Me[0],ge=Me[1],ke=d(null),we=e(ke,2),je=we[0],Ce=we[1],Oe=d(null),Te=e(Oe,2),xe=Te[0],Le=Te[1],Fe=d(null),Pe=e(Fe,2),Ee=Pe[0],Se=Pe[1],Ae=Y||Ee,We=i(null),Be=i(null),Ie=i(null),Ke=i(null),qe=r.useId(),Ye=z||"ihub-daterange-".concat(qe),He="".concat(Ye,"-error"),Qe=Ye,Ve="".concat(Ye,"-end"),ze=o(function(){return w(S)},[S]),Ge=o(function(){return w(A)},[A]);l(function(){if(L){var e=w(L.startDate);ae(e),oe(w(L.endDate)),ce(null),e&&!pe&&De(e)}},[null==L?void 0:L.startDate,null==L?void 0:L.endDate]),l(function(){Y&&Se(null)},[Y]);var Je=u(function(){ce(null),Ce(null),ge("start"),he(!1),Le(null)},[]);l(function(){var e=function(e){Be.current&&!Be.current.contains(e.target)&&Je()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[Je]);var Re=u(function(e){var n=p(e,"yyyy-MM-dd");return B.includes(n)},[B]),Ue=u(function(e){var n=h(e);return(!ze||!b(n,ze))&&(!Ge||!v(n,Ge))},[ze,Ge]),Xe=u(function(e){var n=h(e);return ze&&b(n,ze)&&(n=ze),Ge&&v(n,Ge)&&(n=Ge),ze&&b(n,ze)?null:n},[ze,Ge]),Ze=u(function(e){if(!e)return"";try{return p(e,K)}catch(e){return""}},[K]),$e=u(function(e,n){null==F||F({startDate:e?p(e,"yyyy-MM-dd"):"",endDate:n?p(n,"yyyy-MM-dd"):""})},[F]),en=o(function(){for(var e=ye.getFullYear(),n=ye.getMonth(),t=y(ye),a=D(t),r=N(ye),d=[],i=0;i<a;i++)d.push(null);for(var o=1;o<=r;o++)d.push(new Date(e,n,o));return d},[ye]),nn=function(e,n){var t=Xe(e),a=Xe(n);t&&a&&!v(t,a)?Re(t)||Re(a)?Se("That preset starts or ends on an unavailable date."):(ae(t),oe(a),ce(null),Ce(null),ge("start"),Se(null),De(t),$e(t,a),he(!1),Le(null)):Se("That preset falls outside the allowed date range.")},tn=function(e){if(!J){if(he(!0),Le(e),"start"===e)return ce(null),ge("start"),void(te&&De(te));te&&!ie?(ce(te),ge("end")):(ce(null),ge("start")),ie?De(ie):te&&De(te)}},an=function(e,n){"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),tn(n))},rn=Ze(null!=se?se:te),dn=se?"":Ze(ie);return n("div",{ref:Be,className:"ihub-daterange-picker-wrapper ".concat(Q),onKeyDown:function(e){var n,t;if("Escape"===e.key&&pe){e.stopPropagation();var a=xe;Je(),"end"===a?null===(n=Ke.current)||void 0===n||n.focus():null===(t=Ie.current)||void 0===t||t.focus()}},children:[j&&n("label",{className:"ihub-datetime-label",htmlFor:Qe,children:[j,E&&t("span",{className:"ihub-required",children:"*"})]}),n("div",{className:"ihub-daterange-inputs",children:[n("div",{className:"ihub-daterange-input-container ".concat("start"===xe?"active":""),onClick:function(){return tn("start")},children:[t("input",{ref:Ie,id:Qe,type:"text",className:"ihub-datetime-input",value:rn,readOnly:!0,placeholder:(null==q?void 0:q.start)||O,disabled:J,onKeyDown:function(e){return an(e,"start")},"aria-label":$?"".concat($," start date"):"".concat(O),"aria-invalid":!!Ae||void 0,"aria-describedby":Ae?He:void 0}),U&&t("div",{className:"ihub-datetime-icons",children:t("button",{type:"button",className:"ihub-datetime-icon-btn",disabled:J,"aria-label":"Open calendar for start date","aria-expanded":pe&&"start"===xe,onClick:function(e){e.stopPropagation(),tn("start")},children:t(a,{})})})]}),t("span",{className:"ihub-daterange-separator-arrow","aria-hidden":"true",children:"→"}),n("div",{className:"ihub-daterange-input-container ".concat("end"===xe?"active":""),onClick:function(){return tn("end")},children:[t("input",{ref:Ke,id:Ve,type:"text",className:"ihub-datetime-input",value:dn,readOnly:!0,placeholder:(null==q?void 0:q.end)||x,disabled:J,onKeyDown:function(e){return an(e,"end")},"aria-label":$?"".concat($," end date"):"".concat(x),"aria-invalid":!!Ae||void 0,"aria-describedby":Ae?He:void 0}),U&&t("div",{className:"ihub-datetime-icons",children:t("button",{type:"button",className:"ihub-datetime-icon-btn",disabled:J,"aria-label":"Open calendar for end date","aria-expanded":pe&&"end"===xe,onClick:function(e){e.stopPropagation(),tn("end")},children:t(a,{})})})]})]}),Ae&&t("div",{className:"ihub-datetime-error",id:He,role:"alert",children:Ae}),pe&&!J&&n("div",{ref:We,className:"ihub-datetime-picker-dropdown",role:"dialog","aria-label":"Date range picker",children:[t("div",{className:"ihub-daterange-phase-indicator",children:"start"===_e?"Select start date":"Select end date"}),n("div",{className:"ihub-datetime-calendar",children:[n("div",{className:"ihub-datetime-month-nav",children:[t("button",{type:"button",onClick:function(){return De(g(ye,1))},className:"ihub-datetime-nav-btn","aria-label":"Previous month",children:"‹"}),t("span",{className:"ihub-datetime-month-year","aria-live":"polite",children:p(ye,"MMMM yyyy")}),t("button",{type:"button",onClick:function(){return De(k(ye,1))},className:"ihub-datetime-nav-btn","aria-label":"Next month",children:"›"})]}),t("div",{className:"ihub-datetime-weekdays",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(function(e){return t("div",{className:"ihub-datetime-weekday",children:e},e)})}),t("div",{className:"ihub-datetime-days",children:en.map(function(e,n){if(!e)return t("div",{className:"ihub-datetime-day-empty"},"empty-".concat(n));var a=Boolean(se&&M(e,se)||!se&&(te&&M(e,te)||ie&&M(e,ie))),r=M(e,new Date),d=Re(e)||!Ue(e),i=function(e){var n=null!=se?se:te;if(!n)return"";var t=se?je:ie,a=n,r=null!=t?t:n;if(b(r,a)){var d=[r,a];a=d[0],r=d[1]}var i=[];return M(e,a)&&i.push("range-start"),t&&M(e,r)&&i.push("range-end"),t&&v(e,a)&&b(e,r)&&!M(e,a)&&!M(e,r)&&i.push("in-range"),i.join(" ")}(e);return t("button",{type:"button",className:"ihub-datetime-day ".concat(a?"selected":""," ").concat(r?"today":""," ").concat(d?"disabled":""," ").concat(i),onClick:function(){return function(e){if(!Re(e)&&Ue(e)){if("start"===_e||!se)return ce(e),ge("end"),Le("end"),void Se(null);var n=se,t=e;if(b(t,n)){var a=[t,n];n=a[0],t=a[1]}ae(n),oe(t),ce(null),Ce(null),ge("start"),Se(null),$e(n,t),he(!1),Le(null)}}(e)},onMouseEnter:function(){se&&Ce(e)},onMouseLeave:function(){return Ce(null)},onFocus:function(){se&&Ce(e)},disabled:d,"aria-label":p(e,"MMMM d, yyyy"),"aria-pressed":a,"aria-current":r?"date":void 0,children:e.getDate()},e.getTime())})})]}),Z&&n("div",{className:"ihub-daterange-presets",children:[t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=h(new Date);nn(e,e)},children:"Today"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=new Date;nn(c(e),h(s(e)))},children:"This Week"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=new Date;nn(y(e),h(m(e)))},children:"This Month"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=h(new Date);nn(f(e,6),e)},children:"Last 7 Days"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=h(new Date);nn(f(e,29),e)},children:"Last 30 Days"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){ae(null),oe(null),ce(null),Ce(null),ge("start"),Le("start"),Se(E?"Please select a date range.":null),$e(null,null)},children:"Clear"})]})]}),(null==V?void 0:V.start)&&t("input",{type:"hidden",name:V.start,value:te?p(te,"yyyy-MM-dd"):""}),(null==V?void 0:V.end)&&t("input",{type:"hidden",name:V.end,value:ie?p(ie,"yyyy-MM-dd"):""})]})};export{j as default};
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as t}from"react/jsx-runtime";import a from"@mui/icons-material/CalendarMonthOutlined";import r,{useState as o,useRef as d,useMemo as i,useEffect as l,useCallback as u,useLayoutEffect as s}from"react";import{addDays as c}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addDays.js";import{addYears as m}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addYears.js";import{subYears as f}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subYears.js";import{endOfWeek as p}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfWeek.js";import{startOfWeek as b}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfWeek.js";import{subDays as h}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subDays.js";import{endOfMonth as v}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfMonth.js";import{formatDate as y}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/format.js";import{startOfDay as g}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfDay.js";import{isBefore as D}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isBefore.js";import{isAfter as M}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isAfter.js";import{startOfMonth as N}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfMonth.js";import{getDay as _}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDay.js";import{getDaysInMonth as k}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDaysInMonth.js";import{isSameDay as w}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isSameDay.js";import{isValid as j}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isValid.js";import{addMonths as C}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addMonths.js";import{subMonths as F}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subMonths.js";var x=function(e){if(!e)return null;var n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(n){var t=Number(n[1]),a=Number(n[2])-1,r=Number(n[3]),o=new Date(t,a,r);return o.getFullYear()!==t||o.getMonth()!==a||o.getDate()!==r?null:j(o)?o:null}var d=new Date(e);return j(d)?g(d):null},O=function(j){var O=j.label,T=j.startLabel,L=void 0===T?"From":T,P=j.endLabel,A=void 0===P?"To":P,Y=j.value,E=j.onChange,K=j.required,S=void 0!==K&&K,I=j.minDate,W=j.maxDate,B=j.disabledDates,q=void 0===B?[]:B,H=j.dateFormat,U=void 0===H?"yyyy-MM-dd":H,Q=j.placeholder,R=j.errorMessage,V=j.className,z=void 0===V?"":V,G=j.name,J=j.id,X=j.disabled,Z=void 0!==X&&X,$=j.showCalendarIcon,ee=void 0===$||$,ne=j.showQuickActions,te=void 0===ne||ne,ae=j.ariaLabel,re=o(x(null==Y?void 0:Y.startDate)),oe=e(re,2),de=oe[0],ie=oe[1],le=o(x(null==Y?void 0:Y.endDate)),ue=e(le,2),se=ue[0],ce=ue[1],me=o(null),fe=e(me,2),pe=fe[0],be=fe[1],he=o(!1),ve=e(he,2),ye=ve[0],ge=ve[1],De=o(x(null==Y?void 0:Y.startDate)||new Date),Me=e(De,2),Ne=Me[0],_e=Me[1],ke=o("start"),we=e(ke,2),je=we[0],Ce=we[1],Fe=o(null),xe=e(Fe,2),Oe=xe[0],Te=xe[1],Le=o(null),Pe=e(Le,2),Ae=Pe[0],Ye=Pe[1],Ee=o(null),Ke=e(Ee,2),Se=Ke[0],Ie=Ke[1],We=R||Se,Be=o(null),qe=e(Be,2),He=qe[0],Ue=qe[1],Qe=d(null),Re=d(null),Ve=d(null),ze=d(null),Ge=d(new Map),Je=d(!1),Xe=r.useId(),Ze=J||"ihub-daterange-".concat(Xe),$e="".concat(Ze,"-error"),en=Ze,nn="".concat(Ze,"-end"),tn=i(function(){return x(I)},[I]),an=i(function(){return x(W)},[W]);l(function(){if(Y){var e=x(Y.startDate);ie(e),ce(x(Y.endDate)),be(null),e&&!ye&&_e(e)}},[null==Y?void 0:Y.startDate,null==Y?void 0:Y.endDate]),l(function(){R&&Ie(null)},[R]);var rn=u(function(){be(null),Te(null),Ce("start"),ge(!1),Ye(null),Ue(null)},[]);l(function(){var e=function(e){Re.current&&!Re.current.contains(e.target)&&rn()};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[rn]);var on=u(function(e){var n=y(e,"yyyy-MM-dd");return q.includes(n)},[q]),dn=u(function(e){var n=g(e);return(!tn||!D(n,tn))&&(!an||!M(n,an))},[tn,an]),ln=u(function(e){var n=g(e);return tn&&D(n,tn)&&(n=tn),an&&M(n,an)&&(n=an),tn&&D(n,tn)?null:n},[tn,an]),un=u(function(e){if(!e)return"";try{return y(e,U)}catch(e){return""}},[U]),sn=u(function(e,n){null==E||E({startDate:e?y(e,"yyyy-MM-dd"):"",endDate:n?y(n,"yyyy-MM-dd"):""})},[E]),cn=i(function(){for(var e=Ne.getFullYear(),n=Ne.getMonth(),t=N(Ne),a=_(t),r=k(Ne),o=[],d=0;d<a;d++)o.push(null);for(var i=1;i<=r;i++)o.push(new Date(e,n,i));return o},[Ne]),mn=function(e){return y(e,"yyyy-MM-dd")},fn=u(function(e){return!on(e)&&dn(e)},[on,dn]),pn=i(function(){for(var e,n,t=function(e){return e.getMonth()===Ne.getMonth()&&e.getFullYear()===Ne.getFullYear()},a=cn.filter(function(e){return null!==e}),r=0,o=[He,pe,de,se];r<o.length;r++){var d=o[r];if(d&&t(d)&&fn(d))return d}var i=new Date;return t(i)&&fn(i)?i:null!==(e=null!==(n=a.find(fn))&&void 0!==n?n:a[0])&&void 0!==e?e:null},[He,pe,de,se,Ne,cn,fn]),bn=u(function(e,n){for(var t=g(e),a=0;a<=400;a++){if(!dn(t))return;if(!on(t))return Ue(t),t.getMonth()===Ne.getMonth()&&t.getFullYear()===Ne.getFullYear()||_e(N(t)),void(Je.current=!0);t=c(t,n)}},[dn,on,Ne]);s(function(){var e;Je.current&&(Je.current=!1,ye&&He&&(null===(e=Ge.current.get(mn(He)))||void 0===e||e.focus()))});var hn=function(e,n){var t=ln(e),a=ln(n);t&&a&&!M(t,a)?on(t)||on(a)?Ie("That preset starts or ends on an unavailable date."):(ie(t),ce(a),be(null),Te(null),Ce("start"),Ie(null),_e(t),sn(t,a),ge(!1),Ye(null)):Ie("That preset falls outside the allowed date range.")},vn=function(e){if(!Z){if(ge(!0),Ye(e),"start"===e)return be(null),Ce("start"),void(de&&_e(de));de&&!se?(be(de),Ce("end")):(be(null),Ce("start")),se?_e(se):de&&_e(de)}},yn=function(e,n){"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),vn(n))},gn=un(null!=pe?pe:de),Dn=pe?"":un(se);return n("div",{ref:Re,className:"ihub-daterange-picker-wrapper ".concat(z),onKeyDown:function(e){var n,t;if("Escape"===e.key&&ye){e.stopPropagation();var a=Ae;rn(),"end"===a?null===(n=ze.current)||void 0===n||n.focus():null===(t=Ve.current)||void 0===t||t.focus()}},children:[O&&n("label",{className:"ihub-datetime-label",htmlFor:en,children:[O,S&&t("span",{className:"ihub-required",children:"*"})]}),n("div",{className:"ihub-daterange-inputs",children:[n("div",{className:"ihub-daterange-input-container ".concat("start"===Ae?"active":""),onClick:function(){return vn("start")},children:[t("input",{ref:Ve,id:en,type:"text",className:"ihub-datetime-input",value:gn,readOnly:!0,placeholder:(null==Q?void 0:Q.start)||L,disabled:Z,onKeyDown:function(e){return yn(e,"start")},"aria-label":ae?"".concat(ae," start date"):"".concat(L),"aria-invalid":!!We||void 0,"aria-describedby":We?$e:void 0}),ee&&t("div",{className:"ihub-datetime-icons",children:t("button",{type:"button",className:"ihub-datetime-icon-btn",disabled:Z,"aria-label":"Open calendar for start date","aria-expanded":ye&&"start"===Ae,onClick:function(e){e.stopPropagation(),vn("start")},children:t(a,{})})})]}),t("span",{className:"ihub-daterange-separator-arrow","aria-hidden":"true",children:"→"}),n("div",{className:"ihub-daterange-input-container ".concat("end"===Ae?"active":""),onClick:function(){return vn("end")},children:[t("input",{ref:ze,id:nn,type:"text",className:"ihub-datetime-input",value:Dn,readOnly:!0,placeholder:(null==Q?void 0:Q.end)||A,disabled:Z,onKeyDown:function(e){return yn(e,"end")},"aria-label":ae?"".concat(ae," end date"):"".concat(A),"aria-invalid":!!We||void 0,"aria-describedby":We?$e:void 0}),ee&&t("div",{className:"ihub-datetime-icons",children:t("button",{type:"button",className:"ihub-datetime-icon-btn",disabled:Z,"aria-label":"Open calendar for end date","aria-expanded":ye&&"end"===Ae,onClick:function(e){e.stopPropagation(),vn("end")},children:t(a,{})})})]})]}),We&&t("div",{className:"ihub-datetime-error",id:$e,role:"alert",children:We}),ye&&!Z&&n("div",{ref:Qe,className:"ihub-datetime-picker-dropdown",role:"dialog","aria-label":"Date range picker",children:[t("div",{className:"ihub-daterange-phase-indicator",children:"start"===je?"Select start date":"Select end date"}),n("div",{className:"ihub-datetime-calendar",children:[n("div",{className:"ihub-datetime-month-nav",children:[t("button",{type:"button",onClick:function(){return _e(F(Ne,1))},className:"ihub-datetime-nav-btn","aria-label":"Previous month",children:"‹"}),t("span",{className:"ihub-datetime-month-year","aria-live":"polite",children:y(Ne,"MMMM yyyy")}),t("button",{type:"button",onClick:function(){return _e(C(Ne,1))},className:"ihub-datetime-nav-btn","aria-label":"Next month",children:"›"})]}),t("div",{className:"ihub-datetime-weekdays",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(function(e){return t("div",{className:"ihub-datetime-weekday",children:e},e)})}),t("div",{className:"ihub-datetime-days",children:cn.map(function(e,n){if(!e)return t("div",{className:"ihub-datetime-day-empty"},"empty-".concat(n));var a=Boolean(pe&&w(e,pe)||!pe&&(de&&w(e,de)||se&&w(e,se))),r=w(e,new Date),o=on(e)||!dn(e),d=function(e){var n=null!=pe?pe:de;if(!n)return"";var t=pe?Oe:se,a=n,r=null!=t?t:n;if(D(r,a)){var o=[r,a];a=o[0],r=o[1]}var d=[];return w(e,a)&&d.push("range-start"),t&&w(e,r)&&d.push("range-end"),t&&M(e,a)&&D(e,r)&&!w(e,a)&&!w(e,r)&&d.push("in-range"),d.join(" ")}(e);return t("button",{ref:function(n){var t=mn(e);n?Ge.current.set(t,n):Ge.current.delete(t)},type:"button",className:"ihub-datetime-day ".concat(a?"selected":""," ").concat(r?"today":""," ").concat(o?"disabled":""," ").concat(d),onClick:function(){return function(e){if(!on(e)&&dn(e)){if("start"===je||!pe)return be(e),Ce("end"),Ye("end"),void Ie(null);var n=pe,t=e;if(D(t,n)){var a=[t,n];n=a[0],t=a[1]}ie(n),ce(t),be(null),Te(null),Ce("start"),Ie(null),sn(n,t),ge(!1),Ye(null)}}(e)},onKeyDown:function(n){return function(e,n){var t=e.shiftKey,a=!0;switch(e.key){case"ArrowLeft":bn(h(n,1),-1);break;case"ArrowRight":bn(c(n,1),1);break;case"ArrowUp":bn(h(n,7),-1);break;case"ArrowDown":bn(c(n,7),1);break;case"Home":bn(b(n),1);break;case"End":bn(p(n),-1);break;case"PageUp":bn(t?f(n,1):F(n,1),-1);break;case"PageDown":bn(t?m(n,1):C(n,1),1);break;default:a=!1}a&&(e.preventDefault(),e.stopPropagation())}(n,e)},onMouseEnter:function(){pe&&Te(e)},onMouseLeave:function(){return Te(null)},onFocus:function(){pe&&Te(e)},disabled:o,tabIndex:pn&&w(e,pn)?0:-1,"aria-label":y(e,"MMMM d, yyyy"),"aria-pressed":a,"aria-current":r?"date":void 0,children:e.getDate()},e.getTime())})})]}),te&&n("div",{className:"ihub-daterange-presets",children:[t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=g(new Date);hn(e,e)},children:"Today"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=new Date;hn(b(e),g(p(e)))},children:"This Week"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=new Date;hn(N(e),g(v(e)))},children:"This Month"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=g(new Date);hn(h(e,6),e)},children:"Last 7 Days"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){var e=g(new Date);hn(h(e,29),e)},children:"Last 30 Days"}),t("button",{type:"button",className:"ihub-datetime-action-btn",onClick:function(){ie(null),ce(null),be(null),Te(null),Ce("start"),Ye("start"),Ie(S?"Please select a date range.":null),sn(null,null)},children:"Clear"})]})]}),(null==G?void 0:G.start)&&t("input",{type:"hidden",name:G.start,value:de?y(de,"yyyy-MM-dd"):""}),(null==G?void 0:G.end)&&t("input",{type:"hidden",name:G.end,value:se?y(se,"yyyy-MM-dd"):""})]})};export{O as default};
|
|
2
2
|
//# sourceMappingURL=DateRangePicker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,toConsumableArray as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as i}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{slicedToArray as e,toConsumableArray as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as i}from"react/jsx-runtime";import{useState as t,useRef as r,useEffect as a,useCallback as l,useLayoutEffect as d,useMemo as c}from"react";import{createPortal as u}from"react-dom";import s from"@mui/icons-material/CloseOutlined";import p from"@mui/icons-material/KeyboardArrowDownOutlined";import m from"@mui/icons-material/SearchOutlined";var h=function(h){var v=h.label,f=h.name,b=h.key_name,w=h.required,g=h.options,y=h.selectedValue,N=h.onChange,x=h.placeholder,A=void 0===x?"Select...":x,E=h.className,C=void 0===E?"":E,L=h.isMulti,k=void 0!==L&&L,H=h.isSearchable,M=void 0!==H&&H,D=h.noOptionsMessage,O=void 0===D?"No options available":D,S=h.isDisabled,K=void 0!==S&&S,P=h.maxHeight,_=void 0===P?250:P,j=h.renderOption,q=t(!1),z=e(q,2),B=z[0],R=z[1],F=t(""),I=e(F,2),T=I[0],U=I[1],V=t(y),W=e(V,2),G=W[0],J=W[1],Q=r(null),X=r(null),Y=r(null),Z=t({top:0,left:0,width:0,maxHeight:_}),$=e(Z,2),ee=$[0],ne=$[1];a(function(){J(y)},[y]);var oe=l(function(){var e,n=null===(e=Q.current)||void 0===e?void 0:e.getBoundingClientRect();if(!n)return!1;if(n.bottom<0||n.top>window.innerHeight||n.right<0||n.left>window.innerWidth)return!1;var o=window.innerHeight-n.bottom-5-8,i=n.top-5-8,t=o<Math.min(_,120)&&i>o,r=Math.max(120,t?i:o),a=Math.min(_,r);return ne({top:t?Math.max(8,n.top-a-5):n.bottom+5,left:n.left,width:n.width,maxHeight:a}),!0},[_]);d(function(){B&&oe()},[B,oe]),d(function(){B&&oe()},[G,B,oe]),a(function(){if(B){var e=function(e){var n,o,i=e.target;i instanceof Node&&(null!==(n=Q.current)&&void 0!==n&&n.contains(i)||null!==(o=X.current)&&void 0!==o&&o.contains(i)||R(!1))},n=function(e){var n,o=e.target;o instanceof Node&&null!==(n=X.current)&&void 0!==n&&n.contains(o)||oe()||R(!1)},o=function(){oe()||R(!1)},i=function(e){"Escape"===e.key&&R(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("keydown",i),window.addEventListener("scroll",n,!0),window.addEventListener("resize",o),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("keydown",i),window.removeEventListener("scroll",n,!0),window.removeEventListener("resize",o)}}},[B,oe]),a(function(){B&&M&&Y.current&&Y.current.focus()},[B,M]);var ie=c(function(){if(!T)return g;var e=T.toLowerCase();return g.filter(function(n){var o=b?n[b]:null==n?void 0:n.label;return"number"==typeof o?String(o).includes(e):"string"==typeof o&&o.toLowerCase().includes(e)})},[g,T,b]),te=function(e){if(!K)switch(e.key){case"Enter":case"ArrowDown":case"ArrowUp":B||R(!0);break;case"Escape":R(!1)}},re=G?Array.isArray(G)?g.filter(function(e){return G.includes(e.value)}):g.filter(function(e){return e.value===G}):[];return o("div",{className:"ihub-wrapper ihub-dropdown-field ".concat(C," ").concat(K?"ihub-dropdown-disabled":""," ").concat(B?"active":""),ref:Q,tabIndex:K?-1:0,onKeyDown:te,"aria-expanded":B,"aria-disabled":K,"aria-haspopup":"listbox",role:"combobox",children:[o("div",{className:"ihub-dropdown-trigger ".concat(B?"ihub-dropdown-open":""),onClick:function(){K||(U(""),B?R(!1):oe()&&R(!0))},children:[i("div",{className:"ihub-dropdown-value",children:re.length>0?k?i("div",{className:"ihub-dropdown-tags",children:re.map(function(e){return o("div",{className:"ihub-dropdown-tag",children:[b?e[b]:null==e?void 0:e.label,i("button",{type:"button",className:"ihub-dropdown-tag-remove",onClick:function(n){return function(e,n){if(n.stopPropagation(),Array.isArray(G)){var o=G.filter(function(n){return n!==e});J(o),null==N||N(o)}}(e.value,n)},"aria-label":"Remove ".concat(b?e[b]:null==e?void 0:e.label),children:i(s,{})})]},e.value)})}):b?re[0][b]:re[0].label:i("span",{className:"ihub-dropdown-placeholder",children:A})}),i("div",{className:"ihub-dropdown-indicator",children:i(p,{className:B?"ihub-dropdown-chevron-up":""})}),v&&o("label",{htmlFor:f,className:"ihub-chips-label ihub-text-label",children:[v,w&&i("span",{className:"ihub-required",children:"*"})]}),f?i("input",{name:f,type:"hidden",value:"".concat(G),onChange:function(){}}):""]}),B&&"undefined"!=typeof document&&u(o("div",{ref:X,className:"ihub-dropdown-menu ihub-dropdown-menu-portal",style:{maxHeight:"".concat(ee.maxHeight,"px"),top:"".concat(ee.top,"px"),left:"".concat(ee.left,"px"),width:"".concat(ee.width,"px")},role:"listbox","aria-multiselectable":k,onKeyDown:te,children:[M&&o("div",{className:"ihub-dropdown-search",children:[i(m,{className:"ihub-dropdown-search-icon"}),i("input",{type:"text",value:T,onChange:function(e){return U(e.target.value)},placeholder:"Search...",ref:Y,className:"ihub-dropdown-search-input",onClick:function(e){return e.stopPropagation()}})]}),i("div",{className:"ihub-dropdown-options",children:ie.length>0?ie.map(function(e){var o=Array.isArray(G)?G.includes(e.value):G===e.value;return i("div",{className:"ihub-dropdown-option ".concat(o?"ihub-dropdown-selected":""," ").concat(e.disabled?"ihub-dropdown-disabled-option":""),onClick:function(){return function(e){if(!e.disabled)if(k){var o=Array.isArray(G)?G:[];if(o.includes(e.value)){var i=o.filter(function(n){return n!==e.value});J(i),null==N||N(i)}else{var t=[].concat(n(o),[e.value]);J(t),null==N||N(t)}}else J(e.value),null==N||N(e.value),R(!1)}(e)},role:"option","aria-selected":o,"aria-disabled":e.disabled,children:j?j(e):b?e[b]:null==e?void 0:e.label},e.value)}):i("div",{className:"ihub-dropdown-no-options",children:O})})]}),document.body)]})};export{h as default};
|
|
2
2
|
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -1,61 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DropdownPropsType } from "@/types";
|
|
3
|
-
/**
|
|
4
|
-
* A dropdown component that allows users to select one or multiple options
|
|
5
|
-
* @example
|
|
6
|
-
* ```tsx
|
|
7
|
-
* const options = [
|
|
8
|
-
* {
|
|
9
|
-
* value: "js",
|
|
10
|
-
* label: "JavaScript",
|
|
11
|
-
* icon: <CodeOutlinedIcon />,
|
|
12
|
-
* description: "Popular",
|
|
13
|
-
* },
|
|
14
|
-
* {
|
|
15
|
-
* value: "py",
|
|
16
|
-
* label: "Python",
|
|
17
|
-
* icon: <CodeOutlinedIcon />,
|
|
18
|
-
* description: "Popular",
|
|
19
|
-
* }
|
|
20
|
-
* ]
|
|
21
|
-
* <Dropdown
|
|
22
|
-
* label="Dropdown"
|
|
23
|
-
* name="dropdown"
|
|
24
|
-
* key_name="id"
|
|
25
|
-
* options={options}
|
|
26
|
-
* selectedValue={selectedValue}
|
|
27
|
-
* onChange={handleChange}
|
|
28
|
-
* placeholder="Select an option"
|
|
29
|
-
* className="ihub-dropdown"
|
|
30
|
-
* isMulti={true}
|
|
31
|
-
* isSearchable={true}
|
|
32
|
-
* noOptionsMessage="No options available"
|
|
33
|
-
* isDisabled={false}
|
|
34
|
-
* maxHeight={250}
|
|
35
|
-
* renderOption={renderOption}
|
|
36
|
-
* />
|
|
37
|
-
*
|
|
38
|
-
* @prop {string} label - The label text for the dropdown
|
|
39
|
-
* @prop {string} name - The name attribute for the dropdown
|
|
40
|
-
* @prop {string} key_name - The key name of the dropdown (description, name key, etc)
|
|
41
|
-
* @prop {boolean} required - Whether the dropdown is required
|
|
42
|
-
* @prop {DropdownOptionType[]} options - The options to display in the dropdown
|
|
43
|
-
* @prop {string | string[]} selectedValue - The value(s) currently selected in the dropdown
|
|
44
|
-
* @prop {function} onChange - The function to call when the selected value changes
|
|
45
|
-
* @prop {string} placeholder - The placeholder text for the dropdown
|
|
46
|
-
* @prop {string} className - The class name for the dropdown
|
|
47
|
-
* @prop {boolean} isMulti - Whether the dropdown allows multiple selections
|
|
48
|
-
* @prop {boolean} isSearchable - Whether the dropdown allows searching
|
|
49
|
-
* @prop {string} noOptionsMessage - The message to display when there are no options
|
|
50
|
-
* @prop {boolean} isDisabled - Whether the dropdown is disabled
|
|
51
|
-
* @prop {number} maxHeight - The maximum height of the dropdown menu
|
|
52
|
-
* @prop {function} renderOption - The function to render the option label
|
|
53
|
-
*
|
|
54
|
-
* The menu is rendered through a portal on `document.body` at fixed
|
|
55
|
-
* coordinates taken from the trigger. An absolutely positioned menu is clipped
|
|
56
|
-
* by any ancestor with `overflow: auto|hidden` — a table's scroll container, a
|
|
57
|
-
* modal body, a card — which made the component unusable in exactly the places
|
|
58
|
-
* a compact picker is most wanted.
|
|
59
|
-
*/
|
|
60
3
|
declare const Dropdown: React.FC<DropdownPropsType>;
|
|
61
4
|
export default Dropdown;
|