@donotdev/crud 0.1.45 → 0.2.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.
Files changed (190) hide show
  1. package/dist/CrudService.bulk.js +1 -1
  2. package/dist/CrudService.bulkAcross.js +1 -1
  3. package/dist/CrudService.cache.js +1 -1
  4. package/dist/CrudService.d.ts +12 -0
  5. package/dist/CrudService.d.ts.map +1 -1
  6. package/dist/CrudService.internal.d.ts +8 -0
  7. package/dist/CrudService.internal.d.ts.map +1 -1
  8. package/dist/CrudService.internal.js +2 -2
  9. package/dist/CrudService.js +1 -1
  10. package/dist/CrudService.mutations.js +1 -1
  11. package/dist/CrudService.optimistic.js +1 -1
  12. package/dist/CrudService.queries.d.ts +5 -0
  13. package/dist/CrudService.queries.d.ts.map +1 -1
  14. package/dist/CrudService.queries.js +1 -1
  15. package/dist/CrudService.subscriptions.js +1 -1
  16. package/dist/CrudStore.js +1 -1
  17. package/dist/FieldRegistry.js +1 -1
  18. package/dist/adapters/FunctionsAdapter.js +1 -1
  19. package/dist/components/CrudButton.js +1 -1
  20. package/dist/components/CrudCard.js +1 -1
  21. package/dist/components/DateFilter.js +1 -1
  22. package/dist/components/DisplayFieldRenderer.js +1 -1
  23. package/dist/components/DisplayThumbnail.js +1 -1
  24. package/dist/components/EntityFilters.js +1 -1
  25. package/dist/components/FormFieldRenderer.js +1 -1
  26. package/dist/components/FormLayout.js +1 -1
  27. package/dist/components/YearFilter.js +1 -1
  28. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  29. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  30. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
  31. package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
  32. package/dist/components/controlled/complex/ControlledMapField.js +1 -1
  33. package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
  34. package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
  35. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  36. package/dist/components/controlled/complex/index.js +1 -1
  37. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  38. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  39. package/dist/components/controlled/file/ControlledImageField.d.ts.map +1 -1
  40. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  41. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  42. package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
  43. package/dist/components/controlled/file/ControlledMultiImageField.d.ts.map +1 -1
  44. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  45. package/dist/components/controlled/file/index.js +1 -1
  46. package/dist/components/controlled/index.js +1 -1
  47. package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
  48. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  49. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  50. package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
  51. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  52. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  53. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  54. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  55. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  56. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  57. package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
  58. package/dist/components/controlled/input/ControlledTextField.js +1 -1
  59. package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
  60. package/dist/components/controlled/input/index.js +1 -1
  61. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  62. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  63. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  64. package/dist/components/controlled/select/ControlledRadioField.js +1 -1
  65. package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
  66. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  67. package/dist/components/controlled/select/index.js +1 -1
  68. package/dist/components/controlled/types.js +1 -1
  69. package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
  70. package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
  71. package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
  72. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  73. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  74. package/dist/components/fields/display/DropdownDisplay.js +1 -1
  75. package/dist/components/fields/display/FileFieldDisplay.js +1 -1
  76. package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
  77. package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
  78. package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
  79. package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
  80. package/dist/components/fields/display/MapFieldDisplay.js +1 -1
  81. package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
  82. package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
  83. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  84. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  85. package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
  86. package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
  87. package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
  88. package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
  89. package/dist/components/fields/display/RichTextDisplay.js +2 -2
  90. package/dist/components/fields/display/TextAreaDisplay.js +1 -1
  91. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  92. package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
  93. package/dist/components/fields/display/index.js +1 -1
  94. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  95. package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
  96. package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
  97. package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
  98. package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
  99. package/dist/components/form/fields/ComboboxComponent.js +1 -1
  100. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  101. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  102. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  103. package/dist/components/form/fields/DropdownComponent.js +1 -1
  104. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  105. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  106. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  107. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  108. package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
  109. package/dist/components/form/fields/ImageFieldComponent.d.ts +8 -0
  110. package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
  111. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  112. package/dist/components/form/fields/MapFieldComponent.js +1 -1
  113. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  114. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  115. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  116. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  117. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  118. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  119. package/dist/components/form/fields/RadioFieldComponent.js +1 -1
  120. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  121. package/dist/components/form/fields/RatingFieldComponent.js +1 -1
  122. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  123. package/dist/components/form/fields/RichTextComponent.js +1 -1
  124. package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
  125. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  126. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  127. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  128. package/dist/components/form/fields/index.js +1 -1
  129. package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
  130. package/dist/components/form/internal/ImageViewerDialog.js +1 -1
  131. package/dist/components/index.js +1 -1
  132. package/dist/contexts/UploadContext.js +1 -1
  133. package/dist/contexts/index.js +1 -1
  134. package/dist/fieldTypeRegistry.js +1 -1
  135. package/dist/fieldTypeRegistry.store.js +1 -1
  136. package/dist/forms/hooks/index.js +1 -1
  137. package/dist/forms/hooks/useController.js +1 -1
  138. package/dist/forms/hooks/useEntityField.js +1 -1
  139. package/dist/forms/hooks/useEntityForm.js +1 -1
  140. package/dist/forms/index.js +1 -1
  141. package/dist/forms/utils/buildInitialValues.js +1 -1
  142. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  143. package/dist/forms/utils/index.js +1 -1
  144. package/dist/forms/utils/isFieldEditable.js +1 -1
  145. package/dist/forms/utils/translateFieldLabel.js +1 -1
  146. package/dist/forms/utils/validateEntity.js +1 -1
  147. package/dist/hooks/index.js +1 -1
  148. package/dist/hooks/useCrudFilters.js +1 -1
  149. package/dist/hooks/useCrudPageSize.js +1 -1
  150. package/dist/hooks/useEntityFavorites.js +1 -1
  151. package/dist/hooks/useFieldConditions.js +1 -1
  152. package/dist/hooks/useFileUpload.js +1 -1
  153. package/dist/hooks/useReferenceResolver.js +1 -1
  154. package/dist/hooks/useRelatedItems.js +1 -1
  155. package/dist/index.js +1 -1
  156. package/dist/registerBuiltinFieldTypes.js +1 -1
  157. package/dist/stores/FormStore.js +1 -1
  158. package/dist/stores/UploadStore.js +1 -1
  159. package/dist/stores/index.js +1 -1
  160. package/dist/symbol-index.json +1 -1
  161. package/dist/tsconfig.tsbuildinfo +1 -1
  162. package/dist/types.d.ts +8 -1
  163. package/dist/types.d.ts.map +1 -1
  164. package/dist/types.js +1 -1
  165. package/dist/useBaseCrudList.d.ts.map +1 -1
  166. package/dist/useBaseCrudList.js +1 -1
  167. package/dist/useCrud.d.ts.map +1 -1
  168. package/dist/useCrud.js +1 -1
  169. package/dist/useCrudCardList.js +1 -1
  170. package/dist/useCrudList.js +1 -1
  171. package/dist/utils/clientListProcessing.js +1 -1
  172. package/dist/utils/collections.js +1 -1
  173. package/dist/utils/fileStorage.js +1 -1
  174. package/dist/utils/imageProcessing.d.ts +45 -3
  175. package/dist/utils/imageProcessing.d.ts.map +1 -1
  176. package/dist/utils/imageProcessing.js +1 -1
  177. package/dist/utils/imageStorage.js +1 -1
  178. package/dist/utils/imageUtils.js +1 -1
  179. package/dist/utils/matchesFilter.js +1 -1
  180. package/dist/utils/mergeWithOptimistic.js +1 -1
  181. package/dist/utils/sanitizeHtml.d.ts +1 -0
  182. package/dist/utils/sanitizeHtml.d.ts.map +1 -1
  183. package/dist/utils/sanitizeHtml.js +1 -1
  184. package/dist/utils/scopeUtils.js +1 -1
  185. package/dist/utils/uploadValidation.js +1 -1
  186. package/dist/workflows/WorkflowPersistence.js +1 -1
  187. package/dist/workflows/defineWorkflow.js +1 -1
  188. package/dist/workflows/index.js +1 -1
  189. package/dist/workflows/useEntityWorkflow.js +1 -1
  190. package/package.json +14 -15
