@donotdev/crud 0.0.20 → 0.0.22

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 (237) hide show
  1. package/dist/CrudService.d.ts.map +1 -1
  2. package/dist/CrudService.js +2 -2
  3. package/dist/CrudStore.d.ts.map +1 -1
  4. package/dist/CrudStore.js +1 -1
  5. package/dist/FieldRegistry.d.ts +1 -1
  6. package/dist/FieldRegistry.d.ts.map +1 -1
  7. package/dist/FieldRegistry.js +1 -1
  8. package/dist/adapters/FunctionsAdapter.d.ts +15 -0
  9. package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
  10. package/dist/adapters/FunctionsAdapter.js +1 -1
  11. package/dist/components/CrudButton.js +1 -1
  12. package/dist/components/CrudCard.js +1 -1
  13. package/dist/components/DateFilter.d.ts.map +1 -1
  14. package/dist/components/DateFilter.js +1 -1
  15. package/dist/components/DisplayFieldRenderer.d.ts.map +1 -1
  16. package/dist/components/DisplayFieldRenderer.js +1 -1
  17. package/dist/components/DisplayThumbnail.js +1 -1
  18. package/dist/components/EntityFilters.d.ts +4 -1
  19. package/dist/components/EntityFilters.d.ts.map +1 -1
  20. package/dist/components/EntityFilters.js +1 -1
  21. package/dist/components/FormFieldRenderer.d.ts.map +1 -1
  22. package/dist/components/FormFieldRenderer.js +1 -1
  23. package/dist/components/FormLayout.js +1 -1
  24. package/dist/components/controlled/complex/ControlledAddressField.d.ts.map +1 -1
  25. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  26. package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
  27. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  28. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts.map +1 -1
  29. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
  30. package/dist/components/controlled/complex/ControlledGeoPointField.d.ts.map +1 -1
  31. package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
  32. package/dist/components/controlled/complex/ControlledMapField.d.ts.map +1 -1
  33. package/dist/components/controlled/complex/ControlledMapField.js +1 -1
  34. package/dist/components/controlled/complex/ControlledMultiInputField.d.ts.map +1 -1
  35. package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
  36. package/dist/components/controlled/complex/ControlledRichTextField.d.ts.map +1 -1
  37. package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
  38. package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
  39. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  40. package/dist/components/controlled/complex/index.js +1 -1
  41. package/dist/components/controlled/file/ControlledDocumentField.d.ts.map +1 -1
  42. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  43. package/dist/components/controlled/file/ControlledFileField.d.ts.map +1 -1
  44. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  45. package/dist/components/controlled/file/ControlledImageField.d.ts.map +1 -1
  46. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  47. package/dist/components/controlled/file/ControlledMultiDocumentField.d.ts.map +1 -1
  48. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  49. package/dist/components/controlled/file/ControlledMultiFileField.d.ts.map +1 -1
  50. package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
  51. package/dist/components/controlled/file/ControlledMultiImageField.d.ts.map +1 -1
  52. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  53. package/dist/components/controlled/file/index.js +1 -1
  54. package/dist/components/controlled/index.js +1 -1
  55. package/dist/components/controlled/input/ControlledCheckboxField.d.ts.map +1 -1
  56. package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
  57. package/dist/components/controlled/input/ControlledCurrencyField.d.ts.map +1 -1
  58. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  59. package/dist/components/controlled/input/ControlledDurationField.d.ts.map +1 -1
  60. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  61. package/dist/components/controlled/input/ControlledGdprConsentField.d.ts.map +1 -1
  62. package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
  63. package/dist/components/controlled/input/ControlledNumberField.d.ts.map +1 -1
  64. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  65. package/dist/components/controlled/input/ControlledPasswordField.d.ts.map +1 -1
  66. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  67. package/dist/components/controlled/input/ControlledPhoneField.d.ts.map +1 -1
  68. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  69. package/dist/components/controlled/input/ControlledPriceField.d.ts.map +1 -1
  70. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  71. package/dist/components/controlled/input/ControlledRangeField.d.ts.map +1 -1
  72. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  73. package/dist/components/controlled/input/ControlledRatingField.d.ts.map +1 -1
  74. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  75. package/dist/components/controlled/input/ControlledSwitchField.d.ts.map +1 -1
  76. package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
  77. package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
  78. package/dist/components/controlled/input/ControlledTextField.js +1 -1
  79. package/dist/components/controlled/input/ControlledTextareaField.d.ts.map +1 -1
  80. package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
  81. package/dist/components/controlled/input/index.js +1 -1
  82. package/dist/components/controlled/select/ControlledComboboxField.d.ts.map +1 -1
  83. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  84. package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
  85. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  86. package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
  87. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  88. package/dist/components/controlled/select/ControlledRadioField.d.ts.map +1 -1
  89. package/dist/components/controlled/select/ControlledRadioField.js +1 -1
  90. package/dist/components/controlled/select/ControlledReferenceField.d.ts.map +1 -1
  91. package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
  92. package/dist/components/controlled/select/ControlledYearField.d.ts.map +1 -1
  93. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  94. package/dist/components/controlled/select/index.js +1 -1
  95. package/dist/components/controlled/types.d.ts.map +1 -1
  96. package/dist/components/controlled/types.js +1 -1
  97. package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
  98. package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
  99. package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
  100. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  101. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  102. package/dist/components/fields/display/DropdownDisplay.js +1 -1
  103. package/dist/components/fields/display/FileFieldDisplay.js +1 -1
  104. package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
  105. package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
  106. package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
  107. package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
  108. package/dist/components/fields/display/MapFieldDisplay.js +1 -1
  109. package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
  110. package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
  111. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  112. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  113. package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
  114. package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
  115. package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
  116. package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
  117. package/dist/components/fields/display/RichTextDisplay.js +2 -2
  118. package/dist/components/fields/display/TextAreaDisplay.js +1 -1
  119. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  120. package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
  121. package/dist/components/fields/display/index.js +1 -1
  122. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  123. package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
  124. package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
  125. package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
  126. package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
  127. package/dist/components/form/fields/ComboboxComponent.js +1 -1
  128. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  129. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  130. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  131. package/dist/components/form/fields/DropdownComponent.js +1 -1
  132. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  133. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  134. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  135. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  136. package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
  137. package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
  138. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  139. package/dist/components/form/fields/MapFieldComponent.js +1 -1
  140. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  141. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  142. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  143. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  144. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  145. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  146. package/dist/components/form/fields/RadioFieldComponent.js +1 -1
  147. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  148. package/dist/components/form/fields/RatingFieldComponent.js +1 -1
  149. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  150. package/dist/components/form/fields/RichTextComponent.d.ts +1 -1
  151. package/dist/components/form/fields/RichTextComponent.d.ts.map +1 -1
  152. package/dist/components/form/fields/RichTextComponent.js +1 -1
  153. package/dist/components/form/fields/SwitchFieldComponent.d.ts.map +1 -1
  154. package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
  155. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  156. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  157. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  158. package/dist/components/form/fields/index.js +1 -1
  159. package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
  160. package/dist/components/form/internal/ImageViewerDialog.js +1 -1
  161. package/dist/components/index.js +1 -1
  162. package/dist/contexts/UploadContext.d.ts.map +1 -1
  163. package/dist/contexts/UploadContext.js +1 -1
  164. package/dist/contexts/index.js +1 -1
  165. package/dist/fieldTypeRegistry.d.ts +1 -1
  166. package/dist/fieldTypeRegistry.d.ts.map +1 -1
  167. package/dist/fieldTypeRegistry.js +1 -1
  168. package/dist/forms/hooks/index.js +1 -1
  169. package/dist/forms/hooks/useController.d.ts.map +1 -1
  170. package/dist/forms/hooks/useController.js +1 -1
  171. package/dist/forms/hooks/useEntityField.d.ts.map +1 -1
  172. package/dist/forms/hooks/useEntityField.js +1 -1
  173. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  174. package/dist/forms/hooks/useEntityForm.js +1 -1
  175. package/dist/forms/index.js +1 -1
  176. package/dist/forms/types.d.ts +2 -2
  177. package/dist/forms/types.d.ts.map +1 -1
  178. package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
  179. package/dist/forms/utils/buildInitialValues.js +1 -1
  180. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  181. package/dist/forms/utils/index.js +1 -1
  182. package/dist/forms/utils/isFieldEditable.js +1 -1
  183. package/dist/forms/utils/translateFieldLabel.js +1 -1
  184. package/dist/forms/utils/validateEntity.js +1 -1
  185. package/dist/hooks/index.js +1 -1
  186. package/dist/hooks/useCrudFilters.d.ts.map +1 -1
  187. package/dist/hooks/useCrudFilters.js +1 -1
  188. package/dist/hooks/useEntityFavorites.js +1 -1
  189. package/dist/hooks/useFieldConditions.d.ts +1 -1
  190. package/dist/hooks/useFieldConditions.d.ts.map +1 -1
  191. package/dist/hooks/useFieldConditions.js +1 -1
  192. package/dist/hooks/useFileUpload.js +1 -1
  193. package/dist/hooks/useReferenceResolver.js +1 -1
  194. package/dist/hooks/useRelatedItems.js +1 -1
  195. package/dist/hooks/useUnsavedChangesWarning.d.ts +0 -1
  196. package/dist/hooks/useUnsavedChangesWarning.d.ts.map +1 -1
  197. package/dist/hooks/useUnsavedChangesWarning.js +1 -1
  198. package/dist/index.js +1 -1
  199. package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
  200. package/dist/registerBuiltinFieldTypes.js +1 -1
  201. package/dist/stores/FormStore.js +1 -1
  202. package/dist/stores/UploadStore.js +1 -1
  203. package/dist/stores/index.js +1 -1
  204. package/dist/tsconfig.tsbuildinfo +1 -1
  205. package/dist/types.js +1 -1
  206. package/dist/useBaseCrudList.d.ts +9 -2
  207. package/dist/useBaseCrudList.d.ts.map +1 -1
  208. package/dist/useBaseCrudList.js +1 -1
  209. package/dist/useCrud.d.ts.map +1 -1
  210. package/dist/useCrud.js +1 -1
  211. package/dist/useCrudCardList.d.ts.map +1 -1
  212. package/dist/useCrudCardList.js +1 -1
  213. package/dist/useCrudList.d.ts +9 -2
  214. package/dist/useCrudList.d.ts.map +1 -1
  215. package/dist/useCrudList.js +1 -1
  216. package/dist/utils/clientListProcessing.d.ts.map +1 -1
  217. package/dist/utils/clientListProcessing.js +1 -1
  218. package/dist/utils/collections.js +1 -1
  219. package/dist/utils/fileStorage.d.ts.map +1 -1
  220. package/dist/utils/fileStorage.js +1 -1
  221. package/dist/utils/imageProcessing.js +1 -1
  222. package/dist/utils/imageStorage.d.ts.map +1 -1
  223. package/dist/utils/imageStorage.js +1 -1
  224. package/dist/utils/imageUtils.js +1 -1
  225. package/dist/utils/matchesFilter.js +1 -1
  226. package/dist/utils/mergeWithOptimistic.d.ts +0 -8
  227. package/dist/utils/mergeWithOptimistic.d.ts.map +1 -1
  228. package/dist/utils/mergeWithOptimistic.js +1 -1
  229. package/dist/utils/sanitizeHtml.js +1 -1
  230. package/dist/utils/scopeUtils.js +1 -1
  231. package/dist/utils/uploadValidation.js +1 -1
  232. package/dist/workflows/WorkflowPersistence.js +1 -1
  233. package/dist/workflows/defineWorkflow.d.ts.map +1 -1
  234. package/dist/workflows/index.js +1 -1
  235. package/dist/workflows/useEntityWorkflow.d.ts.map +1 -1
  236. package/dist/workflows/useEntityWorkflow.js +1 -1
  237. package/package.json +5 -5
