@donotdev/crud 0.1.0 → 0.1.1

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 (157) hide show
  1. package/dist/CrudService.d.ts +9 -0
  2. package/dist/CrudService.d.ts.map +1 -1
  3. package/dist/CrudService.js +2 -2
  4. package/dist/CrudStore.d.ts.map +1 -1
  5. package/dist/CrudStore.js +1 -1
  6. package/dist/FieldRegistry.d.ts +2 -12
  7. package/dist/FieldRegistry.d.ts.map +1 -1
  8. package/dist/FieldRegistry.js +1 -1
  9. package/dist/components/CrudButton.d.ts +1 -0
  10. package/dist/components/CrudButton.d.ts.map +1 -1
  11. package/dist/components/CrudCard.d.ts +1 -1
  12. package/dist/components/CrudCard.d.ts.map +1 -1
  13. package/dist/components/CrudCard.js +1 -1
  14. package/dist/components/DisplayFieldRenderer.d.ts +1 -0
  15. package/dist/components/DisplayFieldRenderer.d.ts.map +1 -1
  16. package/dist/components/DisplayFieldRenderer.js +1 -1
  17. package/dist/components/DisplayThumbnail.d.ts +1 -9
  18. package/dist/components/DisplayThumbnail.d.ts.map +1 -1
  19. package/dist/components/DisplayThumbnail.js +1 -1
  20. package/dist/components/EntityFilters.d.ts +1 -0
  21. package/dist/components/EntityFilters.d.ts.map +1 -1
  22. package/dist/components/FormFieldRenderer.d.ts +1 -0
  23. package/dist/components/FormFieldRenderer.d.ts.map +1 -1
  24. package/dist/components/FormFieldRenderer.js +1 -1
  25. package/dist/components/FormLayout.d.ts +1 -0
  26. package/dist/components/FormLayout.d.ts.map +1 -1
  27. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  28. package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
  29. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  30. package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
  31. package/dist/components/controlled/complex/ControlledMapField.js +1 -1
  32. package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
  33. package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
  34. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  35. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  36. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  37. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  38. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  39. package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
  40. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  41. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  42. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  43. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  44. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  45. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  46. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  47. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  48. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  49. package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
  50. package/dist/components/controlled/input/ControlledTextField.d.ts +5 -5
  51. package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
  52. package/dist/components/controlled/input/ControlledTextField.js +1 -1
  53. package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
  54. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  55. package/dist/components/controlled/select/ControlledDropdownField.d.ts +2 -4
  56. package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
  57. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  58. package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts +2 -4
  59. package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
  60. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  61. package/dist/components/controlled/select/ControlledRadioField.d.ts +2 -4
  62. package/dist/components/controlled/select/ControlledRadioField.d.ts.map +1 -1
  63. package/dist/components/controlled/select/ControlledRadioField.js +1 -1
  64. package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
  65. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  66. package/dist/components/fields/display/DateFieldDisplay.d.ts.map +1 -1
  67. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  68. package/dist/components/fields/display/NumberFieldDisplay.d.ts.map +1 -1
  69. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  70. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  71. package/dist/components/fields/display/TimestampFieldDisplay.d.ts.map +1 -1
  72. package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
  73. package/dist/components/form/fields/CurrencyFieldComponent.d.ts.map +1 -1
  74. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  75. package/dist/components/form/fields/DateFieldComponent.d.ts +2 -2
  76. package/dist/components/form/fields/DateFieldComponent.d.ts.map +1 -1
  77. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  78. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  79. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  80. package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
  81. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  82. package/dist/components/form/fields/TextFieldComponent.d.ts +2 -2
  83. package/dist/components/form/fields/TextFieldComponent.d.ts.map +1 -1
  84. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  85. package/dist/components/form/fields/TimestampFieldComponent.d.ts +2 -2
  86. package/dist/components/form/fields/TimestampFieldComponent.d.ts.map +1 -1
  87. package/dist/contexts/UploadContext.d.ts +1 -0
  88. package/dist/contexts/UploadContext.d.ts.map +1 -1
  89. package/dist/fieldTypeRegistry.store.d.ts.map +1 -1
  90. package/dist/fieldTypeRegistry.store.js +1 -1
  91. package/dist/fieldTypeRegistry.types.d.ts +4 -0
  92. package/dist/fieldTypeRegistry.types.d.ts.map +1 -1
  93. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  94. package/dist/forms/hooks/useEntityForm.js +1 -1
  95. package/dist/forms/types.d.ts +5 -0
  96. package/dist/forms/types.d.ts.map +1 -1
  97. package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
  98. package/dist/forms/utils/buildInitialValues.js +1 -1
  99. package/dist/forms/utils/getFieldsForOperation.d.ts.map +1 -1
  100. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  101. package/dist/forms/utils/isFieldEditable.d.ts +7 -1
  102. package/dist/forms/utils/isFieldEditable.d.ts.map +1 -1
  103. package/dist/forms/utils/isFieldEditable.js +1 -1
  104. package/dist/hooks/index.d.ts +2 -0
  105. package/dist/hooks/index.d.ts.map +1 -1
  106. package/dist/hooks/index.js +1 -1
  107. package/dist/hooks/useCrudFilters.d.ts +2 -0
  108. package/dist/hooks/useCrudFilters.d.ts.map +1 -1
  109. package/dist/hooks/useCrudPageSize.d.ts +29 -0
  110. package/dist/hooks/useCrudPageSize.d.ts.map +1 -0
  111. package/dist/hooks/useCrudPageSize.js +1 -0
  112. package/dist/hooks/useEntityFavorites.d.ts +2 -0
  113. package/dist/hooks/useEntityFavorites.d.ts.map +1 -1
  114. package/dist/hooks/useFileUpload.d.ts.map +1 -1
  115. package/dist/hooks/useFileUpload.js +1 -1
  116. package/dist/hooks/useReferenceResolver.d.ts +1 -1
  117. package/dist/hooks/useReferenceResolver.d.ts.map +1 -1
  118. package/dist/hooks/useReferenceResolver.js +1 -1
  119. package/dist/hooks/useRelatedItems.d.ts +2 -0
  120. package/dist/hooks/useRelatedItems.d.ts.map +1 -1
  121. package/dist/index.d.ts +3 -3
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +1 -1
  124. package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
  125. package/dist/registerBuiltinFieldTypes.js +1 -1
  126. package/dist/stores/FormStore.d.ts +2 -0
  127. package/dist/stores/FormStore.d.ts.map +1 -1
  128. package/dist/stores/FormStore.js +1 -1
  129. package/dist/stores/UploadStore.d.ts +9 -3
  130. package/dist/stores/UploadStore.d.ts.map +1 -1
  131. package/dist/stores/UploadStore.js +1 -1
  132. package/dist/symbol-index.json +1 -0
  133. package/dist/tsconfig.tsbuildinfo +1 -1
  134. package/dist/types.d.ts +6 -0
  135. package/dist/types.d.ts.map +1 -1
  136. package/dist/useCrud.d.ts +1 -0
  137. package/dist/useCrud.d.ts.map +1 -1
  138. package/dist/useCrud.js +1 -1
  139. package/dist/useCrudCardList.d.ts +5 -3
  140. package/dist/useCrudCardList.d.ts.map +1 -1
  141. package/dist/useCrudList.d.ts +5 -3
  142. package/dist/useCrudList.d.ts.map +1 -1
  143. package/dist/utils/clientListProcessing.d.ts +21 -2
  144. package/dist/utils/clientListProcessing.d.ts.map +1 -1
  145. package/dist/utils/clientListProcessing.js +1 -1
  146. package/dist/utils/fileStorage.d.ts +2 -0
  147. package/dist/utils/fileStorage.d.ts.map +1 -1
  148. package/dist/utils/fileStorage.js +1 -1
  149. package/dist/utils/imageProcessing.d.ts.map +1 -1
  150. package/dist/utils/imageProcessing.js +1 -1
  151. package/dist/utils/imageStorage.d.ts +2 -0
  152. package/dist/utils/imageStorage.d.ts.map +1 -1
  153. package/dist/utils/imageStorage.js +1 -1
  154. package/guidelines/COMPONENTS.md +234 -0
  155. package/guidelines/CRUD.md +340 -0
  156. package/guidelines/GOTCHAS.md +46 -0
  157. package/package.json +7 -4
