@donotdev/crud 0.0.31 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/LICENSE.md +3 -3
  2. package/dist/CrudService.d.ts +4 -4
  3. package/dist/CrudService.js +2 -2
  4. package/dist/CrudStore.d.ts +1 -1
  5. package/dist/CrudStore.js +1 -1
  6. package/dist/FieldRegistry.d.ts +1 -1
  7. package/dist/FieldRegistry.d.ts.map +1 -1
  8. package/dist/FieldRegistry.js +1 -1
  9. package/dist/adapters/FunctionsAdapter.d.ts +3 -3
  10. package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
  11. package/dist/adapters/FunctionsAdapter.js +1 -1
  12. package/dist/adapters/index.d.ts +1 -1
  13. package/dist/builtinFieldTypes.d.ts +1 -1
  14. package/dist/components/CrudButton.js +1 -1
  15. package/dist/components/DateFilter.js +1 -1
  16. package/dist/components/DisplayFieldRenderer.d.ts +1 -1
  17. package/dist/components/DisplayFieldRenderer.js +1 -1
  18. package/dist/components/DisplayThumbnail.d.ts +1 -1
  19. package/dist/components/DisplayThumbnail.js +1 -1
  20. package/dist/components/EntityFilters.js +1 -1
  21. package/dist/components/FormFieldRenderer.js +1 -1
  22. package/dist/components/FormLayout.d.ts +1 -1
  23. package/dist/components/FormLayout.js +1 -1
  24. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  25. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  26. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
  27. package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
  28. package/dist/components/controlled/complex/ControlledMapField.js +1 -1
  29. package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
  30. package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
  31. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  32. package/dist/components/controlled/complex/index.js +1 -1
  33. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  34. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  35. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  36. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  37. package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
  38. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  39. package/dist/components/controlled/file/index.js +1 -1
  40. package/dist/components/controlled/index.js +1 -1
  41. package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
  42. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  43. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  44. package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
  45. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  46. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  47. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  48. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  49. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  50. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  51. package/dist/components/controlled/input/ControlledSwitchField.js +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/input/index.js +1 -1
  55. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  56. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  57. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  58. package/dist/components/controlled/select/ControlledRadioField.js +1 -1
  59. package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
  60. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  61. package/dist/components/controlled/select/index.js +1 -1
  62. package/dist/components/controlled/types.js +1 -1
  63. package/dist/components/fields/display/AvatarFieldDisplay.d.ts +1 -1
  64. package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
  65. package/dist/components/fields/display/BadgeFieldDisplay.d.ts +1 -1
  66. package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
  67. package/dist/components/fields/display/ButtonFieldDisplay.d.ts +2 -2
  68. package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
  69. package/dist/components/fields/display/CheckboxFieldDisplay.d.ts +1 -1
  70. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  71. package/dist/components/fields/display/DateFieldDisplay.d.ts +1 -1
  72. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  73. package/dist/components/fields/display/DropdownDisplay.d.ts +1 -1
  74. package/dist/components/fields/display/DropdownDisplay.js +1 -1
  75. package/dist/components/fields/display/FileFieldDisplay.d.ts +1 -1
  76. package/dist/components/fields/display/FileFieldDisplay.js +1 -1
  77. package/dist/components/fields/display/GeoPointFieldDisplay.d.ts +1 -1
  78. package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
  79. package/dist/components/fields/display/HiddenFieldDisplay.d.ts +2 -2
  80. package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
  81. package/dist/components/fields/display/ImageFieldDisplay.d.ts +1 -1
  82. package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
  83. package/dist/components/fields/display/LinkFieldDisplay.d.ts +1 -1
  84. package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
  85. package/dist/components/fields/display/MapFieldDisplay.d.ts +1 -1
  86. package/dist/components/fields/display/MapFieldDisplay.js +1 -1
  87. package/dist/components/fields/display/MultiDropdownDisplay.d.ts +1 -1
  88. package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
  89. package/dist/components/fields/display/MultiInputTextFieldDisplay.d.ts +1 -1
  90. package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
  91. package/dist/components/fields/display/NumberFieldDisplay.d.ts +1 -1
  92. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  93. package/dist/components/fields/display/PasswordFieldDisplay.d.ts +1 -1
  94. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  95. package/dist/components/fields/display/PhoneNumberDisplay.d.ts +1 -1
  96. package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
  97. package/dist/components/fields/display/RadioFieldDisplay.d.ts +1 -1
  98. package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
  99. package/dist/components/fields/display/RangeFieldDisplay.d.ts +1 -1
  100. package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
  101. package/dist/components/fields/display/ReferenceFieldDisplay.d.ts +1 -1
  102. package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
  103. package/dist/components/fields/display/RichTextDisplay.d.ts +1 -1
  104. package/dist/components/fields/display/RichTextDisplay.js +2 -2
  105. package/dist/components/fields/display/TextAreaDisplay.d.ts +1 -1
  106. package/dist/components/fields/display/TextAreaDisplay.js +1 -1
  107. package/dist/components/fields/display/TextFieldDisplay.d.ts +1 -1
  108. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  109. package/dist/components/fields/display/TimestampFieldDisplay.d.ts +1 -1
  110. package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
  111. package/dist/components/fields/display/index.d.ts +1 -1
  112. package/dist/components/fields/display/index.js +1 -1
  113. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  114. package/dist/components/form/fields/AvatarFieldComponent.d.ts +2 -2
  115. package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
  116. package/dist/components/form/fields/BadgeFieldComponent.d.ts +2 -2
  117. package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
  118. package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
  119. package/dist/components/form/fields/CheckboxFieldComponent.d.ts +1 -1
  120. package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
  121. package/dist/components/form/fields/ComboboxComponent.d.ts +1 -1
  122. package/dist/components/form/fields/ComboboxComponent.js +1 -1
  123. package/dist/components/form/fields/CurrencyFieldComponent.d.ts +1 -1
  124. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  125. package/dist/components/form/fields/DateFieldComponent.d.ts +1 -1
  126. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  127. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  128. package/dist/components/form/fields/DropdownComponent.d.ts +1 -1
  129. package/dist/components/form/fields/DropdownComponent.js +1 -1
  130. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  131. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  132. package/dist/components/form/fields/GdprConsentFieldComponent.d.ts +1 -1
  133. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  134. package/dist/components/form/fields/GeoPointFieldComponent.d.ts +1 -1
  135. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  136. package/dist/components/form/fields/HiddenFieldComponent.d.ts +1 -1
  137. package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
  138. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  139. package/dist/components/form/fields/MapFieldComponent.js +1 -1
  140. package/dist/components/form/fields/MultiDropdownComponent.d.ts +1 -1
  141. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  142. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  143. package/dist/components/form/fields/NumberFieldComponent.d.ts +1 -1
  144. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  145. package/dist/components/form/fields/PasswordFieldComponent.d.ts +1 -1
  146. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  147. package/dist/components/form/fields/PhoneNumberComponent.d.ts +1 -1
  148. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  149. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  150. package/dist/components/form/fields/RadioFieldComponent.js +1 -1
  151. package/dist/components/form/fields/RangeFieldComponent.d.ts +1 -1
  152. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  153. package/dist/components/form/fields/RatingFieldComponent.d.ts +1 -1
  154. package/dist/components/form/fields/RatingFieldComponent.js +1 -1
  155. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  156. package/dist/components/form/fields/RichTextComponent.d.ts +1 -1
  157. package/dist/components/form/fields/RichTextComponent.js +1 -1
  158. package/dist/components/form/fields/SwitchFieldComponent.d.ts +1 -1
  159. package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
  160. package/dist/components/form/fields/TextAreaComponent.d.ts +1 -1
  161. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  162. package/dist/components/form/fields/TextFieldComponent.d.ts +2 -2
  163. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  164. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  165. package/dist/components/form/fields/index.d.ts +1 -1
  166. package/dist/components/form/fields/index.js +1 -1
  167. package/dist/components/form/fields/internal/TiptapEditor.d.ts +1 -1
  168. package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
  169. package/dist/components/form/fields/types.d.ts +1 -1
  170. package/dist/components/form/index.d.ts +1 -1
  171. package/dist/components/form/internal/ImageViewerDialog.js +1 -1
  172. package/dist/components/index.d.ts +1 -1
  173. package/dist/components/index.js +1 -1
  174. package/dist/contexts/UploadContext.js +1 -1
  175. package/dist/contexts/index.js +1 -1
  176. package/dist/fieldTypeRegistry.d.ts.map +1 -1
  177. package/dist/fieldTypeRegistry.js +1 -1
  178. package/dist/fieldTypeRegistry.store.js +1 -1
  179. package/dist/fieldTypeRegistry.types.d.ts.map +1 -1
  180. package/dist/forms/hooks/index.d.ts +1 -1
  181. package/dist/forms/hooks/index.js +1 -1
  182. package/dist/forms/hooks/useController.js +1 -1
  183. package/dist/forms/hooks/useEntityField.d.ts +1 -1
  184. package/dist/forms/hooks/useEntityField.js +1 -1
  185. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  186. package/dist/forms/hooks/useEntityForm.js +1 -1
  187. package/dist/forms/index.d.ts +1 -1
  188. package/dist/forms/index.js +1 -1
  189. package/dist/forms/types.d.ts +7 -7
  190. package/dist/forms/utils/buildInitialValues.js +1 -1
  191. package/dist/forms/utils/getFieldsForOperation.d.ts +2 -2
  192. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  193. package/dist/forms/utils/index.d.ts +1 -1
  194. package/dist/forms/utils/index.js +1 -1
  195. package/dist/forms/utils/isFieldEditable.d.ts +1 -1
  196. package/dist/forms/utils/isFieldEditable.js +1 -1
  197. package/dist/forms/utils/translateFieldLabel.d.ts +3 -3
  198. package/dist/forms/utils/translateFieldLabel.js +1 -1
  199. package/dist/forms/utils/validateEntity.d.ts +1 -1
  200. package/dist/forms/utils/validateEntity.js +1 -1
  201. package/dist/hooks/index.js +1 -1
  202. package/dist/hooks/useCrudFilters.js +1 -1
  203. package/dist/hooks/useEntityFavorites.js +1 -1
  204. package/dist/hooks/useFieldConditions.js +1 -1
  205. package/dist/hooks/useFileUpload.js +1 -1
  206. package/dist/hooks/useReferenceResolver.js +1 -1
  207. package/dist/hooks/useRelatedItems.js +1 -1
  208. package/dist/hooks/useUnsavedChangesWarning.js +1 -1
  209. package/dist/index.d.ts +1 -1
  210. package/dist/index.js +1 -1
  211. package/dist/registerBuiltinFieldTypes.js +1 -1
  212. package/dist/stores/FormStore.js +1 -1
  213. package/dist/stores/UploadStore.js +1 -1
  214. package/dist/stores/index.d.ts +1 -1
  215. package/dist/stores/index.js +1 -1
  216. package/dist/tsconfig.tsbuildinfo +1 -1
  217. package/dist/types.d.ts +4 -4
  218. package/dist/types.js +1 -1
  219. package/dist/useBaseCrudList.js +1 -1
  220. package/dist/useCrud.js +1 -1
  221. package/dist/useCrudCardList.js +1 -1
  222. package/dist/useCrudList.js +1 -1
  223. package/dist/utils/clientListProcessing.d.ts +1 -1
  224. package/dist/utils/clientListProcessing.js +1 -1
  225. package/dist/utils/collections.d.ts +6 -6
  226. package/dist/utils/collections.js +1 -1
  227. package/dist/utils/fileStorage.js +1 -1
  228. package/dist/utils/imageProcessing.d.ts +1 -1
  229. package/dist/utils/imageProcessing.js +1 -1
  230. package/dist/utils/imageStorage.js +1 -1
  231. package/dist/utils/imageUtils.d.ts +1 -1
  232. package/dist/utils/imageUtils.js +1 -1
  233. package/dist/utils/matchesFilter.d.ts.map +1 -1
  234. package/dist/utils/matchesFilter.js +1 -1
  235. package/dist/utils/mergeWithOptimistic.js +1 -1
  236. package/dist/utils/sanitizeHtml.d.ts +0 -5
  237. package/dist/utils/sanitizeHtml.d.ts.map +1 -1
  238. package/dist/utils/sanitizeHtml.js +1 -1
  239. package/dist/utils/scopeUtils.js +1 -1
  240. package/dist/utils/uploadValidation.d.ts +1 -1
  241. package/dist/utils/uploadValidation.js +1 -1
  242. package/dist/workflows/WorkflowPersistence.d.ts +1 -1
  243. package/dist/workflows/WorkflowPersistence.js +1 -1
  244. package/dist/workflows/defineWorkflow.d.ts +1 -1
  245. package/dist/workflows/index.d.ts +1 -1
  246. package/dist/workflows/index.js +1 -1
  247. package/dist/workflows/useEntityWorkflow.js +1 -1
  248. package/package.json +3 -3
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{Badge as r,BADGE_VARIANT as t,Text as l}from"@donotdev/components";const i=({config:c,value:a,t:d,className:s})=>a?e(r,{variant:t.OUTLINE,className:s,children:a}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var o=i;export{i as RadioFieldDisplay,o as default};
1
+ import{jsx as a}from"react/jsx-runtime";import{Badge as e,BADGE_VARIANT as i,Text as n}from"@donotdev/components";const o=({config:s,value:r,t:d,className:t})=>r?a(e,{variant:i.OUTLINE,className:t,children:r}):a(n,{as:"span",variant:"muted",className:t,children:"-"});var c=o;export{o as RadioFieldDisplay,c as default};
@@ -13,7 +13,7 @@ export interface RangeFieldDisplayProps {
13
13
  /**
14
14
  * RangeFieldDisplay - Displays range values in read-only mode
15
15
  *
16
- * @version 0.0.1
16
+ * @version 0.1.0
17
17
  * @since 0.0.1
18
18
  * @author AMBROISE PARK Consulting
19
19
  */
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const n=({config:t,value:a,t:m,className:s})=>a==null?e(l,{as:"span",variant:"muted",className:s,children:"-"}):e(l,{as:"span",className:`font-mono ${s||""}`,children:a});var o=n;export{n as RangeFieldDisplay,o as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";const o=({config:s,value:n,t:a,className:r})=>n==null?t(e,{as:"span",variant:"muted",className:r,children:"-"}):t(e,{as:"span",className:`font-mono ${r||""}`,children:n});var f=o;export{o as RangeFieldDisplay,f as default};
@@ -13,7 +13,7 @@ export interface ReferenceFieldDisplayProps {
13
13
  /**
14
14
  * ReferenceFieldDisplay - Displays reference values as badges
15
15
  *
16
- * @version 0.0.1
16
+ * @version 0.1.0
17
17
  * @since 0.0.1
18
18
  * @author AMBROISE PARK Consulting
19
19
  */
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{Badge as i,BADGE_VARIANT as n,Text as l}from"@donotdev/components";const r=({config:c,value:a,t:d,className:e})=>{if(!a)return s(l,{as:"span",variant:"muted",className:e,children:"-"});const t=a.displayName||a.name||a.id||a;return s(i,{variant:n.OUTLINE,className:e,children:String(t)})};var m=r;export{r as ReferenceFieldDisplay,m as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{Badge as a,BADGE_VARIANT as n,Text as s}from"@donotdev/components";const d=({config:o,value:r,t:m,className:e})=>{if(!r)return t(s,{as:"span",variant:"muted",className:e,children:"-"});const i=r.displayName||r.name||r.id||r;return t(a,{variant:n.OUTLINE,className:e,children:String(i)})};var f=d;export{d as ReferenceFieldDisplay,f as default};
@@ -16,7 +16,7 @@ export interface RichTextDisplayProps {
16
16
  * Renders HTML with styling that matches Tiptap editor output.
17
17
  * Safe to use with HTML from Tiptap (sanitized by Tiptap).
18
18
  *
19
- * @version 0.0.1
19
+ * @version 0.1.0
20
20
  * @since 0.0.1
21
21
  * @author AMBROISE PARK Consulting
22
22
  */
@@ -1,4 +1,4 @@
1
- import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Text as s}from"@donotdev/components";import{sanitizeHtml as t}from"../../../utils/sanitizeHtml";const a=({config:m,value:e,t:l,className:o})=>!e||e.trim()===""?r(s,{as:"span",variant:"muted",className:o,children:"-"}):i("div",{className:o,style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",borderRadius:"var(--radius-md)",border:"1px solid var(--border)",minHeight:"38px"},children:[r("div",{dangerouslySetInnerHTML:{__html:t(e)},style:{outline:"none",fontSize:"var(--font-size-base)",lineHeight:"1.6"},className:"prose prose-sm max-w-none"}),r("style",{children:`
1
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Text as t}from"@donotdev/components";import{sanitizeHtml as s}from"../../../utils/sanitizeHtml";const a=({config:n,value:r,t:m,className:o})=>!r||r.trim()===""?e(t,{as:"span",variant:"muted",className:o,children:"-"}):i("div",{className:o,style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",borderRadius:"var(--radius-md)",border:"1px solid var(--border)",minHeight:"38px"},children:[e("div",{dangerouslySetInnerHTML:{__html:s(r)},style:{outline:"none",fontSize:"var(--font-size-base)",lineHeight:"1.6"},className:"prose prose-sm max-w-none"}),e("style",{children:`
2
2
  /* Match Tiptap ProseMirror styling */
3
3
  .prose p {
4
4
  margin: 0.5em 0;
@@ -58,4 +58,4 @@ import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Text as s}from"@donotde
58
58
  .prose a:hover {
59
59
  color: var(--primary-hover);
60
60
  }
61
- `})]});var n=a;export{a as RichTextDisplay,n as default};
61
+ `})]});var f=a;export{a as RichTextDisplay,f as default};
@@ -13,7 +13,7 @@ export interface TextAreaDisplayProps {
13
13
  /**
14
14
  * TextAreaDisplay - Displays textarea values in read-only mode
15
15
  *
16
- * @version 0.0.1
16
+ * @version 0.1.0
17
17
  * @since 0.0.1
18
18
  * @author AMBROISE PARK Consulting
19
19
  */
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const r=({config:i,value:a,t:m,className:e})=>a?s(l,{as:"div",level:"small",className:`whitespace-pre-wrap ${e||""}`,children:a}):s(l,{as:"span",variant:"muted",className:e,children:"-"});var t=r;export{r as TextAreaDisplay,t as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{Text as a}from"@donotdev/components";const s=({config:i,value:e,t:p,className:r})=>e?t(a,{as:"div",level:"small",className:`whitespace-pre-wrap ${r||""}`,children:e}):t(a,{as:"span",variant:"muted",className:r,children:"-"});var o=s;export{s as TextAreaDisplay,o as default};
@@ -33,7 +33,7 @@ export interface TextFieldDisplayProps {
33
33
  * - Loading states
34
34
  * - Responsive design
35
35
  *
36
- * @version 0.0.1
36
+ * @version 0.1.0
37
37
  * @since 0.0.1
38
38
  * @author AMBROISE PARK Consulting
39
39
  */
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as N,Calendar as L,Clock as k}from"lucide-react";import{useState as A}from"react";import{Skeleton as T,Badge as B,BADGE_VARIANT as E,Text as l,cn as f,CopyToClipboard as x,Stack as i}from"@donotdev/components";import{getWeekFromISOString as I}from"@donotdev/core";const b=({config:o,value:a,t:r,className:s,loading:C=!1,showCopy:u=!1,asBadge:v=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[V,g]=A(!1),j=async()=>{try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(o.type){case"email":return e(N,{});case"month":case"week":return e(L,{});case"time":return e(k,{});default:return null}},w=t=>{if(!t)return null;switch(o.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:m=>m.currentTarget.style.textDecoration="underline",onMouseLeave:m=>m.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long"});case"week":return I(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString();default:return t}},S=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(C)return n(i,{gap:"tight",children:[p&&e(T,{style:{height:"1rem",width:"6rem"}}),e(T,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!a)return n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),e(l,{as:"span",variant:"muted",className:f(s),style:{fontStyle:"italic"},children:r("common.noValue",{defaultValue:"No value"})})]});const D=w(a),y=S(String(D));return v?n(i,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),u&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]}):n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),n(i,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:f("dndev-flex-1",c&&"truncate",s),title:c&&a.length>d?a:void 0,children:e(l,{as:"span",children:y})}),u&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]})]})};var M=b;export{b as TextFieldDisplay,M as default};
1
+ 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};
@@ -13,7 +13,7 @@ export interface TimestampFieldDisplayProps {
13
13
  /**
14
14
  * TimestampFieldDisplay - Displays timestamp values in read-only mode
15
15
  *
16
- * @version 0.0.1
16
+ * @version 0.1.0
17
17
  * @since 0.0.1
18
18
  * @author AMBROISE PARK Consulting
19
19
  */
@@ -1 +1 @@
1
- import{jsx as a,jsxs as c}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";const n=({config:o,value:t,t:d,className:s})=>{if(!t)return a(e,{as:"span",variant:"muted",className:s,children:"-"});try{const r=new Date(t),i=r.toLocaleDateString(),l=r.toLocaleTimeString();return c("div",{className:s,children:[a(e,{as:"span",children:i}),a(e,{as:"span",variant:"muted",level:"small",children:l})]})}catch{return a(e,{as:"span",variant:"muted",className:s,children:"-"})}};var m=n;export{n as TimestampFieldDisplay,m as default};
1
+ 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};
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Display field components
3
3
  * @description Read-only display components for CRUD operations
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -1 +1 @@
1
- import{default as a}from"./TextFieldDisplay";import{default as i}from"./BadgeFieldDisplay";import{default as s}from"./AvatarFieldDisplay";import{default as l}from"./LinkFieldDisplay";import{default as e}from"./DateFieldDisplay";import{default as t}from"./NumberFieldDisplay";import{default as o}from"./PhoneNumberDisplay";import{default as r}from"./TextAreaDisplay";import{default as p}from"./RichTextDisplay";import{default as m}from"./CheckboxFieldDisplay";import{default as d}from"./DropdownDisplay";import{default as f}from"./MultiDropdownDisplay";import{default as u}from"./MultiInputTextFieldDisplay";import{default as D}from"./RadioFieldDisplay";import{default as y}from"./RangeFieldDisplay";import{default as F}from"./FileFieldDisplay";import{default as n}from"./ImageFieldDisplay";import{default as x}from"./GeoPointFieldDisplay";import{default as T}from"./MapFieldDisplay";import{default as R}from"./ReferenceFieldDisplay";import{default as b}from"./TimestampFieldDisplay";import{default as g}from"./HiddenFieldDisplay";import{default as M}from"./ButtonFieldDisplay";export{s as AvatarFieldDisplay,i as BadgeFieldDisplay,M as ButtonFieldDisplay,m as CheckboxFieldDisplay,e as DateFieldDisplay,d as DropdownDisplay,F as FileFieldDisplay,x as GeoPointFieldDisplay,g as HiddenFieldDisplay,n as ImageFieldDisplay,l as LinkFieldDisplay,T as MapFieldDisplay,f as MultiDropdownDisplay,u as MultiInputTextFieldDisplay,t as NumberFieldDisplay,o as PhoneNumberDisplay,D as RadioFieldDisplay,y as RangeFieldDisplay,R as ReferenceFieldDisplay,p as RichTextDisplay,r as TextAreaDisplay,a as TextFieldDisplay,b as TimestampFieldDisplay};
1
+ import{default as l}from"./TextFieldDisplay";import{default as o}from"./BadgeFieldDisplay";import{default as p}from"./AvatarFieldDisplay";import{default as d}from"./LinkFieldDisplay";import{default as s}from"./DateFieldDisplay";import{default as m}from"./NumberFieldDisplay";import{default as D}from"./PhoneNumberDisplay";import{default as F}from"./TextAreaDisplay";import{default as T}from"./RichTextDisplay";import{default as b}from"./CheckboxFieldDisplay";import{default as g}from"./DropdownDisplay";import{default as M}from"./MultiDropdownDisplay";import{default as w}from"./MultiInputTextFieldDisplay";import{default as B}from"./RadioFieldDisplay";import{default as N}from"./RangeFieldDisplay";import{default as v}from"./FileFieldDisplay";import{default as G}from"./ImageFieldDisplay";import{default as L}from"./GeoPointFieldDisplay";import{default as q}from"./MapFieldDisplay";import{default as E}from"./ReferenceFieldDisplay";import{default as K}from"./TimestampFieldDisplay";import{default as Q}from"./HiddenFieldDisplay";import{default as U}from"./ButtonFieldDisplay";export{p as AvatarFieldDisplay,o as BadgeFieldDisplay,U as ButtonFieldDisplay,b as CheckboxFieldDisplay,s as DateFieldDisplay,g as DropdownDisplay,v as FileFieldDisplay,L as GeoPointFieldDisplay,Q as HiddenFieldDisplay,G as ImageFieldDisplay,d as LinkFieldDisplay,q as MapFieldDisplay,M as MultiDropdownDisplay,w as MultiInputTextFieldDisplay,m as NumberFieldDisplay,D as PhoneNumberDisplay,B as RadioFieldDisplay,N as RangeFieldDisplay,E as ReferenceFieldDisplay,T as RichTextDisplay,F as TextAreaDisplay,l as TextFieldDisplay,K as TimestampFieldDisplay};
@@ -1 +1 @@
1
- import{jsx as a,jsxs as m}from"react/jsx-runtime";import{MapPin as U}from"lucide-react";import{useState as y,useEffect as w,useRef as S,useMemo as D}from"react";import{Combobox as L,Stack as M}from"@donotdev/components";import{useTranslation as N,getPlatformEnvVar as W}from"@donotdev/core";const Y=({label:b,value:l,onChange:x,enableGoogleMaps:O=!1,extractDistrictCode:T,error:i,helperText:c,required:P})=>{const{t:o}=N("crud"),[n,u]=y(l?.formatted_address||""),[g,f]=y([]),[E,p]=y(!1),v=S(null),h=S(null),d=S(null),_=W("GOOGLE_MAPS_API_KEY")||"",s=O&&!!_,j=D(()=>g.map(e=>({value:e.place_id,label:e.description,description:e.structured_formatting?.secondary_text,content:m("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[a(U,{style:{width:"var(--size-icon-sm)",height:"var(--size-icon-sm)"}}),m("div",{children:[a("div",{children:e.description}),e.structured_formatting?.secondary_text&&a("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:e.structured_formatting.secondary_text})]})]})})),[g]),q=e=>{h.current&&(p(!0),h.current.getDetails({placeId:e,fields:["formatted_address","geometry","address_components"]},(t,r)=>{if(p(!1),r===window.google?.maps?.places?.PlacesServiceStatus.OK&&t){const I=t.formatted_address||"",K=t.geometry?.location?.lat(),V=t.geometry?.location?.lng(),z={formatted_address:I,latitude:K,longitude:V};if(T&&t.address_components){const A=t.address_components.find(R=>R.types.includes("postal_code"))?.long_name||"",k=A.startsWith("92")?92:parseInt(A.slice(-2),10)||null;z.district_code=k}u(I),x(z)}}))};w(()=>{l?.formatted_address&&u(l.formatted_address)},[l]),w(()=>{if(!s)return;let e=null;const t=()=>{window.google?.maps?.places&&(v.current=new window.google.maps.places.AutocompleteService,h.current=new window.google.maps.places.PlacesService(document.createElement("div")))};return(()=>{if(window.google?.maps?.places){t();return}if(document.querySelector("#google-maps-script")){e=setInterval(()=>{window.google?.maps?.places&&(clearInterval(e),e=null,t())},100);return}const r=document.createElement("script");r.id="google-maps-script",r.src=`https://maps.googleapis.com/maps/api/js?key=${_}&libraries=places`,r.async=!0,r.defer=!0,r.onload=()=>t(),document.head.appendChild(r)})(),()=>{e!==null&&(clearInterval(e),e=null)}},[s,_]),w(()=>{if(!s||!n||!v.current){f([]);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{p(!0),v.current.getPlacePredictions({input:n,types:["geocode","establishment"]},(e,t)=>{p(!1),t===window.google?.maps?.places?.PlacesServiceStatus.OK&&e?f(e):f([])})},300),()=>{d.current&&clearTimeout(d.current)}},[s,n]);const G=e=>{u(e),x({formatted_address:e})},C=e=>{const t=Array.isArray(e)?e[0]||"":e;if(!s){G(t);return}g.some(r=>r.place_id===t)&&q(t)};return s?m(M,{gap:"tight",children:[a(L,{label:b,value:n,onValueChange:C,onSearchChange:e=>{s&&u(e)},placeholder:o("address.placeholder","Enter address..."),emptyMessage:E?o("messages.loading","Loading..."):o("address.noResults","No addresses found"),options:j,required:P,variant:i?"destructive":void 0,isLoading:E,creatable:!0,createLabel:o("actions.use","Use this address")}),c&&a("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)"},children:c})]}):m(M,{gap:"tight",children:[a(L,{label:b,value:n,onValueChange:C,placeholder:o("address.placeholder","Enter address..."),options:[],required:P,variant:i?"destructive":void 0,creatable:!0,createLabel:o("actions.use","Use this address")}),c&&a("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)"},children:c})]})};var F=Y;export{F as default};
1
+ import{jsx as r,jsxs as p}from"react/jsx-runtime";import{MapPin as D}from"lucide-react";import{useState as S,useEffect as w,useRef as b,useMemo as F}from"react";import{Combobox as L,Stack as M}from"@donotdev/components";import{useTranslation as N,getPlatformEnvVar as W}from"@donotdev/core";const Y=({label:C,value:i,onChange:P,enableGoogleMaps:j=!1,extractDistrictCode:O,error:c,helperText:l,required:x})=>{const{t:n}=N("crud"),[a,u]=S(i?.formatted_address||""),[f,g]=S([]),[I,m]=S(!1),v=b(null),h=b(null),d=b(null),_=W("GOOGLE_MAPS_API_KEY")||"",o=j&&!!_,R=F(()=>f.map(e=>({value:e.place_id,label:e.description,description:e.structured_formatting?.secondary_text,content:p("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[r(D,{style:{width:"var(--size-icon-sm)",height:"var(--size-icon-sm)"}}),p("div",{children:[r("div",{children:e.description}),e.structured_formatting?.secondary_text&&r("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:e.structured_formatting.secondary_text})]})]})})),[f]),V=e=>{h.current&&(m(!0),h.current.getDetails({placeId:e,fields:["formatted_address","geometry","address_components"]},(t,y)=>{if(m(!1),y===window.google?.maps?.places?.PlacesServiceStatus.OK&&t){const s=t.formatted_address||"",k=t.geometry?.location?.lat(),q=t.geometry?.location?.lng(),z={formatted_address:s,latitude:k,longitude:q};if(O&&t.address_components){const A=t.address_components.find(U=>U.types.includes("postal_code"))?.long_name||"",T=A.startsWith("92")?92:parseInt(A.slice(-2),10)||null;z.district_code=T}u(s),P(z)}}))};w(()=>{i?.formatted_address&&u(i.formatted_address)},[i]),w(()=>{if(!o)return;let e=null;const t=()=>{window.google?.maps?.places&&(v.current=new window.google.maps.places.AutocompleteService,h.current=new window.google.maps.places.PlacesService(document.createElement("div")))};return(()=>{if(window.google?.maps?.places){t();return}if(document.querySelector("#google-maps-script")){e=setInterval(()=>{window.google?.maps?.places&&(clearInterval(e),e=null,t())},100);return}const s=document.createElement("script");s.id="google-maps-script",s.src=`https://maps.googleapis.com/maps/api/js?key=${_}&libraries=places`,s.async=!0,s.defer=!0,s.onload=()=>t(),document.head.appendChild(s)})(),()=>{e!==null&&(clearInterval(e),e=null)}},[o,_]),w(()=>{if(!o||!a||!v.current){g([]);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{m(!0),v.current.getPlacePredictions({input:a,types:["geocode","establishment"]},(e,t)=>{m(!1),t===window.google?.maps?.places?.PlacesServiceStatus.OK&&e?g(e):g([])})},300),()=>{d.current&&clearTimeout(d.current)}},[o,a]);const K=e=>{u(e),P({formatted_address:e})},E=e=>{const t=Array.isArray(e)?e[0]||"":e;if(!o){K(t);return}f.some(s=>s.place_id===t)&&V(t)},G=e=>{o&&u(e)};return o?p(M,{gap:"tight",children:[r(L,{label:C,value:a,onValueChange:E,onSearchChange:G,placeholder:n("address.placeholder","Enter address..."),emptyMessage:I?n("messages.loading","Loading..."):n("address.noResults","No addresses found"),options:R,required:x,variant:c?"destructive":void 0,isLoading:I,creatable:!0,createLabel:n("actions.use","Use this address")}),l&&r("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)"},children:l})]}):p(M,{gap:"tight",children:[r(L,{label:C,value:a,onValueChange:E,placeholder:n("address.placeholder","Enter address..."),options:[],required:x,variant:c?"destructive":void 0,creatable:!0,createLabel:n("actions.use","Use this address")}),l&&r("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)"},children:l})]})};var Z=Y;export{Z as default};
@@ -2,7 +2,7 @@
2
2
  * @fileoverview AvatarFieldComponent
