@zimyo/ui 1.15.5 → 1.17.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),t=require("../../chunks/moment-1102cd58.js"),r=require("../../chunks/index-4d90f67d.js"),u=require("../Popover/index.js"),o=require("../../chunks/dayjs.min-5e22609b.js"),n=require("../../chunks/lucide-937248a9.js");function a(e){var i=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),i.default=e,Object.freeze(i)}require("../../chunks/createSuper-c9c5c00c.js"),require("../../chunks/assertThisInitialized-9901ca61.js"),require("../../chunks/tslib.es6-a3dc1f53.js"),require("../Button/index.js"),require("@mui/material"),require("../../chunks/_commonjsHelpers-3d4c1909.js");var s=a(i),l={xs:"zui:h-9 zui:px-3 zui:text-xs",sm:"zui:h-9 zui:px-3 zui:text-sm",md:"zui:h-10 zui:px-3 zui:text-sm",lg:"zui:h-11 zui:px-3 zui:text-base"},d=function(e){return!!e&&t.isValid(e)},c=function(i){var a=i.label,c=i.value,m=i.onChange,z=i.placeholder,f=void 0===z?"Pick a date":z,v=i.required,x=i.description,j=i.error,b=i.disabled,h=i.variant,p=void 0===h?"outlined":h,g=i.size,y=void 0===g?"md":g,k=i.className,q=i.floatingLabel,N=void 0!==q&&q,w=i.isClearable,O=void 0!==w&&w,C=i.dateFormat,M=void 0===C?"MMMM dd, yyyy":C,P=i.dateLibrary,D=void 0===P?"date":P,V=function(e){return{container:e?"zui:opacity-80":"",label:e?"zui:text-gray-500":"zui:text-gray-700",input:e?" zui:cursor-not-allowed zui:opacity-60 zui:text-gray-500 zui:bg-gray-50 zui:border zui:border-gray-300":""}}(b||!1),F=r.useStableId("date-range"),S=s.useCallback(function(e){if(e){if("moment"===D){var i=t.moment.isMoment(e)?e:t.moment(e,M);return i.isValid()?i.toDate():void 0}if("dayjs"===D){var r=o.dayjs.isDayjs(e)?e:o.dayjs(e,M);return r.isValid()?r.toDate():void 0}if(e instanceof Date&&t.isValid(e))return e;if("string"==typeof e){var u=t.parse(e,M,new Date);return t.isValid(u)?u:void 0}}},[D,M]),E=s.useState({from:S(null==c?void 0:c.from),to:S(null==c?void 0:c.to)}),_=E[0],B=E[1];s.useEffect(function(){B({from:S(null==c?void 0:c.from),to:S(null==c?void 0:c.to)})},[c,S]);var I=s.useState(null),L=I[0],T=I[1],H=s.useCallback(function(e){return e?"moment"===D?t.moment(e).format(M):"dayjs"===D?o.dayjs(e).format(M):t.format(e,M):""},[D,M]);return e.jsxs("div",{className:r.cn("zui:w-full zui:space-y-1",V.container,k),children:[!N&&a&&e.jsxs("label",{htmlFor:F,className:r.cn("zui:block zui:mb-2 zui:text-sm zui:font-medium zui:leading-none",V.label),children:[a,v&&e.jsx("span",{className:"zui:text-destructive zui:font-medium",children:" *"})]}),e.jsxs("div",{className:r.cn("zui:relative zui:flex zui:items-center zui:justify-between zui:rounded-sm zui:border zui:text-sm zui:ring-offset-background zui:transition-colors","focus-within:zui:ring-1 focus-within:zui:ring-ring focus-within:zui:ring-offset-1","outlined"===p&&"zui:bg-background zui:border-input","contained"===p&&"zui:bg-muted zui:border-transparent",j&&"zui:border-destructive focus-within:zui:ring-destructive",l[y],V.input,k),onClick:function(e){return!b&&void T(e.currentTarget)},children:[e.jsx("div",{className:"zui:truncate",children:d(null==_?void 0:_.from)?d(null==_?void 0:_.to)?e.jsxs(e.Fragment,{children:[H(_.from)," -"," ",H(_.to)]}):H(_.from):f}),e.jsxs("div",{className:"zui:flex zui:items-center zui:ml-2",children:[(d(null==_?void 0:_.from)||d(null==_?void 0:_.to))&&O&&e.jsx("button",{type:"button",className:"zui:p-1 zui:rounded-full hover:zui:bg-gray-200 zui:text-gray-500",onClick:function(e){e.stopPropagation(),B({from:void 0,to:void 0}),null==m||m(void 0)},children:"✕"}),e.jsx(n.Calendar,{className:"zui:ml-2 zui:h-4 zui:w-4 zui:opacity-50"})]}),N&&a&&e.jsxs("label",{htmlFor:F,className:r.cn("zui:pointer-events-none zui:absolute zui:left-3 zui:-top-[9px] zui:z-10 zui:bg-background zui:px-1 zui:text-xs zui:text-muted-foreground zui:transition-all",V.label),children:[a,v&&e.jsx("span",{className:"zui:text-destructive zui:font-medium",children:" *"})]})]}),e.jsx(u.Popover,{open:Boolean(L),onClose:function(){T(null)},anchorEl:L,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:e.jsx(t.Calendar,{id:F,autoFocus:!0,mode:"range",defaultMonth:null==_?void 0:_.from,selected:_,onSelect:function(e){var i;if((null==e?void 0:e.from)&&t.isValid(e.from)){B(e);var r={from:e.from,to:null!==(i=e.to)&&void 0!==i?i:e.from};"moment"===D?r={from:t.moment(e.from),to:e.to?t.moment(e.to):t.moment(e.from)}:"dayjs"===D&&(r={from:o.dayjs(e.from),to:e.to?o.dayjs(e.to):o.dayjs(e.from)}),null==m||m(r)}else B(void 0),null==m||m(void 0)},numberOfMonths:2})}),x&&!j&&e.jsx("p",{className:"zui:text-xs zui:text-muted-foreground",children:x}),j&&e.jsx("p",{className:"zui:text-xs zui:text-destructive",children:j})]})};exports.DateRangePicker=c,exports.default=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),t=require("../../chunks/moment-1102cd58.js"),r=require("../../chunks/index-4d90f67d.js"),u=require("../Popover/index.js"),o=require("../../chunks/dayjs.min-5e22609b.js"),n=require("../../chunks/lucide-937248a9.js");function a(e){var i=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),i.default=e,Object.freeze(i)}require("../../chunks/createSuper-c9c5c00c.js"),require("../../chunks/assertThisInitialized-9901ca61.js"),require("../../chunks/tslib.es6-a3dc1f53.js"),require("../Button/index.js"),require("@mui/material"),require("../../chunks/_commonjsHelpers-3d4c1909.js");var s=a(i),l={xs:"zui:h-9 zui:px-3 zui:text-xs",sm:"zui:h-9 zui:px-3 zui:text-sm",md:"zui:h-10 zui:px-3 zui:text-sm",lg:"zui:h-11 zui:px-3 zui:text-base"},d=function(e){return!!e&&t.isValid(e)},c=function(i){var a=i.label,c=i.value,m=i.onChange,z=i.placeholder,f=void 0===z?"Pick a date":z,v=i.required,x=i.description,b=i.error,j=i.disabled,h=i.variant,p=void 0===h?"outlined":h,g=i.size,y=void 0===g?"md":g,k=i.className,q=i.floatingLabel,N=void 0!==q&&q,w=i.isClearable,O=void 0!==w&&w,C=i.dateFormat,M=void 0===C?"MMMM dd, yyyy":C,P=i.dateLibrary,D=void 0===P?"date":P,V=function(e){return{container:e?"zui:opacity-80":"",label:e?"zui:text-gray-500":"zui:text-gray-700",input:e?" zui:cursor-not-allowed zui:opacity-60 zui:text-gray-500 zui:bg-gray-50 zui:border zui:border-gray-300":""}}(j||!1),F=r.useStableId("date-range"),S=s.useCallback(function(e){if(e){if("moment"===D){var i=t.moment.isMoment(e)?e:t.moment(e,M);return i.isValid()?i.toDate():void 0}if("dayjs"===D){var r=o.dayjs.isDayjs(e)?e:o.dayjs(e,M);return r.isValid()?r.toDate():void 0}if(e instanceof Date&&t.isValid(e))return e;if("string"==typeof e){var u=t.parse(e,M,new Date);return t.isValid(u)?u:void 0}}},[D,M]),E=s.useState({from:S(null==c?void 0:c.from),to:S(null==c?void 0:c.to)}),_=E[0],B=E[1];s.useEffect(function(){B({from:S(null==c?void 0:c.from),to:S(null==c?void 0:c.to)})},[c,S]);var I=s.useState(null),L=I[0],T=I[1],H=s.useCallback(function(e){return e?"moment"===D?t.moment(e).format(M):"dayjs"===D?o.dayjs(e).format(M):t.format(e,M):""},[D,M]);return e.jsxs("div",{className:r.cn("zui:w-full zui:space-y-1",V.container,k),children:[!N&&a&&e.jsxs("label",{htmlFor:F,className:r.cn("zui:block zui:mb-2 zui:text-sm zui:font-medium zui:leading-none",V.label),children:[a,v&&e.jsx("span",{className:"zui:text-destructive zui:font-medium",children:" *"})]}),e.jsxs("div",{className:r.cn("zui:relative zui:flex zui:items-center zui:justify-between zui:rounded-sm zui:border zui:text-sm zui:ring-offset-background zui:transition-colors","focus-within:zui:ring-1 focus-within:zui:ring-ring focus-within:zui:ring-offset-1","outlined"===p&&"zui:bg-background zui:border-input","contained"===p&&"zui:bg-muted zui:border-transparent",b&&"zui:border-destructive focus-within:zui:ring-destructive",l[y],V.input,k),onClick:function(e){return!j&&void T(e.currentTarget)},children:[e.jsx("div",{className:"zui:truncate",children:d(null==_?void 0:_.from)?d(null==_?void 0:_.to)?e.jsxs(e.Fragment,{children:[H(_.from)," -"," ",H(_.to)]}):H(_.from):f}),e.jsxs("div",{className:"zui:flex zui:items-center zui:ml-2",children:[(d(null==_?void 0:_.from)||d(null==_?void 0:_.to))&&O&&e.jsx("button",{type:"button",className:"zui:p-1 zui:rounded-full hover:zui:bg-gray-200 zui:text-gray-500",onClick:function(e){e.stopPropagation(),B({from:void 0,to:void 0}),null==m||m(void 0)},children:"✕"}),e.jsx(n.Calendar,{className:"zui:ml-2 zui:h-4 zui:w-4 zui:opacity-50"})]}),N&&a&&e.jsxs("label",{htmlFor:F,className:r.cn("zui:pointer-events-none zui:absolute zui:left-3 zui:-top-[9px] zui:z-10 zui:bg-background zui:px-1 zui:text-xs zui:text-muted-foreground zui:transition-all",V.label),children:[a,v&&e.jsx("span",{className:"zui:text-destructive zui:font-medium",children:" *"})]})]}),e.jsx(u.Popover,{open:Boolean(L),onClose:function(){T(null)},anchorEl:L,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:e.jsx(t.Calendar,{id:F,autoFocus:!0,mode:"range",defaultMonth:null==_?void 0:_.from,selected:_,onSelect:function(e){var i;if((null==e?void 0:e.from)&&t.isValid(e.from)){B(e);var r={from:e.from,to:null!==(i=e.to)&&void 0!==i?i:e.from};"moment"===D?r={from:t.moment(e.from),to:e.to?t.moment(e.to):t.moment(e.from)}:"dayjs"===D&&(r={from:o.dayjs(e.from),to:e.to?o.dayjs(e.to):o.dayjs(e.from)}),null==m||m(r)}else B(void 0),null==m||m(void 0)},numberOfMonths:2})}),x&&!b&&e.jsx("p",{className:"zui:text-xs zui:text-muted-foreground",children:x}),b&&e.jsx("p",{className:"zui:text-xs zui:text-destructive",children:b})]})};exports.DateRangePicker=c,exports.default=c;
@@ -30,7 +30,7 @@ interface SelectProps extends Omit<Props<Option, boolean, GroupBase<Option>>, 'o
30
30
  cacheOptions?: boolean;
31
31
  defaultOptions?: boolean | Option[];
32
32
  }
33
- declare function Select({ label, error, className, size, required, valueKey, labelKey, isMulti, value, options, loadOptions, cacheOptions, defaultOptions, onChange, searchByID, floatingLabel, maxChipVisible, description, isDisabled, ...props }: SelectProps): react_jsx_runtime.JSX.Element;
33
+ declare function Select({ label, error, className, size, required, valueKey, labelKey, isMulti, value, options, loadOptions, cacheOptions, defaultOptions, onChange, searchByID, floatingLabel, maxChipVisible, description, isDisabled, defaultValue, ...props }: SelectProps): react_jsx_runtime.JSX.Element;
34
34
 
35
35
  export { Select, Select as default };
36
36
  export type { SelectProps };