@@ -1 +1 @@
1
- "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{PriceFieldComponent as h}from"../../form/fields";import{convertValidationRules as g}from"../types";function q(c){const{control:s,errors:n,fieldConfig:i,t:a,placeholder:d}=c,{name:e,label:u,validation:o}=i,r=(i.options||{}).fieldSpecific;return l(C,{name:e,control:s,rules:o?g(o):void 0,render:({field:t})=>{const p=t.value,f=m=>{t.onChange(m)};return l(h,{label:a(u),value:p??void 0,onChange:f,error:!!n[e],helperText:n[e]?.message,required:o?.required,placeholder:d,defaultCurrency:r?.defaultCurrency??"EUR",optionsTitle:r?.optionsTitle,currencies:r?.currencies})}})}export{q as ControlledPriceField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{PriceFieldComponent as h}from"../../form/fields";import{convertValidationRules as g}from"../types";function y(l){const{control:c,errors:v,fieldConfig:o,t:s,placeholder:a}=l,{name:u,label:d,validation:e}=o,r=(o.options||{}).fieldSpecific;return t(C,{name:u,control:c,rules:e?g(e):void 0,render:({field:n,fieldState:i})=>{const p=n.value,f=m=>{n.onChange(m)};return t(h,{label:s(d),value:p??void 0,onChange:f,error:!!i.error,helperText:i.error?.message,required:e?.required,placeholder:a,defaultCurrency:r?.defaultCurrency??"EUR",optionsTitle:r?.optionsTitle,currencies:r?.currencies})}})}export{y as ControlledPriceField};
@@ -1 +1 @@
1
- "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{RangeFieldComponent as f}from"../../form/fields";import{convertValidationRules as g}from"../types";function v(s){const{control:m,errors:t,fieldConfig:i,t:p}=s,{name:o,label:u,validation:e}=i,l=i.options||{},c=l.fieldSpecific;return a(d,{name:o,control:m,rules:e?g(e):void 0,render:({field:n})=>a(f,{label:p(u),value:n.value??void 0,onChange:r=>{typeof r=="number"?n.onChange(r):n.onChange(Number(r.target.value)||0)},error:!!t[o],helperText:t[o]?.message,required:e?.required,min:e?.min,max:e?.max,step:l.step,showValue:c?.showValue})})}export{v as ControlledRangeField};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{RangeFieldComponent as f}from"../../form/fields";import{convertValidationRules as g}from"../types";function R(a){const{control:s,errors:C,fieldConfig:n,t:m}=a,{name:p,label:u,validation:e}=n,t=n.options||{},c=t.fieldSpecific;return l(d,{name:p,control:s,rules:e?g(e):void 0,render:({field:o,fieldState:i})=>l(f,{label:m(u),value:o.value??void 0,onChange:r=>{typeof r=="number"?o.onChange(r):o.onChange(Number(r.target.value)||0)},error:!!i.error,helperText:i.error?.message,required:e?.required,min:e?.min,max:e?.max,step:t.step,showValue:c?.showValue})})}export{R as ControlledRangeField};
@@ -1 +1 @@
1
- "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{RatingFieldComponent as u}from"../../form/fields";import{convertValidationRules as f}from"../types";function R(a){const{control:s,errors:n,fieldConfig:r,t:m}=a,{name:o,label:c,validation:e}=r,i=(r.options||{}).fieldSpecific;return l(p,{name:o,control:s,rules:e?f(e):void 0,render:({field:t})=>l(u,{label:m(c),value:t.value??0,onChange:d=>{t.onChange(d)},error:!!n[o],helperText:n[o]?.message,required:e?.required,max:i?.max??e?.max??5,showValue:i?.showValue})})}export{R as ControlledRatingField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{RatingFieldComponent as d}from"../../form/fields";import{convertValidationRules as f}from"../types";function V(l){const{control:a,errors:x,fieldConfig:e,t:s}=l,{name:m,label:c,validation:o}=e,r=(e.options||{}).fieldSpecific;return t(u,{name:m,control:a,rules:o?f(o):void 0,render:({field:n,fieldState:i})=>t(d,{label:s(c),value:n.value??0,onChange:p=>{n.onChange(p)},error:!!i.error,helperText:i.error?.message,required:o?.required,max:r?.max??o?.max??5,showValue:r?.showValue})})}export{V as ControlledRatingField};
@@ -1 +1 @@
1
- "use client";import{jsx as i}from"react/jsx-runtime";import{Controller as V}from"react-hook-form";import{SwitchFieldComponent as x}from"../../form/fields";import"../types";function T(h){const{control:s,errors:u,fieldConfig:f,t:c,onChange:o}=h,{name:t,label:k,options:m={}}=f,e=m.fieldSpecific,p=e?.uncheckedValue??!1,l=e?.checkedValue??!0,d=e?.uncheckedLabel,r=e?.checkedLabel;return i(V,{name:t,control:s,render:({field:{value:C,onChange:b}})=>{const g=C===l,L=n=>{const a=n?l:p;b(a),o&&o(a)};return i(x,{label:c(k),checked:g,onChange:n=>L(n.target.checked),uncheckedLabel:d?c(d):void 0,checkedLabel:r?c(r):void 0,helperText:u[t]?.message})}})}export{T as ControlledSwitchField};
1
+ "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as V}from"react-hook-form";import{SwitchFieldComponent as x}from"../../form/fields";import"../types";function _(i){const{control:h,errors:S,fieldConfig:s,t:c,onChange:o}=i,{name:u,label:f,options:k={}}=s,e=k.fieldSpecific,m=e?.uncheckedValue??!1,t=e?.checkedValue??!0,l=e?.uncheckedLabel,r=e?.checkedLabel;return a(V,{name:u,control:h,render:({field:{value:p,onChange:C},fieldState:b})=>{const g=p===t,L=n=>{const d=n?t:m;C(d),o&&o(d)};return a(x,{label:c(f),checked:g,onChange:n=>L(n.target.checked),uncheckedLabel:l?c(l):void 0,checkedLabel:r?c(r):void 0,helperText:b.error?.message})}})}export{_ as ControlledSwitchField};
@@ -1,11 +1,11 @@
1
1
  import { type ControlledFieldProps } from '../types';
2
2
  import type { ReactElement } from 'react';
3
3
  /**
4
-
5
- * ControlledTextField - Explicit controlled component for text inputs
6
-
7
- * Forwards Controller's ref for focus/validation (simple input)
8
-
4
+ * ControlledTextField - Text input controlled by react-hook-form
5
+ *
6
+ * Uses Controller to keep value in sync with RHF state.
7
+ * register() is incompatible with TextFieldComponent's controlled
8
+ * `<Input value={value}>` — default values are overwritten on re-render.
9
9
  */
10
10
  export declare function ControlledTextField(props: ControlledFieldProps): ReactElement;
11
11
  //# sourceMappingURL=ControlledTextField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ControlledTextField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/input/ControlledTextField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAoC7E"}
