@donotdev/crud 0.3.0 → 0.3.2

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 (117) hide show
  1. package/dist/CrudService.bulk.js +1 -1
  2. package/dist/CrudService.bulkAcross.js +1 -1
  3. package/dist/CrudService.bulkReconciliation.js +1 -1
  4. package/dist/CrudService.cache.d.ts +8 -0
  5. package/dist/CrudService.cache.d.ts.map +1 -1
  6. package/dist/CrudService.cache.js +1 -1
  7. package/dist/CrudService.d.ts +7 -2
  8. package/dist/CrudService.d.ts.map +1 -1
  9. package/dist/CrudService.internal.js +2 -2
  10. package/dist/CrudService.js +1 -1
  11. package/dist/CrudService.mutations.js +1 -1
  12. package/dist/CrudService.optimistic.js +1 -1
  13. package/dist/CrudService.subscriptions.js +1 -1
  14. package/dist/CrudService.writeRules.js +1 -1
  15. package/dist/CrudStore.js +1 -1
  16. package/dist/components/CrudButton.js +1 -1
  17. package/dist/components/CrudCard.js +1 -1
  18. package/dist/components/DateFilter.d.ts.map +1 -1
  19. package/dist/components/DateFilter.js +1 -1
  20. package/dist/components/DisplayFieldRenderer.js +1 -1
  21. package/dist/components/DisplayThumbnail.js +1 -1
  22. package/dist/components/EntityFilters.js +1 -1
  23. package/dist/components/YearFilter.js +1 -1
  24. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
  25. package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
  26. package/dist/components/controlled/complex/ControlledMapField.js +1 -1
  27. package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
  28. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  29. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  30. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  31. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  32. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  33. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  34. package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
  35. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  36. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  37. package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
  38. package/dist/components/controlled/select/ControlledRadioField.js +1 -1
  39. package/dist/components/controlled/types.js +1 -1
  40. package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
  41. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  42. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  43. package/dist/components/fields/display/FileFieldDisplay.js +1 -1
  44. package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
  45. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  46. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  47. package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
  48. package/dist/components/fields/display/TextAreaDisplay.js +1 -1
  49. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  50. package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
  51. package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
  52. package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
  53. package/dist/components/form/fields/DateFieldComponent.d.ts.map +1 -1
  54. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  55. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  56. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  57. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  58. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  59. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  60. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  61. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  62. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  63. package/dist/components/form/fields/RatingFieldComponent.js +1 -1
  64. package/dist/components/form/fields/RichTextComponent.js +1 -1
  65. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  66. package/dist/components/form/fields/internal/InlineFieldRow.js +1 -1
  67. package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
  68. package/dist/components/form/internal/ImageViewerDialog.js +1 -1
  69. package/dist/forms/hooks/useController.js +1 -1
  70. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  71. package/dist/forms/hooks/useEntityForm.js +1 -1
  72. package/dist/forms/utils/buildInitialValues.js +1 -1
  73. package/dist/forms/utils/emptyValue.js +1 -1
  74. package/dist/forms/utils/validateEntity.js +1 -1
  75. package/dist/hooks/useCrudFilters.js +1 -1
  76. package/dist/hooks/useCrudPageSize.js +1 -1
  77. package/dist/hooks/useEntityFavorites.js +1 -1
  78. package/dist/hooks/useExtensionRows.js +1 -1
  79. package/dist/hooks/useFileUpload.js +1 -1
  80. package/dist/hooks/useRelatedItems.js +1 -1
  81. package/dist/stores/UploadStore.d.ts.map +1 -1
  82. package/dist/stores/UploadStore.js +1 -1
  83. package/dist/stores/uploadStoreRef.d.ts +35 -0
  84. package/dist/stores/uploadStoreRef.d.ts.map +1 -0
  85. package/dist/stores/uploadStoreRef.js +1 -0
  86. package/dist/symbol-index.json +1 -1
  87. package/dist/tsconfig.tsbuildinfo +1 -1
  88. package/dist/types.d.ts +4 -2
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/useBaseCrudList.js +1 -1
  91. package/dist/useCrud.js +1 -1
  92. package/dist/useCrudCardList.js +1 -1
  93. package/dist/useCrudDoc.d.ts +8 -1
  94. package/dist/useCrudDoc.d.ts.map +1 -1
  95. package/dist/useCrudDoc.js +1 -1
  96. package/dist/useCrudList.js +1 -1
  97. package/dist/useServerPrefetch.js +1 -1
  98. package/dist/utils/clientListProcessing.js +1 -1
  99. package/dist/utils/collections.js +1 -1
  100. package/dist/utils/filterUrl.js +1 -1
  101. package/dist/utils/imageProcessing.js +1 -1
  102. package/dist/utils/matchesFilter.js +1 -1
  103. package/dist/utils/mergeWithOptimistic.js +1 -1
  104. package/dist/utils/referenceEntity.js +1 -1
  105. package/dist/utils/routeRecord.d.ts +21 -0
  106. package/dist/utils/routeRecord.d.ts.map +1 -0
  107. package/dist/utils/routeRecord.js +1 -0
  108. package/dist/utils/uploadValidation.js +1 -1
  109. package/dist/utils/useRowTranslator.js +1 -1
  110. package/dist/workflows/defineWorkflow.js +1 -1
  111. package/dist/workflows/useEntityWorkflow.js +1 -1
  112. package/guidelines/COMPONENTS.md +1 -1
  113. package/guidelines/CRUD.md +3 -1
  114. package/package.json +3 -3
  115. package/dist/CrudService.writeSchema.d.ts +0 -64
  116. package/dist/CrudService.writeSchema.d.ts.map +0 -1
  117. package/dist/CrudService.writeSchema.js +0 -1
