@donotdev/crud 0.3.1 → 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.
- package/dist/CrudService.bulk.js +1 -1
- package/dist/CrudService.bulkAcross.js +1 -1
- package/dist/CrudService.bulkReconciliation.js +1 -1
- package/dist/CrudService.cache.d.ts +8 -0
- package/dist/CrudService.cache.d.ts.map +1 -1
- package/dist/CrudService.cache.js +1 -1
- package/dist/CrudService.d.ts +7 -2
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.internal.js +2 -2
- package/dist/CrudService.js +1 -1
- package/dist/CrudService.mutations.js +1 -1
- package/dist/CrudService.optimistic.js +1 -1
- package/dist/CrudService.queries.js +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/CrudService.writeRules.js +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.js +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.d.ts.map +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/SortableCardList.js +1 -1
- package/dist/components/YearFilter.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/ControlledFieldArrayField.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/fieldOptions.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/ControlledReferenceField.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.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.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/InlineFieldRow.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/fieldTypeRegistry.store.js +1 -1
- package/dist/forms/FormNavigation.js +1 -1
- package/dist/forms/childRows.js +1 -1
- package/dist/forms/extend.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.js +1 -1
- package/dist/forms/hooks/useFormDraftState.js +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/conditionAwareResolver.js +1 -1
- package/dist/forms/utils/emptyValue.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/forms/utils/writableFields.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useChildRows.js +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useCrudPageSize.js +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useExtensionRows.js +1 -1
- package/dist/hooks/useFieldConditions.js +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useReferenceResolver.js +1 -1
- package/dist/hooks/useRelatedItems.js +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/stores/uploadStoreRef.js +1 -1
- package/dist/symbol-index.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +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/useCrudDoc.d.ts +8 -1
- package/dist/useCrudDoc.d.ts.map +1 -1
- package/dist/useCrudDoc.js +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/useServerPrefetch.js +1 -1
- package/dist/utils/clientListProcessing.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/filterUrl.js +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.js +1 -1
- package/dist/utils/imageUtils.js +1 -1
- package/dist/utils/matchesFilter.js +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/referenceEntity.js +1 -1
- package/dist/utils/routeRecord.d.ts +21 -0
- package/dist/utils/routeRecord.d.ts.map +1 -0
- package/dist/utils/routeRecord.js +1 -0
- package/dist/utils/sanitizeHtml.js +1 -1
- package/dist/utils/scopeUtils.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/utils/useRowTranslator.js +1 -1
- package/dist/workflows/WorkflowPersistence.js +1 -1
- package/dist/workflows/defineWorkflow.js +1 -1
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/guidelines/COMPONENTS.md +1 -1
- package/guidelines/CRUD.md +3 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as
|
|
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
|
|
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
|
-
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 s,Fragment as
|
|
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 e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Input as v,Stack as p}from"@donotdev/components";import{useTranslation as g}from"@donotdev/core";const m=({label:n,value:d={},onChange:a,error:r,helperText:t,required:s})=>{const{t:l}=g("crud");return o(p,{gap:"tight",children:[o("div",{className:"dndev-surface","data-variant":r?"destructive":"default",style:{border:"1px solid",borderColor:r?"var(--destructive)":"var(--input)",borderRadius:"var(--radius-lg)",padding:"var(--gap-md)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",marginBottom:"var(--gap-md)"},children:"Map component placeholder"}),e(v,{label:n,type:"text",required:s,className:"dndev-w-full",placeholder:l("form.enterLocationData","Enter location data (JSON)"),value:JSON.stringify(d),onChange:i=>{try{const u=JSON.parse(i.target.value),c={target:{value:JSON.stringify(u)}};a(c)}catch{a({target:{value:"{}"}})}}})]}),t&&e("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:t})]})};var f=m;export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
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
|
|
1
|
+
"use client";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useState as h}from"react";import{Input as b,Button as x,Stack as d}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";const S=({label:m,info:c,value:o=[],onChange:l,className:g,required:p})=>{const{t:s}=N("crud"),[t,u]=h(""),f=()=>{if(t.trim()){const e=[...o,t.trim()],r={target:{value:JSON.stringify(e)}};l(r),u("")}},v=e=>{const r=o.filter((A,y)=>y!==e),a={target:{value:JSON.stringify(r)}};l(a)};return i(d,{className:g,children:[i(d,{direction:"row",align:"end",children:[n(b,{label:m,info:c,type:"text",value:t,onChange:e=>u(e.target.value),required:p,className:"dndev-flex-1",placeholder:s("form.typeAndPressAdd","Type and press Add...")}),n(x,{type:"button",onClick:f,disabled:!t.trim(),children:s("form.add","Add")})]}),n(d,{direction:"row",wrap:"wrap",children:o.map((e,r)=>i("span",{className:"dndev-surface","data-variant":"muted",style:{display:"inline-flex",alignItems:"center",gap:"var(--gap-sm)",padding:"var(--gap-sm) var(--gap-md)",fontSize:"var(--font-size-sm)",fontWeight:500,borderRadius:"var(--radius-lg)"},children:[e,n("button",{type:"button",onClick:()=>v(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 w=S;export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as v,jsxs as q}from"react/jsx-runtime";import{useState as z,useEffect as D,useCallback as f}from"react";import{Input as E,cn as I,Stack as L}from"@donotdev/components";import{useTranslation as M}from"@donotdev/core";const P=({label:b,info:x,value:l,onChange:i,error:g,helperText:c,min:y,max:N,step:S,disabled:s,required:h,className:w,mask:r="number",...F})=>{const{i18n:k}=M(),n=k?.language||(typeof navigator<"u"?navigator.language:"en-US"),u=f(a=>a==null||isNaN(a)?"":r==="currency"?a.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2}):r==="mileage"?Math.round(a).toLocaleString(n):a.toString(),[r,n]),C=f(a=>{if(!a||a.trim()==="")return null;const t=new Intl.NumberFormat(n).formatToParts(1234.56),e=t.find(m=>m.type==="group")?.value||",",j=t.find(m=>m.type==="decimal")?.value||".";let o=a.replace(new RegExp(`\\${e}`,"g"),"");o=o.replace(j,"."),o=o.replace(/[^\d.\-]/g,"");const p=parseFloat(o);return isNaN(p)?null:p},[n]),[T,d]=z(()=>u(l));return D(()=>{d(u(l))},[l,u]),q(L,{gap:"tight",children:[v(E,{type:r==="number"?"number":"text",inputMode:r==="number"?void 0:"decimal",label:b,info:x,value:T,onChange:a=>{const t=a.target.value;if(d(t),r==="number"){const e=parseFloat(t);isNaN(e)?i(a):i({...a,target:{...a.target,value:e.toString()}})}else{const e=C(t);e!==null?i({...a,target:{...a.target,value:e.toString()}}):t===""&&i({...a,target:{...a.target,value:""}})}},min:y,max:N,step:S,disabled:s,required:h,className:I("dndev-w-full",w),"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 H=P;export{H 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 u}from"react";import{PasswordInput as f,Stack as m}from"@donotdev/components";const p=({label:o,info:s,value:t,onChange:n,error:i,helperText:e,...r})=>{const l=u();return d(m,{gap:"tight",children:[a(f,{id:l,value:t??"",onChange:n,label:o,info:s,className:"dndev-w-full",required:r.required,...r}),e&&a("p",{style:{fontSize:"var(--font-size-xs)",color:i?"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
|
|
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
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l,jsxs as c}from"react/jsx-runtime";import{CirclePlus as q,CircleMinus as z}from"lucide-react";import{useId as E,useState as B}from"react";import{Input as C,Checkbox as D,Stack as G,Select as H,CollapsiblePrimitive as J,CollapsibleTrigger as K,CollapsibleContent as L}from"@donotdev/components";import{useTranslation as O,getCurrencySymbol as V}from"@donotdev/core";const Y=["EUR","USD","GBP","CHF","JPY","KRW"],w=({label:f,info:I,value:a,onChange:P,error:s,helperText:g,required:N=!1,disabled:o=!1,placeholder:x="0",defaultCurrency:d="EUR",optionsTitle:T="Price options",currencies:b})=>{const u=E(),{t:p}=O("crud"),t=b?.length?b:[...Y],h=a?.currency??d,m=t.includes(h)?h:t[0]??d,k=a?.vatIncluded??!0,y=a?.discountPercent??0,S=`${f} (${V(m)})`,i=e=>{const n=e.amount!==void 0?e.amount:a?.amount??null;let r=e.currency!==void 0?e.currency:a?.currency??d;t.includes(r)||(r=m);const R=e.vatIncluded!==void 0?e.vatIncluded:a?.vatIncluded??!0,U=e.discountPercent!==void 0?e.discountPercent:a?.discountPercent??0;P({amount:n===null?null:Number(n),currency:r,vatIncluded:R,discountPercent:Number(U)})},$=e=>{const n=e.target.value;if(n===""||n===null){i({amount:null});return}const r=parseFloat(n);i({amount:isNaN(r)?null:r})},j=e=>{i({currency:e||d})},F=e=>{const n=e.target.value;if(n===""||n===null){i({discountPercent:0});return}const r=parseFloat(n);i({discountPercent:isNaN(r)?0:r})},[v,M]=B(!1);return c(J,{open:v,onOpenChange:M,children:[c(G,{children:[c("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"var(--gap-sm)",alignItems:"end"},children:[l(C,{id:u,type:"number",inputMode:"decimal",label:S,info:I,value:a?.amount!==void 0&&a?.amount!==null?a.amount:"",onChange:$,disabled:o,placeholder:x,required:N,min:0,step:.01,"data-variant":s?"destructive":void 0,"aria-invalid":s}),l(K,{asChild:!0,children:l("button",{type:"button","aria-label":T,"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?l(z,{className:"dndev-collapsible-icon","aria-hidden":"true"}):l(q,{className:"dndev-collapsible-icon","aria-hidden":"true"})})})]}),l(L,{className:"dndev-collapsible-content",children:c("div",{style:{display:"grid",gridTemplateColumns:t.length>1?"1fr auto 1fr":"auto 1fr",gap:"var(--gap-sm)",alignItems:"end",paddingTop:"var(--gap-md)"},children:[t.length>1&&l(H,{value:m,onValueChange:j,placeholder:d,options:t.map(e=>({value:e,label:e})),disabled:o,label:p("price.currency")}),l(D,{id:`${u}-vat`,label:p("price.vatIncluded"),checked:k,onCheckedChange:e=>i({vatIncluded:e===!0}),disabled:o}),l(C,{id:`${u}-discount`,type:"number",inputMode:"decimal",min:0,max:100,step:1,value:y===0?"":y,onChange:F,disabled:o,placeholder:"0",label:p("price.discountLabel")})]})})]}),g&&l("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)"},children:g})]})};var A=w;export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as d}from"react/jsx-runtime";import{RadioGroup as f,Label as p,Stack as c}from"@donotdev/components";const v=({label:t,value:o,onChange:a,options:s,error:i,helperText:r,required:n})=>{const l=u=>{a({target:{value:u}})};return d(c,{gap:"tight",children:[e(p,{required:n,style:{display:"block",fontSize:"var(--font-size-input)",fontWeight:500},children:t}),e(f,{value:o,onValueChange:l,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:a,value:i=0,onChange:u,error:n,helperText:s,min:r=0,max:c=100,step:v=1,disabled:t,required:m,showValue:f=!0})=>{const g=o=>{const p={target:{value:o.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:a}),f&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:i})]}),e(b,{value:[i??r],onValueChange:([o])=>g(o??r),min:r,max:c,step:v,disabled:t,style:{borderColor:n?"var(--destructive)":void 0,opacity:t?"var(--opacity-muted)":void 0,cursor:t?"not-allowed":void 0},"aria-label":a}),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 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
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as A,useId as $}from"react";import{Combobox as j,Stack as c}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";const L=({label:r,info:p,value:l,onChange:u,options:n,isLoading:f=!1,error:h,helperText:o,required:m,onBlur:g,onCreate:I,placeholder:v})=>{const{t:s}=q("crud"),i=$(),b=A(()=>n.map(e=>({value:e.id,label:e.label,description:e.description})),[n]),x=e=>{const S=Array.isArray(e)?e[0]||"":e;u(S)},y=e=>{e||g?.()},a=!!h,C=`${i}-error`,z=`${i}-helper`;return d(c,{gap:"tight",children:[t(j,{label:r,info:p,value:l||"",onValueChange:x,onOpenChange:y,placeholder:v||s("reference.placeholder",{label:r})||`Select ${r}`,emptyMessage:s("reference.noResults")||"No results found",options:b,required:m,variant:a?"destructive":void 0,isLoading:f,clearable:!!l}),a&&d(c,{id:C,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:z,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var M=L;export{M 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 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
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Switch as i,Text as s,Stack as o}from"@donotdev/components";import{InlineFieldRow as m}from"./internal/InlineFieldRow";const k=({label:t,checked:a=!1,onChange:c,uncheckedLabel:r,checkedLabel:h,helperText:l})=>n(o,{gap:"tight",children:[e(m,{children:e(i,{checked:a,onCheckedChange:d=>{c&&c({target:{checked:d}})},label:t,variant:a?"primary":"muted",uncheckedLabel:r,checkedLabel:h})}),l&&e(s,{as:"p",variant:"muted",level:"small",children:l})]});var p=k;export{p 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 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
|
-
"use client";import{jsx as o,jsxs as
|
|
1
|
+
"use client";import{jsx as o,jsxs as i}from"react/jsx-runtime";import{useId as S}from"react";import{Input as j,cn as c,Stack as u}from"@donotdev/components";function q({label:f,info:h,value:d="",onChange:v,error:l,helperText:a,type:g="text",loading:p=!1,maxLength:e,showCharCount:s=!1,required:m=!1,disabled:x=!1,className:z,ref:b,...y}){const r=S(),t=!!l,n=d.length,$=e&&n>e*.8,w=e&&n>e,{children:I,...C}=y;return i(u,{gap:"tight",children:[o(j,{ref:b,id:r,type:g,value:d,onChange:v,label:f,info:h,disabled:x||p,maxLength:e,required:m,"aria-describedby":c(t&&`${r}-error`,a&&!t&&`${r}-helper`,s&&`${r}-count`),"aria-invalid":t,className:c("dndev-w-full",z),"data-variant":t?"destructive":void 0,...C}),s&&e&&i("div",{id:`${r}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:w?"var(--destructive-foreground)":$?"var(--warning)":"var(--muted-foreground)"},children:[n,"/",e]}),t&&i(u,{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"}),l]}),a&&!t&&o("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})}var A=q;export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import f from"./DateFieldComponent";const g=({label:o,info:a,value:e,onChange:r,error:l,helperText:n,mode:i="datetime-local",required:m})=>{const s=e?new Date(e).toISOString():"";return d(f,{label:o,info:a,value:s,onChange:t=>{if(t){const u={target:{value:new Date(t).toISOString()}};r(u)}else r({target:{value:""}})},error:l,helperText:n,mode:i,required:m})};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 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
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
|
|
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},
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as re,jsxs as
|
|
1
|
+
"use client";import{jsx as e,Fragment as re,jsxs as a}from"react/jsx-runtime";import{ChevronLeft as le,ChevronRight as ne,RotateCcw as M,RotateCw as B,Trash2 as de,Check as ce,Undo2 as se,ZoomIn as ge,ZoomOut as me,Maximize2 as pe,Grid3X3 as he}from"lucide-react";import{useCallback as g,useEffect as H,useState as c,useRef as ue}from"react";import ve from"react-easy-crop";import{Button as o,BUTTON_VARIANT as r,Sheet as fe,Stack as n,Text as u,Slider as F,ToggleGroup as ye}from"@donotdev/components";import{useTranslation as we}from"@donotdev/core";import{processImage as Ce}from"../../../utils/imageProcessing";import{createPreviewURL as be,revokePreviewURL as ke}from"../../../utils/imageUtils";const xe={free:void 0,"1:1":1,"4:3":4/3,"16:9":16/9,"3:2":3/2};function Y({images:h,selectedIndex:l,open:R,onClose:T,onUpdate:D,onDelete:E,onNavigate:m,multiple:L=!1}){const{t}=we("crud"),[Z,C]=c({x:0,y:0}),[v,p]=c(1),[b,f]=c(0),[N,$]=c(null),[S,z]=c("free"),[k,q]=c(!0),[y,w]=c(!1),[A,G]=c(!1),[X,x]=c(!1),I=ue({crop:{x:0,y:0},zoom:1,rotation:0}),d=h[l],U=L&&l>0,O=L&&l<h.length-1;H(()=>{if(d){const i={x:0,y:0};C(i),p(1),f(d.rotation*90),z("free"),w(!1),x(!1),I.current={crop:i,zoom:1,rotation:d.rotation*90}}},[d]);const _=g((i,s)=>{$(s)},[]),J=g(()=>{C(I.current.crop),p(I.current.zoom),f(I.current.rotation)},[]),P=g(()=>{f(i=>(i-90+360)%360)},[]),V=g(()=>{f(i=>(i+90)%360)},[]),K=g(()=>{p(i=>Math.min(i+.25,3))},[]),Q=g(()=>{p(i=>Math.max(i-.25,1))},[]),ee=g(()=>{p(1),C({x:0,y:0})},[]),ie=async()=>{if(!(!d||!N)){G(!0);try{const i=await Ce(d.file,{crop:N,maxWidth:2048,maxHeight:2048,quality:.95}),s=new File([i.fullBlob],d.file.name,{type:"image/webp"}),oe=be(s);d.previewURL.startsWith("blob:")&&ke(d.previewURL),D(l,{file:s,previewURL:oe,uploaded:null,uploadProgress:null,error:null,rotation:0}),w(!1)}catch{}finally{G(!1)}}},te=g(()=>{E(l),x(!1),h.length===1?T():l>=h.length-1&&m(l-1)},[l,h.length,E,T,m]);if(H(()=>{if(!R)return;const i=s=>{s.key==="ArrowLeft"&&U?m(l-1):s.key==="ArrowRight"&&O?m(l+1):s.key==="Escape"&&y&&w(!1)};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[R,U,O,l,m,y]),!d)return null;const W=d.uploadProgress!==null&&d.uploadProgress<100,j=d.uploaded?.fullUrl||d.previewURL,ae=L?t("image.editor.titleWithIndex",{current:l+1,total:h.length}):t("image.editor.title");return e(fe,{open:R,onOpenChange:i=>!i&&T(),side:"right",title:ae,description:t("image.editor.description"),noSwipe:y,children:a(n,{gap:"large",style:{height:"100%"},children:[e("div",{style:{position:"relative",flex:1,minHeight:300,backgroundColor:"var(--surface-muted)",borderRadius:"var(--radius-lg)",overflow:"hidden"},children:y?e(ve,{image:j,crop:Z,zoom:v,rotation:b,aspect:xe[S],onCropChange:C,onCropComplete:_,onZoomChange:p,showGrid:k,style:{containerStyle:{position:"absolute",top:0,left:0,right:0,bottom:0},cropAreaStyle:{border:"2px solid var(--primary)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.5)"}}}):a(re,{children:[U&&e(o,{variant:r.GHOST,icon:le,onClick:()=>m(l-1),"aria-label":t("image.editor.previousImage"),style:{position:"absolute",left:"var(--gap-sm)",top:"50%",transform:"translateY(-50%)",zIndex:10,backgroundColor:"rgba(0,0,0,0.3)",color:"white"}}),e("img",{src:j,alt:`Image ${l+1}`,style:{width:"100%",height:"100%",objectFit:"contain",transform:`rotate(${b}deg)`,transition:"transform var(--dur-normal) var(--ease-out)"}}),O&&e(o,{variant:r.GHOST,icon:ne,onClick:()=>m(l+1),"aria-label":t("image.editor.nextImage"),style:{position:"absolute",right:"var(--gap-sm)",top:"50%",transform:"translateY(-50%)",zIndex:10,backgroundColor:"rgba(0,0,0,0.3)",color:"white"}})]})}),y?a(n,{children:[a(n,{gap:"tight",children:[e(u,{level:"small",variant:"muted",children:t("image.editor.aspectRatio")}),e(ye,{type:"single",value:S,onValueChange:i=>i&&z(i),items:[{value:"free",label:t("image.editor.aspectFree")},{value:"1:1",label:"1:1"},{value:"4:3",label:"4:3"},{value:"16:9",label:"16:9"}]})]}),a(n,{gap:"tight",children:[a(n,{direction:"row",justify:"between",align:"center",children:[e(u,{level:"small",variant:"muted",children:t("image.editor.zoom")}),a(u,{level:"small",variant:"muted",children:[Math.round(v*100),"%"]})]}),a(n,{direction:"row",gap:"tight",align:"center",children:[e(o,{variant:r.OUTLINE,icon:me,display:"compact",onClick:Q,disabled:v<=1}),e(F,{value:[v],min:1,max:3,step:.05,onValueChange:i=>p(i[0]??1),style:{flex:1}}),e(o,{variant:r.OUTLINE,icon:ge,display:"compact",onClick:K,disabled:v>=3})]})]}),a(n,{gap:"tight",children:[a(n,{direction:"row",justify:"between",align:"center",children:[e(u,{level:"small",variant:"muted",children:t("image.editor.rotation")}),a(u,{level:"small",variant:"muted",children:[b,"\xB0"]})]}),a(n,{direction:"row",gap:"tight",align:"center",children:[e(o,{variant:r.OUTLINE,icon:M,display:"compact",onClick:P,tooltip:t("image.editor.rotateLeft")}),e(F,{value:[b],min:0,max:360,step:1,onValueChange:i=>f(i[0]??0),style:{flex:1}}),e(o,{variant:r.OUTLINE,icon:B,display:"compact",onClick:V,tooltip:t("image.editor.rotateRight")})]})]}),a(n,{direction:"row",gap:"tight",children:[e(o,{variant:r.OUTLINE,icon:pe,display:"compact",onClick:ee,tooltip:t("image.editor.fitToView")}),e(o,{variant:r.OUTLINE,icon:he,display:"compact",onClick:()=>q(!k),tooltip:t(k?"image.editor.hideGrid":"image.editor.showGrid"),"data-active":k||void 0}),e(o,{variant:r.OUTLINE,icon:se,display:"compact",onClick:J,tooltip:t("image.editor.reset")})]}),a(n,{direction:"row",style:{marginTop:"var(--gap-md)"},children:[e(o,{variant:r.OUTLINE,onClick:()=>w(!1),fullWidth:!0,children:t("image.editor.cancel")}),e(o,{variant:r.PRIMARY,icon:ce,onClick:ie,disabled:A,fullWidth:!0,children:t(A?"image.editor.processing":"image.editor.apply")})]})]}):a(n,{children:[a(n,{direction:"row",gap:"tight",justify:"center",children:[e(o,{variant:r.OUTLINE,icon:M,display:"compact",onClick:P,tooltip:t("image.editor.rotateLeft")}),e(o,{variant:r.PRIMARY,onClick:()=>w(!0),disabled:W,children:t("image.editor.editButton")}),e(o,{variant:r.OUTLINE,icon:B,display:"compact",onClick:V,tooltip:t("image.editor.rotateRight")})]}),X?a(n,{style:{border:"1px solid var(--destructive)",padding:"var(--gap-md)",borderRadius:"var(--radius-md)"},children:[e(u,{variant:"destructive",level:"small",textAlign:"center",children:t("image.editor.deleteConfirm")}),a(n,{direction:"row",gap:"tight",children:[e(o,{variant:r.OUTLINE,onClick:()=>x(!1),fullWidth:!0,children:t("image.editor.cancel")}),e(o,{variant:r.DESTRUCTIVE,onClick:te,fullWidth:!0,children:t("actions.delete")})]})]}):e(o,{variant:r.GHOST,icon:de,onClick:()=>x(!0),disabled:W,style:{color:"var(--destructive)"},children:t("image.editor.deleteImage")})]})]})})}var Ie=Y;export{Y as ImageViewerDialog,Ie as default};
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as
|
|
1
|
+
import{default as r}from"./CrudButton";import{FormFieldRenderer as a}from"./FormFieldRenderer";import{DisplayFieldRenderer as t,formatValue as e}from"./DisplayFieldRenderer";import{default as o}from"./FormLayout";export*from"./controlled";export*from"./form";import{EntityFilters as m}from"./EntityFilters";import{matchesFilter as s}from"../utils/matchesFilter";import{YearFilter as i}from"./YearFilter";export*from"./fields/display";import{DisplayThumbnail as l}from"./DisplayThumbnail";import{CrudCard as p}from"./CrudCard";import{SortableCardList as d}from"./SortableCardList";export{r as CrudButton,p as CrudCard,t as DisplayFieldRenderer,l as DisplayThumbnail,m as EntityFilters,a as FormFieldRenderer,o as FormLayout,d as SortableCardList,i as YearFilter,e as formatValue,s as matchesFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{createContext as n,useContext as i}from"react";const e=n(void 0);function s({formId:o,children:r}){return t(e.Provider,{value:o,children:r})}function a(){return i(e)}export{s as UploadProvider,a as useUploadContext};
|
package/dist/contexts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UploadProvider as
|
|
1
|
+
import{UploadProvider as o,useUploadContext as a}from"./UploadContext";export{o as UploadProvider,a as useUploadContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{getFieldRegistry as
|
|
1
|
+
"use client";import{getFieldRegistry as a}from"./FieldRegistry";import{setRegistrationInit as s,getMetadataRegistry as r}from"./fieldTypeRegistry.store";import{registerAllBuiltinFieldTypes as l}from"./registerBuiltinFieldTypes";s(e=>{l(e,a())});import{getFieldTypeMetadata as o,getFilterType as p,getDisplayFormatter as g,isFilterable as n,clearFieldTypeRegistry as y}from"./fieldTypeRegistry.store";function F(e){const{type:i,components:t}=e;t&&a().registerComponent(i,t.controlled,t.uncontrolled),r().set(i,e)}export{y as clearFieldTypeRegistry,g as getDisplayFormatter,o as getFieldTypeMetadata,p as getFilterType,n as isFilterable,F as registerBuiltinFieldType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{getGlobalSingleton as
|
|
1
|
+
"use client";import{getGlobalSingleton as n}from"@donotdev/core";import{getFieldRegistry as i}from"./FieldRegistry";function r(){return n("field-type-metadata",()=>({registry:new Map,builtinsRegistered:!1,initFn:null}))}function a(e){r().initFn=e}function t(){const e=r();return e.builtinsRegistered||(e.builtinsRegistered=!0,e.initFn?.(e.registry)),e.registry}function s(e){return t().get(e)}function l(e){return i().getFilterType(e)||t().get(e)?.filterType}function g(e){return i().getDisplayFormatter(e)||t().get(e)?.displayFormatter}function o(e){return i().isFilterable(e)?!0:t().get(e)?.filterable??!1}function u(){t().clear()}export{u as clearFieldTypeRegistry,g as getDisplayFormatter,s as getFieldTypeMetadata,l as getFilterType,t as getMetadataRegistry,o as isFilterable,a as setRegistrationInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as r,useContext as t}from"react";const o=r(null),e=o.Provider;function n(){return t(o)}export{e as FormNavigationProvider,n as useFormNavigation};
|
package/dist/forms/childRows.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as p from"valibot";import{createSchemas as
|
|
1
|
+
import*as p from"valibot";import{createSchemas as q,describeEntity as z,generateUUID as H,getEntityByCollection as Y,hasRoleAccess as K,isFieldVisible as Z,prepareCreate as G,prepareUpdate as Q}from"@donotdev/core";import{extensionMintKey as X}from"../stores/FormStore";import{injectScope as J}from"../utils/scopeUtils";import{extensionFieldName as B,extensionWritable as $,splitExtensionField as A,splitPatch as x,withoutLinkField as P}from"./extend";import{buildSchemaDefaults as ee}from"./utils/buildInitialValues";import{writableFields as D}from"./utils/writableFields";const M={changes:{},added:[],removed:[]},I=/^[A-Za-z0-9_-]{1,128}$/,te=p.object({changes:p.record(p.pipe(p.string(),p.regex(I)),p.record(p.string(),p.unknown())),added:p.array(p.looseObject({id:p.pipe(p.string(),p.regex(I))})),removed:p.array(p.pipe(p.string(),p.regex(I)))}),U=new WeakMap;function C(e){let t=U.get(e);return t||(t=q(e),U.set(e,t)),t}function ne(e,t){const n=z(e).fields[t]?.value;if(n?.kind!=="ref"||n.ref===void 0)throw new Error(`useChildRows: parent field "${t}" is not a reference field of entity "${e.name}".`);return n.ref}function se(e){const t=Y(e);if(!t)throw new Error(`useEntityForm: no entity defines collection "${e}" (joined child rows). Define it with defineEntity().`);return t}function W(e,t){return{create:K(t,e.access.create),update:K(t,e.access.update),delete:K(t,e.access.delete)}}function N(e,t){const n=e??null,s=t??null;return n===s?!0:typeof n!="object"||typeof s!="object"?!1:JSON.stringify(n)===JSON.stringify(s)}function E(e){return Object.keys(e.changes).length>0||e.added.length>0||e.removed.length>0}function ie(e){return Object.values(e.changes).reduce((t,n)=>t+Object.keys(n).length,0)+e.added.length+e.removed.length}function oe(e,t){if(!E(t))return{base:[...e],items:[...e]};const n=new Set(t.removed),s=[...e.filter(r=>!n.has(r.id)),...t.added],o=s.map(r=>t.changes[r.id]?{...r,...t.changes[r.id]}:r);return{base:s,items:o}}function re(e,t,n){const s={...e.changes[t.id]};for(const[r,c]of Object.entries(n))N(c,t[r])?delete s[r]:s[r]=c;const o={...e.changes};return Object.keys(s).length===0?delete o[t.id]:o[t.id]=s,{...e,changes:o}}function ce(e,t){const n=new Set(t),s=new Set(e.added.map(o=>o.id));return{changes:Object.fromEntries(Object.entries(e.changes).filter(([o])=>!n.has(o))),added:e.added.filter(o=>!n.has(o.id)),removed:[...new Set([...e.removed,...t.filter(o=>!s.has(o))])]}}function de(e,t){if(!E(e))return e;const n=new Map(t.map(a=>[a.id,a])),s=e.added.filter(a=>!n.has(a.id)),o=new Set(s.map(a=>a.id)),r=e.removed.filter(a=>n.has(a)),c={};for(const[a,b]of Object.entries(e.changes)){const j=n.get(a);if(!j){o.has(a)&&(c[a]=b);continue}const d=Object.fromEntries(Object.entries(b).filter(([u,g])=>!N(g,j[u])));Object.keys(d).length>0&&(c[a]=d)}const w={changes:c,added:s,removed:r};return JSON.stringify(w)===JSON.stringify(e)?e:w}function ae(e,t){if(e===t)return M;const n=new Set(t.added.map(c=>c.id)),s=new Set(t.removed),o={};for(const[c,w]of Object.entries(e.changes)){const a=t.changes[c]??{},b=Object.fromEntries(Object.entries(w).filter(([j,d])=>!(j in a&&N(d,a[j]))));Object.keys(b).length>0&&(o[c]=b)}const r={changes:o,added:e.added.filter(c=>!n.has(c.id)),removed:e.removed.filter(c=>!s.has(c))};return E(r)?r:M}function _(e,t,n){const s=p.safeParse(C(e).update,{...n,id:t}),o=new Set(Object.keys(n));if(!s.success)for(const r of s.issues){const c=r.path?.[0]?.key;typeof c=="string"&&o.delete(c)}return o}function F(e,t){return Object.fromEntries(Object.entries(e).filter(([n])=>t.has(n)))}const le=e=>new Set([...e].map(t=>A(t)?.[1]??t));function L(e,t){return ee(e.entity,le($(e,t,"create")))}function fe(e,t,n){const{entity:s,parent:o,extensions:r=[]}=e,c=p.parse(te,t),w=W(s,n),a=r.flatMap(i=>[...$(i,n,"create")]),b=[...a,...r.flatMap(i=>[...$(i,n,"edit")])],j=new Set([...D(s,n,"edit"),...b]),d=new Set([...D(s,n,"create"),...a]);o&&d.delete(o.field);const u=(i,m)=>{const{own:h,byKey:l}=x(m,r),k=_(s,i,h);for(const S of r){const R=l[S.key];if(R)for(const V of _(S.entity,i,R))k.add(B(S.key,V))}return F(m,k)},g=(w.create?c.added:[]).map(i=>({...u(i.id,F(i,d)),id:i.id,...o&&{[o.field]:o.value}})),y=new Set(g.map(i=>i.id)),f={};for(const[i,m]of Object.entries(c.changes)){const h=y.has(i)?d:new Set([...j].filter(k=>A(k)!==null||w.update)),l=u(i,F(m,h));Object.keys(l).length>0&&(f[i]=l)}const O=w.delete?[...new Set(c.removed.filter(i=>!y.has(i)))]:[],v={changes:f,added:g,removed:O};return E(v)?v:M}const T=new WeakMap;function he(e,t){let n=T.get(e);n||(n=new Map,T.set(e,n));let s=n.get(t);return s||(s={...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([,o])=>Z(o.visibility??"guest",t)))},n.set(t,s)),s}function ue(e,t,n="guest"){const{entity:s,extensions:o=[],savedRows:r}=e;if(!E(t))return{};const c=new Set(t.added.map(d=>d.id)),w=new Set(t.removed),a={},b=(d,u,g,y,f,O)=>{const v=C(he(d,n)),i=f===void 0?G(v,g):Q(v,{id:String(f.id??u),patch:O??{},stored:f});if(!i.ok)for(const m of i.issues){const h=m.path?.[0]?.key;if(typeof h!="string")continue;const l=m.path?.[0]?.value,k=l==null||l===""?"required":"invalid",S=y?B(y,h):h;a[u]={...a[u],[S]:a[u]?.[S]??k}}},j=(d,u,g,y)=>{for(const f of o){const O=g[f.key],v=y?void 0:u?.[f.key];ge(v)?O&&b(P(f),d,{...v,...O},f.key,v,O):(y&&f.create||O)&&b(P(f),d,{...L(f,n),...O},f.key)}};for(const d of t.added){const{id:u,...g}={...d,...t.changes[d.id]},{own:y,byKey:f}=x(g,o);b(s,u,y,""),j(u,void 0,f,!0)}for(const[d,u]of Object.entries(t.changes)){if(c.has(d)||w.has(d))continue;const g=r?.get(d);if(!g)continue;const{own:y,byKey:f}=x(u,o);Object.keys(y).length>0&&b(s,d,pe(g,y),"",g,y),j(d,g,f,!1)}return a}function pe(e,t){const n={};for(const[s,o]of Object.entries(e))A(s)||(n[s]=o);return{...n,...t}}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ye(e,t,n="guest"){const{entity:s,parent:o,extensions:r=[],extensionIds:c={},mintId:w=()=>H()}=e,a=C(s),b=new Set(t.added.map(i=>i.id)),j=new Set(t.removed),d={},u={},g=new Set,y=(i,m,h)=>{for(const l of r){const k=m[l.key],S=h?void 0:c[i]?.[l.key];if(S){if(!k)continue;if(!l.update)throw new Error(`extend.${l.key}: the viewer may not edit it.`);(u[l.key]??=[]).push({id:S,patch:k})}else if(h&&l.create||k){if(!l.create)throw new Error(`extend.${l.key}: the viewer may not create it.`);(d[l.key]??=[]).push(J({...L(l,n),...k,id:w(X(l.entity.collection,i)),[l.field]:i},l.entity.scope)),h&&g.add(l.key)}}},f=t.added.map(i=>{const{own:m,byKey:h}=x({...i,...t.changes[i.id]},r);return y(i.id,h,!0),J({...m,id:i.id,...o&&{[o.field]:o.value}},s.scope)}),O=Object.entries(t.changes).filter(([i])=>!b.has(i)&&!j.has(i)).flatMap(([i,m])=>{const{own:h,byKey:l}=x(m,r);return y(i,l,!1),Object.keys(h).length>0?[{id:i,patch:h}]:[]}),v=[];(f.length>0||O.length>0||t.removed.length>0)&&v.push({collection:s.collection,...f.length>0&&{inserts:f},...O.length>0&&{updates:O},...t.removed.length>0&&{deletes:[...t.removed]},schemas:a});for(const i of r){const m=d[i.key]??[],h=u[i.key]??[];if(m.length===0&&h.length===0)continue;const l=C(i.entity);v.push({collection:i.entity.collection,...m.length>0&&{inserts:m},...h.length>0&&{updates:h},schemas:l,...g.has(i.key)&&{dependsOn:[s.collection]}})}return v}function me(e){const t=new Map;for(const n of e){const s=t.get(n.collection);if(!s){t.set(n.collection,n);continue}const o=[...s.inserts??[],...n.inserts??[]],r=[...s.updates??[],...n.updates??[]],c=[...s.deletes??[],...n.deletes??[]],w=[...new Set([...s.dependsOn??[],...n.dependsOn??[]])];t.set(n.collection,{...s,...o.length>0&&{inserts:o},...r.length>0&&{updates:r},...c.length>0&&{deletes:c},...w.length>0&&{dependsOn:w}})}return[...t.values()]}export{M as EMPTY_CHILD_EDITS,oe as applyChildEdits,ye as childEditsBatches,ue as childEditsErrors,se as childEntityOf,W as childRowsAccess,ie as countChildEdits,E as hasChildEdits,me as mergeBatches,ne as parentCollectionOf,fe as parseChildEdits,F as pickFields,ae as rebaseChildEdits,de as reconcileChildEdits,ce as removeChildRows,C as schemasOf,re as setChildValues,D as writableFields};
|
package/dist/forms/extend.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BACKEND_GENERATED_FIELD_NAMES as
|
|
1
|
+
import{BACKEND_GENERATED_FIELD_NAMES as b,describeEntity as w,hasRoleAccess as f}from"@donotdev/core";import{getFieldsForOperation as $}from"./utils/getFieldsForOperation";const E=30;function x(e,n){return n===e.field||n==="status"||b.includes(n)}function g(e,n,i){return n?Object.entries(n).map(([o,t])=>{if(o.includes(".")||o in e.fields)throw new Error(`extend: key "${o}" must not contain "." nor be a field of entity "${e.name}".`);const s=t.entity.fields[t.field];if(s?.type!=="reference"||s.validation?.reference!==e.collection)throw new Error(`extend.${o}: "${t.field}" is not a reference of entity "${t.entity.name}" to "${e.collection}".`);const r=f(i,t.entity.access.read);return{key:o,entity:t.entity,field:t.field,readable:r,create:r&&f(i,t.entity.access.create),update:r&&f(i,t.entity.access.update)}}):[]}function k(e){return e?Object.entries(e).map(([n,i])=>`${n}:${i.entity.collection}:${i.field}`).join("|"):""}const c=(e,n)=>`${e}.${n}`;function l(e){const n=e.indexOf(".");return n===-1?null:[e.slice(0,n),e.slice(n+1)]}function N(e){let n=d.get(e.entity);n||(n=new Map,d.set(e.entity,n));let i=n.get(e.field);if(!i){const{[e.field]:o,...t}=e.entity.fields;i={...e.entity,fields:t},n.set(e.field,i)}return i}const d=new WeakMap;function u(e,n,i){if(!e.readable)return[];const o=i==="create"?e.create:e.update;return $(e.entity,{operation:i,viewerRole:n}).filter(t=>!x(e,t.name)).map(t=>({name:c(e.key,t.name),config:{...t.config,name:c(e.key,t.name),label:(t.config.label||t.name).includes(":")?t.config.label||t.name:`${e.entity.namespace}:${t.config.label||t.name}`},editable:t.editable&&o,written:t.written&&o,scope:e.key}))}function h(e,n,i){const{fields:o}=w(e.entity);return new Set(u(e,n,i).filter(t=>t.written).flatMap(t=>{const s=o[l(t.name)?.[1]??t.name]?.companion;return s?[t.name,c(e.key,s)]:[t.name]}))}function A(e,n){const i={},o={};for(const[t,s]of Object.entries(e)){const r=l(t);if(!r){i[t]=s;continue}const[a,m]=r;if(!n.some(p=>p.key===a))throw new Error(`extend: no extension "${a}" for field "${t}".`);o[a]={...o[a],[m]:s}}return{own:i,byKey:o}}function y(e,n,i){const o=l(n);if(!o)return{...e,[n]:i};const[t,s]=o,r=e[t],a=typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{};return{...e,[t]:y(a,s,i)}}export{E as EXTENSION_IN_CHUNK,c as extensionFieldName,u as extensionFields,h as extensionWritable,k as extensionsSignature,g as resolveExtensions,y as setAtPath,l as splitExtensionField,A as splitPatch,N as withoutLinkField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEntityForm as
|
|
1
|
+
import{useEntityForm as t}from"./useEntityForm";import{useEntityField as o}from"./useEntityField";import{useController as r}from"./useController";export{r as useController,o as useEntityField,t as useEntityForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useController as
|
|
1
|
+
"use client";import{useController as o}from"react-hook-form";function r(e){return o(e)}export{r as useController};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useMemo as
|
|
1
|
+
"use client";import{useMemo as l,useCallback as h}from"react";import{useController as p}from"./useController";import{formatValue as E}from"../../components/DisplayFieldRenderer";function D(r,e){const{entity:n,fields:d}=r,t=n.fields[e],o=l(()=>{if(!t)throw new Error(`useEntityField: entity "${n.name}" has no field "${e}".`);return{...t,name:t.name||e,label:t.label||e}},[e,t]),s=l(()=>d.find(a=>a.name===e),[d,e]),u=s!==void 0,c=s?.editable??!1,{field:m,fieldState:i}=p({name:e,control:r.control}),y=l(()=>({error:i.error?.message,touched:i.isTouched,isDirty:i.isDirty}),[i.error?.message,i.isTouched,i.isDirty]),f=s?.written?m.value:r.record?.[e],b=h(a=>E(f,o,r.t,a),[f,o,r.t]);return{field:m,meta:y,config:o,isEditable:c,isVisible:u,display:b}}export{D as useEntityField};
|