1
+ {"version":3,"file":"ControlledTextField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/input/ControlledTextField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAyC7E"}
@@ -1 +1 @@
1
- "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{TextFieldComponent as d}from"../../form/fields";import{convertValidationRules as h}from"../types";function v(s){const{control:m,errors:n,fieldConfig:e,t:i,placeholder:p}=s,{name:r,label:c,validation:o,options:l={}}=e;return a(u,{name:r,control:m,rules:o?h(o):void 0,render:({field:t})=>a(d,{...t,label:i(c),value:t.value??"",onChange:t.onChange,error:n[r]?.message,helperText:n[r]?.message,type:e.type==="email"?"email":e.type==="url"?"url":e.type==="color"?"color":"text",required:o?.required,placeholder:p||l.placeholder,maxLength:o?.maxLength,showCharCount:l.showCharCount,className:l.className})})}export{v as ControlledTextField};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{TextFieldComponent as d}from"../../form/fields";import{convertValidationRules as x}from"../types";function b(a){const{control:s,errors:g,fieldConfig:r,t:m,placeholder:u}=a,{name:p,label:c,validation:o,options:n={}}=r,i=o?x(o):void 0,h=r.type==="email"?"email":r.type==="url"?"url":r.type==="color"?"color":"text";return l(C,{name:p,control:s,rules:i,render:({field:e,fieldState:t})=>l(d,{ref:e.ref,name:e.name,value:e.value??"",onChange:e.onChange,onBlur:e.onBlur,label:m(c),error:t.error?.message,helperText:t.error?.message,type:h,required:o?.required,placeholder:u||n.placeholder,maxLength:o?.maxLength,showCharCount:n.showCharCount,className:n.className})})}export{b as ControlledTextField};
@@ -1 +1 @@
1
- "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as h}from"react-hook-form";import{TextAreaComponent as p}from"../../form/fields";import{convertValidationRules as d}from"../types";function v(s){const{control:i,errors:a,fieldConfig:t,t:m,placeholder:u}=s,{name:r,label:c,validation:o}=t,e=t.options||{};return l(h,{name:r,control:i,rules:o?d(o):void 0,render:({field:n})=>l(p,{...n,label:m(c),value:n.value??"",onChange:n.onChange,error:a[r]?.message,helperText:a[r]?.message,required:o?.required,placeholder:u||e.placeholder,maxLength:o?.maxLength,showCharCount:e.showCharCount,autoResize:e.autoResize,rows:e.rows,className:e.className})})}export{v as ControlledTextareaField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as h}from"react-hook-form";import{TextAreaComponent as p}from"../../form/fields";import{convertValidationRules as d}from"../types";function w(s){const{control:l,errors:C,fieldConfig:n,t:i,placeholder:m}=s,{name:u,label:c,validation:o}=n,e=n.options||{};return t(h,{name:u,control:l,rules:o?d(o):void 0,render:({field:r,fieldState:a})=>t(p,{...r,label:i(c),value:r.value??"",onChange:r.onChange,error:a.error?.message,helperText:a.error?.message,required:o?.required,placeholder:m||e.placeholder,maxLength:o?.maxLength,showCharCount:e.showCharCount,autoResize:e.autoResize,rows:e.rows,className:e.className})})}export{w as ControlledTextareaField};
@@ -1 +1 @@
1
- "use client";import{jsx as b}from"react/jsx-runtime";import{useMemo as h}from"react";import{Controller as j,useWatch as q,useFormContext as B}from"react-hook-form";import{translateLabel as F}from"../../../forms/utils";import{ComboboxComponent as P}from"../../form/fields";import{convertValidationRules as S}from"../types";function _(x){const{control:d,errors:c,fieldConfig:r,t:l,placeholder:g}=x,{name:s,label:O,validation:n,options:p={}}=r,f=B()?.setValue,o=q({control:d}),t="dependsOn"in r?r.dependsOn:void 0,V=t&&o?o[t.field]:void 0,m=h(()=>{const e=n?.options;return e?typeof e=="function"?e(o||{}):e:[]},[n?.options,o,V]),v=h(()=>m.map(e=>({...e,label:F(e.label,l)})),[m,l]),a=p.fieldSpecific;return b(j,{name:s,control:d,rules:n?S(n):void 0,render:({field:e})=>{const y=i=>{const C=typeof i=="string"?i:i.target.value;if(e.onChange(C),t&&f&&a?.setParentOnChange){const u=a.setParentOnChange(C,o||{});u!=null&&f(t.field,u,{shouldValidate:!0,shouldDirty:!0})}};return b(P,{...e,label:l(O),value:e.value??"",onChange:y,onBlur:e.onBlur,options:v,error:!!c[s],helperText:c[s]?.message,required:n?.required,placeholder:g||p.placeholder,creatable:a?.creatable??!1})}})}export{_ as ControlledComboboxField};
1
+ "use client";import{jsx as C}from"react/jsx-runtime";import{useMemo as b}from"react";import{Controller as j,useWatch as q,useFormContext as B}from"react-hook-form";import{translateLabel as F}from"../../../forms/utils";import{ComboboxComponent as P}from"../../form/fields";import{convertValidationRules as w}from"../types";function k(h){const{control:u,errors:D,fieldConfig:r,t:l,placeholder:x}=h,{name:g,label:O,validation:o,options:c={}}=r,d=B()?.setValue,n=q({control:u}),t="dependsOn"in r?r.dependsOn:void 0,V=t&&n?n[t.field]:void 0,p=b(()=>{const e=o?.options;return e?typeof e=="function"?e(n||{}):e:[]},[o?.options,n,V]),v=b(()=>p.map(e=>({...e,label:F(e.label,l)})),[p,l]),s=c.fieldSpecific;return C(j,{name:g,control:u,rules:o?w(o):void 0,render:({field:e,fieldState:f})=>{const y=a=>{const m=typeof a=="string"?a:a.target.value;if(e.onChange(m),t&&d&&s?.setParentOnChange){const i=s.setParentOnChange(m,n||{});i!=null&&d(t.field,i,{shouldValidate:!0,shouldDirty:!0})}};return C(P,{...e,label:l(O),value:e.value??"",onChange:y,onBlur:e.onBlur,options:v,error:!!f.error,helperText:f.error?.message,required:o?.required,placeholder:x||c.placeholder,creatable:s?.creatable??!1})}})}export{k as ControlledComboboxField};
@@ -1,13 +1,11 @@
1
1
  import { type ControlledFieldProps } from '../types';
2
2
  import type { ReactElement } from 'react';
3
3
  /**
4
-
5
4
  * ControlledDropdownField - Explicit controlled component for select/dropdown inputs
6
-
5
+ *
7
6
  * Forwards Controller's ref for focus/validation (simple input)
8
-
7
+ *
9
8
  * Handles dynamic options (function-based) and dependsOn logic
10
-
11
9
  */
12
10
  export declare function ControlledDropdownField(props: ControlledFieldProps): ReactElement;
13
11
  //# sourceMappingURL=ControlledDropdownField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ControlledDropdownField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/select/ControlledDropdownField.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;;;GAQG;AAEH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CA4Gd"}
1
+ {"version":3,"file":"ControlledDropdownField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/select/ControlledDropdownField.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CA8Gd"}
@@ -1 +1 @@
1
- "use client";import{jsx as C}from"react/jsx-runtime";import{useMemo as g}from"react";import{Controller as w,useWatch as y,useFormContext as D}from"react-hook-form";import{translateLabel as S}from"../../../forms/utils";import{DropdownComponent as j}from"../../form/fields";import{convertValidationRules as q}from"../types";function _(h){const{control:u,errors:d,fieldConfig:r,t:s,onChange:B}=h,{name:i,label:O,validation:n,options:V={}}=r,p=D()?.setValue,o=y({control:u}),t="dependsOn"in r?r.dependsOn:void 0,x=t&&o?o[t.field]:void 0,f=g(()=>{const e=n?.options;return e?typeof e=="function"?e(o||{}):e:[]},[n?.options,o,x]),b=g(()=>f.map(e=>({...e,label:S(e.label,s)})),[f,s]),c=V.fieldSpecific;return C(w,{name:i,control:u,rules:n?q(n):void 0,render:({field:e})=>{const v=l=>{const m=typeof l=="string"?l:l.target.value;if(e.onChange(m),t&&p&&c?.setParentOnChange){const a=c.setParentOnChange(m,o||{});a!=null&&p(t.field,a,{shouldValidate:!0,shouldDirty:!0})}};return C(j,{label:s(O),value:e.value!==void 0&&e.value!==null?String(e.value):"",onChange:v,onBlur:e.onBlur,options:b,error:!!d[i],helperText:d[i]?.message,required:n?.required})}})}export{_ as ControlledDropdownField};
1
+ "use client";import{jsx as C}from"react/jsx-runtime";import{useMemo as h}from"react";import{Controller as w,useWatch as D,useFormContext as F}from"react-hook-form";import{translateLabel as j}from"../../../forms/utils";import{DropdownComponent as q}from"../../form/fields";import{convertValidationRules as B}from"../types";function z(g){const{control:u,errors:P,fieldConfig:s,t:i,onChange:S}=g,{name:O,label:x,validation:o,options:V={}}=s,p=F()?.setValue,t="dependsOn"in s?s.dependsOn:void 0,e=t?t.field:void 0,b=typeof o?.options=="function",l=D({control:u,name:e,disabled:!e}),c=h(()=>{const n=o?.options;if(!n)return[];if(typeof n=="function"){const r=e?{[e]:l}:{};return n(r)}return n},[o?.options,b,e,l]),v=h(()=>c.map(n=>({...n,label:j(n.label,i)})),[c,i]),f=V.fieldSpecific;return C(w,{name:O,control:u,rules:o?B(o):void 0,render:({field:n,fieldState:r})=>{const y=a=>{const m=typeof a=="string"?a:a.target.value;if(n.onChange(m),t&&p&&f?.setParentOnChange){const d=f.setParentOnChange(m,e?{[e]:l}:{});d!=null&&p(t.field,d,{shouldValidate:!0,shouldDirty:!0})}};return C(q,{label:i(x),value:n.value!==void 0&&n.value!==null?String(n.value):"",onChange:y,onBlur:n.onBlur,options:v,error:!!r.error,helperText:r.error?.message,required:o?.required})}})}export{z as ControlledDropdownField};
@@ -1,13 +1,11 @@
1
1
  import { type ControlledFieldProps } from '../types';
2
2
  import type { ReactElement } from 'react';
3
3
  /**
4
-
5
4
  * ControlledMultiDropdownField - Explicit controlled component for multiselect inputs
6
-
5
+ *
7
6
  * Forwards Controller's ref for focus/validation (simple input)
8
-
7
+ *
9
8
  * Handles dynamic options
10
-
11
9
  */
12
10
  export declare function ControlledMultiDropdownField(props: ControlledFieldProps): ReactElement;
13
11
  //# sourceMappingURL=ControlledMultiDropdownField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ControlledMultiDropdownField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/select/ControlledMultiDropdownField.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;;;GAQG;AAEH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAiFd"}
