@donotdev/crud 0.1.45 → 0.2.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/README.md +13 -9
- package/dist/CrudService.bulk.js +1 -1
- package/dist/CrudService.bulkAcross.js +1 -1
- package/dist/CrudService.cache.d.ts.map +1 -1
- package/dist/CrudService.cache.js +1 -1
- package/dist/CrudService.d.ts +12 -0
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.internal.d.ts +24 -4
- package/dist/CrudService.internal.d.ts.map +1 -1
- package/dist/CrudService.internal.js +2 -2
- package/dist/CrudService.js +1 -1
- package/dist/CrudService.mutations.d.ts.map +1 -1
- package/dist/CrudService.mutations.js +1 -1
- package/dist/CrudService.optimistic.d.ts.map +1 -1
- package/dist/CrudService.optimistic.js +1 -1
- package/dist/CrudService.queries.d.ts +5 -0
- package/dist/CrudService.queries.d.ts.map +1 -1
- package/dist/CrudService.queries.js +1 -1
- package/dist/CrudService.subscriptions.d.ts.map +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +0 -11
- package/dist/FieldRegistry.d.ts.map +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.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.d.ts +0 -2
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.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.d.ts.map +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/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.d.ts.map +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.d.ts.map +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.d.ts +1 -11
- package/dist/components/controlled/types.d.ts.map +1 -1
- package/dist/components/controlled/types.js +1 -1
- package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
- package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/DateFieldDisplay.js +1 -1
- package/dist/components/fields/display/DropdownDisplay.js +1 -1
- package/dist/components/fields/display/FileFieldDisplay.js +1 -1
- package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
- package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
- package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
- package/dist/components/fields/display/MapFieldDisplay.js +1 -1
- package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
- package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
- package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
- package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
- package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
- package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
- package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
- package/dist/components/fields/display/RichTextDisplay.js +2 -2
- package/dist/components/fields/display/TextAreaDisplay.js +1 -1
- package/dist/components/fields/display/TextFieldDisplay.js +1 -1
- package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
- package/dist/components/fields/display/index.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.js +1 -1
- package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
- package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
- package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
- package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
- package/dist/components/form/fields/ComboboxComponent.js +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.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.d.ts +8 -0
- package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MapFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/PriceFieldComponent.js +1 -1
- package/dist/components/form/fields/RadioFieldComponent.js +1 -1
- package/dist/components/form/fields/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/RatingFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
- package/dist/components/form/fields/RichTextComponent.js +1 -1
- package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
- package/dist/components/form/fields/index.js +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
- package/dist/components/form/internal/ImageViewerDialog.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/contexts/index.js +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/fieldTypeRegistry.store.js +1 -1
- package/dist/fieldTypeRegistry.types.d.ts +0 -10
- package/dist/fieldTypeRegistry.types.d.ts.map +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/index.js +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/index.js +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/translateFieldLabel.js +1 -1
- package/dist/forms/utils/validateEntity.js +1 -1
- package/dist/hooks/index.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/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.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/registerBuiltinFieldTypes.d.ts.map +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/symbol-index.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +7 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/useBaseCrudList.d.ts.map +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudDoc.d.ts +59 -0
- package/dist/useCrudDoc.d.ts.map +1 -0
- package/dist/useCrudDoc.js +1 -0
- package/dist/useCrudList.js +1 -1
- package/dist/useServerPrefetch.d.ts +34 -0
- package/dist/useServerPrefetch.d.ts.map +1 -0
- package/dist/useServerPrefetch.js +1 -0
- package/dist/utils/clientListProcessing.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/imageProcessing.d.ts +45 -3
- package/dist/utils/imageProcessing.d.ts.map +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.d.ts +13 -0
- package/dist/utils/mergeWithOptimistic.d.ts.map +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/sanitizeHtml.d.ts +1 -0
- package/dist/utils/sanitizeHtml.d.ts.map +1 -1
- package/dist/utils/sanitizeHtml.js +1 -1
- package/dist/utils/scopeUtils.js +1 -1
- package/dist/utils/uploadValidation.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 +9 -2
- package/guidelines/CRUD.md +1 -0
- package/package.json +14 -16
|
@@ -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 c}from"react-hook-form";import{TextAreaComponent as p}from"../../form/fields";import{convertValidationRules as C}from"../types";function f(n){const{control:s,fieldConfig:a,t:i,placeholder:m,required:d}=n,{name:u,label:h,validation:o}=a,e=a.options||{};return t(c,{name:u,control:s,rules:o?C(o):void 0,render:({field:r,fieldState:l})=>t(p,{...r,label:i(h),value:r.value??"",onChange:r.onChange,error:l.error?.message,helperText:l.error?.message,required:d,placeholder:m||e.placeholder,maxLength:o?.maxLength,showCharCount:e.showCharCount,autoResize:e.autoResize,rows:e.rows,className:e.className})})}export{f as ControlledTextareaField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ControlledCheckboxField as
|
|
1
|
+
import{ControlledCheckboxField as o}from"./ControlledCheckboxField";import{ControlledCurrencyField as l}from"./ControlledCurrencyField";import{ControlledNumberField as e}from"./ControlledNumberField";import{ControlledPasswordField as r}from"./ControlledPasswordField";import{ControlledPriceField as d}from"./ControlledPriceField";import{ControlledPhoneField as t}from"./ControlledPhoneField";import{ControlledRangeField as i}from"./ControlledRangeField";import{ControlledRatingField as n}from"./ControlledRatingField";import{ControlledDurationField as a}from"./ControlledDurationField";import{ControlledSwitchField as s}from"./ControlledSwitchField";import{ControlledTextField as C}from"./ControlledTextField";import{ControlledTextareaField as m}from"./ControlledTextareaField";import{ControlledGdprConsentField as F}from"./ControlledGdprConsentField";export{o as ControlledCheckboxField,l as ControlledCurrencyField,a as ControlledDurationField,F as ControlledGdprConsentField,e as ControlledNumberField,r as ControlledPasswordField,t as ControlledPhoneField,d as ControlledPriceField,i as ControlledRangeField,n as ControlledRatingField,s as ControlledSwitchField,C as ControlledTextField,m as ControlledTextareaField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as O}from"react/jsx-runtime";import{useMemo as y,useEffect as S,useRef as V}from"react";import{Controller as j,useWatch as D,useFormContext as E}from"react-hook-form";import{translateLabel as L}from"../../../forms/utils";import{ComboboxComponent as M}from"../../form/fields";import{convertValidationRules as w}from"../types";function G(F){const{control:m,fieldConfig:a,t:s,placeholder:q,required:B}=F,{name:i,label:P,validation:t,options:f={}}=a,b=E(),h=b?.setValue,v=b?.resetField,o=D({control:m}),n="dependsOn"in a?a.dependsOn:void 0,l=n&&o?o[n.field]:void 0,d=y(()=>{const e=t?.options;return e?typeof e=="function"?e(o||{}):e:[]},[t?.options,o,l]),C=V(void 0);S(()=>{const e=C.current;if(C.current=l,e===void 0||e===l)return;const r=o?.[i];r&&!d.map(c=>c.value).includes(r)&&v&&v(i)},[l]);const R=y(()=>d.map(e=>({...e,label:L(e.label,s)})),[d,s]),u=f.fieldSpecific;return O(j,{name:i,control:m,rules:t?w(t):void 0,render:({field:e,fieldState:r})=>{const c=p=>{const g=typeof p=="string"?p:p.target.value;if(e.onChange(g),n&&h&&u?.setParentOnChange){const x=u.setParentOnChange(g,o||{});x!=null&&h(n.field,x,{shouldValidate:!0,shouldDirty:!0})}};return O(M,{...e,label:s(P),value:e.value??"",onChange:c,onBlur:e.onBlur,options:R,error:!!r.error,helperText:r.error?.message,required:B,placeholder:q||f.placeholder,creatable:u?.creatable??!1})}})}export{G as ControlledComboboxField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as v}from"react/jsx-runtime";import{useMemo as C}from"react";import{Controller as V,useWatch as q,useFormContext as w}from"react-hook-form";import{translateLabel as B}from"../../../forms/utils";import{DropdownComponent as F}from"../../form/fields";import{convertValidationRules as P}from"../types";function j(g){const{control:d,fieldConfig:l,t:a,onChange:z,required:h}=g,{name:b,label:x,validation:n,options:y={}}=l,u=w()?.setValue,t="dependsOn"in l?l.dependsOn:void 0,o=t?t.field:void 0,O=typeof n?.options=="function",i=q({control:d,name:o,disabled:!o}),f=C(()=>{const e=n?.options;if(!e)return[];if(typeof e=="function"){const r=o?{[o]:i}:{};return e(r)}return e},[n?.options,O,o,i]),D=C(()=>f.map(e=>({...e,label:B(e.label,a)})),[f,a]),p=y.fieldSpecific;return v(V,{name:b,control:d,rules:n?P(n):void 0,render:({field:e,fieldState:r})=>{const S=s=>{const m=typeof s=="string"?s:s.target.value;if(e.onChange(m),t&&u&&p?.setParentOnChange){const c=p.setParentOnChange(m,o?{[o]:i}:{});c!=null&&u(t.field,c,{shouldValidate:!0,shouldDirty:!0})}};return v(F,{label:a(x),value:e.value!==void 0&&e.value!==null?String(e.value):"",onChange:S,onBlur:e.onBlur,options:D,error:!!r.error,helperText:r.error?.message,required:h})}})}export{j as ControlledDropdownField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as f}from"react/jsx-runtime";import{useMemo as m}from"react";import{Controller as A,useWatch as x}from"react-hook-form";import{translateLabel as M}from"../../../forms/utils";import{MultiDropdownComponent as O}from"../../form/fields";import{convertValidationRules as w}from"../types";function D(c){const{control:s,fieldConfig:a,t:l,required:v}=c,{name:y,label:b,validation:e}=a,u="dependsOn"in a?a.dependsOn:void 0,o=u?u.field:void 0,g=typeof e?.options=="function",d=x({control:s,name:o,disabled:!o}),p=m(()=>{const r=e?.options;if(!r)return[];if(typeof r=="function"){const n=o?{[o]:d}:{};return r(n)}return r},[e?.options,g,o,d]),C=m(()=>p.map(r=>({value:String(r.value),label:M(r.label,l)})),[p,l]);return f(A,{name:y,control:s,rules:e?w(e):void 0,render:({field:r,fieldState:n})=>{const h=i=>{let t;if(Array.isArray(i))t=i;else try{t=JSON.parse(i.target.value)}catch{t=[]}r.onChange(t)};return f(O,{...r,label:l(b),value:Array.isArray(r.value)?r.value:[],onChange:h,onBlur:r.onBlur,options:C,error:!!n.error,helperText:n.error?.message,required:v})}})}export{D as ControlledMultiDropdownField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as p}from"react/jsx-runtime";import{useMemo as u}from"react";import{Controller as x,useWatch as y}from"react-hook-form";import{translateLabel as R}from"../../../forms/utils";import{RadioFieldComponent as q}from"../../form/fields";import{convertValidationRules as F}from"../types";function O(m){const{control:a,fieldConfig:t,t:i,required:c}=m,{name:v,label:g,validation:o}=t,s="dependsOn"in t?t.dependsOn:void 0,r=s?s.field:void 0,b=typeof o?.options=="function",d=y({control:a,name:r,disabled:!r}),f=u(()=>{const e=o?.options;if(!e)return[];if(typeof e=="function"){const n=r?{[r]:d}:{};return e(n)}return e},[o?.options,b,r,d]),C=u(()=>f.map(e=>({value:String(e.value),label:R(e.label,i)})),[f,i]);return p(x,{name:v,control:a,rules:o?F(o):void 0,render:({field:e,fieldState:n})=>p(q,{...e,label:i(g),value:e.value??void 0,onChange:l=>{const h=typeof l=="string"?l:l.target.value;e.onChange(h)},options:C,error:!!n.error,helperText:n.error?.message,required:c})})}export{O as ControlledRadioField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as m}from"react/jsx-runtime";import{useMemo as v}from"react";import{Controller as S}from"react-hook-form";import{useCrudList as _}from"../../../useCrudList";import x from"../../form/fields/ReferenceFieldComponent";import{convertValidationRules as L}from"../types";const R=["name","title","label","displayName"];function p(e,n,l){if(n?.length){const r=n.map(i=>e[i]).filter(i=>i!=null&&i!=="");if(r.length)return r.join(" ")}if(l&&e[l]!=null&&e[l]!=="")return String(e[l]);for(const r of R)if(e[r]!=null&&e[r]!=="")return String(e[r]);return e.id??"?"}function j(e){const{control:n,fieldConfig:l,t:r,placeholder:i,required:c}=e,{name:b,label:g,validation:a,options:d={}}=l,s=a?.reference,t=d.fieldSpecific,{items:f,loading:h}=_(s??"__disabled__",{enabled:!!s}),C=v(()=>f.map(o=>({id:o.id,label:p(o,t?.labelFields,t?.displayField)})),[f,t?.labelFields,t?.displayField]);return m(S,{name:b,control:n,rules:a?L(a):void 0,render:({field:o,fieldState:u})=>m(x,{label:r(g),value:o.value??"",onChange:F=>o.onChange(F),onBlur:o.onBlur,options:C,isLoading:h,error:!!u.error,helperText:u.error?.message,required:c,placeholder:i||d.placeholder})})}export{j as ControlledReferenceField,p as buildReferenceLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import{useMemo as b}from"react";import{Controller as C}from"react-hook-form";import{translateLabel as x}from"../../../forms/utils";import{ComboboxComponent as S}from"../../form/fields";import{convertValidationRules as y}from"../types";function Y(i){const{control:s,fieldConfig:m,t:u,placeholder:c,required:p}=i,{name:d,label:f,validation:o,options:v={}}=m,g=b(()=>{const e=o?.min??1900,l=o?.max??new Date().getFullYear()+10,t=[];for(let r=l;r>=e;r--)t.push({value:String(r),label:String(r)});return t},[o?.min,o?.max]);return n(C,{name:d,control:s,rules:o?y(o):void 0,render:({field:e,fieldState:l})=>{const t=r=>{const a=typeof r=="string"?r:r.target.value,h=a===""?void 0:Number(a);e.onChange(h)};return n(S,{...e,label:x(f,u),value:e.value!==void 0&&e.value!==null?String(e.value):"",onChange:t,onBlur:e.onBlur,options:g,error:!!l.error,helperText:l.error?.message,required:p,placeholder:c||v.placeholder,translationNamespace:"crud",placeholderKey:"actions.selectYear",placeholderDefault:"Select or type year",creatable:!0})}})}export{Y as ControlledYearField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ControlledComboboxField as
|
|
1
|
+
import{ControlledComboboxField as o}from"./ControlledComboboxField";import{ControlledDropdownField as l}from"./ControlledDropdownField";import{ControlledMultiDropdownField as e}from"./ControlledMultiDropdownField";import{ControlledRadioField as r}from"./ControlledRadioField";import{ControlledReferenceField as d}from"./ControlledReferenceField";import{ControlledYearField as i}from"./ControlledYearField";export{o as ControlledComboboxField,l as ControlledDropdownField,e as ControlledMultiDropdownField,r as ControlledRadioField,d as ControlledReferenceField,i as ControlledYearField};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Control, ControllerRenderProps,
|
|
1
|
+
import type { Control, ControllerRenderProps, FieldValues, Path, RegisterOptions } from 'react-hook-form';
|
|
2
2
|
import type { EntityField, FieldType, ValueTypeForField } from '@donotdev/core';
|
|
3
3
|
/**
|
|
4
4
|
* Props for controlled field components (react-hook-form)
|
|
@@ -9,16 +9,6 @@ import type { EntityField, FieldType, ValueTypeForField } from '@donotdev/core';
|
|
|
9
9
|
export interface ControlledFieldProps<T extends FieldValues = FieldValues, FT extends FieldType = FieldType> {
|
|
10
10
|
/** Control object from react-hook-form - use with framework's useController hook */
|
|
11
11
|
control: Control<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Form-wide errors. Withheld when the field type registers `omitFormErrors`.
|
|
14
|
-
*
|
|
15
|
-
* @deprecated Read the error from `fieldState` (useController/Controller), or
|
|
16
|
-
* `useFormState({ control, name })` for nested paths. This object changes
|
|
17
|
-
* identity on every formState update, so receiving it re-renders the field on
|
|
18
|
-
* every validation pass. Removed in the next major — see
|
|
19
|
-
* docs/plans/form-perf-migration.html
|
|
20
|
-
*/
|
|
21
|
-
errors?: FieldErrors<T>;
|
|
22
12
|
fieldConfig: EntityField<FT>;
|
|
23
13
|
t: (key: string, options?: Record<string, unknown>) => string;
|
|
24
14
|
onChange?: (value: ValueTypeForField<FT>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/controlled/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,qBAAqB,EACrB,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/controlled/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,qBAAqB,EACrB,WAAW,EACX,IAAI,EACJ,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CACnC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,EAAE,SAAS,SAAS,GAAG,SAAS;IAEhC,oFAAoF;IACpF,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;IAC9D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,6FAA6F;IAC7F,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC7B,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AAEH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GACnC,MAAM,GAAG,SAAS,CAsBpB;AAED;;;;GAIG;AAEH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,GAAG,GAAG,eAAe,CA4BvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function
|
|
1
|
+
"use client";function i(e){if(e){if(e instanceof RegExp)return e;try{const t=/^\/(.*)\/([gimyus]*)$/.exec(e);if(t){const[,r,n]=t;if(r)return new RegExp(r,n)}return new RegExp(e)}catch{return}}}function a(e){if(!e)return{};const t={};return e.required!==void 0&&(t.required=e.required),e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),e.minLength!==void 0&&(t.minLength=e.minLength),e.maxLength!==void 0&&(t.maxLength=e.maxLength),e.pattern&&typeof e.pattern=="string"&&(t.pattern={value:i(e.pattern)||/.*/,message:"Invalid format"}),t}export{i as convertPatternToRegex,a as convertValidationRules};
|
|
@@ -1 +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 o}from"react/jsx-runtime";import{Badge as r,Text as l}from"@donotdev/components";const n=({config:m,value:a,t:s,className:e})=>{if(a==null)return o(l,{as:"span",variant:"muted",className:e,children:"-"});const t=typeof a=="boolean"?s(a?"common.yes":"common.no"):String(a);return o(r,{variant:typeof a=="boolean"?a?"default":"secondary":"outline",className:e,children:t})};var i=n;export{n as BadgeFieldDisplay,i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a=()=>null;var t=a;export{a as ButtonFieldDisplay,t 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
|
|
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}from"react/jsx-runtime";import{Badge as t,BADGE_VARIANT as o,Text as i}from"@donotdev/components";const r=({config:n,value:a,t:c,className:s})=>a?e(t,{variant:o.OUTLINE,className:s,children:a}):e(i,{as:"span",variant:"muted",className:s,children:"-"});var l=r;export{r as DropdownDisplay,l 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 o,jsxs as t}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const e=({config:d,value:a,t:m,className:s})=>!a||a.lat===void 0&&a.lng===void 0?o(l,{as:"span",variant:"muted",className:s,children:"-"}):t(l,{as:"div",level:"small",className:`font-mono ${s||""}`,children:[a.lat?.toFixed(6),", ",a.lng?.toFixed(6)]});var i=e;export{e as GeoPointFieldDisplay,i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a=()=>null;var l=a;export{a as HiddenFieldDisplay,l as default};
|
|
@@ -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||"Image",fallback:c(a.label||"IMG"),className:`${i[r]} ${e||""}`})};var u=l;export{l as ImageFieldDisplay,u 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
|
|
1
|
+
import{jsx as o,jsxs as t}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const e=({config:d,value:a,t:m,className:s})=>!a||a.lat===void 0&&a.lng===void 0?o(l,{as:"span",variant:"muted",className:s,children:"-"}):t(l,{as:"div",level:"small",className:`font-mono ${s||""}`,children:[a.lat?.toFixed(6),", ",a.lng?.toFixed(6)]});var i=e;export{e as MapFieldDisplay,i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as l,Text as o,Stack as c}from"@donotdev/components";const t=({config:p,value:a,t:d,className:s})=>!a||!Array.isArray(a)||a.length===0?r(o,{as:"span",variant:"muted",className:s,children:"-"}):r(c,{direction:"row",wrap:"wrap",className:s,children:a.map((e,i)=>r(n,{variant:l.OUTLINE,children:String(e)},i))});var m=t;export{t as MultiDropdownDisplay,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{Badge as l,BADGE_VARIANT as n,Text as c,Stack as m}from"@donotdev/components";const e=({config:p,value:a,t:d,className:s})=>!a||!Array.isArray(a)||a.length===0?r(c,{as:"span",variant:"muted",className:s,children:"-"}):r(m,{direction:"row",wrap:"wrap",className:s,children:a.map((t,i)=>r(l,{variant:n.OUTLINE,children:String(t)},i))});var o=e;export{e as MultiInputTextFieldDisplay,o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx 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
|
|
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 t}from"react/jsx-runtime";import{Text as s}from"@donotdev/components";const n=({config:c,value:e,t:o,className:r})=>e?t("a",{href:`tel:${e}`,className:r||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none","aria-label":o("common.callNumber",{number:e}),children:e}):t(s,{as:"span",variant:"muted",className:r,children:"-"});var l=n;export{n as PhoneNumberDisplay,l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Badge as r,BADGE_VARIANT as t,Text as l}from"@donotdev/components";const i=({config:c,value:a,t:d,className:s})=>a?e(r,{variant:t.OUTLINE,className:s,children:a}):e(l,{as:"span",variant:"muted",className:s,children:"-"});var o=i;export{i as RadioFieldDisplay,o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const n=({config:t,value:a,t:m,className:s})=>a==null?e(l,{as:"span",variant:"muted",className:s,children:"-"}):e(l,{as:"span",className:`font-mono ${s||""}`,children:a});var o=n;export{n as RangeFieldDisplay,o as default};
|
|
@@ -1 +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,4 +1,4 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Text as s}from"@donotdev/components";import{sanitizeHtml as t}from"../../../utils/sanitizeHtml";const a=({config:m,value:e,t:l,className:o})=>!e||e.trim()===""?r(s,{as:"span",variant:"muted",className:o,children:"-"}):i("div",{className:o,style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",borderRadius:"var(--radius-md)",border:"1px solid var(--border)",minHeight:"38px"},children:[r("div",{dangerouslySetInnerHTML:{__html:t(e)},style:{outline:"none",fontSize:"var(--font-size-base)",lineHeight:"1.6"},className:"prose prose-sm max-w-none"}),r("style",{children:`
|
|
2
2
|
/* Match Tiptap ProseMirror styling */
|
|
3
3
|
.prose p {
|
|
4
4
|
margin: 0.5em 0;
|
|
@@ -58,4 +58,4 @@ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Text as t}from"@donotde
|
|
|
58
58
|
.prose a:hover {
|
|
59
59
|
color: var(--primary-hover);
|
|
60
60
|
}
|
|
61
|
-
`})]});var
|
|
61
|
+
`})]});var n=a;export{a as RichTextDisplay,n 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
|
|
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:u=!1,asBadge:w=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[j,m]=A(!1),F=async()=>{try{await navigator.clipboard.writeText(a),m(!0),setTimeout(()=>m(!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:g=>g.currentTarget.style.textDecoration="underline",onMouseLeave:g=>g.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}),u&&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})}),u&&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
|
|
1
|
+
import{jsx as a,jsxs as m}from"react/jsx-runtime";import{Text as e}from"@donotdev/components";import{getI18nInstance as o}from"@donotdev/core";const i=({config:p,value:t,t:u,className:s})=>{if(!t)return a(e,{as:"span",variant:"muted",className:s,children:"-"});try{const n=new Date(t),r=o()?.language,l=n.toLocaleDateString(r),c=n.toLocaleTimeString(r);return m("div",{className:s,children:[a(e,{as:"span",children:l}),a(e,{as:"span",variant:"muted",level:"small",children:c})]})}catch{return a(e,{as:"span",variant:"muted",className:s,children:"-"})}};var d=i;export{i as TimestampFieldDisplay,d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as
|
|
1
|
+
import{default as a}from"./TextFieldDisplay";import{default as i}from"./BadgeFieldDisplay";import{default as s}from"./AvatarFieldDisplay";import{default as l}from"./LinkFieldDisplay";import{default as e}from"./DateFieldDisplay";import{default as t}from"./NumberFieldDisplay";import{default as o}from"./PhoneNumberDisplay";import{default as r}from"./TextAreaDisplay";import{default as p}from"./RichTextDisplay";import{default as m}from"./CheckboxFieldDisplay";import{default as d}from"./DropdownDisplay";import{default as f}from"./MultiDropdownDisplay";import{default as u}from"./MultiInputTextFieldDisplay";import{default as D}from"./RadioFieldDisplay";import{default as y}from"./RangeFieldDisplay";import{default as F}from"./FileFieldDisplay";import{default as n}from"./ImageFieldDisplay";import{default as x}from"./GeoPointFieldDisplay";import{default as T}from"./MapFieldDisplay";import{default as R}from"./ReferenceFieldDisplay";import{default as b}from"./TimestampFieldDisplay";import{default as g}from"./HiddenFieldDisplay";import{default as M}from"./ButtonFieldDisplay";export{s as AvatarFieldDisplay,i as BadgeFieldDisplay,M as ButtonFieldDisplay,m as CheckboxFieldDisplay,e as DateFieldDisplay,d as DropdownDisplay,F as FileFieldDisplay,x as GeoPointFieldDisplay,g as HiddenFieldDisplay,n as ImageFieldDisplay,l as LinkFieldDisplay,T as MapFieldDisplay,f as MultiDropdownDisplay,u as MultiInputTextFieldDisplay,t as NumberFieldDisplay,o as PhoneNumberDisplay,D as RadioFieldDisplay,y as RangeFieldDisplay,R as ReferenceFieldDisplay,p as RichTextDisplay,r as TextAreaDisplay,a as TextFieldDisplay,b as TimestampFieldDisplay};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as C,jsxs as V}from"react/jsx-runtime";import{useState as L,useEffect as U,useRef as B,useCallback as Z}from"react";import{Combobox as D,Stack as F}from"@donotdev/components";import{useTranslation as H,getPlatformEnvVar as Q}from"@donotdev/core";const K="dndev-address-autocomplete-cache",X=100;function $(){try{const o=typeof localStorage<"u"?localStorage.getItem(K):null;if(o)return new Map(JSON.parse(o))}catch{}return new Map}function ee(o){try{typeof localStorage<"u"&&localStorage.setItem(K,JSON.stringify([...o]))}catch{}}function W(o){if(o.size>X){const d=o.keys().next().value;d!==void 0&&o.delete(d)}}const z=$(),M=new Map;function te(o){const d={key:o,v:"weekly"},s="google",x="importLibrary",A="__ib__",m=document,u=window;u[s]=u[s]||{};const c=u[s].maps||(u[s].maps={}),l=new Set,a=new URLSearchParams,f=()=>c._p||(c._p=new Promise(async(S,p)=>{const h=m.createElement("script");a.set("libraries",[...l].join(","));for(const y of Object.keys(d))a.set(y.replace(/[A-Z]/g,E=>"_"+E[0].toLowerCase()),d[y]);a.set("callback",s+".maps."+A),h.src="https://maps.googleapis.com/maps/api/js?"+a,c[A]=S,h.onerror=()=>{c._p=null,p(new Error("Google Maps JS API could not load."))};const g=m.querySelector("script[nonce]");g?.nonce&&(h.nonce=g.nonce),m.head.append(h)}));c[x]||(c[x]=(S,...p)=>(l.add(S),f().then(()=>c[x](S,...p))))}const oe=({label:o,value:d,onChange:s,enableGoogleMaps:x=!1,extractDistrictCode:A,error:m,helperText:u,required:c})=>{const{t:l}=H("crud"),[a,f]=L(d?.formatted_address||""),[S,p]=L([]),[h,g]=L(!1),[y,E]=L(!1),[T,q]=L(!1),P=B(null),k=B(null),G=Q("GOOGLE_MAPS_API_KEY")||"",w=x&&!!G;U(()=>{const t=d?.formatted_address??"";f(e=>e===t?e:t)},[d]),U(()=>{if(!w||T)return;const t=window.google;if(t?.maps?.places?.AutocompleteSuggestion){P.current=new t.maps.places.AutocompleteSessionToken,q(!0);return}let e=!1;return(async()=>{try{if(window.google?.maps?.importLibrary||te(G),await window.google.maps.importLibrary("places"),e)return;P.current=new window.google.maps.places.AutocompleteSessionToken,q(!0)}catch{e||E(!0)}})(),()=>{e=!0}},[w,G,T]),U(()=>{if(!w||!T||y)return;if(a.length<3){p([]);return}const t=z.get(a);if(t){p(t);return}return k.current&&clearTimeout(k.current),k.current=setTimeout(async()=>{g(!0);try{const e=window.google.maps.places,{suggestions:v}=await e.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:a,sessionToken:P.current}),b=v.filter(r=>r.placePrediction).map(r=>{const n=r.placePrediction,i=[n.mainText?.text,n.secondaryText?.text].filter(Boolean).join(", ");return M.set(i,n),W(M),{value:i,label:i}});p(b),z.set(a,b),W(z),ee(z)}catch{E(!0),p([])}finally{g(!1)}},300),()=>{k.current&&clearTimeout(k.current)}},[w,T,y,a]);const J=Z(async t=>{const e=Array.isArray(t)?t[0]||"":t;if(!e)return;if(!w){f(e),s({formatted_address:e});return}let v=M.get(e);const b=window.google?.maps?.places;if(b){if(!v){g(!0);try{const{suggestions:r}=await b.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:e,sessionToken:P.current}),n=r.find(i=>[i.placePrediction?.mainText?.text,i.placePrediction?.secondaryText?.text].filter(Boolean).join(", ")===e);n?.placePrediction&&(v=n.placePrediction,M.set(e,v))}catch{}if(!v){g(!1),f(e),s({formatted_address:e});return}}g(!0);try{const r=v.toPlace();await r.fetchFields({fields:["formattedAddress","location","addressComponents"]});const n=r.formattedAddress||e;let i=r.location?.lat()??0,I=r.location?.lng()??0;if(i===0&&I===0&&n)try{const j=await window.google.maps.importLibrary("geocoding"),_=(await new j.Geocoder().geocode({address:n})).results?.[0]?.geometry?.location;_&&(i=_.lat(),I=_.lng())}catch{}const R={formatted_address:n,latitude:i,longitude:I};if(A){const j=r.addressComponents||[],_=j.find(O=>(O.types||[]).includes("postal_code"))?.longText||j.find(O=>(O.types||[]).includes("postal_code"))?.long_name||"",Y=_.startsWith("92")?92:parseInt(_.slice(-2),10)||null;R.district_code=Y}f(n),p([]),s(R),P.current=new b.AutocompleteSessionToken}catch{f(e),s({formatted_address:e})}finally{g(!1)}}},[w,A,s]),N=t=>{f(t)};return w?V(F,{gap:"tight",children:[C(D,{label:o,value:a,onValueChange:J,onSearchChange:N,placeholder:l("address.placeholder","Enter address..."),emptyMessage:h?l("messages.loading","Loading..."):l("address.noResults","No addresses found"),options:S.map(t=>({value:t.value,label:t.label})),required:c,variant:m?"destructive":void 0,isLoading:h,creatable:!0,createLabel:l("actions.use","Use this address"),disabled:!T&&!y}),y&&C("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:l("address.apiUnavailable","Google Places unavailable \u2014 type address manually")}),u&&C("p",{style:{fontSize:"var(--font-size-xs)",color:m?"var(--destructive-foreground)":"var(--muted-foreground)"},children:u})]}):V(F,{gap:"tight",children:[C(D,{label:o,value:a,onValueChange:J,onSearchChange:N,placeholder:l("address.placeholder","Enter address..."),options:[],required:c,variant:m?"destructive":void 0,creatable:!0,createLabel:l("actions.use","Use this address")}),u&&C("p",{style:{fontSize:"var(--font-size-xs)",color:m?"var(--destructive-foreground)":"var(--muted-foreground)"},children:u})]})};var ae=oe;export{ae 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
|
-
import{jsx as
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{Checkbox as h}from"@donotdev/components";const t=({label:r,checked:a=!1,onChange:e,required:c})=>d(h,{checked:a,onCheckedChange:o=>{e&&e({target:{checked:o}})},label:r,required:c});var n=t;export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useMemo as L,useId as N}from"react";import{Combobox as $,Stack as d}from"@donotdev/components";import{useTranslation as D}from"@donotdev/core";const I=({label:u,value:l,options:s,error:p,helperText:a,onChange:n,onBlur:m,required:g,placeholder:h,translationNamespace:v="dndev",placeholderKey:f="actions.select",placeholderDefault:b="Select",creatable:x=!1,createLabel:y,emptyMessage:S})=>{const{t:r}=D(v),i=N(),z=L(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),C=e=>{if(n){const q={target:{value:Array.isArray(e)?e[0]||"":e}};n(q)}},A=e=>{e||m?.()},t=!!p,M=`${i}-error`,j=`${i}-helper`;return c(d,{gap:"tight",children:[o($,{label:u,value:l||"",onValueChange:C,onOpenChange:A,placeholder:h||r(f,b),emptyMessage:S||r("messages.noResults","No results found"),creatable:x,createLabel:y||r("actions.create","Create"),options:z,required:g,variant:t?"destructive":void 0,clearable:!!l}),t&&c(d,{id:M,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),a]}),a&&!t&&o("p",{id:j,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})};var O=I;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as h,useEffect as j,useId as q}from"react";import{Input as C,FloatingLabel as L,Stack as M}from"@donotdev/components";const U=({label:b,value:r,onChange:x,currency:o="EUR",locale:F,error:i,helperText:d,required:I=!1,disabled:u=!1,placeholder:N})=>{const c=q(),S=F||(typeof navigator<"u"?navigator.language:"en-US"),l=e=>e==null||isNaN(e)?"":(e/100).toString(),p=e=>{if(!e||e.trim()==="")return null;const a=e.replace(/[^\d.,\-]/g,"").replace(",","."),t=parseFloat(a);return isNaN(t)?null:Math.round(t*100)},[g,s]=h(l(r)),[v,m]=h(!1);j(()=>{v?p(g)!==r&&s(l(r)):s(l(r))},[r,v]);const z=e=>{const a=e.target.value;s(a);const t={target:{value:p(a)}};x(t)},E=()=>m(!0),T=()=>m(!1),f=(()=>{try{return new Intl.NumberFormat(S,{style:"currency",currency:o,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||o}catch{return o}})();return y(M,{gap:"tight",children:[n(L,{htmlFor:c,label:b,disabled:u,required:I,children:y("div",{style:{position:"relative"},children:[n("span",{style:{position:"absolute",left:"var(--gap-md)",top:"50%",transform:"translateY(-50%)",color:"var(--muted-foreground)",pointerEvents:"none",zIndex:1},children:f}),n(C,{id:c,type:"text",inputMode:"decimal",bare:!0,value:g,onChange:z,onFocus:E,onBlur:T,disabled:u,placeholder:N||"0","data-variant":i?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${f.length*.6}em + var(--gap-sm))`}})]})}),d&&n("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:d})]})};var B=U;export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,jsxs as n}from"react/jsx-runtime";import{useId as m}from"react";import{DatePicker as z,DateTimePicker as $,Input as b,cn as h,Stack as d}from"@donotdev/components";const x=({label:u,value:s,onChange:v,error:c,helperText:t,mode:a="date",required:g,...p})=>{const r=m(),e=!!c,f=o=>{const S=o.target.value?new Date(o.target.value).toISOString():null;v(S)};let l="";if(s){const o=new Date(s);a==="date"?l=o.toISOString().split("T")[0]||"":a==="datetime-local"?l=o.toISOString().slice(0,16)||"":a==="month"?l=o.toISOString().slice(0,7):a==="time"?l=o.toISOString().slice(11,16):a==="week"&&(l=o.toISOString().split("T")[0]||"")}return a==="date"?n(d,{gap:"tight",children:[i(z,{id:r,label:u,value:s??null,onChange:v,required:g,"aria-describedby":h(e&&`${r}-error`,t&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&n(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),c]}),t&&!e&&i("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]}):a==="datetime-local"?n(d,{gap:"tight",children:[i($,{id:r,label:u,value:s??null,onChange:v,required:g,"aria-describedby":h(e&&`${r}-error`,t&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0}),e&&n(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),c]}),t&&!e&&i("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]}):n(d,{gap:"tight",children:[i(b,{id:r,label:u,type:a,value:l,onChange:f,required:g,"aria-describedby":h(e&&`${r}-error`,t&&!e&&`${r}-helper`),"aria-invalid":e,"data-variant":e?"destructive":void 0,className:"dndev-w-full",...p}),e&&n(d,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[i("span",{children:"\u26A0"}),c]}),t&&!e&&i("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:t})]})};var y=x;export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
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-xs)"}})]}),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-xs)"},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 l,jsxs as g}from"react/jsx-runtime";import{Select as d,Stack as v}from"@donotdev/components";import{useTranslation as m}from"@donotdev/core";const f=({label:t,value:r,options:n,error:s,helperText:a,onChange:o,onBlur:i,required:u})=>{const{t:p}=m("crud"),c=r!=null?String(r):"";return g(v,{gap:"tight",children:[l(d,{label:t,value:c,onValueChange:e=>{o&&o({target:{value:e}})},onOpenChange:e=>!e&&i?.(),placeholder:p("actions.select","Select"),required:u,options:n.map(e=>({value:String(e.value),label:e.label}))}),a&&l("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var h=f;export{h as default};
|