@@ -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 t}from"react/jsx-runtime";import{Text as i}from"@donotdev/components";const o=({config:l,value:e,t:r,className:n})=>{if(!e)return t(i,{as:"span",variant:"muted",className:n,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 t("a",{...s,className:n||"",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 i}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:"-"}):i(l,{as:"div",level:"small",className:`font-mono ${s||""}`,children:[a.lat?.toFixed(6),", ",a.lng?.toFixed(6)]});var t=e;export{e as MapFieldDisplay,t 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 o}from"@donotdev/components";const s=({config:a,value:n,t:f,className:r,loading:i=!1})=>i?e(o,{className:r}):n==null?e(t,{as:"span",variant:"muted",className:r,children:"-"}):e(t,{as:"span",className:`font-mono ${r||""}`,children:n.toLocaleString()});var p=s;export{s as NumberFieldDisplay,p as default};
1
+ import{jsx as s}from"react/jsx-runtime";import{Text as e,Spinner as r}from"@donotdev/components";const n=({config:i,value:l,t:m,className:a,loading:o=!1})=>o?s(r,{className:a}):l==null?s(e,{as:"span",variant:"muted",className:a,children:"-"}):s(e,{as:"span",className:`font-mono ${a||""}`,children:l.toLocaleString()});var t=n;export{n as NumberFieldDisplay,t 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 t}from"react/jsx-runtime";import{Eye as c,EyeOff as n}from"lucide-react";import{useState as u}from"react";import{Skeleton as m,Button as y,CopyToClipboard as f,Stack as i}from"@donotdev/components";const l=({config:g,value:e,t:r,className:s,loading:d=!1})=>{const[a,p]=u(!1);return d?o(m,{className:s}):e?t(i,{direction:"row",align:"center",className:s,children:[o("span",{style:{fontFamily:"monospace"},children:a?e:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),t(i,{direction:"row",align:"center",gap:"tight",children:[o(y,{type:"button",onClick:()=>p(!a),"aria-label":a?"Hide password":"Show password",children:a?o(n,{}):o(c,{})}),o(f,{text:e,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("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 s}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:e})=>{if(!a)return s(l,{as:"span",variant:"muted",className:e,children:"-"});const t=a.displayName||a.name||a.id||a;return s(i,{variant:n.OUTLINE,className:e,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 s}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const r=({config:i,value:a,t:m,className:e})=>a?s(l,{as:"div",level:"small",className:`whitespace-pre-wrap ${e||""}`,children:a}):s(l,{as:"span",variant:"muted",className:e,children:"-"});var t=r;export{r as TextAreaDisplay,t as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Mail as V,Calendar as k,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 n}from"@donotdev/components";import{getWeekFromISOString as I}from"@donotdev/core";const B=({config:a,value:r,t:o,className:c,loading:C=!1,showCopy:m=!1,asBadge:b=!1,truncate:s=!1,maxLength:d=50,showLabel:p=!1})=>{const[E,h]=j(!1),M=async()=>{try{await navigator.clipboard.writeText(r),h(!0),setTimeout(()=>h(!1),2e3)}catch{}},y=()=>{switch(a.type){case"email":return e(V,{});case"month":case"week":return e(k,{});case"time":return e(N,{});default:return null}},S=t=>{if(!t)return null;switch(a.type){case"email":return i("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:[y(),t]});case"month":return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long"});case"week":return I(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString();default:return t}},w=t=>!s||t.length<=d?t:`${t.substring(0,d)}...`;if(C)return i(n,{gap:"tight",children:[p&&e(f,{style:{height:"1rem",width:"6rem"}}),e(f,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!r)return i(n,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:a.label||a.name}),e(l,{as:"span",variant:"muted",className:T(c),style:{fontStyle:"italic"},children:o("common.noValue",{defaultValue:"No value"})})]});const D=S(r),g=w(String(D));return b?i(n,{direction:"row",align:"center",gap:"tight",children:[y(),e(A,{variant:F.SECONDARY,className:c,children:g}),m&&e(x,{text:r,tooltipText:o("copyToClipboard")||"Copy to clipboard",copiedTooltipText:o("copied")||"Copied!",ariaLabel:o("copyToClipboard")||"Copy to clipboard"})]}):i(n,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:a.label||a.name}),i(n,{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:g})}),m&&e(x,{text:r,tooltipText:o("copyToClipboard")||"Copy to clipboard",copiedTooltipText:o("copied")||"Copied!",ariaLabel:o("copyToClipboard")||"Copy to clipboard"})]})]})};var W=B;export{B as TextFieldDisplay,W as default};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as N,Calendar as L,Clock as k}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 i}from"@donotdev/components";import{getWeekFromISOString as I}from"@donotdev/core";const b=({config:o,value:a,t:r,className:s,loading:C=!1,showCopy:u=!1,asBadge:v=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[V,g]=A(!1),j=async()=>{try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(o.type){case"email":return e(N,{});case"month":case"week":return e(L,{});case"time":return e(k,{});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:m=>m.currentTarget.style.textDecoration="underline",onMouseLeave:m=>m.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long"});case"week":return I(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString();default:return t}},S=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(C)return n(i,{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(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),e(l,{as:"span",variant:"muted",className:f(s),style:{fontStyle:"italic"},children:r("common.noValue",{defaultValue:"No value"})})]});const D=w(a),y=S(String(D));return v?n(i,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),u&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("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:f("dndev-flex-1",c&&"truncate",s),title:c&&a.length>d?a:void 0,children:e(l,{as:"span",children:y})}),u&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]})]})};var M=b;export{b as TextFieldDisplay,M as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";const c=({config:m,value:s,t:d,className:a})=>{if(!s)return t(e,{as:"span",variant:"muted",className:a,children:"-"});try{const r=new Date(s),n=r.toLocaleDateString(),i=r.toLocaleTimeString();return o("div",{className:a,children:[t(e,{as:"span",children:n}),t(e,{as:"span",variant:"muted",level:"small",children:i})]})}catch{return t(e,{as:"span",variant:"muted",className:a,children:"-"})}};var f=c;export{c as TimestampFieldDisplay,f as default};
1
+ import{jsx as a,jsxs as c}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";const n=({config:o,value:t,t:d,className:s})=>{if(!t)return a(e,{as:"span",variant:"muted",className:s,children:"-"});try{const r=new Date(t),i=r.toLocaleDateString(),l=r.toLocaleTimeString();return c("div",{className:s,children:[a(e,{as:"span",children:i}),a(e,{as:"span",variant:"muted",level:"small",children:l})]})}catch{return a(e,{as:"span",variant:"muted",className:s,children:"-"})}};var m=n;export{n as TimestampFieldDisplay,m 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 r,jsxs as p}from"react/jsx-runtime";import{MapPin as D}from"lucide-react";import{useState as S,useEffect as w,useRef as b,useMemo as F}from"react";import{Combobox as L,Stack as M}from"@donotdev/components";import{useTranslation as N,getPlatformEnvVar as W}from"@donotdev/core";const Y=({label:C,value:i,onChange:P,enableGoogleMaps:j=!1,extractDistrictCode:O,error:c,helperText:l,required:x})=>{const{t:n}=N("crud"),[a,u]=S(i?.formatted_address||""),[f,g]=S([]),[I,m]=S(!1),v=b(null),h=b(null),d=b(null),_=W("GOOGLE_MAPS_API_KEY")||"",o=j&&!!_,R=F(()=>f.map(e=>({value:e.place_id,label:e.description,description:e.structured_formatting?.secondary_text,content:p("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[r(D,{style:{width:"var(--size-icon-sm)",height:"var(--size-icon-sm)"}}),p("div",{children:[r("div",{children:e.description}),e.structured_formatting?.secondary_text&&r("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:e.structured_formatting.secondary_text})]})]})})),[f]),V=e=>{h.current&&(m(!0),h.current.getDetails({placeId:e,fields:["formatted_address","geometry","address_components"]},(t,y)=>{if(m(!1),y===window.google?.maps?.places?.PlacesServiceStatus.OK&&t){const s=t.formatted_address||"",k=t.geometry?.location?.lat(),q=t.geometry?.location?.lng(),z={formatted_address:s,latitude:k,longitude:q};if(O&&t.address_components){const A=t.address_components.find(U=>U.types.includes("postal_code"))?.long_name||"",T=A.startsWith("92")?92:parseInt(A.slice(-2),10)||null;z.district_code=T}u(s),P(z)}}))};w(()=>{i?.formatted_address&&u(i.formatted_address)},[i]),w(()=>{if(!o)return;let e=null;const t=()=>{window.google?.maps?.places&&(v.current=new window.google.maps.places.AutocompleteService,h.current=new window.google.maps.places.PlacesService(document.createElement("div")))};return(()=>{if(window.google?.maps?.places){t();return}if(document.querySelector("#google-maps-script")){e=setInterval(()=>{window.google?.maps?.places&&(clearInterval(e),e=null,t())},100);return}const s=document.createElement("script");s.id="google-maps-script",s.src=`https://maps.googleapis.com/maps/api/js?key=${_}&libraries=places`,s.async=!0,s.defer=!0,s.onload=()=>t(),document.head.appendChild(s)})(),()=>{e!==null&&(clearInterval(e),e=null)}},[o,_]),w(()=>{if(!o||!a||!v.current){g([]);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{m(!0),v.current.getPlacePredictions({input:a,types:["geocode","establishment"]},(e,t)=>{m(!1),t===window.google?.maps?.places?.PlacesServiceStatus.OK&&e?g(e):g([])})},300),()=>{d.current&&clearTimeout(d.current)}},[o,a]);const K=e=>{u(e),P({formatted_address:e})},E=e=>{const t=Array.isArray(e)?e[0]||"":e;if(!o){K(t);return}f.some(s=>s.place_id===t)&&V(t)},G=e=>{o&&u(e)};return o?p(M,{gap:"tight",children:[r(L,{label:C,value:a,onValueChange:E,onSearchChange:G,placeholder:n("address.placeholder","Enter address..."),emptyMessage:I?n("messages.loading","Loading..."):n("address.noResults","No addresses found"),options:R,required:x,variant:c?"destructive":void 0,isLoading:I,creatable:!0,createLabel:n("actions.use","Use this address")}),l&&r("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)"},children:l})]}):p(M,{gap:"tight",children:[r(L,{label:C,value:a,onValueChange:E,placeholder:n("address.placeholder","Enter address..."),options:[],required:x,variant:c?"destructive":void 0,creatable:!0,createLabel:n("actions.use","Use this address")}),l&&r("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)"},children:l})]})};var Z=Y;export{Z as default};
1
+ import{jsx as a,jsxs as m}from"react/jsx-runtime";import{MapPin as U}from"lucide-react";import{useState as y,useEffect as w,useRef as S,useMemo as D}from"react";import{Combobox as L,Stack as M}from"@donotdev/components";import{useTranslation as N,getPlatformEnvVar as W}from"@donotdev/core";const Y=({label:b,value:l,onChange:x,enableGoogleMaps:O=!1,extractDistrictCode:T,error:i,helperText:c,required:P})=>{const{t:o}=N("crud"),[n,u]=y(l?.formatted_address||""),[g,f]=y([]),[E,p]=y(!1),v=S(null),h=S(null),d=S(null),_=W("GOOGLE_MAPS_API_KEY")||"",s=O&&!!_,j=D(()=>g.map(e=>({value:e.place_id,label:e.description,description:e.structured_formatting?.secondary_text,content:m("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[a(U,{style:{width:"var(--size-icon-sm)",height:"var(--size-icon-sm)"}}),m("div",{children:[a("div",{children:e.description}),e.structured_formatting?.secondary_text&&a("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:e.structured_formatting.secondary_text})]})]})})),[g]),q=e=>{h.current&&(p(!0),h.current.getDetails({placeId:e,fields:["formatted_address","geometry","address_components"]},(t,r)=>{if(p(!1),r===window.google?.maps?.places?.PlacesServiceStatus.OK&&t){const I=t.formatted_address||"",K=t.geometry?.location?.lat(),V=t.geometry?.location?.lng(),z={formatted_address:I,latitude:K,longitude:V};if(T&&t.address_components){const A=t.address_components.find(R=>R.types.includes("postal_code"))?.long_name||"",k=A.startsWith("92")?92:parseInt(A.slice(-2),10)||null;z.district_code=k}u(I),x(z)}}))};w(()=>{l?.formatted_address&&u(l.formatted_address)},[l]),w(()=>{if(!s)return;let e=null;const t=()=>{window.google?.maps?.places&&(v.current=new window.google.maps.places.AutocompleteService,h.current=new window.google.maps.places.PlacesService(document.createElement("div")))};return(()=>{if(window.google?.maps?.places){t();return}if(document.querySelector("#google-maps-script")){e=setInterval(()=>{window.google?.maps?.places&&(clearInterval(e),e=null,t())},100);return}const r=document.createElement("script");r.id="google-maps-script",r.src=`https://maps.googleapis.com/maps/api/js?key=${_}&libraries=places`,r.async=!0,r.defer=!0,r.onload=()=>t(),document.head.appendChild(r)})(),()=>{e!==null&&(clearInterval(e),e=null)}},[s,_]),w(()=>{if(!s||!n||!v.current){f([]);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{p(!0),v.current.getPlacePredictions({input:n,types:["geocode","establishment"]},(e,t)=>{p(!1),t===window.google?.maps?.places?.PlacesServiceStatus.OK&&e?f(e):f([])})},300),()=>{d.current&&clearTimeout(d.current)}},[s,n]);const G=e=>{u(e),x({formatted_address:e})},C=e=>{const t=Array.isArray(e)?e[0]||"":e;if(!s){G(t);return}g.some(r=>r.place_id===t)&&q(t)};return s?m(M,{gap:"tight",children:[a(L,{label:b,value:n,onValueChange:C,onSearchChange:e=>{s&&u(e)},placeholder:o("address.placeholder","Enter address..."),emptyMessage:E?o("messages.loading","Loading..."):o("address.noResults","No addresses found"),options:j,required:P,variant:i?"destructive":void 0,isLoading:E,creatable:!0,createLabel:o("actions.use","Use this address")}),c&&a("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)"},children:c})]}):m(M,{gap:"tight",children:[a(L,{label:b,value:n,onValueChange:C,placeholder:o("address.placeholder","Enter address..."),options:[],required:P,variant:i?"destructive":void 0,creatable:!0,createLabel:o("actions.use","Use this address")}),c&&a("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)"},children:c})]})};var F=Y;export{F 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 m,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,...h})=>{const v=a=>a.split(" ").map(p=>p.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(m,{src:t,alt:r.label||"Avatar",fallback:v(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),...h})})]}),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 t}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:r,t:n,variant:s="default",className:i,...c})=>t(o,{children:[t(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})})]}),r&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:r})]});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 o}from"react/jsx-runtime";import{Button as l}from"@donotdev/components";const n=({label:a,type:t,onClick:r,variant:e,disabled:i=!1})=>o(l,{type:t,onClick:r,variant:e,disabled:i,children:a});var s=n;export{s as default};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as c}from"react/jsx-runtime";import{Checkbox as h,Label as i,Stack as s}from"@donotdev/components";const d=({label:t,checked:n=!1,onChange:e,required:a})=>c(s,{direction:"row",align:"center",gap:"tight",children:[r(h,{checked:n,onCheckedChange:o=>{e&&e({target:{checked:o}})}}),r(i,{required:a,children:t})]});var C=d;export{C as default};
1
+ import{jsx as r,jsxs as h}from"react/jsx-runtime";import{Checkbox as i,Label as n,Stack as s}from"@donotdev/components";const d=({label:a,checked:c=!1,onChange:e,required:o})=>h(s,{direction:"row",align:"center",gap:"tight",children:[r(i,{checked:c,onCheckedChange:t=>{e&&e({target:{checked:t}})}}),r(n,{required:o,children:a})]});var l=d;export{l 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:r,onChange:n,onBlur:m,required:g,placeholder:h,translationNamespace:v="dndev",placeholderKey:f="actions.select",placeholderDefault:b="Select",creatable:x=!1,createLabel:y,emptyMessage:C})=>{const{t:a}=D(v),i=N(),z=L(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),S=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:S,onOpenChange:A,placeholder:h||a(f,b),emptyMessage:C||a("messages.noResults","No results found"),creatable:x,createLabel:y||a("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"}),r]}),r&&!t&&o("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:r})]})};var O=I;export{O as default};
@@ -1 +1 @@
1
- import{jsx as n,jsxs as f}from"react/jsx-runtime";import{useState as N,useEffect as V,useId as j}from"react";import{Input as E,FloatingLabel as I,Stack as z}from"@donotdev/components";const L=({label:m,value:r,onChange:g,currency:a="EUR",locale:y,error:s,helperText:l,required:v=!1,disabled:i=!1,placeholder:h})=>{const c=j(),b=y||(typeof navigator<"u"?navigator.language:"en-US"),d=e=>e==null||isNaN(e)?"":(e/100).toFixed(2),x=e=>{if(!e||e.trim()==="")return null;const t=e.replace(/[^\d.,\-]/g,"").replace(",","."),o=parseFloat(t);return isNaN(o)?null:Math.round(o*100)},[S,u]=N(d(r));V(()=>{u(d(r))},[r]);const C=e=>{const t=e.target.value;u(t);const F={target:{value:x(t)}};g(F)},p=(()=>{try{return new Intl.NumberFormat(b,{style:"currency",currency:a,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||a}catch{return a}})();return f(z,{gap:"tight",children:[n(I,{htmlFor:c,label:m,disabled:i,required:v,children:f("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:p}),n(E,{id:c,type:"text",inputMode:"decimal",value:S,onChange:C,disabled:i,placeholder:h||"0.00","data-variant":s?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${p.length*.6}em + var(--gap-sm))`}})]})}),l&&n("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var k=L;export{k as default};
1
+ import{jsx as t,jsxs as v}from"react/jsx-runtime";import{useState as I,useEffect as S,useId as z}from"react";import{Input as E,FloatingLabel as T,Stack as j}from"@donotdev/components";const C=({label:g,value:n,onChange:m,currency:l="EUR",locale:f,error:o,helperText:s,required:y=!1,disabled:i=!1,placeholder:h})=>{const d=z(),b=f||(typeof navigator<"u"?navigator.language:"en-US"),u=e=>e==null||isNaN(e)?"":(e/100).toFixed(2),x=e=>{if(!e||e.trim()==="")return null;const r=e.replace(/[^\d.,\-]/g,"").replace(",","."),a=parseFloat(r);return isNaN(a)?null:Math.round(a*100)},[F,c]=I(u(n));S(()=>{c(u(n))},[n]);const N=e=>{const r=e.target.value;c(r);const a={target:{value:x(r)}};m(a)},p=(()=>{try{return new Intl.NumberFormat(b,{style:"currency",currency:l,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||l}catch{return l}})();return v(j,{gap:"tight",children:[t(T,{htmlFor:d,label:g,disabled:i,required:y,children:v("div",{style:{position:"relative"},children:[t("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:p}),t(E,{id:d,type:"text",inputMode:"decimal",value:F,onChange:N,disabled:i,placeholder:h||"0.00","data-variant":o?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${p.length*.6}em + var(--gap-sm))`}})]})}),s&&t("p",{style:{fontSize:"var(--font-size-xs)",color:o?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:s})]})};var L=C;export{L as default};
@@ -1 +1 @@
1
- import{jsx as l,jsxs as S}from"react/jsx-runtime";import{Input as d,Stack as p}from"@donotdev/components";const m=({label:r,value:i,onChange:s,error:o,helperText:n,mode:e="date",required:g,...c})=>{const f=t=>{const u=t.target.value?new Date(t.target.value).toISOString():null;s(u)};let a="";if(i){const t=new Date(i);e==="date"?a=t.toISOString().split("T")[0]||"":e==="datetime-local"?a=t.toISOString().slice(0,16)||"":e==="month"?a=t.toISOString().slice(0,7):e==="time"?a=t.toISOString().slice(11,16):e==="week"&&(a=t.toISOString().split("T")[0]||"")}return S(p,{gap:"tight",children:[l(d,{label:r,type:e,value:a,onChange:f,required:g,className:"dndev-w-full",...c}),n&&l("p",{style:{fontSize:"var(--font-size-xs)",color:o?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:n})]})};var O=m;export{O as default};
1
+ import{jsx as l,jsxs as S}from"react/jsx-runtime";import{Input as m,Stack as p}from"@donotdev/components";const v=({label:n,value:a,onChange:i,error:s,helperText:o,mode:e="date",required:g,...u})=>{const c=t=>{const d=t.target.value?new Date(t.target.value).toISOString():null;i(d)};let r="";if(a){const t=new Date(a);e==="date"?r=t.toISOString().split("T")[0]||"":e==="datetime-local"?r=t.toISOString().slice(0,16)||"":e==="month"?r=t.toISOString().slice(0,7):e==="time"?r=t.toISOString().slice(11,16):e==="week"&&(r=t.toISOString().split("T")[0]||"")}return S(p,{gap:"tight",children:[l(m,{label:n,type:e,value:r,onChange:c,required:g,className:"dndev-w-full",...u}),o&&l("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var f=v;export{f as default};
@@ -1 +1 @@
1
- "use client";import{jsx as n,jsxs as l,Fragment as ie}from"react/jsx-runtime";import{Upload as ae,X as se,FileText as P,FileSpreadsheet as le,File as de,Loader2 as ce,Eye as ue}from"lucide-react";import{useCallback as w,useState as E,useRef as F,useEffect as W,useImperativeHandle as pe,forwardRef as me}from"react";import{Button as _,BUTTON_VARIANT as G,Text as g,Stack as x,Progress as fe,Dialog as ge,DialogContent as ve,DialogHeader as he,DialogTitle as ye}from"@donotdev/components";import{handleError as N,useTranslation as we}from"@donotdev/core";import{useUploadContext as xe}from"../../../contexts/UploadContext";import{useUploadStore as V}from"../../../stores/UploadStore";import{uploadFile as Te,deleteFile as be,generateFileId as X,getFileIcon as Pe,formatFileSize as Fe,getDocumentAcceptString as Ne}from"../../../utils/fileStorage";function De({type:f,className:c}){switch(f){case"pdf":return n(P,{className:c,style:{color:"var(--destructive)"}});case"doc":return n(P,{className:c,style:{color:"var(--primary)"}});case"xls":return n(le,{className:c,style:{color:"var(--success)"}});case"ppt":return n(P,{className:c,style:{color:"var(--warning)"}});case"text":case"html":return n(P,{className:c});default:return n(de,{className:c})}}const q=me(({name:f,label:c,value:v,onChange:D,error:k,helperText:M,multiple:p=!1,maxFiles:A=10,maxSize:C=25*1024*1024,storagePath:R="uploads/documents",required:K,enablePreview:L=!0},J)=>{const{t:Q}=we("crud"),s=Q,h=xe(),H=!!h,[a,u]=E([]),[O,I]=E(!1),[S,j]=E(null),y=F(null),U=F(!1),T=F(void 0),Y=Ne(),b=w(e=>{const t=e.filter(r=>r.uploaded&&!r.error).map(r=>r.uploaded);D(p?t:t[0]||null)},[p,D]);W(()=>{if(U.current){U.current=!1;return}if(v){const e=[];(Array.isArray(v)?v:[v]).forEach(r=>{r.url&&e.push({id:X(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),u(e)}else u([])},[v]);const Z=w(async()=>{const e=a.filter(t=>!t.uploaded&&!t.error&&t.uploadProgress===null);if(e.length!==0){u(t=>t.map(r=>e.some(i=>i.id===r.id)?{...r,uploadProgress:0}:r));for(const t of e)try{const r=await Te(t.file,{storagePath:R,onProgress:i=>{u(o=>o.map(d=>d.id===t.id?{...d,uploadProgress:i.progress}:d))}});u(i=>{const o=i.map(d=>d.id===t.id?{...d,uploaded:r,uploadProgress:100,error:null}:d);return queueMicrotask(()=>b(o)),o})}catch{u(i=>i.map(o=>o.id===t.id?{...o,error:"Upload failed",uploadProgress:null}:o))}}},[a,R,b]);T.current=Z,W(()=>{if(!(!h||!f))return V.getState().registerUpload(h,f,async()=>{await T.current?.()}),()=>{V.getState().unregisterUpload(h,f)}},[h,f]),pe(J,()=>({upload:async()=>{await T.current?.()},getDocuments:()=>B.current||[]}),[]);const B=F(a);B.current=a;const $=e=>{const t=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],r="."+e.name.split(".").pop()?.toLowerCase();return t.includes(r)},z=w(e=>{const r=(p?A:1)-a.length;if(r<=0){N(new Error("Maximum documents reached"),{userMessage:s("document.errors.maxFiles",{max:A}),severity:"warning",showNotification:!0});return}const i=e.slice(0,r),o=[],d=(C/(1024*1024)).toFixed(0);for(const m of i){if(!$(m)){N(new Error("Invalid document type"),{userMessage:s("document.errors.invalidType",{fileName:m.name}),severity:"warning",showNotification:!0});continue}if(m.size>C){N(new Error("Document too large"),{userMessage:s("document.errors.exceedsSize",{fileName:m.name,size:d}),severity:"warning",showNotification:!0});continue}o.push({id:X(),file:m,uploadProgress:null,uploaded:null,error:null})}o.length!==0&&(u(m=>p?[...m,...o]:o),H||setTimeout(()=>T.current?.(),0))},[a,p,A,C,s,H]),ee=e=>{const t=Array.from(e.target.files||[]);t.length>0&&z(t),y.current&&(y.current.value="")},re=w(e=>{e.preventDefault(),I(!1);const t=Array.from(e.dataTransfer.files);z(t)},[z]),te=w(async e=>{const t=a.find(r=>r.id===e);if(t)try{t.uploaded&&await be(t.uploaded);const r=a.filter(i=>i.id!==e);U.current=!0,u(r),setTimeout(()=>b(r),0)}catch(r){N(r,{userMessage:s("document.delete.failed"),severity:"error",showNotification:!0})}},[a,b,s]),ne=e=>{e.uploaded?.url&&e.uploaded.mimeType==="application/pdf"&&j(e.uploaded.url)},oe=p||a.length===0;return l(ie,{children:[l(x,{gap:"tight",children:[l(g,{level:"body",align:"start",children:[c,K?"*":""]}),oe&&l("div",{role:"button",tabIndex:0,"aria-label":s("document.upload.ariaLabel"),className:"dndev-surface","data-variant":k?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:O?"var(--primary)":k?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:O?"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(),I(!0)},onDragLeave:()=>I(!1),onDrop:re,onClick:()=>y.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),y.current?.click())},children:[n("input",{ref:y,type:"file",accept:Y,multiple:p,style:{display:"none"},onChange:ee}),l(x,{align:"center",justify:"center",children:[n(ae,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),n(g,{as:"p",variant:"muted",level:"small",align:"center",children:s("document.upload.hint")}),n(g,{as:"p",variant:"muted",level:"caption",align:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),a.length>0&&n(x,{gap:"tight",children:a.map((e,t)=>{const r=Pe(e.uploaded?.mimeType||e.file.type,e.file.name),i=e.uploadProgress!==null&&e.uploadProgress<100,o=e.uploaded?.mimeType==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf");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:[n(De,{type:r,className:"dndev-size-md"}),l(x,{gap:"none",style:{flex:1,minWidth:0},children:[n(g,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),l(g,{level:"caption",variant:"muted",children:[Fe(e.uploaded?.size||e.file.size),e.error&&l("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),i&&n(fe,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),l(x,{direction:"row",gap:"tight",children:[L&&o&&e.uploaded&&n(_,{variant:G.GHOST,onClick:()=>ne(e),"aria-label":s("document.preview.ariaLabel"),children:n(ue,{className:"dndev-size-sm"})}),i?n(ce,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):n(_,{variant:G.GHOST,onClick:()=>te(e.id),"aria-label":s("document.delete.ariaLabel"),children:n(se,{className:"dndev-size-sm"})})]})]},e.id)})}),M&&n(g,{level:"caption",variant:k?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]}),L&&S&&n(ge,{open:!!S,onOpenChange:()=>j(null),children:l(ve,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[n(he,{children:n(ye,{children:s("document.preview.title")})}),n("iframe",{src:S,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});q.displayName="DocumentFieldComponent";var Me=q;export{Me as default};
1
+ "use client";import{jsx as t,jsxs as n,Fragment as le}from"react/jsx-runtime";import{Upload as se,X as oe,FileText as N,FileSpreadsheet as ie,File as ne,Loader2 as de,Eye as ce}from"lucide-react";import{useCallback as y,useState as A,useRef as T,useEffect as j,useImperativeHandle as ue,forwardRef as pe}from"react";import{Button as B,BUTTON_VARIANT as q,Text as g,Stack as w,Progress as me,Dialog as ge,DialogContent as ve,DialogHeader as fe,DialogTitle as he}from"@donotdev/components";import{handleError as P,useTranslation as ye}from"@donotdev/core";import{useUploadContext as we}from"../../../contexts/UploadContext";import{useUploadStore as G}from"../../../stores/UploadStore";import{uploadFile as xe,deleteFile as be,generateFileId as X,getFileIcon as Ne,formatFileSize as Te,getDocumentAcceptString as Pe}from"../../../utils/fileStorage";function De({type:m,className:d}){switch(m){case"pdf":return t(N,{className:d,style:{color:"var(--destructive)"}});case"doc":return t(N,{className:d,style:{color:"var(--primary)"}});case"xls":return t(ie,{className:d,style:{color:"var(--success)"}});case"ppt":return t(N,{className:d,style:{color:"var(--warning)"}});case"text":case"html":return t(N,{className:d});default:return t(ne,{className:d})}}const V=pe(({name:m,label:d,value:v,onChange:I,error:D,helperText:L,multiple:p=!1,maxFiles:k=10,maxSize:C=25*1024*1024,storagePath:M="uploads/documents",required:J,enablePreview:O=!0},K)=>{const{t:Q}=ye("crud"),i=Q,f=we(),R=!!f,[o,c]=A([]),[U,F]=A(!1),[z,H]=A(null),h=T(null),S=T(!1),x=T(void 0),Y=Pe(),b=y(e=>{const r=e.filter(a=>a.uploaded&&!a.error).map(a=>a.uploaded);I(p?r:r[0]||null)},[p,I]);j(()=>{if(S.current){S.current=!1;return}if(v){const e=[];(Array.isArray(v)?v:[v]).forEach(r=>{r.url&&e.push({id:X(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),c(e)}else c([])},[v]);const Z=y(async()=>{const e=o.filter(r=>!r.uploaded&&!r.error&&r.uploadProgress===null);if(e.length!==0){c(r=>r.map(a=>e.some(l=>l.id===a.id)?{...a,uploadProgress:0}:a));for(const r of e)try{const a=await xe(r.file,{storagePath:M,onProgress:l=>{c(u=>u.map(s=>s.id===r.id?{...s,uploadProgress:l.progress}:s))}});c(l=>{const u=l.map(s=>s.id===r.id?{...s,uploaded:a,uploadProgress:100,error:null}:s);return queueMicrotask(()=>b(u)),u})}catch{c(a=>a.map(l=>l.id===r.id?{...l,error:"Upload failed",uploadProgress:null}:l))}}},[o,M,b]);x.current=Z,j(()=>{if(!(!f||!m))return G.getState().registerUpload(f,m,async()=>{await x.current?.()}),()=>{G.getState().unregisterUpload(f,m)}},[f,m]),ue(K,()=>({upload:async()=>{await x.current?.()},getDocuments:()=>W.current||[]}),[]);const W=T(o);W.current=o;const _=e=>{const r=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],a="."+e.name.split(".").pop()?.toLowerCase();return r.includes(a)},E=y(e=>{const r=(p?k:1)-o.length;if(r<=0){P(new Error("Maximum documents reached"),{userMessage:i("document.errors.maxFiles",{max:k}),severity:"warning",showNotification:!0});return}const a=e.slice(0,r),l=[],u=(C/(1024*1024)).toFixed(0);for(const s of a){if(!_(s)){P(new Error("Invalid document type"),{userMessage:i("document.errors.invalidType",{fileName:s.name}),severity:"warning",showNotification:!0});continue}if(s.size>C){P(new Error("Document too large"),{userMessage:i("document.errors.exceedsSize",{fileName:s.name,size:u}),severity:"warning",showNotification:!0});continue}l.push({id:X(),file:s,uploadProgress:null,uploaded:null,error:null})}l.length!==0&&(c(s=>p?[...s,...l]:l),R||setTimeout(()=>x.current?.(),0))},[o,p,k,C,i,R]),$=e=>{const r=Array.from(e.target.files||[]);r.length>0&&E(r),h.current&&(h.current.value="")},ee=y(e=>{e.preventDefault(),F(!1);const r=Array.from(e.dataTransfer.files);E(r)},[E]),re=y(async e=>{const r=o.find(a=>a.id===e);if(r)try{r.uploaded&&await be(r.uploaded);const a=o.filter(l=>l.id!==e);S.current=!0,c(a),setTimeout(()=>b(a),0)}catch(a){P(a,{userMessage:i("document.delete.failed"),severity:"error",showNotification:!0})}},[o,b,i]),ae=e=>{e.uploaded?.url&&e.uploaded.mimeType==="application/pdf"&&H(e.uploaded.url)},te=p||o.length===0;return n(le,{children:[n(w,{gap:"tight",children:[n(g,{level:"body",align:"start",children:[d,J?"*":""]}),te&&n("div",{role:"button",tabIndex:0,"aria-label":i("document.upload.ariaLabel"),className:"dndev-surface","data-variant":D?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:U?"var(--primary)":D?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:U?"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:ee,onClick:()=>h.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),h.current?.click())},children:[t("input",{ref:h,type:"file",accept:Y,multiple:p,style:{display:"none"},onChange:$}),n(w,{align:"center",justify:"center",children:[t(se,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),t(g,{as:"p",variant:"muted",level:"small",align:"center",children:i("document.upload.hint")}),t(g,{as:"p",variant:"muted",level:"caption",align:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&t(w,{gap:"tight",children:o.map((e,r)=>{const a=Ne(e.uploaded?.mimeType||e.file.type,e.file.name),l=e.uploadProgress!==null&&e.uploadProgress<100,u=e.uploaded?.mimeType==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf");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:[t(De,{type:a,className:"dndev-size-md"}),n(w,{gap:"none",style:{flex:1,minWidth:0},children:[t(g,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(g,{level:"caption",variant:"muted",children:[Te(e.uploaded?.size||e.file.size),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),l&&t(me,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),n(w,{direction:"row",gap:"tight",children:[O&&u&&e.uploaded&&t(B,{variant:q.GHOST,onClick:()=>ae(e),"aria-label":i("document.preview.ariaLabel"),children:t(ce,{className:"dndev-size-sm"})}),l?t(de,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):t(B,{variant:q.GHOST,onClick:()=>re(e.id),"aria-label":i("document.delete.ariaLabel"),children:t(oe,{className:"dndev-size-sm"})})]})]},e.id)})}),L&&t(g,{level:"caption",variant:D?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:L})]}),O&&z&&t(ge,{open:!!z,onOpenChange:()=>H(null),children:n(ve,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[t(fe,{children:t(he,{children:i("document.preview.title")})}),t("iframe",{src:z,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});V.displayName="DocumentFieldComponent";var ke=V;export{ke 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 t,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:o,value:r,options:n,error:s,helperText:a,onChange:l,onBlur:i,required:u})=>{const{t:p}=m("crud"),c=r!=null?String(r):"";return g(v,{gap:"tight",children:[t(d,{label:o,value:c,onValueChange:e=>{l&&l({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&&t("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{useState as w,useMemo as C}from"react";import{Clock as S}from"lucide-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 u}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as T,useMemo as k}from"react";import{Label as $,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}`,l=N[e];return!n||!l?o:n(`crud:${l}`,{defaultValue:o})??o}const W=({label:e,value:n,onChange:o,error:l,helperText:d,disabled:m,required:p,readonly:M,min:g=0,max:v=480,step:V=5,t})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,h=f.includes(r),[c,b]=T(!h&&r>0),C=k(()=>f.map(a=>({minutes:a,label:q(a,t)})),[t]),y=t?t("crud:duration.custom",{defaultValue:"Custom"}):"Custom";if(M){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 u(s,{gap:"tight",children:[i($,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),u(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:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})}return u(s,{children:[i($,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),u(s,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[C.map(({minutes:a,label:z})=>u(S,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),o(a)},"aria-pressed":r===a,"aria-label":z,children:[i(x,{size:14,style:{marginRight:"var(--gap-xs)"},"aria-hidden":!0}),z]},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:V,showValue:!0,disabled:m,"aria-label":e})}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:l?"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 t,jsxs as p}from"react/jsx-runtime";import{Upload as Z,X as $,File as ee,Loader2 as re,FileText as z,FileSpreadsheet as se,FileImage as te,FileVideo as oe,FileAudio as ae,FileArchive as ne,FileCode as le}from"lucide-react";import{useCallback as y,useState as B,useRef as b,useEffect as O,useImperativeHandle as ie,forwardRef as de}from"react";import{Button as ue,BUTTON_VARIANT as ce,Text as F,Stack as P,Progress as pe}from"@donotdev/components";import{handleError as C,useTranslation as fe}from"@donotdev/core";import{useUploadContext as ge}from"../../../contexts/UploadContext";import{useUploadStore as H}from"../../../stores/UploadStore";import{uploadFile as me,deleteFile as ve,generateFileId as _,getFileIcon as he,formatFileSize as ye}from"../../../utils/fileStorage";function Fe({type:f,className:l}){switch(f){case"pdf":return t(z,{className:l,style:{color:"var(--destructive)"}});case"doc":return t(z,{className:l,style:{color:"var(--primary)"}});case"xls":return t(se,{className:l,style:{color:"var(--success)"}});case"ppt":return t(z,{className:l,style:{color:"var(--warning)"}});case"image":return t(te,{className:l});case"video":return t(oe,{className:l});case"audio":return t(ae,{className:l});case"archive":return t(ne,{className:l});case"html":case"text":return t(le,{className:l});default:return t(ee,{className:l})}}const V=de(({name:f,label:l,value:g,onChange:T,error:A,helperText:M,accept:q,multiple:d=!1,maxFiles:N=10,maxSize:k=50*1024*1024,storagePath:R="uploads/files",required:D},G)=>{const{t:K}=fe("crud"),i=K,m=ge(),E=!!m,[n,c]=B([]),[j,I]=B(!1),v=b(null),S=b(!1),w=b(void 0),x=y(e=>{const s=e.filter(r=>r.uploaded&&!r.error).map(r=>r.uploaded);T(d?s:s[0]||null)},[d,T]);O(()=>{if(S.current){S.current=!1;return}if(g){const e=[];(Array.isArray(g)?g:[g]).forEach(r=>{r.url&&e.push({id:_(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),c(e)}else c([])},[g]);const W=y(async()=>{const e=n.filter(s=>!s.uploaded&&!s.error&&s.uploadProgress===null);if(e.length!==0){c(s=>s.map(r=>e.some(o=>o.id===r.id)?{...r,uploadProgress:0}:r));for(const s of e)try{const r=await me(s.file,{storagePath:R,onProgress:o=>{c(a=>a.map(u=>u.id===s.id?{...u,uploadProgress:o.progress}:u))}});c(o=>{const a=o.map(u=>u.id===s.id?{...u,uploaded:r,uploadProgress:100,error:null}:u);return queueMicrotask(()=>x(a)),a})}catch{c(o=>o.map(a=>a.id===s.id?{...a,error:"Upload failed",uploadProgress:null}:a))}}},[n,R,x]);w.current=W,O(()=>{if(!(!m||!f))return H.getState().registerUpload(m,f,async e=>{await w.current?.()}),()=>{H.getState().unregisterUpload(m,f)}},[m,f]),ie(G,()=>({upload:async()=>{await w.current?.()},getFiles:()=>L.current||[]}),[]);const L=b(n);L.current=n;const U=y(e=>{const r=(d?N:1)-n.length;if(r<=0){C(new Error("Maximum files reached"),{userMessage:i("file.errors.maxFiles",{max:N}),severity:"warning",showNotification:!0});return}const o=e.slice(0,r),a=[],u=(k/(1024*1024)).toFixed(0);for(const h of o){if(h.size>k){C(new Error("File too large"),{userMessage:i("file.errors.exceedsSize",{fileName:h.name,size:u}),severity:"warning",showNotification:!0});continue}a.push({id:_(),file:h,uploadProgress:null,uploaded:null,error:null})}a.length!==0&&(c(h=>d?[...h,...a]:a),E||setTimeout(()=>w.current?.(),0))},[n,d,N,k,i,E]),X=e=>{const s=Array.from(e.target.files||[]);s.length>0&&U(s),v.current&&(v.current.value="")},J=y(e=>{e.preventDefault(),I(!1);const s=Array.from(e.dataTransfer.files);U(s)},[U]),Q=y(async e=>{const s=n.find(r=>r.id===e);if(s)try{s.uploaded&&await ve(s.uploaded);const r=n.filter(o=>o.id!==e);S.current=!0,c(r),setTimeout(()=>x(r),0)}catch(r){C(r,{userMessage:i("file.delete.failed"),severity:"error",showNotification:!0})}},[n,x,i]),Y=d||n.length===0,we=n.some(e=>!e.uploaded&&!e.error&&e.uploadProgress===null);return p(P,{gap:"tight",children:[p(F,{level:"body",align:"start",children:[l,D?"*":""]}),Y&&p("div",{role:"button",tabIndex:0,"aria-label":i(d?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":A?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:j?"var(--primary)":A?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:j?"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(),I(!0)},onDragLeave:()=>I(!1),onDrop:J,onClick:()=>v.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),v.current?.click())},children:[t("input",{ref:v,type:"file",accept:q,multiple:d,style:{display:"none"},onChange:X}),p(P,{align:"center",justify:"center",children:[t(Z,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),t(F,{as:"p",variant:"muted",level:"small",align:"center",children:i(d?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),n.length>0&&t(P,{gap:"tight",children:n.map((e,s)=>{const r=he(e.uploaded?.mimeType||e.file.type,e.file.name),o=e.uploadProgress!==null&&e.uploadProgress<100,a=e.uploaded&&!e.error;return p("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:[t(Fe,{type:r,className:"dndev-size-md"}),p(P,{gap:"none",style:{flex:1,minWidth:0},children:[t(F,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),p(F,{level:"caption",variant:"muted",children:[ye(e.uploaded?.size||e.file.size),e.error&&p("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),o&&t(pe,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),o?t(re,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):t(ue,{variant:ce.GHOST,onClick:()=>Q(e.id),"aria-label":i("file.delete.ariaLabel"),children:t($,{className:"dndev-size-sm"})})]},e.id)})}),M&&t(F,{level:"caption",variant:A?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]})});V.displayName="FileFieldComponent";var Ue=V;export{Ue as default};
1
+ "use client";import{jsx as l,jsxs as c}from"react/jsx-runtime";import{Upload as Y,X as Z,File as $,Loader2 as ee,FileText as S,FileSpreadsheet as re,FileImage as ae,FileVideo as le,FileAudio as se,FileArchive as te,FileCode as ie}from"lucide-react";import{useCallback as h,useState as E,useRef as w,useEffect as O,useImperativeHandle as oe,forwardRef as ne}from"react";import{Button as de,BUTTON_VARIANT as ue,Text as y,Stack as F,Progress as ce}from"@donotdev/components";import{handleError as D,useTranslation as pe}from"@donotdev/core";import{useUploadContext as me}from"../../../contexts/UploadContext";import{useUploadStore as j}from"../../../stores/UploadStore";import{uploadFile as fe,deleteFile as ge,generateFileId as B,getFileIcon as ve,formatFileSize as he}from"../../../utils/fileStorage";function ye({type:m,className:o}){switch(m){case"pdf":return l(S,{className:o,style:{color:"var(--destructive)"}});case"doc":return l(S,{className:o,style:{color:"var(--primary)"}});case"xls":return l(re,{className:o,style:{color:"var(--success)"}});case"ppt":return l(S,{className:o,style:{color:"var(--warning)"}});case"image":return l(ae,{className:o});case"video":return l(le,{className:o});case"audio":return l(se,{className:o});case"archive":return l(te,{className:o});case"html":case"text":return l(ie,{className:o});default:return l($,{className:o})}}const H=ne(({name:m,label:o,value:f,onChange:A,error:b,helperText:M,accept:q,multiple:n=!1,maxFiles:T=10,maxSize:k=50*1024*1024,storagePath:I="uploads/files",required:G},V)=>{const{t:W}=pe("crud"),d=W,g=me(),L=!!g,[t,u]=E([]),[R,P]=E(!1),v=w(null),z=w(!1),x=w(void 0),N=h(e=>{const r=e.filter(a=>a.uploaded&&!a.error).map(a=>a.uploaded);A(n?r:r[0]||null)},[n,A]);O(()=>{if(z.current){z.current=!1;return}if(f){const e=[];(Array.isArray(f)?f:[f]).forEach(r=>{r.url&&e.push({id:B(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),u(e)}else u([])},[f]);const X=h(async()=>{const e=t.filter(r=>!r.uploaded&&!r.error&&r.uploadProgress===null);if(e.length!==0){u(r=>r.map(a=>e.some(s=>s.id===a.id)?{...a,uploadProgress:0}:a));for(const r of e)try{const a=await fe(r.file,{storagePath:I,onProgress:s=>{u(p=>p.map(i=>i.id===r.id?{...i,uploadProgress:s.progress}:i))}});u(s=>{const p=s.map(i=>i.id===r.id?{...i,uploaded:a,uploadProgress:100,error:null}:i);return queueMicrotask(()=>N(p)),p})}catch{u(a=>a.map(s=>s.id===r.id?{...s,error:"Upload failed",uploadProgress:null}:s))}}},[t,I,N]);x.current=X,O(()=>{if(!(!g||!m))return j.getState().registerUpload(g,m,async e=>{await x.current?.()}),()=>{j.getState().unregisterUpload(g,m)}},[g,m]),oe(V,()=>({upload:async()=>{await x.current?.()},getFiles:()=>U.current||[]}),[]);const U=w(t);U.current=t;const C=h(e=>{const r=(n?T:1)-t.length;if(r<=0){D(new Error("Maximum files reached"),{userMessage:d("file.errors.maxFiles",{max:T}),severity:"warning",showNotification:!0});return}const a=e.slice(0,r),s=[],p=(k/(1024*1024)).toFixed(0);for(const i of a){if(i.size>k){D(new Error("File too large"),{userMessage:d("file.errors.exceedsSize",{fileName:i.name,size:p}),severity:"warning",showNotification:!0});continue}s.push({id:B(),file:i,uploadProgress:null,uploaded:null,error:null})}s.length!==0&&(u(i=>n?[...i,...s]:s),L||setTimeout(()=>x.current?.(),0))},[t,n,T,k,d,L]),_=e=>{const r=Array.from(e.target.files||[]);r.length>0&&C(r),v.current&&(v.current.value="")},J=h(e=>{e.preventDefault(),P(!1);const r=Array.from(e.dataTransfer.files);C(r)},[C]),K=h(async e=>{const r=t.find(a=>a.id===e);if(r)try{r.uploaded&&await ge(r.uploaded);const a=t.filter(s=>s.id!==e);z.current=!0,u(a),setTimeout(()=>N(a),0)}catch(a){D(a,{userMessage:d("file.delete.failed"),severity:"error",showNotification:!0})}},[t,N,d]),Q=n||t.length===0,Ne=t.some(e=>!e.uploaded&&!e.error&&e.uploadProgress===null);return c(F,{gap:"tight",children:[c(y,{level:"body",align:"start",children:[o,G?"*":""]}),Q&&c("div",{role:"button",tabIndex:0,"aria-label":d(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":b?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:R?"var(--primary)":b?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:R?"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(),P(!0)},onDragLeave:()=>P(!1),onDrop:J,onClick:()=>v.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),v.current?.click())},children:[l("input",{ref:v,type:"file",accept:q,multiple:n,style:{display:"none"},onChange:_}),c(F,{align:"center",justify:"center",children:[l(Y,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),l(y,{as:"p",variant:"muted",level:"small",align:"center",children:d(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),t.length>0&&l(F,{gap:"tight",children:t.map((e,r)=>{const a=ve(e.uploaded?.mimeType||e.file.type,e.file.name),s=e.uploadProgress!==null&&e.uploadProgress<100,p=e.uploaded&&!e.error;return c("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:[l(ye,{type:a,className:"dndev-size-md"}),c(F,{gap:"none",style:{flex:1,minWidth:0},children:[l(y,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),c(y,{level:"caption",variant:"muted",children:[he(e.uploaded?.size||e.file.size),e.error&&c("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),s&&l(ce,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),s?l(ee,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):l(de,{variant:ue.GHOST,onClick:()=>K(e.id),"aria-label":d("file.delete.ariaLabel"),children:l(Z,{className:"dndev-size-sm"})})]},e.id)})}),M&&l(y,{level:"caption",variant:b?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]})});H.displayName="FileFieldComponent";var xe=H;export{xe 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 g,Stack as D,Text as j}from"@donotdev/components";import{useTranslation as H}from"@donotdev/core";const V=({checked:l=!1,onChange:s,required:u,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:u,plain:!0,onClick:C,style:{cursor:"pointer"},children:o(j,{level:"small",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(g,{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(g,{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 q=V;export{q as default};
1
+ import{jsx as t,jsxs as a,Fragment as w}from"react/jsx-runtime";import{useState as m}from"react";import{Checkbox as D,Label as H,Sheet as f,Stack as P,Text as V}from"@donotdev/components";import{useTranslation as j}from"@donotdev/core";const q=({checked:o=!1,onChange:l,required:u,privacyPolicyPath:s="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:r}=j("crud"),[y,d]=m(!1),[x,h]=m(!1),p=e=>{l&&l({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!o))},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 a(w,{children:[a(P,{direction:"row",align:"center",gap:"tight",children:[t(D,{checked:o,onCheckedChange:p}),t(H,{required:u,plain:!0,onClick:v,style:{cursor:"pointer"},children:a(V,{level:"small",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(f,{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(f,{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 O=q;export{O 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 t,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:a={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:f})=>{const m=l=>{const e=parseFloat(l.target.value)||0;if(e>=-90&&e<=90){const n={...a,lat:e},s={target:{value:JSON.stringify(n)}};i(s)}},p=l=>{const e=parseFloat(l.target.value)||0;if(e>=-180&&e<=180){const n={...a,lng:e},s={target:{value:JSON.stringify(n)}};i(s)}};return u(g,{gap:"tight",children:[t(b,{required:f,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:c}),u(g,{direction:"row",children:[t(v,{label:"Latitude",type:"number",value:a.lat,onChange:m,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),t(v,{label:"Longitude",type:"number",value:a.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&t("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-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 +1 @@
1
- {"version":3,"file":"ImageFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/ImageFieldComponent.tsx"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,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,wDAAwD;IACxD,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;AA8LD;;GAEG;AACH,QAAA,MAAM,mBAAmB,6HA0QxB,CAAC;AAIF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ImageFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/ImageFieldComponent.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAe9C,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,wDAAwD;IACxD,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;AA8LD;;GAEG;AACH,QAAA,MAAM,mBAAmB,6HA0QxB,CAAC;AAIF,eAAe,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as l,Fragment as q}from"react/jsx-runtime";import{DndContext as J,closestCenter as Q,PointerSensor as Z,TouchSensor as ee,useSensor as j,useSensors as re}from"@dnd-kit/core";import{SortableContext as te,useSortable as oe,rectSortingStrategy as ne,arrayMove as ie}from"@dnd-kit/sortable";import{CSS as ae}from"@dnd-kit/utilities";import{Upload as se,X as A,Loader2 as le,GripVertical as de}from"lucide-react";import{forwardRef as ce,useCallback as V,useImperativeHandle as pe,useRef as ue,useState as L}from"react";import{Text as h,Stack as C,Progress as ge}from"@donotdev/components";import{useTranslation as me}from"@donotdev/core";import{useFileUpload as he}from"../../../hooks/useFileUpload";import{processImage as ve}from"../../../utils/imageProcessing";import{uploadImage as fe}from"../../../utils/imageStorage";import{ImageViewerDialog as be}from"../internal/ImageViewerDialog";const ye=["image/*"];function we(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function xe({file:t,index:v,multiple:f,onImageClick:d,onRemove:b,t:u}){const{attributes:n,listeners:D,setNodeRef:S,transform:g,transition:R,isDragging:y}=oe({id:t.id}),w=t.progress!==null&&t.progress<100,s=f&&!w,a={transform:ae.Transform.toString(g),transition:R,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:S,style:a,...n,...s?D:{},onClick:()=>{y||d(v)},children:w?l(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(le,{style:{animation:"spin 1s linear infinite"}}),r(ge,{value:t.progress||0,style:{width:"80%"}})]}):t.error?l(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(A,{style:{color:"var(--destructive)"}}),r(h,{variant:"destructive",level:"small",children:t.error})]}):l(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(de,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:u("image.alt.upload",{index:v+1}),draggable:!1,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:c=>{c.stopPropagation(),b(t.id)},onPointerDown:c=>c.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(A,{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(h,{variant:"muted",level:"small",style:{color:"white"},children:u("image.upload.pending",{defaultValue:"Pending"})})})]})})}const z=ce(({name:t="image",label:v,value:f,onChange:d,error:b,helperText:u,multiple:n=!1,maxFiles:D=10,maxSize:S=10*1024*1024,storagePath:g="uploads/images",required:R,capture:y},w)=>{const{t:s}=me("crud"),a=ue(null),[E,c]=L(!1),[_,P]=L(0),M=re(j(Z,{activationConstraint:{distance:8}}),j(ee,{activationConstraint:{delay:200,tolerance:5}})),N=V(async(e,o)=>{const{fullBlob:m,thumbBlob:x}=await ve(e);return fe(m,x,e.name,{storagePath:g,onProgress:I=>o(I.progress)})},[g]),{files:i,addFiles:F,removeFile:T}=he({name:t,value:f,onChange:d,multiple:n,maxFiles:D,maxSize:S,accept:ye,storagePath:g,uploadFn:N}),O=e=>{const o=Array.from(e.target.files||[]);o.length>0&&F(o),a.current&&(a.current.value="")},B=V(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&F(Array.from(e.dataTransfer.files))},[F]),G=V(e=>{const{active:o,over:m}=e;if(m&&o.id!==m.id){const x=i.findIndex(k=>k.id===o.id),I=i.findIndex(k=>k.id===m.id);if(x!==-1&&I!==-1){const U=ie(i,x,I).filter(p=>p.uploaded||p.previewURL).map(p=>p.uploaded||{fullUrl:p.previewURL,thumbUrl:p.previewURL});d(n?U.length>0?U:null:U[0]||null)}}},[i,n,d]),H=e=>{P(e),c(!0)},K=(e,o)=>{},W=e=>{const o=i[e];o&&T(o.id)},X=e=>{P(e)},Y=n||i.length===0;pe(w,()=>({upload:async()=>{},focus:()=>a.current?.focus()}),[]);const $=i.map(we);return l(C,{gap:"tight",children:[l(h,{level:"body",align:"start",children:[v,R&&"*"]}),Y&&l("div",{role:"button",tabIndex:0,onClick:()=>a.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&a.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:B,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:a,type:"file",accept:"image/*",capture:y,multiple:n,style:{display:"none"},onChange:O}),l(C,{align:"center",children:[r(se,{style:{color:"var(--muted-foreground)"}}),r(h,{variant:"muted",level:"small",children:n?s("image.upload.dropzoneMultiple",{defaultValue:"Drop images here or click to upload"}):s("image.upload.dropzoneSingle",{defaultValue:"Drop image here or click to upload"})})]})]}),i.length>0&&r(J,{sensors:M,collisionDetection:Q,onDragEnd:G,children:r(te,{items:i.map(e=>e.id),strategy:ne,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:i.map((e,o)=>r(xe,{file:e,index:o,multiple:n,onImageClick:H,onRemove:T,t:s},e.id))})})}),u&&r(h,{variant:b?"destructive":"muted",level:"small",children:u}),r(be,{images:$,selectedIndex:_,open:E,onClose:()=>c(!1),onUpdate:K,onDelete:W,onNavigate:X,multiple:n})]})});z.displayName="ImageFieldComponent";var je=z;export{je as default};
1
+ "use client";import{jsx as r,jsxs as d,Fragment as J}from"react/jsx-runtime";import{DndContext as Q,closestCenter as Y,PointerSensor as Z,TouchSensor as _,useSensor as z,useSensors as ee}from"@dnd-kit/core";import{SortableContext as re,useSortable as te,rectSortingStrategy as oe,arrayMove as ae}from"@dnd-kit/sortable";import{CSS as ie}from"@dnd-kit/utilities";import{Upload as ne,X as j,Loader2 as le,GripVertical as se}from"lucide-react";import{forwardRef as de,useCallback as U,useImperativeHandle as ue,useRef as pe,useState as A}from"react";import{Text as f,Stack as S,Progress as ce}from"@donotdev/components";import{useTranslation as ge}from"@donotdev/core";import{useFileUpload as me}from"../../../hooks/useFileUpload";import{processImage as he}from"../../../utils/imageProcessing";import{uploadImage as fe}from"../../../utils/imageStorage";import{ImageViewerDialog as ve}from"../internal/ImageViewerDialog";const be=["image/*"];function ye(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function xe({file:t,index:v,multiple:b,onImageClick:p,onRemove:y,t:c}){const{attributes:a,listeners:R,setNodeRef:D,transform:g,transition:I,isDragging:x}=te({id:t.id}),w=t.progress!==null&&t.progress<100,l=b&&!w,n={transform:ie.Transform.toString(g),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:x?.5:1,cursor:l?"grab":"pointer",userSelect:"none",touchAction:l?"none":"auto"};return r("div",{ref:D,style:n,...a,...l?R:{},onClick:()=>{x||p(v)},children:w?d(S,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(le,{style:{animation:"spin 1s linear infinite"}}),r(ce,{value:t.progress||0,style:{width:"80%"}})]}):t.error?d(S,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(j,{style:{color:"var(--destructive)"}}),r(f,{variant:"destructive",level:"small",children:t.error})]}):d(J,{children:[b&&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(se,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:c("image.alt.upload",{index:v+1}),draggable:!1,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:m=>{m.stopPropagation(),y(t.id)},onPointerDown:m=>m.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(j,{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(f,{variant:"muted",level:"small",style:{color:"white"},children:c("image.upload.pending",{defaultValue:"Pending"})})})]})})}const E=de(({name:t="image",label:v,value:b,onChange:p,error:y,helperText:c,multiple:a=!1,maxFiles:R=10,maxSize:D=10*1024*1024,storagePath:g="uploads/images",required:I,capture:x},w)=>{const{t:l}=ge("crud"),n=pe(null),[m,F]=A(!1),[V,L]=A(0),N=ee(z(Z,{activationConstraint:{distance:8}}),z(_,{activationConstraint:{delay:200,tolerance:5}})),B=U(async(e,o)=>{const{fullBlob:h,thumbBlob:C}=await he(e);return fe(h,C,e.name,{storagePath:g,onProgress:k=>o(k.progress)})},[g]),{files:i,addFiles:P,removeFile:T}=me({name:t,value:b,onChange:p,multiple:a,maxFiles:R,maxSize:D,accept:be,storagePath:g,uploadFn:B}),M=e=>{const o=Array.from(e.target.files||[]);o.length>0&&P(o),n.current&&(n.current.value="")},q=U(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&P(Array.from(e.dataTransfer.files))},[P]),G=U(e=>{const{active:o,over:h}=e;if(h&&o.id!==h.id){const C=i.findIndex(s=>s.id===o.id),k=i.findIndex(s=>s.id===h.id);if(C!==-1&&k!==-1){const s=ae(i,C,k).filter(u=>u.uploaded||u.previewURL).map(u=>u.uploaded||{fullUrl:u.previewURL,thumbUrl:u.previewURL});p(a?s.length>0?s:null:s[0]||null)}}},[i,a,p]),H=e=>{L(e),F(!0)},K=(e,o)=>{},O=e=>{const o=i[e];o&&T(o.id)},W=e=>{L(e)},X=a||i.length===0;ue(w,()=>({upload:async()=>{},focus:()=>n.current?.focus()}),[]);const $=i.map(ye);return d(S,{gap:"tight",children:[d(f,{level:"body",align:"start",children:[v,I&&"*"]}),X&&d("div",{role:"button",tabIndex:0,onClick:()=>n.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&n.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:q,style:{border:`var(--border-width) dashed ${y?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:n,type:"file",accept:"image/*",capture:x,multiple:a,style:{display:"none"},onChange:M}),d(S,{align:"center",children:[r(ne,{style:{color:"var(--muted-foreground)"}}),r(f,{variant:"muted",level:"small",children:a?l("image.upload.dropzoneMultiple",{defaultValue:"Drop images here or click to upload"}):l("image.upload.dropzoneSingle",{defaultValue:"Drop image here or click to upload"})})]})]}),i.length>0&&r(Q,{sensors:N,collisionDetection:Y,onDragEnd:G,children:r(re,{items:i.map(e=>e.id),strategy:oe,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:i.map((e,o)=>r(xe,{file:e,index:o,multiple:a,onImageClick:H,onRemove:T,t:l},e.id))})})}),c&&r(f,{variant:y?"destructive":"muted",level:"small",children:c}),r(ve,{images:$,selectedIndex:V,open:m,onClose:()=>F(!1),onUpdate:K,onDelete:O,onNavigate:W,multiple:a})]})});E.displayName="ImageFieldComponent";var we=E;export{we 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 t,jsxs as o,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:a=[],options:n,error:b,helperText:i,onChange:u,onBlur:S,required:x,className:y})=>{const{t:g}=k("crud"),m=M(),z=J(()=>n.map(e=>({value:String(e.value),label:e.label})),[n]),N=e=>{const r=Array.isArray(e)?e:[e],s={target:{value:JSON.stringify(r)}};u(s)},C=e=>{e||S?.()},O=e=>{const r=a.filter(c=>c!==e),s={target:{value:JSON.stringify(r)}};u(s)},l=!!b,A=`${m}-error`,T=`${m}-helper`,j=a.length>0?o(q,{children:[a.slice(0,a.length>d?v:d).map((e,r)=>{const s=n.find(c=>String(c.value)===e)?.label||e;return t(p,{size:"sm",onRemove:()=>O(e),children:s},r)}),a.length>d&&o(p,{size:"sm",variant:"outline",disabled:!0,children:["+",a.length-v," more"]})]}):void 0;return o(h,{gap:"tight",className:y,children:[t(R,{label:f,value:a,onValueChange:N,onOpenChange:C,placeholder:g("actions.selectOptions","Select options..."),emptyMessage:g("messages.noResults","No results found"),options:z,multiple:!0,required:x,variant:l?"destructive":void 0,chips:j}),l&&o(h,{id:A,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),i]}),i&&!l&&t("p",{id:T,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})};var I=B;export{I as default};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as d}from"react/jsx-runtime";import{useState as y}from"react";import{Input as h,Button as x,Stack as i}from"@donotdev/components";import{useTranslation as b}from"@donotdev/core";const w=({label:c,value:o=[],onChange:l,className:m,required:p})=>{const{t:s}=b("crud"),[n,u]=y(""),f=()=>{if(n.trim()){const e=[...o,n.trim()],t={target:{value:JSON.stringify(e)}};l(t),u("")}},g=e=>{const t=o.filter((S,v)=>v!==e),r={target:{value:JSON.stringify(t)}};l(r)};return d(i,{className:m,children:[d(i,{direction:"row",align:"end",children:[a(h,{label:c,type:"text",value:n,onChange:e=>u(e.target.value),required:p,className:"dndev-flex-1",placeholder:s("form.typeAndPressAdd","Type and press Add...")}),a(x,{type:"button",onClick:f,disabled:!n.trim(),children:s("form.add","Add")})]}),a(i,{direction:"row",wrap:"wrap",children:o.map((e,t)=>d("span",{className:"dndev-surface","data-variant":"muted",style:{display:"inline-flex",alignItems:"center",gap:"var(--gap-sm)",padding:"var(--gap-sm) var(--gap-md)",fontSize:"var(--font-size-sm)",fontWeight:500,borderRadius:"var(--radius-lg)"},children:[e,a("button",{type:"button",onClick:()=>g(t),style:{color:"var(--muted-foreground)",marginInlineStart:"var(--gap-sm)"},onMouseEnter:r=>{r.currentTarget.style.color="var(--foreground)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--muted-foreground)"},"aria-label":`${s("form.remove","Remove")} ${e}`,children:"\xD7"})]},t))})]})};var j=w;export{j as default};
1
+ "use client";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useState as y}from"react";import{Input as h,Button as b,Stack as d}from"@donotdev/components";import{useTranslation as x}from"@donotdev/core";const N=({label:m,value:o=[],onChange:l,className:c,required:p})=>{const{t:s}=x("crud"),[t,u]=y(""),g=()=>{if(t.trim()){const e=[...o,t.trim()],r={target:{value:JSON.stringify(e)}};l(r),u("")}},f=e=>{const r=o.filter((w,v)=>v!==e),a={target:{value:JSON.stringify(r)}};l(a)};return i(d,{className:c,children:[i(d,{direction:"row",align:"end",children:[n(h,{label:m,type:"text",value:t,onChange:e=>u(e.target.value),required:p,className:"dndev-flex-1",placeholder:s("form.typeAndPressAdd","Type and press Add...")}),n(b,{type:"button",onClick:g,disabled:!t.trim(),children:s("form.add","Add")})]}),n(d,{direction:"row",wrap:"wrap",children:o.map((e,r)=>i("span",{className:"dndev-surface","data-variant":"muted",style:{display:"inline-flex",alignItems:"center",gap:"var(--gap-sm)",padding:"var(--gap-sm) var(--gap-md)",fontSize:"var(--font-size-sm)",fontWeight:500,borderRadius:"var(--radius-lg)"},children:[e,n("button",{type:"button",onClick:()=>f(r),style:{color:"var(--muted-foreground)",marginInlineStart:"var(--gap-sm)"},onMouseEnter:a=>{a.currentTarget.style.color="var(--foreground)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--muted-foreground)"},"aria-label":`${s("form.remove","Remove")} ${e}`,children:"\xD7"})]},r))})]})};var S=N;export{S as default};
@@ -1 +1 @@
1
- import{jsx as g,jsxs as z}from"react/jsx-runtime";import{useState as C,useEffect as E,useCallback as y}from"react";import{Input as I,cn as M,Stack as T}from"@donotdev/components";import{useTranslation as _}from"@donotdev/core";const q=({label:S,value:u,onChange:i,error:d,helperText:m,min:b,max:x,step:N,disabled:l,required:F,className:V,mask:r="number",...h})=>{const{i18n:j}=_(),a=j?.language||(typeof navigator<"u"?navigator.language:"en-US"),s=y(e=>e==null||isNaN(e)?"":r==="currency"?e.toLocaleString(a,{minimumFractionDigits:2,maximumFractionDigits:2}):r==="mileage"?Math.round(e).toLocaleString(a):e.toString(),[r,a]),v=y(e=>{if(!e||e.trim()==="")return null;const t=new Intl.NumberFormat(a).formatToParts(1234.56),D=t.find(c=>c.type==="group")?.value||",",L=t.find(c=>c.type==="decimal")?.value||".";let o=e.replace(new RegExp(`\\${D}`,"g"),"");o=o.replace(L,"."),o=o.replace(/[^\d.\-]/g,"");const p=parseFloat(o);return isNaN(p)?null:p},[a]),[w,f]=C(()=>s(u));return E(()=>{f(s(u))},[u,s]),z(T,{gap:"tight",children:[g(I,{type:r==="number"?"number":"text",inputMode:r==="number"?void 0:"decimal",label:S,value:w,onChange:e=>{const n=e.target.value;if(f(n),r==="number"){const t=parseFloat(n);isNaN(t)?i(e):i({...e,target:{...e.target,value:t.toString()}})}else{const t=v(n);t!==null?i({...e,target:{...e.target,value:t.toString()}}):n===""&&i({...e,target:{...e.target,value:""}})}},min:b,max:x,step:N,disabled:l,required:F,className:M("dndev-w-full",V),"data-variant":d?"destructive":void 0,style:{opacity:l?"var(--opacity-muted)":void 0,cursor:l?"not-allowed":void 0},...h}),m&&g("p",{style:{fontSize:"var(--font-size-xs)",color:d?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:m})]})};var G=q;export{G as default};
1
+ import{jsx as v,jsxs as j}from"react/jsx-runtime";import{useState as q,useEffect as z,useCallback as f}from"react";import{Input as D,cn as E,Stack as I}from"@donotdev/components";import{useTranslation as L}from"@donotdev/core";const M=({label:b,value:l,onChange:i,error:g,helperText:c,min:x,max:y,step:N,disabled:s,required:S,className:h,mask:r="number",...F})=>{const{i18n:T}=L(),n=T?.language||(typeof navigator<"u"?navigator.language:"en-US"),u=f(e=>e==null||isNaN(e)?"":r==="currency"?e.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2}):r==="mileage"?Math.round(e).toLocaleString(n):e.toString(),[r,n]),k=f(e=>{if(!e||e.trim()==="")return null;const t=new Intl.NumberFormat(n).formatToParts(1234.56),a=t.find(m=>m.type==="group")?.value||",",C=t.find(m=>m.type==="decimal")?.value||".";let o=e.replace(new RegExp(`\\${a}`,"g"),"");o=o.replace(C,"."),o=o.replace(/[^\d.\-]/g,"");const p=parseFloat(o);return isNaN(p)?null:p},[n]),[w,d]=q(()=>u(l));return z(()=>{d(u(l))},[l,u]),j(I,{gap:"tight",children:[v(D,{type:r==="number"?"number":"text",inputMode:r==="number"?void 0:"decimal",label:b,value:w,onChange:e=>{const t=e.target.value;if(d(t),r==="number"){const a=parseFloat(t);isNaN(a)?i(e):i({...e,target:{...e.target,value:a.toString()}})}else{const a=k(t);a!==null?i({...e,target:{...e.target,value:a.toString()}}):t===""&&i({...e,target:{...e.target,value:""}})}},min:x,max:y,step:N,disabled:s,required:S,className:E("dndev-w-full",h),"data-variant":g?"destructive":void 0,style:{opacity:s?"var(--opacity-muted)":void 0,cursor:s?"not-allowed":void 0},...F}),c&&v("p",{style:{fontSize:"var(--font-size-xs)",color:g?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:c})]})};var G=M;export{G as default};
@@ -1 +1 @@
1
- "use client";import{jsx as o,jsxs as i}from"react/jsx-runtime";import{useId as l}from"react";import{PasswordInput as u,Stack as m}from"@donotdev/components";const c=({label:s,value:a,onChange:t,error:n,helperText:r,...e})=>{const d=l();return i(m,{gap:"tight",children:[o(u,{id:d,value:a??"",onChange:t,label:s,className:"dndev-w-full",required:e.required,...e}),r&&o("p",{style:{fontSize:"var(--font-size-xs)",color:n?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]})};var j=c;export{j as default};
1
+ "use client";import{jsx as a,jsxs as d}from"react/jsx-runtime";import{useId as i}from"react";import{PasswordInput as u,Stack as m}from"@donotdev/components";const p=({label:o,value:s,onChange:t,error:n,helperText:e,...r})=>{const l=i();return d(m,{gap:"tight",children:[a(u,{id:l,value:s??"",onChange:t,label:o,className:"dndev-w-full",required:r.required,...r}),e&&a("p",{style:{fontSize:"var(--font-size-xs)",color:n?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:e})]})};var c=p;export{c as default};