1
+ {"version":3,"file":"ControlledMultiDropdownField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/select/ControlledMultiDropdownField.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAsFd"}
@@ -1 +1 @@
1
- "use client";import{jsx as m}from"react/jsx-runtime";import{useMemo as c}from"react";import{Controller as y,useWatch as O}from"react-hook-form";import{translateLabel as b}from"../../../forms/utils";import{MultiDropdownComponent as x}from"../../form/fields";import{convertValidationRules as A}from"../types";function D(f){const{control:i,errors:u,fieldConfig:t,t:a}=f,{name:l,label:g,validation:n}=t,r=O({control:i}),p="dependsOn"in t?t.dependsOn:void 0,h=p&&r?r[p.field]:void 0,d=c(()=>{const e=n?.options;return e?typeof e=="function"?e(r||{}):e:[]},[n?.options,r,h]),C=c(()=>d.map(e=>({value:String(e.value),label:b(e.label,a)})),[d,a]);return m(y,{name:l,control:i,rules:n?A(n):void 0,render:({field:e})=>{const v=s=>{let o;if(Array.isArray(s))o=s;else try{o=JSON.parse(s.target.value)}catch{o=[]}e.onChange(o)};return m(x,{...e,label:a(g),value:Array.isArray(e.value)?e.value:[],onChange:v,onBlur:e.onBlur,options:C,error:!!u[l],helperText:u[l]?.message,required:n?.required})}})}export{D as ControlledMultiDropdownField};
1
+ "use client";import{jsx as c}from"react/jsx-runtime";import{useMemo as m}from"react";import{Controller as b,useWatch as v}from"react-hook-form";import{translateLabel as x}from"../../../forms/utils";import{MultiDropdownComponent as A}from"../../form/fields";import{convertValidationRules as w}from"../types";function J(f){const{control:l,errors:D,fieldConfig:s,t:a}=f,{name:h,label:y,validation:n}=s,u="dependsOn"in s?s.dependsOn:void 0,r=u?u.field:void 0,O=typeof n?.options=="function",p=v({control:l,name:r,disabled:!r}),d=m(()=>{const e=n?.options;if(!e)return[];if(typeof e=="function"){const o=r?{[r]:p}:{};return e(o)}return e},[n?.options,O,r,p]),g=m(()=>d.map(e=>({value:String(e.value),label:x(e.label,a)})),[d,a]);return c(b,{name:h,control:l,rules:n?w(n):void 0,render:({field:e,fieldState:o})=>{const C=i=>{let t;if(Array.isArray(i))t=i;else try{t=JSON.parse(i.target.value)}catch{t=[]}e.onChange(t)};return c(A,{...e,label:a(y),value:Array.isArray(e.value)?e.value:[],onChange:C,onBlur:e.onBlur,options:g,error:!!o.error,helperText:o.error?.message,required:n?.required})}})}export{J as ControlledMultiDropdownField};
@@ -1,13 +1,11 @@
1
1
  import { type ControlledFieldProps } from '../types';
2
2
  import type { ReactElement } from 'react';
3
3
  /**
4
-
5
4
  * ControlledRadioField - Explicit controlled component for radio inputs
6
-
5
+ *
7
6
  * Forwards Controller's ref for focus/validation (simple input)
8
-
7
+ *
9
8
  * Handles dynamic options
10
-
11
9
  */
12
10
  export declare function ControlledRadioField(props: ControlledFieldProps): ReactElement;
13
11
  //# sourceMappingURL=ControlledRadioField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ControlledRadioField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/select/ControlledRadioField.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;;;GAQG;AAEH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAiEd"}