@@ -1 +1 @@
1
- import{jsx as r,jsxs as s}from"react/jsx-runtime";import{Badge as a,BADGE_VARIANT as n,Text as t,Stack as l}from"@donotdev/components";const o=({config:c,value:e,t:d,className:i})=>e?s(l,{direction:"row",align:"center",className:i,children:[r(t,{as:"span",level:"small",children:e.name}),e.size&&s(a,{variant:n.SECONDARY,children:[(e.size/1024).toFixed(1)," KB"]})]}):r(t,{as:"span",variant:"muted",className:i,children:"-"});var p=o;export{o as FileFieldDisplay,p as default};
1
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as t,Text as l,Stack as c}from"@donotdev/components";const r=({config:m,value:a,t:o,className:s})=>a?i(c,{direction:"row",align:"center",className:s,children:[e(l,{as:"span",level:"small",children:a.name}),a.size&&i(n,{variant:t.SECONDARY,children:[(a.size/1024).toFixed(1)," KB"]})]}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var d=r;export{r as FileFieldDisplay,d as default};
@@ -1 +1 @@
1
- import{jsx as s,jsxs as i}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";const o=({config:r,value:t,t:d,className:n})=>!t||t.lat===void 0&&t.lng===void 0?s(e,{as:"span",variant:"muted",className:n,children:"-"}):i(e,{as:"div",level:"small",className:`font-mono ${n||""}`,children:[t.lat?.toFixed(6),", ",t.lng?.toFixed(6)]});var x=o;export{o as GeoPointFieldDisplay,x as default};
1
+ import{jsx as o,jsxs as t}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const e=({config:d,value:a,t:m,className:s})=>!a||a.lat===void 0&&a.lng===void 0?o(l,{as:"span",variant:"muted",className:s,children:"-"}):t(l,{as:"div",level:"small",className:`font-mono ${s||""}`,children:[a.lat?.toFixed(6),", ",a.lng?.toFixed(6)]});var i=e;export{e as GeoPointFieldDisplay,i as default};
@@ -1 +1 @@
1
- const e=()=>null;var l=e;export{e as HiddenFieldDisplay,l as default};
1
+ const a=()=>null;var l=a;export{a as HiddenFieldDisplay,l as default};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{Avatar as c,Text as n}from"@donotdev/components";const p=({config:t,value:s,t:d,className:a,size:r="md"})=>{if(!s)return e(n,{as:"span",variant:"muted",className:a,children:"-"});const l={sm:"size-touch",md:"size-touch",lg:"h-16 w-16"},i=m=>m.split(" ").map(o=>o.charAt(0)).slice(0,2).join("").toUpperCase();return e(c,{src:s,alt:t.label||"Image",fallback:i(t.label||"IMG"),className:`${l[r]} ${a||""}`})};var x=p;export{p as ImageFieldDisplay,x as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{Avatar as n,Text as p}from"@donotdev/components";const l=({config:a,value:s,t:d,className:e,size:r="md"})=>{if(!s)return t(p,{as:"span",variant:"muted",className:e,children:"-"});const i={sm:"size-touch",md:"size-touch",lg:"h-16 w-16"},c=m=>m.split(" ").map(o=>o.charAt(0)).slice(0,2).join("").toUpperCase();return t(n,{src:s,alt:a.label||"Image",fallback:c(a.label||"IMG"),className:`${i[r]} ${e||""}`})};var u=l;export{l as ImageFieldDisplay,u as default};
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const s=({config:a,value:e,t:r,className:t})=>{if(!e)return o(l,{as:"span",variant:"muted",className:t,children:"-"});const i=(()=>{switch(a.type){case"email":return{href:`mailto:${e}`,"aria-label":r("common.sendEmailTo",{email:e})};case"tel":return{href:`tel:${e}`,"aria-label":r("common.callNumber",{number:e})};default:return{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":r("common.openLink")}}})();return o("a",{...i,className:t||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:n=>n.currentTarget.style.textDecoration="underline",onMouseLeave:n=>n.currentTarget.style.textDecoration="none",children:e})};var u=s;export{s as LinkFieldDisplay,u as default};
1
+ import{jsx as n}from"react/jsx-runtime";import{Text as i}from"@donotdev/components";const o=({config:l,value:e,t:r,className:t})=>{if(!e)return n(i,{as:"span",variant:"muted",className:t,children:"-"});const s=(()=>{switch(l.type){case"email":return{href:`mailto:${e}`,"aria-label":r("common.sendEmailTo",{email:e})};case"tel":return{href:`tel:${e}`,"aria-label":r("common.callNumber",{number:e})};default:return{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":r("common.openLink")}}})();return n("a",{...s,className:t||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none",children:e})};var c=o;export{o as LinkFieldDisplay,c as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Text as s}from"@donotdev/components";const o=({config:r,value:t,t:d,className:n})=>!t||t.lat===void 0&&t.lng===void 0?e(s,{as:"span",variant:"muted",className:n,children:"-"}):i(s,{as:"div",level:"small",className:`font-mono ${n||""}`,children:[t.lat?.toFixed(6),", ",t.lng?.toFixed(6)]});var x=o;export{o as MapFieldDisplay,x as default};
1
+ import{jsx as o,jsxs as t}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const e=({config:d,value:a,t:m,className:s})=>!a||a.lat===void 0&&a.lng===void 0?o(l,{as:"span",variant:"muted",className:s,children:"-"}):t(l,{as:"div",level:"small",className:`font-mono ${s||""}`,children:[a.lat?.toFixed(6),", ",a.lng?.toFixed(6)]});var i=e;export{e as MapFieldDisplay,i as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{Badge as o,BADGE_VARIANT as e,Text as p,Stack as s}from"@donotdev/components";const c=({config:d,value:r,t:m,className:a})=>!r||!Array.isArray(r)||r.length===0?t(p,{as:"span",variant:"muted",className:a,children:"-"}):t(s,{direction:"row",wrap:"wrap",className:a,children:r.map((i,n)=>t(o,{variant:e.OUTLINE,children:String(i)},n))});var x=c;export{c as MultiDropdownDisplay,x as default};
1
+ import{jsx as r}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as l,Text as o,Stack as c}from"@donotdev/components";const t=({config:p,value:a,t:d,className:s})=>!a||!Array.isArray(a)||a.length===0?r(o,{as:"span",variant:"muted",className:s,children:"-"}):r(c,{direction:"row",wrap:"wrap",className:s,children:a.map((e,i)=>r(n,{variant:l.OUTLINE,children:String(e)},i))});var m=t;export{t as MultiDropdownDisplay,m as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{Badge as e,BADGE_VARIANT as o,Text as p,Stack as s}from"@donotdev/components";const c=({config:d,value:r,t:m,className:i})=>!r||!Array.isArray(r)||r.length===0?t(p,{as:"span",variant:"muted",className:i,children:"-"}):t(s,{direction:"row",wrap:"wrap",className:i,children:r.map((a,n)=>t(e,{variant:o.OUTLINE,children:String(a)},n))});var f=c;export{c as MultiInputTextFieldDisplay,f as default};
1
+ import{jsx as r}from"react/jsx-runtime";import{Badge as l,BADGE_VARIANT as n,Text as c,Stack as m}from"@donotdev/components";const e=({config:p,value:a,t:d,className:s})=>!a||!Array.isArray(a)||a.length===0?r(c,{as:"span",variant:"muted",className:s,children:"-"}):r(m,{direction:"row",wrap:"wrap",className:s,children:a.map((t,i)=>r(l,{variant:n.OUTLINE,children:String(t)},i))});var o=e;export{e as MultiInputTextFieldDisplay,o as default};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{Text as t,Spinner as a}from"@donotdev/components";import{getI18nInstance as i}from"@donotdev/core";const s=({config:f,value:n,t:m,className:r,loading:o=!1})=>o?e(a,{className:r}):n==null?e(t,{as:"span",variant:"muted",className:r,children:"-"}):e(t,{as:"span",className:`font-mono ${r||""}`,children:n.toLocaleString(i()?.language)});var d=s;export{s as NumberFieldDisplay,d as default};
1
+ import{jsx as s}from"react/jsx-runtime";import{Text as n,Spinner as r}from"@donotdev/components";import{getI18nInstance as t}from"@donotdev/core";const l=({config:i,value:e,t:c,className:a,loading:o=!1})=>o?s(r,{className:a}):e==null?s(n,{as:"span",variant:"muted",className:a,children:"-"}):s(n,{as:"span",className:`font-mono ${a||""}`,children:e.toLocaleString(t()?.language)});var m=l;export{l as NumberFieldDisplay,m as default};
@@ -1 +1 @@
1
- import{jsx as o,jsxs as s}from"react/jsx-runtime";import{Eye as n,EyeOff as d}from"lucide-react";import{useState as c}from"react";import{Skeleton as f,Button as m,CopyToClipboard as y,Stack as a}from"@donotdev/components";const x=({config:b,value:r,t:i,className:t,loading:l=!1})=>{const[e,p]=c(!1);return l?o(f,{className:t}):r?s(a,{direction:"row",align:"center",className:t,children:[o("span",{style:{fontFamily:"monospace"},children:e?r:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),s(a,{direction:"row",align:"center",gap:"tight",children:[o(m,{type:"button",onClick:()=>p(!e),"aria-label":e?"Hide password":"Show password",children:e?o(d,{}):o(n,{})}),o(y,{text:r,tooltipText:i("copyToClipboard")||"Copy to clipboard",copiedTooltipText:i("copied")||"Copied!",ariaLabel:i("copyPassword")||"Copy password"})]})]}):o("div",{style:{color:"var(--muted-foreground)"},children:"-"})};var g=x;export{x as PasswordFieldDisplay,g as default};
1
+ import{jsx as o,jsxs as i}from"react/jsx-runtime";import{Eye as d,EyeOff as n}from"lucide-react";import{useState as u}from"react";import{Skeleton as m,Button as y,CopyToClipboard as f,Stack as r}from"@donotdev/components";const l=({config:g,value:e,t,className:s,loading:p=!1})=>{const[a,c]=u(!1);return p?o(m,{className:s}):e?i(r,{direction:"row",align:"center",className:s,children:[o("span",{style:{fontFamily:"monospace"},children:a?e:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),i(r,{direction:"row",align:"center",gap:"tight",children:[o(y,{type:"button",onClick:()=>c(!a),"aria-label":a?"Hide password":"Show password",children:a?o(n,{}):o(d,{})}),o(f,{text:e,tooltipText:t("copyToClipboard")||"Copy to clipboard",copiedTooltipText:t("copied")||"Copied!",ariaLabel:t("copyPassword")||"Copy password"})]})]}):o("div",{style:{color:"var(--muted-foreground)"},children:"-"})};var w=l;export{l as PasswordFieldDisplay,w as default};
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import{Text as a}from"@donotdev/components";const i=({config:s,value:e,t:o,className:t})=>e?n("a",{href:`tel:${e}`,className:t||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:r=>r.currentTarget.style.textDecoration="underline",onMouseLeave:r=>r.currentTarget.style.textDecoration="none","aria-label":o("common.callNumber",{number:e}),children:e}):n(a,{as:"span",variant:"muted",className:t,children:"-"});var m=i;export{i as PhoneNumberDisplay,m as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{Text as s}from"@donotdev/components";const n=({config:c,value:e,t:o,className:r})=>e?t("a",{href:`tel:${e}`,className:r||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none","aria-label":o("common.callNumber",{number:e}),children:e}):t(s,{as:"span",variant:"muted",className:r,children:"-"});var l=n;export{n as PhoneNumberDisplay,l as default};
@@ -1 +1 @@
1
- import{jsx as a}from"react/jsx-runtime";import{Badge as e,BADGE_VARIANT as i,Text as n}from"@donotdev/components";const o=({config:s,value:r,t:d,className:t})=>r?a(e,{variant:i.OUTLINE,className:t,children:r}):a(n,{as:"span",variant:"muted",className:t,children:"-"});var c=o;export{o as RadioFieldDisplay,c as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{Badge as r,BADGE_VARIANT as t,Text as l}from"@donotdev/components";const i=({config:c,value:a,t:d,className:s})=>a?e(r,{variant:t.OUTLINE,className:s,children:a}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var o=i;export{i as RadioFieldDisplay,o as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";const o=({config:s,value:n,t:a,className:r})=>n==null?t(e,{as:"span",variant:"muted",className:r,children:"-"}):t(e,{as:"span",className:`font-mono ${r||""}`,children:n});var f=o;export{o as RangeFieldDisplay,f as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const n=({config:t,value:a,t:m,className:s})=>a==null?e(l,{as:"span",variant:"muted",className:s,children:"-"}):e(l,{as:"span",className:`font-mono ${s||""}`,children:a});var o=n;export{n as RangeFieldDisplay,o as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{Badge as a,BADGE_VARIANT as n,Text as s}from"@donotdev/components";const d=({config:o,value:r,t:m,className:e})=>{if(!r)return t(s,{as:"span",variant:"muted",className:e,children:"-"});const i=r.displayName||r.name||r.id||r;return t(a,{variant:n.OUTLINE,className:e,children:String(i)})};var f=d;export{d as ReferenceFieldDisplay,f as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{Badge as i,BADGE_VARIANT as n,Text as l}from"@donotdev/components";const r=({config:c,value:a,t:d,className:s})=>{if(!a)return e(l,{as:"span",variant:"muted",className:s,children:"-"});const t=a.displayName||a.name||a.id||a;return e(i,{variant:n.OUTLINE,className:s,children:String(t)})};var m=r;export{r as ReferenceFieldDisplay,m as default};
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Text as t}from"@donotdev/components";import{sanitizeHtml as s}from"../../../utils/sanitizeHtml";const a=({config:n,value:r,t:m,className:o})=>!r||r.trim()===""?e(t,{as:"span",variant:"muted",className:o,children:"-"}):i("div",{className:o,style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",borderRadius:"var(--radius-md)",border:"1px solid var(--border)",minHeight:"38px"},children:[e("div",{dangerouslySetInnerHTML:{__html:s(r)},style:{outline:"none",fontSize:"var(--font-size-base)",lineHeight:"1.6"},className:"prose prose-sm max-w-none"}),e("style",{children:`
1
+ import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Text as s}from"@donotdev/components";import{sanitizeHtml as t}from"../../../utils/sanitizeHtml";const a=({config:m,value:e,t:l,className:o})=>!e||e.trim()===""?r(s,{as:"span",variant:"muted",className:o,children:"-"}):i("div",{className:o,style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",borderRadius:"var(--radius-md)",border:"1px solid var(--border)",minHeight:"38px"},children:[r("div",{dangerouslySetInnerHTML:{__html:t(e)},style:{outline:"none",fontSize:"var(--font-size-base)",lineHeight:"1.6"},className:"prose prose-sm max-w-none"}),r("style",{children:`
2
2
  /* Match Tiptap ProseMirror styling */
3
3
  .prose p {
4
4
  margin: 0.5em 0;
@@ -58,4 +58,4 @@ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Text as t}from"@donotde
58
58
  .prose a:hover {
59
59
  color: var(--primary-hover);
60
60
  }
61
- `})]});var f=a;export{a as RichTextDisplay,f as default};
61
+ `})]});var n=a;export{a as RichTextDisplay,n as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{Text as a}from"@donotdev/components";const s=({config:i,value:e,t:p,className:r})=>e?t(a,{as:"div",level:"small",className:`whitespace-pre-wrap ${r||""}`,children:e}):t(a,{as:"span",variant:"muted",className:r,children:"-"});var o=s;export{s as TextAreaDisplay,o as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const r=({config:i,value:a,t:m,className:s})=>a?e(l,{as:"div",level:"small",className:`whitespace-pre-wrap ${s||""}`,children:a}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var t=r;export{r as TextAreaDisplay,t as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as k,Calendar as I,Clock as N}from"lucide-react";import{useState as j}from"react";import{Skeleton as f,Badge as A,BADGE_VARIANT as F,Text as l,cn as T,CopyToClipboard as x,Stack as i}from"@donotdev/components";import{getWeekFromISOString as B,getI18nInstance as C}from"@donotdev/core";const E=({config:o,value:r,t:a,className:c,loading:b=!1,showCopy:m=!1,asBadge:S=!1,truncate:s=!1,maxLength:d=50,showLabel:p=!1})=>{const[M,g]=j(!1),_=async()=>{try{await navigator.clipboard.writeText(r),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(o.type){case"email":return e(k,{});case"month":case"week":return e(I,{});case"time":return e(N,{});default:return null}},w=t=>{if(!t)return null;switch(o.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:u=>u.currentTarget.style.textDecoration="underline",onMouseLeave:u=>u.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(C()?.language,{year:"numeric",month:"long"});case"week":return B(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(C()?.language);default:return t}},D=t=>!s||t.length<=d?t:`${t.substring(0,d)}...`;if(b)return n(i,{gap:"tight",children:[p&&e(f,{style:{height:"1rem",width:"6rem"}}),e(f,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!r)return n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),e(l,{as:"span",variant:"muted",className:T(c),style:{fontStyle:"italic"},children:a("common.noValue",{defaultValue:"No value"})})]});const V=w(r),y=D(String(V));return S?n(i,{direction:"row",align:"center",gap:"tight",children:[h(),e(A,{variant:F.SECONDARY,className:c,children:y}),m&&e(x,{text:r,tooltipText:a("copyToClipboard")||"Copy to clipboard",copiedTooltipText:a("copied")||"Copied!",ariaLabel:a("copyToClipboard")||"Copy to clipboard"})]}):n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),n(i,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:T("dndev-flex-1",s&&"truncate",c),title:s&&r.length>d?r:void 0,children:e(l,{as:"span",children:y})}),m&&e(x,{text:r,tooltipText:a("copyToClipboard")||"Copy to clipboard",copiedTooltipText:a("copied")||"Copied!",ariaLabel:a("copyToClipboard")||"Copy to clipboard"})]})]})};var q=E;export{E as TextFieldDisplay,q as default};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as L,Calendar as k,Clock as I}from"lucide-react";import{useState as A}from"react";import{Skeleton as T,Badge as B,BADGE_VARIANT as E,Text as l,cn as f,CopyToClipboard as x,Stack as o}from"@donotdev/components";import{getWeekFromISOString as M,getI18nInstance as b}from"@donotdev/core";const C=({config:i,value:a,t:r,className:s,loading:v=!1,showCopy:m=!1,asBadge:w=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[j,g]=A(!1),F=async()=>{try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(i.type){case"email":return e(L,{});case"month":case"week":return e(k,{});case"time":return e(I,{});default:return null}},S=t=>{if(!t)return null;switch(i.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:u=>u.currentTarget.style.textDecoration="underline",onMouseLeave:u=>u.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(b()?.language,{year:"numeric",month:"long"});case"week":return M(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(b()?.language);default:return t}},D=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(v)return n(o,{gap:"tight",children:[p&&e(T,{style:{height:"1rem",width:"6rem"}}),e(T,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!a)return n(o,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:i.label||i.name}),e(l,{as:"span",variant:"muted",className:f(s),style:{fontStyle:"italic"},children:r("common.noValue",{defaultValue:"No value"})})]});const N=S(a),y=D(String(N));return w?n(o,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]}):n(o,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:i.label||i.name}),n(o,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:f("dndev-flex-1",c&&"truncate",s),title:c&&a.length>d?a:void 0,children:e(l,{as:"span",children:y})}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]})]})};var V=C;export{C as TextFieldDisplay,V as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as c}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";import{getI18nInstance as l}from"@donotdev/core";const m=({config:d,value:n,t:p,className:a})=>{if(!n)return t(e,{as:"span",variant:"muted",className:a,children:"-"});try{const r=new Date(n),s=l()?.language,o=r.toLocaleDateString(s),i=r.toLocaleTimeString(s);return c("div",{className:a,children:[t(e,{as:"span",children:o}),t(e,{as:"span",variant:"muted",level:"small",children:i})]})}catch{return t(e,{as:"span",variant:"muted",className:a,children:"-"})}};var g=m;export{m as TimestampFieldDisplay,g as default};
1
+ import{jsx as a,jsxs as m}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";import{getI18nInstance as o}from"@donotdev/core";const i=({config:p,value:t,t:u,className:s})=>{if(!t)return a(e,{as:"span",variant:"muted",className:s,children:"-"});try{const n=new Date(t),r=o()?.language,l=n.toLocaleDateString(r),c=n.toLocaleTimeString(r);return m("div",{className:s,children:[a(e,{as:"span",children:l}),a(e,{as:"span",variant:"muted",level:"small",children:c})]})}catch{return a(e,{as:"span",variant:"muted",className:s,children:"-"})}};var d=i;export{i as TimestampFieldDisplay,d as default};
@@ -1 +1 @@
1
- import{default as l}from"./TextFieldDisplay";import{default as o}from"./BadgeFieldDisplay";import{default as p}from"./AvatarFieldDisplay";import{default as d}from"./LinkFieldDisplay";import{default as s}from"./DateFieldDisplay";import{default as m}from"./NumberFieldDisplay";import{default as D}from"./PhoneNumberDisplay";import{default as F}from"./TextAreaDisplay";import{default as T}from"./RichTextDisplay";import{default as b}from"./CheckboxFieldDisplay";import{default as g}from"./DropdownDisplay";import{default as M}from"./MultiDropdownDisplay";import{default as w}from"./MultiInputTextFieldDisplay";import{default as B}from"./RadioFieldDisplay";import{default as N}from"./RangeFieldDisplay";import{default as v}from"./FileFieldDisplay";import{default as G}from"./ImageFieldDisplay";import{default as L}from"./GeoPointFieldDisplay";import{default as q}from"./MapFieldDisplay";import{default as E}from"./ReferenceFieldDisplay";import{default as K}from"./TimestampFieldDisplay";import{default as Q}from"./HiddenFieldDisplay";import{default as U}from"./ButtonFieldDisplay";export{p as AvatarFieldDisplay,o as BadgeFieldDisplay,U as ButtonFieldDisplay,b as CheckboxFieldDisplay,s as DateFieldDisplay,g as DropdownDisplay,v as FileFieldDisplay,L as GeoPointFieldDisplay,Q as HiddenFieldDisplay,G as ImageFieldDisplay,d as LinkFieldDisplay,q as MapFieldDisplay,M as MultiDropdownDisplay,w as MultiInputTextFieldDisplay,m as NumberFieldDisplay,D as PhoneNumberDisplay,B as RadioFieldDisplay,N as RangeFieldDisplay,E as ReferenceFieldDisplay,T as RichTextDisplay,F as TextAreaDisplay,l as TextFieldDisplay,K as TimestampFieldDisplay};
1
+ import{default as a}from"./TextFieldDisplay";import{default as i}from"./BadgeFieldDisplay";import{default as s}from"./AvatarFieldDisplay";import{default as l}from"./LinkFieldDisplay";import{default as e}from"./DateFieldDisplay";import{default as t}from"./NumberFieldDisplay";import{default as o}from"./PhoneNumberDisplay";import{default as r}from"./TextAreaDisplay";import{default as p}from"./RichTextDisplay";import{default as m}from"./CheckboxFieldDisplay";import{default as d}from"./DropdownDisplay";import{default as f}from"./MultiDropdownDisplay";import{default as u}from"./MultiInputTextFieldDisplay";import{default as D}from"./RadioFieldDisplay";import{default as y}from"./RangeFieldDisplay";import{default as F}from"./FileFieldDisplay";import{default as n}from"./ImageFieldDisplay";import{default as x}from"./GeoPointFieldDisplay";import{default as T}from"./MapFieldDisplay";import{default as R}from"./ReferenceFieldDisplay";import{default as b}from"./TimestampFieldDisplay";import{default as g}from"./HiddenFieldDisplay";import{default as M}from"./ButtonFieldDisplay";export{s as AvatarFieldDisplay,i as BadgeFieldDisplay,M as ButtonFieldDisplay,m as CheckboxFieldDisplay,e as DateFieldDisplay,d as DropdownDisplay,F as FileFieldDisplay,x as GeoPointFieldDisplay,g as HiddenFieldDisplay,n as ImageFieldDisplay,l as LinkFieldDisplay,T as MapFieldDisplay,f as MultiDropdownDisplay,u as MultiInputTextFieldDisplay,t as NumberFieldDisplay,o as PhoneNumberDisplay,D as RadioFieldDisplay,y as RangeFieldDisplay,R as ReferenceFieldDisplay,p as RichTextDisplay,r as TextAreaDisplay,a as TextFieldDisplay,b as TimestampFieldDisplay};
@@ -1 +1 @@
1
- import{jsx as k,jsxs as B}from"react/jsx-runtime";import{useState as T,useEffect as z,useRef as J,useCallback as W}from"react";import{Combobox as N,Stack as H}from"@donotdev/components";import{useTranslation as X,getPlatformEnvVar as Q}from"@donotdev/core";const Y="dndev-address-autocomplete-cache",$=100;function D(){try{const o=typeof localStorage<"u"?localStorage.getItem(Y):null;if(o)return new Map(JSON.parse(o))}catch{}return new Map}function ee(o){try{typeof localStorage<"u"&&localStorage.setItem(Y,JSON.stringify([...o]))}catch{}}function Z(o){if(o.size>$){const d=o.keys().next().value;d!==void 0&&o.delete(d)}}const F=D(),G=new Map;function te(o){const d={key:o,v:"weekly"},r="google",v="importLibrary",C="__ib__",g=document,u=window;u[r]=u[r]||{};const c=u[r].maps||(u[r].maps={}),l=new Set,n=new URLSearchParams,m=()=>c._p||(c._p=new Promise(async(A,p)=>{const w=g.createElement("script");n.set("libraries",[...l].join(","));for(const y of Object.keys(d))n.set(y.replace(/[A-Z]/g,M=>"_"+M[0].toLowerCase()),d[y]);n.set("callback",r+".maps."+C),w.src="https://maps.googleapis.com/maps/api/js?"+n,c[C]=A,w.onerror=()=>{c._p=null,p(new Error("Google Maps JS API could not load."))};const f=g.querySelector("script[nonce]");f?.nonce&&(w.nonce=f.nonce),g.head.append(w)}));c[v]||(c[v]=(A,...p)=>(l.add(A),m().then(()=>c[v](A,...p))))}const oe=({label:o,value:d,onChange:r,enableGoogleMaps:v=!1,extractDistrictCode:C,error:g,helperText:u,required:c})=>{const{t:l}=X("crud"),[n,m]=T(d?.formatted_address||""),[A,p]=T([]),[w,f]=T(!1),[y,M]=T(!1),[E,I]=T(!1),L=J(null),x=J(null),O=Q("GOOGLE_MAPS_API_KEY")||"",b=v&&!!O;z(()=>{const t=d?.formatted_address??"";m(e=>e===t?e:t)},[d]),z(()=>{if(!b||E)return;const t=window.google;if(t?.maps?.places?.AutocompleteSuggestion){L.current=new t.maps.places.AutocompleteSessionToken,I(!0);return}let e=!1;return(async()=>{try{if(window.google?.maps?.importLibrary||te(O),await window.google.maps.importLibrary("places"),e)return;L.current=new window.google.maps.places.AutocompleteSessionToken,I(!0)}catch{e||M(!0)}})(),()=>{e=!0}},[b,O,E]),z(()=>{if(!b||!E||y)return;if(n.length<3){p([]);return}const t=F.get(n);if(t){p(t);return}return x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{f(!0);try{const e=window.google.maps.places,{suggestions:h}=await e.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:n,sessionToken:L.current}),_=h.filter(s=>s.placePrediction).map(s=>{const a=s.placePrediction,i=[a.mainText?.text,a.secondaryText?.text].filter(Boolean).join(", ");return G.set(i,a),Z(G),{value:i,label:i}});p(_),F.set(n,_),Z(F),ee(F)}catch{M(!0),p([])}finally{f(!1)}},300),()=>{x.current&&clearTimeout(x.current)}},[b,E,y,n]);const V=W(async t=>{const e=Array.isArray(t)?t[0]||"":t;if(!e)return;if(!b){m(e),r({formatted_address:e});return}let h=G.get(e);const _=window.google?.maps?.places;if(_){if(!h){f(!0);try{const{suggestions:s}=await _.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:e,sessionToken:L.current}),a=s.find(i=>[i.placePrediction?.mainText?.text,i.placePrediction?.secondaryText?.text].filter(Boolean).join(", ")===e);a?.placePrediction&&(h=a.placePrediction,G.set(e,h))}catch{}if(!h){f(!1),m(e),r({formatted_address:e});return}}f(!0);try{const s=h.toPlace();await s.fetchFields({fields:["formattedAddress","location","addressComponents"]});const a=s.formattedAddress||e;let i=s.location?.lat()??0,j=s.location?.lng()??0;if(i===0&&j===0&&a)try{const P=await window.google.maps.importLibrary("geocoding"),S=(await new P.Geocoder().geocode({address:a})).results?.[0]?.geometry?.location;S&&(i=S.lat(),j=S.lng())}catch{}const U={formatted_address:a,latitude:i,longitude:j};if(C){const P=s.addressComponents||[],R=P.find(S=>(S.types||[]).includes("postal_code"))?.longText||P.find(S=>(S.types||[]).includes("postal_code"))?.long_name||"",q=R.startsWith("92")?92:parseInt(R.slice(-2),10)||null;U.district_code=q}m(a),p([]),r(U),L.current=new _.AutocompleteSessionToken}catch{m(e),r({formatted_address:e})}finally{f(!1)}}},[b,C,r]),K=t=>{m(t)};return b?B(H,{gap:"tight",children:[k(N,{label:o,value:n,onValueChange:V,onSearchChange:K,placeholder:l("address.placeholder","Enter address..."),emptyMessage:w?l("messages.loading","Loading..."):l("address.noResults","No addresses found"),options:A.map(t=>({value:t.value,label:t.label})),required:c,variant:g?"destructive":void 0,isLoading:w,creatable:!0,createLabel:l("actions.use","Use this address"),disabled:!E&&!y}),y&&k("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:l("address.apiUnavailable","Google Places unavailable \u2014 type address manually")}),u&&k("p",{style:{fontSize:"var(--font-size-xs)",color:g?"var(--destructive-foreground)":"var(--muted-foreground)"},children:u})]}):B(H,{gap:"tight",children:[k(N,{label:o,value:n,onValueChange:V,onSearchChange:K,placeholder:l("address.placeholder","Enter address..."),options:[],required:c,variant:g?"destructive":void 0,creatable:!0,createLabel:l("actions.use","Use this address")}),u&&k("p",{style:{fontSize:"var(--font-size-xs)",color:g?"var(--destructive-foreground)":"var(--muted-foreground)"},children:u})]})};var ce=oe;export{ce as default};
1
+ import{jsx as C,jsxs as V}from"react/jsx-runtime";import{useState as L,useEffect as U,useRef as B,useCallback as Z}from"react";import{Combobox as D,Stack as F}from"@donotdev/components";import{useTranslation as H,getPlatformEnvVar as Q}from"@donotdev/core";const K="dndev-address-autocomplete-cache",X=100;function $(){try{const o=typeof localStorage<"u"?localStorage.getItem(K):null;if(o)return new Map(JSON.parse(o))}catch{}return new Map}function ee(o){try{typeof localStorage<"u"&&localStorage.setItem(K,JSON.stringify([...o]))}catch{}}function W(o){if(o.size>X){const d=o.keys().next().value;d!==void 0&&o.delete(d)}}const z=$(),M=new Map;function te(o){const d={key:o,v:"weekly"},s="google",x="importLibrary",A="__ib__",m=document,u=window;u[s]=u[s]||{};const c=u[s].maps||(u[s].maps={}),l=new Set,a=new URLSearchParams,f=()=>c._p||(c._p=new Promise(async(S,p)=>{const h=m.createElement("script");a.set("libraries",[...l].join(","));for(const y of Object.keys(d))a.set(y.replace(/[A-Z]/g,E=>"_"+E[0].toLowerCase()),d[y]);a.set("callback",s+".maps."+A),h.src="https://maps.googleapis.com/maps/api/js?"+a,c[A]=S,h.onerror=()=>{c._p=null,p(new Error("Google Maps JS API could not load."))};const g=m.querySelector("script[nonce]");g?.nonce&&(h.nonce=g.nonce),m.head.append(h)}));c[x]||(c[x]=(S,...p)=>(l.add(S),f().then(()=>c[x](S,...p))))}const oe=({label:o,value:d,onChange:s,enableGoogleMaps:x=!1,extractDistrictCode:A,error:m,helperText:u,required:c})=>{const{t:l}=H("crud"),[a,f]=L(d?.formatted_address||""),[S,p]=L([]),[h,g]=L(!1),[y,E]=L(!1),[T,q]=L(!1),P=B(null),k=B(null),G=Q("GOOGLE_MAPS_API_KEY")||"",w=x&&!!G;U(()=>{const t=d?.formatted_address??"";f(e=>e===t?e:t)},[d]),U(()=>{if(!w||T)return;const t=window.google;if(t?.maps?.places?.AutocompleteSuggestion){P.current=new t.maps.places.AutocompleteSessionToken,q(!0);return}let e=!1;return(async()=>{try{if(window.google?.maps?.importLibrary||te(G),await window.google.maps.importLibrary("places"),e)return;P.current=new window.google.maps.places.AutocompleteSessionToken,q(!0)}catch{e||E(!0)}})(),()=>{e=!0}},[w,G,T]),U(()=>{if(!w||!T||y)return;if(a.length<3){p([]);return}const t=z.get(a);if(t){p(t);return}return k.current&&clearTimeout(k.current),k.current=setTimeout(async()=>{g(!0);try{const e=window.google.maps.places,{suggestions:v}=await e.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:a,sessionToken:P.current}),b=v.filter(r=>r.placePrediction).map(r=>{const n=r.placePrediction,i=[n.mainText?.text,n.secondaryText?.text].filter(Boolean).join(", ");return M.set(i,n),W(M),{value:i,label:i}});p(b),z.set(a,b),W(z),ee(z)}catch{E(!0),p([])}finally{g(!1)}},300),()=>{k.current&&clearTimeout(k.current)}},[w,T,y,a]);const J=Z(async t=>{const e=Array.isArray(t)?t[0]||"":t;if(!e)return;if(!w){f(e),s({formatted_address:e});return}let v=M.get(e);const b=window.google?.maps?.places;if(b){if(!v){g(!0);try{const{suggestions:r}=await b.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:e,sessionToken:P.current}),n=r.find(i=>[i.placePrediction?.mainText?.text,i.placePrediction?.secondaryText?.text].filter(Boolean).join(", ")===e);n?.placePrediction&&(v=n.placePrediction,M.set(e,v))}catch{}if(!v){g(!1),f(e),s({formatted_address:e});return}}g(!0);try{const r=v.toPlace();await r.fetchFields({fields:["formattedAddress","location","addressComponents"]});const n=r.formattedAddress||e;let i=r.location?.lat()??0,I=r.location?.lng()??0;if(i===0&&I===0&&n)try{const j=await window.google.maps.importLibrary("geocoding"),_=(await new j.Geocoder().geocode({address:n})).results?.[0]?.geometry?.location;_&&(i=_.lat(),I=_.lng())}catch{}const R={formatted_address:n,latitude:i,longitude:I};if(A){const j=r.addressComponents||[],_=j.find(O=>(O.types||[]).includes("postal_code"))?.longText||j.find(O=>(O.types||[]).includes("postal_code"))?.long_name||"",Y=_.startsWith("92")?92:parseInt(_.slice(-2),10)||null;R.district_code=Y}f(n),p([]),s(R),P.current=new b.AutocompleteSessionToken}catch{f(e),s({formatted_address:e})}finally{g(!1)}}},[w,A,s]),N=t=>{f(t)};return w?V(F,{gap:"tight",children:[C(D,{label:o,value:a,onValueChange:J,onSearchChange:N,placeholder:l("address.placeholder","Enter address..."),emptyMessage:h?l("messages.loading","Loading..."):l("address.noResults","No addresses found"),options:S.map(t=>({value:t.value,label:t.label})),required:c,variant:m?"destructive":void 0,isLoading:h,creatable:!0,createLabel:l("actions.use","Use this address"),disabled:!T&&!y}),y&&C("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:l("address.apiUnavailable","Google Places unavailable \u2014 type address manually")}),u&&C("p",{style:{fontSize:"var(--font-size-xs)",color:m?"var(--destructive-foreground)":"var(--muted-foreground)"},children:u})]}):V(F,{gap:"tight",children:[C(D,{label:o,value:a,onValueChange:J,onSearchChange:N,placeholder:l("address.placeholder","Enter address..."),options:[],required:c,variant:m?"destructive":void 0,creatable:!0,createLabel:l("actions.use","Use this address")}),u&&C("p",{style:{fontSize:"var(--font-size-xs)",color:m?"var(--destructive-foreground)":"var(--muted-foreground)"},children:u})]})};var ae=oe;export{ae as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as v,Input as h,cn as u,Stack as n}from"@donotdev/components";const f=({config:t,value:a,onChange:s,error:g,helperText:l,t:c,className:i,...d})=>{const m=r=>r.split(" ").map(p=>p.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(v,{src:a,alt:t.label||"Avatar",fallback:m(t.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(h,{type:"url",className:u("dndev-w-full",i),placeholder:c("common.enterAvatarUrl"),value:a,onChange:r=>s(r.target.value),...d})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var j=f;export{f as AvatarFieldComponent,j as default};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as p,Input as u,cn as f,Stack as n}from"@donotdev/components";const s=({config:r,value:t,onChange:c,error:A,helperText:l,t:i,className:d,...v})=>{const h=a=>a.split(" ").map(m=>m.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(p,{src:t,alt:r.label||"Avatar",fallback:h(r.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(u,{type:"url",className:f("dndev-w-full",d),placeholder:i("common.enterAvatarUrl"),value:t,onChange:a=>c(a.target.value),...v})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var g=s;export{s as AvatarFieldComponent,g as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Badge as m,Input as f,cn as g,Stack as a}from"@donotdev/components";const p=({config:u,value:r,onChange:d,error:v,helperText:n,t:o,variant:i="default",className:l,...c})=>t(a,{children:[t(a,{direction:"row",align:"center",children:[e(m,{variant:i,style:{minWidth:0},children:r||o("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",l),placeholder:o("common.enterBadgeText"),value:r,onChange:s=>d(s.target.value),...c})})]}),n&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:n})]});var j=p;export{p as BadgeFieldComponent,j as default};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Badge as v,Input as f,cn as g,Stack as o}from"@donotdev/components";const l=({config:p,value:a,onChange:d,error:u,helperText:t,t:n,variant:s="default",className:i,...c})=>r(o,{children:[r(o,{direction:"row",align:"center",children:[e(v,{variant:s,style:{minWidth:0},children:a||n("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",i),placeholder:n("common.enterBadgeText"),value:a,onChange:m=>d(m.target.value),...c})})]}),t&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:t})]});var h=l;export{l as BadgeFieldComponent,h as default};
@@ -1 +1 @@
1
- import{jsx as i}from"react/jsx-runtime";import{Button as a}from"@donotdev/components";const l=({label:t,type:o,onClick:e,variant:n,disabled:r=!1})=>i(a,{type:o,onClick:e,variant:n,disabled:r,children:t});var m=l;export{m as default};
1
+ import{jsx as r}from"react/jsx-runtime";import{Button as e}from"@donotdev/components";const n=({label:a,type:t,onClick:o,variant:i,disabled:l=!1})=>r(e,{type:t,onClick:o,variant:i,disabled:l,children:a});var s=n;export{s as default};
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import{Checkbox as h}from"@donotdev/components";const c=({label:o,checked:r=!1,onChange:e,required:t})=>n(h,{checked:r,onCheckedChange:a=>{e&&e({target:{checked:a}})},label:o,required:t});var C=c;export{C as default};
1
+ import{jsx as d}from"react/jsx-runtime";import{Checkbox as h}from"@donotdev/components";const t=({label:r,checked:a=!1,onChange:e,required:c})=>d(h,{checked:a,onCheckedChange:o=>{e&&e({target:{checked:o}})},label:r,required:c});var n=t;export{n as default};
@@ -1 +1 @@
1
- import{jsx as a,jsxs as c}from"react/jsx-runtime";import{useMemo as E,useId as M}from"react";import{Combobox as V,Stack as d}from"@donotdev/components";import{useTranslation as _}from"@donotdev/core";const $=({label:u,value:n,options:s,error:f,helperText:o,onChange:l,onBlur:m,required:p,placeholder:g,translationNamespace:h="dndev",placeholderKey:b="actions.select",placeholderDefault:v="Select",creatable:x=!1,createLabel:C,emptyMessage:y})=>{const{t:r}=_(h),i=M(),S=E(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),j=e=>{if(l){const O={target:{value:Array.isArray(e)?e[0]||"":e}};l(O)}},z=e=>{e||m?.()},t=!!f,A=`${i}-error`,I=`${i}-helper`;return c(d,{gap:"tight",children:[a(V,{label:u,value:n||"",onValueChange:j,onOpenChange:z,placeholder:g||r(b,v),emptyMessage:y||r("messages.noResults","No results found"),creatable:x,createLabel:C||r("actions.create","Create"),options:S,required:p,variant:t?"destructive":void 0,clearable:!!n}),t&&c(d,{id:A,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),o]}),o&&!t&&a("p",{id:I,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var D=$;export{D as default};
1
+ import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useMemo as L,useId as N}from"react";import{Combobox as $,Stack as d}from"@donotdev/components";import{useTranslation as D}from"@donotdev/core";const I=({label:u,value:l,options:s,error:p,helperText:a,onChange:n,onBlur:m,required:g,placeholder:h,translationNamespace:v="dndev",placeholderKey:f="actions.select",placeholderDefault:b="Select",creatable:x=!1,createLabel:y,emptyMessage:S})=>{const{t:r}=D(v),i=N(),z=L(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),C=e=>{if(n){const q={target:{value:Array.isArray(e)?e[0]||"":e}};n(q)}},A=e=>{e||m?.()},t=!!p,M=`${i}-error`,j=`${i}-helper`;return c(d,{gap:"tight",children:[o($,{label:u,value:l||"",onValueChange:C,onOpenChange:A,placeholder:h||r(f,b),emptyMessage:S||r("messages.noResults","No results found"),creatable:x,createLabel:y||r("actions.create","Create"),options:z,required:g,variant:t?"destructive":void 0,clearable:!!l}),t&&c(d,{id:M,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),a]}),a&&!t&&o("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})};var O=I;export{O as default};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as h}from"react/jsx-runtime";import{useState as v,useEffect as z,useId as L}from"react";import{Input as B,FloatingLabel as D,Stack as M}from"@donotdev/components";const U=({label:b,value:t,onChange:F,currency:s="EUR",locale:C,error:c,helperText:u,required:S=!1,disabled:i=!1,placeholder:x})=>{const d=L(),I=C||(typeof navigator<"u"?navigator.language:"en-US"),a=e=>e==null||isNaN(e)?"":(e/100).toString(),f=e=>{if(!e||e.trim()==="")return null;const n=e.replace(/[^\d.,\-]/g,"").replace(",","."),l=parseFloat(n);return isNaN(l)?null:Math.round(l*100)},[p,o]=v(a(t)),[m,g]=v(!1);z(()=>{m?f(p)!==t&&o(a(t)):o(a(t))},[t,m]);const N=e=>{const n=e.target.value;o(n);const E={target:{value:f(n)}};F(E)},V=()=>g(!0),j=()=>g(!1),y=(()=>{try{return new Intl.NumberFormat(I,{style:"currency",currency:s,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||s}catch{return s}})();return h(M,{gap:"tight",children:[r(D,{htmlFor:d,label:b,disabled:i,required:S,children:h("div",{style:{position:"relative"},children:[r("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:y}),r(B,{id:d,type:"text",inputMode:"decimal",bare:!0,value:p,onChange:N,onFocus:V,onBlur:j,disabled:i,placeholder:x||"0","data-variant":c?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${y.length*.6}em + var(--gap-sm))`}})]})}),u&&r("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:u})]})};var P=U;export{P as default};
1
+ import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as h,useEffect as j,useId as q}from"react";import{Input as C,FloatingLabel as L,Stack as M}from"@donotdev/components";const U=({label:b,value:r,onChange:x,currency:o="EUR",locale:F,error:i,helperText:d,required:I=!1,disabled:u=!1,placeholder:N})=>{const c=q(),S=F||(typeof navigator<"u"?navigator.language:"en-US"),l=e=>e==null||isNaN(e)?"":(e/100).toString(),p=e=>{if(!e||e.trim()==="")return null;const a=e.replace(/[^\d.,\-]/g,"").replace(",","."),t=parseFloat(a);return isNaN(t)?null:Math.round(t*100)},[g,s]=h(l(r)),[v,m]=h(!1);j(()=>{v?p(g)!==r&&s(l(r)):s(l(r))},[r,v]);const z=e=>{const a=e.target.value;s(a);const t={target:{value:p(a)}};x(t)},E=()=>m(!0),T=()=>m(!1),f=(()=>{try{return new Intl.NumberFormat(S,{style:"currency",currency:o,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||o}catch{return o}})();return y(M,{gap:"tight",children:[n(L,{htmlFor:c,label:b,disabled:u,required:I,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(C,{id:c,type:"text",inputMode:"decimal",bare:!0,value:g,onChange:z,onFocus:E,onBlur:T,disabled:u,placeholder:N||"0","data-variant":i?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${f.length*.6}em + var(--gap-sm))`}})]})}),d&&n("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var B=U;export{B as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o}from"react/jsx-runtime";import{useId as z}from"react";import{DatePicker as $,DateTimePicker as y,Input as m,cn as v,Stack as d}from"@donotdev/components";const w=({label:u,value:s,onChange:f,error:c,helperText:i,mode:a="date",required:g,...h})=>{const r=z(),e=!!c,p=n=>{const S=n.target.value?new Date(n.target.value).toISOString():null;f(S)};let l="";if(s){const n=new Date(s);a==="date"?l=n.toISOString().split("T")[0]||"":a==="datetime-local"?l=n.toISOString().slice(0,16)||"":a==="month"?l=n.toISOString().slice(0,7):a==="time"?l=n.toISOString().slice(11,16):a==="week"&&(l=n.toISOString().split("T")[0]||"")}return a==="date"?o(d,{gap:"tight",children:[t($,{id:r,label:u,value:s??null,onChange:f,required:g,"aria-describedby":v(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&o(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),c]}),i&&!e&&t("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):a==="datetime-local"?o(d,{gap:"tight",children:[t(y,{id:r,label:u,value:s??null,onChange:f,required:g,"aria-describedby":v(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&o(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),c]}),i&&!e&&t("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):o(d,{gap:"tight",children:[t(m,{id:r,label:u,type:a,value:l,onChange:p,required:g,"aria-describedby":v(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...h}),e&&o(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),c]}),i&&!e&&t("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})};var D=w;export{D as default};
1
+ import{jsx as i,jsxs as n}from"react/jsx-runtime";import{useId as m}from"react";import{DatePicker as z,DateTimePicker as $,Input as b,cn as h,Stack as d}from"@donotdev/components";const x=({label:u,value:s,onChange:v,error:c,helperText:t,mode:a="date",required:g,...p})=>{const r=m(),e=!!c,f=o=>{const S=o.target.value?new Date(o.target.value).toISOString():null;v(S)};let l="";if(s){const o=new Date(s);a==="date"?l=o.toISOString().split("T")[0]||"":a==="datetime-local"?l=o.toISOString().slice(0,16)||"":a==="month"?l=o.toISOString().slice(0,7):a==="time"?l=o.toISOString().slice(11,16):a==="week"&&(l=o.toISOString().split("T")[0]||"")}return a==="date"?n(d,{gap:"tight",children:[i(z,{id:r,label:u,value:s??null,onChange:v,required:g,"aria-describedby":h(e&&`${r}-error`,t&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&n(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),c]}),t&&!e&&i("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]}):a==="datetime-local"?n(d,{gap:"tight",children:[i($,{id:r,label:u,value:s??null,onChange:v,required:g,"aria-describedby":h(e&&`${r}-error`,t&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&n(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),c]}),t&&!e&&i("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]}):n(d,{gap:"tight",children:[i(b,{id:r,label:u,type:a,value:l,onChange:f,required:g,"aria-describedby":h(e&&`${r}-error`,t&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...p}),e&&n(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),c]}),t&&!e&&i("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]})};var y=x;export{y as default};
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as i,Fragment as G}from"react/jsx-runtime";import{Upload as K,X as Y,FileText as m,FileSpreadsheet as q,File as J,Loader2 as Q,Eye as Z}from"lucide-react";import{useState as C,useRef as $,useImperativeHandle as ee,forwardRef as re}from"react";import{Button as k,BUTTON_VARIANT as I,Text as d,Stack as u,Progress as te,Dialog as ne,DialogContent as ie,DialogHeader as ae,DialogTitle as le}from"@donotdev/components";import{handleError as y,useTranslation as oe}from"@donotdev/core";import{useFileUpload as se}from"../../../hooks/useFileUpload";import{uploadFile as de,deleteFile as ce,getFileIcon as pe,formatFileSize as ue,getDocumentAcceptString as me}from"../../../utils/fileStorage";const fe=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],ve=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"];function ge({type:c,className:a}){switch(c){case"pdf":return r(m,{className:a,style:{color:"var(--destructive)"}});case"doc":return r(m,{className:a,style:{color:"var(--primary)"}});case"xls":return r(q,{className:a,style:{color:"var(--success)"}});case"ppt":return r(m,{className:a,style:{color:"var(--warning)"}});case"text":case"html":return r(m,{className:a});default:return r(J,{className:a})}}function S(c){const a="."+c.name.split(".").pop()?.toLowerCase();return fe.includes(a)}const A=re(({name:c="document",label:a,value:E,onChange:z,error:f,helperText:x,multiple:v=!1,maxFiles:P=10,maxSize:D=25*1024*1024,storagePath:w,required:L,enablePreview:T=!0},O)=>{const{t:l}=oe("crud"),[F,g]=C(!1),[h,b]=C(null),p=$(null),U=me();function _(e,t){return de(e,{storagePath:w,onProgress:n=>t(n.progress)})}const{files:s,addFiles:N,removeFile:M}=se({name:c,value:E,onChange:z,multiple:v,maxFiles:P,maxSize:D,accept:ve,storagePath:w,uploadFn:_});ee(O,()=>({upload:async()=>{},getDocuments:()=>s}),[s]);function R(e){const t=Array.from(e.target.files||[]);if(t.length>0){const n=t.filter(o=>S(o)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:o.name}),severity:"warning",showNotification:!0}),!1));n.length>0&&N(n)}p.current&&(p.current.value="")}function H(e){e.preventDefault(),g(!1);const n=Array.from(e.dataTransfer.files).filter(o=>S(o)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:o.name}),severity:"warning",showNotification:!0}),!1));n.length>0&&N(n)}async function j(e){const t=s.find(n=>n.id===e);if(t)try{t.uploaded&&"url"in t.uploaded&&await ce(t.uploaded),M(e)}catch(n){y(n,{userMessage:l("document.delete.failed"),severity:"error",showNotification:!0})}}function W(e){if(e.uploaded&&"url"in e.uploaded){const t=e.uploaded;t.mimeType==="application/pdf"&&b(t.url)}}const B=v||s.length===0;return i(G,{children:[i(u,{gap:"tight",children:[i(d,{level:"body",textAlign:"start",children:[a,L?"*":""]}),B&&i("div",{role:"button",tabIndex:0,"aria-label":l("document.upload.ariaLabel"),className:"dndev-surface","data-variant":f?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:F?"var(--primary)":f?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:F?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:H,onClick:()=>p.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),p.current?.click())},children:[r("input",{ref:p,type:"file",accept:U,multiple:v,style:{display:"none"},onChange:R}),i(u,{align:"center",justify:"center",children:[r(K,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),r(d,{as:"p",variant:"muted",level:"small",textAlign:"center",children:l("document.upload.hint")}),r(d,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),s.length>0&&r(u,{gap:"tight",children:s.map(e=>{const t=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,n=pe(t||"",e.file.name),o=e.status==="uploading",V=t==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf"),X=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return i("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[r(ge,{type:n,className:"dndev-size-md"}),i(u,{gap:"none",style:{flex:1,minWidth:0},children:[r(d,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),i(d,{level:"caption",variant:"muted",children:[ue(X),e.error&&i("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),o&&r(te,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),i(u,{direction:"row",gap:"tight",children:[T&&V&&e.status==="complete"&&r(k,{variant:I.GHOST,onClick:()=>W(e),"aria-label":l("document.preview.ariaLabel"),children:r(Z,{className:"dndev-size-sm"})}),o?r(Q,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):r(k,{variant:I.GHOST,onClick:()=>j(e.id),"aria-label":l("document.delete.ariaLabel"),children:r(Y,{className:"dndev-size-sm"})})]})]},e.id)})}),x&&r(d,{level:"caption",variant:f?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:x})]}),T&&h&&r(ne,{open:!!h,onOpenChange:()=>b(null),children:i(ie,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[r(ae,{children:r(le,{children:l("document.preview.title")})}),r("iframe",{src:h,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});A.displayName="DocumentFieldComponent";var Ne=A;export{Ne as default};
1
+ "use client";import{jsx as a,jsxs as n,Fragment as K}from"react/jsx-runtime";import{Upload as V,X as _,FileText as u,FileSpreadsheet as J,File as Q,Loader2 as Y,Eye as Z}from"lucide-react";import{useState as D,useRef as $,useImperativeHandle as ee,forwardRef as ae}from"react";import{Button as k,BUTTON_VARIANT as C,Text as s,Stack as m,Progress as re,Dialog as te,DialogContent as ne,DialogHeader as ie,DialogTitle as le}from"@donotdev/components";import{handleError as y,useTranslation as oe}from"@donotdev/core";import{useFileUpload as se}from"../../../hooks/useFileUpload";import{uploadFile as de,deleteFile as ce,getFileIcon as pe,formatFileSize as me,getDocumentAcceptString as ue}from"../../../utils/fileStorage";const ve=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],fe=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"];function ge({type:d,className:i}){switch(d){case"pdf":return a(u,{className:i,style:{color:"var(--destructive)"}});case"doc":return a(u,{className:i,style:{color:"var(--primary)"}});case"xls":return a(J,{className:i,style:{color:"var(--success)"}});case"ppt":return a(u,{className:i,style:{color:"var(--warning)"}});case"text":case"html":return a(u,{className:i});default:return a(Q,{className:i})}}function z(d){const i="."+d.name.split(".").pop()?.toLowerCase();return ve.includes(i)}const P=ae(({name:d="document",label:i,value:S,onChange:A,error:v,helperText:x,multiple:f=!1,maxFiles:L=10,maxSize:H=25*1024*1024,storagePath:w,required:I,enablePreview:b=!0},R)=>{const{t:l}=oe("crud"),[N,g]=D(!1),[h,T]=D(null),c=$(null),E=ue();function M(e,r){return de(e,{storagePath:w,onProgress:t=>r(t.progress)})}const{files:o,addFiles:F,removeFile:O}=se({name:d,value:S,onChange:A,multiple:f,maxFiles:L,maxSize:H,accept:fe,storagePath:w,uploadFn:M});ee(R,()=>({upload:async()=>{},getDocuments:()=>o}),[o]);function W(e){const r=Array.from(e.target.files||[]);if(r.length>0){const t=r.filter(p=>z(p)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:p.name}),severity:"warning",showNotification:!0}),!1));t.length>0&&F(t)}c.current&&(c.current.value="")}function j(e){e.preventDefault(),g(!1);const r=Array.from(e.dataTransfer.files).filter(t=>z(t)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:t.name}),severity:"warning",showNotification:!0}),!1));r.length>0&&F(r)}async function B(e){const r=o.find(t=>t.id===e);if(r)try{r.uploaded&&"url"in r.uploaded&&await ce(r.uploaded),O(e)}catch(t){y(t,{userMessage:l("document.delete.failed"),severity:"error",showNotification:!0})}}function U(e){if(e.uploaded&&"url"in e.uploaded){const r=e.uploaded;r.mimeType==="application/pdf"&&T(r.url)}}const G=f||o.length===0;return n(K,{children:[n(m,{gap:"tight",children:[n(s,{level:"body",textAlign:"start",children:[i,I?"*":""]}),G&&n("div",{role:"button",tabIndex:0,"aria-label":l("document.upload.ariaLabel"),className:"dndev-surface","data-variant":v?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:N?"var(--primary)":v?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:N?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:j,onClick:()=>c.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c.current?.click())},children:[a("input",{ref:c,type:"file",accept:E,multiple:f,style:{display:"none"},onChange:W}),n(m,{align:"center",justify:"center",children:[a(V,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(s,{as:"p",variant:"muted",level:"small",textAlign:"center",children:l("document.upload.hint")}),a(s,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&a(m,{gap:"tight",children:o.map(e=>{const r=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,t=pe(r||"",e.file.name),p=e.status==="uploading",X=r==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf"),q=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ge,{type:t,className:"dndev-size-md"}),n(m,{gap:"none",style:{flex:1,minWidth:0},children:[a(s,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(s,{level:"caption",variant:"muted",children:[me(q),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),p&&a(re,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),n(m,{direction:"row",gap:"tight",children:[b&&X&&e.status==="complete"&&a(k,{variant:C.GHOST,onClick:()=>U(e),"aria-label":l("document.preview.ariaLabel"),children:a(Z,{className:"dndev-size-sm"})}),p?a(Y,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(k,{variant:C.GHOST,onClick:()=>B(e.id),"aria-label":l("document.delete.ariaLabel"),children:a(_,{className:"dndev-size-sm"})})]})]},e.id)})}),x&&a(s,{level:"caption",variant:v?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:x})]}),b&&h&&a(te,{open:!!h,onOpenChange:()=>T(null),children:n(ne,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[a(ie,{children:a(le,{children:l("document.preview.title")})}),a("iframe",{src:h,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});P.displayName="DocumentFieldComponent";var he=P;export{he as default};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as p}from"react/jsx-runtime";import{Select as g,Stack as m}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";const h=({label:o,value:t,options:s,error:l,helperText:n,onChange:a,onBlur:i,required:c})=>{const{t:d}=f("crud"),u=t!=null?String(t):"";return p(m,{gap:"tight",children:[r(g,{label:o,value:u,onValueChange:e=>{a&&a({target:{value:e}})},onOpenChange:e=>!e&&i?.(),placeholder:d("actions.select","Select"),required:c,options:s.map(e=>({value:String(e.value),label:e.label}))}),n&&r("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:n})]})};var C=h;export{C as default};
1
+ import{jsx as o,jsxs as g}from"react/jsx-runtime";import{Select as d,Stack as v}from"@donotdev/components";import{useTranslation as m}from"@donotdev/core";const f=({label:l,value:r,options:n,error:s,helperText:a,onChange:t,onBlur:i,required:u})=>{const{t:p}=m("crud"),c=r!=null?String(r):"";return g(v,{gap:"tight",children:[o(d,{label:l,value:c,onValueChange:e=>{t&&t({target:{value:e}})},onOpenChange:e=>!e&&i?.(),placeholder:p("actions.select","Select"),required:u,options:n.map(e=>({value:String(e.value),label:e.label}))}),a&&o("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var h=f;export{h as default};
@@ -1 +1 @@
1
- import{jsx as a,jsxs as u}from"react/jsx-runtime";import{Clock as S}from"lucide-react";import{useState as w,useMemo as C}from"react";import{Label as $,Stack as l,Button as b,Slider as E}from"@donotdev/components";const x=[15,30,45,60,90,120,150,180],N={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 _(t,n){const i=t<60?`${t}m`:t%60===0?`${t/60}h`:`${Math.floor(t/60)}h${t%60}`,s=N[t];return!n||!s?i:n(`crud:${s}`,{defaultValue:i})??i}const j=({label:t,value:n,onChange:i,error:s,helperText:d,disabled:c,required:h,readonly:M,min:p=0,max:g=480,step:V=5,t:o})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,f=x.includes(r),[m,v]=w(!f&&r>0),k=C(()=>x.map(e=>({minutes:e,label:_(e,o)})),[o]),y=o?o("crud:duration.custom",{defaultValue:"Custom"}):"Custom";if(M){const e=r===0?o?o("crud:duration.zero",{defaultValue:"\u2014"}):"\u2014":r<60?o?o("crud:duration.minutes",{count:r,defaultValue:`${r} min`}):`${r} min`:o?o("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60,defaultValue:`${Math.floor(r/60)}h${r%60?` ${r%60}min`:""}`}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return u(l,{gap:"tight",children:[a($,{required:h,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:t}),u(l,{direction:"row",gap:"tight",align:"center",children:[a(S,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),a("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:e})]}),d&&a("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})}return u(l,{children:[a($,{required:h,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:t}),u(l,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[k.map(({minutes:e,label:z})=>u(b,{type:"button",variant:r===e?"primary":"outline",disabled:c,onClick:()=>{v(!1),i(e)},"aria-pressed":r===e,"aria-label":z,children:[a(S,{size:14,style:{marginRight:"var(--gap-xs)"},"aria-hidden":!0}),z]},e)),a(b,{type:"button",variant:m?"primary":"outline",disabled:c,onClick:()=>{v(!0),!f&&r>0?i(r):i(30)},"aria-pressed":m,"aria-label":y,children:y})]}),m&&a(l,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:a(E,{value:[f?30:r],onValueChange:([e])=>i(Math.max(p,Math.min(g,e??0))),min:p,max:g,step:V,showValue:!0,disabled:c,"aria-label":t})}),d&&a("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var W=j;export{x as DURATION_PRESETS,W as default};
1
+ import{jsx as i,jsxs as l}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as V,useMemo as k}from"react";import{Label as z,Stack as s,Button as S,Slider as w}from"@donotdev/components";const f=[15,30,45,60,90,120,150,180],N={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 q(e,n){const o=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,u=N[e];return!n||!u?o:n(`crud:${u}`,{defaultValue:o})??o}const W=({label:e,value:n,onChange:o,error:u,helperText:d,disabled:m,required:p,readonly:C,min:g=0,max:v=480,step:M=5,t})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,h=f.includes(r),[c,b]=V(!h&&r>0),T=k(()=>f.map(a=>({minutes:a,label:q(a,t)})),[t]),y=t?t("crud:duration.custom",{defaultValue:"Custom"}):"Custom";if(C){const a=r===0?t?t("crud:duration.zero",{defaultValue:"\u2014"}):"\u2014":r<60?t?t("crud:duration.minutes",{count:r,defaultValue:`${r} min`}):`${r} min`:t?t("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60,defaultValue:`${Math.floor(r/60)}h${r%60?` ${r%60}min`:""}`}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return l(s,{gap:"tight",children:[i(z,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),l(s,{direction:"row",gap:"tight",align:"center",children:[i(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),i("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:u?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})}return l(s,{children:[i(z,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),l(s,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[T.map(({minutes:a,label:$})=>l(S,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),o(a)},"aria-pressed":r===a,"aria-label":$,children:[i(x,{size:14,style:{marginRight:"var(--gap-xs)"},"aria-hidden":!0}),$]},a)),i(S,{type:"button",variant:c?"primary":"outline",disabled:m,onClick:()=>{b(!0),!h&&r>0?o(r):o(30)},"aria-pressed":c,"aria-label":y,children:y})]}),c&&i(s,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:i(w,{value:[h?30:r],onValueChange:([a])=>o(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:M,showValue:!0,disabled:m,"aria-label":e})}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:u?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var j=W;export{f as DURATION_PRESETS,j as default};
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as l}from"react/jsx-runtime";import{Upload as M,X as _,File as E,Loader2 as H,FileText as g,FileSpreadsheet as V,FileImage as G,FileVideo as K,FileAudio as P,FileArchive as W,FileCode as X}from"lucide-react";import{useState as q,useRef as J,useImperativeHandle as Q,forwardRef as Y}from"react";import{Button as Z,BUTTON_VARIANT as $,Text as c,Stack as u,Progress as D}from"@donotdev/components";import{handleError as ee,useTranslation as re}from"@donotdev/core";import{useFileUpload as ae}from"../../../hooks/useFileUpload";import{uploadFile as ie,deleteFile as le,getFileIcon as ne,formatFileSize as te}from"../../../utils/fileStorage";function oe({type:p,className:a}){switch(p){case"pdf":return r(g,{className:a,style:{color:"var(--destructive)"}});case"doc":return r(g,{className:a,style:{color:"var(--primary)"}});case"xls":return r(V,{className:a,style:{color:"var(--success)"}});case"ppt":return r(g,{className:a,style:{color:"var(--warning)"}});case"image":return r(G,{className:a});case"video":return r(K,{className:a});case"audio":return r(P,{className:a});case"archive":return r(W,{className:a});case"html":case"text":return r(X,{className:a});default:return r(E,{className:a})}}const T=Y(({name:p="file",label:a,value:w,onChange:N,error:m,helperText:y,accept:v,multiple:s=!1,maxFiles:k=10,maxSize:z=50*1024*1024,storagePath:h,required:A},I)=>{const{t}=re("crud"),[F,f]=q(!1),d=J(null);function C(e,i){return ie(e,{storagePath:h,onProgress:n=>i(n.progress)})}const{files:o,addFiles:x,removeFile:S}=ae({name:p,value:w,onChange:N,multiple:s,maxFiles:k,maxSize:z,accept:v?[v]:[],storagePath:h,uploadFn:C});Q(I,()=>({upload:async()=>{},getFiles:()=>o}),[o]);function R(e){const i=Array.from(e.target.files||[]);i.length>0&&x(i),d.current&&(d.current.value="")}function j(e){e.preventDefault(),f(!1),x(Array.from(e.dataTransfer.files))}async function L(e){const i=o.find(n=>n.id===e);if(i)try{i.uploaded&&"url"in i.uploaded&&await le(i.uploaded),S(e)}catch(n){ee(n,{userMessage:t("file.delete.failed"),severity:"error",showNotification:!0})}}const U=s||o.length===0;return l(u,{gap:"tight",children:[l(c,{level:"body",textAlign:"start",children:[a,A?"*":""]}),U&&l("div",{role:"button",tabIndex:0,"aria-label":t(s?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":m?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:F?"var(--primary)":m?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:F?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:j,onClick:()=>d.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),d.current?.click())},children:[r("input",{ref:d,type:"file",accept:v,multiple:s,style:{display:"none"},onChange:R}),l(u,{align:"center",justify:"center",children:[r(M,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),r(c,{as:"p",variant:"muted",level:"small",textAlign:"center",children:t(s?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),o.length>0&&r(u,{gap:"tight",children:o.map((e,i)=>{const n=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,O=ne(n||"",e.file.name),b=e.status==="uploading",B=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return l("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[r(oe,{type:O,className:"dndev-size-md"}),l(u,{gap:"none",style:{flex:1,minWidth:0},children:[r(c,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),l(c,{level:"caption",variant:"muted",children:[te(B),e.error&&l("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),b&&r(D,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),b?r(H,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):r(Z,{variant:$.GHOST,onClick:()=>L(e.id),"aria-label":t("file.delete.ariaLabel"),children:r(_,{className:"dndev-size-sm"})})]},e.id)})}),y&&r(c,{level:"caption",variant:m?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:y})]})});T.displayName="FileFieldComponent";var fe=T;export{fe as default};
1
+ "use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{Upload as B,X as M,File as U,Loader2 as E,FileText as g,FileSpreadsheet as H,FileImage as V,FileVideo as q,FileAudio as G,FileArchive as K,FileCode as W}from"lucide-react";import{useState as X,useRef as _,useImperativeHandle as J,forwardRef as Q}from"react";import{Button as Y,BUTTON_VARIANT as Z,Text as d,Stack as u,Progress as $}from"@donotdev/components";import{handleError as ee,useTranslation as ae}from"@donotdev/core";import{useFileUpload as re}from"../../../hooks/useFileUpload";import{uploadFile as le,deleteFile as se,getFileIcon as te,formatFileSize as ie}from"../../../utils/fileStorage";function ne({type:p,className:r}){switch(p){case"pdf":return a(g,{className:r,style:{color:"var(--destructive)"}});case"doc":return a(g,{className:r,style:{color:"var(--primary)"}});case"xls":return a(H,{className:r,style:{color:"var(--success)"}});case"ppt":return a(g,{className:r,style:{color:"var(--warning)"}});case"image":return a(V,{className:r});case"video":return a(q,{className:r});case"audio":return a(G,{className:r});case"archive":return a(K,{className:r});case"html":case"text":return a(W,{className:r});default:return a(U,{className:r})}}const b=Q(({name:p="file",label:r,value:T,onChange:w,error:m,helperText:h,accept:v,multiple:n=!1,maxFiles:k=10,maxSize:z=50*1024*1024,storagePath:y,required:C},S)=>{const{t:c}=ae("crud"),[x,f]=X(!1),o=_(null);function A(e,l){return le(e,{storagePath:y,onProgress:t=>l(t.progress)})}const{files:i,addFiles:F,removeFile:D}=re({name:p,value:T,onChange:w,multiple:n,maxFiles:k,maxSize:z,accept:v?[v]:[],storagePath:y,uploadFn:A});J(S,()=>({upload:async()=>{},getFiles:()=>i}),[i]);function I(e){const l=Array.from(e.target.files||[]);l.length>0&&F(l),o.current&&(o.current.value="")}function L(e){e.preventDefault(),f(!1),F(Array.from(e.dataTransfer.files))}async function P(e){const l=i.find(t=>t.id===e);if(l)try{l.uploaded&&"url"in l.uploaded&&await se(l.uploaded),D(e)}catch(t){ee(t,{userMessage:c("file.delete.failed"),severity:"error",showNotification:!0})}}const R=n||i.length===0;return s(u,{gap:"tight",children:[s(d,{level:"body",textAlign:"start",children:[r,C?"*":""]}),R&&s("div",{role:"button",tabIndex:0,"aria-label":c(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":m?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:x?"var(--primary)":m?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:x?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:L,onClick:()=>o.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),o.current?.click())},children:[a("input",{ref:o,type:"file",accept:v,multiple:n,style:{display:"none"},onChange:I}),s(u,{align:"center",justify:"center",children:[a(B,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(d,{as:"p",variant:"muted",level:"small",textAlign:"center",children:c(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),i.length>0&&a(u,{gap:"tight",children:i.map((e,l)=>{const t=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,O=te(t||"",e.file.name),N=e.status==="uploading",j=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return s("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ne,{type:O,className:"dndev-size-md"}),s(u,{gap:"none",style:{flex:1,minWidth:0},children:[a(d,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),s(d,{level:"caption",variant:"muted",children:[ie(j),e.error&&s("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),N&&a($,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),N?a(E,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(Y,{variant:Z.GHOST,onClick:()=>P(e.id),"aria-label":c("file.delete.ariaLabel"),children:a(M,{className:"dndev-size-sm"})})]},e.id)})}),h&&a(d,{level:"caption",variant:m?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:h})]})});b.displayName="FileFieldComponent";var oe=b;export{oe as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as m}from"react";import{Checkbox as T,Label as O,Sheet as u,Stack as D,Text as j}from"@donotdev/components";import{useTranslation as H}from"@donotdev/core";const S=({checked:l=!1,onChange:s,required:g,privacyPolicyPath:a="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:n}=H("crud"),[x,d]=m(!1),[y,h]=m(!1),p=e=>{s&&s({target:{checked:e}})},C=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!l))},f=(e,b)=>{e.preventDefault(),b==="privacy"?d(!0):h(!0)},v=n("gdprConsent.consent",{defaultValue:"I agree to the"}),r=n("gdprConsent.privacyPolicy",{defaultValue:"privacy policy"}),i=n("gdprConsent.terms",{defaultValue:"terms of use"}),k=n("gdprConsent.and",{defaultValue:"and consent to the processing of my personal data."});return o(w,{children:[o(D,{direction:"row",align:"center",gap:"tight",children:[t(T,{checked:l,onCheckedChange:p}),t(O,{required:g,plain:!0,onClick:C,style:{cursor:"pointer"},children:o(j,{level:"body",style:{fontSize:"var(--font-size-input)"},children:[v," ",t("a",{href:a,onClick:e=>f(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:r})," / ",t("a",{href:c,onClick:e=>f(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," ",k]})})]}),t(u,{open:x,onOpenChange:d,side:"bottom",title:r,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:a,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:r})}),t(u,{open:y,onOpenChange:h,side:"bottom",title:i,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:i})})]})};var z=S;export{z as default};
1
+ import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as f}from"react";import{Checkbox as D,Label as H,Sheet as m,Stack as P,Text as S}from"@donotdev/components";import{useTranslation as V}from"@donotdev/core";const j=({checked:a=!1,onChange:l,required:u,privacyPolicyPath:s="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:r}=V("crud"),[y,d]=f(!1),[x,h]=f(!1),p=e=>{l&&l({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!a))},g=(e,b)=>{e.preventDefault(),b==="privacy"?d(!0):h(!0)},C=r("gdprConsent.consent",{defaultValue:"I agree to the"}),n=r("gdprConsent.privacyPolicy",{defaultValue:"privacy policy"}),i=r("gdprConsent.terms",{defaultValue:"terms of use"}),k=r("gdprConsent.and",{defaultValue:"and consent to the processing of my personal data."});return o(w,{children:[o(P,{direction:"row",align:"center",gap:"tight",children:[t(D,{checked:a,onCheckedChange:p}),t(H,{required:u,plain:!0,onClick:v,style:{cursor:"pointer"},children:o(S,{level:"body",style:{fontSize:"var(--font-size-input)"},children:[C," ",t("a",{href:s,onClick:e=>g(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:n})," / ",t("a",{href:c,onClick:e=>g(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," ",k]})})]}),t(m,{open:y,onOpenChange:d,side:"bottom",title:n,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:s,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:n})}),t(m,{open:x,onOpenChange:h,side:"bottom",title:i,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:i})})]})};var z=j;export{z as default};
@@ -1 +1 @@
1
- import{jsx as n,jsxs as c}from"react/jsx-runtime";import{Label as h,Input as g,Stack as u}from"@donotdev/components";const y=({label:f,value:e={lat:0,lng:0},onChange:l,error:a,helperText:r,disabled:d,required:m})=>{const v=i=>{const t=parseFloat(i.target.value)||0;if(t>=-90&&t<=90){const s={...e,lat:t},o={target:{value:JSON.stringify(s)}};l(o)}},p=i=>{const t=parseFloat(i.target.value)||0;if(t>=-180&&t<=180){const s={...e,lng:t},o={target:{value:JSON.stringify(s)}};l(o)}};return c(u,{gap:"tight",children:[n(h,{required:m,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:f}),c(u,{direction:"row",children:[n(g,{label:"Latitude",type:"number",value:e.lat,onChange:v,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":a?"destructive":void 0,className:"dndev-w-full"}),n(g,{label:"Longitude",type:"number",value:e.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":a?"destructive":void 0,className:"dndev-w-full"})]}),r&&n("p",{style:{fontSize:"var(--font-size-xs)",color:a?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]})};var L=y;export{L as default};
1
+ import{jsx as a,jsxs as u}from"react/jsx-runtime";import{Label as b,Input as v,Stack as g}from"@donotdev/components";const h=({label:c,value:t={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:m})=>{const p=n=>{const e=parseFloat(n.target.value)||0;if(e>=-90&&e<=90){const l={...t,lat:e},s={target:{value:JSON.stringify(l)}};i(s)}},f=n=>{const e=parseFloat(n.target.value)||0;if(e>=-180&&e<=180){const l={...t,lng:e},s={target:{value:JSON.stringify(l)}};i(s)}};return u(g,{gap:"tight",children:[a(b,{required:m,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:c}),u(g,{direction:"row",children:[a(v,{label:"Latitude",type:"number",value:t.lat,onChange:p,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),a(v,{label:"Longitude",type:"number",value:t.lng,onChange:f,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&a("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var y=h;export{y as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";const d=({name:e,value:n})=>t("input",{type:"hidden",name:e,value:n});var i=d;export{i as default};
1
+ import{jsx as t}from"react/jsx-runtime";const n=({name:a,value:e})=>t("input",{type:"hidden",name:a,value:e});var d=n;export{d as default};
@@ -1,4 +1,5 @@
1
1
  import type { Picture } from '@donotdev/core';
2
+ import type { ProcessImageOptions } from '../../../utils/imageProcessing';
2
3
  export interface ImageFieldComponentProps {
3
4
  /** Field name (for upload registration) */
4
5
  name?: string;
@@ -24,6 +25,13 @@ export interface ImageFieldComponentProps {
24
25
  required?: boolean;
25
26
  /** Camera capture mode: 'environment' (back), 'user' (front), or undefined (browser decides) */
26
27
  capture?: 'environment' | 'user';
28
+ /**
29
+ * WebP processing applied before upload (sizes, ratio, quality, background).
30
+ * Omit for the defaults: 1920x1440 full + 300x225 thumb, 4:3 center crop,
31
+ * quality 0.85 / 0.65, white background. Entity fields set it through
32
+ * `options.fieldSpecific.image`.
33
+ */
34
+ processing?: Omit<ProcessImageOptions, 'crop'>;
27
35
  }
28
36
  export interface ImageFieldComponentRef {
29
37
  upload: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/ImageFieldComponent.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAY9C,MAAM,WAAW,wBAAwB;IACvC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACnC,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gGAAgG;IAChG,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AA+LD;;GAEG;AACH,QAAA,MAAM,mBAAmB,6HAgQxB,CAAC;AAIF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ImageFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/ImageFieldComponent.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAQ1E,MAAM,WAAW,wBAAwB;IACvC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACnC,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gGAAgG;IAChG,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACjC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AA+LD;;GAEG;AACH,QAAA,MAAM,mBAAmB,6HAiQxB,CAAC;AAIF,eAAe,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as d,Fragment as q}from"react/jsx-runtime";import{DndContext as J,closestCenter as Q,PointerSensor as Z,TouchSensor as ee,useSensor as A,useSensors as re}from"@dnd-kit/core";import{SortableContext as te,useSortable as oe,rectSortingStrategy as ne,arrayMove as ae}from"@dnd-kit/sortable";import{CSS as ie}from"@dnd-kit/utilities";import{Upload as se,X as T,Loader2 as de,GripVertical as le}from"lucide-react";import{forwardRef as ce,useCallback as R,useImperativeHandle as pe,useRef as ue,useState as j}from"react";import{Text as m,Stack as I,Progress as ge,handleImageError as me}from"@donotdev/components";import{useTranslation as he}from"@donotdev/core";import{useFileUpload as fe}from"../../../hooks/useFileUpload";import{processImage as ve}from"../../../utils/imageProcessing";import{uploadImage as ye}from"../../../utils/imageStorage";import{ImageViewerDialog as be}from"../internal/ImageViewerDialog";const we=["image/*"];function xe(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function Ie({file:t,index:h,multiple:f,onImageClick:C,onRemove:v,t:c}){const{attributes:a,listeners:k,setNodeRef:D,transform:p,transition:S,isDragging:y}=oe({id:t.id}),b=t.progress!==null&&t.progress<100,s=f&&!b,i={transform:ie.Transform.toString(p),transition:S,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:s?"grab":"pointer",userSelect:"none",touchAction:s?"none":"auto"};return r("div",{ref:D,style:i,...a,...s?k:{},onClick:()=>{y||C(h)},children:b?d(I,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(de,{style:{animation:"spin 1s linear infinite"}}),r(ge,{value:t.progress||0,style:{width:"80%"}})]}):t.error?d(I,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(T,{style:{color:"var(--destructive)"}}),r(m,{variant:"destructive",level:"small",children:t.error})]}):d(q,{children:[f&&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(le,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:c("image.alt.upload",{index:h+1}),draggable:!1,onError:me,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:l=>{l.stopPropagation(),v(t.id)},onPointerDown:l=>l.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(T,{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:c("image.upload.pending",{defaultValue:"Pending"})})})]})})}const z=ce(({name:t="image",label:h,value:f,onChange:C,error:v,helperText:c,multiple:a=!1,maxFiles:k=10,maxSize:D=10*1024*1024,storagePath:p,required:S,capture:y},b)=>{const{t:s}=he("crud"),i=ue(null),[E,l]=j(!1),[_,V]=j(0),L=re(A(Z,{activationConstraint:{distance:8}}),A(ee,{activationConstraint:{delay:200,tolerance:5}})),M=R(async(e,o)=>{const{fullBlob:u,thumbBlob:w}=await ve(e);return ye(u,w,e.name,{storagePath:p,onProgress:x=>o(x.progress)})},[p]),{files:n,addFiles:F,removeFile:P,reorderFiles:U}=fe({name:t,value:f,onChange:C,multiple:a,maxFiles:k,maxSize:D,accept:we,storagePath:p,uploadFn:M}),N=e=>{const o=Array.from(e.target.files||[]);o.length>0&&F(o),i.current&&(i.current.value="")},O=R(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&F(Array.from(e.dataTransfer.files))},[F]),B=R(e=>{const{active:o,over:u}=e;if(u&&o.id!==u.id){const w=n.findIndex(g=>g.id===o.id),x=n.findIndex(g=>g.id===u.id);if(w!==-1&&x!==-1){const g=ae(n.map($=>$.id),w,x);U(g)}}},[n,U]),G=e=>{V(e),l(!0)},H=(e,o)=>{},K=e=>{const o=n[e];o&&P(o.id)},W=e=>{V(e)},X=a||n.length===0;pe(b,()=>({upload:async()=>{},focus:()=>i.current?.focus()}),[]);const Y=n.map(xe);return d(I,{gap:"tight",children:[d(m,{level:"body",textAlign:"start",children:[h,S&&"*"]}),X&&d("div",{role:"button",tabIndex:0,onClick:()=>i.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&i.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:O,style:{border:`var(--border-width) dashed ${v?"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:a,style:{display:"none"},onChange:N}),d(I,{align:"center",children:[r(se,{style:{color:"var(--muted-foreground)"}}),r(m,{variant:"muted",level:"small",children:a?s("image.upload.dropzoneMultiple",{defaultValue:"Drop images here or click to upload"}):s("image.upload.dropzoneSingle",{defaultValue:"Drop image here or click to upload"})})]})]}),n.length>0&&r(J,{sensors:L,collisionDetection:Q,onDragEnd:B,children:r(te,{items:n.map(e=>e.id),strategy:ne,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:n.map((e,o)=>r(Ie,{file:e,index:o,multiple:a,onImageClick:G,onRemove:P,t:s},e.id))})})}),c&&r(m,{variant:v?"destructive":"muted",level:"small",children:c}),r(be,{images:Y,selectedIndex:_,open:E,onClose:()=>l(!1),onUpdate:H,onDelete:K,onNavigate:W,multiple:a})]})});z.displayName="ImageFieldComponent";var je=z;export{je as default};
1
+ "use client";import{jsx as r,jsxs as s,Fragment as Z}from"react/jsx-runtime";import{DndContext as _,closestCenter as Y,PointerSensor as ee,TouchSensor as re,useSensor as A,useSensors as ae}from"@dnd-kit/core";import{SortableContext as oe,useSortable as te,rectSortingStrategy as ie,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 ue,useCallback as R,useImperativeHandle as pe,useRef as ge,useState as j}from"react";import{Text as h,Stack as C,Progress as me,handleImageError as he}from"@donotdev/components";import{useTranslation as fe}from"@donotdev/core";import{useFileUpload as ve}from"../../../hooks/useFileUpload";import{processImage as be}from"../../../utils/imageProcessing";import{uploadImage as ye}from"../../../utils/imageStorage";import{ImageViewerDialog as xe}from"../internal/ImageViewerDialog";const we=["image/*"];function Ce(a){return{id:a.id,file:a.file,previewURL:a.previewURL,hash:"",rotation:0,uploadProgress:a.progress,uploaded:a.uploaded,error:a.error}}function Se({file:a,index:f,multiple:v,onImageClick:S,onRemove:b,t:l}){const{attributes:n,listeners:k,setNodeRef:D,transform:d,transition:I,isDragging:y}=te({id:a.id}),c=a.progress!==null&&a.progress<100,u=v&&!c,p={transform:se.Transform.toString(d),transition:I,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:u?"grab":"pointer",userSelect:"none",touchAction:u?"none":"auto"};return r("div",{ref:D,style:p,...n,...u?k:{},onClick:()=>{y||S(f)},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:a.progress||0,style:{width:"80%"}})]}):a.error?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(U,{style:{color:"var(--destructive)"}}),r(h,{variant:"destructive",level:"small",children:a.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:a.previewURL,alt:l("image.alt.upload",{index:f+1}),draggable:!1,onError:he,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:t=>{t.stopPropagation(),b(a.id)},onPointerDown:t=>t.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}})}),!a.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(h,{variant:"muted",level:"small",style:{color:"white"},children:l("image.upload.pending",{defaultValue:"Pending"})})})]})})}const V=ue(({name:a="image",label:f,value:v,onChange:S,error:b,helperText:l,multiple:n=!1,maxFiles:k=10,maxSize:D=10*1024*1024,storagePath:d,required:I,capture:y,processing:c},u)=>{const{t:p}=fe("crud"),t=ge(null),[L,F]=j(!1),[N,E]=j(0),B=ae(A(ee,{activationConstraint:{distance:8}}),A(re,{activationConstraint:{delay:200,tolerance:5}})),M=R(async(e,o)=>{const{fullBlob:g,thumbBlob:x}=await be(e,c);return ye(g,x,e.name,{storagePath:d,onProgress:w=>o(w.progress)})},[d,c]),{files:i,addFiles:P,removeFile:T,reorderFiles:z}=ve({name:a,value:v,onChange:S,multiple:n,maxFiles:k,maxSize:D,accept:we,storagePath:d,uploadFn:M}),q=e=>{const o=Array.from(e.target.files||[]);o.length>0&&P(o),t.current&&(t.current.value="")},G=R(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&P(Array.from(e.dataTransfer.files))},[P]),H=R(e=>{const{active:o,over:g}=e;if(g&&o.id!==g.id){const x=i.findIndex(m=>m.id===o.id),w=i.findIndex(m=>m.id===g.id);if(x!==-1&&w!==-1){const m=ne(i.map(Q=>Q.id),x,w);z(m)}}},[i,z]),K=e=>{E(e),F(!0)},O=(e,o)=>{},W=e=>{const o=i[e];o&&T(o.id)},X=e=>{E(e)},$=n||i.length===0;pe(u,()=>({upload:async()=>{},focus:()=>t.current?.focus()}),[]);const J=i.map(Ce);return s(C,{gap:"tight",children:[s(h,{level:"body",textAlign:"start",children:[f,I&&"*"]}),$&&s("div",{role:"button",tabIndex:0,onClick:()=>t.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&t.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:G,style:{border:`var(--border-width) dashed ${b?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:t,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(h,{variant:"muted",level:"small",children:n?p("image.upload.dropzoneMultiple",{defaultValue:"Drop images here or click to upload"}):p("image.upload.dropzoneSingle",{defaultValue:"Drop image here or click to upload"})})]})]}),i.length>0&&r(_,{sensors:B,collisionDetection:Y,onDragEnd:H,children:r(oe,{items:i.map(e=>e.id),strategy:ie,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:i.map((e,o)=>r(Se,{file:e,index:o,multiple:n,onImageClick:K,onRemove:T,t:p},e.id))})})}),l&&r(h,{variant:b?"destructive":"muted",level:"small",children:l}),r(xe,{images:J,selectedIndex:N,open:L,onClose:()=>F(!1),onUpdate:O,onDelete:W,onNavigate:X,multiple:n})]})});V.displayName="ImageFieldComponent";var ke=V;export{ke as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Input as u,Stack as p}from"@donotdev/components";import{useTranslation as m}from"@donotdev/core";const f=({label:s,value:d={},onChange:a,error:t,helperText:r,required:i})=>{const{t:l}=m("crud");return n(p,{gap:"tight",children:[n("div",{className:"dndev-surface","data-variant":t?"destructive":"default",style:{border:"1px solid",borderColor:t?"var(--destructive)":"var(--input)",borderRadius:"var(--radius-lg)",padding:"var(--gap-md)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",marginBottom:"var(--gap-md)"},children:"Map component placeholder"}),e(u,{label:s,type:"text",required:i,className:"dndev-w-full",placeholder:l("form.enterLocationData","Enter location data (JSON)"),value:JSON.stringify(d),onChange:c=>{try{const o=JSON.parse(c.target.value),v={target:{value:JSON.stringify(o)}};a(v)}catch{a({target:{value:"{}"}})}}})]}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:t?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]})};var x=f;export{x as default};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Input as v,Stack as p}from"@donotdev/components";import{useTranslation as g}from"@donotdev/core";const m=({label:n,value:d={},onChange:a,error:r,helperText:t,required:s})=>{const{t:l}=g("crud");return o(p,{gap:"tight",children:[o("div",{className:"dndev-surface","data-variant":r?"destructive":"default",style:{border:"1px solid",borderColor:r?"var(--destructive)":"var(--input)",borderRadius:"var(--radius-lg)",padding:"var(--gap-md)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",marginBottom:"var(--gap-md)"},children:"Map component placeholder"}),e(v,{label:n,type:"text",required:s,className:"dndev-w-full",placeholder:l("form.enterLocationData","Enter location data (JSON)"),value:JSON.stringify(d),onChange:i=>{try{const u=JSON.parse(i.target.value),c={target:{value:JSON.stringify(u)}};a(c)}catch{a({target:{value:"{}"}})}}})]}),t&&e("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:t})]})};var f=m;export{f as default};
@@ -1 +1 @@
1
- import{jsx as o,jsxs as s,Fragment as V}from"react/jsx-runtime";import{useMemo as _,useId as j}from"react";import{Combobox as M,Tag as h,Stack as p}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";const d=4,f=3,B=({label:S,value:t=[],options:i,error:b,helperText:a,onChange:u,onBlur:v,required:y,className:x})=>{const{t:m}=N("crud"),g=j(),I=_(()=>i.map(e=>({value:String(e.value),label:e.label})),[i]),O=e=>{const n=Array.isArray(e)?e:[e],r={target:{value:JSON.stringify(n)}};u(r)},z=e=>{e||v?.()},C=e=>{const n=t.filter(c=>c!==e),r={target:{value:JSON.stringify(n)}};u(r)},l=!!b,E=`${g}-error`,A=`${g}-helper`,L=t.length>0?s(V,{children:[t.slice(0,t.length>d?f:d).map((e,n)=>{const r=i.find(c=>String(c.value)===e)?.label||e;return o(h,{size:"sm",onRemove:()=>C(e),children:r},n)}),t.length>d&&s(h,{size:"sm",variant:"outline",disabled:!0,children:["+",t.length-f," more"]})]}):void 0;return s(p,{gap:"tight",className:x,children:[o(M,{label:S,value:t,onValueChange:O,onOpenChange:z,placeholder:m("actions.selectOptions","Select options..."),emptyMessage:m("messages.noResults","No results found"),options:I,multiple:!0,required:y,variant:l?"destructive":void 0,chips:L}),l&&s(p,{id:E,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),a]}),a&&!l&&o("p",{id:A,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})};var k=B;export{k as default};
1
+ import{jsx as o,jsxs as t,Fragment as q}from"react/jsx-runtime";import{useMemo as J,useId as M}from"react";import{Combobox as R,Tag as p,Stack as h}from"@donotdev/components";import{useTranslation as k}from"@donotdev/core";const d=4,v=3,B=({label:f,value:r=[],options:l,error:b,helperText:n,onChange:u,onBlur:S,required:x,className:y})=>{const{t:g}=k("crud"),m=M(),z=J(()=>l.map(e=>({value:String(e.value),label:e.label})),[l]),N=e=>{const s=Array.isArray(e)?e:[e],a={target:{value:JSON.stringify(s)}};u(a)},C=e=>{e||S?.()},O=e=>{const s=r.filter(c=>c!==e),a={target:{value:JSON.stringify(s)}};u(a)},i=!!b,A=`${m}-error`,T=`${m}-helper`,j=r.length>0?t(q,{children:[r.slice(0,r.length>d?v:d).map((e,s)=>{const a=l.find(c=>String(c.value)===e)?.label||e;return o(p,{size:"sm",onRemove:()=>O(e),children:a},s)}),r.length>d&&t(p,{size:"sm",variant:"outline",disabled:!0,children:["+",r.length-v," more"]})]}):void 0;return t(h,{gap:"tight",className:y,children:[o(R,{label:f,value:r,onValueChange:N,onOpenChange:C,placeholder:g("actions.selectOptions","Select options..."),emptyMessage:g("messages.noResults","No results found"),options:z,multiple:!0,required:x,variant:i?"destructive":void 0,chips:j}),i&&t(h,{id:A,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),n]}),n&&!i&&o("p",{id:T,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var I=B;export{I as default};