@donotdev/crud 0.1.43 → 0.1.44

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.
Files changed (40) hide show
  1. package/dist/CrudService.bulk.js +1 -1
  2. package/dist/CrudService.cache.js +1 -1
  3. package/dist/CrudStore.js +1 -1
  4. package/dist/components/CrudCard.js +1 -1
  5. package/dist/components/EntityFilters.js +1 -1
  6. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  7. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  8. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  9. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  10. package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
  11. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  12. package/dist/components/fields/display/MapFieldDisplay.js +1 -1
  13. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  14. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  15. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  16. package/dist/components/form/fields/AddressFieldComponent.d.ts +12 -10
  17. package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -1
  18. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  19. package/dist/components/form/fields/DropdownComponent.js +1 -1
  20. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  21. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  22. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  23. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  24. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  25. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  26. package/dist/components/form/fields/RichTextComponent.js +1 -1
  27. package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
  28. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  29. package/dist/forms/hooks/useEntityForm.js +1 -1
  30. package/dist/forms/utils/buildInitialValues.js +1 -1
  31. package/dist/forms/utils/isFieldEditable.js +1 -1
  32. package/dist/stores/FormStore.js +1 -1
  33. package/dist/stores/UploadStore.js +1 -1
  34. package/dist/symbol-index.json +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/dist/utils/clientListProcessing.js +1 -1
  37. package/dist/utils/collections.js +1 -1
  38. package/dist/utils/imageProcessing.js +1 -1
  39. package/dist/utils/uploadValidation.js +1 -1
  40. package/package.json +3 -3
