@donotdev/crud 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.subscriptions.js +1 -1
- package/dist/CrudService.writeRules.js +1 -1
- package/dist/CrudStore.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/YearFilter.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/ControlledRichTextField.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/ControlledMultiImageField.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/ControlledPhoneField.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/select/ControlledRadioField.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/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/DateFieldDisplay.js +1 -1
- package/dist/components/fields/display/FileFieldDisplay.js +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.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/ReferenceFieldDisplay.js +1 -1
- package/dist/components/fields/display/TextAreaDisplay.js +1 -1
- package/dist/components/fields/display/TextFieldDisplay.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/DateFieldComponent.d.ts.map +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/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/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/RatingFieldComponent.js +1 -1
- package/dist/components/form/fields/RichTextComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.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/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/emptyValue.js +1 -1
- package/dist/forms/utils/validateEntity.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/useFileUpload.js +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/stores/UploadStore.d.ts.map +1 -1
- package/dist/stores/UploadStore.js +1 -1
- package/dist/stores/uploadStoreRef.d.ts +35 -0
- package/dist/stores/uploadStoreRef.d.ts.map +1 -0
- package/dist/stores/uploadStoreRef.js +1 -0
- 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/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/filterUrl.js +1 -1
- package/dist/utils/imageProcessing.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/uploadValidation.js +1 -1
- package/dist/utils/useRowTranslator.js +1 -1
- package/dist/workflows/defineWorkflow.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
- package/dist/CrudService.writeSchema.d.ts +0 -64
- package/dist/CrudService.writeSchema.d.ts.map +0 -1
- package/dist/CrudService.writeSchema.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as r}from"react/jsx-runtime";import{useFieldArray as F,Controller as R}from"react-hook-form";import{Button as h}from"@donotdev/components";import{getFieldRegistry as q}from"../../../FieldRegistry";import{convertValidationRules as B}from"../types";function D(s){switch(s){case"number":return 0;case"boolean":return!1;default:return""}}function I(s){const{control:c,fieldConfig:f,required:x,t:l}=s,{name:v,label:a,validation:j}=f,m=f.options?.fieldSpecific??{},o=m.fields??[],
|
|
1
|
+
"use client";import{jsx as i,jsxs as r}from"react/jsx-runtime";import{useFieldArray as F,Controller as R}from"react-hook-form";import{Button as h}from"@donotdev/components";import{getFieldRegistry as q}from"../../../FieldRegistry";import{convertValidationRules as B}from"../types";function D(s){switch(s){case"number":return 0;case"boolean":return!1;default:return""}}function I(s){const{control:c,fieldConfig:f,required:x,t:l}=s,{name:v,label:a,validation:j}=f,m=f.options?.fieldSpecific??{},o=m.fields??[],t=m.direction??"row",u=m.fixedRows===!0,{fields:b,append:w,remove:C}=F({control:c,name:v}),S=q(),z=()=>{if(o.length===0)return;const d={};for(const n of o)d[n.name]=D(n.type);w(d)};return o.length===0?i("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l("crud:fieldArray.noSubFields",{field:l(a)})}):r("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[r("span",{style:{fontSize:"var(--font-size-sm)",fontWeight:"var(--font-weight-medium)"},children:[l(a),x&&i("span",{style:{color:"var(--destructive)",marginInlineStart:"var(--gap-sm)"},children:"*"})]}),!u&&i(h,{type:"button",variant:"ghost",display:"compact",intent:"add",onClick:z,"aria-label":l("crud:fieldArray.addRow",{field:l(a)})})]}),b.map((d,n)=>r("div",{style:{display:"flex",flexDirection:t,gap:"var(--gap-sm)",alignItems:t==="row"?"flex-start":void 0},children:[o.map(e=>{const y=`${v}.${n}.${e.name}`,A={name:y,type:e.type,label:e.label,visibility:f.visibility,validation:{...e.validation??{},...e.required?{required:!0}:{}},options:e.options??{}},g=S.getControlledComponent(e.type);return g?i("div",{style:{flex:t==="row"?1:void 0},children:i(g,{control:c,fieldConfig:A,t:l})},e.name):i("div",{style:{flex:t==="row"?1:void 0},children:i(R,{name:y,control:c,rules:e.validation?B(e.validation):void 0,render:({field:p})=>r("label",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[i("span",{style:{fontSize:"var(--font-size-xs)"},children:l(e.label)}),i("input",{className:"dndev-input",value:String(p.value??""),onChange:p.onChange,onBlur:p.onBlur})]})})},e.name)}),!u&&i(h,{type:"button",variant:"ghost",display:"compact",intent:"delete",onClick:()=>C(n),"aria-label":l("crud:fieldArray.removeRow",{field:l(a),index:n+1}),style:{alignSelf:t==="row"?"center":"flex-end"}})]},d.id))]})}export{I as ControlledFieldArrayField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{GeoPointFieldComponent as p}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(l){const{control:a,fieldConfig:i,required:s,t:d}=l,{name:m,label:g,validation:r}=i;return t(f,{name:m,control:a,rules:r?C(r):void 0,render:({field:e,fieldState:n})=>{const u=o=>{if("target"in o)try{const c=JSON.parse(o.target.value);e.onChange(c)}catch{e.onChange({lat:0,lng:0})}else e.onChange(o||{lat:0,lng:0})};return t(p,{label:d(g),value:e.value||{lat:0,lng:0},onChange:u,error:!!n.error,helperText:n.error?.message,required:s})}})}export{h as ControlledGeoPointField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MapFieldComponent as g}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(a){const{control:l,fieldConfig:i,required:s,t:d}=a,{name:m,label:u,validation:o}=i;return t(p,{name:m,control:l,rules:o?C(o):void 0,render:({field:e,fieldState:n})=>{const c=r=>{if("target"in r)try{const f=JSON.parse(r.target.value);e.onChange(f)}catch{e.onChange({})}else e.onChange(r||{})};return t(g,{label:d(u),value:e.value||{},onChange:c,error:!!n.error,helperText:n.error?.message,required:s})}})}export{h as ControlledMapField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a}from"react/jsx-runtime";import{Controller as
|
|
1
|
+
"use client";import{jsx as a}from"react/jsx-runtime";import{Controller as h}from"react-hook-form";import{RichTextComponent as u}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(t){const{control:n,fieldConfig:i,placeholder:s,required:m,t:d}=t,{name:c,label:p,validation:e,options:r={}}=i;return a(h,{name:c,control:n,rules:e?C(e):void 0,render:({field:o,fieldState:l})=>a(u,{label:d(p),value:o.value??"",onChange:f=>o.onChange(f),error:l.error?.message,helperText:l.error?.message,required:m,placeholder:s||r.placeholder,className:r.className})})}export{x as ControlledRichTextField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as c}from"react-hook-form";import{DocumentFieldComponent as p}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:o,label:u,validation:r}=e,a=g(e);return t(c,{name:o,control:m,rules:r?x(r):void 0,render:({field:l,fieldState:i})=>t(p,{name:o,label:d(u),value:l.value??null,onChange:f=>l.onChange(f),error:!!i.error,helperText:i.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:a?.maxSize,storagePath:a?.storagePath})})}export{C as ControlledDocumentField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{FileFieldComponent as c}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:r,label:u,validation:o}=e,l=g(e);return t(p,{name:r,control:m,rules:o?x(o):void 0,render:({field:a,fieldState:i})=>t(c,{name:r,label:d(u),value:a.value??null,onChange:f=>a.onChange(f),error:!!i.error,helperText:i.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:l?.maxSize,storagePath:l?.storagePath})})}export{C as ControlledFileField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{useMemo as c}from"react";import{Controller as x}from"react-hook-form";import{readImageProcessingOptions as C}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{uploadFieldSpecific as v}from"../fieldOptions";import{convertValidationRules as S}from"../types";function F(n){const{control:s,fieldConfig:r,required:d,t:p}=n,{name:o,label:f,validation:a}=r,e=v(r),i=e?.image,g=c(()=>C({image:i}),[JSON.stringify(i)]);return l(x,{name:o,control:s,rules:a?S(a):void 0,render:({field:m,fieldState:t})=>l(h,{name:o,label:p(f),value:m.value??null,onChange:u=>m.onChange(u),error:!!t.error,helperText:t.error?.message,required:d,multiple:!1,maxFiles:1,maxSize:e?.maxSize,storagePath:e?.storagePath,processing:g})})}export{F as ControlledImageField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as v}from"react-hook-form";import{DocumentFieldComponent as x}from"../../form/fields";import{controlledFieldOptions as g,uploadFieldSpecific as C}from"../fieldOptions";import{convertValidationRules as F}from"../types";function h(n){const{control:m,fieldConfig:r,required:s,t:u}=n,{name:o,label:d,validation:l}=r,c=g(r),a=C(r);return i(v,{name:o,control:m,rules:l?F(l):void 0,render:({field:e,fieldState:t})=>{const p=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return i(x,{name:o,label:u(d),value:p,onChange:f=>e.onChange(f),error:!!t.error,helperText:t.error?.message,required:s,multiple:!0,maxFiles:c.maxFiles??10,maxSize:a?.maxSize,storagePath:a?.storagePath})}})}export{h as ControlledMultiDocumentField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n}from"react/jsx-runtime";import{useMemo as x}from"react";import{Controller as C}from"react-hook-form";import{readImageProcessingOptions as F}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{controlledFieldOptions as S,uploadFieldSpecific as y}from"../fieldOptions";import{convertValidationRules as I}from"../types";function O(
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import{useMemo as x}from"react";import{Controller as C}from"react-hook-form";import{readImageProcessingOptions as F}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{controlledFieldOptions as S,uploadFieldSpecific as y}from"../fieldOptions";import{convertValidationRules as I}from"../types";function O(m){const{control:s,fieldConfig:r,required:u,t:d}=m,{name:a,label:p,validation:i}=r,f=S(r),o=y(r),l=o?.image,g=x(()=>F({image:l}),[JSON.stringify(l)]);return n(C,{name:a,control:s,rules:i?I(i):void 0,render:({field:e,fieldState:t})=>{const c=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return n(h,{name:a,label:d(p),value:c,onChange:v=>e.onChange(v),error:!!t.error,helperText:t.error?.message,required:u,multiple:!0,maxFiles:f.maxFiles??10,maxSize:o?.maxSize,storagePath:o?.storagePath,processing:g})}})}export{O as ControlledMultiImageField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as l}from"react/jsx-runtime";import{Controller as
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{DurationFieldComponent as c}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(t){const{control:d,fieldConfig:o,t:i,required:s}=t,{name:m,label:f,validation:n}=o,e=(o.options||{}).fieldSpecific;return l(u,{name:m,control:d,rules:n?C(n):void 0,render:({field:r,fieldState:a})=>l(c,{label:i(f),value:r.value??0,onChange:p=>r.onChange(p),error:!!a.error,helperText:a.error?.message,required:s,disabled:r.disabled,min:e?.min??0,max:e?.max??480,step:e?.step??5,t:i})})}export{x as ControlledDurationField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{GdprConsentFieldComponent as u}from"../../form/fields";import{fieldSpecificOf as h}from"../fieldOptions";import{convertValidationRules as v}from"../types";function y(a){const{control:l,fieldConfig:n,required:s}=a,{name:c,validation:r}=n,
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{GdprConsentFieldComponent as u}from"../../form/fields";import{fieldSpecificOf as h}from"../fieldOptions";import{convertValidationRules as v}from"../types";function y(a){const{control:l,fieldConfig:n,required:s}=a,{name:c,validation:r}=n,t=h(n),d=t?.privacyPolicyPath||"/legal/privacy",p=t?.termsPath||"/legal/terms";return i(C,{name:c,control:l,rules:r?v(r):void 0,render:({field:o})=>{const e=o.value,m=typeof e=="object"&&e!==null?!!e.gdprConsent:!!e;return i(u,{checked:m,onChange:f=>{if(f.target.checked){const g=new Date().toISOString().split("T")[0];o.onChange({gdprConsent:!0,gdprConsentDate:new Date().toISOString(),gdprConsentVersion:g})}else o.onChange(!1)},required:s,privacyPolicyPath:d,termsPath:p})}})}export{y as ControlledGdprConsentField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{fromInputValue as p}from"../../../forms/utils";import{PhoneNumberComponent as g}from"../../form/fields";import{fieldInfo as v}from"../fieldOptions";import{convertValidationRules as c}from"../types";function C(a){const{control:i,fieldConfig:r,t:o,required:m}=a,{name:f,label:s,validation:n}=r;return l(d,{name:f,control:i,rules:n?c(n):void 0,render:({field:e,fieldState:t})=>l(g,{ref:e.ref,name:e.name,onBlur:e.onBlur,label:o(s),info:v(r,o),value:typeof e.value=="string"?e.value:"",onChange:u=>e.onChange(p(u.target.value)),error:t.error?.message,helperText:t.error?.message,required:m})})}export{C as ControlledPhoneField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{RatingFieldComponent as c}from"../../form/fields";import{convertValidationRules as g}from"../types";function x(
|
|
1
|
+
"use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{RatingFieldComponent as c}from"../../form/fields";import{convertValidationRules as g}from"../types";function x(t){const{control:n,fieldConfig:o,t:m,required:s}=t,{name:d,label:f,validation:e}=o,r=(o.options||{}).fieldSpecific;return a(p,{name:d,control:n,rules:e?g(e):void 0,render:({field:i,fieldState:l})=>a(c,{label:m(f),value:i.value??0,onChange:u=>{i.onChange(u)},error:!!l.error,helperText:l.error?.message,required:s,max:r?.max??e?.max??5,showValue:r?.showValue})})}export{x as ControlledRatingField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as d}from"react/jsx-runtime";import{Controller as L}from"react-hook-form";import{SwitchFieldComponent as S}from"../../form/fields";import{fieldSpecificOf as v}from"../fieldOptions";function x(h){const{control:f,fieldConfig:
|
|
1
|
+
"use client";import{jsx as d}from"react/jsx-runtime";import{Controller as L}from"react-hook-form";import{SwitchFieldComponent as S}from"../../form/fields";import{fieldSpecificOf as v}from"../fieldOptions";function x(h){const{control:f,fieldConfig:n,t:o,onChange:l}=h,{name:m,label:s}=n,e=v(n),u=e?.uncheckedValue??!1,r=e?.checkedValue??!0,t=e?.uncheckedLabel,a=e?.checkedLabel;return d(L,{name:m,control:f,render:({field:{value:k,onChange:p},fieldState:b})=>{const g=k===r,C=c=>{const i=c?r:u;p(i),l&&l(i)};return d(S,{label:o(s),checked:g,onChange:c=>C(c.target.checked),uncheckedLabel:t?o(t):void 0,checkedLabel:a?o(a):void 0,helperText:b.error?.message})}})}export{x as ControlledSwitchField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as p}from"react/jsx-runtime";import{useMemo as u}from"react";import{Controller as x,useWatch as y}from"react-hook-form";import{translateLabel as R}from"../../../forms/utils";import{RadioFieldComponent as q}from"../../form/fields";import{convertValidationRules as F}from"../types";function O(m){const{control:
|
|
1
|
+
"use client";import{jsx as p}from"react/jsx-runtime";import{useMemo as u}from"react";import{Controller as x,useWatch as y}from"react-hook-form";import{translateLabel as R}from"../../../forms/utils";import{RadioFieldComponent as q}from"../../form/fields";import{convertValidationRules as F}from"../types";function O(m){const{control:l,fieldConfig:n,t:i,required:c}=m,{name:v,label:g,validation:o}=n,s="dependsOn"in n?n.dependsOn:void 0,r=s?s.field:void 0,b=typeof o?.options=="function",d=y({control:l,name:r,disabled:!r}),f=u(()=>{const e=o?.options;if(!e)return[];if(typeof e=="function"){const t=r?{[r]:d}:{};return e(t)}return e},[o?.options,b,r,d]),C=u(()=>f.map(e=>({value:String(e.value),label:R(e.label,i)})),[f,i]);return p(x,{name:v,control:l,rules:o?F(o):void 0,render:({field:e,fieldState:t})=>p(q,{...e,label:i(g),value:e.value??void 0,onChange:a=>{const h=typeof a=="string"?a:a.target.value;e.onChange(h)},options:C,error:!!t.error,helperText:t.error?.message,required:c})})}export{O as ControlledRadioField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function i(
|
|
1
|
+
"use client";function i(n){if(n){if(n instanceof RegExp)return n;try{const t=/^\/(.*)\/([gimyus]*)$/.exec(n);if(t){const[,r,e]=t;if(r)return new RegExp(r,e)}return new RegExp(n)}catch{return}}}function a(n){if(!n)return{};const t={};return n.required!==void 0&&(t.required=n.required),n.min!==void 0&&(t.min=n.min),n.max!==void 0&&(t.max=n.max),n.minLength!==void 0&&(t.minLength=n.minLength),n.maxLength!==void 0&&(t.maxLength=n.maxLength),n.pattern&&typeof n.pattern=="string"&&(t.pattern={value:i(n.pattern)||/.*/,message:"Invalid format"}),t}export{i as convertPatternToRegex,a as convertValidationRules};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{Avatar as n,Text as p}from"@donotdev/components";const l=({config:a,value:s,t:d,className:e,size:r="md"})=>{if(!s)return t(p,{as:"span",variant:"muted",className:e,children:"-"});const i={sm:"size-touch",md:"size-touch",lg:"h-16 w-16"},c=m=>m.split(" ").map(o=>o.charAt(0)).slice(0,2).join("").toUpperCase();return t(n,{src:s,alt:a.label||"Avatar",fallback:c(a.label||"AV"),className:`${i[r]} ${e||""}`})};var u=l;export{l as AvatarFieldDisplay,u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Badge as t,Text as c}from"@donotdev/components";const n=({config:m,value:a,t:r,className:s})=>{if(a==null)return e(c,{as:"span",variant:"muted",className:s,children:"-"});const o=r(a?"common.yes":"common.no");return e(t,{variant:a?"default":"secondary",className:s,children:o})};var l=n;export{n as CheckboxFieldDisplay,l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as a,jsxs as d}from"react/jsx-runtime";import{Text as
|
|
1
|
+
import{jsx as a,jsxs as d}from"react/jsx-runtime";import{Text as s,Spinner as p}from"@donotdev/components";import{getI18nInstance as u}from"@donotdev/core";const i=({config:c,value:n,t:g,className:e,loading:m=!1})=>{if(m)return a(p,{className:e});if(!n)return a(s,{as:"span",variant:"muted",className:e,children:"-"});try{const t=new Date(n),r=u()?.language,l=t.toLocaleDateString(r),o=t.toLocaleTimeString(r);return c.type==="date"?a(s,{as:"span",className:e,children:l}):d("div",{className:e,children:[a(s,{as:"span",children:l}),a(s,{as:"span",variant:"muted",level:"small",children:o})]})}catch{return a(s,{as:"span",variant:"muted",className:e,children:"-"})}};var f=i;export{i as DateFieldDisplay,f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as t,Text as l,Stack as c}from"@donotdev/components";const r=({config:m,value:a,t:o,className:s})=>a?i(c,{direction:"row",align:"center",className:s,children:[e(l,{as:"span",level:"small",children:a.name}),a.size&&i(n,{variant:t.SECONDARY,children:[(a.size/1024).toFixed(1)," KB"]})]}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var d=r;export{r as FileFieldDisplay,d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import{Text as i}from"@donotdev/components";const o=({config:l,value:e,t:r,className:t})=>{if(!e)return n(i,{as:"span",variant:"muted",className:t,children:"-"});const s=(()=>{switch(l.type){case"email":return{href:`mailto:${e}`,"aria-label":r("common.sendEmailTo",{email:e})};case"tel":return{href:`tel:${e}`,"aria-label":r("common.callNumber",{number:e})};default:return{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":r("common.openLink")}}})();return n("a",{...s,className:t||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none",children:e})};var c=o;export{o as LinkFieldDisplay,c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as s}from"react/jsx-runtime";import{Text as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{Text as n,Spinner as r}from"@donotdev/components";import{getI18nInstance as t}from"@donotdev/core";const l=({config:i,value:e,t:c,className:a,loading:o=!1})=>o?s(r,{className:a}):e==null?s(n,{as:"span",variant:"muted",className:a,children:"-"}):s(n,{as:"span",className:`font-mono ${a||""}`,children:e.toLocaleString(t()?.language)});var m=l;export{l as NumberFieldDisplay,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as i}from"react/jsx-runtime";import{Eye as
|
|
1
|
+
import{jsx as o,jsxs as i}from"react/jsx-runtime";import{Eye as d,EyeOff as n}from"lucide-react";import{useState as u}from"react";import{Skeleton as m,Button as y,CopyToClipboard as f,Stack as r}from"@donotdev/components";const l=({config:g,value:e,t,className:s,loading:p=!1})=>{const[a,c]=u(!1);return p?o(m,{className:s}):e?i(r,{direction:"row",align:"center",className:s,children:[o("span",{style:{fontFamily:"monospace"},children:a?e:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),i(r,{direction:"row",align:"center",gap:"tight",children:[o(y,{type:"button",onClick:()=>c(!a),"aria-label":a?"Hide password":"Show password",children:a?o(n,{}):o(d,{})}),o(f,{text:e,tooltipText:t("copyToClipboard")||"Copy to clipboard",copiedTooltipText:t("copied")||"Copied!",ariaLabel:t("copyPassword")||"Copy password"})]})]}):o("div",{style:{color:"var(--muted-foreground)"},children:"-"})};var w=l;export{l as PasswordFieldDisplay,w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Badge as i,BADGE_VARIANT as n,Text as l}from"@donotdev/components";const r=({config:c,value:a,t:d,className:s})=>{if(!a)return e(l,{as:"span",variant:"muted",className:s,children:"-"});const t=a.displayName||a.name||a.id||a;return e(i,{variant:n.OUTLINE,className:s,children:String(t)})};var m=r;export{r as ReferenceFieldDisplay,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const r=({config:i,value:a,t:m,className:s})=>a?e(l,{as:"div",level:"small",className:`whitespace-pre-wrap ${s||""}`,children:a}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var t=r;export{r as TextAreaDisplay,t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as L,Calendar as k,Clock as I}from"lucide-react";import{useState as A}from"react";import{Skeleton as T,Badge as B,BADGE_VARIANT as E,Text as l,cn as f,CopyToClipboard as x,Stack as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as L,Calendar as k,Clock as I}from"lucide-react";import{useState as A}from"react";import{Skeleton as T,Badge as B,BADGE_VARIANT as E,Text as l,cn as f,CopyToClipboard as x,Stack as o}from"@donotdev/components";import{getWeekFromISOString as M,getI18nInstance as b}from"@donotdev/core";const C=({config:i,value:a,t:r,className:s,loading:v=!1,showCopy:m=!1,asBadge:w=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[j,g]=A(!1),F=async()=>{try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),2e3)}catch{}},h=()=>{switch(i.type){case"email":return e(L,{});case"month":case"week":return e(k,{});case"time":return e(I,{});default:return null}},S=t=>{if(!t)return null;switch(i.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:u=>u.currentTarget.style.textDecoration="underline",onMouseLeave:u=>u.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(b()?.language,{year:"numeric",month:"long"});case"week":return M(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(b()?.language);default:return t}},D=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(v)return n(o,{gap:"tight",children:[p&&e(T,{style:{height:"1rem",width:"6rem"}}),e(T,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!a)return n(o,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:i.label||i.name}),e(l,{as:"span",variant:"muted",className:f(s),style:{fontStyle:"italic"},children:r("common.noValue",{defaultValue:"No value"})})]});const N=S(a),y=D(String(N));return w?n(o,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]}):n(o,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:i.label||i.name}),n(o,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:f("dndev-flex-1",c&&"truncate",s),title:c&&a.length>d?a:void 0,children:e(l,{as:"span",children:y})}),m&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]})]})};var V=C;export{C as TextFieldDisplay,V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as p,Input as u,cn as f,Stack as n}from"@donotdev/components";const s=({config:r,value:t,onChange:c,error:A,helperText:l,t:i,className:d,...v})=>{const h=a=>a.split(" ").map(m=>m.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(p,{src:t,alt:r.label||"Avatar",fallback:h(r.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(u,{type:"url",className:f("dndev-w-full",d),placeholder:i("common.enterAvatarUrl"),value:t,onChange:a=>c(a.target.value),...v})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var g=s;export{s as AvatarFieldComponent,g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Badge as v,Input as f,cn as g,Stack as o}from"@donotdev/components";const l=({config:p,value:a,onChange:d,error:u,helperText:t,t:n,variant:s="default",className:i,...c})=>r(o,{children:[r(o,{direction:"row",align:"center",children:[e(v,{variant:s,style:{minWidth:0},children:a||n("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",i),placeholder:n("common.enterBadgeText"),value:a,onChange:m=>d(m.target.value),...c})})]}),t&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:t})]});var h=l;export{l as BadgeFieldComponent,h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{Button as e}from"@donotdev/components";const n=({label:a,type:t,onClick:o,variant:i,disabled:l=!1})=>r(e,{type:t,onClick:o,variant:i,disabled:l,children:a});var s=n;export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DateFieldComponent.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DateFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/DateFieldComponent.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAWxD,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAQD;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,EAAE,aAAa,CAAC,uBAAuB,CAiN9D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as s}from"react/jsx-runtime";import{useId as z}from"react";import{DatePicker as x,DateTimePicker as y,Input as w,cn as p,Stack as c}from"@donotdev/components";import{useTranslation as I}from"@donotdev/core";function D(a){const o=u=>String(u).padStart(2,"0");return`${a.getFullYear()}-${o(a.getMonth()+1)}-${o(a.getDate())}T${o(a.getHours())}:${o(a.getMinutes())}`}const O=({label:a,info:o,value:u,onChange:v,error:g,helperText:i,mode:l="date",required:h,...S})=>{const r=z(),e=!!g,{t:f}=I("crud"),m=t=>{const b=t.target.value?new Date(t.target.value).toISOString():null;v(b)},$=t=>{v(t?new Date(t).toISOString():null)};let d="";if(u){const t=new Date(u);l==="date"?d=t.toISOString().split("T")[0]||"":l==="datetime-local"?d=D(t):l==="month"?d=t.toISOString().slice(0,7):l==="time"?d=t.toISOString().slice(11,16):l==="week"&&(d=t.toISOString().split("T")[0]||"")}return l==="date"?s(c,{gap:"tight",children:[n(x,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:o,value:u??null,onChange:v,required:h,"aria-describedby":p(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):l==="datetime-local"?s(c,{gap:"tight",children:[n(y,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:o,value:d||null,onChange:$,required:h,"aria-describedby":p(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]}):s(c,{gap:"tight",children:[n(w,{id:r,label:a,info:o,type:l,value:d,onChange:m,required:h,"aria-describedby":p(e&&`${r}-error`,i&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...S}),e&&s(c,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),g]}),i&&!e&&n("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:i})]})};var T=O;export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as n,Fragment as K}from"react/jsx-runtime";import{Upload as V,X as _,FileText as u,FileSpreadsheet as J,File as Q,Loader2 as Y,Eye as Z}from"lucide-react";import{useState as D,useRef as $,useImperativeHandle as ee,forwardRef as ae}from"react";import{Button as k,BUTTON_VARIANT as C,Text as s,Stack as m,Progress as re,Dialog as te,DialogContent as ne,DialogHeader as ie,DialogTitle as le}from"@donotdev/components";import{handleError as y,useTranslation as oe}from"@donotdev/core";import{useFileUpload as se}from"../../../hooks/useFileUpload";import{uploadFile as de,deleteFile as ce,getFileIcon as pe,formatFileSize as me,getDocumentAcceptString as ue}from"../../../utils/fileStorage";const ve=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],fe=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"];function ge({type:d,className:i}){switch(d){case"pdf":return a(u,{className:i,style:{color:"var(--destructive)"}});case"doc":return a(u,{className:i,style:{color:"var(--primary)"}});case"xls":return a(J,{className:i,style:{color:"var(--success)"}});case"ppt":return a(u,{className:i,style:{color:"var(--warning)"}});case"text":case"html":return a(u,{className:i});default:return a(Q,{className:i})}}function z(d){const i="."+d.name.split(".").pop()?.toLowerCase();return ve.includes(i)}const P=ae(({name:d="document",label:i,value:S,onChange:A,error:v,helperText:x,multiple:f=!1,maxFiles:L=10,maxSize:
|
|
1
|
+
"use client";import{jsx as a,jsxs as n,Fragment as K}from"react/jsx-runtime";import{Upload as V,X as _,FileText as u,FileSpreadsheet as J,File as Q,Loader2 as Y,Eye as Z}from"lucide-react";import{useState as D,useRef as $,useImperativeHandle as ee,forwardRef as ae}from"react";import{Button as k,BUTTON_VARIANT as C,Text as s,Stack as m,Progress as re,Dialog as te,DialogContent as ne,DialogHeader as ie,DialogTitle as le}from"@donotdev/components";import{handleError as y,useTranslation as oe}from"@donotdev/core";import{useFileUpload as se}from"../../../hooks/useFileUpload";import{uploadFile as de,deleteFile as ce,getFileIcon as pe,formatFileSize as me,getDocumentAcceptString as ue}from"../../../utils/fileStorage";const ve=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"],fe=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"];function ge({type:d,className:i}){switch(d){case"pdf":return a(u,{className:i,style:{color:"var(--destructive)"}});case"doc":return a(u,{className:i,style:{color:"var(--primary)"}});case"xls":return a(J,{className:i,style:{color:"var(--success)"}});case"ppt":return a(u,{className:i,style:{color:"var(--warning)"}});case"text":case"html":return a(u,{className:i});default:return a(Q,{className:i})}}function z(d){const i="."+d.name.split(".").pop()?.toLowerCase();return ve.includes(i)}const P=ae(({name:d="document",label:i,value:S,onChange:A,error:v,helperText:x,multiple:f=!1,maxFiles:L=10,maxSize:H=25*1024*1024,storagePath:w,required:I,enablePreview:b=!0},R)=>{const{t:l}=oe("crud"),[N,g]=D(!1),[h,T]=D(null),c=$(null),E=ue();function M(e,r){return de(e,{storagePath:w,onProgress:t=>r(t.progress)})}const{files:o,addFiles:F,removeFile:O}=se({name:d,value:S,onChange:A,multiple:f,maxFiles:L,maxSize:H,accept:fe,storagePath:w,uploadFn:M});ee(R,()=>({upload:async()=>{},getDocuments:()=>o}),[o]);function W(e){const r=Array.from(e.target.files||[]);if(r.length>0){const t=r.filter(p=>z(p)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:p.name}),severity:"warning",showNotification:!0}),!1));t.length>0&&F(t)}c.current&&(c.current.value="")}function j(e){e.preventDefault(),g(!1);const r=Array.from(e.dataTransfer.files).filter(t=>z(t)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:t.name}),severity:"warning",showNotification:!0}),!1));r.length>0&&F(r)}async function B(e){const r=o.find(t=>t.id===e);if(r)try{r.uploaded&&"url"in r.uploaded&&await ce(r.uploaded),O(e)}catch(t){y(t,{userMessage:l("document.delete.failed"),severity:"error",showNotification:!0})}}function U(e){if(e.uploaded&&"url"in e.uploaded){const r=e.uploaded;r.mimeType==="application/pdf"&&T(r.url)}}const G=f||o.length===0;return n(K,{children:[n(m,{gap:"tight",children:[n(s,{level:"body",textAlign:"start",children:[i,I?"*":""]}),G&&n("div",{role:"button",tabIndex:0,"aria-label":l("document.upload.ariaLabel"),className:"dndev-surface","data-variant":v?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:N?"var(--primary)":v?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:N?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:j,onClick:()=>c.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c.current?.click())},children:[a("input",{ref:c,type:"file",accept:E,multiple:f,style:{display:"none"},onChange:W}),n(m,{align:"center",justify:"center",children:[a(V,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(s,{as:"p",variant:"muted",level:"small",textAlign:"center",children:l("document.upload.hint")}),a(s,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&a(m,{gap:"tight",children:o.map(e=>{const r=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,t=pe(r||"",e.file.name),p=e.status==="uploading",X=r==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf"),q=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ge,{type:t,className:"dndev-size-md"}),n(m,{gap:"none",style:{flex:1,minWidth:0},children:[a(s,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(s,{level:"caption",variant:"muted",children:[me(q),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),p&&a(re,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),n(m,{direction:"row",gap:"tight",children:[b&&X&&e.status==="complete"&&a(k,{variant:C.GHOST,onClick:()=>U(e),"aria-label":l("document.preview.ariaLabel"),children:a(Z,{className:"dndev-size-sm"})}),p?a(Y,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(k,{variant:C.GHOST,onClick:()=>B(e.id),"aria-label":l("document.delete.ariaLabel"),children:a(_,{className:"dndev-size-sm"})})]})]},e.id)})}),x&&a(s,{level:"caption",variant:v?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:x})]}),b&&h&&a(te,{open:!!h,onOpenChange:()=>T(null),children:n(ne,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[a(ie,{children:a(le,{children:l("document.preview.title")})}),a("iframe",{src:h,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});P.displayName="DocumentFieldComponent";var he=P;export{he as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as d}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as k,useMemo as w}from"react";import{Label as S,Stack as u,Button as $,Slider as N}from"@donotdev/components";const f=[15,30,45,60,90,120,150,180],q={15:"duration.15m",30:"duration.30m",45:"duration.45m",60:"duration.1h",90:"duration.1h30",120:"duration.2h",150:"duration.2h30",180:"duration.3h"};function W(e,n){const i=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,s=q[e];return!n||!s?i:n(`crud:${s}`,{defaultValue:i})??i}const j=({label:e,value:n,onChange:i,error:s,helperText:l,disabled:m,required:p,readonly:C,min:g=0,max:v=480,step:M=5,t})=>{const r=typeof n=="number"&&!Number.isNaN(n)?n:0,c=f.includes(r),[h,b]=k(!c&&r>0),T=w(()=>f.map(a=>({minutes:a,label:W(a,t)})),[t]),y=t?t("crud:duration.custom"):"Custom";if(C){const a=r===0?t?t("crud:duration.zero"):"\u2014":r<60?t?t("crud:duration.minutes",{count:r}):`${r} min`:t?t("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return d(u,{gap:"tight",children:[o(S,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",children:[o(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),o("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),l&&o("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})}return d(u,{children:[o(S,{required:p,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[T.map(({minutes:a,label:z})=>d($,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),i(a)},"aria-pressed":r===a,"aria-label":z,children:[o(x,{size:14,style:{marginRight:"var(--gap-sm)"},"aria-hidden":!0}),z]},a)),o($,{type:"button",variant:h?"primary":"outline",disabled:m,onClick:()=>{b(!0),!c&&r>0?i(r):i(30)},"aria-pressed":h,"aria-label":y,children:y})]}),h&&o(u,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:o(N,{value:[c?30:r],onValueChange:([a])=>i(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:M,showValue:!0,disabled:m,"aria-label":e})}),l&&o("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var E=j;export{f as DURATION_PRESETS,E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{Upload as B,X as M,File as U,Loader2 as E,FileText as g,FileSpreadsheet as H,FileImage as V,FileVideo as q,FileAudio as G,FileArchive as K,FileCode as W}from"lucide-react";import{useState as X,useRef as _,useImperativeHandle as J,forwardRef as Q}from"react";import{Button as Y,BUTTON_VARIANT as Z,Text as d,Stack as u,Progress as $}from"@donotdev/components";import{handleError as ee,useTranslation as ae}from"@donotdev/core";import{useFileUpload as re}from"../../../hooks/useFileUpload";import{uploadFile as le,deleteFile as se,getFileIcon as te,formatFileSize as ie}from"../../../utils/fileStorage";function ne({type:p,className:r}){switch(p){case"pdf":return a(g,{className:r,style:{color:"var(--destructive)"}});case"doc":return a(g,{className:r,style:{color:"var(--primary)"}});case"xls":return a(H,{className:r,style:{color:"var(--success)"}});case"ppt":return a(g,{className:r,style:{color:"var(--warning)"}});case"image":return a(V,{className:r});case"video":return a(q,{className:r});case"audio":return a(G,{className:r});case"archive":return a(K,{className:r});case"html":case"text":return a(W,{className:r});default:return a(U,{className:r})}}const b=Q(({name:p="file",label:r,value:T,onChange:w,error:m,helperText:h,accept:v,multiple:n=!1,maxFiles:k=10,maxSize:z=50*1024*1024,storagePath:y,required:
|
|
1
|
+
"use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{Upload as B,X as M,File as U,Loader2 as E,FileText as g,FileSpreadsheet as H,FileImage as V,FileVideo as q,FileAudio as G,FileArchive as K,FileCode as W}from"lucide-react";import{useState as X,useRef as _,useImperativeHandle as J,forwardRef as Q}from"react";import{Button as Y,BUTTON_VARIANT as Z,Text as d,Stack as u,Progress as $}from"@donotdev/components";import{handleError as ee,useTranslation as ae}from"@donotdev/core";import{useFileUpload as re}from"../../../hooks/useFileUpload";import{uploadFile as le,deleteFile as se,getFileIcon as te,formatFileSize as ie}from"../../../utils/fileStorage";function ne({type:p,className:r}){switch(p){case"pdf":return a(g,{className:r,style:{color:"var(--destructive)"}});case"doc":return a(g,{className:r,style:{color:"var(--primary)"}});case"xls":return a(H,{className:r,style:{color:"var(--success)"}});case"ppt":return a(g,{className:r,style:{color:"var(--warning)"}});case"image":return a(V,{className:r});case"video":return a(q,{className:r});case"audio":return a(G,{className:r});case"archive":return a(K,{className:r});case"html":case"text":return a(W,{className:r});default:return a(U,{className:r})}}const b=Q(({name:p="file",label:r,value:T,onChange:w,error:m,helperText:h,accept:v,multiple:n=!1,maxFiles:k=10,maxSize:z=50*1024*1024,storagePath:y,required:C},S)=>{const{t:c}=ae("crud"),[x,f]=X(!1),o=_(null);function A(e,l){return le(e,{storagePath:y,onProgress:t=>l(t.progress)})}const{files:i,addFiles:F,removeFile:D}=re({name:p,value:T,onChange:w,multiple:n,maxFiles:k,maxSize:z,accept:v?[v]:[],storagePath:y,uploadFn:A});J(S,()=>({upload:async()=>{},getFiles:()=>i}),[i]);function I(e){const l=Array.from(e.target.files||[]);l.length>0&&F(l),o.current&&(o.current.value="")}function L(e){e.preventDefault(),f(!1),F(Array.from(e.dataTransfer.files))}async function P(e){const l=i.find(t=>t.id===e);if(l)try{l.uploaded&&"url"in l.uploaded&&await se(l.uploaded),D(e)}catch(t){ee(t,{userMessage:c("file.delete.failed"),severity:"error",showNotification:!0})}}const R=n||i.length===0;return s(u,{gap:"tight",children:[s(d,{level:"body",textAlign:"start",children:[r,C?"*":""]}),R&&s("div",{role:"button",tabIndex:0,"aria-label":c(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":m?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:x?"var(--primary)":m?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:x?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:L,onClick:()=>o.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),o.current?.click())},children:[a("input",{ref:o,type:"file",accept:v,multiple:n,style:{display:"none"},onChange:I}),s(u,{align:"center",justify:"center",children:[a(B,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(d,{as:"p",variant:"muted",level:"small",textAlign:"center",children:c(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),i.length>0&&a(u,{gap:"tight",children:i.map((e,l)=>{const t=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,O=te(t||"",e.file.name),N=e.status==="uploading",j=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return s("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ne,{type:O,className:"dndev-size-md"}),s(u,{gap:"none",style:{flex:1,minWidth:0},children:[a(d,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),s(d,{level:"caption",variant:"muted",children:[ie(j),e.error&&s("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),N&&a($,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),N?a(E,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(Y,{variant:Z.GHOST,onClick:()=>P(e.id),"aria-label":c("file.delete.ariaLabel"),children:a(M,{className:"dndev-size-sm"})})]},e.id)})}),h&&a(d,{level:"caption",variant:m?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:h})]})});b.displayName="FileFieldComponent";var oe=b;export{oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as o,Fragment as w}from"react/jsx-runtime";import{useState as g}from"react";import{Checkbox as D,Label as H,Sheet as f,Text as P}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";import{InlineFieldRow as j}from"./internal/InlineFieldRow";const F=({checked:l=!1,onChange:a,required:y,privacyPolicyPath:s="/legal/privacy",termsPath:
|
|
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
|
-
"use client";import{jsx as r,jsxs as s,Fragment as Z}from"react/jsx-runtime";import{DndContext as _,closestCenter 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
|
|
1
|
+
import{jsx as a,jsxs as s,Fragment as J}from"react/jsx-runtime";import{useMemo as M,useId as R}from"react";import{Combobox as $,Tag as p,Stack as h}from"@donotdev/components";import{useTranslation as B}from"@donotdev/core";const d=4,f=3,F=({label:v,info:b,value:t=[],options:l,error:S,helperText:n,onChange:u,onBlur:x,required:y,className:z})=>{const{t:g}=B("crud"),m=R(),N=M(()=>l.map(e=>({value:String(e.value),label:e.label})),[l]),C=e=>{const r=Array.isArray(e)?e:[e],o={target:{value:JSON.stringify(r)}};u(o)},O=e=>{e||x?.()},A=e=>{const r=t.filter(c=>c!==e),o={target:{value:JSON.stringify(r)}};u(o)},i=!!S,T=`${m}-error`,j=`${m}-helper`,q=t.length>0?s(J,{children:[t.slice(0,t.length>d?f:d).map((e,r)=>{const o=l.find(c=>String(c.value)===e)?.label||e;return a(p,{size:"sm",onRemove:()=>A(e),children:o},r)}),t.length>d&&s(p,{size:"sm",variant:"outline",disabled:!0,children:["+",t.length-f," more"]})]}):void 0;return s(h,{gap:"tight",className:z,children:[a($,{label:v,info:b,value:t,onValueChange:C,onOpenChange:O,placeholder:g("actions.selectOptions","Select options..."),emptyMessage:g("messages.noResults","No results found"),options:N,multiple:!0,required:y,variant:i?"destructive":void 0,chips:q}),i&&s(h,{id:T,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),n]}),n&&!i&&a("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var V=F;export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useState as q,useMemo as
|
|
1
|
+
"use client";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useState as q,useMemo as f,useEffect as E,useId as O}from"react";import{Input as U,FloatingLabel as D,Button as G,BUTTON_VARIANT as H,DropdownMenu as V,Stack as h,cn as _}from"@donotdev/components";import{Flag as $,COUNTRIES as y}from"@donotdev/core";const P=({label:z,info:R,value:i="",onChange:C,name:w,onBlur:B,ref:F,error:N,helperText:g,required:I=!1,disabled:v=!1,defaultCountry:x="FR",showFlags:S=!0,preferredCountries:c,countries:m})=>{const o=O(),p=f(()=>m&&m.length>0?m.map(e=>y.find(r=>r.code===e)).filter(e=>e!==void 0):Array.from(y),[m]),n=f(()=>{if(!c||c.length===0)return p;const e=c.map(t=>p.find(j=>j.code===t)).filter(t=>t!==void 0),r=p.filter(t=>!c.includes(t.code));return[...e,...r]},[p,c]),u=f(()=>n.find(e=>e.code===x)||n[0]||y[0],[x,n]),{country:b,phoneNumber:k}=f(()=>{if(!i)return{country:u,phoneNumber:""};const e=n.find(t=>i.startsWith(t.dialCode));if(e){let t=i.slice(e.dialCode.length).trim();return t.startsWith("0")&&(t=t.slice(1).trim()),t=t.replace(/\s+/g," ").trim(),{country:e,phoneNumber:t}}if(i.startsWith("+"))return{country:u,phoneNumber:i};let r=i.trim();return r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim(),{country:u,phoneNumber:r}},[i,u,n]),[d,T]=q(u);E(()=>{i&&b.code!==d.code&&T(b)},[i,b,d.code]);const W=k,A=e=>{T(e);let r=W;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:r?`${e.dialCode} ${r}`:""}};C(t)},L=e=>{let r=e.target.value;r.startsWith("0")&&(r=r.slice(1).trim()),r=r.replace(/\s+/g," ").trim();const t={target:{value:r?`${d.dialCode} ${r}`:""}};C(t)},M=n.map(e=>({label:e.dialCode,onClick:()=>A(e),checked:e.code===d.code,children:S?s(h,{direction:"row",align:"center",gap:"tight",children:[a($,{code:e.flagCode,title:e.name}),a("span",{children:e.dialCode}),a("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-xs)"},children:e.name})]}):s("span",{children:[e.dialCode," ",e.name]})})),l=!!N;return s(h,{gap:"tight",children:[a(D,{htmlFor:o,label:z,info:R,disabled:v,required:I,children:s("div",{className:"dndev-relative",style:{display:"flex",gap:0},children:[a(V,{trigger:a(G,{type:"button",variant:H.GHOST,disabled:v,style:{minWidth:"fit-content",padding:"0 var(--gap-md)"},"aria-label":`Country code: ${d.dialCode}`,children:s(h,{direction:"row",align:"center",gap:"tight",children:[S&&a($,{code:d.flagCode,title:d.name}),a("span",{children:d.dialCode})]})}),items:M,contentWidth:"16rem"}),a(U,{ref:F,name:w,onBlur:B,id:o,type:"tel",inputMode:"tel",value:W,onChange:L,disabled:v,placeholder:"6 12 34 56 78",bare:!0,"data-variant":l?"destructive":void 0,className:"dndev-flex-1",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderRadius:"0 var(--radius-md) var(--radius-md) 0"},"aria-describedby":_(l&&`${o}-error`,g&&!l&&`${o}-helper`),"aria-invalid":l})]})}),l&&s(h,{id:`${o}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[a("span",{children:"\u26A0"}),N]}),g&&!l&&a("p",{id:`${o}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:g})]})};var Y=P;export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as h,Rating as m,Stack as
|
|
1
|
+
import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as h,Rating as m,Stack as f}from"@donotdev/components";const v=({label:a,value:o=0,onChange:s,error:l,helperText:r,max:t=5,disabled:i,required:n,readonly:d,showValue:u=!1})=>g(f,{gap:"tight",children:[e(h,{required:n,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:a}),e(m,{value:o,onChange:s,max:t,disabled:i,readonly:d,showValue:u,"aria-label":a}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]});var p=v;export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import h from"./TextAreaComponent";const p=m(()=>typeof window<"u"?import("./internal/TiptapEditor").catch(()=>({default:()=>null})):Promise.resolve({default:()=>null})),x=({label:l,value:a="",onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import h from"./TextAreaComponent";const p=m(()=>typeof window<"u"?import("./internal/TiptapEditor").catch(()=>({default:()=>null})):Promise.resolve({default:()=>null})),x=({label:l,value:a="",onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n})=>{const[i,u]=f(!1);return g(()=>{u(!0)},[]),i?e(v,{gap:"tight",children:e(b,{fallback:e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n}),children:p?e(p,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n}):e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n})})}):e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:c,className:n})};var C=x;export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as N,useId as F,useRef as j,useEffect as q}from"react";import{Textarea as A,FloatingLabel as R,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,info:b,value:o="",onChange:y,error:h,helperText:s,rows:z=3,loading:d=!1,maxLength:r,showCharCount:v=!1,autoResize:i=!1,required:w=!1,disabled:g=!1,className:$,...S})=>{const e=F(),[I,f]=N(!1),l=j(null),a=!!h,c=o.length,C=r&&c>r*.8,L=r&&c>r;return q(()=>{if(i&&l.current){const u=l.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[o,i]),n(p,{gap:"tight",children:[t(R,{htmlFor:e,label:x,info:b,disabled:g||d,required:w,children:n("div",{className:"dndev-relative",children:[t(A,{ref:l,id:e,value:o,onChange:y,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||d,maxLength:r,rows:i?1:z,bare:!0,"aria-describedby":m(a&&`${e}-error`,s&&!a&&`${e}-helper`,v&&`${e}-count`),"aria-invalid":a,className:m("dndev-w-full",i&&"dndev-overflow-hidden",$),"data-variant":a?"destructive":void 0,style:{resize:i?"none":void 0},...S}),d&&t("div",{className:"dndev-absolute",style:{right:"var(--gap-md)",top:"var(--gap-md)"},children:t(k,{"aria-label":"Loading"})})]})}),v&&r&&n("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:L?"var(--destructive-foreground)":C?"var(--warning)":"var(--muted-foreground)"},children:[c,"/",r]}),a&&n(p,{as:"p",id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),h]}),s&&!a&&t("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:s})]})};var E=B;export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{Stack as i}from"@donotdev/components";const e={minBlockSize:"var(--touch-target)"};function o({children:r}){return t(i,{direction:"row",align:"center",gap:"tight",style:e,children:r})}export{o as InlineFieldRow};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as
|
|
1
|
+
"use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as P}from"@donotdev/components";const x=({label:d,value:r="",onChange:s,error:e,helperText:n,required:o,disabled:a,placeholder:l,className:c,modules:g})=>{const{useEditor:v,EditorContent:p,StarterKit:h,Placeholder:b}=g,t=v({extensions:[h.configure({heading:{levels:[1,2,3]}}),b.configure({placeholder:l||"Start typing..."})],content:r,editable:!a,onUpdate:({editor:y})=>{const M={target:{value:y.getHTML()}};s(M)}});return u(()=>{t&&r!==t.getHTML()&&t.commands.setContent(r||"")},[r,t]),t?m(P,{gap:"tight",children:[m("label",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:e?"var(--destructive-foreground)":"var(--foreground)"},children:[d,o&&i("span",{style:{color:"var(--destructive)"},children:" *"})]}),i("div",{className:c,"data-variant":e?"destructive":void 0,style:{border:"var(--border-hairline) solid",borderColor:e?"var(--destructive)":"var(--line-2)",borderRadius:"var(--radius-interactive)",padding:"var(--gap-md)",minHeight:"200px",backgroundColor:a?"var(--muted)":"transparent",opacity:a?"var(--opacity-muted)":void 0},children:i(p,{editor:t})}),n&&i("p",{style:{fontSize:"var(--font-size-xs)",color:e?"var(--destructive-foreground)":"var(--muted-foreground)"},children:n}),i("style",{children:`
|
|
2
2
|
.ProseMirror {
|
|
3
3
|
outline: none;
|
|
4
4
|
min-height: 150px;
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
margin: 0.5em 0;
|
|
50
50
|
color: var(--muted-foreground);
|
|
51
51
|
}
|
|
52
|
-
`})]}):null},z=
|
|
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};
|