1
+ {"version":3,"file":"ControlledRadioField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/select/ControlledRadioField.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAsEd"}
@@ -1 +1 @@
1
- "use client";import{jsx as p}from"react/jsx-runtime";import{useMemo as m}from"react";import{Controller as v,useWatch as O}from"react-hook-form";import{translateLabel as h}from"../../../forms/utils";import{RadioFieldComponent as x}from"../../form/fields";import{convertValidationRules as V}from"../types";function L(f){const{control:a,errors:l,fieldConfig:r,t}=f,{name:i,label:c,validation:n}=r,o=O({control:a}),d="dependsOn"in r?r.dependsOn:void 0,g=d&&o?o[d.field]:void 0,u=m(()=>{const e=n?.options;return e?typeof e=="function"?e(o||{}):e:[]},[n?.options,o,g]),C=m(()=>u.map(e=>({value:String(e.value),label:h(e.label,t)})),[u,t]);return p(v,{name:i,control:a,rules:n?V(n):void 0,render:({field:e})=>p(x,{...e,label:t(c),value:e.value??void 0,onChange:s=>{const b=typeof s=="string"?s:s.target.value;e.onChange(b)},options:C,error:!!l[i],helperText:l[i]?.message,required:n?.required})})}export{L as ControlledRadioField};
1
+ "use client";import{jsx as u}from"react/jsx-runtime";import{useMemo as c}from"react";import{Controller as h,useWatch as v}from"react-hook-form";import{translateLabel as x}from"../../../forms/utils";import{RadioFieldComponent as y}from"../../form/fields";import{convertValidationRules as F}from"../types";function M(m){const{control:a,errors:R,fieldConfig:r,t:i}=m,{name:f,label:g,validation:n}=r,l="dependsOn"in r?r.dependsOn:void 0,o=l?l.field:void 0,O=typeof n?.options=="function",d=v({control:a,name:o,disabled:!o}),p=c(()=>{const e=n?.options;if(!e)return[];if(typeof e=="function"){const t=o?{[o]:d}:{};return e(t)}return e},[n?.options,O,o,d]),b=c(()=>p.map(e=>({value:String(e.value),label:x(e.label,i)})),[p,i]);return u(h,{name:f,control:a,rules:n?F(n):void 0,render:({field:e,fieldState:t})=>u(y,{...e,label:i(g),value:e.value??void 0,onChange:s=>{const C=typeof s=="string"?s:s.target.value;e.onChange(C)},options:b,error:!!t.error,helperText:t.error?.message,required:n?.required})})}export{M as ControlledRadioField};
@@ -1 +1 @@
1
- "use client";import{jsx as u}from"react/jsx-runtime";import{useMemo as C}from"react";import{Controller as _}from"react-hook-form";import{useCrudList as x}from"../../../useCrudList";import S from"../../form/fields/ReferenceFieldComponent";import{convertValidationRules as L}from"../types";const R=["name","title","label","displayName"];function T(e,t,n){if(t?.length){const r=t.map(o=>e[o]).filter(o=>o!=null&&o!=="");if(r.length)return r.join(" ")}if(n&&e[n]!=null&&e[n]!=="")return String(e[n]);for(const r of R)if(e[r]!=null&&e[r]!=="")return String(e[r]);return e.id??"?"}function B(e){const{control:t,errors:n,fieldConfig:r,t:o,placeholder:p}=e,{name:s,label:m,validation:i,options:c={}}=r,f=i?.reference,a=c.fieldSpecific,{items:d,loading:g}=x(f??"__disabled__",{enabled:!!f}),b=C(()=>d.map(l=>({id:l.id,label:T(l,a?.labelFields,a?.displayField)})),[d,a?.labelFields,a?.displayField]);return u(_,{name:s,control:t,rules:i?L(i):void 0,render:({field:l})=>u(S,{label:o(m),value:l.value??"",onChange:h=>l.onChange(h),onBlur:l.onBlur,options:b,isLoading:g,error:!!n[s],helperText:n[s]?.message,required:i?.required,placeholder:p||c.placeholder})})}export{B as ControlledReferenceField,T as buildReferenceLabel};
1
+ "use client";import{jsx as d}from"react/jsx-runtime";import{useMemo as _}from"react";import{Controller as x}from"react-hook-form";import{useCrudList as L}from"../../../useCrudList";import R from"../../form/fields/ReferenceFieldComponent";import{convertValidationRules as S}from"../types";const T=["name","title","label","displayName"];function j(e,t,l){if(t?.length){const r=t.map(o=>e[o]).filter(o=>o!=null&&o!=="");if(r.length)return r.join(" ")}if(l&&e[l]!=null&&e[l]!=="")return String(e[l]);for(const r of T)if(e[r]!=null&&e[r]!=="")return String(e[r]);return e.id??"?"}function D(e){const{control:t,errors:l,fieldConfig:r,t:o,placeholder:p}=e,{name:m,label:g,validation:i,options:s={}}=r,c=i?.reference,a=s.fieldSpecific,{items:f,loading:b}=L(c??"__disabled__",{enabled:!!c}),h=_(()=>f.map(n=>({id:n.id,label:j(n,a?.labelFields,a?.displayField)})),[f,a?.labelFields,a?.displayField]);return d(x,{name:m,control:t,rules:i?S(i):void 0,render:({field:n,fieldState:u})=>d(R,{label:o(g),value:n.value??"",onChange:C=>n.onChange(C),onBlur:n.onBlur,options:h,isLoading:b,error:!!u.error,helperText:u.error?.message,required:i?.required,placeholder:p||s.placeholder})})}export{D as ControlledReferenceField,j as buildReferenceLabel};
@@ -1 +1 @@
1
- "use client";import{jsx as s}from"react/jsx-runtime";import{useMemo as b}from"react";import{Controller as x}from"react-hook-form";import{translateLabel as C}from"../../../forms/utils";import{ComboboxComponent as y}from"../../form/fields";import{convertValidationRules as v}from"../types";function B(i){const{control:u,errors:l,fieldConfig:m,t:c,placeholder:p}=i,{name:t,label:d,validation:r,options:f={}}=m,g=b(()=>{const e=r?.min??1900,a=r?.max??new Date().getFullYear()+10,n=[];for(let o=a;o>=e;o--)n.push({value:String(o),label:String(o)});return n},[r?.min,r?.max]);return s(x,{name:t,control:u,rules:r?v(r):void 0,render:({field:e})=>{const a=n=>{const o=typeof n=="string"?n:n.target.value,h=o===""?void 0:Number(o);e.onChange(h)};return s(y,{...e,label:C(d,c),value:e.value!==void 0&&e.value!==null?String(e.value):"",onChange:a,onBlur:e.onBlur,options:g,error:!!l[t],helperText:l[t]?.message,required:r?.required,placeholder:p||f.placeholder,translationNamespace:"crud",placeholderKey:"actions.selectYear",placeholderDefault:"Select or type year",creatable:!0})}})}export{B as ControlledYearField};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{useMemo as b}from"react";import{Controller as x}from"react-hook-form";import{translateLabel as C}from"../../../forms/utils";import{ComboboxComponent as y}from"../../form/fields";import{convertValidationRules as v}from"../types";function D(s){const{control:u,errors:Y,fieldConfig:i,t:m,placeholder:c}=s,{name:p,label:d,validation:o,options:g={}}=i,h=b(()=>{const e=o?.min??1900,n=o?.max??new Date().getFullYear()+10,t=[];for(let r=n;r>=e;r--)t.push({value:String(r),label:String(r)});return t},[o?.min,o?.max]);return l(x,{name:p,control:u,rules:o?v(o):void 0,render:({field:e,fieldState:n})=>{const t=r=>{const a=typeof r=="string"?r:r.target.value,f=a===""?void 0:Number(a);e.onChange(f)};return l(y,{...e,label:C(d,m),value:e.value!==void 0&&e.value!==null?String(e.value):"",onChange:t,onBlur:e.onBlur,options:h,error:!!n.error,helperText:n.error?.message,required:o?.required,placeholder:c||g.placeholder,translationNamespace:"crud",placeholderKey:"actions.selectYear",placeholderDefault:"Select or type year",creatable:!0})}})}export{D as ControlledYearField};
@@ -1 +1 @@
1
- {"version":3,"file":"DateFieldDisplay.d.ts","sourceRoot":"","sources":["../../../../src/components/fields/display/DateFieldDisplay.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC;IAC/C,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAC1D,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,CA+CjE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"DateFieldDisplay.d.ts","sourceRoot":"","sources":["../../../../src/components/fields/display/DateFieldDisplay.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC;IAC/C,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAC1D,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,CAgDjE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as d}from"react/jsx-runtime";import{Text as a,Spinner as c}from"@donotdev/components";const m=({config:i,value:n,t:p,className:t,loading:l=!1})=>{if(l)return e(c,{className:t});if(!n)return e(a,{as:"span",variant:"muted",className:t,children:"-"});try{const r=new Date(n),s=r.toLocaleDateString(),o=r.toLocaleTimeString();return i.type==="date"?e(a,{as:"span",className:t,children:s}):d("div",{className:t,children:[e(a,{as:"span",children:s}),e(a,{as:"span",variant:"muted",level:"small",children:o})]})}catch{return e(a,{as:"span",variant:"muted",className:t,children:"-"})}};var h=m;export{m as DateFieldDisplay,h as default};
1
+ import{jsx as e,jsxs as d}from"react/jsx-runtime";import{Text as a,Spinner as m}from"@donotdev/components";import{getI18nInstance as p}from"@donotdev/core";const f=({config:o,value:n,t:u,className:t,loading:l=!1})=>{if(l)return e(m,{className:t});if(!n)return e(a,{as:"span",variant:"muted",className:t,children:"-"});try{const r=new Date(n),s=p()?.language,i=r.toLocaleDateString(s),c=r.toLocaleTimeString(s);return o.type==="date"?e(a,{as:"span",className:t,children:i}):d("div",{className:t,children:[e(a,{as:"span",children:i}),e(a,{as:"span",variant:"muted",level:"small",children:c})]})}catch{return e(a,{as:"span",variant:"muted",className:t,children:"-"})}};var D=f;export{f as DateFieldDisplay,D as default};
@@ -1 +1 @@
1
- {"version":3,"file":"NumberFieldDisplay.d.ts","sourceRoot":"","sources":["../../../../src/components/fields/display/NumberFieldDisplay.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;IACxC,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAC1D,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CAwBrE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"NumberFieldDisplay.d.ts","sourceRoot":"","sources":["../../../../src/components/fields/display/NumberFieldDisplay.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;IACxC,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAC1D,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CAwBrE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -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 e}from"react/jsx-runtime";import{Text as t,Spinner as a}from"@donotdev/components";import{getI18nInstance as i}from"@donotdev/core";const s=({config:f,value:n,t:m,className:r,loading:o=!1})=>o?e(a,{className:r}):n==null?e(t,{as:"span",variant:"muted",className:r,children:"-"}):e(t,{as:"span",className:`font-mono ${r||""}`,children:n.toLocaleString(i()?.language)});var d=s;export{s as NumberFieldDisplay,d as default};
@@ -1 +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 k,Calendar as I,Clock as N}from"lucide-react";import{useState as j}from"react";import{Skeleton as f,Badge as A,BADGE_VARIANT as F,Text as l,cn as T,CopyToClipboard as x,Stack as i}from"@donotdev/components";import{getWeekFromISOString as B,getI18nInstance as C}from"@donotdev/core";const E=({config:o,value:r,t:a,className:c,loading:b=!1,showCopy:m=!1,asBadge:S=!1,truncate:s=!1,maxLength:d=50,showLabel:p=!1})=>{const[M,g]=j(!1),_=async()=>{try{await navigator.clipboard.writeText(r),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(o.type){case"email":return e(k,{});case"month":case"week":return e(I,{});case"time":return e(N,{});default:return null}},w=t=>{if(!t)return null;switch(o.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:u=>u.currentTarget.style.textDecoration="underline",onMouseLeave:u=>u.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(C()?.language,{year:"numeric",month:"long"});case"week":return B(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(C()?.language);default:return t}},D=t=>!s||t.length<=d?t:`${t.substring(0,d)}...`;if(b)return n(i,{gap:"tight",children:[p&&e(f,{style:{height:"1rem",width:"6rem"}}),e(f,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!r)return n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),e(l,{as:"span",variant:"muted",className:T(c),style:{fontStyle:"italic"},children:a("common.noValue",{defaultValue:"No value"})})]});const V=w(r),y=D(String(V));return S?n(i,{direction:"row",align:"center",gap:"tight",children:[h(),e(A,{variant:F.SECONDARY,className:c,children:y}),m&&e(x,{text:r,tooltipText:a("copyToClipboard")||"Copy to clipboard",copiedTooltipText:a("copied")||"Copied!",ariaLabel:a("copyToClipboard")||"Copy to clipboard"})]}):n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),n(i,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:T("dndev-flex-1",s&&"truncate",c),title:s&&r.length>d?r:void 0,children:e(l,{as:"span",children:y})}),m&&e(x,{text:r,tooltipText:a("copyToClipboard")||"Copy to clipboard",copiedTooltipText:a("copied")||"Copied!",ariaLabel:a("copyToClipboard")||"Copy to clipboard"})]})]})};var q=E;export{E as TextFieldDisplay,q as default};
@@ -1 +1 @@
1
- {"version":3,"file":"TimestampFieldDisplay.d.ts","sourceRoot":"","sources":["../../../../src/components/fields/display/TimestampFieldDisplay.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,0BAA0B;IACzC,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACjC,uBAAuB;IACvB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAC1D,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,0BAA0B,CA8B3B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"TimestampFieldDisplay.d.ts","sourceRoot":"","sources":["../../../../src/components/fields/display/TimestampFieldDisplay.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,0BAA0B;IACzC,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACjC,uBAAuB;IACvB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAC1D,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,0BAA0B,CA+B3B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -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 t,jsxs as c}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";import{getI18nInstance as l}from"@donotdev/core";const m=({config:d,value:n,t:p,className:a})=>{if(!n)return t(e,{as:"span",variant:"muted",className:a,children:"-"});try{const r=new Date(n),s=l()?.language,o=r.toLocaleDateString(s),i=r.toLocaleTimeString(s);return c("div",{className:a,children:[t(e,{as:"span",children:o}),t(e,{as:"span",variant:"muted",level:"small",children:i})]})}catch{return t(e,{as:"span",variant:"muted",className:a,children:"-"})}};var g=m;export{m as TimestampFieldDisplay,g as default};
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/CurrencyFieldComponent.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,2BAA2B;IAC1C,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACzD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,EAAE,aAAa,CAAC,2BAA2B,CAyHtE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"CurrencyFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/CurrencyFieldComponent.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,2BAA2B;IAC1C,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACzD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,EAAE,aAAa,CAAC,2BAA2B,CA4ItE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -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 r,jsxs as h}from"react/jsx-runtime";import{useState as v,useEffect as z,useId as L}from"react";import{Input as B,FloatingLabel as D,Stack as M}from"@donotdev/components";const U=({label:b,value:t,onChange:F,currency:s="EUR",locale:C,error:c,helperText:u,required:S=!1,disabled:i=!1,placeholder:x})=>{const d=L(),I=C||(typeof navigator<"u"?navigator.language:"en-US"),a=e=>e==null||isNaN(e)?"":(e/100).toString(),f=e=>{if(!e||e.trim()==="")return null;const n=e.replace(/[^\d.,\-]/g,"").replace(",","."),l=parseFloat(n);return isNaN(l)?null:Math.round(l*100)},[p,o]=v(a(t)),[m,g]=v(!1);z(()=>{m?f(p)!==t&&o(a(t)):o(a(t))},[t,m]);const N=e=>{const n=e.target.value;o(n);const E={target:{value:f(n)}};F(E)},V=()=>g(!0),j=()=>g(!1),y=(()=>{try{return new Intl.NumberFormat(I,{style:"currency",currency:s,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||s}catch{return s}})();return h(M,{gap:"tight",children:[r(D,{htmlFor:d,label:b,disabled:i,required:S,children:h("div",{style:{position:"relative"},children:[r("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:y}),r(B,{id:d,type:"text",inputMode:"decimal",bare:!0,value:p,onChange:N,onFocus:V,onBlur:j,disabled:i,placeholder:x||"0","data-variant":c?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${y.length*.6}em + var(--gap-sm))`}})]})}),u&&r("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:u})]})};var P=U;export{P as default};
@@ -6,8 +6,8 @@ export interface DateFieldComponentProps {
6
6
  value?: string | null;
7
7
  /** Change handler emitting an ISO string or null */
8
8
  onChange: (date: string | null) => void;
9
- /** Whether the field is in error state */
10
- error?: boolean;
9
+ /** Error message (string = message to display, falsy = no error) */
10
+ error?: string;
11
11
  /** Helper text to display */
12
12
  helperText?: string;
13
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DateFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DateFieldComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,0CAA0C;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CAgE9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"DateFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DateFieldComponent.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CA4F9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -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 d}from"react/jsx-runtime";import{useId as v}from"react";import{Input as I,cn as m,Stack as c}from"@donotdev/components";const w=({label:f,value:s,onChange:u,error:o,helperText:n,mode:t="date",required:g,...S})=>{const a=v(),i=!!o,p=e=>{const h=e.target.value?new Date(e.target.value).toISOString():null;u(h)};let r="";if(s){const e=new Date(s);t==="date"?r=e.toISOString().split("T")[0]||"":t==="datetime-local"?r=e.toISOString().slice(0,16)||"":t==="month"?r=e.toISOString().slice(0,7):t==="time"?r=e.toISOString().slice(11,16):t==="week"&&(r=e.toISOString().split("T")[0]||"")}return d(c,{gap:"tight",children:[l(I,{id:a,label:f,type:t,value:r,onChange:p,required:g,"aria-describedby":m(i&&`${a}-error`,n&&!i&&`${a}-helper`),"aria-invalid":i,"data-variant":i?"destructive":void 0,className:"dndev-w-full",...S}),i&&d(c,{id:`${a}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[l("span",{children:"\u26A0"}),o]}),n&&!i&&l("p",{id:`${a}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var j=w;export{j 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 Ae({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:A,error:D,helperText:M,multiple:p=!1,maxFiles:k=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);A(p?t:t[0]||null)},[p,A]);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?k:1)-a.length;if(r<=0){N(new Error("Maximum documents reached"),{userMessage:s("document.errors.maxFiles",{max:k}),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,k,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",textAlign:"start",children:[c,K?"*":""]}),oe&&l("div",{role:"button",tabIndex:0,"aria-label":s("document.upload.ariaLabel"),className:"dndev-surface","data-variant":D?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:O?"var(--primary)":D?"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",textAlign:"center",children:s("document.upload.hint")}),n(g,{as:"p",variant:"muted",level:"caption",textAlign:"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(Ae,{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:D?"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 n,jsxs as l,Fragment as ie}from"react/jsx-runtime";import{Upload as se,X as ae,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 B,useImperativeHandle as pe,forwardRef as me}from"react";import{Button as W,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 Ae({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:A,error:D,helperText:M,multiple:p=!1,maxFiles:k=10,maxSize:C=25*1024*1024,storagePath:R="uploads/documents",required:K,enablePreview:L=!0},J)=>{const{t:Q}=we("crud"),a=Q,h=xe(),H=!!h,[s,u]=E([]),[O,I]=E(!1),[S,_]=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);A(p?t:t[0]||null)},[p,A]);B(()=>{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=s.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))}}},[s,R,b]);T.current=Z,B(()=>{if(!(!h||!f))return V.getState().registerUpload(h,f,async(e,t)=>{await T.current?.()}),()=>{V.getState().unregisterUpload(h,f)}},[h,f]),pe(J,()=>({upload:async()=>{await T.current?.()},getDocuments:()=>j.current||[]}),[]);const j=F(s);j.current=s;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?k:1)-s.length;if(r<=0){N(new Error("Maximum documents reached"),{userMessage:a("document.errors.maxFiles",{max:k}),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:a("document.errors.invalidType",{fileName:m.name}),severity:"warning",showNotification:!0});continue}if(m.size>C){N(new Error("Document too large"),{userMessage:a("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))},[s,p,k,C,a,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=s.find(r=>r.id===e);if(t)try{t.uploaded&&await be(t.uploaded);const r=s.filter(i=>i.id!==e);U.current=!0,u(r),setTimeout(()=>b(r),0)}catch(r){N(r,{userMessage:a("document.delete.failed"),severity:"error",showNotification:!0})}},[s,b,a]),ne=e=>{e.uploaded?.url&&e.uploaded.mimeType==="application/pdf"&&_(e.uploaded.url)},oe=p||s.length===0;return l(ie,{children:[l(x,{gap:"tight",children:[l(g,{level:"body",textAlign:"start",children:[c,K?"*":""]}),oe&&l("div",{role:"button",tabIndex:0,"aria-label":a("document.upload.ariaLabel"),className:"dndev-surface","data-variant":D?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:O?"var(--primary)":D?"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(se,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),n(g,{as:"p",variant:"muted",level:"small",textAlign:"center",children:a("document.upload.hint")}),n(g,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),s.length>0&&n(x,{gap:"tight",children:s.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(Ae,{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(W,{variant:G.GHOST,onClick:()=>ne(e),"aria-label":a("document.preview.ariaLabel"),children:n(ue,{className:"dndev-size-sm"})}),i?n(ce,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):n(W,{variant:G.GHOST,onClick:()=>te(e.id),"aria-label":a("document.delete.ariaLabel"),children:n(ae,{className:"dndev-size-sm"})})]})]},e.id)})}),M&&n(g,{level:"caption",variant:D?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]}),L&&S&&n(ge,{open:!!S,onOpenChange:()=>_(null),children:l(ve,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[n(he,{children:n(ye,{children:a("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 +1 @@
1
- "use client";import{jsx as s,jsxs as p}from"react/jsx-runtime";import{Upload as Z,X as $,File as ee,Loader2 as re,FileText as z,FileSpreadsheet as te,FileImage as se,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 A,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 s(z,{className:l,style:{color:"var(--destructive)"}});case"doc":return s(z,{className:l,style:{color:"var(--primary)"}});case"xls":return s(te,{className:l,style:{color:"var(--success)"}});case"ppt":return s(z,{className:l,style:{color:"var(--warning)"}});case"image":return s(se,{className:l});case"video":return s(oe,{className:l});case"audio":return s(ae,{className:l});case"archive":return s(ne,{className:l});case"html":case"text":return s(le,{className:l});default:return s(ee,{className:l})}}const V=de(({name:f,label:l,value:g,onChange:P,error:T,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 t=e.filter(r=>r.uploaded&&!r.error).map(r=>r.uploaded);P(d?t:t[0]||null)},[d,P]);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(t=>!t.uploaded&&!t.error&&t.uploadProgress===null);if(e.length!==0){c(t=>t.map(r=>e.some(o=>o.id===r.id)?{...r,uploadProgress:0}:r));for(const t of e)try{const r=await me(t.file,{storagePath:R,onProgress:o=>{c(a=>a.map(u=>u.id===t.id?{...u,uploadProgress:o.progress}:u))}});c(o=>{const a=o.map(u=>u.id===t.id?{...u,uploaded:r,uploadProgress:100,error:null}:u);return queueMicrotask(()=>x(a)),a})}catch{c(o=>o.map(a=>a.id===t.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 t=Array.from(e.target.files||[]);t.length>0&&U(t),v.current&&(v.current.value="")},J=y(e=>{e.preventDefault(),I(!1);const t=Array.from(e.dataTransfer.files);U(t)},[U]),Q=y(async e=>{const t=n.find(r=>r.id===e);if(t)try{t.uploaded&&await ve(t.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(A,{gap:"tight",children:[p(F,{level:"body",textAlign:"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":T?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:j?"var(--primary)":T?"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:[s("input",{ref:v,type:"file",accept:q,multiple:d,style:{display:"none"},onChange:X}),p(A,{align:"center",justify:"center",children:[s(Z,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),s(F,{as:"p",variant:"muted",level:"small",textAlign:"center",children:i(d?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),n.length>0&&s(A,{gap:"tight",children:n.map((e,t)=>{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:[s(Fe,{type:r,className:"dndev-size-md"}),p(A,{gap:"none",style:{flex:1,minWidth:0},children:[s(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&&s(pe,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),o?s(re,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):s(ue,{variant:ce.GHOST,onClick:()=>Q(e.id),"aria-label":i("file.delete.ariaLabel"),children:s($,{className:"dndev-size-sm"})})]},e.id)})}),M&&s(F,{level:"caption",variant:T?"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 s,jsxs as p}from"react/jsx-runtime";import{Upload as Z,X as $,File as ee,Loader2 as re,FileText as z,FileSpreadsheet as te,FileImage as se,FileVideo as oe,FileAudio as ae,FileArchive as ne,FileCode as le}from"lucide-react";import{useCallback as y,useState as _,useRef as b,useEffect as B,useImperativeHandle as ie,forwardRef as de}from"react";import{Button as ue,BUTTON_VARIANT as ce,Text as F,Stack as A,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 O}from"../../../stores/UploadStore";import{uploadFile as me,deleteFile as ve,generateFileId as H,getFileIcon as he,formatFileSize as ye}from"../../../utils/fileStorage";function Fe({type:f,className:l}){switch(f){case"pdf":return s(z,{className:l,style:{color:"var(--destructive)"}});case"doc":return s(z,{className:l,style:{color:"var(--primary)"}});case"xls":return s(te,{className:l,style:{color:"var(--success)"}});case"ppt":return s(z,{className:l,style:{color:"var(--warning)"}});case"image":return s(se,{className:l});case"video":return s(oe,{className:l});case"audio":return s(ae,{className:l});case"archive":return s(ne,{className:l});case"html":case"text":return s(le,{className:l});default:return s(ee,{className:l})}}const V=de(({name:f,label:l,value:g,onChange:P,error:T,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]=_([]),[j,I]=_(!1),v=b(null),S=b(!1),w=b(void 0),x=y(e=>{const t=e.filter(r=>r.uploaded&&!r.error).map(r=>r.uploaded);P(d?t:t[0]||null)},[d,P]);B(()=>{if(S.current){S.current=!1;return}if(g){const e=[];(Array.isArray(g)?g:[g]).forEach(r=>{r.url&&e.push({id:H(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),c(e)}else c([])},[g]);const W=y(async()=>{const e=n.filter(t=>!t.uploaded&&!t.error&&t.uploadProgress===null);if(e.length!==0){c(t=>t.map(r=>e.some(o=>o.id===r.id)?{...r,uploadProgress:0}:r));for(const t of e)try{const r=await me(t.file,{storagePath:R,onProgress:o=>{c(a=>a.map(u=>u.id===t.id?{...u,uploadProgress:o.progress}:u))}});c(o=>{const a=o.map(u=>u.id===t.id?{...u,uploaded:r,uploadProgress:100,error:null}:u);return queueMicrotask(()=>x(a)),a})}catch{c(o=>o.map(a=>a.id===t.id?{...a,error:"Upload failed",uploadProgress:null}:a))}}},[n,R,x]);w.current=W,B(()=>{if(!(!m||!f))return O.getState().registerUpload(m,f,async(e,t)=>{await w.current?.()}),()=>{O.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:H(),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 t=Array.from(e.target.files||[]);t.length>0&&U(t),v.current&&(v.current.value="")},J=y(e=>{e.preventDefault(),I(!1);const t=Array.from(e.dataTransfer.files);U(t)},[U]),Q=y(async e=>{const t=n.find(r=>r.id===e);if(t)try{t.uploaded&&await ve(t.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(A,{gap:"tight",children:[p(F,{level:"body",textAlign:"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":T?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:j?"var(--primary)":T?"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:[s("input",{ref:v,type:"file",accept:q,multiple:d,style:{display:"none"},onChange:X}),p(A,{align:"center",justify:"center",children:[s(Z,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),s(F,{as:"p",variant:"muted",level:"small",textAlign:"center",children:i(d?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),n.length>0&&s(A,{gap:"tight",children:n.map((e,t)=>{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:[s(Fe,{type:r,className:"dndev-size-md"}),p(A,{gap:"none",style:{flex:1,minWidth:0},children:[s(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&&s(pe,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),o?s(re,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):s(ue,{variant:ce.GHOST,onClick:()=>Q(e.id),"aria-label":i("file.delete.ariaLabel"),children:s($,{className:"dndev-size-sm"})})]},e.id)})}),M&&s(F,{level:"caption",variant:T?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]})});V.displayName="FileFieldComponent";var Ue=V;export{Ue as default};
@@ -1 +1 @@
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
+ {"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;AA+LD;;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 T,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 j,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(j,{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(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(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(T(Z,{activationConstraint:{distance:8}}),T(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:A}=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&&A(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",textAlign:"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:A,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 Te=z;export{Te as default};
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 T,useSensors as re}from"@dnd-kit/core";import{SortableContext as te,useSortable as oe,rectSortingStrategy as ne,arrayMove as ae}from"@dnd-kit/sortable";import{CSS as ie}from"@dnd-kit/utilities";import{Upload as se,X as j,Loader2 as le,GripVertical as de}from"lucide-react";import{forwardRef as ce,useCallback as E,useImperativeHandle as pe,useRef as ue,useState as L}from"react";import{Text as h,Stack as C,Progress as ge,handleImageError as me}from"@donotdev/components";import{useTranslation as he}from"@donotdev/core";import{useFileUpload as ve}from"../../../hooks/useFileUpload";import{processImage as fe}from"../../../utils/imageProcessing";import{uploadImage as be}from"../../../utils/imageStorage";import{ImageViewerDialog as ye}from"../internal/ImageViewerDialog";const we=["image/*"];function xe(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function Ie({file:t,index: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,i={transform:ie.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:i,...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(j,{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,onError:me,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(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(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}=he("crud"),i=ue(null),[V,c]=L(!1),[_,P]=L(0),M=re(T(Z,{activationConstraint:{distance:8}}),T(ee,{activationConstraint:{delay:200,tolerance:5}})),N=E(async(e,o)=>{const{fullBlob:m,thumbBlob:x}=await fe(e);return be(m,x,e.name,{storagePath:g,onProgress:I=>o(I.progress)})},[g]),{files:a,addFiles:F,removeFile:A}=ve({name:t,value:f,onChange:d,multiple:n,maxFiles:D,maxSize:S,accept:we,storagePath:g,uploadFn:N}),O=e=>{const o=Array.from(e.target.files||[]);o.length>0&&F(o),i.current&&(i.current.value="")},B=E(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&F(Array.from(e.dataTransfer.files))},[F]),G=E(e=>{const{active:o,over:m}=e;if(m&&o.id!==m.id){const x=a.findIndex(k=>k.id===o.id),I=a.findIndex(k=>k.id===m.id);if(x!==-1&&I!==-1){const U=ae(a,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)}}},[a,n,d]),H=e=>{P(e),c(!0)},K=(e,o)=>{},W=e=>{const o=a[e];o&&A(o.id)},X=e=>{P(e)},Y=n||a.length===0;pe(w,()=>({upload:async()=>{},focus:()=>i.current?.focus()}),[]);const $=a.map(xe);return l(C,{gap:"tight",children:[l(h,{level:"body",textAlign:"start",children:[v,R&&"*"]}),Y&&l("div",{role:"button",tabIndex:0,onClick:()=>i.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&i.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:i,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"})})]})]}),a.length>0&&r(J,{sensors:M,collisionDetection:Q,onDragEnd:G,children:r(te,{items:a.map(e=>e.id),strategy:ne,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:a.map((e,o)=>r(Ie,{file:e,index:o,multiple:n,onImageClick:H,onRemove:A,t:s},e.id))})})}),u&&r(h,{variant:b?"destructive":"muted",level:"small",children:u}),r(ye,{images:$,selectedIndex:_,open:V,onClose:()=>c(!1),onUpdate:K,onDelete:W,onNavigate:X,multiple:n})]})});z.displayName="ImageFieldComponent";var je=z;export{je as default};
@@ -1,5 +1,5 @@
1
1
  import { Input } from '@donotdev/components';
2
- import type { ChangeEvent, ComponentProps, ComponentType } from 'react';
2
+ import type { ChangeEvent, ComponentProps } from 'react';
3
3
  export interface TextFieldComponentProps extends Omit<ComponentProps<typeof Input>, 'value' | 'onChange'> {
4
4
  /** Field label */
5
5
  label: string;
@@ -46,6 +46,6 @@ export interface TextFieldComponentProps extends Omit<ComponentProps<typeof Inpu
46
46
  * @param props - TextFieldComponentProps
47
47
  * @returns JSX.Element
48
48
  */
49
- declare const TextFieldComponent: ComponentType<TextFieldComponentProps>;
49
+ declare function TextFieldComponent({ label, value, onChange, error, helperText, type, loading, maxLength, showCharCount, required, disabled, className, ref, ...props }: TextFieldComponentProps): import("react/jsx-runtime").JSX.Element;
50
50
  export default TextFieldComponent;
51
51
  //# sourceMappingURL=TextFieldComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TextFieldComponent.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,EAA6B,MAAM,sBAAsB,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExE,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CACnD,cAAc,CAAC,OAAO,KAAK,CAAC,EAC5B,OAAO,GAAG,UAAU,CACrB;IACC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CACR,KAAK,EAAE,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,KACvD,IAAI,CAAC;IACV,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CAkG9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"TextFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TextFieldComponent.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,EAA6B,MAAM,sBAAsB,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CACnD,cAAc,CAAC,OAAO,KAAK,CAAC,EAC5B,OAAO,GAAG,UAAU,CACrB;IACC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CACR,KAAK,EAAE,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,KACvD,IAAI,CAAC;IACV,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,KAAU,EACV,QAAQ,EACR,KAAK,EACL,UAAU,EACV,IAAa,EACb,OAAe,EACf,SAAS,EACT,aAAqB,EACrB,QAAgB,EAChB,QAAgB,EAChB,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,uBAAuB,2CAwFzB;AAED,eAAe,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{useId as j}from"react";import{Input as x,cn as c,Stack as u}from"@donotdev/components";const _=({label:f,value:d="",onChange:v,error:a,helperText:t,type:p="text",loading:g=!1,maxLength:r,showCharCount:l=!1,required:h=!1,disabled:m=!1,className:z,...$})=>{const e=j(),i=!!a,n=d.length,b=r&&n>r*.8,y=r&&n>r,{children:w,...S}=$;return s(u,{gap:"tight",children:[o(x,{id:e,type:p,value:d,onChange:v,label:f,disabled:m||g,maxLength:r,required:h,"aria-describedby":c(i&&`${e}-error`,t&&!i&&`${e}-helper`,l&&`${e}-count`),"aria-invalid":i,className:c("dndev-w-full",z),"data-variant":i?"destructive":void 0,...S}),l&&r&&s("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:y?"var(--destructive-foreground)":b?"var(--warning)":"var(--muted-foreground)"},children:[n,"/",r]}),i&&s(u,{id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),a]}),t&&!i&&o("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]})};var C=_;export{C as default};
1
+ "use client";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{useId as x}from"react";import{Input as _,cn as c,Stack as f}from"@donotdev/components";function w({label:u,value:d="",onChange:v,error:a,helperText:t,type:p="text",loading:g=!1,maxLength:r,showCharCount:l=!1,required:h=!1,disabled:m=!1,className:z,ref:$,...b}){const e=x(),i=!!a,n=d.length,y=r&&n>r*.8,S=r&&n>r,{children:A,...j}=b;return s(f,{gap:"tight",children:[o(_,{ref:$,id:e,type:p,value:d,onChange:v,label:u,disabled:m||g,maxLength:r,required:h,"aria-describedby":c(i&&`${e}-error`,t&&!i&&`${e}-helper`,l&&`${e}-count`),"aria-invalid":i,className:c("dndev-w-full",z),"data-variant":i?"destructive":void 0,...j}),l&&r&&s("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:S?"var(--destructive-foreground)":y?"var(--warning)":"var(--muted-foreground)"},children:[n,"/",r]}),i&&s(f,{id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),a]}),t&&!i&&o("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]})}var E=w;export{E as default};
@@ -6,8 +6,8 @@ export interface TimestampFieldComponentProps {
6
6
  value?: Date | null;
7
7
  /** Change handler - accepts both event and direct value */
8
8
  onChange: (date: Date | null | ChangeEvent<HTMLInputElement>) => void;
9
- /** Error state */
10
- error?: boolean;
9
+ /** Error message */
10
+ error?: string;
11
11
  /** Helper text */
12
12
  helperText?: string;
13
13
  /** Mode for underlying date field (defaults to "datetime-local") */
@@ -1 +1 @@
1
- {"version":3,"file":"TimestampFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TimestampFieldComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,4BAA4B;IAC3C,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtE,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,uBAAuB,EAAE,aAAa,CAAC,4BAA4B,CAuCxE,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"TimestampFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TimestampFieldComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,4BAA4B;IAC3C,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtE,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,uBAAuB,EAAE,aAAa,CAAC,4BAA4B,CAuCxE,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
+ /** Props for the {@link UploadProvider} component. */
2
3
  export interface UploadProviderProps {
3
4
  formId: string | undefined;
4
5
  children: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"UploadContext.d.ts","sourceRoot":"","sources":["../../src/contexts/UploadContext.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAIvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD"}
1
+ {"version":3,"file":"UploadContext.d.ts","sourceRoot":"","sources":["../../src/contexts/UploadContext.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAIvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD"}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldTypeRegistry.store.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.store.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAW3D;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAAK,IAAI,GACrD,IAAI,CAEN;AAED,wBAAgB,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAOpE;AAID,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GACX,iBAAiB,GAAG,SAAS,CAE/B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAIlE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,SAAS,CAI9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEhE;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
1
+ {"version":3,"file":"fieldTypeRegistry.store.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.store.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAiB3D;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAAK,IAAI,GACrD,IAAI,CAEN;AAED,wBAAgB,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAOpE;AAID,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GACX,iBAAiB,GAAG,SAAS,CAE/B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAIlE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,SAAS,CAI9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEhE;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -1 +1 @@
1
- "use client";import{getFieldRegistry as n}from"./FieldRegistry";var i=null,a=!1,l=null;function o(e){l=e}function t(){return i||(i=new Map),a||(a=!0,l?.(i)),i}function s(e){return t().get(e)}function g(e){const r=n().getFilterType(e);return r||t().get(e)?.filterType}function f(e){const r=n().getDisplayFormatter(e);return r||t().get(e)?.displayFormatter}function p(e){return n().isFilterable(e)?!0:t().get(e)?.filterable??!1}function c(e){return t().get(e)?.valueType}function y(){t().clear()}export{y as clearFieldTypeRegistry,f as getDisplayFormatter,s as getFieldTypeMetadata,g as getFilterType,t as getMetadataRegistry,c as getValueType,p as isFilterable,o as setRegistrationInit};
1
+ "use client";import{getGlobalSingleton as o}from"@donotdev/core";import{getFieldRegistry as i}from"./FieldRegistry";function n(){return o("field-type-metadata",()=>({registry:new Map,builtinsRegistered:!1,initFn:null}))}function a(t){n().initFn=t}function e(){const t=n();return t.builtinsRegistered||(t.builtinsRegistered=!0,t.initFn?.(t.registry)),t.registry}function s(t){return e().get(t)}function g(t){const r=i().getFilterType(t);return r||e().get(t)?.filterType}function f(t){const r=i().getDisplayFormatter(t);return r||e().get(t)?.displayFormatter}function p(t){return i().isFilterable(t)?!0:e().get(t)?.filterable??!1}function c(t){return e().get(t)?.valueType}function y(){e().clear()}export{y as clearFieldTypeRegistry,f as getDisplayFormatter,s as getFieldTypeMetadata,g as getFilterType,e as getMetadataRegistry,c as getValueType,p as isFilterable,a as setRegistrationInit};
@@ -21,6 +21,10 @@ export type DisplayFormatterOptions = {
21
21
  asString?: boolean;
22
22
  /** Pre-resolved reference data: { collectionName: { id: displayLabel } } */
23
23
  referenceData?: Record<string, Record<string, string>>;
24
+ /** BCP 47 locale tag for date/number formatting (e.g. 'fr', 'ko'). Auto-resolved from i18n when omitted. */
25
+ locale?: string;
26
+ /** Full item record — enables cross-field conditional display via `displayValue` resolver */
27
+ item?: Record<string, unknown>;
24
28
  };
25
29
  export type DisplayFormatter = (value: any, config: EntityField, t: (key: string, options?: Record<string, any>) => string, options?: DisplayFormatterOptions) => string | ReactElement;
26
30
  /**