@@ -1 +1 @@
1
- import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,i,l){const o=Object.entries(i);return o.length===0?t:t.filter(n=>o.every(([r,c])=>{const e=l.fields[r]?.type||"text";return u(n[r],c,e)}))}function a(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const i=new Set(["string"]),l=[];for(const[o,n]of Object.entries(t.fields)){if(n.visibility==="hidden"||n.visibility==="technical")continue;const r=f(n.type);r&&i.has(r)&&l.push(o)}return l}function p(t,i,l){if(!i||i.trim()==="")return t;const o=i.toLowerCase(),n=a(l);return n.length===0?t.filter(r=>Object.values(r).some(c=>c==null?!1:String(c).toLowerCase().includes(o))):t.filter(r=>n.some(c=>{const e=r[c];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(o):String(e).toLowerCase().includes(o)}))}function m(t,i){if(typeof i=="function")return[...t].sort(i);const{field:l,direction:o="asc"}=i,n=o==="desc"?-1:1;return[...t].sort((r,c)=>{const e=r[l],s=c[l];return e==null&&s==null?0:e==null?1:s==null?-1:typeof e=="number"&&typeof s=="number"?(e-s)*n:typeof e=="object"&&"amount"in e&&typeof s=="object"&&"amount"in s?(e.amount-s.amount)*n:e instanceof Date&&s instanceof Date?(e.getTime()-s.getTime())*n:String(e).localeCompare(String(s))*n})}export{d as applyFilters,p as applySearch,m as applySort,a as getSearchableFields};
1
+ import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,r,l){const i=Object.entries(r);return i.length===0?t:t.filter(n=>i.every(([s,c])=>{const e=l.fields[s]?.type||"text";return u(n[s],c,e)}))}function a(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const r=new Set(["string"]),l=[];for(const[i,n]of Object.entries(t.fields)){if(n.visibility==="hidden"||n.visibility==="technical")continue;const s=f(n.type);s&&r.has(s)&&l.push(i)}return l}function p(t,r,l){if(!r||r.trim()==="")return t;const i=r.toLowerCase(),n=a(l);return n.length===0?t.filter(s=>Object.values(s).some(c=>c==null?!1:String(c).toLowerCase().includes(i))):t.filter(s=>n.some(c=>{const e=s[c];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(i):String(e).toLowerCase().includes(i)}))}function m(t,r){if(typeof r=="function")return[...t].sort(r);const{field:l,direction:i="asc"}=r,n=i==="desc"?-1:1;return[...t].sort((s,c)=>{const e=s[l],o=c[l];return e==null&&o==null?0:e==null?1:o==null?-1:typeof e=="number"&&typeof o=="number"?(e-o)*n:typeof e=="object"&&"amount"in e&&typeof o=="object"&&"amount"in o?(e.amount-o.amount)*n:e instanceof Date&&o instanceof Date?(e.getTime()-o.getTime())*n:String(e).localeCompare(String(o))*n})}export{d as applyFilters,p as applySearch,m as applySort,a as getSearchableFields};
@@ -1 +1 @@
1
- import{getCrudService as i}from"../CrudService";async function p(a,t){const e=i(),s=[],o=t.range?.start??1,c=t.range?.end??28;for(let r=o;r<=c;r++){const m=String(r),n=await e.get(t.path(a),m,t.schema);n&&s.push(n)}return s}async function d(a,t,e){const s=i();for(const o of e){const c=t.idOf(o);await s.set(t.path(a),c,o,t.schema)}}async function h(a,t,e){const s=i();if(t.idFrom){const o=t.idFrom(e);return s.set(t.path(a),o,e,t.schema)}return s.add(t.path(a),e,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
1
+ import{getCrudService as i}from"../CrudService";async function p(o,t){const a=i(),e=[],s=t.range?.start??1,r=t.range?.end??28;for(let c=s;c<=r;c++){const m=String(c),n=await a.get(t.path(o),m,t.schema);n&&e.push(n)}return e}async function d(o,t,a){const e=i();for(const s of a){const r=t.idOf(s);await e.set(t.path(o),r,s,t.schema)}}async function h(o,t,a){const e=i();if(t.idFrom){const s=t.idFrom(a);return e.set(t.path(o),s,a,t.schema)}return e.add(t.path(o),a,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
@@ -1 +1 @@
1
- const F=new WeakMap;function W(t){return JSON.stringify({maxWidth:t.maxWidth,maxHeight:t.maxHeight,thumbWidth:t.thumbWidth,thumbHeight:t.thumbHeight,aspectRatio:t.aspectRatio,quality:t.quality,crop:t.crop})}async function H(t,a={}){const n=W(a),h=F.get(t);if(h?.has(n))return h.get(n);const{maxWidth:s=1920,maxHeight:e=1440,thumbWidth:i=300,thumbHeight:r=225,aspectRatio:l=4/3,quality:m=.85,crop:o}=a;return new Promise((g,c)=>{const d=new Image,w=new FileReader;w.onload=u=>{d.src=u.target?.result},w.onerror=()=>c(new Error("Failed to read file")),d.onload=async()=>{try{const{width:u,height:f}=M(o?o.width:d.width,o?o.height:d.height,s,e,l),y=await x(d,u,f,l,m,o),v=await x(d,i,r,l,.65,o),p={fullBlob:y,thumbBlob:v,width:u,height:f};let b=F.get(t);b||(b=new Map,F.set(t,b)),b.set(n,p),g(p)}catch(u){c(u)}},d.onerror=()=>c(new Error("Failed to load image")),w.readAsDataURL(t)})}function M(t,a,n,h,s){let e=t,i=a;e>n&&(i=n/e*i,e=n),i>h&&(e=h/i*e,i=h);const r=e/i;return Math.abs(r-s)>.01&&(r>s?i=e/s:e=i*s),{width:Math.round(e),height:Math.round(i)}}async function x(t,a,n,h,s,e){const i=document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("Failed to get canvas context");i.width=a,i.height=n,r.fillStyle="#FFFFFF",r.fillRect(0,0,a,n);let l,m,o,g;if(e)l=e.x,m=e.y,o=e.width,g=e.height;else{const c=t.width/t.height;o=t.width,g=t.height,l=0,m=0,c>h?(o=t.height*h,l=(t.width-o)/2):c<h&&(g=t.width/h,m=(t.height-g)/2)}return r.drawImage(t,l,m,o,g,0,0,a,n),new Promise((c,d)=>{i.toBlob(w=>{w?c(w):d(new Error("Failed to convert canvas to blob"))},"image/webp",s)})}function E(t,a){return t.type.startsWith("image/")?a&&t.size>a?{valid:!1,error:`File size exceeds ${(a/1048576).toFixed(1)}MB limit`}:{valid:!0}:{valid:!1,error:"File must be an image"}}export{H as processImage,E as validateImageFile};
1
+ const F=new WeakMap;function W(t){return JSON.stringify({maxWidth:t.maxWidth,maxHeight:t.maxHeight,thumbWidth:t.thumbWidth,thumbHeight:t.thumbHeight,aspectRatio:t.aspectRatio,quality:t.quality,crop:t.crop})}async function H(t,a={}){const n=W(a),h=F.get(t);if(h?.has(n))return h.get(n);const{maxWidth:d=1920,maxHeight:e=1440,thumbWidth:i=300,thumbHeight:o=225,aspectRatio:l=4/3,quality:m=.85,crop:r}=a;return new Promise((g,c)=>{const s=new Image,w=new FileReader;w.onload=u=>{s.src=u.target?.result},w.onerror=()=>c(new Error("Failed to read file")),s.onload=async()=>{try{const{width:u,height:f}=M(r?r.width:s.width,r?r.height:s.height,d,e,l),y=await x(s,u,f,l,m,r),v=await x(s,i,o,l,.65,r),p={fullBlob:y,thumbBlob:v,width:u,height:f};let b=F.get(t);b||(b=new Map,F.set(t,b)),b.set(n,p),g(p)}catch(u){c(u)}},s.onerror=()=>c(new Error("Failed to load image")),w.readAsDataURL(t)})}function M(t,a,n,h,d){let e=t,i=a;e>n&&(i=n/e*i,e=n),i>h&&(e=h/i*e,i=h);const o=e/i;return Math.abs(o-d)>.01&&(o>d?i=e/d:e=i*d),{width:Math.round(e),height:Math.round(i)}}async function x(t,a,n,h,d,e){const i=document.createElement("canvas"),o=i.getContext("2d");if(!o)throw new Error("Failed to get canvas context");i.width=a,i.height=n,o.fillStyle="#FFFFFF",o.fillRect(0,0,a,n);let l,m,r,g;if(e)l=e.x,m=e.y,r=e.width,g=e.height;else{const c=t.width/t.height;r=t.width,g=t.height,l=0,m=0,c>h?(r=t.height*h,l=(t.width-r)/2):c<h&&(g=t.width/h,m=(t.height-g)/2)}return o.drawImage(t,l,m,r,g,0,0,a,n),new Promise((c,s)=>{i.toBlob(w=>{w?c(w):s(new Error("Failed to convert canvas to blob"))},"image/webp",d)})}function E(t,a){return t.type.startsWith("image/")?a&&t.size>a?{valid:!1,error:`File size exceeds ${(a/1048576).toFixed(1)}MB limit`}:{valid:!0}:{valid:!1,error:"File must be an image"}}export{H as processImage,E as validateImageFile};
@@ -1 +1 @@
1
- "use client";function o(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!o(r.fullUrl)||r.thumbUrl&&!o(r.thumbUrl))}function i(r,l=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(l||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((e,s)=>{const n=l?`${l}[${s}]`:`[${s}]`;t.push(...i(e,n))});else{const e=r;if(e.fullUrl!==void 0&&e.thumbUrl!==void 0){const s=e.fullUrl,n=e.thumbUrl,u=typeof s=="string"&&!o(s),c=n&&typeof n=="string"&&!o(n);if(u||c){const f=l||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(e).forEach(([s,n])=>{const u=l?`${l}.${s}`:s;t.push(...i(n,u))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,o as isStorageUrl,h as validatePicture};
1
+ "use client";function u(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!u(r.fullUrl)||r.thumbUrl&&!u(r.thumbUrl))}function i(r,n=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(n||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((s,o)=>{const l=n?`${n}[${o}]`:`[${o}]`;t.push(...i(s,l))});else{const s=r;if(s.fullUrl!==void 0&&s.thumbUrl!==void 0){const o=s.fullUrl,l=s.thumbUrl,e=typeof o=="string"&&!u(o),c=l&&typeof l=="string"&&!u(l);if(e||c){const f=n||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(s).forEach(([o,l])=>{const e=n?`${n}.${o}`:o;t.push(...i(l,e))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,u as isStorageUrl,h as validatePicture};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/crud",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -57,8 +57,8 @@
57
57
  "@dnd-kit/core": "^6.3.1",
58
58
  "@dnd-kit/sortable": "^10.0.0",
59
59
  "@dnd-kit/utilities": "^3.2.2",
60
- "@donotdev/components": "^0.1.43",
61
- "@donotdev/core": "^0.1.42",
60
+ "@donotdev/components": "^0.1.44",
61
+ "@donotdev/core": "^0.1.44",
62
62
  "dompurify": "^3.3.2",
63
63
  "react-easy-crop": "^5.5.6"
64
64
  },