@donotdev/crud 0.3.2 → 0.3.4
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.internal.js +2 -2
- 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/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/DisplayFieldRenderer.js +1 -1
- package/dist/components/DisplayThumbnail.js +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/SortableCardList.js +1 -1
- package/dist/components/YearFilter.js +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
- package/dist/components/controlled/complex/ControlledMapField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
- package/dist/components/controlled/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/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/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/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/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/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/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/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.d.ts +19 -0
- package/dist/components/form/fields/PhoneNumberComponent.d.ts.map +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/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/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/fieldTypeRegistry.store.js +1 -1
- package/dist/forms/extend.js +1 -1
- package/dist/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityField.js +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/hooks/useFormDraftState.js +1 -1
- package/dist/forms/types.d.ts +9 -0
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/conditionAwareResolver.d.ts +6 -2
- package/dist/forms/utils/conditionAwareResolver.d.ts.map +1 -1
- package/dist/forms/utils/conditionAwareResolver.js +1 -1
- package/dist/forms/utils/emptyValue.js +1 -1
- package/dist/forms/utils/fieldErrorMessages.d.ts +33 -0
- package/dist/forms/utils/fieldErrorMessages.d.ts.map +1 -0
- package/dist/forms/utils/fieldErrorMessages.js +1 -0
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/validateEntity.js +1 -1
- package/dist/forms/utils/writableFields.js +1 -1
- package/dist/hooks/useChildRows.js +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useCrudPageSize.js +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useExtensionRows.js +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useReferenceResolver.js +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/stores/FormStore.js +1 -1
- package/dist/stores/UploadStore.js +1 -1
- package/dist/stores/uploadStoreRef.js +1 -1
- package/dist/symbol-index.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudDoc.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/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/CRUD.md +3 -1
- package/guidelines/GOTCHAS.md +2 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MultiInputTextFieldComponent as C}from"../../form/fields";import{fieldInfo as v}from"../fieldOptions";import{convertValidationRules as y}from"../types";function g(l){const{control:s,fieldConfig:
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MultiInputTextFieldComponent as C}from"../../form/fields";import{fieldInfo as v}from"../fieldOptions";import{convertValidationRules as y}from"../types";function g(l){const{control:s,fieldConfig:a,required:u,t:o}=l,{name:m,label:f,validation:n,options:c={}}=a;return i(p,{name:m,control:s,rules:n?y(n):void 0,render:({field:r})=>{const d=e=>{if(Array.isArray(e))r.onChange(e);else try{const t=JSON.parse(e.target.value);r.onChange(Array.isArray(t)?t:[])}catch{r.onChange([])}};return i(C,{label:o(f),info:v(a,o),value:Array.isArray(r.value)?r.value:[],onChange:d,required:u,className:c.className})}})}export{g as ControlledMultiInputField};
|
|
@@ -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 f}from"react-hook-form";import{RichTextComponent as h}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(n){const{control:t,fieldConfig:i,placeholder:s,required:m,t:d}=n,{name:c,label:p,validation:e,options:r={}}=i;return a(f,{name:c,control:t,rules:e?C(e):void 0,render:({field:o,fieldState:l})=>a(h,{label:d(p),value:o.value??"",onChange:u=>o.onChange(u),error:l.error?.message,helperText:l.error?.message,required:m,placeholder:s||r.placeholder,className:r.className})})}export{x as ControlledRichTextField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as c}from"react-hook-form";import{DocumentFieldComponent as f}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:o,label:u,validation:r}=e,a=g(e);return i(c,{name:o,control:m,rules:r?x(r):void 0,render:({field:t,fieldState:l})=>i(f,{name:o,label:d(u),value:t.value??null,onChange:p=>t.onChange(p),error:!!l.error,helperText:l.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:a?.maxSize,storagePath:a?.storagePath})})}export{C as ControlledDocumentField};
|
|
@@ -1 +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 f}from"react-hook-form";import{FileFieldComponent as c}from"../../form/fields";import{uploadFieldSpecific as g}from"../fieldOptions";import{convertValidationRules as x}from"../types";function C(n){const{control:m,fieldConfig:e,required:s,t:d}=n,{name:r,label:u,validation:o}=e,l=g(e);return t(f,{name:r,control:m,rules:o?x(o):void 0,render:({field:a,fieldState:i})=>t(c,{name:r,label:d(u),value:a.value??null,onChange:p=>a.onChange(p),error:!!i.error,helperText:i.error?.message,required:s,multiple:!1,maxFiles:1,maxSize:l?.maxSize,storagePath:l?.storagePath})})}export{C as ControlledFileField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as m}from"react/jsx-runtime";import{useMemo as c}from"react";import{Controller as x}from"react-hook-form";import{readImageProcessingOptions as C}from"../../../utils/imageProcessing";import{ImageFieldComponent as h}from"../../form/fields";import{uploadFieldSpecific as v}from"../fieldOptions";import{convertValidationRules as S}from"../types";function F(n){const{control:s,fieldConfig:r,required:d,t:p}=n,{name:o,label:f,validation:a}=r,e=v(r),i=e?.image,g=c(()=>C({image:i}),[JSON.stringify(i)]);return m(x,{name:o,control:s,rules:a?S(a):void 0,render:({field:l,fieldState:t})=>m(h,{name:o,label:p(f),value:l.value??null,onChange:u=>l.onChange(u),error:!!t.error,helperText:t.error?.message,required:d,multiple:!1,maxFiles:1,maxSize:e?.maxSize,storagePath:e?.storagePath,processing:g})})}export{F as ControlledImageField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as v}from"react-hook-form";import{DocumentFieldComponent as x}from"../../form/fields";import{controlledFieldOptions as g,uploadFieldSpecific as C}from"../fieldOptions";import{convertValidationRules as F}from"../types";function h(n){const{control:m,fieldConfig:r,required:s,t:u}=n,{name:o,label:d,validation:l}=r,c=g(r),a=C(r);return t(v,{name:o,control:m,rules:l?F(l):void 0,render:({field:e,fieldState:i})=>{const p=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return t(x,{name:o,label:u(d),value:p,onChange:f=>e.onChange(f),error:!!i.error,helperText:i.error?.message,required:s,multiple:!0,maxFiles:c.maxFiles??10,maxSize:a?.maxSize,storagePath:a?.storagePath})}})}export{h as ControlledMultiDocumentField};
|
|
@@ -1 +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(s){const{control:m,fieldConfig:r,required:u,t:d}=s,{name:a,label:p,validation:i}=r,f=S(r),o=y(r),l=o?.image,g=x(()=>F({image:l}),[JSON.stringify(l)]);return n(C,{name:a,control:m,rules:i?I(i):void 0,render:({field:e,fieldState:t})=>{const c=Array.isArray(e.value)?e.value:e.value?[e.value]:null;return n(h,{name:a,label:d(p),value:c,onChange:v=>e.onChange(v),error:!!t.error,helperText:t.error?.message,required:u,multiple:!0,maxFiles:f.maxFiles??10,maxSize:o?.maxSize,storagePath:o?.storagePath,processing:g})}})}export{O as ControlledMultiImageField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as u}from"react/jsx-runtime";import{Controller as
|
|
1
|
+
"use client";import{jsx as u}from"react/jsx-runtime";import{Controller as h}from"react-hook-form";import{CurrencyFieldComponent as y}from"../../form/fields";import{fieldInfo as N}from"../fieldOptions";import{convertValidationRules as x}from"../types";function S(c){const{control:s,fieldConfig:o,t:l,placeholder:d,required:f}=c,{name:m,label:p,validation:n}=o,t=(o.options||{}).fieldSpecific;return u(h,{name:m,control:s,rules:n?x(n):void 0,render:({field:e,fieldState:a})=>{const C=g=>{const r=g.target.value;if(r==null||r===""){e.onChange(null);return}const i=typeof r=="number"?r/100:parseFloat(String(r))/100;isNaN(i)?e.onChange(null):e.onChange(i)},v=e.value!=null&&!isNaN(e.value)?Math.round(e.value*100):void 0;return u(y,{label:l(p),info:N(o,l),value:v,onChange:C,currency:t?.currency||"EUR",locale:t?.locale,error:!!a.error,helperText:a.error?.message,required:f,placeholder:d})}})}export{S as ControlledCurrencyField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{DurationFieldComponent as c}from"../../form/fields";import{convertValidationRules as C}from"../types";function x(l){const{control:d,fieldConfig:r,t:i,required:s}=l,{name:m,label:f,validation:n}=r,e=(r.options||{}).fieldSpecific;return a(p,{name:m,control:d,rules:n?C(n):void 0,render:({field:o,fieldState:t})=>a(c,{label:i(f),value:o.value??0,onChange:u=>o.onChange(u),error:!!t.error,helperText:t.error?.message,required:s,disabled:o.disabled,min:e?.min??0,max:e?.max??480,step:e?.step??5,t:i})})}export{x as ControlledDurationField};
|
|
@@ -1 +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,o=h(n),d=o?.privacyPolicyPath||"/legal/privacy",p=o?.termsPath||"/legal/terms";return i(C,{name:c,control:l,rules:r?v(r):void 0,render:({field:t})=>{const e=t.value,m=typeof e=="object"&&e!==null?!!e.gdprConsent:!!e;return i(u,{checked:m,onChange:f=>{if(f.target.checked){const g=new Date().toISOString().split("T")[0];t.onChange({gdprConsent:!0,gdprConsentDate:new Date().toISOString(),gdprConsentVersion:g})}else t.onChange(!1)},required:s,privacyPolicyPath:d,termsPath:p})}})}export{y as ControlledGdprConsentField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as s}from"react/jsx-runtime";import{Controller as v}from"react-hook-form";import{NumberFieldComponent as C}from"../../form/fields";import{fieldInfo as h}from"../fieldOptions";import{convertValidationRules as N}from"../types";function b(u){const{control:c,fieldConfig:o,t,placeholder:x,required:d}=u,{name:f,label:p,validation:r}=o,
|
|
1
|
+
"use client";import{jsx as s}from"react/jsx-runtime";import{Controller as v}from"react-hook-form";import{NumberFieldComponent as C}from"../../form/fields";import{fieldInfo as h}from"../fieldOptions";import{convertValidationRules as N}from"../types";function b(u){const{control:c,fieldConfig:o,t:n,placeholder:x,required:d}=u,{name:f,label:p,validation:r}=o,t=o.options||{},a=t.fieldSpecific;return s(v,{name:f,control:c,rules:r?N(r):void 0,render:({field:e,fieldState:i})=>{const g=l=>{if(l.target.value===""||l.target.value===null){e.onChange(null);return}try{const m=parseFloat(l.target.value);isNaN(m)||e.onChange(m)}catch{e.onChange(0)}};return s(C,{...e,label:n(p),info:h(o,n),value:e.value??void 0,onChange:g,error:!!i.error,helperText:i.error?.message,required:d,min:r?.min,max:r?.max,step:a?.mask==="currency"?.01:a?.mask==="mileage"?1:void 0,mask:a?.mask||"number",className:t.className})}})}export{b as ControlledNumberField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{fromInputValue as h}from"../../../forms/utils";import{PasswordFieldComponent as v}from"../../form/fields";import{fieldInfo as C}from"../fieldOptions";import{convertValidationRules as g}from"../types";function x(i){const{control:s,fieldConfig:o,t:r,placeholder:m,required:d}=i,{name:f,label:p,validation:l,options:a={}}=o;return t(u,{name:f,control:s,rules:l?g(l):void 0,render:({field:e,fieldState:n})=>t(v,{...e,label:r(p),info:C(o,r),value:e.value??"",onChange:c=>e.onChange(h(c.target.value)),error:!!n.error,helperText:n.error?.message,required:d,placeholder:m||a.placeholder,className:a.className})})}export{x as ControlledPasswordField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{fromInputValue as p}from"../../../forms/utils";import{PhoneNumberComponent as g}from"../../form/fields";import{fieldInfo as v}from"../fieldOptions";import{convertValidationRules as c}from"../types";function C(l){const{control:i,fieldConfig:r,t:o,required:m}=l,{name:f,label:s,validation:n}=r;return t(d,{name:f,control:i,rules:n?c(n):void 0,render:({field:e,fieldState:a})=>t(g,{ref:e.ref,name:e.name,onBlur:e.onBlur,label:o(s),info:v(r,o),value:typeof e.value=="string"?e.value:"",onChange:u=>e.onChange(p(u.target.value)),error:a.error?.message,helperText:a.error?.message,required:m})})}export{C as ControlledPhoneField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{RatingFieldComponent as c}from"../../form/fields";import{convertValidationRules as g}from"../types";function x(l){const{control:t,fieldConfig:o,t:m,required:s}=l,{name:d,label:f,validation:e}=o,r=(o.options||{}).fieldSpecific;return i(p,{name:d,control:t,rules:e?g(e):void 0,render:({field:n,fieldState:a})=>i(c,{label:m(f),value:n.value??0,onChange:u=>{n.onChange(u)},error:!!a.error,helperText:a.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:c,t:o,onChange:l}=h,{name:m,label:s}=c,e=v(c),u=e?.uncheckedValue??!1,r=e?.checkedValue??!0,t=e?.uncheckedLabel,a=e?.checkedLabel;return d(L,{name:m,control:f,render:({field:{value:k,onChange:p},fieldState:C})=>{const g=k===r,b=n=>{const i=n?r:u;p(i),l&&l(i)};return d(S,{label:o(s),checked:g,onChange:n=>b(n.target.checked),uncheckedLabel:t?o(t):void 0,checkedLabel:a?o(a):void 0,helperText:C.error?.message})}})}export{x as ControlledSwitchField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{fromInputValue as g}from"../../../forms/utils";import{TextFieldComponent as x}from"../../form/fields";import{controlledFieldOptions as v,fieldInfo as y}from"../fieldOptions";import{convertValidationRules as F}from"../types";function T(i){const{control:m,fieldConfig:e,t:a,placeholder:s,required:d}=i,{name:p,label:u,validation:
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import{Controller as C}from"react-hook-form";import{fromInputValue as g}from"../../../forms/utils";import{TextFieldComponent as x}from"../../form/fields";import{controlledFieldOptions as v,fieldInfo as y}from"../fieldOptions";import{convertValidationRules as F}from"../types";function T(i){const{control:m,fieldConfig:e,t:a,placeholder:s,required:d}=i,{name:p,label:u,validation:r}=e,l=v(e),f=r?F(r):void 0,c=e.type==="email"?"email":e.type==="url"?"url":e.type==="color"?"color":"text";return n(C,{name:p,control:m,rules:f,render:({field:o,fieldState:t})=>n(x,{ref:o.ref,name:o.name,value:o.value??"",onChange:h=>o.onChange(g(h.target.value)),onBlur:o.onBlur,label:a(u),info:y(e,a),error:t.error?.message,helperText:t.error?.message,type:c,required:d,placeholder:s||l.placeholder,maxLength:r?.maxLength,showCharCount:l.showCharCount,className:l.className})})}export{T as ControlledTextField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as O}from"react/jsx-runtime";import{useMemo as V,useEffect as P,useRef as R}from"react";import{Controller as S,useWatch as j,useFormContext as D}from"react-hook-form";import{fromInputValue as E,translateLabel as L}from"../../../forms/utils";import{ComboboxComponent as M}from"../../form/fields";import{fieldInfo as T}from"../fieldOptions";import{convertValidationRules as w}from"../types";function J(
|
|
1
|
+
"use client";import{jsx as O}from"react/jsx-runtime";import{useMemo as V,useEffect as P,useRef as R}from"react";import{Controller as S,useWatch as j,useFormContext as D}from"react-hook-form";import{fromInputValue as E,translateLabel as L}from"../../../forms/utils";import{ComboboxComponent as M}from"../../form/fields";import{fieldInfo as T}from"../fieldOptions";import{convertValidationRules as w}from"../types";function J(F){const{control:p,fieldConfig:t,t:n,placeholder:q,required:y}=F,{name:i,label:B,validation:l,options:c={}}=t,b=D(),h=b?.setValue,v=b?.resetField,o=j({control:p}),a="dependsOn"in t?t.dependsOn:void 0,s=a&&o?o[a.field]:void 0,d=V(()=>{const e=l?.options;return e?typeof e=="function"?e(o||{}):e:[]},[l?.options,o,s]),C=R(void 0);P(()=>{const e=C.current;if(C.current=s,e===void 0||e===s)return;const r=o?.[i];r&&!d.map(f=>f.value).includes(r)&&v&&v(i)},[s]);const I=V(()=>d.map(e=>({...e,label:L(e.label,n)})),[d,n]),u=c.fieldSpecific;return O(S,{name:i,control:p,rules:l?w(l):void 0,render:({field:e,fieldState:r})=>{const f=m=>{const g=typeof m=="string"?m:m.target.value;if(e.onChange(E(g)),a&&h&&u?.setParentOnChange){const x=u.setParentOnChange(g,o||{});x!=null&&h(a.field,x,{shouldValidate:!0,shouldDirty:!0})}};return O(M,{...e,label:n(B),info:T(t,n),value:e.value??"",onChange:f,onBlur:e.onBlur,options:I,error:!!r.error,helperText:r.error?.message,required:y,placeholder:q||c.placeholder,creatable:u?.creatable??!1})}})}export{J as ControlledComboboxField};
|
|
@@ -1 +1 @@
|
|
|
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{fieldInfo as P}from"../fieldOptions";import{convertValidationRules as j}from"../types";function I(g){const{control:d,fieldConfig:r,t,onChange:A,required:h}=g,{name:b,label:x,validation:n,options:y={}}=r,u=w()?.setValue,i="dependsOn"in r?r.dependsOn:void 0,
|
|
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{fieldInfo as P}from"../fieldOptions";import{convertValidationRules as j}from"../types";function I(g){const{control:d,fieldConfig:r,t,onChange:A,required:h}=g,{name:b,label:x,validation:n,options:y={}}=r,u=w()?.setValue,i="dependsOn"in r?r.dependsOn:void 0,e=i?i.field:void 0,O=typeof n?.options=="function",a=q({control:d,name:e,disabled:!e}),f=C(()=>{const o=n?.options;if(!o)return[];if(typeof o=="function"){const l=e?{[e]:a}:{};return o(l)}return o},[n?.options,O,e,a]),D=C(()=>f.map(o=>({...o,label:B(o.label,t)})),[f,t]),p=y.fieldSpecific;return v(V,{name:b,control:d,rules:n?j(n):void 0,render:({field:o,fieldState:l})=>{const S=s=>{const m=typeof s=="string"?s:s.target.value;if(o.onChange(m),i&&u&&p?.setParentOnChange){const c=p.setParentOnChange(m,e?{[e]:a}:{});c!=null&&u(i.field,c,{shouldValidate:!0,shouldDirty:!0})}};return v(F,{label:t(x),info:P(r,t),value:o.value!==void 0&&o.value!==null?String(o.value):"",onChange:S,onBlur:o.onBlur,options:D,error:!!l.error,helperText:l.error?.message,required:h})}})}export{I as ControlledDropdownField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as p}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{fieldInfo as S}from"../fieldOptions";import{convertValidationRules as w}from"../types";function D(c){const{control:s,fieldConfig:n,t,required:v}=c,{name:y,label:b,validation:o}=n,u="dependsOn"in n?n.dependsOn:void 0,
|
|
1
|
+
"use client";import{jsx as p}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{fieldInfo as S}from"../fieldOptions";import{convertValidationRules as w}from"../types";function D(c){const{control:s,fieldConfig:n,t,required:v}=c,{name:y,label:b,validation:o}=n,u="dependsOn"in n?n.dependsOn:void 0,e=u?u.field:void 0,g=typeof o?.options=="function",d=x({control:s,name:e,disabled:!e}),f=m(()=>{const r=o?.options;if(!r)return[];if(typeof r=="function"){const i=e?{[e]:d}:{};return r(i)}return r},[o?.options,g,e,d]),C=m(()=>f.map(r=>({value:String(r.value),label:M(r.label,t)})),[f,t]);return p(A,{name:y,control:s,rules:o?w(o):void 0,render:({field:r,fieldState:i})=>{const h=a=>{let l;if(Array.isArray(a))l=a;else try{l=JSON.parse(a.target.value)}catch{l=[]}r.onChange(l)};return p(O,{...r,label:t(b),info:S(n,t),value:Array.isArray(r.value)?r.value:[],onChange:h,onBlur:r.onBlur,options:C,error:!!i.error,helperText:i.error?.message,required:v})}})}export{D as ControlledMultiDropdownField};
|
|
@@ -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: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 c}from"react/jsx-runtime";import{useMemo as y}from"react";import{Controller as R}from"react-hook-form";import{fromInputValue as S}from"../../../forms/utils";import{useCrudList as _}from"../../../useCrudList";import{resolveReferenceEntity as x}from"../../../utils/referenceEntity";import L from"../../form/fields/ReferenceFieldComponent";import{fieldInfo as j,fieldSpecificOf as q}from"../fieldOptions";import{convertValidationRules as B}from"../types";const I=["name","title","label","displayName"];function p(e,n,o){if(n?.length){const r=n.map(l=>e[l]).filter(l=>l!=null&&l!=="");if(r.length)return r.join(" ")}if(o&&e[o]!=null&&e[o]!=="")return String(e[o]);for(const r of I)if(e[r]!=null&&e[r]!=="")return String(e[r]);return e.id??"?"}function E(e){const{control:n,fieldConfig:o,t:r,placeholder:l,required:b}=e,{name:d,label:g,validation:s,options:h={}}=o,f=s?.reference,t=q(o),a=f?x(f,d):void 0,{items:m,loading:v}=_(a?a.collection:"__disabled__",{enabled:!!a,entity:a}),C=y(()=>m.map(i=>({id:i.id,label:p(i,t?.labelFields,t?.displayField)})),[m,t?.labelFields,t?.displayField]);return c(R,{name:d,control:n,rules:s?B(s):void 0,render:({field:i,fieldState:u})=>c(L,{label:r(g),info:j(o,r),value:i.value??"",onChange:F=>i.onChange(S(F)),onBlur:i.onBlur,options:C,isLoading:v,error:!!u.error,helperText:u.error?.message,required:b,placeholder:l||h.placeholder})})}export{E as ControlledReferenceField,p as buildReferenceLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function i(
|
|
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 e}from"react/jsx-runtime";import{Avatar as n,Text as p}from"@donotdev/components";const l=({config:a,value:s,t:d,className:t,size:r="md"})=>{if(!s)return e(p,{as:"span",variant:"muted",className:t,children:"-"});const i={sm:"size-touch",md:"size-touch",lg:"h-16 w-16"},c=m=>m.split(" ").map(o=>o.charAt(0)).slice(0,2).join("").toUpperCase();return e(n,{src:s,alt:a.label||"Avatar",fallback:c(a.label||"AV"),className:`${i[r]} ${t||""}`})};var u=l;export{l as AvatarFieldDisplay,u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{Badge as t,Text as c}from"@donotdev/components";const n=({config:m,value:a,t:o,className:e})=>{if(a==null)return s(c,{as:"span",variant:"muted",className:e,children:"-"});const r=o(a?"common.yes":"common.no");return s(t,{variant:a?"default":"secondary",className:e,children:r})};var l=n;export{n as CheckboxFieldDisplay,l as default};
|
|
@@ -1 +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 e,Spinner as p}from"@donotdev/components";import{getI18nInstance as u}from"@donotdev/core";const i=({config:c,value:t,t:g,className:s,loading:m=!1})=>{if(m)return a(p,{className:s});if(!t)return a(e,{as:"span",variant:"muted",className:s,children:"-"});try{const n=new Date(t),r=u()?.language,l=n.toLocaleDateString(r),o=n.toLocaleTimeString(r);return c.type==="date"?a(e,{as:"span",className:s,children:l}):d("div",{className:s,children:[a(e,{as:"span",children:l}),a(e,{as:"span",variant:"muted",level:"small",children:o})]})}catch{return a(e,{as:"span",variant:"muted",className:s,children:"-"})}};var f=i;export{i as DateFieldDisplay,f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s,jsxs as i}from"react/jsx-runtime";import{Badge as n,BADGE_VARIANT as t,Text as l,Stack as c}from"@donotdev/components";const r=({config:m,value:a,t:o,className:e})=>a?i(c,{direction:"row",align:"center",className:e,children:[s(l,{as:"span",level:"small",children:a.name}),a.size&&i(n,{variant:t.SECONDARY,children:[(a.size/1024).toFixed(1)," KB"]})]}):s(l,{as:"span",variant:"muted",className:e,children:"-"});var d=r;export{r as FileFieldDisplay,d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{Text as i}from"@donotdev/components";const o=({config:l,value:e,t:r,className:n})=>{if(!e)return t(i,{as:"span",variant:"muted",className:n,children:"-"});const s=(()=>{switch(l.type){case"email":return{href:`mailto:${e}`,"aria-label":r("common.sendEmailTo",{email:e})};case"tel":return{href:`tel:${e}`,"aria-label":r("common.callNumber",{number:e})};default:return{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":r("common.openLink")}}})();return t("a",{...s,className:n||"",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:a=>a.currentTarget.style.textDecoration="underline",onMouseLeave:a=>a.currentTarget.style.textDecoration="none",children:e})};var c=o;export{o as LinkFieldDisplay,c as default};
|
|
@@ -1 +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 e,Spinner as o}from"@donotdev/components";import{getI18nInstance as r}from"@donotdev/core";const l=({config:i,value:n,t:c,className:a,loading:t=!1})=>t?s(o,{className:a}):n==null?s(e,{as:"span",variant:"muted",className:a,children:"-"}):s(e,{as:"span",className:`font-mono ${a||""}`,children:n.toLocaleString(r()?.language)});var m=l;export{l as NumberFieldDisplay,m as default};
|
|
@@ -1 +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 c,EyeOff as n}from"lucide-react";import{useState as u}from"react";import{Skeleton as m,Button as y,CopyToClipboard as f,Stack as t}from"@donotdev/components";const l=({config:g,value:e,t:r,className:s,loading:d=!1})=>{const[a,p]=u(!1);return d?o(m,{className:s}):e?i(t,{direction:"row",align:"center",className:s,children:[o("span",{style:{fontFamily:"monospace"},children:a?e:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),i(t,{direction:"row",align:"center",gap:"tight",children:[o(y,{type:"button",onClick:()=>p(!a),"aria-label":a?"Hide password":"Show password",children:a?o(n,{}):o(c,{})}),o(f,{text:e,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyPassword")||"Copy password"})]})]}):o("div",{style:{color:"var(--muted-foreground)"},children:"-"})};var w=l;export{l as PasswordFieldDisplay,w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{Badge as i,BADGE_VARIANT as n,Text as l}from"@donotdev/components";const r=({config:c,value:a,t:d,className:e})=>{if(!a)return s(l,{as:"span",variant:"muted",className:e,children:"-"});const t=a.displayName||a.name||a.id||a;return s(i,{variant:n.OUTLINE,className:e,children:String(t)})};var m=r;export{r as ReferenceFieldDisplay,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{Text as l}from"@donotdev/components";const r=({config:i,value:a,t:m,className:e})=>a?s(l,{as:"div",level:"small",className:`whitespace-pre-wrap ${e||""}`,children:a}):s(l,{as:"span",variant:"muted",className:e,children:"-"});var t=r;export{r as TextAreaDisplay,t as default};
|
|
@@ -1 +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 i}from"@donotdev/components";import{getWeekFromISOString as M,getI18nInstance as b}from"@donotdev/core";const C=({config:o,value:a,t:r,className:s,loading:v=!1,showCopy:g=!1,asBadge:w=!1,truncate:c=!1,maxLength:d=50,showLabel:p=!1})=>{const[j,u]=A(!1),F=async()=>{try{await navigator.clipboard.writeText(a),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},h=()=>{switch(o.type){case"email":return e(L,{});case"month":case"week":return e(k,{});case"time":return e(I,{});default:return null}},S=t=>{if(!t)return null;switch(o.type){case"email":return n("a",{href:`mailto:${t}`,style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},onMouseEnter:m=>m.currentTarget.style.textDecoration="underline",onMouseLeave:m=>m.currentTarget.style.textDecoration="none",children:[h(),t]});case"month":return new Date(t).toLocaleDateString(b()?.language,{year:"numeric",month:"long"});case"week":return M(t);case"time":return new Date(`2000-01-01T${t}`).toLocaleTimeString(b()?.language);default:return t}},D=t=>!c||t.length<=d?t:`${t.substring(0,d)}...`;if(v)return n(i,{gap:"tight",children:[p&&e(T,{style:{height:"1rem",width:"6rem"}}),e(T,{className:"dndev-w-full",style:{height:"1.5rem"}})]});if(!a)return n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),e(l,{as:"span",variant:"muted",className:f(s),style:{fontStyle:"italic"},children:r("common.noValue",{defaultValue:"No value"})})]});const N=S(a),y=D(String(N));return w?n(i,{direction:"row",align:"center",gap:"tight",children:[h(),e(B,{variant:E.SECONDARY,className:s,children:y}),g&&e(x,{text:a,tooltipText:r("copyToClipboard")||"Copy to clipboard",copiedTooltipText:r("copied")||"Copied!",ariaLabel:r("copyToClipboard")||"Copy to clipboard"})]}):n(i,{gap:"tight",children:[p&&e(l,{as:"span",variant:"muted",children:o.label||o.name}),n(i,{direction:"row",align:"center",gap:"tight",children:[e("div",{className:f("dndev-flex-1",c&&"truncate",s),title:c&&a.length>d?a:void 0,children:e(l,{as:"span",children:y})}),g&&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 L,jsxs as D}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsx as L,jsxs as D}from"react/jsx-runtime";import{useState as z,useEffect as q,useRef as F,useCallback as Q}from"react";import{Combobox as K,Stack as W}from"@donotdev/components";import{useTranslation as X,getPlatformEnvVar as $}from"@donotdev/core";const Y="dndev-address-autocomplete-cache",ee=100;function te(){try{const a=typeof localStorage<"u"?localStorage.getItem(Y):null;if(a)return new Map(JSON.parse(a))}catch{}return new Map}function ae(a){try{typeof localStorage<"u"&&localStorage.setItem(Y,JSON.stringify([...a]))}catch{}}function Z(a){if(a.size>ee){const g=a.keys().next().value;g!==void 0&&a.delete(g)}}function v(){return window.google}const M=te(),G=new Map;function oe(a){const g={key:a,v:"weekly"},d="google",u="importLibrary",E="__ib__",b=document,p=window;p[d]=p[d]||{};const o=p[d].maps||(p[d].maps={}),x=new Set,s=new URLSearchParams,m=()=>o._p||(o._p=new Promise(async(r,A)=>{const i=b.createElement("script");s.set("libraries",[...x].join(","));for(const f of Object.keys(g))s.set(f.replace(/[A-Z]/g,S=>"_"+S[0].toLowerCase()),g[f]);s.set("callback",d+".maps."+E),i.src="https://maps.googleapis.com/maps/api/js?"+s,o[E]=r,i.onerror=()=>{o._p=null,A(new Error("Google Maps JS API could not load."))};const T=b.querySelector("script[nonce]");T?.nonce&&(i.nonce=T.nonce),b.head.append(i)}));o[u]||(o[u]=(r,...A)=>(x.add(r),m().then(()=>o[u](r,...A))))}const se=({label:a,info:g,value:d,onChange:u,enableGoogleMaps:E=!1,extractDistrictCode:b,error:p,helperText:o,required:x})=>{const{t:s}=X("crud"),[m,r]=z(d?.formatted_address||""),[A,i]=z([]),[T,f]=z(!1),[S,J]=z(!1),[P,N]=z(!1),k=F(null),C=F(null),I=$("GOOGLE_MAPS_API_KEY")||"",y=E&&!!I;q(()=>{const t=d?.formatted_address??"";r(e=>e===t?e:t)},[d]),q(()=>{if(!y||P)return;const t=v();if(t?.maps?.places?.AutocompleteSuggestion){k.current=new t.maps.places.AutocompleteSessionToken,N(!0);return}let e=!1;return(async()=>{try{if(v()?.maps?.importLibrary||oe(I),await v().maps.importLibrary("places"),e)return;k.current=new(v()).maps.places.AutocompleteSessionToken,N(!0)}catch{e||J(!0)}})(),()=>{e=!0}},[y,I,P]),q(()=>{if(!y||!P||S)return;if(m.length<3){i([]);return}const t=M.get(m);if(t){i(t);return}return C.current&&clearTimeout(C.current),C.current=setTimeout(async()=>{f(!0);try{const e=v().maps.places,{suggestions:h}=await e.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:m,sessionToken:k.current}),w=h.filter(n=>n.placePrediction).map(n=>{const c=n.placePrediction,l=[c.mainText?.text,c.secondaryText?.text].filter(Boolean).join(", ");return G.set(l,c),Z(G),{value:l,label:l}});i(w),M.set(m,w),Z(M),ae(M)}catch{J(!0),i([])}finally{f(!1)}},300),()=>{C.current&&clearTimeout(C.current)}},[y,P,S,m]);const R=Q(async t=>{const e=Array.isArray(t)?t[0]||"":t;if(!e)return;if(!y){r(e),u({formatted_address:e});return}let h=G.get(e);const w=v()?.maps?.places;if(w){if(!h){f(!0);try{const{suggestions:n}=await w.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:e,sessionToken:k.current}),c=n.find(l=>[l.placePrediction?.mainText?.text,l.placePrediction?.secondaryText?.text].filter(Boolean).join(", ")===e);c?.placePrediction&&(h=c.placePrediction,G.set(e,h))}catch{}if(!h){f(!1),r(e),u({formatted_address:e});return}}f(!0);try{const n=h.toPlace();await n.fetchFields({fields:["formattedAddress","location","addressComponents"]});const c=n.formattedAddress||e;let l=n.location?.lat()??0,O=n.location?.lng()??0;if(l===0&&O===0&&c)try{const j=await v().maps.importLibrary("geocoding"),_=(await new j.Geocoder().geocode({address:c})).results?.[0]?.geometry?.location;_&&(l=_.lat(),O=_.lng())}catch{}const B={formatted_address:c,latitude:l,longitude:O};if(b){const j=n.addressComponents||[],_=j.find(U=>(U.types||[]).includes("postal_code"))?.longText||j.find(U=>(U.types||[]).includes("postal_code"))?.long_name||"",H=_.startsWith("92")?92:parseInt(_.slice(-2),10)||null;B.district_code=H}r(c),i([]),u(B),k.current=new w.AutocompleteSessionToken}catch{r(e),u({formatted_address:e})}finally{f(!1)}}},[y,b,u]),V=t=>{r(t)};return y?D(W,{gap:"tight",children:[L(K,{label:a,info:g,value:m,onValueChange:R,onSearchChange:V,placeholder:s("address.placeholder","Enter address..."),emptyMessage:T?s("messages.loading","Loading..."):s("address.noResults","No addresses found"),options:A.map(t=>({value:t.value,label:t.label})),required:x,variant:p?"destructive":void 0,isLoading:T,creatable:!0,createLabel:s("actions.use","Use this address"),disabled:!P&&!S}),S&&L("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:s("address.apiUnavailable","Google Places unavailable \u2014 type address manually")}),o&&L("p",{style:{fontSize:"var(--font-size-xs)",color:p?"var(--destructive)":"var(--muted-foreground)"},children:o})]}):D(W,{gap:"tight",children:[L(K,{label:a,info:g,value:m,onValueChange:R,onSearchChange:V,placeholder:s("address.placeholder","Enter address..."),options:[],required:x,variant:p?"destructive":void 0,creatable:!0,createLabel:s("actions.use","Use this address")}),o&&L("p",{style:{fontSize:"var(--font-size-xs)",color:p?"var(--destructive)":"var(--muted-foreground)"},children:o})]})};var re=se;export{re 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 m,Input as u,cn as f,Stack as n}from"@donotdev/components";const s=({config:r,value:t,onChange:c,error:A,helperText:l,t:i,className:d,...h})=>{const v=a=>a.split(" ").map(p=>p.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{children:[o(n,{direction:"row",align:"center",children:[e(m,{src:t,alt:r.label||"Avatar",fallback:v(r.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(u,{type:"url",className:f("dndev-w-full",d),placeholder:i("common.enterAvatarUrl"),value:t,onChange:a=>c(a.target.value),...h})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var g=s;export{s as AvatarFieldComponent,g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Badge as v,Input as f,cn as g,Stack as o}from"@donotdev/components";const l=({config:p,value:a,onChange:d,error:u,helperText:r,t:n,variant:s="default",className:i,...c})=>t(o,{children:[t(o,{direction:"row",align:"center",children:[e(v,{variant:s,style:{minWidth:0},children:a||n("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(f,{type:"text",className:g("dndev-w-full",i),placeholder:n("common.enterBadgeText"),value:a,onChange:m=>d(m.target.value),...c})})]}),r&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:r})]});var h=l;export{l as BadgeFieldComponent,h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{Button as l}from"@donotdev/components";const n=({label:a,type:t,onClick:r,variant:e,disabled:i=!1})=>o(l,{type:t,onClick:r,variant:e,disabled:i,children:a});var s=n;export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as c}from"react/jsx-runtime";import{useMemo as N,useId as T}from"react";import{Combobox as $,Stack as d}from"@donotdev/components";import{useTranslation as k}from"@donotdev/core";const I=({label:u,info:p,value:l,options:s,error:m,helperText:r,onChange:n,onBlur:f,required:h,placeholder:v,translationNamespace:g="dndev",placeholderKey:b="actions.select",placeholderDefault:x="Select",creatable:y=!1,createLabel:S,emptyMessage:C})=>{const{t:a}=k(g),i=T(),z=N(()=>s.map(e=>({value:String(e.value),label:e.label})),[s]),A=e=>{if(n){const L={target:{value:Array.isArray(e)?e[0]||"":e}};n(L)}},M=e=>{e||f?.()},t=!!m,j=`${i}-error`,q=`${i}-helper`;return c(d,{gap:"tight",children:[o($,{label:u,info:p,value:l||"",onValueChange:A,onOpenChange:M,placeholder:v||a(b,x),emptyMessage:C||a("messages.noResults","No results found"),creatable:y,createLabel:S||a("actions.create","Create"),options:z,required:h,variant:t?"destructive":void 0,clearable:!!l}),t&&c(d,{id:j,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive)"},role:"alert",children:[o("span",{children:"\u26A0"}),r]}),r&&!t&&o("p",{id:q,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:r})]})};var O=I;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as h,useEffect as
|
|
1
|
+
import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as h,useEffect as z,useId as C}from"react";import{Input as L,FloatingLabel as M,Stack as U}from"@donotdev/components";const B=({label:b,info:x,value:a,onChange:F,currency:l="EUR",locale:I,error:i,helperText:c,required:N=!1,disabled:u=!1,placeholder:S})=>{const d=C(),E=I||(typeof navigator<"u"?navigator.language:"en-US"),o=e=>e==null||isNaN(e)?"":(e/100).toString(),p=e=>{if(!e||e.trim()==="")return null;const r=e.replace(/[^\d.,\-]/g,"").replace(",","."),t=parseFloat(r);return isNaN(t)?null:Math.round(t*100)},[v,s]=h(o(a)),[g,m]=h(!1);z(()=>{g?p(v)!==a&&s(o(a)):s(o(a))},[a,g]);const T=e=>{const r=e.target.value;s(r);const t={target:{value:p(r)}};F(t)},j=()=>m(!0),q=()=>m(!1),f=(()=>{try{return new Intl.NumberFormat(E,{style:"currency",currency:l,currencyDisplay:"symbol"}).formatToParts(0).find(e=>e.type==="currency")?.value||l}catch{return l}})();return y(U,{gap:"tight",children:[n(M,{htmlFor:d,label:b,info:x,disabled:u,required:N,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(L,{id:d,type:"text",inputMode:"decimal",bare:!0,value:v,onChange:T,onFocus:j,onBlur:q,disabled:u,placeholder:S||"0","data-variant":i?"destructive":void 0,style:{paddingLeft:`calc(var(--gap-md) + ${f.length*.6}em + var(--gap-sm))`}})]})}),c&&n("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:c})]})};var D=B;export{D as default};
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 h,Stack as c}from"@donotdev/components";import{useTranslation as I}from"@donotdev/core";function D(a){const l=u=>String(u).padStart(2,"0");return`${a.getFullYear()}-${l(a.getMonth()+1)}-${l(a.getDate())}T${l(a.getHours())}:${l(a.getMinutes())}`}const O=({label:a,info:l,value:u,onChange:v,error:g,helperText:i,mode:o="date",required:p,...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);o==="date"?d=t.toISOString().split("T")[0]||"":o==="datetime-local"?d=D(t):o==="month"?d=t.toISOString().slice(0,7):o==="time"?d=t.toISOString().slice(11,16):o==="week"&&(d=t.toISOString().split("T")[0]||"")}return o==="date"?s(c,{gap:"tight",children:[n(x,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:l,value:u??null,onChange:v,required:p,"aria-describedby":h(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)"},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})]}):o==="datetime-local"?s(c,{gap:"tight",children:[n(y,{id:r,calendarErrorLabel:f("date.calendarLoadError"),label:a,info:l,value:d||null,onChange:$,required:p,"aria-describedby":h(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)"},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:l,type:o,value:d,onChange:m,required:p,"aria-describedby":h(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)"},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:E=25*1024*1024,storagePath:w,required:I,enablePreview:b=!0},O)=>{const{t:l}=oe("crud"),[N,g]=D(!1),[h,T]=D(null),c=$(null),H=ue();function M(e,r){return de(e,{storagePath:w,onProgress:t=>r(t.progress)})}const{files:o,addFiles:F,removeFile:R}=se({name:d,value:S,onChange:A,multiple:f,maxFiles:L,maxSize:E,accept:fe,storagePath:w,uploadFn:M});ee(O,()=>({upload:async()=>{},getDocuments:()=>o}),[o]);function W(e){const r=Array.from(e.target.files||[]);if(r.length>0){const t=r.filter(p=>z(p)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:p.name}),severity:"warning",showNotification:!0}),!1));t.length>0&&F(t)}c.current&&(c.current.value="")}function j(e){e.preventDefault(),g(!1);const r=Array.from(e.dataTransfer.files).filter(t=>z(t)?!0:(y(new Error("Invalid document type"),{userMessage:l("document.errors.invalidType",{fileName:t.name}),severity:"warning",showNotification:!0}),!1));r.length>0&&F(r)}async function B(e){const r=o.find(t=>t.id===e);if(r)try{r.uploaded&&"url"in r.uploaded&&await ce(r.uploaded),R(e)}catch(t){y(t,{userMessage:l("document.delete.failed"),severity:"error",showNotification:!0})}}function U(e){if(e.uploaded&&"url"in e.uploaded){const r=e.uploaded;r.mimeType==="application/pdf"&&T(r.url)}}const G=f||o.length===0;return n(K,{children:[n(m,{gap:"tight",children:[n(s,{level:"body",textAlign:"start",children:[i,I?"*":""]}),G&&n("div",{role:"button",tabIndex:0,"aria-label":l("document.upload.ariaLabel"),className:"dndev-surface","data-variant":v?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:N?"var(--primary)":v?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:N?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:j,onClick:()=>c.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),c.current?.click())},children:[a("input",{ref:c,type:"file",accept:H,multiple:f,style:{display:"none"},onChange:W}),n(m,{align:"center",justify:"center",children:[a(V,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(s,{as:"p",variant:"muted",level:"small",textAlign:"center",children:l("document.upload.hint")}),a(s,{as:"p",variant:"muted",level:"caption",textAlign:"center",children:"PDF, Word, Excel, PowerPoint, TXT, Markdown, HTML"})]})]}),o.length>0&&a(m,{gap:"tight",children:o.map(e=>{const r=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,t=pe(r||"",e.file.name),p=e.status==="uploading",X=r==="application/pdf"||e.file.name.toLowerCase().endsWith(".pdf"),q=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return n("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ge,{type:t,className:"dndev-size-md"}),n(m,{gap:"none",style:{flex:1,minWidth:0},children:[a(s,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),n(s,{level:"caption",variant:"muted",children:[me(q),e.error&&n("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),p&&a(re,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),n(m,{direction:"row",gap:"tight",children:[b&&X&&e.status==="complete"&&a(k,{variant:C.GHOST,onClick:()=>U(e),"aria-label":l("document.preview.ariaLabel"),children:a(Z,{className:"dndev-size-sm"})}),p?a(Y,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(k,{variant:C.GHOST,onClick:()=>B(e.id),"aria-label":l("document.delete.ariaLabel"),children:a(_,{className:"dndev-size-sm"})})]})]},e.id)})}),x&&a(s,{level:"caption",variant:v?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:x})]}),b&&h&&a(te,{open:!!h,onOpenChange:()=>T(null),children:n(ne,{style:{maxWidth:"90vw",maxHeight:"90vh",width:"900px",height:"80vh"},children:[a(ie,{children:a(le,{children:l("document.preview.title")})}),a("iframe",{src:h,sandbox:"allow-same-origin",style:{width:"100%",height:"100%",border:"none",borderRadius:"var(--radius-md)"},title:"PDF Preview"})]})})]})});P.displayName="DocumentFieldComponent";var he=P;export{he as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as v}from"react/jsx-runtime";import{Select as d,Stack as m}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";const h=({label:o,info:n,value:r,options:s,error:i,helperText:a,onChange:l,onBlur:u,required:c})=>{const{t:p}=f("crud"),g=r!=null?String(r):"";return v(m,{gap:"tight",children:[t(d,{label:o,info:n,value:g,onValueChange:e=>{l&&l({target:{value:e}})},onOpenChange:e=>!e&&u?.(),placeholder:p("actions.select","Select"),required:c,options:s.map(e=>({value:String(e.value),label:e.label}))}),a&&t("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var S=h;export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import{Clock as x}from"lucide-react";import{useState as k,useMemo as w}from"react";import{Label as S,Stack as u,Button as $,Slider as N}from"@donotdev/components";const p=[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,o){const n=e<60?`${e}m`:e%60===0?`${e/60}h`:`${Math.floor(e/60)}h${e%60}`,s=q[e];return!o||!s?n:o(`crud:${s}`,{defaultValue:n})??n}const j=({label:e,value:o,onChange:n,error:s,helperText:l,disabled:m,required:f,readonly:M,min:g=0,max:v=480,step:T=5,t:i})=>{const r=typeof o=="number"&&!Number.isNaN(o)?o:0,c=p.includes(r),[h,b]=k(!c&&r>0),C=w(()=>p.map(a=>({minutes:a,label:W(a,i)})),[i]),y=i?i("crud:duration.custom"):"Custom";if(M){const a=r===0?i?i("crud:duration.zero"):"\u2014":r<60?i?i("crud:duration.minutes",{count:r}):`${r} min`:i?i("crud:duration.hoursMinutes",{hours:Math.floor(r/60),minutes:r%60}):`${Math.floor(r/60)}h${r%60?` ${r%60}m`:""}`;return d(u,{gap:"tight",children:[t(S,{required:f,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",children:[t(x,{size:18,style:{color:"var(--muted-foreground)"},"aria-hidden":!0}),t("span",{style:{color:"var(--muted-foreground)",fontSize:"var(--font-size-sm)"},children:a})]}),l&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})}return d(u,{children:[t(S,{required:f,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:e}),d(u,{direction:"row",gap:"tight",align:"center",style:{flexWrap:"wrap"},children:[C.map(({minutes:a,label:z})=>d($,{type:"button",variant:r===a?"primary":"outline",disabled:m,onClick:()=>{b(!1),n(a)},"aria-pressed":r===a,"aria-label":z,children:[t(x,{size:14,style:{marginRight:"var(--gap-sm)"},"aria-hidden":!0}),z]},a)),t($,{type:"button",variant:h?"primary":"outline",disabled:m,onClick:()=>{b(!0),!c&&r>0?n(r):n(30)},"aria-pressed":h,"aria-label":y,children:y})]}),h&&t(u,{gap:"tight",style:{marginTop:"var(--gap-sm)"},children:t(N,{value:[c?30:r],onValueChange:([a])=>n(Math.max(g,Math.min(v,a??0))),min:g,max:v,step:T,showValue:!0,disabled:m,"aria-label":e})}),l&&t("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var E=j;export{p 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:D},S)=>{const{t:c}=ae("crud"),[x,f]=X(!1),o=_(null);function A(e,l){return le(e,{storagePath:y,onProgress:t=>l(t.progress)})}const{files:i,addFiles:F,removeFile:C}=re({name:p,value:T,onChange:w,multiple:n,maxFiles:k,maxSize:z,accept:v?[v]:[],storagePath:y,uploadFn:A});J(S,()=>({upload:async()=>{},getFiles:()=>i}),[i]);function I(e){const l=Array.from(e.target.files||[]);l.length>0&&F(l),o.current&&(o.current.value="")}function L(e){e.preventDefault(),f(!1),F(Array.from(e.dataTransfer.files))}async function P(e){const l=i.find(t=>t.id===e);if(l)try{l.uploaded&&"url"in l.uploaded&&await se(l.uploaded),C(e)}catch(t){ee(t,{userMessage:c("file.delete.failed"),severity:"error",showNotification:!0})}}const R=n||i.length===0;return s(u,{gap:"tight",children:[s(d,{level:"body",textAlign:"start",children:[r,D?"*":""]}),R&&s("div",{role:"button",tabIndex:0,"aria-label":c(n?"file.upload.ariaLabelMultiple":"file.upload.ariaLabelSingle"),className:"dndev-surface","data-variant":m?"destructive":"default",style:{border:"var(--border-width) dashed",borderColor:x?"var(--primary)":m?"var(--destructive)":"var(--border)",borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:x?"color-mix(in oklab, var(--primary) 5%, transparent)":"var(--surface)",transition:"border-color var(--dur-fast), background-color var(--dur-fast)",cursor:"pointer",outline:"none"},onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:L,onClick:()=>o.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),o.current?.click())},children:[a("input",{ref:o,type:"file",accept:v,multiple:n,style:{display:"none"},onChange:I}),s(u,{align:"center",justify:"center",children:[a(B,{className:"dndev-size-lg",style:{color:"var(--muted-foreground)"}}),a(d,{as:"p",variant:"muted",level:"small",textAlign:"center",children:c(n?"file.upload.dragDropMultiple":"file.upload.dragDropSingle")})]})]}),i.length>0&&a(u,{gap:"tight",children:i.map((e,l)=>{const t=e.uploaded&&"mimeType"in e.uploaded?e.uploaded.mimeType:e.file.type,O=te(t||"",e.file.name),N=e.status==="uploading",j=e.uploaded&&"size"in e.uploaded?e.uploaded.size:e.file.size;return s("div",{className:"dndev-surface","data-variant":"muted",style:{padding:"var(--gap-md)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",gap:"var(--gap-md)"},children:[a(ne,{type:O,className:"dndev-size-md"}),s(u,{gap:"none",style:{flex:1,minWidth:0},children:[a(d,{level:"small",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.file.name}),s(d,{level:"caption",variant:"muted",children:[ie(j),e.error&&s("span",{style:{color:"var(--destructive)"},children:[" ","\xB7 ",e.error]})]}),N&&a($,{value:e.progress||0,max:100,style:{marginTop:"var(--gap-sm)"}})]}),N?a(E,{className:"dndev-size-sm",style:{animation:"spin 1s linear infinite"}}):a(Y,{variant:Z.GHOST,onClick:()=>P(e.id),"aria-label":c("file.delete.ariaLabel"),children:a(M,{className:"dndev-size-sm"})})]},e.id)})}),h&&a(d,{level:"caption",variant:m?"destructive":"muted",style:{marginTop:"var(--gap-sm)"},children:h})]})});b.displayName="FileFieldComponent";var oe=b;export{oe as default};
|
|
@@ -1 +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:c="/legal/terms"})=>{const{t:r}=S("crud"),[u,d]=g(!1),[x,h]=g(!1),p=e=>{a&&a({target:{checked:e}})},v=e=>{e.target.tagName!=="A"&&(e.target.closest('[data-type="checkbox"]')||p(!l))},m=(e,k)=>{e.preventDefault(),k==="privacy"?d(!0):h(!0)},C=r("gdprConsent.consent"),i=r("gdprConsent.privacyPolicy"),n=r("gdprConsent.terms"),b=r("gdprConsent.and");return o(w,{children:[o(j,{children:[t(D,{checked:l,onCheckedChange:p}),t(H,{required:y,plain:!0,onClick:v,style:{cursor:"pointer"},children:o(P,{level:"body",style:{fontSize:"var(--font-size-input)"},children:[C," ",t("a",{href:s,onClick:e=>m(e,"privacy"),style:{textDecoration:"underline",cursor:"pointer"},children:i})," / ",t("a",{href:c,onClick:e=>m(e,"terms"),style:{textDecoration:"underline",cursor:"pointer"},children:n})," ",b]})})]}),t(f,{open:u,onOpenChange:d,side:"bottom",title:i,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:s,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:i})}),t(f,{open:x,onOpenChange:h,side:"bottom",title:n,style:{width:"100%",height:"90%",maxHeight:"90dvh",display:"flex",flexDirection:"column",overflow:"hidden"},children:t("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1,minHeight:0},title:n})})]})};var O=F;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as u}from"react/jsx-runtime";import{Label as b,Input as v,Stack as c}from"@donotdev/components";const h=({label:g,value:a={lat:0,lng:0},onChange:i,error:r,helperText:o,disabled:d,required:m})=>{const f=l=>{const e=parseFloat(l.target.value)||0;if(e>=-90&&e<=90){const n={...a,lat:e},s={target:{value:JSON.stringify(n)}};i(s)}},p=l=>{const e=parseFloat(l.target.value)||0;if(e>=-180&&e<=180){const n={...a,lng:e},s={target:{value:JSON.stringify(n)}};i(s)}};return u(c,{gap:"tight",children:[t(b,{required:m,style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:g}),u(c,{direction:"row",children:[t(v,{label:"Latitude",type:"number",value:a.lat,onChange:f,min:"-90",max:"90",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"}),t(v,{label:"Longitude",type:"number",value:a.lng,onChange:p,min:"-180",max:"180",step:"0.000001",disabled:d,"data-variant":r?"destructive":void 0,className:"dndev-w-full"})]}),o&&t("p",{style:{fontSize:"var(--font-size-xs)",color:r?"var(--destructive)":"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 Q,PointerSensor as ee,TouchSensor as re,useSensor as A,useSensors as te}from"@dnd-kit/core";import{SortableContext as ae,useSortable as ie,rectSortingStrategy as oe,arrayMove as ne}from"@dnd-kit/sortable";import{CSS as se}from"@dnd-kit/utilities";import{Upload as le,X as U,Loader2 as de,GripVertical as ce}from"lucide-react";import{forwardRef as pe,useCallback as P,useImperativeHandle as ue,useRef as ge,useState as j}from"react";import{Text as m,Stack as C,Progress as me,handleImageError as he}from"@donotdev/components";import{useTranslation as ve}from"@donotdev/core";import{useFileUpload as fe}from"../../../hooks/useFileUpload";import{processImage as ye}from"../../../utils/imageProcessing";import{uploadImage as be}from"../../../utils/imageStorage";import{ImageViewerDialog as xe}from"../internal/ImageViewerDialog";const we=["image/*"];function Ce(t){return{id:t.id,file:t.file,previewURL:t.previewURL,hash:"",rotation:0,uploadProgress:t.progress,uploaded:t.uploaded,error:t.error}}function Se({file:t,index:h,multiple:v,onImageClick:S,onRemove:f,t:l}){const{attributes:n,listeners:k,setNodeRef:I,transform:d,transition:D,isDragging:y}=ie({id:t.id}),c=t.progress!==null&&t.progress<100,p=v&&!c,b={transform:se.Transform.toString(d),transition:D,position:"relative",width:100,height:100,borderRadius:"var(--radius-md)",border:"var(--border-width) solid var(--border)",overflow:"hidden",backgroundColor:"var(--surface)",opacity:y?.5:1,cursor:p?"grab":"pointer",userSelect:"none",touchAction:p?"none":"auto"};return r("div",{ref:I,style:b,...n,...p?k:{},onClick:()=>{y||S(h)},children:c?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(de,{style:{animation:"spin 1s linear infinite"}}),r(me,{value:t.progress||0,style:{width:"80%"}})]}):t.error?s(C,{align:"center",justify:"center",style:{width:"100%",height:"100%"},children:[r(U,{style:{color:"var(--destructive)"}}),r(m,{variant:"destructive",level:"small",children:t.error})]}):s(Z,{children:[v&&r("div",{style:{position:"absolute",top:4,left:4,padding:2,background:"rgba(0,0,0,0.5)",borderRadius:"var(--radius-sm)",display:"flex",zIndex:2,pointerEvents:"none"},children:r(ce,{style:{color:"white",width:14,height:14}})}),r("img",{src:t.previewURL,alt:l("image.alt.upload",{index:h+1}),draggable:!1,onError:he,style:{width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none",userSelect:"none"}}),r("button",{type:"button",onClick:i=>{i.stopPropagation(),f(t.id)},onPointerDown:i=>i.stopPropagation(),style:{position:"absolute",top:4,right:4,padding:4,background:"rgba(0,0,0,0.5)",border:"none",borderRadius:"var(--radius-sm)",cursor:"pointer",display:"flex",zIndex:2},children:r(U,{style:{color:"white",width:16,height:16}})}),!t.uploaded&&r("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:4,background:"rgba(0,0,0,0.7)",textAlign:"center",pointerEvents:"none"},children:r(m,{variant:"muted",level:"small",style:{color:"white"},children:l("image.upload.pending")})})]})})}const L=pe(({name:t="image",label:h,value:v,onChange:S,error:f,helperText:l,multiple:n=!1,maxFiles:k=10,maxSize:I=10*1024*1024,storagePath:d,required:D,capture:y,processing:c},p)=>{const{t:b}=ve("crud"),i=ge(null),[N,F]=j(!1),[B,E]=j(0),M=te(A(ee,{activationConstraint:{distance:8}}),A(re,{activationConstraint:{delay:200,tolerance:5}})),V=P(async(e,a)=>{const{fullBlob:u,thumbBlob:x}=await ye(e,c);return be(u,x,e.name,{storagePath:d,onProgress:w=>a(w.progress)})},[d,c]),{files:o,addFiles:R,removeFile:T,reorderFiles:z}=fe({name:t,value:v,onChange:S,multiple:n,maxFiles:k,maxSize:I,accept:we,storagePath:d,uploadFn:V}),q=e=>{const a=Array.from(e.target.files||[]);a.length>0&&R(a),i.current&&(i.current.value="")},G=P(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files.length>0&&R(Array.from(e.dataTransfer.files))},[R]),H=P(e=>{const{active:a,over:u}=e;if(u&&a.id!==u.id){const x=o.findIndex(g=>g.id===a.id),w=o.findIndex(g=>g.id===u.id);if(x!==-1&&w!==-1){const g=ne(o.map(Y=>Y.id),x,w);z(g)}}},[o,z]),K=e=>{E(e),F(!0)},O=(e,a)=>{},W=e=>{const a=o[e];a&&T(a.id)},X=e=>{E(e)},$=n||o.length===0;ue(p,()=>({upload:async()=>{},focus:()=>i.current?.focus()}),[]);const J=o.map(Ce);return s(C,{gap:"tight",children:[s(m,{level:"body",textAlign:"start",children:[h,D&&"*"]}),$&&s("div",{role:"button",tabIndex:0,onClick:()=>i.current?.click(),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&i.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:G,style:{border:`var(--border-width) dashed ${f?"var(--destructive)":"var(--border)"}`,borderRadius:"var(--radius-lg)",padding:"var(--gap-lg)",backgroundColor:"var(--surface)",cursor:"pointer",textAlign:"center"},children:[r("input",{ref:i,type:"file",accept:"image/*",capture:y,multiple:n,style:{display:"none"},onChange:q}),s(C,{align:"center",children:[r(le,{style:{color:"var(--muted-foreground)"}}),r(m,{variant:"muted",level:"small",children:b(n?"image.upload.dropzoneMultiple":"image.upload.dropzoneSingle")})]})]}),o.length>0&&r(_,{sensors:M,collisionDetection:Q,onDragEnd:H,children:r(ae,{items:o.map(e=>e.id),strategy:oe,children:r("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-md)"},children:o.map((e,a)=>r(Se,{file:e,index:a,multiple:n,onImageClick:K,onRemove:T,t:b},e.id))})})}),l&&r(m,{variant:f?"destructive":"muted",level:"small",children:l}),r(xe,{images:J,selectedIndex:B,open:N,onClose:()=>F(!1),onUpdate:O,onDelete:W,onNavigate:X,multiple:n})]})});L.displayName="ImageFieldComponent";var ke=L;export{ke as default};
|