@donotdev/crud 0.3.3 → 0.3.4
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/CrudService.cache.js +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.js +1 -1
- package/dist/components/form/fields/ComboboxComponent.js +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/DurationFieldComponent.js +1 -1
- package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/PriceFieldComponent.js +1 -1
- package/dist/components/form/fields/RadioFieldComponent.js +1 -1
- package/dist/components/form/fields/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/RatingFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.js +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/conditionAwareResolver.js +1 -1
- package/dist/forms/utils/emptyValue.js +1 -1
- package/dist/forms/utils/fieldErrorMessages.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as g}from"@donotdev/core";import{CRUD_OPERATION as y}from"./types";function h(
|
|
1
|
+
import{handleError as g}from"@donotdev/core";import{CRUD_OPERATION as y}from"./types";function h(u,s){return["crud",u,"query",JSON.stringify(s)]}function D(u,s,i){let t;for(const n of u.getQueryCache().findAll({queryKey:["crud",s,"query"]})){const a=n.state.data?.items?.find(r=>r!=null&&typeof r=="object"&&r.id===i);a&&(!t||n.state.dataUpdatedAt>t.updatedAt)&&(t={data:a,updatedAt:n.state.dataUpdatedAt})}return t}function A(u,s,i){return u.getQueryData(["crud",s,"get",i])!=null?!0:u.getQueriesData({queryKey:["crud",s]}).some(([,t])=>{const n=Array.isArray(t)?t:t!=null&&typeof t=="object"&&"items"in t?t.items:null;return Array.isArray(n)&&n.some(a=>a!=null&&typeof a=="object"&&a.id===i)})}function d(u,s,i,t,n){const a=u.getQueryClient(),r=["crud",s,"get",i];if(n===y.DELETE){const e=a.getQueryCache().find({queryKey:r,exact:!0});if(!e)return;if(e.getObserversCount()===0){a.removeQueries({queryKey:r,exact:!0});return}a.setQueryData(r,null),a.invalidateQueries({queryKey:r,exact:!0,refetchType:"none"})}else n===y.SET&&t?a.setQueryData(r,t):(n===y.UPDATE||n===y.ADD)&&t&&a.setQueryData(r,e=>e?{...e,...t}:t)}function E(u,s,i,t,n){const a=u.getQueryClient();d(u,s,i,t,n),a.setQueriesData({queryKey:["crud",s]},r=>{if(r&&typeof r=="object"&&"items"in r){const e=r;let o=e.items;return n===y.DELETE?(o=e.items.filter(l=>l!=null&&typeof l=="object"&&l.id!==i),o.length===e.items.length?r:{...e,items:o,...e.total===void 0?{}:{total:Math.max(0,e.total-1)}}):n===y.ADD&&t?(o=[...e.items,{...t,id:i}],{...e,items:o,total:(e.total??e.items.length)+1}):(n===y.UPDATE||n===y.SET)&&t&&e.items.some(l=>l!=null&&typeof l=="object"&&l.id===i)?(o=e.items.map(l=>l==null||typeof l!="object"||l.id!==i?l:n===y.SET?{...t,id:i}:{...l,...t}),{...e,items:o}):r}if(Array.isArray(r)){if(n===y.DELETE)return r.filter(e=>e.id!==i);if(n===y.ADD&&t)return[...r,{...t,id:i}];if((n===y.UPDATE||n===y.SET)&&t)return r.some(e=>e!=null&&typeof e=="object"&&e.id===i)?r.map(e=>e==null||typeof e!="object"||e.id!==i?e:n===y.SET?{...t,id:i}:{...e,...t}):r}return r})}function Q(u,s,i,t){const n=t.metadata?.uniqueKeys;if(!n||n.length===0)return null;const a=u.getQueryClient().getQueriesData({queryKey:["crud",s]}),r=[];for(const[,o]of a)o&&typeof o=="object"&&"items"in o?r.push(...o.items):Array.isArray(o)&&r.push(...o);if(r.length===0)return null;const e=i;for(const o of n){if(!o.fields.every(f=>e[f]!=null&&e[f]!==""))continue;const l=r.find(f=>o.fields.every(c=>{const m=typeof e[c]=="string"?e[c].toLowerCase():e[c],p=typeof f[c]=="string"?f[c].toLowerCase():f[c];return m===p}));if(l){if(o.findOrCreate)return l.id;const f=o.fields.join(" + ");throw g(new Error(o.errorMessage||`Duplicate ${f}`),{userMessage:o.errorMessage||`A record with this ${f} already exists`,showNotification:!0})}}return null}function C(u,s,i){const t=u.getQueryClient().getQueriesData({queryKey:["crud",s]});for(const[,n]of t)if(n?.items){const a=n.items.find(r=>r.id===i);if(a)return a}return null}async function q(u,s){await u.getQueryClient().invalidateQueries({queryKey:["crud",s]})}export{D as cachedListRow,Q as checkUniquenessFromCache,C as getItemFromListCache,q as invalidateCollectionImpl,A as isCachedRow,h as listQueryKey,d as updateGetCache,E as updateListCaches};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as l}from"@donotdev/core";import{assertCanAccess as p,decryptPiiRow as d,ensureAdapter as b}from"./CrudService.internal";import{listQueryKey as y}from"./CrudService.cache";function h(e,n,
|
|
1
|
+
import{handleError as l}from"@donotdev/core";import{assertCanAccess as p,decryptPiiRow as d,ensureAdapter as b}from"./CrudService.internal";import{listQueryKey as y}from"./CrudService.cache";function h(e,n,c,t,i){if(!e.adapter){let r=!1,o=null;return b(e).then(()=>{r||(o=m(e,n,c,t,i))}).catch(a=>{r||t(null,l(a))}),()=>{r=!0,o?.()}}return m(e,n,c,t,i)}function m(e,n,c,t,i){try{const r=e.adapter;return r?r.subscribe?(p(e.adapter,n,i),r.subscribe(n,c,(o,a)=>{const u=o&&d(e,i,o);u&&e.getQueryClient().setQueryData(["crud",n,"get",c],u),t(u,a)},i)):()=>{}:(t(null,new Error("Adapter not initialized")),()=>{})}catch(r){return t(null,l(r)),()=>{}}}function C(e,n,c,t,i){if(!e.adapter){let r=!1,o=null;return b(e).then(()=>{r||(o=f(e,n,c,t,i))}).catch(a=>{r||t([],l(a))}),()=>{r=!0,o?.()}}return f(e,n,c,t,i)}function f(e,n,c,t,i){try{const r=e.adapter;return r?r.subscribeToCollection?(p(e.adapter,n,i),r.subscribeToCollection(n,c,(o,a)=>{const u=o?.map(s=>d(e,i,s));u&&e.getQueryClient().setQueryData(y(n,c),s=>s?{...s,items:u}:{items:u}),t(u,a)},i)):()=>{}:(t([],new Error("Adapter not initialized")),()=>{})}catch(r){return t([],l(r)),()=>{}}}export{h as subscribeImpl,C as subscribeToCollectionImpl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as L,jsxs as D}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsx as L,jsxs as D}from"react/jsx-runtime";import{useState as z,useEffect as q,useRef as F,useCallback as Q}from"react";import{Combobox as K,Stack as W}from"@donotdev/components";import{useTranslation as X,getPlatformEnvVar as $}from"@donotdev/core";const Y="dndev-address-autocomplete-cache",ee=100;function te(){try{const a=typeof localStorage<"u"?localStorage.getItem(Y):null;if(a)return new Map(JSON.parse(a))}catch{}return new Map}function ae(a){try{typeof localStorage<"u"&&localStorage.setItem(Y,JSON.stringify([...a]))}catch{}}function Z(a){if(a.size>ee){const g=a.keys().next().value;g!==void 0&&a.delete(g)}}function v(){return window.google}const M=te(),G=new Map;function oe(a){const g={key:a,v:"weekly"},d="google",u="importLibrary",E="__ib__",b=document,p=window;p[d]=p[d]||{};const o=p[d].maps||(p[d].maps={}),x=new Set,s=new URLSearchParams,m=()=>o._p||(o._p=new Promise(async(r,A)=>{const i=b.createElement("script");s.set("libraries",[...x].join(","));for(const f of Object.keys(g))s.set(f.replace(/[A-Z]/g,S=>"_"+S[0].toLowerCase()),g[f]);s.set("callback",d+".maps."+E),i.src="https://maps.googleapis.com/maps/api/js?"+s,o[E]=r,i.onerror=()=>{o._p=null,A(new Error("Google Maps JS API could not load."))};const T=b.querySelector("script[nonce]");T?.nonce&&(i.nonce=T.nonce),b.head.append(i)}));o[u]||(o[u]=(r,...A)=>(x.add(r),m().then(()=>o[u](r,...A))))}const se=({label:a,info:g,value:d,onChange:u,enableGoogleMaps:E=!1,extractDistrictCode:b,error:p,helperText:o,required:x})=>{const{t:s}=X("crud"),[m,r]=z(d?.formatted_address||""),[A,i]=z([]),[T,f]=z(!1),[S,J]=z(!1),[P,N]=z(!1),k=F(null),C=F(null),I=$("GOOGLE_MAPS_API_KEY")||"",y=E&&!!I;q(()=>{const t=d?.formatted_address??"";r(e=>e===t?e:t)},[d]),q(()=>{if(!y||P)return;const t=v();if(t?.maps?.places?.AutocompleteSuggestion){k.current=new t.maps.places.AutocompleteSessionToken,N(!0);return}let e=!1;return(async()=>{try{if(v()?.maps?.importLibrary||oe(I),await v().maps.importLibrary("places"),e)return;k.current=new(v()).maps.places.AutocompleteSessionToken,N(!0)}catch{e||J(!0)}})(),()=>{e=!0}},[y,I,P]),q(()=>{if(!y||!P||S)return;if(m.length<3){i([]);return}const t=M.get(m);if(t){i(t);return}return C.current&&clearTimeout(C.current),C.current=setTimeout(async()=>{f(!0);try{const e=v().maps.places,{suggestions:h}=await e.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:m,sessionToken:k.current}),w=h.filter(n=>n.placePrediction).map(n=>{const c=n.placePrediction,l=[c.mainText?.text,c.secondaryText?.text].filter(Boolean).join(", ");return G.set(l,c),Z(G),{value:l,label:l}});i(w),M.set(m,w),Z(M),ae(M)}catch{J(!0),i([])}finally{f(!1)}},300),()=>{C.current&&clearTimeout(C.current)}},[y,P,S,m]);const R=Q(async t=>{const e=Array.isArray(t)?t[0]||"":t;if(!e)return;if(!y){r(e),u({formatted_address:e});return}let h=G.get(e);const w=v()?.maps?.places;if(w){if(!h){f(!0);try{const{suggestions:n}=await w.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:e,sessionToken:k.current}),c=n.find(l=>[l.placePrediction?.mainText?.text,l.placePrediction?.secondaryText?.text].filter(Boolean).join(", ")===e);c?.placePrediction&&(h=c.placePrediction,G.set(e,h))}catch{}if(!h){f(!1),r(e),u({formatted_address:e});return}}f(!0);try{const n=h.toPlace();await n.fetchFields({fields:["formattedAddress","location","addressComponents"]});const c=n.formattedAddress||e;let l=n.location?.lat()??0,O=n.location?.lng()??0;if(l===0&&O===0&&c)try{const j=await v().maps.importLibrary("geocoding"),_=(await new j.Geocoder().geocode({address:c})).results?.[0]?.geometry?.location;_&&(l=_.lat(),O=_.lng())}catch{}const B={formatted_address:c,latitude:l,longitude:O};if(b){const j=n.addressComponents||[],_=j.find(U=>(U.types||[]).includes("postal_code"))?.longText||j.find(U=>(U.types||[]).includes("postal_code"))?.long_name||"",H=_.startsWith("92")?92:parseInt(_.slice(-2),10)||null;B.district_code=H}r(c),i([]),u(B),k.current=new w.AutocompleteSessionToken}catch{r(e),u({formatted_address:e})}finally{f(!1)}}},[y,b,u]),V=t=>{r(t)};return y?D(W,{gap:"tight",children:[L(K,{label:a,info:g,value:m,onValueChange:R,onSearchChange:V,placeholder:s("address.placeholder","Enter address..."),emptyMessage:T?s("messages.loading","Loading..."):s("address.noResults","No addresses found"),options:A.map(t=>({value:t.value,label:t.label})),required:x,variant:p?"destructive":void 0,isLoading:T,creatable:!0,createLabel:s("actions.use","Use this address"),disabled:!P&&!S}),S&&L("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:s("address.apiUnavailable","Google Places unavailable \u2014 type address manually")}),o&&L("p",{style:{fontSize:"var(--font-size-xs)",color:p?"var(--destructive)":"var(--muted-foreground)"},children:o})]}):D(W,{gap:"tight",children:[L(K,{label:a,info:g,value:m,onValueChange:R,onSearchChange:V,placeholder:s("address.placeholder","Enter address..."),options:[],required:x,variant:p?"destructive":void 0,creatable:!0,createLabel:s("actions.use","Use this address")}),o&&L("p",{style:{fontSize:"var(--font-size-xs)",color:p?"var(--destructive)":"var(--muted-foreground)"},children:o})]})};var re=se;export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useMemo as N,useId as T}from"react";import{Combobox as $,Stack as d}from"@donotdev/components";import{useTranslation as k}from"@donotdev/core";const I=({label:u,info:p,value:l,options:s,error:m,helperText:
|
|
1
|
+
import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useMemo as N,useId as T}from"react";import{Combobox as $,Stack as d}from"@donotdev/components";import{useTranslation as k}from"@donotdev/core";const I=({label:u,info:p,value:l,options:s,error:m,helperText:r,onChange:n,onBlur:f,required:h,placeholder:v,translationNamespace:g="dndev",placeholderKey:b="actions.select",placeholderDefault:x="Select",creatable:y=!1,createLabel:S,emptyMessage:C})=>{const{t:a}=k(g),i=T(),z=N(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),A=e=>{if(n){const L={target:{value:Array.isArray(e)?e[0]||"":e}};n(L)}},M=e=>{e||f?.()},t=!!m,j=`${i}-error`,q=`${i}-helper`;return c(d,{gap:"tight",children:[o($,{label:u,info:p,value:l||"",onValueChange:A,onOpenChange:M,placeholder:v||a(b,x),emptyMessage:C||a("messages.noResults","No results found"),creatable:y,createLabel:S||a("actions.create","Create"),options:z,required:h,variant:t?"destructive":void 0,clearable:!!l}),t&&c(d,{id:j,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[o("span",{children:"\u26A0"}),r]}),r&&!t&&o("p",{id:q,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:r})]})};var O=I;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as h,useEffect as
|
|
1
|
+
import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as h,useEffect as z,useId as C}from"react";import{Input as L,FloatingLabel as M,Stack as U}from"@donotdev/components";const B=({label:b,info:x,value:a,onChange:F,currency:l="EUR",locale:I,error:i,helperText:c,required:N=!1,disabled:u=!1,placeholder:S})=>{const d=C(),E=I||(typeof navigator<"u"?navigator.language:"en-US"),o=e=>e==null||isNaN(e)?"":(e/100).toString(),p=e=>{if(!e||e.trim()==="")return null;const r=e.replace(/[^\d.,\-]/g,"").replace(",","."),t=parseFloat(r);return isNaN(t)?null:Math.round(t*100)},[v,s]=h(o(a)),[g,m]=h(!1);z(()=>{g?p(v)!==a&&s(o(a)):s(o(a))},[a,g]);const T=e=>{const r=e.target.value;s(r);const t={target:{value:p(r)}};F(t)},j=()=>m(!0),q=()=>m(!1),f=(()=>{try{return new Intl.NumberFormat(E,{style:"currency",currency:l,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||l}catch{return l}})();return y(U,{gap:"tight",children:[n(M,{htmlFor:d,label:b,info:x,disabled:u,required:N,children:y("div",{style:{position:"relative"},children:[n("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:f}),n(L,{id:d,type:"text",inputMode:"decimal",bare:!0,value:v,onChange:T,onFocus:j,onBlur:q,disabled:u,placeholder:S||"0","data-variant":i?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${f.length*.6}em + var(--gap-sm))`}})]})}),c&&n("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:c})]})};var D=B;export{D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n,jsxs as s}from"react/jsx-runtime";import{useId as z}from"react";import{DatePicker as x,DateTimePicker as y,Input as w,cn as
|
|
1
|
+
import{jsx as n,jsxs as s}from"react/jsx-runtime";import{useId as z}from"react";import{DatePicker as x,DateTimePicker as y,Input as w,cn as h,Stack as c}from"@donotdev/components";import{useTranslation as I}from"@donotdev/core";function D(a){const l=u=>String(u).padStart(2,"0");return`${a.getFullYear()}-${l(a.getMonth()+1)}-${l(a.getDate())}T${l(a.getHours())}:${l(a.getMinutes())}`}const O=({label:a,info:l,value:u,onChange:v,error:g,helperText:i,mode:o="date",required:p,...S})=>{const r=z(),e=!!g,{t:f}=I("crud"),m=t=>{const b=t.target.value?new Date(t.target.value).toISOString():null;v(b)},$=t=>{v(t?new Date(t).toISOString():null)};let d="";if(u){const t=new Date(u);o==="date"?d=t.toISOString().split("T")[0]||"":o==="datetime-local"?d=D(t):o==="month"?d=t.toISOString().slice(0,7):o==="time"?d=t.toISOString().slice(11,16):o==="week"&&(d=t.toISOString().split("T")[0]||"")}return o==="date"?s(c,{gap:"tight",children:[n(x,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:l,value:u??null,onChange:v,required:p,"aria-describedby":h(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):o==="datetime-local"?s(c,{gap:"tight",children:[n(y,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:l,value:d||null,onChange:$,required:p,"aria-describedby":h(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):s(c,{gap:"tight",children:[n(w,{id:r,label:a,info:l,type:o,value:d,onChange:m,required:p,"aria-describedby":h(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...S}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})};var T=O;export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as v}from"react/jsx-runtime";import{Select as d,Stack as m}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";const h=({label:o,info:n,value:r,options:s,error:i,helperText:a,onChange:l,onBlur:u,required:c})=>{const{t:p}=f("crud"),g=r!=null?String(r):"";return v(m,{gap:"tight",children:[t(d,{label:o,info:n,value:g,onValueChange:e=>{l&&l({target:{value:e}})},onOpenChange:e=>!e&&u?.(),placeholder:p("actions.select","Select"),required:c,options:s.map(e=>({value:String(e.value),label:e.label}))}),a&&t("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var S=h;export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as k,useMemo as w}from"react";import{Label as S,Stack as u,Button as $,Slider as N}from"@donotdev/components";const p=[15,30,45,60,90,120,150,180],q={15:"duration.15m",30:"duration.30m",45:"duration.45m",60:"duration.1h",90:"duration.1h30",120:"duration.2h",150:"duration.2h30",180:"duration.3h"};function W(e,o){const n=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,s=q[e];return!o||!s?n:o(`crud:${s}`,{defaultValue:n})??n}const j=({label:e,value:o,onChange:n,error:s,helperText:l,disabled:m,required:f,readonly:M,min:g=0,max:v=480,step:T=5,t:i})=>{const r=typeof o=="number"&&!Number.isNaN(o)?o:0,c=p.includes(r),[h,b]=k(!c&&r>0),C=w(()=>p.map(a=>({minutes:a,label:W(a,i)})),[i]),y=i?i("crud:duration.custom"):"Custom";if(M){const a=r===0?i?i("crud:duration.zero"):"\u2014":r<60?i?i("crud:duration.minutes",{count:r}):`${r} min`:i?i("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return d(u,{gap:"tight",children:[t(S,{required:f,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",children:[t(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),t("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),l&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})}return d(u,{children:[t(S,{required:f,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[C.map(({minutes:a,label:z})=>d($,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),n(a)},"aria-pressed":r===a,"aria-label":z,children:[t(x,{size:14,style:{marginRight:"var(--gap-sm)"},"aria-hidden":!0}),z]},a)),t($,{type:"button",variant:h?"primary":"outline",disabled:m,onClick:()=>{b(!0),!c&&r>0?n(r):n(30)},"aria-pressed":h,"aria-label":y,children:y})]}),h&&t(u,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:t(N,{value:[c?30:r],onValueChange:([a])=>n(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:T,showValue:!0,disabled:m,"aria-label":e})}),l&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var E=j;export{p as DURATION_PRESETS,E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as u}from"react/jsx-runtime";import{Label as b,Input as v,Stack as c}from"@donotdev/components";const h=({label:g,value:a={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:m})=>{const f=l=>{const e=parseFloat(l.target.value)||0;if(e>=-90&&e<=90){const n={...a,lat:e},s={target:{value:JSON.stringify(n)}};i(s)}},p=l=>{const e=parseFloat(l.target.value)||0;if(e>=-180&&e<=180){const n={...a,lng:e},s={target:{value:JSON.stringify(n)}};i(s)}};return u(c,{gap:"tight",children:[t(b,{required:m,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:g}),u(c,{direction:"row",children:[t(v,{label:"Latitude",type:"number",value:a.lat,onChange:f,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),t(v,{label:"Longitude",type:"number",value:a.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&t("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var y=h;export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as s,Fragment as Z}from"react/jsx-runtime";import{DndContext as _,closestCenter as Q,PointerSensor as ee,TouchSensor as re,useSensor as A,useSensors as te}from"@dnd-kit/core";import{SortableContext as
|
|
1
|
+
"use client";import{jsx as r,jsxs as s,Fragment as Z}from"react/jsx-runtime";import{DndContext as _,closestCenter as Q,PointerSensor as ee,TouchSensor as re,useSensor as A,useSensors as te}from"@dnd-kit/core";import{SortableContext as ae,useSortable as ie,rectSortingStrategy as oe,arrayMove as ne}from"@dnd-kit/sortable";import{CSS as se}from"@dnd-kit/utilities";import{Upload as le,X as U,Loader2 as de,GripVertical as ce}from"lucide-react";import{forwardRef as pe,useCallback as P,useImperativeHandle as ue,useRef as ge,useState as j}from"react";import{Text as m,Stack as C,Progress as me,handleImageError as he}from"@donotdev/components";import{useTranslation as ve}from"@donotdev/core";import{useFileUpload as fe}from"../../../hooks/useFileUpload";import{processImage as ye}from"../../../utils/imageProcessing";import{uploadImage as be}from"../../../utils/imageStorage";import{ImageViewerDialog as xe}from"../internal/ImageViewerDialog";const we=["image/*"];function Ce(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function Se({file:t,index:h,multiple:v,onImageClick:S,onRemove:f,t:l}){const{attributes:n,listeners:k,setNodeRef:I,transform:d,transition:D,isDragging:y}=ie({id:t.id}),c=t.progress!==null&&t.progress<100,p=v&&!c,b={transform:se.Transform.toString(d),transition:D,position:"relative",width:100,height:100,borderRadius:"var(--radius-md)",border:"var(--border-width) solid var(--border)",overflow:"hidden",backgroundColor:"var(--surface)",opacity:y?.5:1,cursor:p?"grab":"pointer",userSelect:"none",touchAction:p?"none":"auto"};return r("div",{ref:I,style:b,...n,...p?k:{},onClick:()=>{y||S(h)},children:c?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(de,{style:{animation:"spin 1s linear infinite"}}),r(me,{value:t.progress||0,style:{width:"80%"}})]}):t.error?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(U,{style:{color:"var(--destructive)"}}),r(m,{variant:"destructive",level:"small",children:t.error})]}):s(Z,{children:[v&&r("div",{style:{position:"absolute",top:4,left:4,padding:2,background:"rgba(0,0,0,0.5)",borderRadius:"var(--radius-sm)",display:"flex",zIndex:2,pointerEvents:"none"},children:r(ce,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:l("image.alt.upload",{index:h+1}),draggable:!1,onError:he,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:i=>{i.stopPropagation(),f(t.id)},onPointerDown:i=>i.stopPropagation(),style:{position:"absolute",top:4,right:4,padding:4,background:"rgba(0,0,0,0.5)",border:"none",borderRadius:"var(--radius-sm)",cursor:"pointer",display:"flex",zIndex:2},children:r(U,{style:{color:"white",width:16,height:16}})}),!t.uploaded&&r("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:4,background:"rgba(0,0,0,0.7)",textAlign:"center",pointerEvents:"none"},children:r(m,{variant:"muted",level:"small",style:{color:"white"},children:l("image.upload.pending")})})]})})}const L=pe(({name:t="image",label:h,value:v,onChange:S,error:f,helperText:l,multiple:n=!1,maxFiles:k=10,maxSize:I=10*1024*1024,storagePath:d,required:D,capture:y,processing:c},p)=>{const{t:b}=ve("crud"),i=ge(null),[N,F]=j(!1),[B,E]=j(0),M=te(A(ee,{activationConstraint:{distance:8}}),A(re,{activationConstraint:{delay:200,tolerance:5}})),V=P(async(e,a)=>{const{fullBlob:u,thumbBlob:x}=await ye(e,c);return be(u,x,e.name,{storagePath:d,onProgress:w=>a(w.progress)})},[d,c]),{files:o,addFiles:R,removeFile:T,reorderFiles:z}=fe({name:t,value:v,onChange:S,multiple:n,maxFiles:k,maxSize:I,accept:we,storagePath:d,uploadFn:V}),q=e=>{const a=Array.from(e.target.files||[]);a.length>0&&R(a),i.current&&(i.current.value="")},G=P(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&R(Array.from(e.dataTransfer.files))},[R]),H=P(e=>{const{active:a,over:u}=e;if(u&&a.id!==u.id){const x=o.findIndex(g=>g.id===a.id),w=o.findIndex(g=>g.id===u.id);if(x!==-1&&w!==-1){const g=ne(o.map(Y=>Y.id),x,w);z(g)}}},[o,z]),K=e=>{E(e),F(!0)},O=(e,a)=>{},W=e=>{const a=o[e];a&&T(a.id)},X=e=>{E(e)},$=n||o.length===0;ue(p,()=>({upload:async()=>{},focus:()=>i.current?.focus()}),[]);const J=o.map(Ce);return s(C,{gap:"tight",children:[s(m,{level:"body",textAlign:"start",children:[h,D&&"*"]}),$&&s("div",{role:"button",tabIndex:0,onClick:()=>i.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&i.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:G,style:{border:`var(--border-width) dashed ${f?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:i,type:"file",accept:"image/*",capture:y,multiple:n,style:{display:"none"},onChange:q}),s(C,{align:"center",children:[r(le,{style:{color:"var(--muted-foreground)"}}),r(m,{variant:"muted",level:"small",children:b(n?"image.upload.dropzoneMultiple":"image.upload.dropzoneSingle")})]})]}),o.length>0&&r(_,{sensors:M,collisionDetection:Q,onDragEnd:H,children:r(ae,{items:o.map(e=>e.id),strategy:oe,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:o.map((e,a)=>r(Se,{file:e,index:a,multiple:n,onImageClick:K,onRemove:T,t:b},e.id))})})}),l&&r(m,{variant:f?"destructive":"muted",level:"small",children:l}),r(xe,{images:J,selectedIndex:B,open:N,onClose:()=>F(!1),onUpdate:O,onDelete:W,onNavigate:X,multiple:n})]})});L.displayName="ImageFieldComponent";var ke=L;export{ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as o,Fragment as J}from"react/jsx-runtime";import{useMemo as M,useId as R}from"react";import{Combobox as $,Tag as p,Stack as h}from"@donotdev/components";import{useTranslation as B}from"@donotdev/core";const u=4,v=3,F=({label:f,info:b,value:a=[],options:n,error:S,helperText:i,onChange:d,onBlur:x,required:y,className:z})=>{const{t:g}=B("crud"),m=R(),N=M(()=>n.map(e=>({value:String(e.value),label:e.label})),[n]),C=e=>{const s=Array.isArray(e)?e:[e],r={target:{value:JSON.stringify(s)}};d(r)},O=e=>{e||x?.()},A=e=>{const s=a.filter(c=>c!==e),r={target:{value:JSON.stringify(s)}};d(r)},l=!!S,T=`${m}-error`,j=`${m}-helper`,q=a.length>0?o(J,{children:[a.slice(0,a.length>u?v:u).map((e,s)=>{const r=n.find(c=>String(c.value)===e)?.label||e;return t(p,{size:"sm",onRemove:()=>A(e),children:r},s)}),a.length>u&&o(p,{size:"sm",variant:"outline",disabled:!0,children:["+",a.length-v," more"]})]}):void 0;return o(h,{gap:"tight",className:z,children:[t($,{label:f,info:b,value:a,onValueChange:C,onOpenChange:O,placeholder:g("actions.selectOptions","Select options..."),emptyMessage:g("messages.noResults","No results found"),options:N,multiple:!0,required:y,variant:l?"destructive":void 0,chips:q}),l&&o(h,{id:T,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[t("span",{children:"\u26A0"}),i]}),i&&!l&&t("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})};var V=F;export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as v,jsxs as q}from"react/jsx-runtime";import{useState as z,useEffect as D,useCallback as f}from"react";import{Input as E,cn as I,Stack as L}from"@donotdev/components";import{useTranslation as M}from"@donotdev/core";const P=({label:b,info:x,value:l,onChange:i,error:c,helperText:g,min:y,max:N,step:S,disabled:s,required:h,className:
|
|
1
|
+
import{jsx as v,jsxs as q}from"react/jsx-runtime";import{useState as z,useEffect as D,useCallback as f}from"react";import{Input as E,cn as I,Stack as L}from"@donotdev/components";import{useTranslation as M}from"@donotdev/core";const P=({label:b,info:x,value:l,onChange:i,error:c,helperText:g,min:y,max:N,step:S,disabled:s,required:h,className:F,mask:r="number",...T})=>{const{i18n:k}=M(),n=k?.language||(typeof navigator<"u"?navigator.language:"en-US"),u=f(e=>e==null||isNaN(e)?"":r==="currency"?e.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2}):r==="mileage"?Math.round(e).toLocaleString(n):e.toString(),[r,n]),w=f(e=>{if(!e||e.trim()==="")return null;const t=new Intl.NumberFormat(n).formatToParts(1234.56),a=t.find(m=>m.type==="group")?.value||",",j=t.find(m=>m.type==="decimal")?.value||".";let o=e.replace(new RegExp(`\\${a}`,"g"),"");o=o.replace(j,"."),o=o.replace(/[^\d.\-]/g,"");const p=parseFloat(o);return isNaN(p)?null:p},[n]),[C,d]=z(()=>u(l));return D(()=>{d(u(l))},[l,u]),q(L,{gap:"tight",children:[v(E,{type:r==="number"?"number":"text",inputMode:r==="number"?void 0:"decimal",label:b,info:x,value:C,onChange:e=>{const t=e.target.value;if(d(t),r==="number"){const a=parseFloat(t);isNaN(a)?i(e):i({...e,target:{...e.target,value:a.toString()}})}else{const a=w(t);a!==null?i({...e,target:{...e.target,value:a.toString()}}):t===""&&i({...e,target:{...e.target,value:""}})}},min:y,max:N,step:S,disabled:s,required:h,className:I("dndev-w-full",F),"data-variant":c?"destructive":void 0,style:{opacity:s?"var(--opacity-muted)":void 0,cursor:s?"not-allowed":void 0},...T}),g&&v("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:g})]})};var H=P;export{H as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as d}from"react/jsx-runtime";import{useId as u}from"react";import{PasswordInput as f,Stack as m}from"@donotdev/components";const p=({label:o,info:s,value:t,onChange:n,error:
|
|
1
|
+
"use client";import{jsx as a,jsxs as d}from"react/jsx-runtime";import{useId as u}from"react";import{PasswordInput as f,Stack as m}from"@donotdev/components";const p=({label:o,info:s,value:t,onChange:n,error:i,helperText:e,...r})=>{const l=u();return d(m,{gap:"tight",children:[a(f,{id:l,value:t??"",onChange:n,label:o,info:s,className:"dndev-w-full",required:r.required,...r}),e&&a("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:e})]})};var c=p;export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{useState as E,useMemo as p,useEffect as U,useId as V}from"react";import{Input as
|
|
1
|
+
"use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{useState as E,useMemo as p,useEffect as U,useId as V}from"react";import{Input as q,FloatingLabel as D,Button as G,BUTTON_VARIANT as H,DropdownMenu as P,Stack as g,cn as _}from"@donotdev/components";import{Flag as T,COUNTRIES as N}from"@donotdev/core";const J=/[\s.-]/g;function W(v,c){let t=v.replace(J,"");if(t.startsWith("00")&&(t=`+${t.slice(2)}`),t.startsWith(c))t=t.slice(c.length);else if(t.startsWith("+"))return t;return t.startsWith("0")&&(t=t.slice(1)),t?`${c} ${t}`:""}const K=({label:v,info:c,value:t="",onChange:x,name:z,onBlur:B,ref:k,error:S,helperText:b,required:A=!1,disabled:C=!1,defaultCountry:$="FR",showFlags:w=!0,preferredCountries:u,countries:h})=>{const o=V(),m=p(()=>h&&h.length>0?h.map(e=>N.find(r=>r.code===e)).filter(e=>e!==void 0):Array.from(N),[h]),d=p(()=>{if(!u||u.length===0)return m;const e=u.map(a=>m.find(j=>j.code===a)).filter(a=>a!==void 0),r=m.filter(a=>!u.includes(a.code));return[...e,...r]},[m,u]),f=p(()=>d.find(e=>e.code===$)||d[0]||N[0],[$,d]),{country:y,phoneNumber:I}=p(()=>{if(!t)return{country:f,phoneNumber:""};const e=d.find(a=>t.startsWith(a.dialCode));if(e){let a=t.slice(e.dialCode.length).trim();return a.startsWith("0")&&(a=a.slice(1).trim()),a=a.replace(/\s+/g," ").trim(),{country:e,phoneNumber:a}}if(t.startsWith("+"))return{country:f,phoneNumber:t};let r=t.trim();return r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim(),{country:f,phoneNumber:r}},[t,f,d]),[n,F]=E(f);U(()=>{t&&y.code!==n.code&&F(y)},[t,y,n.code]);const R=I,L=e=>{F(e);const r={target:{value:W(R,e.dialCode)}};x(r)},M=e=>{const r={target:{value:W(e.target.value,n.dialCode)}};x(r)},O=d.map(e=>({label:e.dialCode,onClick:()=>L(e),checked:e.code===n.code,children:w?s(g,{direction:"row",align:"center",gap:"tight",children:[i(T,{code:e.flagCode,title:e.name}),i("span",{children:e.dialCode}),i("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-xs)"},children:e.name})]}):s("span",{children:[e.dialCode," ",e.name]})})),l=!!S;return s(g,{gap:"tight",children:[i(D,{htmlFor:o,label:v,info:c,disabled:C,required:A,children:s("div",{className:"dndev-relative",style:{display:"flex",gap:0},children:[i(P,{trigger:i(G,{type:"button",variant:H.GHOST,disabled:C,style:{minWidth:"fit-content",padding:"0 var(--gap-md)"},"aria-label":`Country code: ${n.dialCode}`,children:s(g,{direction:"row",align:"center",gap:"tight",children:[w&&i(T,{code:n.flagCode,title:n.name}),i("span",{children:n.dialCode})]})}),items:O,contentWidth:"16rem"}),i(q,{ref:k,name:z,onBlur:B,id:o,type:"tel",inputMode:"tel",value:R,onChange:M,disabled:C,placeholder:"6 12 34 56 78",bare:!0,"data-variant":l?"destructive":void 0,className:"dndev-flex-1",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderRadius:"0 var(--radius-md) var(--radius-md) 0"},"aria-describedby":_(l&&`${o}-error`,b&&!l&&`${o}-helper`),"aria-invalid":l})]})}),l&&s(g,{id:`${o}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[i("span",{children:"\u26A0"}),S]}),b&&!l&&i("p",{id:`${o}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:b})]})};var Q=K;export{Q as default,W as toPhoneValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as l,jsxs as c}from"react/jsx-runtime";import{CirclePlus as q,CircleMinus as z}from"lucide-react";import{useId as E,useState as B}from"react";import{Input as f,Checkbox as D,Stack as G,Select as H,CollapsiblePrimitive as J,CollapsibleTrigger as K,CollapsibleContent as L}from"@donotdev/components";import{useTranslation as O,getCurrencySymbol as V}from"@donotdev/core";const Y=["EUR","USD","GBP","CHF","JPY","KRW"],w=({label:y,info:I,value:
|
|
1
|
+
"use client";import{jsx as l,jsxs as c}from"react/jsx-runtime";import{CirclePlus as q,CircleMinus as z}from"lucide-react";import{useId as E,useState as B}from"react";import{Input as f,Checkbox as D,Stack as G,Select as H,CollapsiblePrimitive as J,CollapsibleTrigger as K,CollapsibleContent as L}from"@donotdev/components";import{useTranslation as O,getCurrencySymbol as V}from"@donotdev/core";const Y=["EUR","USD","GBP","CHF","JPY","KRW"],w=({label:y,info:I,value:n,onChange:P,error:s,helperText:g,required:N=!1,disabled:o=!1,placeholder:x="0",defaultCurrency:i="EUR",optionsTitle:S="Price options",currencies:b})=>{const u=E(),{t:p}=O("crud"),r=b?.length?b:[...Y],h=n?.currency??i,m=r.includes(h)?h:r[0]??i,T=n?.vatIncluded??!0,C=n?.discountPercent??0,k=`${y} (${V(m)})`,d=e=>{const a=e.amount!==void 0?e.amount:n?.amount??null;let t=e.currency!==void 0?e.currency:n?.currency??i;r.includes(t)||(t=m);const R=e.vatIncluded!==void 0?e.vatIncluded:n?.vatIncluded??!0,U=e.discountPercent!==void 0?e.discountPercent:n?.discountPercent??0;P({amount:a===null?null:Number(a),currency:t,vatIncluded:R,discountPercent:Number(U)})},$=e=>{const a=e.target.value;if(a===""||a===null){d({amount:null});return}const t=parseFloat(a);d({amount:isNaN(t)?null:t})},j=e=>{d({currency:e||i})},F=e=>{const a=e.target.value;if(a===""||a===null){d({discountPercent:0});return}const t=parseFloat(a);d({discountPercent:isNaN(t)?0:t})},[v,M]=B(!1);return c(J,{open:v,onOpenChange:M,children:[c(G,{children:[c("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"var(--gap-sm)",alignItems:"end"},children:[l(f,{id:u,type:"number",inputMode:"decimal",label:k,info:I,value:n?.amount!==void 0&&n?.amount!==null?n.amount:"",onChange:$,disabled:o,placeholder:x,required:N,min:0,step:.01,"data-variant":s?"destructive":void 0,"aria-invalid":s}),l(K,{asChild:!0,children:l("button",{type:"button","aria-label":S,"aria-expanded":v,className:"dndev-collapsible-trigger",style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"var(--gap-sm)",background:"none",border:"none",cursor:"pointer"},children:v?l(z,{className:"dndev-collapsible-icon","aria-hidden":"true"}):l(q,{className:"dndev-collapsible-icon","aria-hidden":"true"})})})]}),l(L,{className:"dndev-collapsible-content",children:c("div",{style:{display:"grid",gridTemplateColumns:r.length>1?"1fr auto 1fr":"auto 1fr",gap:"var(--gap-sm)",alignItems:"end",paddingTop:"var(--gap-md)"},children:[r.length>1&&l(H,{value:m,onValueChange:j,placeholder:i,options:r.map(e=>({value:e,label:e})),disabled:o,label:p("price.currency")}),l(D,{id:`${u}-vat`,label:p("price.vatIncluded"),checked:T,onCheckedChange:e=>d({vatIncluded:e===!0}),disabled:o}),l(f,{id:`${u}-discount`,type:"number",inputMode:"decimal",min:0,max:100,step:1,value:C===0?"":C,onChange:F,disabled:o,placeholder:"0",label:p("price.discountLabel")})]})})]}),g&&l("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive)":"var(--muted-foreground)"},children:g})]})};var A=w;export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as d}from"react/jsx-runtime";import{RadioGroup as p,Label as c,Stack as f}from"@donotdev/components";const v=({label:t,value:a,onChange:o,options:s,error:i,helperText:r,required:
|
|
1
|
+
import{jsx as e,jsxs as d}from"react/jsx-runtime";import{RadioGroup as p,Label as c,Stack as f}from"@donotdev/components";const v=({label:t,value:a,onChange:o,options:s,error:i,helperText:r,required:n})=>{const l=u=>{o({target:{value:u}})};return d(f,{gap:"tight",children:[e(c,{required:n,style:{display:"block",fontSize:"var(--font-size-input)",fontWeight:500},children:t}),e(p,{value:a,onValueChange:l,items:s}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive)":"var(--muted-foreground)"},children:r})]})};var h=v;export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Label as h,Slider as b,Stack as d}from"@donotdev/components";const x=({label:o,value:i=0,onChange:c,error:n,helperText:s,min:r=0,max:u=100,step:v=1,disabled:t,required:m,showValue:f=!0})=>{const g=a=>{const p={target:{value:a.toString()}};c(p)};return l(d,{gap:"tight",children:[l(d,{direction:"row",justify:"between",align:"center",children:[e(h,{required:m,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:o}),f&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:i})]}),e(b,{value:[i??r],onValueChange:([a])=>g(a??r),min:r,max:u,step:v,disabled:t,style:{borderColor:n?"var(--destructive)":void 0,opacity:t?"var(--opacity-muted)":void 0,cursor:t?"not-allowed":void 0},"aria-label":o}),s&&e("p",{style:{fontSize:"var(--font-size-xs)",color:n?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:s})]})};var y=x;export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as u}from"react/jsx-runtime";import{Label as f,Rating as g,Stack as
|
|
1
|
+
import{jsx as e,jsxs as u}from"react/jsx-runtime";import{Label as f,Rating as g,Stack as m}from"@donotdev/components";const v=({label:a,value:o=0,onChange:s,error:l,helperText:r,max:t=5,disabled:i,required:n,readonly:d,showValue:h=!1})=>u(m,{gap:"tight",children:[e(f,{required:n,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:a}),e(g,{value:o,onChange:s,max:t,disabled:i,readonly:d,showValue:h,"aria-label":a}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]});var p=v;export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as A,useId as $}from"react";import{Combobox as j,Stack as c}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";const L=({label:r,info:p,value:
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as A,useId as $}from"react";import{Combobox as j,Stack as c}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";const L=({label:r,info:p,value:i,onChange:u,options:s,isLoading:f=!1,error:h,helperText:o,required:m,onBlur:g,onCreate:I,placeholder:v})=>{const{t:l}=q("crud"),n=$(),b=A(()=>s.map(e=>({value:e.id,label:e.label,description:e.description})),[s]),x=e=>{const S=Array.isArray(e)?e[0]||"":e;u(S)},y=e=>{e||g?.()},a=!!h,C=`${n}-error`,z=`${n}-helper`;return d(c,{gap:"tight",children:[t(j,{label:r,info:p,value:i||"",onValueChange:x,onOpenChange:y,placeholder:v||l("reference.placeholder",{label:r})||`Select ${r}`,emptyMessage:l("reference.noResults")||"No results found",options:b,required:m,variant:a?"destructive":void 0,isLoading:f,clearable:!!i}),a&&d(c,{id:C,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[t("span",{children:"\u26A0"}),o]}),o&&!a&&t("p",{id:z,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var M=L;export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as N,useId as F,useRef as j,useEffect as q}from"react";import{Textarea as A,FloatingLabel as R,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,info:b,value:s="",onChange:y,error:h,helperText:o,rows:z=3,loading:l=!1,maxLength:
|
|
1
|
+
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as N,useId as F,useRef as j,useEffect as q}from"react";import{Textarea as A,FloatingLabel as R,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,info:b,value:s="",onChange:y,error:h,helperText:o,rows:z=3,loading:l=!1,maxLength:a,showCharCount:v=!1,autoResize:i=!1,required:w=!1,disabled:g=!1,className:$,...S})=>{const e=F(),[I,f]=N(!1),d=j(null),r=!!h,c=s.length,C=a&&c>a*.8,L=a&&c>a;return q(()=>{if(i&&d.current){const u=d.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[s,i]),n(p,{gap:"tight",children:[t(R,{htmlFor:e,label:x,info:b,disabled:g||l,required:w,children:n("div",{className:"dndev-relative",children:[t(A,{ref:d,id:e,value:s,onChange:y,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||l,maxLength:a,rows:i?1:z,bare:!0,"aria-describedby":m(r&&`${e}-error`,o&&!r&&`${e}-helper`,v&&`${e}-count`),"aria-invalid":r,className:m("dndev-w-full",i&&"dndev-overflow-hidden",$),"data-variant":r?"destructive":void 0,style:{resize:i?"none":void 0},...S}),l&&t("div",{className:"dndev-absolute",style:{right:"var(--gap-md)",top:"var(--gap-md)"},children:t(k,{"aria-label":"Loading"})})]})}),v&&a&&n("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:L?"var(--destructive)":C?"var(--warning)":"var(--muted-foreground)"},children:[c,"/",a]}),r&&n(p,{as:"p",id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[t("span",{children:"\u26A0"}),h]}),o&&!r&&t("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var E=B;export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,jsxs as o}from"react/jsx-runtime";import{useId as S}from"react";import{Input as j,cn as c,Stack as u}from"@donotdev/components";function q({label:h,info:v,value:l="",onChange:f,error:d,helperText:
|
|
1
|
+
"use client";import{jsx as n,jsxs as o}from"react/jsx-runtime";import{useId as S}from"react";import{Input as j,cn as c,Stack as u}from"@donotdev/components";function q({label:h,info:v,value:l="",onChange:f,error:d,helperText:i,type:g="text",loading:p=!1,maxLength:e,showCharCount:s=!1,required:m=!1,disabled:x=!1,className:$,ref:b,...y}){const r=S(),t=!!d,a=l.length,z=e&&a>e*.8,w=e&&a>e,{children:I,...C}=y;return o(u,{gap:"tight",children:[n(j,{ref:b,id:r,type:g,value:l,onChange:f,label:h,info:v,disabled:x||p,maxLength:e,required:m,"aria-describedby":c(t&&`${r}-error`,i&&!t&&`${r}-helper`,s&&`${r}-count`),"aria-invalid":t,className:c("dndev-w-full",$),"data-variant":t?"destructive":void 0,...C}),s&&e&&o("div",{id:`${r}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:w?"var(--destructive)":z?"var(--warning)":"var(--muted-foreground)"},children:[a,"/",e]}),t&&o(u,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[n("span",{children:"\u26A0"}),d]}),i&&!t&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})}var A=q;export{A as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as
|
|
1
|
+
"use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as M}from"@donotdev/components";const x=({label:s,value:e="",onChange:d,error:r,helperText:n,required:t,disabled:a,placeholder:l,className:c,modules:g})=>{const{useEditor:v,EditorContent:p,StarterKit:h,Placeholder:b}=g,o=v({extensions:[h.configure({heading:{levels:[1,2,3]}}),b.configure({placeholder:l||"Start typing..."})],content:e,editable:!a,onUpdate:({editor:P})=>{const y={target:{value:P.getHTML()}};d(y)}});return u(()=>{o&&e!==o.getHTML()&&o.commands.setContent(e||"")},[e,o]),o?m(M,{gap:"tight",children:[m("label",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:r?"var(--destructive)":"var(--foreground)"},children:[s,t&&i("span",{style:{color:"var(--destructive)"},children:" *"})]}),i("div",{className:c,"data-variant":r?"destructive":void 0,style:{border:"var(--border-hairline) solid",borderColor:r?"var(--destructive)":"var(--line-2)",borderRadius:"var(--radius-interactive)",padding:"var(--gap-md)",minHeight:"200px",backgroundColor:a?"var(--muted)":"transparent",opacity:a?"var(--opacity-muted)":void 0},children:i(p,{editor:o})}),n&&i("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive)":"var(--muted-foreground)"},children:n}),i("style",{children:`
|
|
2
2
|
.ProseMirror {
|
|
3
3
|
outline: none;
|
|
4
4
|
min-height: 150px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStatus as p}from"@donotdev/core";import{EMPTY_VALUE as d}from"./emptyValue";const b=new Set(["text","textarea","email","url","tel","iban","password","color"]);function a(s,i,c){const{fields:l,keepId:f=!1}=c,t=Object.fromEntries(Object.entries(i).filter(([e])=>l.has(e)||f&&e==="id"));return Object.entries(s.fields).forEach(([e,
|
|
1
|
+
import{createStatus as p}from"@donotdev/core";import{EMPTY_VALUE as d}from"./emptyValue";const b=new Set(["text","textarea","email","url","tel","iban","password","color"]);function a(s,i,c){const{fields:l,keepId:f=!1}=c,t=Object.fromEntries(Object.entries(i).filter(([e])=>l.has(e)||f&&e==="id"));return Object.entries(s.fields).forEach(([e,n])=>{if(!l.has(e))return;const r=t[e],o=!(e in t)||r===null||r===void 0;if(e==="status"&&o)t[e]=p(void 0);else if(b.has(n.type))(o||r==="")&&(t[e]=d);else if(n.type==="switch"){if(r==null){const u=n.options?.fieldSpecific;t[e]=u?.uncheckedValue??!1}}else o&&(n.type==="price"?t[e]=null:n.type==="checkbox"||n.type==="boolean"?t[e]=!1:(n.type==="number"||n.type==="range"||n.type==="rating")&&(t[e]=void 0))}),t}function h(s,i){return a(s,{},{fields:i})}export{a as buildInitialFromRecord,h as buildSchemaDefaults};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{valibotResolver as R}from"@hookform/resolvers/valibot";import{createSchemas as w,evaluateFieldConditions as
|
|
1
|
+
import{valibotResolver as R}from"@hookform/resolvers/valibot";import{createSchemas as w,evaluateFieldConditions as A,i18nFieldName as S,createStatus as I,statusCan as K,updateCheck as M}from"@donotdev/core";import{translateFieldErrors as z}from"./fieldErrorMessages";function g(u,m){return Object.entries(u.fields).filter(([,s])=>s.conditions?.visible||s.conditions?.required).map(([s,a])=>{const o=A(a.conditions,m);return{name:s,visible:o.visible,required:a.conditions?.required?o.required:a.validation?.required}})}function H(u,m,s,a,o){const n={...u,fields:Object.fromEntries(Object.entries(u.fields).filter(([i])=>s.has(i)))},C=w(n);let j,h,p=[];return async(i,E,k)=>{const b=g(n,i),y={...i,status:i.status??o?.status};let c,l=null;if(m==="edit"){const e=M(y,o);c=e.schemaKey,e.schemaKey==="update"&&!e.whole&&(l=Object.keys(n.fields).filter(f=>[f,S(f)].some(r=>JSON.stringify(i[r])!==JSON.stringify(o?.[r]))))}else c=K(I(y),"saveIncomplete")?"draft":"create";const q=JSON.stringify([c,b,l]);if(q!==j){const e=C[c];if(!("entries"in e)||typeof e.entries!="object"||e.entries===null)throw new Error("Expected an object write schema");const f=new Set(Object.keys(e.entries));p=b.filter(t=>!t.visible&&f.has(t.name)).flatMap(({name:t})=>n.fields[t]?.i18n===!0?[t,S(t)].filter(d=>f.has(d)):[t]);const r={...n.fields};if(l)for(const t of Object.keys(r))l.includes(t)||delete r[t];for(const[t,d]of Object.entries(r)){const O=b.find(x=>x.name===t);O&&(O.visible?d.conditions?.required&&(r[t]={...d,validation:{...d.validation,required:O.required}}):delete r[t])}const J=w({...n,fields:r})[c];h=R(J),j=q}const F=Object.fromEntries(p.filter(e=>Object.hasOwn(i,e)).map(e=>[e,i[e]])),v=await h(i,E,k);if(Object.keys(v.errors).length>0){const e=z(v.errors,i,n,a);return{values:{},errors:e}}const N=l?Object.fromEntries(Object.entries(i).filter(([e])=>s.has(e))):{};return{errors:{},values:{...N,...F,...v.values}}}}export{H as createConditionAwareResolver,g as getFormConditionStates};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=null;function t(
|
|
1
|
+
const n=null;function t(u){return u===""?null:u}export{n as EMPTY_VALUE,t as fromInputValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i18nFieldName as x}from"@donotdev/core";import{translateFieldLabel as g}from"./translateFieldLabel";const y=new Set(["date","datetime-local","timestamp","time","week","month"]),h=/^[\w.-]+$/,v=
|
|
1
|
+
import{i18nFieldName as x}from"@donotdev/core";import{translateFieldLabel as g}from"./translateFieldLabel";const y=new Set(["date","datetime-local","timestamp","time","week","month"]),h=/^[\w.-]+$/,v=a=>a==null||a==="",u=a=>typeof a=="object"&&a!==null;function p(a,d,n,f,e,l){const t=g(a,d,(r,m)=>e(r,{ns:l,...m}));if(v(f))return e("crud:text.required",{field:t});const s=e("crud:text.invalid",{field:t}),i=d?.validation;return i?.schema?h.test(n.message)?e(n.message,{ns:l,field:t,defaultValue:s}):s:n.type==="min_length"&&i?.minLength!==void 0?e("crud:text.minLength",{field:t,min:i.minLength}):n.type==="max_length"&&i?.maxLength!==void 0?e("crud:text.maxLength",{field:t,max:i.maxLength}):n.type==="min_value"&&i?.min!==void 0?e("crud:number.min",{field:t,min:i.min}):n.type==="max_value"&&i?.max!==void 0?e("crud:number.max",{field:t,max:i.max}):d?.type==="tel"?e("crud:text.phone",{field:t}):d?.type==="email"?e("crud:text.email",{field:t}):d?.type==="url"?e("crud:text.url",{field:t}):d&&y.has(d.type)?e("crud:date.format",{field:t}):s}function b(a,d,n,f){const e={};for(const[l,t]of Object.entries(a)){const s=n.fields[l]??Object.entries(n.fields).find(([r])=>x(r)===l)?.[1],i=(r,m)=>Array.isArray(r)?r.map((o,c)=>i(o,Array.isArray(m)?m[c]:void 0)):u(r)?typeof r.message=="string"?{...r,message:p(l,s,{type:r.type,message:r.message},m,f,n.namespace)}:Object.fromEntries(Object.entries(r).map(([o,c])=>[o,o==="ref"?c:i(c,u(m)?m[o]:void 0)])):r;e[l]=i(t,d[l])}return e}export{p as fieldErrorMessage,b as translateFieldErrors};
|