@donotdev/crud 0.0.15 → 0.0.16
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.
- package/dist/CrudService.js +2 -2
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +3 -30
- package/dist/FieldRegistry.d.ts.map +1 -1
- package/dist/FieldRegistry.js +1 -1
- package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/DisplayFieldRenderer.js +1 -1
- package/dist/components/DisplayThumbnail.js +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/__tests__/EntityFilters.test.js +1 -1
- package/dist/components/__tests__/FormFieldRenderer.test.js +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
- package/dist/components/controlled/complex/ControlledMapField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
- package/dist/components/controlled/complex/index.js +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
- package/dist/components/controlled/file/index.js +1 -1
- package/dist/components/controlled/index.js +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
- package/dist/components/controlled/input/ControlledDurationField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
- package/dist/components/controlled/input/ControlledNumberField.js +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
- package/dist/components/controlled/input/ControlledPriceField.js +1 -1
- package/dist/components/controlled/input/ControlledRangeField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
- package/dist/components/controlled/input/ControlledTextField.js +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
- package/dist/components/controlled/input/index.js +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledRadioField.js +1 -1
- package/dist/components/controlled/select/ControlledYearField.js +1 -1
- package/dist/components/controlled/select/index.js +1 -1
- package/dist/components/controlled/types.d.ts +19 -5
- package/dist/components/controlled/types.d.ts.map +1 -1
- package/dist/components/controlled/types.js +1 -1
- package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
- package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/DateFieldDisplay.js +1 -1
- package/dist/components/fields/display/DropdownDisplay.js +1 -1
- package/dist/components/fields/display/FileFieldDisplay.js +1 -1
- package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
- package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
- package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
- package/dist/components/fields/display/MapFieldDisplay.js +1 -1
- package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
- package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
- package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
- package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
- package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
- package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
- package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
- package/dist/components/fields/display/RichTextDisplay.js +2 -2
- package/dist/components/fields/display/TextAreaDisplay.js +1 -1
- package/dist/components/fields/display/TextFieldDisplay.js +1 -1
- package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
- package/dist/components/fields/display/index.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.js +1 -1
- package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
- package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
- package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
- package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
- package/dist/components/form/fields/ComboboxComponent.js +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/DurationFieldComponent.js +1 -1
- package/dist/components/form/fields/FileFieldComponent.js +1 -1
- package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
- package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
- package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MapFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/PriceFieldComponent.js +1 -1
- package/dist/components/form/fields/RadioFieldComponent.js +1 -1
- package/dist/components/form/fields/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/RatingFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
- package/dist/components/form/fields/RichTextComponent.js +1 -1
- package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
- package/dist/components/form/fields/index.js +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
- package/dist/components/form/internal/ImageViewerDialog.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/contexts/index.js +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/forms/hooks/index.js +1 -1
- package/dist/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityField.js +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts +3 -2
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/types.d.ts +0 -8
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/index.js +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/translateFieldLabel.js +1 -1
- package/dist/forms/utils/validateEntity.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useFileUpload.d.ts.map +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useFormNavigationGuard.js +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/hooks/useUnsavedChangesWarning.d.ts +3 -24
- package/dist/hooks/useUnsavedChangesWarning.d.ts.map +1 -1
- package/dist/hooks/useUnsavedChangesWarning.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/registerBuiltinFieldTypes.js +1 -1
- package/dist/stores/FormStore.js +1 -1
- package/dist/stores/UploadStore.js +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.js +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.d.ts.map +1 -1
- package/dist/utils/imageStorage.js +1 -1
- package/dist/utils/imageUtils.js +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/sanitizeHtml.js +1 -1
- package/dist/utils/scopeUtils.js +1 -1
- package/dist/utils/uploadValidation.d.ts.map +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/package.json +5 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as v}from"react/jsx-runtime";import{useState as I,useEffect as S,useId as z}from"react";import{Input as E,FloatingLabel as T,Stack as j}from"@donotdev/components";const C=({label:g,value:n,onChange:m,currency:l="EUR",locale:f,error:o,helperText:s,required:y=!1,disabled:i=!1,placeholder:h})=>{const d=z(),b=f||(typeof navigator<"u"?navigator.language:"en-US"),u=e=>e==null||isNaN(e)?"":(e/100).toFixed(2),x=e=>{if(!e||e.trim()==="")return null;const r=e.replace(/[^\d.,\-]/g,"").replace(",","."),a=parseFloat(r);return isNaN(a)?null:Math.round(a*100)},[F,c]=I(u(n));S(()=>{c(u(n))},[n]);const N=e=>{const r=e.target.value;c(r);const a={target:{value:x(r)}};m(a)},p=(()=>{try{return new Intl.NumberFormat(b,{style:"currency",currency:l,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||l}catch{return l}})();return v(j,{gap:"tight",children:[t(T,{htmlFor:d,label:g,disabled:i,required:y,children:v("div",{style:{position:"relative"},children:[t("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:p}),t(E,{id:d,type:"text",inputMode:"decimal",value:F,onChange:N,disabled:i,placeholder:h||"0.00","data-variant":o?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${p.length*.6}em + var(--gap-sm))`}})]})}),s&&t("p",{style:{fontSize:"var(--font-size-xs)",color:o?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:s})]})};var L=C;export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as l,jsxs as S}from"react/jsx-runtime";import{Input as
|
|
1
|
+
import{jsx as l,jsxs as S}from"react/jsx-runtime";import{Input as m,Stack as p}from"@donotdev/components";const v=({label:n,value:a,onChange:i,error:s,helperText:o,mode:e="date",required:g,...u})=>{const c=t=>{const d=t.target.value?new Date(t.target.value).toISOString():null;i(d)};let r="";if(a){const t=new Date(a);e==="date"?r=t.toISOString().split("T")[0]||"":e==="datetime-local"?r=t.toISOString().slice(0,16)||"":e==="month"?r=t.toISOString().slice(0,7):e==="time"?r=t.toISOString().slice(11,16):e==="week"&&(r=t.toISOString().split("T")[0]||"")}return S(p,{gap:"tight",children:[l(m,{label:n,type:e,value:r,onChange:c,required:g,className:"dndev-w-full",...u}),o&&l("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var f=v;export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DocumentFieldComponent.tsx"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;IACvC,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1D,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IACxC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,qCAAqC;IACrC,YAAY,EAAE,MAAM,gBAAgB,EAAE,CAAC;CACxC;AA2CD;;;GAGG;AACH,QAAA,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"DocumentFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DocumentFieldComponent.tsx"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;IACvC,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1D,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IACxC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,qCAAqC;IACrC,YAAY,EAAE,MAAM,gBAAgB,EAAE,CAAC;CACxC;AA2CD;;;GAGG;AACH,QAAA,MAAM,sBAAsB,mIAshB3B,CAAC;AAIF,eAAe,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t,jsxs as n,Fragment as le}from"react/jsx-runtime";import{Upload as se,X as oe,FileText as N,FileSpreadsheet as ie,File as ne,Loader2 as de,Eye as ce}from"lucide-react";import{useCallback as y,useState as A,useRef as T,useEffect as j,useImperativeHandle as ue,forwardRef as pe}from"react";import{Button as B,BUTTON_VARIANT as q,Text as g,Stack as w,Progress as me,Dialog as ge,DialogContent as ve,DialogHeader as fe,DialogTitle as he}from"@donotdev/components";import{handleError as P,useTranslation as ye}from"@donotdev/core";import{useUploadContext as we}from"../../../contexts/UploadContext";import{useUploadStore as G}from"../../../stores/UploadStore";import{uploadFile as xe,deleteFile as be,generateFileId as X,getFileIcon as Ne,formatFileSize as Te,getDocumentAcceptString as Pe}from"../../../utils/fileStorage";function De({type:m,className:d}){switch(m){case"pdf":return t(N,{className:d,style:{color:"var(--destructive)"}});case"doc":return t(N,{className:d,style:{color:"var(--primary)"}});case"xls":return t(ie,{className:d,style:{color:"var(--success)"}});case"ppt":return t(N,{className:d,style:{color:"var(--warning)"}});case"text":case"html":return t(N,{className:d});default:return t(ne,{className:d})}}const V=pe(({name:m,label:d,value:v,onChange:I,error:D,helperText:L,multiple:p=!1,maxFiles:k=10,maxSize:C=25*1024*1024,storagePath:M="uploads/documents",required:J,enablePreview:O=!0},K)=>{const{t:Q}=ye("dndev"),i=Q,f=we(),R=!!f,[o,c]=A([]),[U,F]=A(!1),[z,H]=A(null),h=T(null),S=T(!1),x=T(void 0),Y=Pe(),b=y(e=>{const r=e.filter(a=>a.uploaded&&!a.error).map(a=>a.uploaded);I(p?r:r[0]||null)},[p,I]);j(()=>{if(S.current){S.current=!1;return}if(v){const e=[];(Array.isArray(v)?v:[v]).forEach(r=>{r.url&&e.push({id:X(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),c(e)}else c([])},[v]);const Z=y(async()=>{const e=o.filter(r=>!r.uploaded&&!r.error&&r.uploadProgress===null);if(e.length!==0){c(r=>r.map(a=>e.some(l=>l.id===a.id)?{...a,uploadProgress:0}:a));for(const r of e)try{const a=await xe(r.file,{storagePath:M,onProgress:l=>{c(u=>u.map(s=>s.id===r.id?{...s,uploadProgress:l.progress}:s))}});c(l=>{const u=l.map(s=>s.id===r.id?{...s,uploaded:a,uploadProgress:100,error:null}:s);return queueMicrotask(()=>b(u)),u})}catch{c(a=>a.map(l=>l.id===r.id?{...l,error:"Upload failed",uploadProgress:null}:l))}}},[o,M,b]);x.current=Z,j(()=>{if(!(!f||!m))return G.getState().registerUpload(f,m,async()=>{await x.current?.()}),()=>{G.getState().unregisterUpload(f,m)}},[f,m]),ue(K,()=>({upload:async()=>{await x.current?.()},getDocuments:()=>W.current||[]}),[]);const W=T(o);W.current=o;const _=e=>{const r=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],a="."+e.name.split(".").pop()?.toLowerCase();return r.includes(a)},E=y(e=>{const r=(p?k:1)-o.length;if(r<=0){P(new Error("Maximum documents reached"),{userMessage:i("document.errors.maxFiles",{max:k}),severity:"warning",showNotification:!0});return}const a=e.slice(0,r),l=[],u=(C/(1024*1024)).toFixed(0);for(const s of a){if(!_(s)){P(new Error("Invalid document type"),{userMessage:i("document.errors.invalidType",{fileName:s.name}),severity:"warning",showNotification:!0});continue}if(s.size>C){P(new Error("Document too large"),{userMessage:i("document.errors.exceedsSize",{fileName:s.name,size:u}),severity:"warning",showNotification:!0});continue}l.push({id:X(),file:s,uploadProgress:null,uploaded:null,error:null})}l.length!==0&&(c(s=>p?[...s,...l]:l),R||setTimeout(()=>x.current?.(),0))},[o,p,k,C,i,R]),$=e=>{const r=Array.from(e.target.files||[]);r.length>0&&E(r),h.current&&(h.current.value="")},ee=y(e=>{e.preventDefault(),F(!1);const r=Array.from(e.dataTransfer.files);E(r)},[E]),re=y(async e=>{const r=o.find(a=>a.id===e);if(r)try{r.uploaded&&await be(r.uploaded);const a=o.filter(l=>l.id!==e);S.current=!0,c(a),setTimeout(()=>b(a),0)}catch(a){P(a,{userMessage:i("document.delete.failed"),severity:"error",showNotification:!0})}},[o,b,i]),ae=e=>{e.uploaded?.url&&e.uploaded.mimeType==="application/pdf"&&H(e.uploaded.url)},te=p||o.length===0;return n(le,{children:[n(w,{gap:"tight",children:[n(g,{level:"body",align:"start",children:[d,J?"*":""]}),te&&n("div",{role:"button",tabIndex:0,"aria-label":i("document.upload.ariaLabel"),className:"dndev-surface","data-variant":D?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:U?"var(--primary)":D?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:U?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),F(!0)},onDragLeave:()=>F(!1),onDrop:ee,onClick:()=>h.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),h.current?.click())},children:[t("input",{ref:h,type:"file",accept:Y,multiple:p,style:{display:"none"},onChange:$}),n(w,{align:"center",justify:"center",children:[t(se,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),t(g,{as:"p",variant:"muted",level:"small",align:"center",children:i("document.upload.hint")}),t(g,{as:"p",variant:"muted",level:"caption",align:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&t(w,{gap:"tight",children:o.map((e,r)=>{const a=Ne(e.uploaded?.mimeType||e.file.type,e.file.name),l=e.uploadProgress!==null&&e.uploadProgress<100,u=e.uploaded?.mimeType==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf");return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[t(De,{type:a,className:"dndev-size-md"}),n(w,{gap:"none",style:{flex:1,minWidth:0},children:[t(g,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(g,{level:"caption",variant:"muted",children:[Te(e.uploaded?.size||e.file.size),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),l&&t(me,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),n(w,{direction:"row",gap:"tight",children:[O&&u&&e.uploaded&&t(B,{variant:q.GHOST,onClick:()=>ae(e),"aria-label":i("document.preview.ariaLabel"),children:t(ce,{className:"dndev-size-sm"})}),l?t(de,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):t(B,{variant:q.GHOST,onClick:()=>re(e.id),"aria-label":i("document.delete.ariaLabel"),children:t(oe,{className:"dndev-size-sm"})})]})]},e.id)})}),L&&t(g,{level:"caption",variant:D?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:L})]}),O&&z&&t(ge,{open:!!z,onOpenChange:()=>H(null),children:n(ve,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[t(fe,{children:t(he,{children:i("document.preview.title")})}),t("iframe",{src:z,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});V.displayName="DocumentFieldComponent";var ke=V;export{ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import{Select as g,Stack as v}from"@donotdev/components";import{useTranslation as m}from"@donotdev/core";const f=({label:o,value:r,options:n,error:s,helperText:a,onChange:l,onBlur:i,required:u})=>{const{t:p}=m("dndev"),c=r!=null?String(r):"";return d(v,{gap:"tight",children:[t(g,{label:o,value:c,onValueChange:e=>{l&&l({target:{value:e}})},onOpenChange:e=>!e&&i?.(),placeholder:p("actions.select","Select"),required:u,options:n.map(e=>({value:String(e.value),label:e.label}))}),a&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var h=f;export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,jsxs as u}from"react/jsx-runtime";import{useState as T,useMemo as k}from"react";import{Clock as x}from"lucide-react";import{Label as $,Stack as s,Button as S,Slider as w}from"@donotdev/components";const f=[15,30,45,60,90,120,150,180],N={15:"duration.15m",30:"duration.30m",45:"duration.45m",60:"duration.1h",90:"duration.1h30",120:"duration.2h",150:"duration.2h30",180:"duration.3h"};function q(e,n){const o=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,l=N[e];return!n||!l?o:n(`crud:${l}`,{defaultValue:o})??o}const W=({label:e,value:n,onChange:o,error:l,helperText:d,disabled:m,required:p,readonly:M,min:g=0,max:v=480,step:V=5,t})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,h=f.includes(r),[c,b]=T(!h&&r>0),C=k(()=>f.map(a=>({minutes:a,label:q(a,t)})),[t]),y=t?t("crud:duration.custom",{defaultValue:"Custom"}):"Custom";if(M){const a=r===0?t?t("crud:duration.zero",{defaultValue:"\u2014"}):"\u2014":r<60?t?t("crud:duration.minutes",{count:r,defaultValue:`${r} min`}):`${r} min`:t?t("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60,defaultValue:`${Math.floor(r/60)}h${r%60?` ${r%60}min`:""}`}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return u(s,{gap:"tight",children:[i($,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),u(s,{direction:"row",gap:"tight",align:"center",children:[i(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),i("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})}return u(s,{children:[i($,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),u(s,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[C.map(({minutes:a,label:z})=>u(S,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),o(a)},"aria-pressed":r===a,"aria-label":z,children:[i(x,{size:14,style:{marginRight:"var(--gap-xs)"},"aria-hidden":!0}),z]},a)),i(S,{type:"button",variant:c?"primary":"outline",disabled:m,onClick:()=>{b(!0),!h&&r>0?o(r):o(30)},"aria-pressed":c,"aria-label":y,children:y})]}),c&&i(s,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:i(w,{value:[h?30:r],onValueChange:([a])=>o(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:V,showValue:!0,disabled:m,"aria-label":e})}),d&&i("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var j=W;export{f as DURATION_PRESETS,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l,jsxs as c}from"react/jsx-runtime";import{Upload as Y,X as Z,File as $,Loader2 as ee,FileText as S,FileSpreadsheet as re,FileImage as ae,FileVideo as le,FileAudio as se,FileArchive as te,FileCode as ie}from"lucide-react";import{useCallback as h,useState as E,useRef as w,useEffect as O,useImperativeHandle as oe,forwardRef as ne}from"react";import{Button as de,BUTTON_VARIANT as ue,Text as y,Stack as F,Progress as ce}from"@donotdev/components";import{handleError as D,useTranslation as pe}from"@donotdev/core";import{useUploadContext as me}from"../../../contexts/UploadContext";import{useUploadStore as j}from"../../../stores/UploadStore";import{uploadFile as fe,deleteFile as ge,generateFileId as B,getFileIcon as ve,formatFileSize as he}from"../../../utils/fileStorage";function ye({type:m,className:o}){switch(m){case"pdf":return l(S,{className:o,style:{color:"var(--destructive)"}});case"doc":return l(S,{className:o,style:{color:"var(--primary)"}});case"xls":return l(re,{className:o,style:{color:"var(--success)"}});case"ppt":return l(S,{className:o,style:{color:"var(--warning)"}});case"image":return l(ae,{className:o});case"video":return l(le,{className:o});case"audio":return l(se,{className:o});case"archive":return l(te,{className:o});case"html":case"text":return l(ie,{className:o});default:return l($,{className:o})}}const H=ne(({name:m,label:o,value:f,onChange:A,error:b,helperText:M,accept:q,multiple:n=!1,maxFiles:T=10,maxSize:k=50*1024*1024,storagePath:I="uploads/files",required:G},V)=>{const{t:W}=pe("dndev"),d=W,g=me(),L=!!g,[t,u]=E([]),[R,P]=E(!1),v=w(null),z=w(!1),x=w(void 0),N=h(e=>{const r=e.filter(a=>a.uploaded&&!a.error).map(a=>a.uploaded);A(n?r:r[0]||null)},[n,A]);O(()=>{if(z.current){z.current=!1;return}if(f){const e=[];(Array.isArray(f)?f:[f]).forEach(r=>{r.url&&e.push({id:B(),file:new File([],r.filename),uploadProgress:null,uploaded:r,error:null})}),u(e)}else u([])},[f]);const X=h(async()=>{const e=t.filter(r=>!r.uploaded&&!r.error&&r.uploadProgress===null);if(e.length!==0){u(r=>r.map(a=>e.some(s=>s.id===a.id)?{...a,uploadProgress:0}:a));for(const r of e)try{const a=await fe(r.file,{storagePath:I,onProgress:s=>{u(p=>p.map(i=>i.id===r.id?{...i,uploadProgress:s.progress}:i))}});u(s=>{const p=s.map(i=>i.id===r.id?{...i,uploaded:a,uploadProgress:100,error:null}:i);return queueMicrotask(()=>N(p)),p})}catch{u(a=>a.map(s=>s.id===r.id?{...s,error:"Upload failed",uploadProgress:null}:s))}}},[t,I,N]);x.current=X,O(()=>{if(!(!g||!m))return j.getState().registerUpload(g,m,async e=>{await x.current?.()}),()=>{j.getState().unregisterUpload(g,m)}},[g,m]),oe(V,()=>({upload:async()=>{await x.current?.()},getFiles:()=>U.current||[]}),[]);const U=w(t);U.current=t;const C=h(e=>{const r=(n?T:1)-t.length;if(r<=0){D(new Error("Maximum files reached"),{userMessage:d("file.errors.maxFiles",{max:T}),severity:"warning",showNotification:!0});return}const a=e.slice(0,r),s=[],p=(k/(1024*1024)).toFixed(0);for(const i of a){if(i.size>k){D(new Error("File too large"),{userMessage:d("file.errors.exceedsSize",{fileName:i.name,size:p}),severity:"warning",showNotification:!0});continue}s.push({id:B(),file:i,uploadProgress:null,uploaded:null,error:null})}s.length!==0&&(u(i=>n?[...i,...s]:s),L||setTimeout(()=>x.current?.(),0))},[t,n,T,k,d,L]),_=e=>{const r=Array.from(e.target.files||[]);r.length>0&&C(r),v.current&&(v.current.value="")},J=h(e=>{e.preventDefault(),P(!1);const r=Array.from(e.dataTransfer.files);C(r)},[C]),K=h(async e=>{const r=t.find(a=>a.id===e);if(r)try{r.uploaded&&await ge(r.uploaded);const a=t.filter(s=>s.id!==e);z.current=!0,u(a),setTimeout(()=>N(a),0)}catch(a){D(a,{userMessage:d("file.delete.failed"),severity:"error",showNotification:!0})}},[t,N,d]),Q=n||t.length===0,Ne=t.some(e=>!e.uploaded&&!e.error&&e.uploadProgress===null);return c(F,{gap:"tight",children:[c(y,{level:"body",align:"start",children:[o,G?"*":""]}),Q&&c("div",{role:"button",tabIndex:0,"aria-label":d(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":b?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:R?"var(--primary)":b?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:R?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:J,onClick:()=>v.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),v.current?.click())},children:[l("input",{ref:v,type:"file",accept:q,multiple:n,style:{display:"none"},onChange:_}),c(F,{align:"center",justify:"center",children:[l(Y,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),l(y,{as:"p",variant:"muted",level:"small",align:"center",children:d(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),t.length>0&&l(F,{gap:"tight",children:t.map((e,r)=>{const a=ve(e.uploaded?.mimeType||e.file.type,e.file.name),s=e.uploadProgress!==null&&e.uploadProgress<100,p=e.uploaded&&!e.error;return c("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[l(ye,{type:a,className:"dndev-size-md"}),c(F,{gap:"none",style:{flex:1,minWidth:0},children:[l(y,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),c(y,{level:"caption",variant:"muted",children:[he(e.uploaded?.size||e.file.size),e.error&&c("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),s&&l(ce,{value:e.uploadProgress||0,max:100,style:{marginTop:"var(--gap-xs)"}})]}),s?l(ee,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):l(de,{variant:ue.GHOST,onClick:()=>K(e.id),"aria-label":d("file.delete.ariaLabel"),children:l(Z,{className:"dndev-size-sm"})})]},e.id)})}),M&&l(y,{level:"caption",variant:b?"destructive":"muted",style:{marginTop:"var(--gap-xs)"},children:M})]})});H.displayName="FileFieldComponent";var xe=H;export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as a,Fragment as w}from"react/jsx-runtime";import{useState as m}from"react";import{Checkbox as D,Label as H,Sheet as f,Stack as P,Text as V}from"@donotdev/components";import{useTranslation as j}from"@donotdev/core";const q=({checked:o=!1,onChange:l,required:u,privacyPolicyPath:s="/legal/privacy",termsPath:c="/legal/terms"})=>{const{t:r}=j("crud"),[y,d]=m(!1),[x,h]=m(!1),p=e=>{l&&l({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!o))},g=(e,b)=>{e.preventDefault(),b==="privacy"?d(!0):h(!0)},C=r("gdprConsent.consent",{defaultValue:"I agree to the"}),n=r("gdprConsent.privacyPolicy",{defaultValue:"privacy policy"}),i=r("gdprConsent.terms",{defaultValue:"terms of use"}),k=r("gdprConsent.and",{defaultValue:"and consent to the processing of my personal data."});return a(w,{children:[a(P,{direction:"row",align:"center",gap:"tight",children:[t(D,{checked:o,onCheckedChange:p}),t(H,{required:u,plain:!0,onClick:v,style:{cursor:"pointer"},children:a(V,{level:"small",children:[C," ",t("a",{href:s,onClick:e=>g(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:n})," / ",t("a",{href:c,onClick:e=>g(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," ",k]})})]}),t(f,{open:y,onOpenChange:d,side:"bottom",title:n,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:s,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:n})}),t(f,{open:x,onOpenChange:h,side:"bottom",title:i,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:i})})]})};var O=q;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as u}from"react/jsx-runtime";import{Label as b,Input as v,Stack as g}from"@donotdev/components";const h=({label:c,value:a={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:f})=>{const m=l=>{const e=parseFloat(l.target.value)||0;if(e>=-90&&e<=90){const n={...a,lat:e},s={target:{value:JSON.stringify(n)}};i(s)}},p=l=>{const e=parseFloat(l.target.value)||0;if(e>=-180&&e<=180){const n={...a,lng:e},s={target:{value:JSON.stringify(n)}};i(s)}};return u(g,{gap:"tight",children:[t(b,{required:f,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:c}),u(g,{direction:"row",children:[t(v,{label:"Latitude",type:"number",value:a.lat,onChange:m,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),t(v,{label:"Longitude",type:"number",value:a.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&t("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:o})]})};var y=h;export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";const
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";const n=({name:a,value:e})=>t("input",{type:"hidden",name:a,value:e});var d=n;export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as
|
|
1
|
+
"use client";import{jsx as r,jsxs as d,Fragment as J}from"react/jsx-runtime";import{DndContext as Q,closestCenter as Y,PointerSensor as Z,TouchSensor as _,useSensor as z,useSensors as ee}from"@dnd-kit/core";import{SortableContext as re,useSortable as te,rectSortingStrategy as oe,arrayMove as ae}from"@dnd-kit/sortable";import{CSS as ie}from"@dnd-kit/utilities";import{Upload as ne,X as j,Loader2 as le,GripVertical as se}from"lucide-react";import{forwardRef as de,useCallback as U,useImperativeHandle as ue,useRef as pe,useState as A}from"react";import{Text as f,Stack as S,Progress as ce}from"@donotdev/components";import{useTranslation as ge}from"@donotdev/core";import{useFileUpload as me}from"../../../hooks/useFileUpload";import{processImage as he}from"../../../utils/imageProcessing";import{uploadImage as fe}from"../../../utils/imageStorage";import{ImageViewerDialog as ve}from"../internal/ImageViewerDialog";const be=["image/*"];function ye(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function xe({file:t,index:v,multiple:b,onImageClick:p,onRemove:y,t:c}){const{attributes:a,listeners:R,setNodeRef:D,transform:g,transition:I,isDragging:x}=te({id:t.id}),w=t.progress!==null&&t.progress<100,l=b&&!w,n={transform:ie.Transform.toString(g),transition:I,position:"relative",width:100,height:100,borderRadius:"var(--radius-md)",border:"var(--border-width) solid var(--border)",overflow:"hidden",backgroundColor:"var(--surface)",opacity:x?.5:1,cursor:l?"grab":"pointer",userSelect:"none",touchAction:l?"none":"auto"};return r("div",{ref:D,style:n,...a,...l?R:{},onClick:()=>{x||p(v)},children:w?d(S,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(le,{style:{animation:"spin 1s linear infinite"}}),r(ce,{value:t.progress||0,style:{width:"80%"}})]}):t.error?d(S,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(j,{style:{color:"var(--destructive)"}}),r(f,{variant:"destructive",level:"small",children:t.error})]}):d(J,{children:[b&&r("div",{style:{position:"absolute",top:4,left:4,padding:2,background:"rgba(0,0,0,0.5)",borderRadius:"var(--radius-sm)",display:"flex",zIndex:2,pointerEvents:"none"},children:r(se,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:c("image.alt.upload",{index:v+1}),draggable:!1,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:m=>{m.stopPropagation(),y(t.id)},onPointerDown:m=>m.stopPropagation(),style:{position:"absolute",top:4,right:4,padding:4,background:"rgba(0,0,0,0.5)",border:"none",borderRadius:"var(--radius-sm)",cursor:"pointer",display:"flex",zIndex:2},children:r(j,{style:{color:"white",width:16,height:16}})}),!t.uploaded&&r("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:4,background:"rgba(0,0,0,0.7)",textAlign:"center",pointerEvents:"none"},children:r(f,{variant:"muted",level:"small",style:{color:"white"},children:c("image.upload.pending",{defaultValue:"Pending"})})})]})})}const E=de(({name:t="image",label:v,value:b,onChange:p,error:y,helperText:c,multiple:a=!1,maxFiles:R=10,maxSize:D=10*1024*1024,storagePath:g="uploads/images",required:I,capture:x},w)=>{const{t:l}=ge("crud"),n=pe(null),[m,F]=A(!1),[V,L]=A(0),N=ee(z(Z,{activationConstraint:{distance:8}}),z(_,{activationConstraint:{delay:200,tolerance:5}})),B=U(async(e,o)=>{const{fullBlob:h,thumbBlob:C}=await he(e);return fe(h,C,e.name,{storagePath:g,onProgress:k=>o(k.progress)})},[g]),{files:i,addFiles:P,removeFile:T}=me({name:t,value:b,onChange:p,multiple:a,maxFiles:R,maxSize:D,accept:be,storagePath:g,uploadFn:B}),M=e=>{const o=Array.from(e.target.files||[]);o.length>0&&P(o),n.current&&(n.current.value="")},q=U(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&P(Array.from(e.dataTransfer.files))},[P]),G=U(e=>{const{active:o,over:h}=e;if(h&&o.id!==h.id){const C=i.findIndex(s=>s.id===o.id),k=i.findIndex(s=>s.id===h.id);if(C!==-1&&k!==-1){const s=ae(i,C,k).filter(u=>u.uploaded||u.previewURL).map(u=>u.uploaded||{fullUrl:u.previewURL,thumbUrl:u.previewURL});p(a?s.length>0?s:null:s[0]||null)}}},[i,a,p]),H=e=>{L(e),F(!0)},K=(e,o)=>{},O=e=>{const o=i[e];o&&T(o.id)},W=e=>{L(e)},X=a||i.length===0;ue(w,()=>({upload:async()=>{},focus:()=>n.current?.focus()}),[]);const $=i.map(ye);return d(S,{gap:"tight",children:[d(f,{level:"body",align:"start",children:[v,I&&"*"]}),X&&d("div",{role:"button",tabIndex:0,onClick:()=>n.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&n.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:q,style:{border:`var(--border-width) dashed ${y?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:n,type:"file",accept:"image/*",capture:x,multiple:a,style:{display:"none"},onChange:M}),d(S,{align:"center",children:[r(ne,{style:{color:"var(--muted-foreground)"}}),r(f,{variant:"muted",level:"small",children:a?l("image.upload.dropzoneMultiple",{defaultValue:"Drop images here or click to upload"}):l("image.upload.dropzoneSingle",{defaultValue:"Drop image here or click to upload"})})]})]}),i.length>0&&r(Q,{sensors:N,collisionDetection:Y,onDragEnd:G,children:r(re,{items:i.map(e=>e.id),strategy:oe,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:i.map((e,o)=>r(xe,{file:e,index:o,multiple:a,onImageClick:H,onRemove:T,t:l},e.id))})})}),c&&r(f,{variant:y?"destructive":"muted",level:"small",children:c}),r(ve,{images:$,selectedIndex:V,open:m,onClose:()=>F(!1),onUpdate:K,onDelete:O,onNavigate:W,multiple:a})]})});E.displayName="ImageFieldComponent";var we=E;export{we as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Input as c,Stack as p}from"@donotdev/components";import{useTranslation as g}from"@donotdev/core";const m=({label:n,value:d={},onChange:a,error:r,helperText:t,required:s})=>{const{t:l}=g("dndev");return o(p,{gap:"tight",children:[o("div",{className:"dndev-surface","data-variant":r?"destructive":"default",style:{border:"1px solid",borderColor:r?"var(--destructive)":"var(--input)",borderRadius:"var(--radius-lg)",padding:"var(--gap-md)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",marginBottom:"var(--gap-md)"},children:"Map component placeholder"}),e(c,{label:n,type:"text",required:s,className:"dndev-w-full",placeholder:l("form.enterLocationData","Enter location data (JSON)"),value:JSON.stringify(d),onChange:i=>{try{const u=JSON.parse(i.target.value),v={target:{value:JSON.stringify(u)}};a(v)}catch{a({target:{value:"{}"}})}}})]}),t&&e("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:t})]})};var f=m;export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a,jsxs as d}from"react/jsx-runtime";import{X as T}from"lucide-react";import{useMemo as C,useId as z}from"react";import{Combobox as B,Badge as w,BADGE_VARIANT as R,Button as I,BUTTON_VARIANT as V,Stack as c}from"@donotdev/components";import{useTranslation as j}from"@donotdev/core";const E=({label:g,value:s=[],options:o,error:v,helperText:n,onChange:u,onBlur:h,required:f,className:N})=>{const{t:p}=j("dndev"),m=z(),S=C(()=>o.map(e=>({value:String(e.value),label:e.label})),[o]),y=e=>{const r=Array.isArray(e)?e:[e],t={target:{value:JSON.stringify(r)}};u(t)},A=e=>{e||h?.()},b=e=>{const r=s.filter(l=>l!==e),t={target:{value:JSON.stringify(r)}};u(t)},i=!!v,x=`${m}-error`,O=`${m}-helper`;return d(c,{gap:"tight",className:N,children:[s.length>0&&a(c,{direction:"row",wrap:"wrap",children:s.map((e,r)=>{const t=o.find(l=>String(l.value)===e)?.label||e;return d(w,{variant:R.SECONDARY,className:"dndev-gap-sm",children:[t,a(I,{type:"button",variant:V.GHOST,style:{padding:0,height:"auto"},onClick:()=>b(e),children:a(T,{className:"dndev-size-md"})})]},r)})}),a(B,{label:g,value:s,onValueChange:y,onOpenChange:A,placeholder:p("actions.selectOptions","Select options..."),emptyMessage:p("messages.noResults","No results found"),options:S,multiple:!0,required:f,variant:i?"destructive":void 0}),i&&d(c,{id:x,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:O,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var $=E;export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n,jsxs as d}from"react/jsx-runtime";import{useState as y}from"react";import{Input as h,Button as b,Stack as i}from"@donotdev/components";import{useTranslation as x}from"@donotdev/core";const N=({label:u,value:o=[],onChange:l,className:c,required:p})=>{const{t:s}=x("dndev"),[t,m]=y(""),g=()=>{if(t.trim()){const e=[...o,t.trim()],r={target:{value:JSON.stringify(e)}};l(r),m("")}},f=e=>{const r=o.filter((w,v)=>v!==e),a={target:{value:JSON.stringify(r)}};l(a)};return d(i,{className:c,children:[d(i,{direction:"row",align:"end",children:[n(h,{label:u,type:"text",value:t,onChange:e=>m(e.target.value),required:p,className:"dndev-flex-1",placeholder:s("form.typeAndPressAdd","Type and press Add...")}),n(b,{type:"button",onClick:g,disabled:!t.trim(),children:s("form.add","Add")})]}),n(i,{direction:"row",wrap:"wrap",children:o.map((e,r)=>d("span",{className:"dndev-surface","data-variant":"muted",style:{display:"inline-flex",alignItems:"center",gap:"var(--gap-sm)",padding:"var(--gap-sm) var(--gap-md)",fontSize:"var(--font-size-sm)",fontWeight:500,borderRadius:"var(--radius-lg)"},children:[e,n("button",{type:"button",onClick:()=>f(r),style:{color:"var(--muted-foreground)",marginInlineStart:"var(--gap-sm)"},onMouseEnter:a=>{a.currentTarget.style.color="var(--foreground)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--muted-foreground)"},"aria-label":`${s("form.remove","Remove")} ${e}`,children:"\xD7"})]},r))})]})};var S=N;export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as v,jsxs as j}from"react/jsx-runtime";import{useState as q,useEffect as z,useCallback as f}from"react";import{Input as D,cn as E,Stack as I}from"@donotdev/components";import{useTranslation as L}from"@donotdev/core";const M=({label:b,value:l,onChange:i,error:g,helperText:c,min:x,max:y,step:N,disabled:s,required:S,className:h,mask:r="number",...F})=>{const{i18n:T}=L(),n=T?.language||(typeof navigator<"u"?navigator.language:"en-US"),u=f(e=>e==null||isNaN(e)?"":r==="currency"?e.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2}):r==="mileage"?Math.round(e).toLocaleString(n):e.toString(),[r,n]),k=f(e=>{if(!e||e.trim()==="")return null;const t=new Intl.NumberFormat(n).formatToParts(1234.56),a=t.find(m=>m.type==="group")?.value||",",C=t.find(m=>m.type==="decimal")?.value||".";let o=e.replace(new RegExp(`\\${a}`,"g"),"");o=o.replace(C,"."),o=o.replace(/[^\d.\-]/g,"");const p=parseFloat(o);return isNaN(p)?null:p},[n]),[w,d]=q(()=>u(l));return z(()=>{d(u(l))},[l,u]),j(I,{gap:"tight",children:[v(D,{type:r==="number"?"number":"text",inputMode:r==="number"?void 0:"decimal",label:b,value:w,onChange:e=>{const t=e.target.value;if(d(t),r==="number"){const a=parseFloat(t);isNaN(a)?i(e):i({...e,target:{...e.target,value:a.toString()}})}else{const a=k(t);a!==null?i({...e,target:{...e.target,value:a.toString()}}):t===""&&i({...e,target:{...e.target,value:""}})}},min:x,max:y,step:N,disabled:s,required:S,className:E("dndev-w-full",h),"data-variant":g?"destructive":void 0,style:{opacity:s?"var(--opacity-muted)":void 0,cursor:s?"not-allowed":void 0},...F}),c&&v("p",{style:{fontSize:"var(--font-size-xs)",color:g?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:c})]})};var G=M;export{G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a,jsxs as d}from"react/jsx-runtime";import{useId as i}from"react";import{PasswordInput as u,Stack as m}from"@donotdev/components";const p=({label:o,value:s,onChange:t,error:n,helperText:e,...r})=>{const l=i();return d(m,{gap:"tight",children:[a(u,{id:l,value:s??"",onChange:t,label:o,className:"dndev-w-full",required:r.required,...r}),e&&a("p",{style:{fontSize:"var(--font-size-xs)",color:n?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:e})]})};var c=p;export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{useState as
|
|
1
|
+
"use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{useState as L,useMemo as p,useEffect as k,useId as E}from"react";import{Input as M,FloatingLabel as O,Button as U,BUTTON_VARIANT as j,DropdownMenu as q,Stack as g,cn as D}from"@donotdev/components";import{Flag as S,COUNTRIES as y}from"@donotdev/core";const V=({label:T,value:d="",onChange:C,error:R,helperText:f,required:F=!1,disabled:v=!1,defaultCountry:x="FR",showFlags:N=!0,preferredCountries:c,countries:h})=>{const o=E(),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(I=>I.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===x)||n[0]||y[0],[x,n]),{country:b,phoneNumber:$}=p(()=>{if(!d)return{country:u,phoneNumber:""};const e=n.find(t=>d.startsWith(t.dialCode));if(e){let t=d.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(d.startsWith("+"))return{country:u,phoneNumber:d};let r=d.trim();return r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim(),{country:u,phoneNumber:r}},[d,u,n]),[a,W]=L(u);k(()=>{b.code!==a.code&&W(b)},[b,a.code]);const z=$,w=e=>{W(e);let r=z;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:e.dialCode+(r?" "+r:"")}};C(t)},A=e=>{let r=e.target.value;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:a.dialCode+(r?" "+r:"")}};C(t)},B=n.map(e=>({label:e.dialCode,onClick:()=>w(e),checked:e.code===a.code,children:N?s(g,{direction:"row",align:"center",gap:"tight",children:[i(S,{code:e.flagCode,title:e.name}),i("span",{children:e.dialCode}),i("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-xs)"},children:e.name})]}):s("span",{children:[e.dialCode," ",e.name]})})),l=!!R;return s(g,{gap:"tight",children:[i(O,{htmlFor:o,label:T,disabled:v,required:F,children:s("div",{className:"dndev-relative",style:{display:"flex",gap:0},children:[i(q,{trigger:i(U,{type:"button",variant:j.OUTLINE,disabled:v,style:{minWidth:"fit-content",padding:"0 var(--gap-md)",borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0,borderRadius:"var(--radius-md) 0 0 var(--radius-md)"},"aria-label":`Country code: ${a.dialCode}`,children:s(g,{direction:"row",align:"center",gap:"tight",children:[N&&i(S,{code:a.flagCode,title:a.name}),i("span",{children:a.dialCode})]})}),items:B,contentWidth:"16rem"}),i(M,{id:o,type:"tel",inputMode:"tel",value:z,onChange:A,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":D(l&&`${o}-error`,f&&!l&&`${o}-helper`),"aria-invalid":l})]})}),l&&s(g,{id:`${o}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),R]}),f&&!l&&i("p",{id:`${o}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:f})]})};var _=V;export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{useId as R,useState as U}from"react";import{Input as C,Checkbox as q,Stack as z,Select as D,CollapsiblePrimitive as E,CollapsibleTrigger as A,CollapsibleContent as B}from"@donotdev/components";import{useTranslation as G,getCurrencySymbol as H}from"@donotdev/core";import{CirclePlus as J,CircleMinus as L}from"lucide-react";const O=["EUR","USD","GBP","CHF","JPY","KRW"],Y=({label:f,value:n,onChange:I,error:s,helperText:g,required:P=!1,disabled:c=!1,placeholder:N="0",defaultCurrency:i="EUR",optionsTitle:x="Price options",currencies:b})=>{const u=R(),{t:p}=G("crud"),r=b?.length?b:[...O],h=n?.currency??i,m=r.includes(h)?h:r[0]??i,T=n?.vatIncluded??!0,y=n?.discountPercent??0,S=`${f} (${H(m)})`,d=e=>{const l=e.amount!==void 0?e.amount:n?.amount??0;let t=e.currency!==void 0?e.currency:n?.currency??i;r.includes(t)||(t=m);const F=e.vatIncluded!==void 0?e.vatIncluded:n?.vatIncluded??!0,M=e.discountPercent!==void 0?e.discountPercent:n?.discountPercent??0;I({amount:Number(l),currency:t,vatIncluded:F,discountPercent:Number(M)})},k=e=>{const l=e.target.value;if(l===""||l===null){d({amount:0});return}const t=parseFloat(l);d({amount:isNaN(t)?0:t})},V=e=>{d({currency:e||i})},$=e=>{const l=e.target.value;if(l===""||l===null){d({discountPercent:0});return}const t=parseFloat(l);d({discountPercent:isNaN(t)?0:t})},[v,j]=U(!1);return o(E,{open:v,onOpenChange:j,children:[o(z,{children:[o("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"var(--gap-sm)",alignItems:"end"},children:[a(C,{id:u,type:"number",inputMode:"decimal",label:S,value:n?.amount!==void 0&&n?.amount!==null?n.amount:"",onChange:k,disabled:c,placeholder:N,required:P,min:0,step:.01,"data-variant":s?"destructive":void 0,"aria-invalid":s}),a(A,{asChild:!0,children:a("button",{type:"button","aria-label":x,"aria-expanded":v,className:"dndev-collapsible-trigger",style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"var(--gap-sm)",background:"none",border:"none",cursor:"pointer"},children:v?a(L,{className:"dndev-collapsible-icon","aria-hidden":"true"}):a(J,{className:"dndev-collapsible-icon","aria-hidden":"true"})})})]}),a(B,{className:"dndev-collapsible-content",children:o("div",{style:{display:"grid",gridTemplateColumns:r.length>1?"1fr auto 1fr":"auto 1fr",gap:"var(--gap-sm)",alignItems:"end",paddingTop:"var(--gap-md)"},children:[r.length>1&&a(D,{value:m,onValueChange:V,placeholder:i,options:r.map(e=>({value:e,label:e})),disabled:c,label:p("price.currency",{defaultValue:"Currency"})}),a(q,{id:`${u}-vat`,label:p("price.vatIncluded",{defaultValue:"VAT Incl."}),checked:T,onCheckedChange:e=>d({vatIncluded:e===!0}),disabled:c}),a(C,{id:`${u}-discount`,type:"number",inputMode:"decimal",min:0,max:100,step:1,value:y===0?"":y,onChange:$,disabled:c,placeholder:"0",label:p("price.discountLabel",{defaultValue:"Discount (%)"})})]})})]}),g&&a("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)"},children:g})]})};var w=Y;export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as u}from"react/jsx-runtime";import{RadioGroup as f,Label as c,Stack as p}from"@donotdev/components";const v=({label:o,value:t,onChange:a,options:s,error:i,helperText:r,required:l})=>{const n=d=>{a({target:{value:d}})};return u(p,{gap:"tight",children:[e(c,{required:l,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:o}),e(f,{value:t,onValueChange:n,items:s}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)"},children:r})]})};var h=v;export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Label as h,Slider as b,Stack as d}from"@donotdev/components";const x=({label:o,value:i=0,onChange:u,error:n,helperText:s,min:r=0,max:c=100,step:v=1,disabled:a,required:m,showValue:f=!0})=>{const g=t=>{const p={target:{value:t.toString()}};u(p)};return l(d,{gap:"tight",children:[l(d,{direction:"row",justify:"between",align:"center",children:[e(h,{required:m,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:o}),f&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:i})]}),e(b,{value:[i??r],onValueChange:([t])=>g(t??r),min:r,max:c,step:v,disabled:a,style:{borderColor:n?"var(--destructive)":void 0,opacity:a?"var(--opacity-muted)":void 0,cursor:a?"not-allowed":void 0},"aria-label":o}),s&&e("p",{style:{fontSize:"var(--font-size-xs)",color:n?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:s})]})};var y=x;export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as
|
|
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 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as S,useId as A}from"react";import{Combobox as $,Stack as c}from"@donotdev/components";import{useTranslation as j}from"@donotdev/core";const q=({label:r,value:s,onChange:p,options:i,isLoading:u=!1,error:f,helperText:o,required:h,onBlur:m,onCreate:I,placeholder:g})=>{const{t:l}=j("crud"),n=A(),v=S(()=>i.map(e=>({value:e.id,label:e.label,description:e.description})),[i]),b=e=>{const z=Array.isArray(e)?e[0]||"":e;p(z)},x=e=>{e||m?.()},a=!!f,y=`${n}-error`,C=`${n}-helper`;return d(c,{gap:"tight",children:[t($,{label:r,value:s||"",onValueChange:b,onOpenChange:x,placeholder:g||l("reference.placeholder",{label:r})||`Select ${r}`,emptyMessage:l("reference.noResults")||"No results found",options:v,required:h,variant:a?"destructive":void 0,isLoading:u,clearable:!!s}),a&&d(c,{id:y,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),o]}),o&&!a&&t("p",{id:C,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var L=q;export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as
|
|
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 n 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,h]=f(!1);return g(()=>{h(!0)},[]),c?e(v,{gap:"tight",children:e(b,{fallback:e(n,{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(n,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})})}):e(n,{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 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Switch as k,Text as l,Stack as n}from"@donotdev/components";import{useTranslation as m}from"@donotdev/core";const p=({label:a,checked:d=!1,onChange:r,uncheckedLabel:h,checkedLabel:s,helperText:c})=>{const{t:g}=m("dndev"),i=o=>{r&&r({target:{checked:o}})};return e(n,{gap:"tight",children:[e(n,{direction:"row",align:"center",style:{flexWrap:"wrap"},children:[e(l,{level:"body",align:"start",children:[a,":"]}),t(k,{checked:d,onCheckedChange:i,"aria-label":a,variant:"muted",uncheckedLabel:h,checkedLabel:s})]}),c&&t(l,{as:"p",variant:"muted",level:"small",children:c})]})};var b=p;export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as L,useId as N,useRef as F,useEffect as j}from"react";import{Textarea as q,FloatingLabel as A,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,value:o="",onChange:b,error:h,helperText:s,rows:y=3,loading:l=!1,maxLength:r,showCharCount:v=!1,autoResize:i=!1,required:z=!1,disabled:g=!1,className:w,...S})=>{const e=N(),[I,f]=L(!1),d=F(null),a=!!h,c=o.length,$=r&&c>r*.8,C=r&&c>r;return j(()=>{if(i&&d.current){const u=d.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[o,i]),n(p,{gap:"tight",children:[t(A,{htmlFor:e,label:x,disabled:g||l,required:z,children:n("div",{className:"dndev-relative",children:[t(q,{ref:d,id:e,value:o,onChange:b,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||l,maxLength:r,rows:i?1:y,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",w),"data-variant":a?"destructive":void 0,style:{resize:i?"none":void 0},...S}),l&&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:C?"var(--destructive-foreground)":$?"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
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n,jsxs as o}from"react/jsx-runtime";import{useId as w}from"react";import{Input as C,cn as c,Stack as u}from"@donotdev/components";const S=({label:h,value:d="",onChange:v,error:l,helperText:a,type:g="text",loading:f=!1,maxLength:r,showCharCount:s=!1,required:p=!1,disabled:m=!1,className:x,...y})=>{const e=w(),t=!!l,i=d.length,z=r&&i>r*.8,$=r&&i>r,{children:q,...b}=y;return o(u,{gap:"tight",children:[n(C,{id:e,type:g,value:d,onChange:v,label:h,disabled:m||f,maxLength:r,required:p,"aria-describedby":c(t&&`${e}-error`,a&&!t&&`${e}-helper`,s&&`${e}-count`),"aria-invalid":t,className:c("dndev-w-full",x),"data-variant":t?"destructive":void 0,...b}),s&&r&&o("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:$?"var(--destructive-foreground)":z?"var(--warning)":"var(--muted-foreground)"},children:[i,"/",r]}),t&&o(u,{id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),l]}),a&&!t&&n("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})};var j=S;export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import d from"./DateFieldComponent";const g=({label:a,value:e,onChange:r,error:o,helperText:l,mode:n="datetime-local",required:u})=>{const i=e?new Date(e).toISOString():"";return s(d,{label:a,value:i,onChange:t=>{if(t){const m={target:{value:new Date(t).toISOString()}};r(m)}else r({target:{value:""}})},error:o,helperText:l,mode:n,required:u})};var p=g;export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as
|
|
1
|
+
import{default as o}from"./AvatarFieldComponent";import{default as t}from"./BadgeFieldComponent";import{default as e}from"./TextFieldComponent";import{default as a}from"./NumberFieldComponent";import{default as m}from"./DateFieldComponent";import{default as r}from"./CheckboxFieldComponent";import{default as n}from"./ComboboxComponent";import{default as p}from"./DropdownComponent";import{default as s}from"./MultiDropdownComponent";import{default as i}from"./FileFieldComponent";import{default as d}from"./ImageFieldComponent";import{default as f}from"./DocumentFieldComponent";import{default as l}from"./TextAreaComponent";import{default as u}from"./SwitchFieldComponent";import{default as C}from"./RadioFieldComponent";import{default as F}from"./RangeFieldComponent";import{default as T}from"./RatingFieldComponent";import{default as R}from"./DurationFieldComponent";import{DURATION_PRESETS as x}from"./DurationFieldComponent";import{default as D}from"./PhoneNumberComponent";import{default as c}from"./GeoPointFieldComponent";import{default as P}from"./MapFieldComponent";import{default as b}from"./TimestampFieldComponent";import{default as A}from"./MultiInputTextFieldComponent";import{default as S}from"./ButtonFieldComponent";import{default as g}from"./HiddenFieldComponent";import{default as h}from"./PasswordFieldComponent";import{default as w}from"./AddressFieldComponent";import{default as E}from"./CurrencyFieldComponent";import{default as I}from"./PriceFieldComponent";import{default as N}from"./RichTextComponent";import{default as M}from"./GdprConsentFieldComponent";export{w as AddressFieldComponent,o as AvatarFieldComponent,t as BadgeFieldComponent,S as ButtonFieldComponent,r as CheckboxFieldComponent,n as ComboboxComponent,E as CurrencyFieldComponent,x as DURATION_PRESETS,m as DateFieldComponent,f as DocumentFieldComponent,p as DropdownComponent,R as DurationFieldComponent,i as FileFieldComponent,M as GdprConsentFieldComponent,c as GeoPointFieldComponent,g as HiddenFieldComponent,d as ImageFieldComponent,P as MapFieldComponent,s as MultiDropdownComponent,A as MultiInputTextFieldComponent,a as NumberFieldComponent,h as PasswordFieldComponent,D as PhoneNumberComponent,I as PriceFieldComponent,C as RadioFieldComponent,F as RangeFieldComponent,T as RatingFieldComponent,N as RichTextComponent,u as SwitchFieldComponent,l as TextAreaComponent,e as TextFieldComponent,b as TimestampFieldComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as
|
|
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:`
|
|
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},
|
|
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};
|