@@ -1 +1 @@
1
- "use client";import{jsx as i,jsxs as r}from"react/jsx-runtime";import{useFieldArray as F,Controller as R}from"react-hook-form";import{Button as h}from"@donotdev/components";import{getFieldRegistry as q}from"../../../FieldRegistry";import{convertValidationRules as B}from"../types";function D(s){switch(s){case"number":return 0;case"boolean":return!1;default:return""}}function I(s){const{control:c,fieldConfig:f,required:x,t:l}=s,{name:v,label:a,validation:j}=f,m=f.options?.fieldSpecific??{},o=m.fields??[],n=m.direction??"row",u=m.fixedRows===!0,{fields:b,append:w,remove:C}=F({control:c,name:v}),S=q(),z=()=>{if(o.length===0)return;const d={};for(const t of o)d[t.name]=D(t.type);w(d)};return o.length===0?i("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l("crud:fieldArray.noSubFields",{field:l(a)})}):r("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[r("span",{style:{fontSize:"var(--font-size-sm)",fontWeight:"var(--font-weight-medium)"},children:[l(a),x&&i("span",{style:{color:"var(--destructive)",marginInlineStart:"var(--gap-sm)"},children:"*"})]}),!u&&i(h,{type:"button",variant:"ghost",display:"compact",intent:"add",onClick:z,"aria-label":l("crud:fieldArray.addRow",{field:l(a)})})]}),b.map((d,t)=>r("div",{style:{display:"flex",flexDirection:n,gap:"var(--gap-sm)",alignItems:n==="row"?"flex-start":void 0},children:[o.map(e=>{const y=`${v}.${t}.${e.name}`,A={name:y,type:e.type,label:e.label,visibility:f.visibility,validation:{...e.validation??{},...e.required?{required:!0}:{}},options:e.options??{}},g=S.getControlledComponent(e.type);return g?i("div",{style:{flex:n==="row"?1:void 0},children:i(g,{control:c,fieldConfig:A,t:l})},e.name):i("div",{style:{flex:n==="row"?1:void 0},children:i(R,{name:y,control:c,rules:e.validation?B(e.validation):void 0,render:({field:p})=>r("label",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[i("span",{style:{fontSize:"var(--font-size-xs)"},children:l(e.label)}),i("input",{className:"dndev-input",value:String(p.value??""),onChange:p.onChange,onBlur:p.onBlur})]})})},e.name)}),!u&&i(h,{type:"button",variant:"ghost",display:"compact",intent:"delete",onClick:()=>C(t),"aria-label":l("crud:fieldArray.removeRow",{field:l(a),index:t+1}),style:{alignSelf:n==="row"?"center":"flex-end"}})]},d.id))]})}export{I as ControlledFieldArrayField};
1
+ "use client";import{jsx as i,jsxs as r}from"react/jsx-runtime";import{useFieldArray as F,Controller as R}from"react-hook-form";import{Button as h}from"@donotdev/components";import{getFieldRegistry as q}from"../../../FieldRegistry";import{convertValidationRules as B}from"../types";function D(s){switch(s){case"number":return 0;case"boolean":return!1;default:return""}}function I(s){const{control:c,fieldConfig:f,required:x,t:l}=s,{name:v,label:a,validation:j}=f,m=f.options?.fieldSpecific??{},o=m.fields??[],t=m.direction??"row",u=m.fixedRows===!0,{fields:b,append:w,remove:C}=F({control:c,name:v}),S=q(),z=()=>{if(o.length===0)return;const d={};for(const n of o)d[n.name]=D(n.type);w(d)};return o.length===0?i("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l("crud:fieldArray.noSubFields",{field:l(a)})}):r("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[r("span",{style:{fontSize:"var(--font-size-sm)",fontWeight:"var(--font-weight-medium)"},children:[l(a),x&&i("span",{style:{color:"var(--destructive)",marginInlineStart:"var(--gap-sm)"},children:"*"})]}),!u&&i(h,{type:"button",variant:"ghost",display:"compact",intent:"add",onClick:z,"aria-label":l("crud:fieldArray.addRow",{field:l(a)})})]}),b.map((d,n)=>r("div",{style:{display:"flex",flexDirection:t,gap:"var(--gap-sm)",alignItems:t==="row"?"flex-start":void 0},children:[o.map(e=>{const y=`${v}.${n}.${e.name}`,A={name:y,type:e.type,label:e.label,visibility:f.visibility,validation:{...e.validation??{},...e.required?{required:!0}:{}},options:e.options??{}},g=S.getControlledComponent(e.type);return g?i("div",{style:{flex:t==="row"?1:void 0},children:i(g,{control:c,fieldConfig:A,t:l})},e.name):i("div",{style:{flex:t==="row"?1:void 0},children:i(R,{name:y,control:c,rules:e.validation?B(e.validation):void 0,render:({field:p})=>r("label",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[i("span",{style:{fontSize:"var(--font-size-xs)"},children:l(e.label)}),i("input",{className:"dndev-input",value:String(p.value??""),onChange:p.onChange,onBlur:p.onBlur})]})})},e.name)}),!u&&i(h,{type:"button",variant:"ghost",display:"compact",intent:"delete",onClick:()=>C(n),"aria-label":l("crud:fieldArray.removeRow",{field:l(a),index:n+1}),style:{alignSelf:t==="row"?"center":"flex-end"}})]},d.id))]})}export{I as ControlledFieldArrayField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{GeoPointFieldComponent as p}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(l){const{control:a,fieldConfig:i,required:s,t:d}=l,{name:m,label:g,validation:o}=i;return n(f,{name:m,control:a,rules:o?C(o):void 0,render:({field:e,fieldState:t})=>{const u=r=>{if("target"in r)try{const c=JSON.parse(r.target.value);e.onChange(c)}catch{e.onChange({lat:0,lng:0})}else e.onChange(r||{lat:0,lng:0})};return n(p,{label:d(g),value:e.value||{lat:0,lng:0},onChange:u,error:!!t.error,helperText:t.error?.message,required:s})}})}export{h as ControlledGeoPointField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{GeoPointFieldComponent as p}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(l){const{control:a,fieldConfig:i,required:s,t:d}=l,{name:m,label:g,validation:r}=i;return t(f,{name:m,control:a,rules:r?C(r):void 0,render:({field:e,fieldState:n})=>{const u=o=>{if("target"in o)try{const c=JSON.parse(o.target.value);e.onChange(c)}catch{e.onChange({lat:0,lng:0})}else e.onChange(o||{lat:0,lng:0})};return t(p,{label:d(g),value:e.value||{lat:0,lng:0},onChange:u,error:!!n.error,helperText:n.error?.message,required:s})}})}export{h as ControlledGeoPointField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MapFieldComponent as g}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(a){const{control:l,fieldConfig:i,required:s,t:d}=a,{name:m,label:u,validation:o}=i;return n(p,{name:m,control:l,rules:o?C(o):void 0,render:({field:e,fieldState:t})=>{const c=r=>{if("target"in r)try{const f=JSON.parse(r.target.value);e.onChange(f)}catch{e.onChange({})}else e.onChange(r||{})};return n(g,{label:d(u),value:e.value||{},onChange:c,error:!!t.error,helperText:t.error?.message,required:s})}})}export{h as ControlledMapField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MapFieldComponent as g}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(a){const{control:l,fieldConfig:i,required:s,t:d}=a,{name:m,label:u,validation:o}=i;return t(p,{name:m,control:l,rules:o?C(o):void 0,render:({field:e,fieldState:n})=>{const c=r=>{if("target"in r)try{const f=JSON.parse(r.target.value);e.onChange(f)}catch{e.onChange({})}else e.onChange(r||{})};return t(g,{label:d(u),value:e.value||{},onChange:c,error:!!n.error,helperText:n.error?.message,required:s})}})}export{h as ControlledMapField};
@@ -1 +1 @@
1
- "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{RichTextComponent as h}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(n){const{control:t,fieldConfig:i,placeholder:s,required:m,t:d}=n,{name:c,label:p,validation:e,options:r={}}=i;return a(f,{name:c,control:t,rules:e?C(e):void 0,render:({field:o,fieldState:l})=>a(h,{label:d(p),value:o.value??"",onChange:u=>o.onChange(u),error:l.error?.message,helperText:l.error?.message,required:m,placeholder:s||r.placeholder,className:r.className})})}export{x as ControlledRichTextField};
1
+ "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as h}from"react-hook-form";import{RichTextComponent as u}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(t){const{control:n,fieldConfig:i,placeholder:s,required:m,t:d}=t,{name:c,label:p,validation:e,options:r={}}=i;return a(h,{name:c,control:n,rules:e?C(e):void 0,render:({field:o,fieldState:l})=>a(u,{label:d(p),value:o.value??"",onChange:f=>o.onChange(f),error:l.error?.message,helperText:l.error?.message,required:m,placeholder:s||r.placeholder,className:r.className})})}export{x as ControlledRichTextField};
@@ -1 +1 @@
1
- "use client";import{jsx as i}from"react/jsx-runtime";import{Controller as c}from"react-hook-form";import{DocumentFieldComponent as f}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:o,label:u,validation:r}=e,a=g(e);return i(c,{name:o,control:m,rules:r?x(r):void 0,render:({field:t,fieldState:l})=>i(f,{name:o,label:d(u),value:t.value??null,onChange:p=>t.onChange(p),error:!!l.error,helperText:l.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:a?.maxSize,storagePath:a?.storagePath})})}export{C as ControlledDocumentField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as c}from"react-hook-form";import{DocumentFieldComponent as p}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:o,label:u,validation:r}=e,a=g(e);return t(c,{name:o,control:m,rules:r?x(r):void 0,render:({field:l,fieldState:i})=>t(p,{name:o,label:d(u),value:l.value??null,onChange:f=>l.onChange(f),error:!!i.error,helperText:i.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:a?.maxSize,storagePath:a?.storagePath})})}export{C as ControlledDocumentField};
@@ -1 +1 @@
1
- "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{FileFieldComponent as c}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:r,label:u,validation:o}=e,l=g(e);return t(f,{name:r,control:m,rules:o?x(o):void 0,render:({field:a,fieldState:i})=>t(c,{name:r,label:d(u),value:a.value??null,onChange:p=>a.onChange(p),error:!!i.error,helperText:i.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:l?.maxSize,storagePath:l?.storagePath})})}export{C as ControlledFileField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{FileFieldComponent as c}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:r,label:u,validation:o}=e,l=g(e);return t(p,{name:r,control:m,rules:o?x(o):void 0,render:({field:a,fieldState:i})=>t(c,{name:r,label:d(u),value:a.value??null,onChange:f=>a.onChange(f),error:!!i.error,helperText:i.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:l?.maxSize,storagePath:l?.storagePath})})}export{C as ControlledFileField};
@@ -1 +1 @@
1
- "use client";import{jsx as m}from"react/jsx-runtime";import{useMemo as c}from"react";import{Controller as x}from"react-hook-form";import{readImageProcessingOptions as C}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{uploadFieldSpecific as v}from"../fieldOptions";import{convertValidationRules as S}from"../types";function F(n){const{control:s,fieldConfig:r,required:d,t:p}=n,{name:o,label:f,validation:a}=r,e=v(r),i=e?.image,g=c(()=>C({image:i}),[JSON.stringify(i)]);return m(x,{name:o,control:s,rules:a?S(a):void 0,render:({field:l,fieldState:t})=>m(h,{name:o,label:p(f),value:l.value??null,onChange:u=>l.onChange(u),error:!!t.error,helperText:t.error?.message,required:d,multiple:!1,maxFiles:1,maxSize:e?.maxSize,storagePath:e?.storagePath,processing:g})})}export{F as ControlledImageField};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{useMemo as c}from"react";import{Controller as x}from"react-hook-form";import{readImageProcessingOptions as C}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{uploadFieldSpecific as v}from"../fieldOptions";import{convertValidationRules as S}from"../types";function F(n){const{control:s,fieldConfig:r,required:d,t:p}=n,{name:o,label:f,validation:a}=r,e=v(r),i=e?.image,g=c(()=>C({image:i}),[JSON.stringify(i)]);return l(x,{name:o,control:s,rules:a?S(a):void 0,render:({field:m,fieldState:t})=>l(h,{name:o,label:p(f),value:m.value??null,onChange:u=>m.onChange(u),error:!!t.error,helperText:t.error?.message,required:d,multiple:!1,maxFiles:1,maxSize:e?.maxSize,storagePath:e?.storagePath,processing:g})})}export{F as ControlledImageField};
@@ -1 +1 @@
1
- "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as v}from"react-hook-form";import{DocumentFieldComponent as x}from"../../form/fields";import{controlledFieldOptions as g,uploadFieldSpecific as C}from"../fieldOptions";import{convertValidationRules as F}from"../types";function h(n){const{control:m,fieldConfig:r,required:s,t:u}=n,{name:o,label:d,validation:l}=r,c=g(r),a=C(r);return t(v,{name:o,control:m,rules:l?F(l):void 0,render:({field:e,fieldState:i})=>{const p=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return t(x,{name:o,label:u(d),value:p,onChange:f=>e.onChange(f),error:!!i.error,helperText:i.error?.message,required:s,multiple:!0,maxFiles:c.maxFiles??10,maxSize:a?.maxSize,storagePath:a?.storagePath})}})}export{h as ControlledMultiDocumentField};
1
+ "use client";import{jsx as i}from"react/jsx-runtime";import{Controller as v}from"react-hook-form";import{DocumentFieldComponent as x}from"../../form/fields";import{controlledFieldOptions as g,uploadFieldSpecific as C}from"../fieldOptions";import{convertValidationRules as F}from"../types";function h(n){const{control:m,fieldConfig:r,required:s,t:u}=n,{name:o,label:d,validation:l}=r,c=g(r),a=C(r);return i(v,{name:o,control:m,rules:l?F(l):void 0,render:({field:e,fieldState:t})=>{const p=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return i(x,{name:o,label:u(d),value:p,onChange:f=>e.onChange(f),error:!!t.error,helperText:t.error?.message,required:s,multiple:!0,maxFiles:c.maxFiles??10,maxSize:a?.maxSize,storagePath:a?.storagePath})}})}export{h as ControlledMultiDocumentField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}from"react/jsx-runtime";import{useMemo as x}from"react";import{Controller as C}from"react-hook-form";import{readImageProcessingOptions as F}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{controlledFieldOptions as S,uploadFieldSpecific as y}from"../fieldOptions";import{convertValidationRules as I}from"../types";function O(s){const{control:m,fieldConfig:r,required:u,t:d}=s,{name:a,label:p,validation:i}=r,f=S(r),o=y(r),l=o?.image,g=x(()=>F({image:l}),[JSON.stringify(l)]);return n(C,{name:a,control:m,rules:i?I(i):void 0,render:({field:e,fieldState:t})=>{const c=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return n(h,{name:a,label:d(p),value:c,onChange:v=>e.onChange(v),error:!!t.error,helperText:t.error?.message,required:u,multiple:!0,maxFiles:f.maxFiles??10,maxSize:o?.maxSize,storagePath:o?.storagePath,processing:g})}})}export{O as ControlledMultiImageField};
1
+ "use client";import{jsx as n}from"react/jsx-runtime";import{useMemo as x}from"react";import{Controller as C}from"react-hook-form";import{readImageProcessingOptions as F}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{controlledFieldOptions as S,uploadFieldSpecific as y}from"../fieldOptions";import{convertValidationRules as I}from"../types";function O(m){const{control:s,fieldConfig:r,required:u,t:d}=m,{name:a,label:p,validation:i}=r,f=S(r),o=y(r),l=o?.image,g=x(()=>F({image:l}),[JSON.stringify(l)]);return n(C,{name:a,control:s,rules:i?I(i):void 0,render:({field:e,fieldState:t})=>{const c=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return n(h,{name:a,label:d(p),value:c,onChange:v=>e.onChange(v),error:!!t.error,helperText:t.error?.message,required:u,multiple:!0,maxFiles:f.maxFiles??10,maxSize:o?.maxSize,storagePath:o?.storagePath,processing:g})}})}export{O as ControlledMultiImageField};
@@ -1 +1 @@
1
- "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{DurationFieldComponent as c}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(t){const{control:d,fieldConfig:r,t:i,required:s}=t,{name:m,label:f,validation:n}=r,e=(r.options||{}).fieldSpecific;return l(p,{name:m,control:d,rules:n?C(n):void 0,render:({field:o,fieldState:a})=>l(c,{label:i(f),value:o.value??0,onChange:u=>o.onChange(u),error:!!a.error,helperText:a.error?.message,required:s,disabled:o.disabled,min:e?.min??0,max:e?.max??480,step:e?.step??5,t:i})})}export{x as ControlledDurationField};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{DurationFieldComponent as c}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(t){const{control:d,fieldConfig:o,t:i,required:s}=t,{name:m,label:f,validation:n}=o,e=(o.options||{}).fieldSpecific;return l(u,{name:m,control:d,rules:n?C(n):void 0,render:({field:r,fieldState:a})=>l(c,{label:i(f),value:r.value??0,onChange:p=>r.onChange(p),error:!!a.error,helperText:a.error?.message,required:s,disabled:r.disabled,min:e?.min??0,max:e?.max??480,step:e?.step??5,t:i})})}export{x as ControlledDurationField};
@@ -1 +1 @@
1
- "use client";import{jsx as i}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{GdprConsentFieldComponent as u}from"../../form/fields";import{fieldSpecificOf as h}from"../fieldOptions";import{convertValidationRules as v}from"../types";function y(a){const{control:l,fieldConfig:n,required:s}=a,{name:c,validation:r}=n,o=h(n),d=o?.privacyPolicyPath||"/legal/privacy",p=o?.termsPath||"/legal/terms";return i(C,{name:c,control:l,rules:r?v(r):void 0,render:({field:t})=>{const e=t.value,m=typeof e=="object"&&e!==null?!!e.gdprConsent:!!e;return i(u,{checked:m,onChange:f=>{if(f.target.checked){const g=new Date().toISOString().split("T")[0];t.onChange({gdprConsent:!0,gdprConsentDate:new Date().toISOString(),gdprConsentVersion:g})}else t.onChange(!1)},required:s,privacyPolicyPath:d,termsPath:p})}})}export{y as ControlledGdprConsentField};
1
+ "use client";import{jsx as i}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{GdprConsentFieldComponent as u}from"../../form/fields";import{fieldSpecificOf as h}from"../fieldOptions";import{convertValidationRules as v}from"../types";function y(a){const{control:l,fieldConfig:n,required:s}=a,{name:c,validation:r}=n,t=h(n),d=t?.privacyPolicyPath||"/legal/privacy",p=t?.termsPath||"/legal/terms";return i(C,{name:c,control:l,rules:r?v(r):void 0,render:({field:o})=>{const e=o.value,m=typeof e=="object"&&e!==null?!!e.gdprConsent:!!e;return i(u,{checked:m,onChange:f=>{if(f.target.checked){const g=new Date().toISOString().split("T")[0];o.onChange({gdprConsent:!0,gdprConsentDate:new Date().toISOString(),gdprConsentVersion:g})}else o.onChange(!1)},required:s,privacyPolicyPath:d,termsPath:p})}})}export{y as ControlledGdprConsentField};
@@ -1 +1 @@
1
- "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{fromInputValue as p}from"../../../forms/utils";import{PhoneNumberComponent as g}from"../../form/fields";import{fieldInfo as v}from"../fieldOptions";import{convertValidationRules as c}from"../types";function C(l){const{control:i,fieldConfig:r,t:o,required:m}=l,{name:f,label:s,validation:n}=r;return t(d,{name:f,control:i,rules:n?c(n):void 0,render:({field:e,fieldState:a})=>t(g,{ref:e.ref,name:e.name,onBlur:e.onBlur,label:o(s),info:v(r,o),value:typeof e.value=="string"?e.value:"",onChange:u=>e.onChange(p(u.target.value)),error:a.error?.message,helperText:a.error?.message,required:m})})}export{C as ControlledPhoneField};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{fromInputValue as p}from"../../../forms/utils";import{PhoneNumberComponent as g}from"../../form/fields";import{fieldInfo as v}from"../fieldOptions";import{convertValidationRules as c}from"../types";function C(a){const{control:i,fieldConfig:r,t:o,required:m}=a,{name:f,label:s,validation:n}=r;return l(d,{name:f,control:i,rules:n?c(n):void 0,render:({field:e,fieldState:t})=>l(g,{ref:e.ref,name:e.name,onBlur:e.onBlur,label:o(s),info:v(r,o),value:typeof e.value=="string"?e.value:"",onChange:u=>e.onChange(p(u.target.value)),error:t.error?.message,helperText:t.error?.message,required:m})})}export{C as ControlledPhoneField};
@@ -1 +1 @@
1
- "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{RatingFieldComponent as c}from"../../form/fields";import{convertValidationRules as g}from"../types";function x(l){const{control:t,fieldConfig:o,t:m,required:s}=l,{name:d,label:f,validation:e}=o,r=(o.options||{}).fieldSpecific;return a(p,{name:d,control:t,rules:e?g(e):void 0,render:({field:i,fieldState:n})=>a(c,{label:m(f),value:i.value??0,onChange:u=>{i.onChange(u)},error:!!n.error,helperText:n.error?.message,required:s,max:r?.max??e?.max??5,showValue:r?.showValue})})}export{x as ControlledRatingField};
1
+ "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{RatingFieldComponent as c}from"../../form/fields";import{convertValidationRules as g}from"../types";function x(t){const{control:n,fieldConfig:o,t:m,required:s}=t,{name:d,label:f,validation:e}=o,r=(o.options||{}).fieldSpecific;return a(p,{name:d,control:n,rules:e?g(e):void 0,render:({field:i,fieldState:l})=>a(c,{label:m(f),value:i.value??0,onChange:u=>{i.onChange(u)},error:!!l.error,helperText:l.error?.message,required:s,max:r?.max??e?.max??5,showValue:r?.showValue})})}export{x as ControlledRatingField};
@@ -1 +1 @@
1
- "use client";import{jsx as d}from"react/jsx-runtime";import{Controller as L}from"react-hook-form";import{SwitchFieldComponent as S}from"../../form/fields";import{fieldSpecificOf as v}from"../fieldOptions";function x(h){const{control:f,fieldConfig:c,t:o,onChange:l}=h,{name:m,label:s}=c,e=v(c),u=e?.uncheckedValue??!1,r=e?.checkedValue??!0,t=e?.uncheckedLabel,a=e?.checkedLabel;return d(L,{name:m,control:f,render:({field:{value:k,onChange:p},fieldState:C})=>{const g=k===r,b=n=>{const i=n?r:u;p(i),l&&l(i)};return d(S,{label:o(s),checked:g,onChange:n=>b(n.target.checked),uncheckedLabel:t?o(t):void 0,checkedLabel:a?o(a):void 0,helperText:C.error?.message})}})}export{x as ControlledSwitchField};
1
+ "use client";import{jsx as d}from"react/jsx-runtime";import{Controller as L}from"react-hook-form";import{SwitchFieldComponent as S}from"../../form/fields";import{fieldSpecificOf as v}from"../fieldOptions";function x(h){const{control:f,fieldConfig:n,t:o,onChange:l}=h,{name:m,label:s}=n,e=v(n),u=e?.uncheckedValue??!1,r=e?.checkedValue??!0,t=e?.uncheckedLabel,a=e?.checkedLabel;return d(L,{name:m,control:f,render:({field:{value:k,onChange:p},fieldState:b})=>{const g=k===r,C=c=>{const i=c?r:u;p(i),l&&l(i)};return d(S,{label:o(s),checked:g,onChange:c=>C(c.target.checked),uncheckedLabel:t?o(t):void 0,checkedLabel:a?o(a):void 0,helperText:b.error?.message})}})}export{x as ControlledSwitchField};
@@ -1 +1 @@
1
- "use client";import{jsx as p}from"react/jsx-runtime";import{useMemo as u}from"react";import{Controller as x,useWatch as y}from"react-hook-form";import{translateLabel as R}from"../../../forms/utils";import{RadioFieldComponent as q}from"../../form/fields";import{convertValidationRules as F}from"../types";function O(m){const{control:a,fieldConfig:t,t:i,required:c}=m,{name:v,label:g,validation:o}=t,s="dependsOn"in t?t.dependsOn:void 0,r=s?s.field:void 0,b=typeof o?.options=="function",d=y({control:a,name:r,disabled:!r}),f=u(()=>{const e=o?.options;if(!e)return[];if(typeof e=="function"){const n=r?{[r]:d}:{};return e(n)}return e},[o?.options,b,r,d]),C=u(()=>f.map(e=>({value:String(e.value),label:R(e.label,i)})),[f,i]);return p(x,{name:v,control:a,rules:o?F(o):void 0,render:({field:e,fieldState:n})=>p(q,{...e,label:i(g),value:e.value??void 0,onChange:l=>{const h=typeof l=="string"?l:l.target.value;e.onChange(h)},options:C,error:!!n.error,helperText:n.error?.message,required:c})})}export{O as ControlledRadioField};
1
+ "use client";import{jsx as p}from"react/jsx-runtime";import{useMemo as u}from"react";import{Controller as x,useWatch as y}from"react-hook-form";import{translateLabel as R}from"../../../forms/utils";import{RadioFieldComponent as q}from"../../form/fields";import{convertValidationRules as F}from"../types";function O(m){const{control:l,fieldConfig:n,t:i,required:c}=m,{name:v,label:g,validation:o}=n,s="dependsOn"in n?n.dependsOn:void 0,r=s?s.field:void 0,b=typeof o?.options=="function",d=y({control:l,name:r,disabled:!r}),f=u(()=>{const e=o?.options;if(!e)return[];if(typeof e=="function"){const t=r?{[r]:d}:{};return e(t)}return e},[o?.options,b,r,d]),C=u(()=>f.map(e=>({value:String(e.value),label:R(e.label,i)})),[f,i]);return p(x,{name:v,control:l,rules:o?F(o):void 0,render:({field:e,fieldState:t})=>p(q,{...e,label:i(g),value:e.value??void 0,onChange:a=>{const h=typeof a=="string"?a:a.target.value;e.onChange(h)},options:C,error:!!t.error,helperText:t.error?.message,required:c})})}export{O as ControlledRadioField};
@@ -1 +1 @@
1
- "use client";function i(e){if(e){if(e instanceof RegExp)return e;try{const t=/^\/(.*)\/([gimyus]*)$/.exec(e);if(t){const[,r,n]=t;if(r)return new RegExp(r,n)}return new RegExp(e)}catch{return}}}function a(e){if(!e)return{};const t={};return e.required!==void 0&&(t.required=e.required),e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),e.minLength!==void 0&&(t.minLength=e.minLength),e.maxLength!==void 0&&(t.maxLength=e.maxLength),e.pattern&&typeof e.pattern=="string"&&(t.pattern={value:i(e.pattern)||/.*/,message:"Invalid format"}),t}export{i as convertPatternToRegex,a as convertValidationRules};
1
+ "use client";function i(n){if(n){if(n instanceof RegExp)return n;try{const t=/^\/(.*)\/([gimyus]*)$/.exec(n);if(t){const[,r,e]=t;if(r)return new RegExp(r,e)}return new RegExp(n)}catch{return}}}function a(n){if(!n)return{};const t={};return n.required!==void 0&&(t.required=n.required),n.min!==void 0&&(t.min=n.min),n.max!==void 0&&(t.max=n.max),n.minLength!==void 0&&(t.minLength=n.minLength),n.maxLength!==void 0&&(t.maxLength=n.maxLength),n.pattern&&typeof n.pattern=="string"&&(t.pattern={value:i(n.pattern)||/.*/,message:"Invalid format"}),t}export{i as convertPatternToRegex,a as convertValidationRules};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{Avatar as n,Text as p}from"@donotdev/components";const l=({config:a,value:s,t:d,className:t,size:r="md"})=>{if(!s)return e(p,{as:"span",variant:"muted",className:t,children:"-"});const i={sm:"size-touch",md:"size-touch",lg:"h-16 w-16"},c=m=>m.split(" ").map(o=>o.charAt(0)).slice(0,2).join("").toUpperCase();return e(n,{src:s,alt:a.label||"Avatar",fallback:c(a.label||"AV"),className:`${i[r]} ${t||""}`})};var u=l;export{l as AvatarFieldDisplay,u as default};
1
+ import{jsx as t}from"react/jsx-runtime";import{Avatar as n,Text as p}from"@donotdev/components";const l=({config:a,value:s,t:d,className:e,size:r="md"})=>{if(!s)return t(p,{as:"span",variant:"muted",className:e,children:"-"});const i={sm:"size-touch",md:"size-touch",lg:"h-16 w-16"},c=m=>m.split(" ").map(o=>o.charAt(0)).slice(0,2).join("").toUpperCase();return t(n,{src:s,alt:a.label||"Avatar",fallback:c(a.label||"AV"),className:`${i[r]} ${e||""}`})};var u=l;export{l as AvatarFieldDisplay,u as default};
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{Badge as t,Text as c}from"@donotdev/components";const n=({config:m,value:a,t:o,className:e})=>{if(a==null)return s(c,{as:"span",variant:"muted",className:e,children:"-"});const r=o(a?"common.yes":"common.no");return s(t,{variant:a?"default":"secondary",className:e,children:r})};var l=n;export{n as CheckboxFieldDisplay,l as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{Badge as t,Text as c}from"@donotdev/components";const n=({config:m,value:a,t:r,className:s})=>{if(a==null)return e(c,{as:"span",variant:"muted",className:s,children:"-"});const o=r(a?"common.yes":"common.no");return e(t,{variant:a?"default":"secondary",className:s,children:o})};var l=n;export{n as CheckboxFieldDisplay,l as default};
@@ -1 +1 @@
1
- import{jsx as a,jsxs as d}from"react/jsx-runtime";import{Text as e,Spinner as p}from"@donotdev/components";import{getI18nInstance as u}from"@donotdev/core";const i=({config:c,value:t,t:g,className:s,loading:m=!1})=>{if(m)return a(p,{className:s});if(!t)return a(e,{as:"span",variant:"muted",className:s,children:"-"});try{const n=new Date(t),r=u()?.language,l=n.toLocaleDateString(r),o=n.toLocaleTimeString(r);return c.type==="date"?a(e,{as:"span",className:s,children:l}):d("div",{className:s,children:[a(e,{as:"span",children:l}),a(e,{as:"span",variant:"muted",level:"small",children:o})]})}catch{return a(e,{as:"span",variant:"muted",className:s,children:"-"})}};var f=i;export{i as DateFieldDisplay,f as default};
1
+ import{jsx as a,jsxs as d}from"react/jsx-runtime";import{Text as s,Spinner as p}from"@donotdev/components";import{getI18nInstance as u}from"@donotdev/core";const i=({config:c,value:n,t:g,className:e,loading:m=!1})=>{if(m)return a(p,{className:e});if(!n)return a(s,{as:"span",variant:"muted",className:e,children:"-"});try{const t=new Date(n),r=u()?.language,l=t.toLocaleDateString(r),o=t.toLocaleTimeString(r);return c.type==="date"?a(s,{as:"span",className:e,children:l}):d("div",{className:e,children:[a(s,{as:"span",children:l}),a(s,{as:"span",variant:"muted",level:"small",children:o})]})}catch{return a(s,{as:"span",variant:"muted",className:e,children:"-"})}};var f=i;export{i as DateFieldDisplay,f as default};
@@ -1 +1 @@
1
- import{jsx as s,jsxs as i}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as t,Text as l,Stack as c}from"@donotdev/components";const r=({config:m,value:a,t:o,className:e})=>a?i(c,{direction:"row",align:"center",className:e,children:[s(l,{as:"span",level:"small",children:a.name}),a.size&&i(n,{variant:t.SECONDARY,children:[(a.size/1024).toFixed(1)," KB"]})]}):s(l,{as:"span",variant:"muted",className:e,children:"-"});var d=r;export{r as FileFieldDisplay,d as default};
1
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as t,Text as l,Stack as c}from"@donotdev/components";const r=({config:m,value:a,t:o,className:s})=>a?i(c,{direction:"row",align:"center",className:s,children:[e(l,{as:"span",level:"small",children:a.name}),a.size&&i(n,{variant:t.SECONDARY,children:[(a.size/1024).toFixed(1)," KB"]})]}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var d=r;export{r as FileFieldDisplay,d as default};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{Text as i}from"@donotdev/components";const o=({config:l,value:e,t:r,className:n})=>{if(!e)return t(i,{as:"span",variant:"muted",className:n,children:"-"});const s=(()=>{switch(l.type){case"email":return{href:`mailto:${e}`,"aria-label":r("common.sendEmailTo",{email:e})};case"tel":return{href:`tel:${e}`,"aria-label":r("common.callNumber",{number:e})};default:return{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":r("common.openLink")}}})();return t("a",{...s,className:n||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none",children:e})};var c=o;export{o as LinkFieldDisplay,c as default};
1
+ import{jsx as n}from"react/jsx-runtime";import{Text as i}from"@donotdev/components";const o=({config:l,value:e,t:r,className:t})=>{if(!e)return n(i,{as:"span",variant:"muted",className:t,children:"-"});const s=(()=>{switch(l.type){case"email":return{href:`mailto:${e}`,"aria-label":r("common.sendEmailTo",{email:e})};case"tel":return{href:`tel:${e}`,"aria-label":r("common.callNumber",{number:e})};default:return{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":r("common.openLink")}}})();return n("a",{...s,className:t||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none",children:e})};var c=o;export{o as LinkFieldDisplay,c as default};
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{Text as e,Spinner as o}from"@donotdev/components";import{getI18nInstance as r}from"@donotdev/core";const l=({config:i,value:n,t:c,className:a,loading:t=!1})=>t?s(o,{className:a}):n==null?s(e,{as:"span",variant:"muted",className:a,children:"-"}):s(e,{as:"span",className:`font-mono ${a||""}`,children:n.toLocaleString(r()?.language)});var m=l;export{l as NumberFieldDisplay,m as default};
1
+ import{jsx as s}from"react/jsx-runtime";import{Text as n,Spinner as r}from"@donotdev/components";import{getI18nInstance as t}from"@donotdev/core";const l=({config:i,value:e,t:c,className:a,loading:o=!1})=>o?s(r,{className:a}):e==null?s(n,{as:"span",variant:"muted",className:a,children:"-"}):s(n,{as:"span",className:`font-mono ${a||""}`,children:e.toLocaleString(t()?.language)});var m=l;export{l as NumberFieldDisplay,m as default};
@@ -1 +1 @@
1
- import{jsx as o,jsxs as i}from"react/jsx-runtime";import{Eye as c,EyeOff as n}from"lucide-react";import{useState as u}from"react";import{Skeleton as m,Button as y,CopyToClipboard as f,Stack as t}from"@donotdev/components";const l=({config:g,value:e,t:r,className:s,loading:d=!1})=>{const[a,p]=u(!1);return d?o(m,{className:s}):e?i(t,{direction:"row",align:"center",className:s,children:[o("span",{style:{fontFamily:"monospace"},children:a?e:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),i(t,{direction:"row",align:"center",gap:"tight",children:[o(y,{type:"button",onClick:()=>p(!a),"aria-label":a?"Hide password":"Show password",children:a?o(n,{}):o(c,{})}),o(f,{text:e,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyPassword")||"Copy password"})]})]}):o("div",{style:{color:"var(--muted-foreground)"},children:"-"})};var w=l;export{l as PasswordFieldDisplay,w as default};
1
+ import{jsx as o,jsxs as i}from"react/jsx-runtime";import{Eye as d,EyeOff as n}from"lucide-react";import{useState as u}from"react";import{Skeleton as m,Button as y,CopyToClipboard as f,Stack as r}from"@donotdev/components";const l=({config:g,value:e,t,className:s,loading:p=!1})=>{const[a,c]=u(!1);return p?o(m,{className:s}):e?i(r,{direction:"row",align:"center",className:s,children:[o("span",{style:{fontFamily:"monospace"},children:a?e:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),i(r,{direction:"row",align:"center",gap:"tight",children:[o(y,{type:"button",onClick:()=>c(!a),"aria-label":a?"Hide password":"Show password",children:a?o(n,{}):o(d,{})}),o(f,{text:e,tooltipText:t("copyToClipboard")||"Copy to clipboard",copiedTooltipText:t("copied")||"Copied!",ariaLabel:t("copyPassword")||"Copy password"})]})]}):o("div",{style:{color:"var(--muted-foreground)"},children:"-"})};var w=l;export{l as PasswordFieldDisplay,w as default};
@@ -1 +1 @@
1
- import{jsx as 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 e}from"react/jsx-runtime";import{Badge as i,BADGE_VARIANT as n,Text as l}from"@donotdev/components";const r=({config:c,value:a,t:d,className:s})=>{if(!a)return e(l,{as:"span",variant:"muted",className:s,children:"-"});const t=a.displayName||a.name||a.id||a;return e(i,{variant:n.OUTLINE,className:s,children:String(t)})};var m=r;export{r as ReferenceFieldDisplay,m as default};
@@ -1 +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 e}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const r=({config:i,value:a,t:m,className:s})=>a?e(l,{as:"div",level:"small",className:`whitespace-pre-wrap ${s||""}`,children:a}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var t=r;export{r as TextAreaDisplay,t as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as L,Calendar as k,Clock as I}from"lucide-react";import{useState as A}from"react";import{Skeleton as T,Badge as B,BADGE_VARIANT as E,Text as l,cn as f,CopyToClipboard as x,Stack as i}from"@donotdev/components";import{getWeekFromISOString as M,getI18nInstance as b}from"@donotdev/core";const C=({config:o,value:a,t:r,className:s,loading:v=!1,showCopy:m=!1,asBadge:w=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[j,g]=A(!1),F=async()=>{try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(o.type){case"email":return e(L,{});case"month":case"week":return e(k,{});case"time":return e(I,{});default:return null}},S=t=>{if(!t)return null;switch(o.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:u=>u.currentTarget.style.textDecoration="underline",onMouseLeave:u=>u.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(b()?.language,{year:"numeric",month:"long"});case"week":return M(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(b()?.language);default:return t}},D=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(v)return n(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 N=S(a),y=D(String(N));return w?n(i,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]}):n(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})}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]})]})};var V=C;export{C as TextFieldDisplay,V as default};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as L,Calendar as k,Clock as I}from"lucide-react";import{useState as A}from"react";import{Skeleton as T,Badge as B,BADGE_VARIANT as E,Text as l,cn as f,CopyToClipboard as x,Stack as o}from"@donotdev/components";import{getWeekFromISOString as M,getI18nInstance as b}from"@donotdev/core";const C=({config:i,value:a,t:r,className:s,loading:v=!1,showCopy:m=!1,asBadge:w=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[j,g]=A(!1),F=async()=>{try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(i.type){case"email":return e(L,{});case"month":case"week":return e(k,{});case"time":return e(I,{});default:return null}},S=t=>{if(!t)return null;switch(i.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:u=>u.currentTarget.style.textDecoration="underline",onMouseLeave:u=>u.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(b()?.language,{year:"numeric",month:"long"});case"week":return M(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(b()?.language);default:return t}},D=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(v)return n(o,{gap:"tight",children:[p&&e(T,{style:{height:"1rem",width:"6rem"}}),e(T,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!a)return n(o,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:i.label||i.name}),e(l,{as:"span",variant:"muted",className:f(s),style:{fontStyle:"italic"},children:r("common.noValue",{defaultValue:"No value"})})]});const N=S(a),y=D(String(N));return w?n(o,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]}):n(o,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:i.label||i.name}),n(o,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:f("dndev-flex-1",c&&"truncate",s),title:c&&a.length>d?a:void 0,children:e(l,{as:"span",children:y})}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]})]})};var V=C;export{C as TextFieldDisplay,V as default};
@@ -1 +1 @@
1
- import{jsx as 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 p,Input as u,cn as f,Stack as n}from"@donotdev/components";const s=({config:r,value:t,onChange:c,error:A,helperText:l,t:i,className:d,...v})=>{const h=a=>a.split(" ").map(m=>m.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(p,{src:t,alt:r.label||"Avatar",fallback:h(r.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(u,{type:"url",className:f("dndev-w-full",d),placeholder:i("common.enterAvatarUrl"),value:t,onChange:a=>c(a.target.value),...v})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var g=s;export{s as AvatarFieldComponent,g as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Badge as 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 r}from"react/jsx-runtime";import{Badge as v,Input as f,cn as g,Stack as o}from"@donotdev/components";const l=({config:p,value:a,onChange:d,error:u,helperText:t,t:n,variant:s="default",className:i,...c})=>r(o,{children:[r(o,{direction:"row",align:"center",children:[e(v,{variant:s,style:{minWidth:0},children:a||n("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",i),placeholder:n("common.enterBadgeText"),value:a,onChange:m=>d(m.target.value),...c})})]}),t&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:t})]});var h=l;export{l as BadgeFieldComponent,h as default};
@@ -1 +1 @@
1
- import{jsx as 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 r}from"react/jsx-runtime";import{Button as e}from"@donotdev/components";const n=({label:a,type:t,onClick:o,variant:i,disabled:l=!1})=>r(e,{type:t,onClick:o,variant:i,disabled:l,children:a});var s=n;export{s as default};
@@ -1 +1 @@
1
- {"version":3,"file":"DateFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DateFieldComponent.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAUxD,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAQD;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CA8M9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"DateFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DateFieldComponent.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAWxD,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAQD;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CAiN9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- import{jsx as o,jsxs as s}from"react/jsx-runtime";import{useId as z}from"react";import{DatePicker as b,DateTimePicker as x,Input as y,cn as p,Stack as c}from"@donotdev/components";function w(i){const n=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${n(i.getMonth()+1)}-${n(i.getDate())}T${n(i.getHours())}:${n(i.getMinutes())}`}const I=({label:i,info:n,value:u,onChange:v,error:g,helperText:a,mode:l="date",required:h,...f})=>{const r=z(),e=!!g,S=t=>{const m=t.target.value?new Date(t.target.value).toISOString():null;v(m)},$=t=>{v(t?new Date(t).toISOString():null)};let d="";if(u){const t=new Date(u);l==="date"?d=t.toISOString().split("T")[0]||"":l==="datetime-local"?d=w(t):l==="month"?d=t.toISOString().slice(0,7):l==="time"?d=t.toISOString().slice(11,16):l==="week"&&(d=t.toISOString().split("T")[0]||"")}return l==="date"?s(c,{gap:"tight",children:[o(b,{id:r,label:i,info:n,value:u??null,onChange:v,required:h,"aria-describedby":p(e&&`${r}-error`,a&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),g]}),a&&!e&&o("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]}):l==="datetime-local"?s(c,{gap:"tight",children:[o(x,{id:r,label:i,info:n,value:d||null,onChange:$,required:h,"aria-describedby":p(e&&`${r}-error`,a&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),g]}),a&&!e&&o("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]}):s(c,{gap:"tight",children:[o(y,{id:r,label:i,info:n,type:l,value:d,onChange:S,required:h,"aria-describedby":p(e&&`${r}-error`,a&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...f}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),g]}),a&&!e&&o("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})};var D=I;export{D as default};
1
+ import{jsx as n,jsxs as s}from"react/jsx-runtime";import{useId as z}from"react";import{DatePicker as x,DateTimePicker as y,Input as w,cn as p,Stack as c}from"@donotdev/components";import{useTranslation as I}from"@donotdev/core";function D(a){const o=u=>String(u).padStart(2,"0");return`${a.getFullYear()}-${o(a.getMonth()+1)}-${o(a.getDate())}T${o(a.getHours())}:${o(a.getMinutes())}`}const O=({label:a,info:o,value:u,onChange:v,error:g,helperText:i,mode:l="date",required:h,...S})=>{const r=z(),e=!!g,{t:f}=I("crud"),m=t=>{const b=t.target.value?new Date(t.target.value).toISOString():null;v(b)},$=t=>{v(t?new Date(t).toISOString():null)};let d="";if(u){const t=new Date(u);l==="date"?d=t.toISOString().split("T")[0]||"":l==="datetime-local"?d=D(t):l==="month"?d=t.toISOString().slice(0,7):l==="time"?d=t.toISOString().slice(11,16):l==="week"&&(d=t.toISOString().split("T")[0]||"")}return l==="date"?s(c,{gap:"tight",children:[n(x,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:o,value:u??null,onChange:v,required:h,"aria-describedby":p(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):l==="datetime-local"?s(c,{gap:"tight",children:[n(y,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:o,value:d||null,onChange:$,required:h,"aria-describedby":p(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):s(c,{gap:"tight",children:[n(w,{id:r,label:a,info:o,type:l,value:d,onChange:m,required:h,"aria-describedby":p(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...S}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})};var T=O;export{T as default};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as n,Fragment as K}from"react/jsx-runtime";import{Upload as V,X as _,FileText as u,FileSpreadsheet as J,File as Q,Loader2 as Y,Eye as Z}from"lucide-react";import{useState as D,useRef as $,useImperativeHandle as ee,forwardRef as ae}from"react";import{Button as k,BUTTON_VARIANT as C,Text as s,Stack as m,Progress as re,Dialog as te,DialogContent as ne,DialogHeader as ie,DialogTitle as le}from"@donotdev/components";import{handleError as y,useTranslation as oe}from"@donotdev/core";import{useFileUpload as se}from"../../../hooks/useFileUpload";import{uploadFile as de,deleteFile as ce,getFileIcon as pe,formatFileSize as me,getDocumentAcceptString as ue}from"../../../utils/fileStorage";const ve=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],fe=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"];function ge({type:d,className:i}){switch(d){case"pdf":return a(u,{className:i,style:{color:"var(--destructive)"}});case"doc":return a(u,{className:i,style:{color:"var(--primary)"}});case"xls":return a(J,{className:i,style:{color:"var(--success)"}});case"ppt":return a(u,{className:i,style:{color:"var(--warning)"}});case"text":case"html":return a(u,{className:i});default:return a(Q,{className:i})}}function z(d){const i="."+d.name.split(".").pop()?.toLowerCase();return ve.includes(i)}const P=ae(({name:d="document",label:i,value:S,onChange:A,error:v,helperText:x,multiple:f=!1,maxFiles:L=10,maxSize:E=25*1024*1024,storagePath:w,required:I,enablePreview:b=!0},O)=>{const{t:l}=oe("crud"),[N,g]=D(!1),[h,T]=D(null),c=$(null),H=ue();function M(e,r){return de(e,{storagePath:w,onProgress:t=>r(t.progress)})}const{files:o,addFiles:F,removeFile:R}=se({name:d,value:S,onChange:A,multiple:f,maxFiles:L,maxSize:E,accept:fe,storagePath:w,uploadFn:M});ee(O,()=>({upload:async()=>{},getDocuments:()=>o}),[o]);function W(e){const r=Array.from(e.target.files||[]);if(r.length>0){const t=r.filter(p=>z(p)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:p.name}),severity:"warning",showNotification:!0}),!1));t.length>0&&F(t)}c.current&&(c.current.value="")}function j(e){e.preventDefault(),g(!1);const r=Array.from(e.dataTransfer.files).filter(t=>z(t)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:t.name}),severity:"warning",showNotification:!0}),!1));r.length>0&&F(r)}async function B(e){const r=o.find(t=>t.id===e);if(r)try{r.uploaded&&"url"in r.uploaded&&await ce(r.uploaded),R(e)}catch(t){y(t,{userMessage:l("document.delete.failed"),severity:"error",showNotification:!0})}}function U(e){if(e.uploaded&&"url"in e.uploaded){const r=e.uploaded;r.mimeType==="application/pdf"&&T(r.url)}}const G=f||o.length===0;return n(K,{children:[n(m,{gap:"tight",children:[n(s,{level:"body",textAlign:"start",children:[i,I?"*":""]}),G&&n("div",{role:"button",tabIndex:0,"aria-label":l("document.upload.ariaLabel"),className:"dndev-surface","data-variant":v?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:N?"var(--primary)":v?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:N?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:j,onClick:()=>c.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c.current?.click())},children:[a("input",{ref:c,type:"file",accept:H,multiple:f,style:{display:"none"},onChange:W}),n(m,{align:"center",justify:"center",children:[a(V,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(s,{as:"p",variant:"muted",level:"small",textAlign:"center",children:l("document.upload.hint")}),a(s,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&a(m,{gap:"tight",children:o.map(e=>{const r=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,t=pe(r||"",e.file.name),p=e.status==="uploading",X=r==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf"),q=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ge,{type:t,className:"dndev-size-md"}),n(m,{gap:"none",style:{flex:1,minWidth:0},children:[a(s,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(s,{level:"caption",variant:"muted",children:[me(q),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),p&&a(re,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),n(m,{direction:"row",gap:"tight",children:[b&&X&&e.status==="complete"&&a(k,{variant:C.GHOST,onClick:()=>U(e),"aria-label":l("document.preview.ariaLabel"),children:a(Z,{className:"dndev-size-sm"})}),p?a(Y,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(k,{variant:C.GHOST,onClick:()=>B(e.id),"aria-label":l("document.delete.ariaLabel"),children:a(_,{className:"dndev-size-sm"})})]})]},e.id)})}),x&&a(s,{level:"caption",variant:v?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:x})]}),b&&h&&a(te,{open:!!h,onOpenChange:()=>T(null),children:n(ne,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[a(ie,{children:a(le,{children:l("document.preview.title")})}),a("iframe",{src:h,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});P.displayName="DocumentFieldComponent";var he=P;export{he as default};
1
+ "use client";import{jsx as a,jsxs as n,Fragment as K}from"react/jsx-runtime";import{Upload as V,X as _,FileText as u,FileSpreadsheet as J,File as Q,Loader2 as Y,Eye as Z}from"lucide-react";import{useState as D,useRef as $,useImperativeHandle as ee,forwardRef as ae}from"react";import{Button as k,BUTTON_VARIANT as C,Text as s,Stack as m,Progress as re,Dialog as te,DialogContent as ne,DialogHeader as ie,DialogTitle as le}from"@donotdev/components";import{handleError as y,useTranslation as oe}from"@donotdev/core";import{useFileUpload as se}from"../../../hooks/useFileUpload";import{uploadFile as de,deleteFile as ce,getFileIcon as pe,formatFileSize as me,getDocumentAcceptString as ue}from"../../../utils/fileStorage";const ve=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],fe=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"];function ge({type:d,className:i}){switch(d){case"pdf":return a(u,{className:i,style:{color:"var(--destructive)"}});case"doc":return a(u,{className:i,style:{color:"var(--primary)"}});case"xls":return a(J,{className:i,style:{color:"var(--success)"}});case"ppt":return a(u,{className:i,style:{color:"var(--warning)"}});case"text":case"html":return a(u,{className:i});default:return a(Q,{className:i})}}function z(d){const i="."+d.name.split(".").pop()?.toLowerCase();return ve.includes(i)}const P=ae(({name:d="document",label:i,value:S,onChange:A,error:v,helperText:x,multiple:f=!1,maxFiles:L=10,maxSize:H=25*1024*1024,storagePath:w,required:I,enablePreview:b=!0},R)=>{const{t:l}=oe("crud"),[N,g]=D(!1),[h,T]=D(null),c=$(null),E=ue();function M(e,r){return de(e,{storagePath:w,onProgress:t=>r(t.progress)})}const{files:o,addFiles:F,removeFile:O}=se({name:d,value:S,onChange:A,multiple:f,maxFiles:L,maxSize:H,accept:fe,storagePath:w,uploadFn:M});ee(R,()=>({upload:async()=>{},getDocuments:()=>o}),[o]);function W(e){const r=Array.from(e.target.files||[]);if(r.length>0){const t=r.filter(p=>z(p)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:p.name}),severity:"warning",showNotification:!0}),!1));t.length>0&&F(t)}c.current&&(c.current.value="")}function j(e){e.preventDefault(),g(!1);const r=Array.from(e.dataTransfer.files).filter(t=>z(t)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:t.name}),severity:"warning",showNotification:!0}),!1));r.length>0&&F(r)}async function B(e){const r=o.find(t=>t.id===e);if(r)try{r.uploaded&&"url"in r.uploaded&&await ce(r.uploaded),O(e)}catch(t){y(t,{userMessage:l("document.delete.failed"),severity:"error",showNotification:!0})}}function U(e){if(e.uploaded&&"url"in e.uploaded){const r=e.uploaded;r.mimeType==="application/pdf"&&T(r.url)}}const G=f||o.length===0;return n(K,{children:[n(m,{gap:"tight",children:[n(s,{level:"body",textAlign:"start",children:[i,I?"*":""]}),G&&n("div",{role:"button",tabIndex:0,"aria-label":l("document.upload.ariaLabel"),className:"dndev-surface","data-variant":v?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:N?"var(--primary)":v?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:N?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:j,onClick:()=>c.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c.current?.click())},children:[a("input",{ref:c,type:"file",accept:E,multiple:f,style:{display:"none"},onChange:W}),n(m,{align:"center",justify:"center",children:[a(V,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(s,{as:"p",variant:"muted",level:"small",textAlign:"center",children:l("document.upload.hint")}),a(s,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&a(m,{gap:"tight",children:o.map(e=>{const r=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,t=pe(r||"",e.file.name),p=e.status==="uploading",X=r==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf"),q=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ge,{type:t,className:"dndev-size-md"}),n(m,{gap:"none",style:{flex:1,minWidth:0},children:[a(s,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(s,{level:"caption",variant:"muted",children:[me(q),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),p&&a(re,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),n(m,{direction:"row",gap:"tight",children:[b&&X&&e.status==="complete"&&a(k,{variant:C.GHOST,onClick:()=>U(e),"aria-label":l("document.preview.ariaLabel"),children:a(Z,{className:"dndev-size-sm"})}),p?a(Y,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(k,{variant:C.GHOST,onClick:()=>B(e.id),"aria-label":l("document.delete.ariaLabel"),children:a(_,{className:"dndev-size-sm"})})]})]},e.id)})}),x&&a(s,{level:"caption",variant:v?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:x})]}),b&&h&&a(te,{open:!!h,onOpenChange:()=>T(null),children:n(ne,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[a(ie,{children:a(le,{children:l("document.preview.title")})}),a("iframe",{src:h,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});P.displayName="DocumentFieldComponent";var he=P;export{he as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as d}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as k,useMemo as w}from"react";import{Label as S,Stack as u,Button as $,Slider as N}from"@donotdev/components";const f=[15,30,45,60,90,120,150,180],q={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 W(e,n){const o=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,s=q[e];return!n||!s?o:n(`crud:${s}`,{defaultValue:o})??o}const j=({label:e,value:n,onChange:o,error:s,helperText:l,disabled:m,required:p,readonly:M,min:g=0,max:v=480,step:T=5,t:i})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,c=f.includes(r),[h,b]=k(!c&&r>0),C=w(()=>f.map(a=>({minutes:a,label:W(a,i)})),[i]),y=i?i("crud:duration.custom"):"Custom";if(M){const a=r===0?i?i("crud:duration.zero"):"\u2014":r<60?i?i("crud:duration.minutes",{count:r}):`${r} min`:i?i("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return d(u,{gap:"tight",children:[t(S,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",children:[t(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),t("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),l&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})}return d(u,{children:[t(S,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[C.map(({minutes:a,label:z})=>d($,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),o(a)},"aria-pressed":r===a,"aria-label":z,children:[t(x,{size:14,style:{marginRight:"var(--gap-sm)"},"aria-hidden":!0}),z]},a)),t($,{type:"button",variant:h?"primary":"outline",disabled:m,onClick:()=>{b(!0),!c&&r>0?o(r):o(30)},"aria-pressed":h,"aria-label":y,children:y})]}),h&&t(u,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:t(N,{value:[c?30:r],onValueChange:([a])=>o(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:T,showValue:!0,disabled:m,"aria-label":e})}),l&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var E=j;export{f as DURATION_PRESETS,E as default};
1
+ import{jsx as o,jsxs as d}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as k,useMemo as w}from"react";import{Label as S,Stack as u,Button as $,Slider as N}from"@donotdev/components";const f=[15,30,45,60,90,120,150,180],q={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 W(e,n){const i=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,s=q[e];return!n||!s?i:n(`crud:${s}`,{defaultValue:i})??i}const j=({label:e,value:n,onChange:i,error:s,helperText:l,disabled:m,required:p,readonly:C,min:g=0,max:v=480,step:M=5,t})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,c=f.includes(r),[h,b]=k(!c&&r>0),T=w(()=>f.map(a=>({minutes:a,label:W(a,t)})),[t]),y=t?t("crud:duration.custom"):"Custom";if(C){const a=r===0?t?t("crud:duration.zero"):"\u2014":r<60?t?t("crud:duration.minutes",{count:r}):`${r} min`:t?t("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return d(u,{gap:"tight",children:[o(S,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",children:[o(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),o("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),l&&o("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})}return d(u,{children:[o(S,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[T.map(({minutes:a,label:z})=>d($,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),i(a)},"aria-pressed":r===a,"aria-label":z,children:[o(x,{size:14,style:{marginRight:"var(--gap-sm)"},"aria-hidden":!0}),z]},a)),o($,{type:"button",variant:h?"primary":"outline",disabled:m,onClick:()=>{b(!0),!c&&r>0?i(r):i(30)},"aria-pressed":h,"aria-label":y,children:y})]}),h&&o(u,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:o(N,{value:[c?30:r],onValueChange:([a])=>i(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:M,showValue:!0,disabled:m,"aria-label":e})}),l&&o("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var E=j;export{f as DURATION_PRESETS,E as default};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{Upload as B,X as M,File as U,Loader2 as E,FileText as g,FileSpreadsheet as H,FileImage as V,FileVideo as q,FileAudio as G,FileArchive as K,FileCode as W}from"lucide-react";import{useState as X,useRef as _,useImperativeHandle as J,forwardRef as Q}from"react";import{Button as Y,BUTTON_VARIANT as Z,Text as d,Stack as u,Progress as $}from"@donotdev/components";import{handleError as ee,useTranslation as ae}from"@donotdev/core";import{useFileUpload as re}from"../../../hooks/useFileUpload";import{uploadFile as le,deleteFile as se,getFileIcon as te,formatFileSize as ie}from"../../../utils/fileStorage";function ne({type:p,className:r}){switch(p){case"pdf":return a(g,{className:r,style:{color:"var(--destructive)"}});case"doc":return a(g,{className:r,style:{color:"var(--primary)"}});case"xls":return a(H,{className:r,style:{color:"var(--success)"}});case"ppt":return a(g,{className:r,style:{color:"var(--warning)"}});case"image":return a(V,{className:r});case"video":return a(q,{className:r});case"audio":return a(G,{className:r});case"archive":return a(K,{className:r});case"html":case"text":return a(W,{className:r});default:return a(U,{className:r})}}const b=Q(({name:p="file",label:r,value:T,onChange:w,error:m,helperText:h,accept:v,multiple:n=!1,maxFiles:k=10,maxSize:z=50*1024*1024,storagePath:y,required:D},S)=>{const{t:c}=ae("crud"),[x,f]=X(!1),o=_(null);function A(e,l){return le(e,{storagePath:y,onProgress:t=>l(t.progress)})}const{files:i,addFiles:F,removeFile:C}=re({name:p,value:T,onChange:w,multiple:n,maxFiles:k,maxSize:z,accept:v?[v]:[],storagePath:y,uploadFn:A});J(S,()=>({upload:async()=>{},getFiles:()=>i}),[i]);function I(e){const l=Array.from(e.target.files||[]);l.length>0&&F(l),o.current&&(o.current.value="")}function L(e){e.preventDefault(),f(!1),F(Array.from(e.dataTransfer.files))}async function P(e){const l=i.find(t=>t.id===e);if(l)try{l.uploaded&&"url"in l.uploaded&&await se(l.uploaded),C(e)}catch(t){ee(t,{userMessage:c("file.delete.failed"),severity:"error",showNotification:!0})}}const R=n||i.length===0;return s(u,{gap:"tight",children:[s(d,{level:"body",textAlign:"start",children:[r,D?"*":""]}),R&&s("div",{role:"button",tabIndex:0,"aria-label":c(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":m?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:x?"var(--primary)":m?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:x?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:L,onClick:()=>o.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),o.current?.click())},children:[a("input",{ref:o,type:"file",accept:v,multiple:n,style:{display:"none"},onChange:I}),s(u,{align:"center",justify:"center",children:[a(B,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(d,{as:"p",variant:"muted",level:"small",textAlign:"center",children:c(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),i.length>0&&a(u,{gap:"tight",children:i.map((e,l)=>{const t=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,O=te(t||"",e.file.name),N=e.status==="uploading",j=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return s("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ne,{type:O,className:"dndev-size-md"}),s(u,{gap:"none",style:{flex:1,minWidth:0},children:[a(d,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),s(d,{level:"caption",variant:"muted",children:[ie(j),e.error&&s("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),N&&a($,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),N?a(E,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(Y,{variant:Z.GHOST,onClick:()=>P(e.id),"aria-label":c("file.delete.ariaLabel"),children:a(M,{className:"dndev-size-sm"})})]},e.id)})}),h&&a(d,{level:"caption",variant:m?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:h})]})});b.displayName="FileFieldComponent";var oe=b;export{oe as default};
1
+ "use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{Upload as B,X as M,File as U,Loader2 as E,FileText as g,FileSpreadsheet as H,FileImage as V,FileVideo as q,FileAudio as G,FileArchive as K,FileCode as W}from"lucide-react";import{useState as X,useRef as _,useImperativeHandle as J,forwardRef as Q}from"react";import{Button as Y,BUTTON_VARIANT as Z,Text as d,Stack as u,Progress as $}from"@donotdev/components";import{handleError as ee,useTranslation as ae}from"@donotdev/core";import{useFileUpload as re}from"../../../hooks/useFileUpload";import{uploadFile as le,deleteFile as se,getFileIcon as te,formatFileSize as ie}from"../../../utils/fileStorage";function ne({type:p,className:r}){switch(p){case"pdf":return a(g,{className:r,style:{color:"var(--destructive)"}});case"doc":return a(g,{className:r,style:{color:"var(--primary)"}});case"xls":return a(H,{className:r,style:{color:"var(--success)"}});case"ppt":return a(g,{className:r,style:{color:"var(--warning)"}});case"image":return a(V,{className:r});case"video":return a(q,{className:r});case"audio":return a(G,{className:r});case"archive":return a(K,{className:r});case"html":case"text":return a(W,{className:r});default:return a(U,{className:r})}}const b=Q(({name:p="file",label:r,value:T,onChange:w,error:m,helperText:h,accept:v,multiple:n=!1,maxFiles:k=10,maxSize:z=50*1024*1024,storagePath:y,required:C},S)=>{const{t:c}=ae("crud"),[x,f]=X(!1),o=_(null);function A(e,l){return le(e,{storagePath:y,onProgress:t=>l(t.progress)})}const{files:i,addFiles:F,removeFile:D}=re({name:p,value:T,onChange:w,multiple:n,maxFiles:k,maxSize:z,accept:v?[v]:[],storagePath:y,uploadFn:A});J(S,()=>({upload:async()=>{},getFiles:()=>i}),[i]);function I(e){const l=Array.from(e.target.files||[]);l.length>0&&F(l),o.current&&(o.current.value="")}function L(e){e.preventDefault(),f(!1),F(Array.from(e.dataTransfer.files))}async function P(e){const l=i.find(t=>t.id===e);if(l)try{l.uploaded&&"url"in l.uploaded&&await se(l.uploaded),D(e)}catch(t){ee(t,{userMessage:c("file.delete.failed"),severity:"error",showNotification:!0})}}const R=n||i.length===0;return s(u,{gap:"tight",children:[s(d,{level:"body",textAlign:"start",children:[r,C?"*":""]}),R&&s("div",{role:"button",tabIndex:0,"aria-label":c(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":m?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:x?"var(--primary)":m?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:x?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:L,onClick:()=>o.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),o.current?.click())},children:[a("input",{ref:o,type:"file",accept:v,multiple:n,style:{display:"none"},onChange:I}),s(u,{align:"center",justify:"center",children:[a(B,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(d,{as:"p",variant:"muted",level:"small",textAlign:"center",children:c(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),i.length>0&&a(u,{gap:"tight",children:i.map((e,l)=>{const t=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,O=te(t||"",e.file.name),N=e.status==="uploading",j=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return s("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ne,{type:O,className:"dndev-size-md"}),s(u,{gap:"none",style:{flex:1,minWidth:0},children:[a(d,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),s(d,{level:"caption",variant:"muted",children:[ie(j),e.error&&s("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),N&&a($,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),N?a(E,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(Y,{variant:Z.GHOST,onClick:()=>P(e.id),"aria-label":c("file.delete.ariaLabel"),children:a(M,{className:"dndev-size-sm"})})]},e.id)})}),h&&a(d,{level:"caption",variant:m?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:h})]})});b.displayName="FileFieldComponent";var oe=b;export{oe as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as g}from"react";import{Checkbox as D,Label as H,Sheet as f,Text as P}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";import{InlineFieldRow as j}from"./internal/InlineFieldRow";const F=({checked:l=!1,onChange:a,required:y,privacyPolicyPath:s="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:r}=S("crud"),[u,d]=g(!1),[x,h]=g(!1),p=e=>{a&&a({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!l))},m=(e,k)=>{e.preventDefault(),k==="privacy"?d(!0):h(!0)},C=r("gdprConsent.consent"),i=r("gdprConsent.privacyPolicy"),n=r("gdprConsent.terms"),b=r("gdprConsent.and");return o(w,{children:[o(j,{children:[t(D,{checked:l,onCheckedChange:p}),t(H,{required:y,plain:!0,onClick:v,style:{cursor:"pointer"},children:o(P,{level:"body",style:{fontSize:"var(--font-size-input)"},children:[C," ",t("a",{href:s,onClick:e=>m(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," / ",t("a",{href:c,onClick:e=>m(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:n})," ",b]})})]}),t(f,{open:u,onOpenChange:d,side:"bottom",title:i,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:i})}),t(f,{open:x,onOpenChange:h,side:"bottom",title:n,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:n})})]})};var O=F;export{O as default};
1
+ import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as g}from"react";import{Checkbox as D,Label as H,Sheet as f,Text as P}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";import{InlineFieldRow as j}from"./internal/InlineFieldRow";const F=({checked:l=!1,onChange:a,required:y,privacyPolicyPath:s="/legal/privacy",termsPath:h="/legal/terms"})=>{const{t:r}=S("crud"),[u,c]=g(!1),[x,d]=g(!1),p=e=>{a&&a({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!l))},m=(e,k)=>{e.preventDefault(),k==="privacy"?c(!0):d(!0)},C=r("gdprConsent.consent"),i=r("gdprConsent.privacyPolicy"),n=r("gdprConsent.terms"),b=r("gdprConsent.and");return o(w,{children:[o(j,{children:[t(D,{checked:l,onCheckedChange:p}),t(H,{required:y,plain:!0,onClick:v,style:{cursor:"pointer"},children:o(P,{level:"body",style:{fontSize:"var(--font-size-input)"},children:[C," ",t("a",{href:s,onClick:e=>m(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," / ",t("a",{href:h,onClick:e=>m(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:n})," ",b]})})]}),t(f,{open:u,onOpenChange:c,side:"bottom",title:i,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:i})}),t(f,{open:x,onOpenChange:d,side:"bottom",title:n,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:h,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:n})})]})};var O=F;export{O as default};
@@ -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 p=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)}},m=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:p,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:m,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 a,jsxs as u}from"react/jsx-runtime";import{Label as b,Input as v,Stack as g}from"@donotdev/components";const h=({label:c,value:t={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:m})=>{const p=n=>{const e=parseFloat(n.target.value)||0;if(e>=-90&&e<=90){const l={...t,lat:e},s={target:{value:JSON.stringify(l)}};i(s)}},f=n=>{const e=parseFloat(n.target.value)||0;if(e>=-180&&e<=180){const l={...t,lng:e},s={target:{value:JSON.stringify(l)}};i(s)}};return u(g,{gap:"tight",children:[a(b,{required:m,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:c}),u(g,{direction:"row",children:[a(v,{label:"Latitude",type:"number",value:t.lat,onChange:p,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),a(v,{label:"Longitude",type:"number",value:t.lng,onChange:f,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&a("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var y=h;export{y as default};
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as s,Fragment as Z}from"react/jsx-runtime";import{DndContext as _,closestCenter as Q,PointerSensor as ee,TouchSensor as re,useSensor as A,useSensors as te}from"@dnd-kit/core";import{SortableContext as oe,useSortable as ie,rectSortingStrategy as ae,arrayMove as ne}from"@dnd-kit/sortable";import{CSS as se}from"@dnd-kit/utilities";import{Upload as le,X as U,Loader2 as de,GripVertical as ce}from"lucide-react";import{forwardRef as pe,useCallback as P,useImperativeHandle as ue,useRef as ge,useState as j}from"react";import{Text as m,Stack as C,Progress as me,handleImageError as he}from"@donotdev/components";import{useTranslation as ve}from"@donotdev/core";import{useFileUpload as fe}from"../../../hooks/useFileUpload";import{processImage as ye}from"../../../utils/imageProcessing";import{uploadImage as be}from"../../../utils/imageStorage";import{ImageViewerDialog as xe}from"../internal/ImageViewerDialog";const we=["image/*"];function Ce(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function Se({file:t,index:h,multiple:v,onImageClick:S,onRemove:f,t:l}){const{attributes:n,listeners:k,setNodeRef:I,transform:d,transition:D,isDragging:y}=ie({id:t.id}),c=t.progress!==null&&t.progress<100,p=v&&!c,b={transform:se.Transform.toString(d),transition:D,position:"relative",width:100,height:100,borderRadius:"var(--radius-md)",border:"var(--border-width) solid var(--border)",overflow:"hidden",backgroundColor:"var(--surface)",opacity:y?.5:1,cursor:p?"grab":"pointer",userSelect:"none",touchAction:p?"none":"auto"};return r("div",{ref:I,style:b,...n,...p?k:{},onClick:()=>{y||S(h)},children:c?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(de,{style:{animation:"spin 1s linear infinite"}}),r(me,{value:t.progress||0,style:{width:"80%"}})]}):t.error?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(U,{style:{color:"var(--destructive)"}}),r(m,{variant:"destructive",level:"small",children:t.error})]}):s(Z,{children:[v&&r("div",{style:{position:"absolute",top:4,left:4,padding:2,background:"rgba(0,0,0,0.5)",borderRadius:"var(--radius-sm)",display:"flex",zIndex:2,pointerEvents:"none"},children:r(ce,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:l("image.alt.upload",{index:h+1}),draggable:!1,onError:he,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:i=>{i.stopPropagation(),f(t.id)},onPointerDown:i=>i.stopPropagation(),style:{position:"absolute",top:4,right:4,padding:4,background:"rgba(0,0,0,0.5)",border:"none",borderRadius:"var(--radius-sm)",cursor:"pointer",display:"flex",zIndex:2},children:r(U,{style:{color:"white",width:16,height:16}})}),!t.uploaded&&r("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:4,background:"rgba(0,0,0,0.7)",textAlign:"center",pointerEvents:"none"},children:r(m,{variant:"muted",level:"small",style:{color:"white"},children:l("image.upload.pending")})})]})})}const L=pe(({name:t="image",label:h,value:v,onChange:S,error:f,helperText:l,multiple:n=!1,maxFiles:k=10,maxSize:I=10*1024*1024,storagePath:d,required:D,capture:y,processing:c},p)=>{const{t:b}=ve("crud"),i=ge(null),[N,F]=j(!1),[B,E]=j(0),M=te(A(ee,{activationConstraint:{distance:8}}),A(re,{activationConstraint:{delay:200,tolerance:5}})),V=P(async(e,o)=>{const{fullBlob:u,thumbBlob:x}=await ye(e,c);return be(u,x,e.name,{storagePath:d,onProgress:w=>o(w.progress)})},[d,c]),{files:a,addFiles:R,removeFile:T,reorderFiles:z}=fe({name:t,value:v,onChange:S,multiple:n,maxFiles:k,maxSize:I,accept:we,storagePath:d,uploadFn:V}),q=e=>{const o=Array.from(e.target.files||[]);o.length>0&&R(o),i.current&&(i.current.value="")},G=P(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&R(Array.from(e.dataTransfer.files))},[R]),H=P(e=>{const{active:o,over:u}=e;if(u&&o.id!==u.id){const x=a.findIndex(g=>g.id===o.id),w=a.findIndex(g=>g.id===u.id);if(x!==-1&&w!==-1){const g=ne(a.map(Y=>Y.id),x,w);z(g)}}},[a,z]),K=e=>{E(e),F(!0)},O=(e,o)=>{},W=e=>{const o=a[e];o&&T(o.id)},X=e=>{E(e)},$=n||a.length===0;ue(p,()=>({upload:async()=>{},focus:()=>i.current?.focus()}),[]);const J=a.map(Ce);return s(C,{gap:"tight",children:[s(m,{level:"body",textAlign:"start",children:[h,D&&"*"]}),$&&s("div",{role:"button",tabIndex:0,onClick:()=>i.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&i.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:G,style:{border:`var(--border-width) dashed ${f?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:i,type:"file",accept:"image/*",capture:y,multiple:n,style:{display:"none"},onChange:q}),s(C,{align:"center",children:[r(le,{style:{color:"var(--muted-foreground)"}}),r(m,{variant:"muted",level:"small",children:b(n?"image.upload.dropzoneMultiple":"image.upload.dropzoneSingle")})]})]}),a.length>0&&r(_,{sensors:M,collisionDetection:Q,onDragEnd:H,children:r(oe,{items:a.map(e=>e.id),strategy:ae,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:a.map((e,o)=>r(Se,{file:e,index:o,multiple:n,onImageClick:K,onRemove:T,t:b},e.id))})})}),l&&r(m,{variant:f?"destructive":"muted",level:"small",children:l}),r(xe,{images:J,selectedIndex:B,open:N,onClose:()=>F(!1),onUpdate:O,onDelete:W,onNavigate:X,multiple:n})]})});L.displayName="ImageFieldComponent";var ke=L;export{ke as default};
1
+ "use client";import{jsx as r,jsxs as s,Fragment as Z}from"react/jsx-runtime";import{DndContext as _,closestCenter as Y,PointerSensor as ee,TouchSensor as re,useSensor as A,useSensors as oe}from"@dnd-kit/core";import{SortableContext as te,useSortable as ae,rectSortingStrategy as ie,arrayMove as ne}from"@dnd-kit/sortable";import{CSS as se}from"@dnd-kit/utilities";import{Upload as le,X as U,Loader2 as de,GripVertical as ce}from"lucide-react";import{forwardRef as pe,useCallback as P,useImperativeHandle as ue,useRef as ge,useState as j}from"react";import{Text as m,Stack as C,Progress as me,handleImageError as he}from"@donotdev/components";import{useTranslation as ve}from"@donotdev/core";import{useFileUpload as fe}from"../../../hooks/useFileUpload";import{processImage as be}from"../../../utils/imageProcessing";import{uploadImage as ye}from"../../../utils/imageStorage";import{ImageViewerDialog as xe}from"../internal/ImageViewerDialog";const we=["image/*"];function Ce(o){return{id:o.id,file:o.file,previewURL:o.previewURL,hash:"",rotation:0,uploadProgress:o.progress,uploaded:o.uploaded,error:o.error}}function Se({file:o,index:h,multiple:v,onImageClick:S,onRemove:f,t:l}){const{attributes:n,listeners:k,setNodeRef:I,transform:d,transition:D,isDragging:b}=ae({id:o.id}),c=o.progress!==null&&o.progress<100,p=v&&!c,y={transform:se.Transform.toString(d),transition:D,position:"relative",width:100,height:100,borderRadius:"var(--radius-md)",border:"var(--border-width) solid var(--border)",overflow:"hidden",backgroundColor:"var(--surface)",opacity:b?.5:1,cursor:p?"grab":"pointer",userSelect:"none",touchAction:p?"none":"auto"};return r("div",{ref:I,style:y,...n,...p?k:{},onClick:()=>{b||S(h)},children:c?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(de,{style:{animation:"spin 1s linear infinite"}}),r(me,{value:o.progress||0,style:{width:"80%"}})]}):o.error?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(U,{style:{color:"var(--destructive)"}}),r(m,{variant:"destructive",level:"small",children:o.error})]}):s(Z,{children:[v&&r("div",{style:{position:"absolute",top:4,left:4,padding:2,background:"rgba(0,0,0,0.5)",borderRadius:"var(--radius-sm)",display:"flex",zIndex:2,pointerEvents:"none"},children:r(ce,{style:{color:"white",width:14,height:14}})}),r("img",{src:o.previewURL,alt:l("image.alt.upload",{index:h+1}),draggable:!1,onError:he,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:a=>{a.stopPropagation(),f(o.id)},onPointerDown:a=>a.stopPropagation(),style:{position:"absolute",top:4,right:4,padding:4,background:"rgba(0,0,0,0.5)",border:"none",borderRadius:"var(--radius-sm)",cursor:"pointer",display:"flex",zIndex:2},children:r(U,{style:{color:"white",width:16,height:16}})}),!o.uploaded&&r("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:4,background:"rgba(0,0,0,0.7)",textAlign:"center",pointerEvents:"none"},children:r(m,{variant:"muted",level:"small",style:{color:"white"},children:l("image.upload.pending")})})]})})}const L=pe(({name:o="image",label:h,value:v,onChange:S,error:f,helperText:l,multiple:n=!1,maxFiles:k=10,maxSize:I=10*1024*1024,storagePath:d,required:D,capture:b,processing:c},p)=>{const{t:y}=ve("crud"),a=ge(null),[N,F]=j(!1),[B,E]=j(0),M=oe(A(ee,{activationConstraint:{distance:8}}),A(re,{activationConstraint:{delay:200,tolerance:5}})),V=P(async(e,t)=>{const{fullBlob:u,thumbBlob:x}=await be(e,c);return ye(u,x,e.name,{storagePath:d,onProgress:w=>t(w.progress)})},[d,c]),{files:i,addFiles:R,removeFile:T,reorderFiles:z}=fe({name:o,value:v,onChange:S,multiple:n,maxFiles:k,maxSize:I,accept:we,storagePath:d,uploadFn:V}),q=e=>{const t=Array.from(e.target.files||[]);t.length>0&&R(t),a.current&&(a.current.value="")},G=P(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&R(Array.from(e.dataTransfer.files))},[R]),H=P(e=>{const{active:t,over:u}=e;if(u&&t.id!==u.id){const x=i.findIndex(g=>g.id===t.id),w=i.findIndex(g=>g.id===u.id);if(x!==-1&&w!==-1){const g=ne(i.map(Q=>Q.id),x,w);z(g)}}},[i,z]),K=e=>{E(e),F(!0)},O=(e,t)=>{},W=e=>{const t=i[e];t&&T(t.id)},X=e=>{E(e)},$=n||i.length===0;ue(p,()=>({upload:async()=>{},focus:()=>a.current?.focus()}),[]);const J=i.map(Ce);return s(C,{gap:"tight",children:[s(m,{level:"body",textAlign:"start",children:[h,D&&"*"]}),$&&s("div",{role:"button",tabIndex:0,onClick:()=>a.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&a.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:G,style:{border:`var(--border-width) dashed ${f?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:a,type:"file",accept:"image/*",capture:b,multiple:n,style:{display:"none"},onChange:q}),s(C,{align:"center",children:[r(le,{style:{color:"var(--muted-foreground)"}}),r(m,{variant:"muted",level:"small",children:y(n?"image.upload.dropzoneMultiple":"image.upload.dropzoneSingle")})]})]}),i.length>0&&r(_,{sensors:M,collisionDetection:Y,onDragEnd:H,children:r(te,{items:i.map(e=>e.id),strategy:ie,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:i.map((e,t)=>r(Se,{file:e,index:t,multiple:n,onImageClick:K,onRemove:T,t:y},e.id))})})}),l&&r(m,{variant:f?"destructive":"muted",level:"small",children:l}),r(xe,{images:J,selectedIndex:B,open:N,onClose:()=>F(!1),onUpdate:O,onDelete:W,onNavigate:X,multiple:n})]})});L.displayName="ImageFieldComponent";var ke=L;export{ke as default};
@@ -1 +1 @@
1
- import{jsx as o,jsxs as s,Fragment as J}from"react/jsx-runtime";import{useMemo as M,useId as R}from"react";import{Combobox as $,Tag as p,Stack as h}from"@donotdev/components";import{useTranslation as B}from"@donotdev/core";const d=4,f=3,F=({label:v,info:b,value:a=[],options:l,error:S,helperText:n,onChange:u,onBlur:x,required:y,className:z})=>{const{t:g}=B("crud"),m=R(),N=M(()=>l.map(e=>({value:String(e.value),label:e.label})),[l]),C=e=>{const r=Array.isArray(e)?e:[e],t={target:{value:JSON.stringify(r)}};u(t)},O=e=>{e||x?.()},A=e=>{const r=a.filter(c=>c!==e),t={target:{value:JSON.stringify(r)}};u(t)},i=!!S,T=`${m}-error`,j=`${m}-helper`,q=a.length>0?s(J,{children:[a.slice(0,a.length>d?f:d).map((e,r)=>{const t=l.find(c=>String(c.value)===e)?.label||e;return o(p,{size:"sm",onRemove:()=>A(e),children:t},r)}),a.length>d&&s(p,{size:"sm",variant:"outline",disabled:!0,children:["+",a.length-f," more"]})]}):void 0;return s(h,{gap:"tight",className:z,children:[o($,{label:v,info:b,value:a,onValueChange:C,onOpenChange:O,placeholder:g("actions.selectOptions","Select options..."),emptyMessage:g("messages.noResults","No results found"),options:N,multiple:!0,required:y,variant:i?"destructive":void 0,chips:q}),i&&s(h,{id:T,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),n]}),n&&!i&&o("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var V=F;export{V as default};
1
+ import{jsx as a,jsxs as s,Fragment as J}from"react/jsx-runtime";import{useMemo as M,useId as R}from"react";import{Combobox as $,Tag as p,Stack as h}from"@donotdev/components";import{useTranslation as B}from"@donotdev/core";const d=4,f=3,F=({label:v,info:b,value:t=[],options:l,error:S,helperText:n,onChange:u,onBlur:x,required:y,className:z})=>{const{t:g}=B("crud"),m=R(),N=M(()=>l.map(e=>({value:String(e.value),label:e.label})),[l]),C=e=>{const r=Array.isArray(e)?e:[e],o={target:{value:JSON.stringify(r)}};u(o)},O=e=>{e||x?.()},A=e=>{const r=t.filter(c=>c!==e),o={target:{value:JSON.stringify(r)}};u(o)},i=!!S,T=`${m}-error`,j=`${m}-helper`,q=t.length>0?s(J,{children:[t.slice(0,t.length>d?f:d).map((e,r)=>{const o=l.find(c=>String(c.value)===e)?.label||e;return a(p,{size:"sm",onRemove:()=>A(e),children:o},r)}),t.length>d&&s(p,{size:"sm",variant:"outline",disabled:!0,children:["+",t.length-f," more"]})]}):void 0;return s(h,{gap:"tight",className:z,children:[a($,{label:v,info:b,value:t,onValueChange:C,onOpenChange:O,placeholder:g("actions.selectOptions","Select options..."),emptyMessage:g("messages.noResults","No results found"),options:N,multiple:!0,required:y,variant:i?"destructive":void 0,chips:q}),i&&s(h,{id:T,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),n]}),n&&!i&&a("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var V=F;export{V as default};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useState as q,useMemo as p,useEffect as E,useId as U}from"react";import{Input as j,FloatingLabel as D,Button as G,BUTTON_VARIANT as H,DropdownMenu as V,Stack as f,cn as _}from"@donotdev/components";import{Flag as T,COUNTRIES as y}from"@donotdev/core";const P=({label:W,info:R,value:i="",onChange:C,name:w,onBlur:A,ref:B,error:$,helperText:g,required:F=!1,disabled:v=!1,defaultCountry:N="FR",showFlags:x=!0,preferredCountries:c,countries:h})=>{const o=U(),m=p(()=>h&&h.length>0?h.map(e=>y.find(r=>r.code===e)).filter(e=>e!==void 0):Array.from(y),[h]),n=p(()=>{if(!c||c.length===0)return m;const e=c.map(t=>m.find(O=>O.code===t)).filter(t=>t!==void 0),r=m.filter(t=>!c.includes(t.code));return[...e,...r]},[m,c]),u=p(()=>n.find(e=>e.code===N)||n[0]||y[0],[N,n]),{country:b,phoneNumber:k}=p(()=>{if(!i)return{country:u,phoneNumber:""};const e=n.find(t=>i.startsWith(t.dialCode));if(e){let t=i.slice(e.dialCode.length).trim();return t.startsWith("0")&&(t=t.slice(1).trim()),t=t.replace(/\s+/g," ").trim(),{country:e,phoneNumber:t}}if(i.startsWith("+"))return{country:u,phoneNumber:i};let r=i.trim();return r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim(),{country:u,phoneNumber:r}},[i,u,n]),[d,S]=q(u);E(()=>{i&&b.code!==d.code&&S(b)},[i,b,d.code]);const z=k,I=e=>{S(e);let r=z;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:r?`${e.dialCode} ${r}`:""}};C(t)},L=e=>{let r=e.target.value;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:r?`${d.dialCode} ${r}`:""}};C(t)},M=n.map(e=>({label:e.dialCode,onClick:()=>I(e),checked:e.code===d.code,children:x?s(f,{direction:"row",align:"center",gap:"tight",children:[a(T,{code:e.flagCode,title:e.name}),a("span",{children:e.dialCode}),a("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-xs)"},children:e.name})]}):s("span",{children:[e.dialCode," ",e.name]})})),l=!!$;return s(f,{gap:"tight",children:[a(D,{htmlFor:o,label:W,info:R,disabled:v,required:F,children:s("div",{className:"dndev-relative",style:{display:"flex",gap:0},children:[a(V,{trigger:a(G,{type:"button",variant:H.GHOST,disabled:v,style:{minWidth:"fit-content",padding:"0 var(--gap-md)"},"aria-label":`Country code: ${d.dialCode}`,children:s(f,{direction:"row",align:"center",gap:"tight",children:[x&&a(T,{code:d.flagCode,title:d.name}),a("span",{children:d.dialCode})]})}),items:M,contentWidth:"16rem"}),a(j,{ref:B,name:w,onBlur:A,id:o,type:"tel",inputMode:"tel",value:z,onChange:L,disabled:v,placeholder:"6 12 34 56 78",bare:!0,"data-variant":l?"destructive":void 0,className:"dndev-flex-1",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderRadius:"0 var(--radius-md) var(--radius-md) 0"},"aria-describedby":_(l&&`${o}-error`,g&&!l&&`${o}-helper`),"aria-invalid":l})]})}),l&&s(f,{id:`${o}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),$]}),g&&!l&&a("p",{id:`${o}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:g})]})};var Y=P;export{Y as default};
1
+ "use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useState as q,useMemo as f,useEffect as E,useId as O}from"react";import{Input as U,FloatingLabel as D,Button as G,BUTTON_VARIANT as H,DropdownMenu as V,Stack as h,cn as _}from"@donotdev/components";import{Flag as $,COUNTRIES as y}from"@donotdev/core";const P=({label:z,info:R,value:i="",onChange:C,name:w,onBlur:B,ref:F,error:N,helperText:g,required:I=!1,disabled:v=!1,defaultCountry:x="FR",showFlags:S=!0,preferredCountries:c,countries:m})=>{const o=O(),p=f(()=>m&&m.length>0?m.map(e=>y.find(r=>r.code===e)).filter(e=>e!==void 0):Array.from(y),[m]),n=f(()=>{if(!c||c.length===0)return p;const e=c.map(t=>p.find(j=>j.code===t)).filter(t=>t!==void 0),r=p.filter(t=>!c.includes(t.code));return[...e,...r]},[p,c]),u=f(()=>n.find(e=>e.code===x)||n[0]||y[0],[x,n]),{country:b,phoneNumber:k}=f(()=>{if(!i)return{country:u,phoneNumber:""};const e=n.find(t=>i.startsWith(t.dialCode));if(e){let t=i.slice(e.dialCode.length).trim();return t.startsWith("0")&&(t=t.slice(1).trim()),t=t.replace(/\s+/g," ").trim(),{country:e,phoneNumber:t}}if(i.startsWith("+"))return{country:u,phoneNumber:i};let r=i.trim();return r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim(),{country:u,phoneNumber:r}},[i,u,n]),[d,T]=q(u);E(()=>{i&&b.code!==d.code&&T(b)},[i,b,d.code]);const W=k,A=e=>{T(e);let r=W;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:r?`${e.dialCode} ${r}`:""}};C(t)},L=e=>{let r=e.target.value;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:r?`${d.dialCode} ${r}`:""}};C(t)},M=n.map(e=>({label:e.dialCode,onClick:()=>A(e),checked:e.code===d.code,children:S?s(h,{direction:"row",align:"center",gap:"tight",children:[a($,{code:e.flagCode,title:e.name}),a("span",{children:e.dialCode}),a("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-xs)"},children:e.name})]}):s("span",{children:[e.dialCode," ",e.name]})})),l=!!N;return s(h,{gap:"tight",children:[a(D,{htmlFor:o,label:z,info:R,disabled:v,required:I,children:s("div",{className:"dndev-relative",style:{display:"flex",gap:0},children:[a(V,{trigger:a(G,{type:"button",variant:H.GHOST,disabled:v,style:{minWidth:"fit-content",padding:"0 var(--gap-md)"},"aria-label":`Country code: ${d.dialCode}`,children:s(h,{direction:"row",align:"center",gap:"tight",children:[S&&a($,{code:d.flagCode,title:d.name}),a("span",{children:d.dialCode})]})}),items:M,contentWidth:"16rem"}),a(U,{ref:F,name:w,onBlur:B,id:o,type:"tel",inputMode:"tel",value:W,onChange:L,disabled:v,placeholder:"6 12 34 56 78",bare:!0,"data-variant":l?"destructive":void 0,className:"dndev-flex-1",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderRadius:"0 var(--radius-md) var(--radius-md) 0"},"aria-describedby":_(l&&`${o}-error`,g&&!l&&`${o}-helper`),"aria-invalid":l})]})}),l&&s(h,{id:`${o}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),N]}),g&&!l&&a("p",{id:`${o}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:g})]})};var Y=P;export{Y as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as h,Rating as m,Stack as u}from"@donotdev/components";const v=({label:a,value:o=0,onChange:s,error:l,helperText:r,max:t=5,disabled:i,required:n,readonly:d,showValue:f=!1})=>g(u,{gap:"tight",children:[e(h,{required:n,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:a}),e(m,{value:o,onChange:s,max:t,disabled:i,readonly:d,showValue:f,"aria-label":a}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]});var p=v;export{p as default};
1
+ import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as h,Rating as m,Stack as f}from"@donotdev/components";const v=({label:a,value:o=0,onChange:s,error:l,helperText:r,max:t=5,disabled:i,required:n,readonly:d,showValue:u=!1})=>g(f,{gap:"tight",children:[e(h,{required:n,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:a}),e(m,{value:o,onChange:s,max:t,disabled:i,readonly:d,showValue:u,"aria-label":a}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]});var p=v;export{p as default};
@@ -1 +1 @@
1
- "use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import h from"./TextAreaComponent";const p=m(()=>typeof window<"u"?import("./internal/TiptapEditor").catch(()=>({default:()=>null})):Promise.resolve({default:()=>null})),x=({label:l,value:a="",onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})=>{const[c,n]=f(!1);return g(()=>{n(!0)},[]),c?e(v,{gap:"tight",children:e(b,{fallback:e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u}),children:p?e(p,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u}):e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})})}):e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})};var C=x;export{C as default};
1
+ "use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import h from"./TextAreaComponent";const p=m(()=>typeof window<"u"?import("./internal/TiptapEditor").catch(()=>({default:()=>null})):Promise.resolve({default:()=>null})),x=({label:l,value:a="",onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n})=>{const[i,u]=f(!1);return g(()=>{u(!0)},[]),i?e(v,{gap:"tight",children:e(b,{fallback:e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n}),children:p?e(p,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n}):e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n})})}):e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n})};var C=x;export{C as default};
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as o}from"react/jsx-runtime";import{useState as N,useId as F,useRef as j,useEffect as q}from"react";import{Textarea as A,FloatingLabel as R,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,info:b,value:s="",onChange:y,error:h,helperText:n,rows:z=3,loading:d=!1,maxLength:r,showCharCount:v=!1,autoResize:i=!1,required:w=!1,disabled:g=!1,className:$,...S})=>{const e=F(),[I,f]=N(!1),l=j(null),a=!!h,c=s.length,C=r&&c>r*.8,L=r&&c>r;return q(()=>{if(i&&l.current){const u=l.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[s,i]),o(p,{gap:"tight",children:[t(R,{htmlFor:e,label:x,info:b,disabled:g||d,required:w,children:o("div",{className:"dndev-relative",children:[t(A,{ref:l,id:e,value:s,onChange:y,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||d,maxLength:r,rows:i?1:z,bare:!0,"aria-describedby":m(a&&`${e}-error`,n&&!a&&`${e}-helper`,v&&`${e}-count`),"aria-invalid":a,className:m("dndev-w-full",i&&"dndev-overflow-hidden",$),"data-variant":a?"destructive":void 0,style:{resize:i?"none":void 0},...S}),d&&t("div",{className:"dndev-absolute",style:{right:"var(--gap-md)",top:"var(--gap-md)"},children:t(k,{"aria-label":"Loading"})})]})}),v&&r&&o("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:L?"var(--destructive-foreground)":C?"var(--warning)":"var(--muted-foreground)"},children:[c,"/",r]}),a&&o(p,{as:"p",id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),h]}),n&&!a&&t("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var E=B;export{E as default};
1
+ "use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as N,useId as F,useRef as j,useEffect as q}from"react";import{Textarea as A,FloatingLabel as R,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,info:b,value:o="",onChange:y,error:h,helperText:s,rows:z=3,loading:d=!1,maxLength:r,showCharCount:v=!1,autoResize:i=!1,required:w=!1,disabled:g=!1,className:$,...S})=>{const e=F(),[I,f]=N(!1),l=j(null),a=!!h,c=o.length,C=r&&c>r*.8,L=r&&c>r;return q(()=>{if(i&&l.current){const u=l.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[o,i]),n(p,{gap:"tight",children:[t(R,{htmlFor:e,label:x,info:b,disabled:g||d,required:w,children:n("div",{className:"dndev-relative",children:[t(A,{ref:l,id:e,value:o,onChange:y,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||d,maxLength:r,rows:i?1:z,bare:!0,"aria-describedby":m(a&&`${e}-error`,s&&!a&&`${e}-helper`,v&&`${e}-count`),"aria-invalid":a,className:m("dndev-w-full",i&&"dndev-overflow-hidden",$),"data-variant":a?"destructive":void 0,style:{resize:i?"none":void 0},...S}),d&&t("div",{className:"dndev-absolute",style:{right:"var(--gap-md)",top:"var(--gap-md)"},children:t(k,{"aria-label":"Loading"})})]})}),v&&r&&n("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:L?"var(--destructive-foreground)":C?"var(--warning)":"var(--muted-foreground)"},children:[c,"/",r]}),a&&n(p,{as:"p",id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),h]}),s&&!a&&t("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:s})]})};var E=B;export{E as default};
@@ -1 +1 @@
1
- import{jsx as i}from"react/jsx-runtime";import{Stack as r}from"@donotdev/components";const e={minBlockSize:"var(--touch-target)"};function o({children:t}){return i(r,{direction:"row",align:"center",gap:"tight",style:e,children:t})}export{o as InlineFieldRow};
1
+ import{jsx as t}from"react/jsx-runtime";import{Stack as i}from"@donotdev/components";const e={minBlockSize:"var(--touch-target)"};function o({children:r}){return t(i,{direction:"row",align:"center",gap:"tight",style:e,children:r})}export{o as InlineFieldRow};
@@ -1,4 +1,4 @@
1
- "use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as M}from"@donotdev/components";const x=({label:s,value:r="",onChange:d,error:e,helperText:n,required:o,disabled:a,placeholder:l,className:c,modules:g})=>{const{useEditor:v,EditorContent:p,StarterKit:h,Placeholder:b}=g,t=v({extensions:[h.configure({heading:{levels:[1,2,3]}}),b.configure({placeholder:l||"Start typing..."})],content:r,editable:!a,onUpdate:({editor:P})=>{const y={target:{value:P.getHTML()}};d(y)}});return u(()=>{t&&r!==t.getHTML()&&t.commands.setContent(r||"")},[r,t]),t?m(M,{gap:"tight",children:[m("label",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:e?"var(--destructive-foreground)":"var(--foreground)"},children:[s,o&&i("span",{style:{color:"var(--destructive)"},children:" *"})]}),i("div",{className:c,"data-variant":e?"destructive":void 0,style:{border:"var(--border-hairline) solid",borderColor:e?"var(--destructive)":"var(--line-2)",borderRadius:"var(--radius-interactive)",padding:"var(--gap-md)",minHeight:"200px",backgroundColor:a?"var(--muted)":"transparent",opacity:a?"var(--opacity-muted)":void 0},children:i(p,{editor:t})}),n&&i("p",{style:{fontSize:"var(--font-size-xs)",color:e?"var(--destructive-foreground)":"var(--muted-foreground)"},children:n}),i("style",{children:`
1
+ "use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as P}from"@donotdev/components";const x=({label:d,value:r="",onChange:s,error:e,helperText:n,required:o,disabled:a,placeholder:l,className:c,modules:g})=>{const{useEditor:v,EditorContent:p,StarterKit:h,Placeholder:b}=g,t=v({extensions:[h.configure({heading:{levels:[1,2,3]}}),b.configure({placeholder:l||"Start typing..."})],content:r,editable:!a,onUpdate:({editor:y})=>{const M={target:{value:y.getHTML()}};s(M)}});return u(()=>{t&&r!==t.getHTML()&&t.commands.setContent(r||"")},[r,t]),t?m(P,{gap:"tight",children:[m("label",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:e?"var(--destructive-foreground)":"var(--foreground)"},children:[d,o&&i("span",{style:{color:"var(--destructive)"},children:" *"})]}),i("div",{className:c,"data-variant":e?"destructive":void 0,style:{border:"var(--border-hairline) solid",borderColor:e?"var(--destructive)":"var(--line-2)",borderRadius:"var(--radius-interactive)",padding:"var(--gap-md)",minHeight:"200px",backgroundColor:a?"var(--muted)":"transparent",opacity:a?"var(--opacity-muted)":void 0},children:i(p,{editor:t})}),n&&i("p",{style:{fontSize:"var(--font-size-xs)",color:e?"var(--destructive-foreground)":"var(--muted-foreground)"},children:n}),i("style",{children:`
2
2
  .ProseMirror {
3
3
  outline: none;
4
4
  min-height: 150px;
@@ -49,4 +49,4 @@
49
49
  margin: 0.5em 0;
50
50
  color: var(--muted-foreground);
51
51
  }
52
- `})]}):null},z=s=>{const[r,d]=f(null),[e,n]=f(!1);return u(()=>{r||e||(async()=>{try{const[{useEditor:o,EditorContent:a},l,c]=await Promise.all([import("@tiptap/react"),import("@tiptap/starter-kit"),import("@tiptap/extension-placeholder")]);d({useEditor:o,EditorContent:a,StarterKit:l.default,Placeholder:c.default})}catch(o){o instanceof Error&&(o.message.includes("Cannot find module '@tiptap")||o.message.includes("Failed to fetch dynamically imported module")),n(!0)}})()},[r,e]),e||!r?null:i(x,{...s,modules:r})};var C=z;export{C as default};
52
+ `})]}):null},z=d=>{const[r,s]=f(null),[e,n]=f(!1);return u(()=>{r||e||(async()=>{try{const[{useEditor:o,EditorContent:a},l,c]=await Promise.all([import("@tiptap/react"),import("@tiptap/starter-kit"),import("@tiptap/extension-placeholder")]);s({useEditor:o,EditorContent:a,StarterKit:l.default,Placeholder:c.default})}catch(o){o instanceof Error&&(o.message.includes("Cannot find module '@tiptap")||o.message.includes("Failed to fetch dynamically imported module")),n(!0)}})()},[r,e]),e||!r?null:i(x,{...d,modules:r})};var C=z;export{C as default};