@zonos/amino 5.4.1 → 5.4.3

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";var e=require("../../_tslib-bd4862e8.js"),t=require("react/jsx-runtime"),n=require("react"),r=require("clsx"),u=require("../flex/Flex.js"),l=require("../tag/Tag.js"),a=require("../../style-inject.es-d4ddeae4.js");function i(e){return e&&e.__esModule?e:{default:e}}require("../../icons/RemoveIcon.js"),require("../../icons/icon-base/_IconBase.js"),require("../../styles/constants/theme.js");var o=i(r),s="Amino_MultiInput-module__tagInputWrapper--FTdAL",c="Amino_MultiInput-module__tagInput--cBsz8";a.styleInject(".Amino_MultiInput-module__tagInputWrapper--FTdAL.Amino_MultiInput-module__tagInputWrapper--FTdAL{border:1px solid #ccc;border-radius:4px;overflow-x:auto;padding:5px}.Amino_MultiInput-module__tagInputWrapper--FTdAL.Amino_MultiInput-module__tagInputWrapper--FTdAL .Amino_MultiInput-module__tagInput--cBsz8{border:none;flex:1 1 auto;flex-grow:1;font-size:var(--amino-font-size-base);font-weight:500;min-width:100px;min-width:50px;outline:none;padding:5px}");exports.MultiInput=function(r){var a=r.className,i=r.placeholder,p=void 0===i?"":i,d=r.setHasValidationError,g=r.setTags,_=r.style,f=r.tags,m=r.tagValidation,h=e.__read(n.useState(""),2),x=h[0],I=h[1],v=n.useRef(null),A=e.__read(n.useState(null),2),j=A[0],y=A[1];n.useEffect((function(){if(d&&m){var e=f.some((function(e){return!m(e)}));d(e)}}),[f,m,d]);var q=function(e){g(f.filter((function(t,n){return n!==e})))};return t.jsxs(u.Flex,{alignItems:"center",className:o.default([a,s]),flexWrap:"wrap",gap:4,style:_,children:[f.map((function(e,n){var r=!(!m||m(e)),a=j===n,i=r?"error":"default";return t.jsx(u.Flex,{alignItems:"center",gap:0,children:t.jsx(l.Tag,{highlighted:a,intent:i,onClick:function(){return y(n)},onClose:function(){return q(n)},size:"lg",children:e})},e)})),t.jsx("input",{ref:v,className:c,onChange:function(e){I(e.target.value)},onFocus:function(){v.current&&(v.current.selectionStart=v.current.value.length,v.current.selectionEnd=v.current.value.length)},onKeyDown:function(t){var n;"Enter"!==t.key&&","!==t.key&&" "!==t.key||!x?"Backspace"===t.key?""===x&&f.length>0&&(null===j?y(f.length-1):(q(j),y(null))):"ArrowLeft"===t.key?null===j&&f.length>0?y(f.length-1):null!==j&&j>0&&y(j-1):"ArrowRight"===t.key&&null!==j&&j<f.length-1?y(j+1):y(null):(t.preventDefault(),(n=x.trim())&&(g(e.__spreadArray(e.__spreadArray([],e.__read(f),!1),[n],!1)),I("")))},placeholder:f.length?"":p,value:x})]})};
1
+ "use strict";var e=require("../../_tslib-bd4862e8.js"),n=require("react/jsx-runtime"),t=require("react"),r=require("clsx"),u=require("../flex/Flex.js"),a=require("../tag/Tag.js"),l=require("../../style-inject.es-d4ddeae4.js");function i(e){return e&&e.__esModule?e:{default:e}}require("../../icons/RemoveIcon.js"),require("../../icons/icon-base/_IconBase.js"),require("../../styles/constants/theme.js");var o=i(r),s="Amino_MultiInput-module__tagInputWrapper--FTdAL",c="Amino_MultiInput-module__tagInput--cBsz8";l.styleInject(".Amino_MultiInput-module__tagInputWrapper--FTdAL.Amino_MultiInput-module__tagInputWrapper--FTdAL{border:var(--amino-border);border-radius:var(--amino-radius-10);overflow-x:auto;padding:6px}.Amino_MultiInput-module__tagInputWrapper--FTdAL.Amino_MultiInput-module__tagInputWrapper--FTdAL .Amino_MultiInput-module__tagInput--cBsz8{background-color:initial;border:none;flex:1 1 auto;flex-grow:1;font-size:var(--amino-font-size-base);font-weight:500;min-width:100px;min-width:50px;outline:none;padding:6px}");exports.MultiInput=function(r){var l=r.className,i=r.placeholder,d=void 0===i?"":i,p=r.setHasValidationError,g=r.setTags,_=r.style,f=r.tags,m=r.tagValidation,h=e.__read(t.useState(""),2),I=h[0],x=h[1],v=t.useRef(null),A=e.__read(t.useState(null),2),j=A[0],y=A[1];t.useEffect((function(){if(p&&m){var e=f.some((function(e){return!m(e)}));p(e)}}),[f,m,p]);var q=function(e){g(f.filter((function(n,t){return t!==e})))};return n.jsxs(u.Flex,{alignItems:"center",className:o.default([l,s]),flexWrap:"wrap",gap:4,style:_,children:[f.map((function(e,t){var r=!(!m||m(e)),l=j===t,i=r?"error":"default";return n.jsx(u.Flex,{alignItems:"center",gap:0,children:n.jsx(a.Tag,{highlighted:l,intent:i,onClick:function(){return y(t)},onClose:function(){return q(t)},size:"lg",children:e})},e)})),n.jsx("input",{ref:v,className:c,onChange:function(e){x(e.target.value)},onFocus:function(){v.current&&(v.current.selectionStart=v.current.value.length,v.current.selectionEnd=v.current.value.length)},onKeyDown:function(n){var t;"Enter"!==n.key&&","!==n.key&&" "!==n.key||!I?"Backspace"===n.key?""===I&&f.length>0&&(null===j?y(f.length-1):(q(j),y(null))):"ArrowLeft"===n.key?null===j&&f.length>0?y(f.length-1):null!==j&&j>0&&y(j-1):"ArrowRight"===n.key&&null!==j&&j<f.length-1?y(j+1):y(null):(n.preventDefault(),(t=I.trim())&&(g(e.__spreadArray(e.__spreadArray([],e.__read(f),!1),[t],!1)),x("")))},placeholder:f.length?"":d,value:I})]})};
@@ -1 +1 @@
1
- "use strict";var e=require("../../_tslib-bd4862e8.js"),l=require("react/jsx-runtime"),o=require("react"),i=require("clsx"),t=require("../checkbox/Checkbox.js"),n=require("../skeleton/Skeleton.js"),a=require("../text/Text.js"),d=require("../../style-inject.es-d4ddeae4.js");function r(e){return e&&e.__esModule?e:{default:e}}require("framer-motion"),require("../help-text/HelpText.js"),require("../../styles/constants/theme.js"),require("../../icons/CheckmarkIcon.js"),require("../../icons/icon-base/_IconBase.js"),require("../../global.module-569e4fd5.js"),require("../../utils/getTestId.js");var m=r(i),s="Amino_SimpleTable-module__tableContainer--UsGFZ",c="Amino_SimpleTable-module__tableStyled--Q3YSy",b="Amino_SimpleTable-module__noPadding--b5Y-c",u="Amino_SimpleTable-module__withHover--eL3XX",_="Amino_SimpleTable-module__clickable--XnaaE",h="Amino_SimpleTable-module__loading--bvjof",y="Amino_SimpleTable-module__cellLink--jySVK",p="Amino_SimpleTable-module__styledCheckbox---753a",S="Amino_SimpleTable-module__skeletonCellWrapper--I8vJ7";d.styleInject(".Amino_SimpleTable-module__tableContainer--UsGFZ{overflow:auto;width:100%}.Amino_SimpleTable-module__tableStyled--Q3YSy{border-collapse:initial;border-spacing:0;width:100%}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead{text-transform:none}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead>tr{border-bottom:var(--amino-border-subtle);height:48px}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead>tr>th{background-color:var(--amino-gray-0);border-bottom:var(--amino-border-subtle);padding:12px;position:-webkit-sticky;position:sticky;top:0;white-space:nowrap}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead>tr>th.Amino_SimpleTable-module__noPadding--b5Y-c{padding:0}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr{height:48px}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr.Amino_SimpleTable-module__withHover--eL3XX:hover{background-color:var(--amino-hover-color)}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr.Amino_SimpleTable-module__clickable--XnaaE{cursor:pointer}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr:not(:hover) .row-hover-show{visibility:collapse}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td{border-bottom:var(--amino-border-subtle);padding:12px}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__noPadding--b5Y-c{padding:0}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__loading--bvjof{text-align:center}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td:not(:hover) .cell-hover-show{visibility:collapse}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__cellLink--jySVK{padding:0}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__cellLink--jySVK>a{display:block;height:100%;padding:12px;width:100%}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__cellLink--jySVK>a.Amino_SimpleTable-module__noPadding--b5Y-c{padding:0}.Amino_SimpleTable-module__styledCheckbox---753a{display:inline-flex;padding:12px}.Amino_SimpleTable-module__skeletonCellWrapper--I8vJ7{display:flex}");var x=function(e){switch(e){case"center":return"center";case"end":return"flex-end";default:return"flex-start"}};exports.SimpleTable=function(i){var d=i.className,r=i.CustomLinkComponent,g=i.getRowLink,v=i.headers,k=i.items,j=i.keyExtractor,A=i.loading,T=void 0!==A&&A,C=i.loadingItems,f=void 0===C?10:C,w=i.loadingSkeletonHeight,Y=void 0===w?13:w,Q=i.maxHeight,q=void 0===Q?"100%":Q,H=i.noHoverBackground,N=void 0!==H&&H,R=i.onRowClick,L=i.onRowHover,P=i.renderFooter,I=i.selectable,F=void 0===I?{enabled:!1}:I,X=i.style,V=function(e,o){var i=o[e.key],t=function(i){if(g&&!F.anySelected&&!e.disabledLink){var t=r||"a";return l.jsx("td",{className:y,children:l.jsx(t,{className:m.default(e.noPadding&&b),href:g(o),style:{textAlign:e.align||"start"},children:i})})}return l.jsx("td",{className:m.default(e.noPadding&&b),style:{textAlign:e.align||"start"},children:i})};return e.renderCustom?l.jsx(l.Fragment,{children:t(e.renderCustom(i,o))}):l.jsx(l.Fragment,{children:t(String(i))})};return l.jsx("div",{className:s,style:{maxHeight:q},children:l.jsxs("table",{className:m.default(d,c),style:X,children:[l.jsxs("colgroup",{children:[!!F.onHeaderCheckboxChange&&l.jsx("col",{width:0}),v.map((function(e){return l.jsx("col",{width:void 0!==e.width?"".concat(e.width,"%"):void 0},e.key)}))]}),l.jsx("thead",{children:l.jsxs("tr",{children:[!!F.onHeaderCheckboxChange&&l.jsx("th",{className:b,children:F.renderCustomHeaderCheckbox||l.jsx(t.Checkbox,{checked:!T&&F.headerCheckboxValue||!1,className:p,disabled:T,onChange:F.onHeaderCheckboxChange})}),v.map((function(e){return l.jsx("th",{className:m.default(e.noPadding&&b),style:{textAlign:e.align||"start"},children:"string"==typeof e.name?l.jsx(a.Text,{color:"gray800",type:"small-header",children:e.name}):e.name},e.key)}))]})}),l.jsx("tbody",{children:T?e.__spreadArray([],e.__read(Array(f).keys()),!1).map((function(e){return l.jsxs("tr",{children:[F.enabled&&l.jsx("td",{children:l.jsx(n.Skeleton,{height:Y},e)}),v.map((function(o){return l.jsx("td",{className:m.default(h,o.noPadding&&b),children:l.jsx("div",{className:S,style:{justifyContent:x(o.align)},children:l.jsx(n.Skeleton,{height:Y,style:{width:"50%"}},e)})},o.key)}))]},e)})):k.map((function(e,i){var n,a,d,r=!!R||!!F.anySelected&&!!F.onRowCheckboxChange;return l.jsxs("tr",{className:m.default(r&&_,!N&&u),onClick:function(l){var o,t,n;F.anySelected?(null===(o=F.isRowCheckboxDisabled)||void 0===o?void 0:o.call(F,e,i))||(l.preventDefault(),null===(t=F.onRowCheckboxChange)||void 0===t||t.call(F,!(null===(n=F.isRowChecked)||void 0===n?void 0:n.call(F,e,i)),e,i)):null==R||R(e)},onMouseEnter:function(){return null==L?void 0:L(e)},children:[F.enabled&&l.jsx("td",{children:(null===(n=F.renderCustomRowCheckbox)||void 0===n?void 0:n.call(F,e,i))||l.jsx(t.Checkbox,{checked:(null===(a=F.isRowChecked)||void 0===a?void 0:a.call(F,e,i))||!1,disabled:(null===(d=F.isRowCheckboxDisabled)||void 0===d?void 0:d.call(F,e,i))||!1,onChange:function(l){var o;return null===(o=F.onRowCheckboxChange)||void 0===o?void 0:o.call(F,l,e,i)}})}),v.map((function(i){return l.jsx(o.Fragment,{children:V(i,e)},i.key)}))]},j(e))}))}),P]})})};
1
+ "use strict";var e=require("../../_tslib-bd4862e8.js"),l=require("react/jsx-runtime"),o=require("react"),i=require("clsx"),t=require("../checkbox/Checkbox.js"),n=require("../skeleton/Skeleton.js"),a=require("../text/Text.js"),d=require("../../style-inject.es-d4ddeae4.js");function r(e){return e&&e.__esModule?e:{default:e}}require("framer-motion"),require("../help-text/HelpText.js"),require("../../styles/constants/theme.js"),require("../../icons/CheckmarkIcon.js"),require("../../icons/icon-base/_IconBase.js"),require("../../global.module-569e4fd5.js"),require("../../utils/getTestId.js");var m=r(i),s="Amino_SimpleTable-module__tableContainer--UsGFZ",c="Amino_SimpleTable-module__tableStyled--Q3YSy",b="Amino_SimpleTable-module__noPadding--b5Y-c",u="Amino_SimpleTable-module__withHover--eL3XX",_="Amino_SimpleTable-module__clickable--XnaaE",h="Amino_SimpleTable-module__loading--bvjof",y="Amino_SimpleTable-module__cellLink--jySVK",p="Amino_SimpleTable-module__styledCheckbox---753a",S="Amino_SimpleTable-module__skeletonCellWrapper--I8vJ7";d.styleInject(".Amino_SimpleTable-module__tableContainer--UsGFZ{overflow:auto;width:100%}.Amino_SimpleTable-module__tableStyled--Q3YSy{border-collapse:initial;border-spacing:0;width:100%}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead{text-transform:none}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead>tr{border-bottom:var(--amino-border-subtle);height:48px}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead>tr>th{background-color:var(--amino-gray-0);border-bottom:var(--amino-border-subtle);padding:12px;position:-webkit-sticky;position:sticky;top:0;white-space:nowrap}.Amino_SimpleTable-module__tableStyled--Q3YSy>thead>tr>th.Amino_SimpleTable-module__noPadding--b5Y-c{padding:0}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr{height:48px}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr.Amino_SimpleTable-module__withHover--eL3XX:hover{background-color:var(--amino-hover-color)}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr.Amino_SimpleTable-module__clickable--XnaaE{cursor:pointer}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr:not(:hover) .row-hover-show{visibility:collapse}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td{border-bottom:var(--amino-border-subtle);padding:12px}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__noPadding--b5Y-c{padding:0}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__loading--bvjof{text-align:center}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td:not(:hover) .cell-hover-show{visibility:collapse}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__cellLink--jySVK{padding:0}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__cellLink--jySVK>a{display:block;height:100%;padding:12px;width:100%}.Amino_SimpleTable-module__tableStyled--Q3YSy>tbody>tr>td.Amino_SimpleTable-module__cellLink--jySVK>a.Amino_SimpleTable-module__noPadding--b5Y-c{padding:0}.Amino_SimpleTable-module__styledCheckbox---753a{display:inline-flex;padding:12px}.Amino_SimpleTable-module__skeletonCellWrapper--I8vJ7{display:flex}");var x=function(e){switch(e){case"center":return"center";case"end":return"flex-end";default:return"flex-start"}};exports.SimpleTable=function(i){var d=i.className,r=i.CustomLinkComponent,g=i.getRowLink,v=i.headers,k=i.items,j=i.keyExtractor,A=i.loading,T=void 0!==A&&A,C=i.loadingItems,f=void 0===C?10:C,w=i.loadingSkeletonHeight,Y=void 0===w?13:w,Q=i.maxHeight,q=void 0===Q?"100%":Q,H=i.noHoverBackground,N=void 0!==H&&H,R=i.onRowClick,L=i.onRowHover,P=i.renderFooter,I=i.selectable,F=void 0===I?{enabled:!1}:I,X=i.style,V=function(e,o){var i=o[e.key],t=function(i){if(g&&!F.anySelected&&!e.disabledLink){var t=r||"a";return l.jsx("td",{className:y,children:l.jsx(t,{className:m.default(e.noPadding&&b),href:g(o),style:{textAlign:e.align||"start"},children:i})})}return l.jsx("td",{className:m.default(e.noPadding&&b),style:{textAlign:e.align||"start"},children:i})};return e.renderCustom?l.jsx(l.Fragment,{children:t(e.renderCustom(i,o))}):l.jsx(l.Fragment,{children:t(String(i))})};return l.jsx("div",{className:m.default(s,d),style:e.__assign({maxHeight:q},X),children:l.jsxs("table",{className:c,children:[l.jsxs("colgroup",{children:[!!F.onHeaderCheckboxChange&&l.jsx("col",{width:0}),v.map((function(e){return l.jsx("col",{width:void 0!==e.width?"".concat(e.width,"%"):void 0},e.key)}))]}),l.jsx("thead",{children:l.jsxs("tr",{children:[!!F.onHeaderCheckboxChange&&l.jsx("th",{className:b,children:F.renderCustomHeaderCheckbox||l.jsx(t.Checkbox,{checked:!T&&F.headerCheckboxValue||!1,className:p,disabled:T,onChange:F.onHeaderCheckboxChange})}),v.map((function(e){return l.jsx("th",{className:m.default(e.noPadding&&b),style:{textAlign:e.align||"start"},children:"string"==typeof e.name?l.jsx(a.Text,{color:"gray800",type:"small-header",children:e.name}):e.name},e.key)}))]})}),l.jsx("tbody",{children:T?e.__spreadArray([],e.__read(Array(f).keys()),!1).map((function(e){return l.jsxs("tr",{children:[F.enabled&&l.jsx("td",{children:l.jsx(n.Skeleton,{height:Y},e)}),v.map((function(o){return l.jsx("td",{className:m.default(h,o.noPadding&&b),children:l.jsx("div",{className:S,style:{justifyContent:x(o.align)},children:l.jsx(n.Skeleton,{height:Y,style:{width:"50%"}},e)})},o.key)}))]},e)})):k.map((function(e,i){var n,a,d,r=!!R||!!F.anySelected&&!!F.onRowCheckboxChange;return l.jsxs("tr",{className:m.default(r&&_,!N&&u),onClick:function(l){var o,t,n;F.anySelected?(null===(o=F.isRowCheckboxDisabled)||void 0===o?void 0:o.call(F,e,i))||(l.preventDefault(),null===(t=F.onRowCheckboxChange)||void 0===t||t.call(F,!(null===(n=F.isRowChecked)||void 0===n?void 0:n.call(F,e,i)),e,i)):null==R||R(e)},onMouseEnter:function(){return null==L?void 0:L(e)},children:[F.enabled&&l.jsx("td",{children:(null===(n=F.renderCustomRowCheckbox)||void 0===n?void 0:n.call(F,e,i))||l.jsx(t.Checkbox,{checked:(null===(a=F.isRowChecked)||void 0===a?void 0:a.call(F,e,i))||!1,disabled:(null===(d=F.isRowCheckboxDisabled)||void 0===d?void 0:d.call(F,e,i))||!1,onChange:function(l){var o;return null===(o=F.onRowCheckboxChange)||void 0===o?void 0:o.call(F,l,e,i)}})}),v.map((function(i){return l.jsx(o.Fragment,{children:V(i,e)},i.key)}))]},j(e))}))}),P]})})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/amino",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "Core UI components for Amino",
5
5
  "repository": "git@github.com:Zonos/amino.git",
6
6
  "license": "MIT",
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("../storage.js");require("dayjs"),require("zod");var r=function(e){return function(t){return"local"===e&&window.addEventListener("storage",t),window.addEventListener("amino:storage-".concat(e),t),function(){"local"===e&&window.removeEventListener("storage",t),window.removeEventListener("amino:storage-".concat(e),t)}}};exports.useStorage=function(n){var a=n.defaultValue,o=n.key,u=n.schema,i=n.type,l=e.useMemo((function(){return r(i)}),[i]);e.useSyncExternalStore(l,(function(){return"local"===i?localStorage.getItem(o):sessionStorage.getItem(o)}),(function(){return JSON.stringify(a)}));var s=t.getStorageItem({key:o,schema:u,type:i})||null;return{setValue:e.useCallback((function(e){return t.setStorageItem({key:o,type:i,value:e})}),[o,i]),value:null!=s?s:a}},exports.useStorageWithLifetime=function(n){var a=n.defaultValue,o=n.key,u=n.lifetime,i=n.schema,l=n.type,s=e.useMemo((function(){return r(l)}),[l]);e.useSyncExternalStore(s,(function(){return"local"===l?localStorage.getItem(o):sessionStorage.getItem(o)}),(function(){return JSON.stringify(a)}));var c=t.getShouldUpdateStorageItem({key:o,schema:i,type:l})?null:t.getStorageItem({key:o,schema:i,type:l})||null;return{setValue:e.useCallback((function(e){return t.setStorageItemWithLifetime({key:o,lifetime:u,type:l,value:e})}),[o,l,u]),value:null!=c?c:a}};
1
+ "use strict";var e=require("react"),t=require("../storage.js");require("dayjs"),require("zod");var r=function(e){return function(t){return"local"===e&&window.addEventListener("storage",t),window.addEventListener("amino:storage-".concat(e),t),function(){"local"===e&&window.removeEventListener("storage",t),window.removeEventListener("amino:storage-".concat(e),t)}}};exports.useStorage=function(n){var a,o=n.defaultValue,u=n.key,i=n.schema,l=n.type,s=e.useMemo((function(){return r(l)}),[l]);e.useSyncExternalStore(s,(function(){return"local"===l?localStorage.getItem(u):sessionStorage.getItem(u)}),(function(){return JSON.stringify(o)}));var c=null!==(a=t.getStorageItem({key:u,schema:i,type:l}))&&void 0!==a?a:null;return{setValue:e.useCallback((function(e){return t.setStorageItem({key:u,type:l,value:e})}),[u,l]),value:null!=c?c:o}},exports.useStorageWithLifetime=function(n){var a,o=n.defaultValue,u=n.key,i=n.lifetime,l=n.schema,s=n.type,c=e.useMemo((function(){return r(s)}),[s]);e.useSyncExternalStore(c,(function(){return"local"===s?localStorage.getItem(u):sessionStorage.getItem(u)}),(function(){return JSON.stringify(o)}));var g=t.getShouldUpdateStorageItem({key:u,schema:l,type:s})?null:null!==(a=t.getStorageItem({key:u,schema:l,type:s}))&&void 0!==a?a:null;return{setValue:e.useCallback((function(e){return t.setStorageItemWithLifetime({key:u,lifetime:i,type:s,value:e})}),[u,s,i]),value:null!=g?g:o}};