3
3
  * @description Input field for avatar URLs with preview
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -26,7 +26,7 @@ export interface AvatarFieldComponentProps extends Omit<ComponentProps<typeof In
26
26
  /**
27
27
  * AvatarFieldComponent - Input field for avatar URLs with preview
28
28
  *
29
- * @version 0.0.1
29
+ * @version 0.1.0
30
30
  * @since 0.0.1
31
31
  * @author AMBROISE PARK Consulting
32
32
  */
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as m,Input as u,cn as f,Stack as n}from"@donotdev/components";const s=({config:r,value:t,onChange:c,error:A,helperText:l,t:i,className:d,...h})=>{const v=a=>a.split(" ").map(p=>p.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(m,{src:t,alt:r.label||"Avatar",fallback:v(r.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(u,{type:"url",className:f("dndev-w-full",d),placeholder:i("common.enterAvatarUrl"),value:t,onChange:a=>c(a.target.value),...h})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var g=s;export{s as AvatarFieldComponent,g as default};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as v,Input as h,cn as u,Stack as n}from"@donotdev/components";const f=({config:t,value:a,onChange:s,error:g,helperText:l,t:c,className:i,...d})=>{const m=r=>r.split(" ").map(p=>p.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(v,{src:a,alt:t.label||"Avatar",fallback:m(t.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(h,{type:"url",className:u("dndev-w-full",i),placeholder:c("common.enterAvatarUrl"),value:a,onChange:r=>s(r.target.value),...d})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var j=f;export{f as AvatarFieldComponent,j as default};
@@ -2,7 +2,7 @@
2
2
  * @fileoverview BadgeFieldComponent
3
3
  * @description Input field for badge text with preview
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -28,7 +28,7 @@ export interface BadgeFieldComponentProps extends Omit<ComponentProps<typeof Inp
28
28
  /**
29
29
  * BadgeFieldComponent - Input field for badge text with preview
30
30
  *
31
- * @version 0.0.1
31
+ * @version 0.1.0
32
32
  * @since 0.0.1
33
33
  * @author AMBROISE PARK Consulting
34
34
  */
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Badge as v,Input as f,cn as g,Stack as o}from"@donotdev/components";const l=({config:p,value:a,onChange:d,error:u,helperText:r,t:n,variant:s="default",className:i,...c})=>t(o,{children:[t(o,{direction:"row",align:"center",children:[e(v,{variant:s,style:{minWidth:0},children:a||n("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",i),placeholder:n("common.enterBadgeText"),value:a,onChange:m=>d(m.target.value),...c})})]}),r&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:r})]});var h=l;export{l as BadgeFieldComponent,h as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Badge as m,Input as f,cn as g,Stack as a}from"@donotdev/components";const p=({config:u,value:r,onChange:d,error:v,helperText:n,t:o,variant:i="default",className:l,...c})=>t(a,{children:[t(a,{direction:"row",align:"center",children:[e(m,{variant:i,style:{minWidth:0},children:r||o("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",l),placeholder:o("common.enterBadgeText"),value:r,onChange:s=>d(s.target.value),...c})})]}),n&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:n})]});var j=p;export{p as BadgeFieldComponent,j as default};
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{Button as l}from"@donotdev/components";const n=({label:a,type:t,onClick:r,variant:e,disabled:i=!1})=>o(l,{type:t,onClick:r,variant:e,disabled:i,children:a});var s=n;export{s as default};
1
+ import{jsx as i}from"react/jsx-runtime";import{Button as a}from"@donotdev/components";const l=({label:t,type:o,onClick:e,variant:n,disabled:r=!1})=>i(a,{type:o,onClick:e,variant:n,disabled:r,children:t});var m=l;export{m as default};
@@ -12,7 +12,7 @@ export interface CheckboxFieldComponentProps {
12
12
  /**
13
13
  * CheckboxFieldComponent renders a labeled checkbox.
14
14
  *
15
- * @version 0.0.1
15
+ * @version 0.1.0
16
16
  * @since 0.0.1
17
17
  * @author AMBROISE PARK Consulting
18
18
  * @param props - CheckboxFieldComponentProps
@@ -1 +1 @@
1
- import{jsx as r,jsxs as h}from"react/jsx-runtime";import{Checkbox as i,Label as n,Stack as s}from"@donotdev/components";const d=({label:a,checked:c=!1,onChange:e,required:o})=>h(s,{direction:"row",align:"center",gap:"tight",children:[r(i,{checked:c,onCheckedChange:t=>{e&&e({target:{checked:t}})}}),r(n,{required:o,children:a})]});var l=d;export{l as default};
1
+ import{jsx as r,jsxs as c}from"react/jsx-runtime";import{Checkbox as h,Label as i,Stack as s}from"@donotdev/components";const d=({label:t,checked:n=!1,onChange:e,required:a})=>c(s,{direction:"row",align:"center",gap:"tight",children:[r(h,{checked:n,onCheckedChange:o=>{e&&e({target:{checked:o}})}}),r(i,{required:a,children:t})]});var C=d;export{C as default};
@@ -38,7 +38,7 @@ export interface ComboboxComponentProps {
38
38
  * ComboboxComponent renders a searchable combobox with autocomplete.
39
39
  * Input + Dropdown pattern: user types in input, dropdown appears below.
40
40
  *
41
- * @version 0.0.1
41
+ * @version 0.1.0
42
42
  * @since 0.0.1
43
43
  * @author AMBROISE PARK Consulting
44
44
  * @param props - ComboboxComponentProps
@@ -1 +1 @@
1
- import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useMemo as L,useId as N}from"react";import{Combobox as $,Stack as d}from"@donotdev/components";import{useTranslation as D}from"@donotdev/core";const I=({label:u,value:l,options:s,error:p,helperText:r,onChange:n,onBlur:m,required:g,placeholder:h,translationNamespace:v="dndev",placeholderKey:f="actions.select",placeholderDefault:b="Select",creatable:x=!1,createLabel:y,emptyMessage:C})=>{const{t:a}=D(v),i=N(),z=L(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),S=e=>{if(n){const q={target:{value:Array.isArray(e)?e[0]||"":e}};n(q)}},A=e=>{e||m?.()},t=!!p,M=`${i}-error`,j=`${i}-helper`;return c(d,{gap:"tight",children:[o($,{label:u,value:l||"",onValueChange:S,onOpenChange:A,placeholder:h||a(f,b),emptyMessage:C||a("messages.noResults","No results found"),creatable:x,createLabel:y||a("actions.create","Create"),options:z,required:g,variant:t?"destructive":void 0,clearable:!!l}),t&&c(d,{id:M,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),r]}),r&&!t&&o("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:r})]})};var O=I;export{O as default};
1
+ import{jsx as a,jsxs as c}from"react/jsx-runtime";import{useMemo as E,useId as M}from"react";import{Combobox as V,Stack as d}from"@donotdev/components";import{useTranslation as _}from"@donotdev/core";const $=({label:u,value:n,options:s,error:f,helperText:o,onChange:l,onBlur:m,required:p,placeholder:g,translationNamespace:h="dndev",placeholderKey:b="actions.select",placeholderDefault:v="Select",creatable:x=!1,createLabel:C,emptyMessage:y})=>{const{t:r}=_(h),i=M(),S=E(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),j=e=>{if(l){const O={target:{value:Array.isArray(e)?e[0]||"":e}};l(O)}},z=e=>{e||m?.()},t=!!f,A=`${i}-error`,I=`${i}-helper`;return c(d,{gap:"tight",children:[a(V,{label:u,value:n||"",onValueChange:j,onOpenChange:z,placeholder:g||r(b,v),emptyMessage:y||r("messages.noResults","No results found"),creatable:x,createLabel:C||r("actions.create","Create"),options:S,required:p,variant:t?"destructive":void 0,clearable:!!n}),t&&c(d,{id:A,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),o]}),o&&!t&&a("p",{id:I,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var D=$;export{D as default};
@@ -24,7 +24,7 @@ export interface CurrencyFieldComponentProps {
24
24
  /**
25
25
  * Currency field with locale-aware formatting
26
26
  *
27
- * @version 0.0.1
27
+ * @version 0.1.0
28
28
  * @since 0.0.1
29
29
  * @author AMBROISE PARK Consulting
30
30
  */
@@ -1 +1 @@
1
- import{jsx as t,jsxs as v}from"react/jsx-runtime";import{useState as I,useEffect as S,useId as z}from"react";import{Input as E,FloatingLabel as T,Stack as j}from"@donotdev/components";const C=({label:g,value:n,onChange:m,currency:l="EUR",locale:f,error:o,helperText:s,required:y=!1,disabled:i=!1,placeholder:h})=>{const d=z(),b=f||(typeof navigator<"u"?navigator.language:"en-US"),u=e=>e==null||isNaN(e)?"":(e/100).toFixed(2),x=e=>{if(!e||e.trim()==="")return null;const r=e.replace(/[^\d.,\-]/g,"").replace(",","."),a=parseFloat(r);return isNaN(a)?null:Math.round(a*100)},[F,c]=I(u(n));S(()=>{c(u(n))},[n]);const N=e=>{const r=e.target.value;c(r);const a={target:{value:x(r)}};m(a)},p=(()=>{try{return new Intl.NumberFormat(b,{style:"currency",currency:l,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||l}catch{return l}})();return v(j,{gap:"tight",children:[t(T,{htmlFor:d,label:g,disabled:i,required:y,children:v("div",{style:{position:"relative"},children:[t("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:p}),t(E,{id:d,type:"text",inputMode:"decimal",value:F,onChange:N,disabled:i,placeholder:h||"0.00","data-variant":o?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${p.length*.6}em + var(--gap-sm))`}})]})}),s&&t("p",{style:{fontSize:"var(--font-size-xs)",color:o?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:s})]})};var L=C;export{L as default};
1
+ 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};
@@ -21,7 +21,7 @@ export interface DateFieldComponentProps {
21
21
  /**
22
22
  * DateFieldComponent renders a date (or related) input field
23
23
  *
24
- * @version 0.0.1
24
+ * @version 0.1.0
25
25
  * @since 0.0.1
26
26
  * @author AMBROISE PARK Consulting
27
27
  */
@@ -1 +1 @@
1
- import{jsx as l,jsxs as S}from"react/jsx-runtime";import{Input as m,Stack as p}from"@donotdev/components";const v=({label:n,value:a,onChange:i,error:s,helperText:o,mode:e="date",required:g,...u})=>{const c=t=>{const d=t.target.value?new Date(t.target.value).toISOString():null;i(d)};let r="";if(a){const t=new Date(a);e==="date"?r=t.toISOString().split("T")[0]||"":e==="datetime-local"?r=t.toISOString().slice(0,16)||"":e==="month"?r=t.toISOString().slice(0,7):e==="time"?r=t.toISOString().slice(11,16):e==="week"&&(r=t.toISOString().split("T")[0]||"")}return S(p,{gap:"tight",children:[l(m,{label:n,type:e,value:r,onChange:c,required:g,className:"dndev-w-full",...u}),o&&l("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var f=v;export{f as default};
1
+ 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 +1 @@
1
- "use client";import{jsx as t,jsxs as n,Fragment as le}from"react/jsx-runtime";import{Upload as se,X as oe,FileText as N,FileSpreadsheet as ie,File as ne,Loader2 as de,Eye as ce}from"lucide-react";import{useCallback as y,useState as E,useRef as T,useEffect as j,useImperativeHandle as ue,forwardRef as pe}from"react";import{Button as B,BUTTON_VARIANT as q,Text as g,Stack as x,Progress as me,Dialog as ge,DialogContent as ve,DialogHeader as fe,DialogTitle as he}from"@donotdev/components";import{handleError as P,useTranslation as ye}from"@donotdev/core";import{useUploadContext as xe}from"../../../contexts/UploadContext";import{useUploadStore as G}from"../../../stores/UploadStore";import{uploadFile as we,deleteFile as be,generateFileId as X,getFileIcon as Ne,formatFileSize as Te,getDocumentAcceptString as Pe}from"../../../utils/fileStorage";function De({type:m,className:d}){switch(m){case"pdf":return t(N,{className:d,style:{color:"var(--destructive)"}});case"doc":return t(N,{className:d,style:{color:"var(--primary)"}});case"xls":return t(ie,{className:d,style:{color:"var(--success)"}});case"ppt":return t(N,{className:d,style:{color:"var(--warning)"}});case"text":case"html":return t(N,{className:d});default:return t(ne,{className:d})}}const V=pe(({name:m,label:d,value:v,onChange:L,error:D,helperText:M,multiple:p=!1,maxFiles:k=10,maxSize:C=25*1024*1024,storagePath:O="uploads/documents",required:J,enablePreview:R=!0},K)=>{const{t:Q}=ye("crud"),i=Q,f=xe(),I=!!f,[o,c]=E([]),[U,F]=E(!1),[z,H]=E(null),h=T(null),A=T(!1),w=T(void 0),Y=Pe(),b=y(e=>{const r=e.filter(a=>a.uploaded&&!a.error).map(a=>a.uploaded);L(p?r:r[0]||null)},[p,L]);j(()=>{if(A.current){A.current=!1;return}if(v){const e=[];(Array.isArray(v)?v:[v]).forEach(r=>{r.url&&e.push({id:X(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),c(e)}else c([])},[v]);const Z=y(async()=>{const e=o.filter(r=>!r.uploaded&&!r.error&&r.uploadProgress===null);if(e.length!==0){c(r=>r.map(a=>e.some(l=>l.id===a.id)?{...a,uploadProgress:0}:a));for(const r of e)try{const a=await we(r.file,{storagePath:O,onProgress:l=>{c(u=>u.map(s=>s.id===r.id?{...s,uploadProgress:l.progress}:s))}});c(l=>{const u=l.map(s=>s.id===r.id?{...s,uploaded:a,uploadProgress:100,error:null}:s);return queueMicrotask(()=>b(u)),u})}catch{c(a=>a.map(l=>l.id===r.id?{...l,error:"Upload failed",uploadProgress:null}:l))}}},[o,O,b]);w.current=Z,j(()=>{if(!(!f||!m))return G.getState().registerUpload(f,m,async()=>{await w.current?.()}),()=>{G.getState().unregisterUpload(f,m)}},[f,m]),ue(K,()=>({upload:async()=>{await w.current?.()},getDocuments:()=>W.current||[]}),[]);const W=T(o);W.current=o;const _=e=>{const r=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],a="."+e.name.split(".").pop()?.toLowerCase();return r.includes(a)},S=y(e=>{const r=(p?k:1)-o.length;if(r<=0){P(new Error("Maximum documents reached"),{userMessage:i("document.errors.maxFiles",{max:k}),severity:"warning",showNotification:!0});return}const a=e.slice(0,r),l=[],u=(C/(1024*1024)).toFixed(0);for(const s of a){if(!_(s)){P(new Error("Invalid document type"),{userMessage:i("document.errors.invalidType",{fileName:s.name}),severity:"warning",showNotification:!0});continue}if(s.size>C){P(new Error("Document too large"),{userMessage:i("document.errors.exceedsSize",{fileName:s.name,size:u}),severity:"warning",showNotification:!0});continue}l.push({id:X(),file:s,uploadProgress:null,uploaded:null,error:null})}l.length!==0&&(c(s=>p?[...s,...l]:l),I||setTimeout(()=>w.current?.(),0))},[o,p,k,C,i,I]),$=e=>{const r=Array.from(e.target.files||[]);r.length>0&&S(r),h.current&&(h.current.value="")},ee=y(e=>{e.preventDefault(),F(!1);const r=Array.from(e.dataTransfer.files);S(r)},[S]),re=y(async e=>{const r=o.find(a=>a.id===e);if(r)try{r.uploaded&&await be(r.uploaded);const a=o.filter(l=>l.id!==e);A.current=!0,c(a),setTimeout(()=>b(a),0)}catch(a){P(a,{userMessage:i("document.delete.failed"),severity:"error",showNotification:!0})}},[o,b,i]),ae=e=>{e.uploaded?.url&&e.uploaded.mimeType==="application/pdf"&&H(e.uploaded.url)},te=p||o.length===0;return n(le,{children:[n(x,{gap:"tight",children:[n(g,{level:"body",textAlign:"start",children:[d,J?"*":""]}),te&&n("div",{role:"button",tabIndex:0,"aria-label":i("document.upload.ariaLabel"),className:"dndev-surface","data-variant":D?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:U?"var(--primary)":D?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:U?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),F(!0)},onDragLeave:()=>F(!1),onDrop:ee,onClick:()=>h.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),h.current?.click())},children:[t("input",{ref:h,type:"file",accept:Y,multiple:p,style:{display:"none"},onChange:$}),n(x,{align:"center",justify:"center",children:[t(se,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),t(g,{as:"p",variant:"muted",level:"small",textAlign:"center",children:i("document.upload.hint")}),t(g,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&t(x,{gap:"tight",children:o.map((e,r)=>{const a=Ne(e.uploaded?.mimeType||e.file.type,e.file.name),l=e.uploadProgress!==null&&e.uploadProgress<100,u=e.uploaded?.mimeType==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf");return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[t(De,{type:a,className:"dndev-size-md"}),n(x,{gap:"none",style:{flex:1,minWidth:0},children:[t(g,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(g,{level:"caption",variant:"muted",children:[Te(e.uploaded?.size||e.file.size),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),l&&t(me,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),n(x,{direction:"row",gap:"tight",children:[R&&u&&e.uploaded&&t(B,{variant:q.GHOST,onClick:()=>ae(e),"aria-label":i("document.preview.ariaLabel"),children:t(ce,{className:"dndev-size-sm"})}),l?t(de,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):t(B,{variant:q.GHOST,onClick:()=>re(e.id),"aria-label":i("document.delete.ariaLabel"),children:t(oe,{className:"dndev-size-sm"})})]})]},e.id)})}),M&&t(g,{level:"caption",variant:D?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]}),R&&z&&t(ge,{open:!!z,onOpenChange:()=>H(null),children:n(ve,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[t(fe,{children:t(he,{children:i("document.preview.title")})}),t("iframe",{src:z,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});V.displayName="DocumentFieldComponent";var ke=V;export{ke as default};
1
+ "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};
@@ -23,7 +23,7 @@ export interface DropdownComponentProps {
23
23
  /**
24
24
  * DropdownComponent renders a styled select input.
25
25
  *
26
- * @version 0.0.1
26
+ * @version 0.1.0
27
27
  * @since 0.0.1
28
28
  * @author AMBROISE PARK Consulting
29
29
  * @param props - DropdownComponentProps
@@ -1 +1 @@
1
- import{jsx as t,jsxs as g}from"react/jsx-runtime";import{Select as d,Stack as v}from"@donotdev/components";import{useTranslation as m}from"@donotdev/core";const f=({label:o,value:r,options:n,error:s,helperText:a,onChange:l,onBlur:i,required:u})=>{const{t:p}=m("crud"),c=r!=null?String(r):"";return g(v,{gap:"tight",children:[t(d,{label:o,value:c,onValueChange:e=>{l&&l({target:{value:e}})},onOpenChange:e=>!e&&i?.(),placeholder:p("actions.select","Select"),required:u,options:n.map(e=>({value:String(e.value),label:e.label}))}),a&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var h=f;export{h as default};
1
+ import{jsx as r,jsxs as p}from"react/jsx-runtime";import{Select as g,Stack as m}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";const h=({label:o,value:t,options:s,error:l,helperText:n,onChange:a,onBlur:i,required:c})=>{const{t:d}=f("crud"),u=t!=null?String(t):"";return p(m,{gap:"tight",children:[r(g,{label:o,value:u,onValueChange:e=>{a&&a({target:{value:e}})},onOpenChange:e=>!e&&i?.(),placeholder:d("actions.select","Select"),required:c,options:s.map(e=>({value:String(e.value),label:e.label}))}),n&&r("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:n})]})};var C=h;export{C as default};
@@ -1 +1 @@
1
- import{jsx as i,jsxs as u}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as T,useMemo as k}from"react";import{Label as $,Stack as s,Button as S,Slider as w}from"@donotdev/components";const f=[15,30,45,60,90,120,150,180],N={15:"duration.15m",30:"duration.30m",45:"duration.45m",60:"duration.1h",90:"duration.1h30",120:"duration.2h",150:"duration.2h30",180:"duration.3h"};function q(e,n){const o=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,l=N[e];return!n||!l?o:n(`crud:${l}`,{defaultValue:o})??o}const W=({label:e,value:n,onChange:o,error:l,helperText:d,disabled:m,required:p,readonly:M,min:g=0,max:v=480,step:V=5,t})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,h=f.includes(r),[c,b]=T(!h&&r>0),C=k(()=>f.map(a=>({minutes:a,label:q(a,t)})),[t]),y=t?t("crud:duration.custom",{defaultValue:"Custom"}):"Custom";if(M){const a=r===0?t?t("crud:duration.zero",{defaultValue:"\u2014"}):"\u2014":r<60?t?t("crud:duration.minutes",{count:r,defaultValue:`${r} min`}):`${r} min`:t?t("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60,defaultValue:`${Math.floor(r/60)}h${r%60?` ${r%60}min`:""}`}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return u(s,{gap:"tight",children:[i($,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),u(s,{direction:"row",gap:"tight",align:"center",children:[i(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),i("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})}return u(s,{children:[i($,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),u(s,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[C.map(({minutes:a,label:z})=>u(S,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),o(a)},"aria-pressed":r===a,"aria-label":z,children:[i(x,{size:14,style:{marginRight:"var(--gap-xs)"},"aria-hidden":!0}),z]},a)),i(S,{type:"button",variant:c?"primary":"outline",disabled:m,onClick:()=>{b(!0),!h&&r>0?o(r):o(30)},"aria-pressed":c,"aria-label":y,children:y})]}),c&&i(s,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:i(w,{value:[h?30:r],onValueChange:([a])=>o(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:V,showValue:!0,disabled:m,"aria-label":e})}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var j=W;export{f as DURATION_PRESETS,j as default};
1
+ import{jsx as a,jsxs as u}from"react/jsx-runtime";import{Clock as S}from"lucide-react";import{useState as w,useMemo as C}from"react";import{Label as $,Stack as l,Button as b,Slider as E}from"@donotdev/components";const x=[15,30,45,60,90,120,150,180],N={15:"duration.15m",30:"duration.30m",45:"duration.45m",60:"duration.1h",90:"duration.1h30",120:"duration.2h",150:"duration.2h30",180:"duration.3h"};function _(t,n){const i=t<60?`${t}m`:t%60===0?`${t/60}h`:`${Math.floor(t/60)}h${t%60}`,s=N[t];return!n||!s?i:n(`crud:${s}`,{defaultValue:i})??i}const j=({label:t,value:n,onChange:i,error:s,helperText:d,disabled:c,required:h,readonly:M,min:p=0,max:g=480,step:V=5,t:o})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,f=x.includes(r),[m,v]=w(!f&&r>0),k=C(()=>x.map(e=>({minutes:e,label:_(e,o)})),[o]),y=o?o("crud:duration.custom",{defaultValue:"Custom"}):"Custom";if(M){const e=r===0?o?o("crud:duration.zero",{defaultValue:"\u2014"}):"\u2014":r<60?o?o("crud:duration.minutes",{count:r,defaultValue:`${r} min`}):`${r} min`:o?o("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60,defaultValue:`${Math.floor(r/60)}h${r%60?` ${r%60}min`:""}`}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return u(l,{gap:"tight",children:[a($,{required:h,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:t}),u(l,{direction:"row",gap:"tight",align:"center",children:[a(S,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),a("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:e})]}),d&&a("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})}return u(l,{children:[a($,{required:h,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:t}),u(l,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[k.map(({minutes:e,label:z})=>u(b,{type:"button",variant:r===e?"primary":"outline",disabled:c,onClick:()=>{v(!1),i(e)},"aria-pressed":r===e,"aria-label":z,children:[a(S,{size:14,style:{marginRight:"var(--gap-xs)"},"aria-hidden":!0}),z]},e)),a(b,{type:"button",variant:m?"primary":"outline",disabled:c,onClick:()=>{v(!0),!f&&r>0?i(r):i(30)},"aria-pressed":m,"aria-label":y,children:y})]}),m&&a(l,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:a(E,{value:[f?30:r],onValueChange:([e])=>i(Math.max(p,Math.min(g,e??0))),min:p,max:g,step:V,showValue:!0,disabled:c,"aria-label":t})}),d&&a("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var W=j;export{x as DURATION_PRESETS,W as default};
@@ -1 +1 @@
1
- "use client";import{jsx as l,jsxs as c}from"react/jsx-runtime";import{Upload as Y,X as Z,File as $,Loader2 as ee,FileText as C,FileSpreadsheet as re,FileImage as ae,FileVideo as le,FileAudio as se,FileArchive as te,FileCode as ie}from"lucide-react";import{useCallback as h,useState as U,useRef as w,useEffect as O,useImperativeHandle as oe,forwardRef as ne}from"react";import{Button as de,BUTTON_VARIANT as ue,Text as y,Stack as F,Progress as ce}from"@donotdev/components";import{handleError as S,useTranslation as pe}from"@donotdev/core";import{useUploadContext as me}from"../../../contexts/UploadContext";import{useUploadStore as j}from"../../../stores/UploadStore";import{uploadFile as fe,deleteFile as ge,generateFileId as B,getFileIcon as ve,formatFileSize as he}from"../../../utils/fileStorage";function ye({type:m,className:o}){switch(m){case"pdf":return l(C,{className:o,style:{color:"var(--destructive)"}});case"doc":return l(C,{className:o,style:{color:"var(--primary)"}});case"xls":return l(re,{className:o,style:{color:"var(--success)"}});case"ppt":return l(C,{className:o,style:{color:"var(--warning)"}});case"image":return l(ae,{className:o});case"video":return l(le,{className:o});case"audio":return l(se,{className:o});case"archive":return l(te,{className:o});case"html":case"text":return l(ie,{className:o});default:return l($,{className:o})}}const H=ne(({name:m,label:o,value:f,onChange:D,error:b,helperText:M,accept:q,multiple:n=!1,maxFiles:T=10,maxSize:k=50*1024*1024,storagePath:E="uploads/files",required:G},V)=>{const{t:W}=pe("crud"),d=W,g=me(),I=!!g,[t,u]=U([]),[L,P]=U(!1),v=w(null),z=w(!1),x=w(void 0),N=h(e=>{const r=e.filter(a=>a.uploaded&&!a.error).map(a=>a.uploaded);D(n?r:r[0]||null)},[n,D]);O(()=>{if(z.current){z.current=!1;return}if(f){const e=[];(Array.isArray(f)?f:[f]).forEach(r=>{r.url&&e.push({id:B(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),u(e)}else u([])},[f]);const X=h(async()=>{const e=t.filter(r=>!r.uploaded&&!r.error&&r.uploadProgress===null);if(e.length!==0){u(r=>r.map(a=>e.some(s=>s.id===a.id)?{...a,uploadProgress:0}:a));for(const r of e)try{const a=await fe(r.file,{storagePath:E,onProgress:s=>{u(p=>p.map(i=>i.id===r.id?{...i,uploadProgress:s.progress}:i))}});u(s=>{const p=s.map(i=>i.id===r.id?{...i,uploaded:a,uploadProgress:100,error:null}:i);return queueMicrotask(()=>N(p)),p})}catch{u(a=>a.map(s=>s.id===r.id?{...s,error:"Upload failed",uploadProgress:null}:s))}}},[t,E,N]);x.current=X,O(()=>{if(!(!g||!m))return j.getState().registerUpload(g,m,async e=>{await x.current?.()}),()=>{j.getState().unregisterUpload(g,m)}},[g,m]),oe(V,()=>({upload:async()=>{await x.current?.()},getFiles:()=>R.current||[]}),[]);const R=w(t);R.current=t;const A=h(e=>{const r=(n?T:1)-t.length;if(r<=0){S(new Error("Maximum files reached"),{userMessage:d("file.errors.maxFiles",{max:T}),severity:"warning",showNotification:!0});return}const a=e.slice(0,r),s=[],p=(k/(1024*1024)).toFixed(0);for(const i of a){if(i.size>k){S(new Error("File too large"),{userMessage:d("file.errors.exceedsSize",{fileName:i.name,size:p}),severity:"warning",showNotification:!0});continue}s.push({id:B(),file:i,uploadProgress:null,uploaded:null,error:null})}s.length!==0&&(u(i=>n?[...i,...s]:s),I||setTimeout(()=>x.current?.(),0))},[t,n,T,k,d,I]),_=e=>{const r=Array.from(e.target.files||[]);r.length>0&&A(r),v.current&&(v.current.value="")},J=h(e=>{e.preventDefault(),P(!1);const r=Array.from(e.dataTransfer.files);A(r)},[A]),K=h(async e=>{const r=t.find(a=>a.id===e);if(r)try{r.uploaded&&await ge(r.uploaded);const a=t.filter(s=>s.id!==e);z.current=!0,u(a),setTimeout(()=>N(a),0)}catch(a){S(a,{userMessage:d("file.delete.failed"),severity:"error",showNotification:!0})}},[t,N,d]),Q=n||t.length===0,Ne=t.some(e=>!e.uploaded&&!e.error&&e.uploadProgress===null);return c(F,{gap:"tight",children:[c(y,{level:"body",textAlign:"start",children:[o,G?"*":""]}),Q&&c("div",{role:"button",tabIndex:0,"aria-label":d(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":b?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:L?"var(--primary)":b?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:L?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:J,onClick:()=>v.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),v.current?.click())},children:[l("input",{ref:v,type:"file",accept:q,multiple:n,style:{display:"none"},onChange:_}),c(F,{align:"center",justify:"center",children:[l(Y,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),l(y,{as:"p",variant:"muted",level:"small",textAlign:"center",children:d(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),t.length>0&&l(F,{gap:"tight",children:t.map((e,r)=>{const a=ve(e.uploaded?.mimeType||e.file.type,e.file.name),s=e.uploadProgress!==null&&e.uploadProgress<100,p=e.uploaded&&!e.error;return c("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[l(ye,{type:a,className:"dndev-size-md"}),c(F,{gap:"none",style:{flex:1,minWidth:0},children:[l(y,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),c(y,{level:"caption",variant:"muted",children:[he(e.uploaded?.size||e.file.size),e.error&&c("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),s&&l(ce,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),s?l(ee,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):l(de,{variant:ue.GHOST,onClick:()=>K(e.id),"aria-label":d("file.delete.ariaLabel"),children:l(Z,{className:"dndev-size-sm"})})]},e.id)})}),M&&l(y,{level:"caption",variant:b?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]})});H.displayName="FileFieldComponent";var xe=H;export{xe as default};
1
+ "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};
@@ -15,7 +15,7 @@ export interface GdprConsentFieldComponentProps {
15
15
  * GDPR Consent Field Component - Renders a consent checkbox with automatic label generation.
16
16
  * Opens privacy policy and terms in Sheet with iframe when links are clicked.
17
17
  *
18
- * @version 0.0.2
18
+ * @version 0.1.0
19
19
  * @since 0.0.1
20
20
  * @author AMBROISE PARK Consulting
21
21
  * @param props - GdprConsentFieldComponentProps
@@ -1 +1 @@
1
- import{jsx as t,jsxs as a,Fragment as w}from"react/jsx-runtime";import{useState as m}from"react";import{Checkbox as D,Label as H,Sheet as f,Stack as P,Text as V}from"@donotdev/components";import{useTranslation as j}from"@donotdev/core";const q=({checked:o=!1,onChange:l,required:u,privacyPolicyPath:s="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:r}=j("crud"),[y,d]=m(!1),[x,h]=m(!1),p=e=>{l&&l({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!o))},g=(e,b)=>{e.preventDefault(),b==="privacy"?d(!0):h(!0)},C=r("gdprConsent.consent",{defaultValue:"I agree to the"}),n=r("gdprConsent.privacyPolicy",{defaultValue:"privacy policy"}),i=r("gdprConsent.terms",{defaultValue:"terms of use"}),k=r("gdprConsent.and",{defaultValue:"and consent to the processing of my personal data."});return a(w,{children:[a(P,{direction:"row",align:"center",gap:"tight",children:[t(D,{checked:o,onCheckedChange:p}),t(H,{required:u,plain:!0,onClick:v,style:{cursor:"pointer"},children:a(V,{level:"small",children:[C," ",t("a",{href:s,onClick:e=>g(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:n})," / ",t("a",{href:c,onClick:e=>g(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," ",k]})})]}),t(f,{open:y,onOpenChange:d,side:"bottom",title:n,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:s,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:n})}),t(f,{open:x,onOpenChange:h,side:"bottom",title:i,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:i})})]})};var O=q;export{O as default};
1
+ import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as m}from"react";import{Checkbox as T,Label as O,Sheet as g,Stack as D,Text as j}from"@donotdev/components";import{useTranslation as H}from"@donotdev/core";const V=({checked:l=!1,onChange:s,required:u,privacyPolicyPath:a="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:n}=H("crud"),[x,d]=m(!1),[y,h]=m(!1),p=e=>{s&&s({target:{checked:e}})},C=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!l))},f=(e,b)=>{e.preventDefault(),b==="privacy"?d(!0):h(!0)},v=n("gdprConsent.consent",{defaultValue:"I agree to the"}),r=n("gdprConsent.privacyPolicy",{defaultValue:"privacy policy"}),i=n("gdprConsent.terms",{defaultValue:"terms of use"}),k=n("gdprConsent.and",{defaultValue:"and consent to the processing of my personal data."});return o(w,{children:[o(D,{direction:"row",align:"center",gap:"tight",children:[t(T,{checked:l,onCheckedChange:p}),t(O,{required:u,plain:!0,onClick:C,style:{cursor:"pointer"},children:o(j,{level:"small",children:[v," ",t("a",{href:a,onClick:e=>f(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:r})," / ",t("a",{href:c,onClick:e=>f(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," ",k]})})]}),t(g,{open:x,onOpenChange:d,side:"bottom",title:r,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:a,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:r})}),t(g,{open:y,onOpenChange:h,side:"bottom",title:i,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:i})})]})};var q=V;export{q as default};
@@ -22,7 +22,7 @@ export interface GeoPointFieldComponentProps {
22
22
  /**
23
23
  * GeoPointFieldComponent renders latitude and longitude input fields
24
24
  *
25
- * @version 0.0.1
25
+ * @version 0.1.0
26
26
  * @since 0.0.1
27
27
  * @author AMBROISE PARK Consulting
28
28
  */
@@ -1 +1 @@
1
- import{jsx as t,jsxs as u}from"react/jsx-runtime";import{Label as b,Input as v,Stack as g}from"@donotdev/components";const h=({label:c,value:a={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:f})=>{const m=l=>{const e=parseFloat(l.target.value)||0;if(e>=-90&&e<=90){const n={...a,lat:e},s={target:{value:JSON.stringify(n)}};i(s)}},p=l=>{const e=parseFloat(l.target.value)||0;if(e>=-180&&e<=180){const n={...a,lng:e},s={target:{value:JSON.stringify(n)}};i(s)}};return u(g,{gap:"tight",children:[t(b,{required:f,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:c}),u(g,{direction:"row",children:[t(v,{label:"Latitude",type:"number",value:a.lat,onChange:m,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),t(v,{label:"Longitude",type:"number",value:a.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&t("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var y=h;export{y as default};
1
+ import{jsx as n,jsxs as c}from"react/jsx-runtime";import{Label as h,Input as g,Stack as u}from"@donotdev/components";const y=({label:f,value:e={lat:0,lng:0},onChange:l,error:a,helperText:r,disabled:d,required:m})=>{const v=i=>{const t=parseFloat(i.target.value)||0;if(t>=-90&&t<=90){const s={...e,lat:t},o={target:{value:JSON.stringify(s)}};l(o)}},p=i=>{const t=parseFloat(i.target.value)||0;if(t>=-180&&t<=180){const s={...e,lng:t},o={target:{value:JSON.stringify(s)}};l(o)}};return c(u,{gap:"tight",children:[n(h,{required:m,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:f}),c(u,{direction:"row",children:[n(g,{label:"Latitude",type:"number",value:e.lat,onChange:v,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":a?"destructive":void 0,className:"dndev-w-full"}),n(g,{label:"Longitude",type:"number",value:e.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":a?"destructive":void 0,className:"dndev-w-full"})]}),r&&n("p",{style:{fontSize:"var(--font-size-xs)",color:a?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]})};var L=y;export{L as default};
@@ -2,7 +2,7 @@
2
2
  * @fileoverview HiddenFieldComponent
3
3
  * @description Hidden field component for form inputs
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";const n=({name:a,value:e})=>t("input",{type:"hidden",name:a,value:e});var d=n;export{d as default};
1
+ import{jsx as t}from"react/jsx-runtime";const d=({name:e,value:n})=>t("input",{type:"hidden",name:e,value:n});var i=d;export{i as default};