@donotdev/crud 0.1.1 → 0.1.43
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/LICENSE.md +21 -242
- package/README.md +0 -0
- package/dist/CrudService.bulk.d.ts +57 -0
- package/dist/CrudService.bulk.d.ts.map +1 -0
- package/dist/CrudService.bulk.js +1 -0
- package/dist/CrudService.bulkAcross.d.ts +23 -0
- package/dist/CrudService.bulkAcross.d.ts.map +1 -0
- package/dist/CrudService.bulkAcross.js +1 -0
- package/dist/CrudService.cache.d.ts +45 -0
- package/dist/CrudService.cache.d.ts.map +1 -0
- package/dist/CrudService.cache.js +1 -0
- package/dist/CrudService.d.ts +133 -98
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.internal.d.ts +80 -0
- package/dist/CrudService.internal.d.ts.map +1 -0
- package/dist/CrudService.internal.js +9 -0
- package/dist/CrudService.js +1 -9
- package/dist/CrudService.mutations.d.ts +7 -0
- package/dist/CrudService.mutations.d.ts.map +1 -0
- package/dist/CrudService.mutations.js +1 -0
- package/dist/CrudService.optimistic.d.ts +10 -0
- package/dist/CrudService.optimistic.d.ts.map +1 -0
- package/dist/CrudService.optimistic.js +1 -0
- package/dist/CrudService.queries.d.ts +27 -0
- package/dist/CrudService.queries.d.ts.map +1 -0
- package/dist/CrudService.queries.js +1 -0
- package/dist/CrudService.subscriptions.d.ts +17 -0
- package/dist/CrudService.subscriptions.d.ts.map +1 -0
- package/dist/CrudService.subscriptions.js +1 -0
- package/dist/CrudStore.d.ts.map +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.js +1 -1
- package/dist/adapters/FunctionsAdapter.d.ts +54 -17
- package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/CrudCard.d.ts.map +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.d.ts +1 -1
- package/dist/components/DateFilter.d.ts.map +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/DisplayFieldRenderer.d.ts +1 -1
- package/dist/components/DisplayFieldRenderer.js +1 -1
- package/dist/components/DisplayThumbnail.js +1 -1
- package/dist/components/EntityFilters.d.ts +6 -4
- package/dist/components/EntityFilters.d.ts.map +1 -1
- package/dist/components/EntityFilters.js +1 -1
- 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.d.ts +26 -0
- package/dist/components/YearFilter.d.ts.map +1 -0
- package/dist/components/YearFilter.js +1 -0
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
- package/dist/components/controlled/complex/ControlledMapField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
- package/dist/components/controlled/complex/index.js +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
- package/dist/components/controlled/file/index.js +1 -1
- package/dist/components/controlled/index.js +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
- package/dist/components/controlled/input/ControlledDurationField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
- package/dist/components/controlled/input/ControlledNumberField.js +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
- package/dist/components/controlled/input/ControlledPriceField.js +1 -1
- package/dist/components/controlled/input/ControlledRangeField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
- package/dist/components/controlled/input/ControlledTextField.js +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
- package/dist/components/controlled/input/index.js +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledRadioField.d.ts.map +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 +2 -0
- 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.d.ts.map +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.d.ts.map +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.d.ts.map +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.d.ts +5 -11
- package/dist/components/form/fields/DocumentFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/DurationFieldComponent.js +1 -1
- package/dist/components/form/fields/FileFieldComponent.d.ts +5 -11
- package/dist/components/form/fields/FileFieldComponent.d.ts.map +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 +1 -1
- 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.d.ts.map +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/PriceFieldComponent.d.ts +1 -1
- package/dist/components/form/fields/PriceFieldComponent.d.ts.map +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.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/contexts/index.js +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/fieldTypeRegistry.store.js +1 -1
- package/dist/forms/hooks/index.js +1 -1
- package/dist/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityField.d.ts +2 -2
- package/dist/forms/hooks/useEntityField.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityField.js +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts +4 -4
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/index.d.ts +1 -1
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/types.d.ts +26 -14
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.d.ts +3 -3
- package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/getFieldsForOperation.d.ts +3 -3
- package/dist/forms/utils/getFieldsForOperation.d.ts.map +1 -1
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/index.js +1 -1
- package/dist/forms/utils/isFieldEditable.d.ts +6 -6
- package/dist/forms/utils/isFieldEditable.d.ts.map +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/translateFieldLabel.js +1 -1
- package/dist/forms/utils/validateEntity.d.ts +2 -2
- package/dist/forms/utils/validateEntity.d.ts.map +1 -1
- package/dist/forms/utils/validateEntity.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useCrudFilters.d.ts.map +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useCrudPageSize.d.ts.map +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.d.ts +18 -33
- package/dist/hooks/useFileUpload.d.ts.map +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useReferenceResolver.d.ts +2 -2
- package/dist/hooks/useReferenceResolver.d.ts.map +1 -1
- package/dist/hooks/useReferenceResolver.js +1 -1
- package/dist/hooks/useRelatedItems.d.ts +2 -2
- package/dist/hooks/useRelatedItems.d.ts.map +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/index.d.ts +4 -4
- 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.d.ts +32 -3
- package/dist/stores/FormStore.d.ts.map +1 -1
- package/dist/stores/FormStore.js +1 -1
- package/dist/stores/UploadStore.d.ts +65 -0
- package/dist/stores/UploadStore.d.ts.map +1 -1
- package/dist/stores/UploadStore.js +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.d.ts.map +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 +40 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/useBaseCrudList.d.ts +2 -2
- package/dist/useBaseCrudList.d.ts.map +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.d.ts +54 -7
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.d.ts +4 -3
- package/dist/useCrudCardList.d.ts.map +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.d.ts +4 -3
- package/dist/useCrudList.d.ts.map +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/clientListProcessing.d.ts +4 -4
- package/dist/utils/clientListProcessing.d.ts.map +1 -1
- package/dist/utils/clientListProcessing.js +1 -1
- package/dist/utils/collections.d.ts +4 -4
- package/dist/utils/collections.d.ts.map +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.d.ts +1 -1
- package/dist/utils/fileStorage.d.ts.map +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/imageProcessing.d.ts.map +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.d.ts +1 -1
- package/dist/utils/imageStorage.d.ts.map +1 -1
- package/dist/utils/imageStorage.js +1 -1
- package/dist/utils/imageUtils.js +1 -1
- package/dist/utils/matchesFilter.js +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- 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.d.ts +2 -2
- package/dist/workflows/defineWorkflow.d.ts.map +1 -1
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/guidelines/COMPONENTS.md +0 -0
- package/guidelines/CRUD.md +64 -1
- package/guidelines/GOTCHAS.md +0 -0
- package/package.json +7 -6
- package/dist/hooks/useUnsavedChangesWarning.d.ts +0 -29
- package/dist/hooks/useUnsavedChangesWarning.d.ts.map +0 -1
- package/dist/hooks/useUnsavedChangesWarning.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PriceFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/PriceFieldComponent.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"PriceFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/PriceFieldComponent.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0GAA0G;IAC1G,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAYD,QAAA,MAAM,mBAAmB,EAAE,aAAa,CAAC,wBAAwB,CAwMhE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{CirclePlus as R,CircleMinus as U}from"lucide-react";import{useId as q,useState as z}from"react";import{Input as C,Checkbox as D,Stack as E,Select as A,CollapsiblePrimitive as B,CollapsibleTrigger as G,CollapsibleContent as H}from"@donotdev/components";import{useTranslation as J,getCurrencySymbol as L}from"@donotdev/core";const O=["EUR","USD","GBP","CHF","JPY","KRW"],Y=({label:f,value:n,onChange:I,error:s,helperText:g,required:P=!1,disabled:c=!1,placeholder:N="0",defaultCurrency:d="EUR",optionsTitle:x="Price options",currencies:b})=>{const u=q(),{t:p}=J("crud"),r=b?.length?b:[...O],h=n?.currency??d,m=r.includes(h)?h:r[0]??d,T=n?.vatIncluded??!0,y=n?.discountPercent??0,S=`${f} (${L(m)})`,i=e=>{const l=e.amount!==void 0?e.amount:n?.amount??null;let t=e.currency!==void 0?e.currency:n?.currency??d;r.includes(t)||(t=m);const F=e.vatIncluded!==void 0?e.vatIncluded:n?.vatIncluded??!0,M=e.discountPercent!==void 0?e.discountPercent:n?.discountPercent??0;I({amount:l===null?null:Number(l),currency:t,vatIncluded:F,discountPercent:Number(M)})},k=e=>{const l=e.target.value;if(l===""||l===null){i({amount:null});return}const t=parseFloat(l);i({amount:isNaN(t)?null:t})},V=e=>{i({currency:e||d})},$=e=>{const l=e.target.value;if(l===""||l===null){i({discountPercent:0});return}const t=parseFloat(l);i({discountPercent:isNaN(t)?0:t})},[v,j]=z(!1);return o(B,{open:v,onOpenChange:j,children:[o(E,{children:[o("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"var(--gap-sm)",alignItems:"end"},children:[a(C,{id:u,type:"number",inputMode:"decimal",label:S,value:n?.amount!==void 0&&n?.amount!==null?n.amount:"",onChange:k,disabled:c,placeholder:N,required:P,min:0,step:.01,"data-variant":s?"destructive":void 0,"aria-invalid":s}),a(G,{asChild:!0,children:a("button",{type:"button","aria-label":x,"aria-expanded":v,className:"dndev-collapsible-trigger",style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"var(--gap-sm)",background:"none",border:"none",cursor:"pointer"},children:v?a(U,{className:"dndev-collapsible-icon","aria-hidden":"true"}):a(R,{className:"dndev-collapsible-icon","aria-hidden":"true"})})})]}),a(H,{className:"dndev-collapsible-content",children:o("div",{style:{display:"grid",gridTemplateColumns:r.length>1?"1fr auto 1fr":"auto 1fr",gap:"var(--gap-sm)",alignItems:"end",paddingTop:"var(--gap-md)"},children:[r.length>1&&a(A,{value:m,onValueChange:V,placeholder:d,options:r.map(e=>({value:e,label:e})),disabled:c,label:p("price.currency",{defaultValue:"Currency"})}),a(D,{id:`${u}-vat`,label:p("price.vatIncluded",{defaultValue:"VAT Incl."}),checked:T,onCheckedChange:e=>i({vatIncluded:e===!0}),disabled:c}),a(C,{id:`${u}-discount`,type:"number",inputMode:"decimal",min:0,max:100,step:1,value:y===0?"":y,onChange:$,disabled:c,placeholder:"0",label:p("price.discountLabel",{defaultValue:"Discount (%)"})})]})})]}),g&&a("p",{style:{fontSize:"var(--font-size-xs)",color:s?"var(--destructive-foreground)":"var(--muted-foreground)"},children:g})]})};var w=Y;export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as d}from"react/jsx-runtime";import{RadioGroup as f,Label as p,Stack as c}from"@donotdev/components";const v=({label:t,value:o,onChange:a,options:s,error:i,helperText:r,required:n})=>{const l=u=>{a({target:{value:u}})};return d(c,{gap:"tight",children:[e(p,{required:n,style:{display:"block",fontSize:"var(--font-size-input)",fontWeight:500},children:t}),e(f,{value:o,onValueChange:l,items:s}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:i?"var(--destructive-foreground)":"var(--muted-foreground)"},children:r})]})};var h=v;export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Label as h,Slider as b,Stack as d}from"@donotdev/components";const x=({label:o,value:i=0,onChange:u,error:n,helperText:s,min:r=0,max:c=100,step:v=1,disabled:a,required:m,showValue:f=!0})=>{const g=t=>{const p={target:{value:t.toString()}};u(p)};return l(d,{gap:"tight",children:[l(d,{direction:"row",justify:"between",align:"center",children:[e(h,{required:m,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:o}),f&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:i})]}),e(b,{value:[i??r],onValueChange:([t])=>g(t??r),min:r,max:c,step:v,disabled:a,style:{borderColor:n?"var(--destructive)":void 0,opacity:a?"var(--opacity-muted)":void 0,cursor:a?"not-allowed":void 0},"aria-label":o}),s&&e("p",{style:{fontSize:"var(--font-size-xs)",color:n?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:s})]})};var y=x;export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as
|
|
1
|
+
import{jsx as e,jsxs as g}from"react/jsx-runtime";import{Label as h,Rating as m,Stack as u}from"@donotdev/components";const v=({label:a,value:o=0,onChange:s,error:l,helperText:r,max:t=5,disabled:i,required:n,readonly:d,showValue:f=!1})=>g(u,{gap:"tight",children:[e(h,{required:n,style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:a}),e(m,{value:o,onChange:s,max:t,disabled:i,readonly:d,showValue:f,"aria-label":a}),r&&e("p",{style:{fontSize:"var(--font-size-xs)",color:l?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:r})]});var p=v;export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as S,useId as A}from"react";import{Combobox as $,Stack as c}from"@donotdev/components";import{useTranslation as j}from"@donotdev/core";const q=({label:r,value:s,onChange:p,options:i,isLoading:u=!1,error:f,helperText:o,required:h,onBlur:m,onCreate:I,placeholder:g})=>{const{t:l}=j("crud"),n=A(),v=S(()=>i.map(e=>({value:e.id,label:e.label,description:e.description})),[i]),b=e=>{const z=Array.isArray(e)?e[0]||"":e;p(z)},x=e=>{e||m?.()},a=!!f,y=`${n}-error`,C=`${n}-helper`;return d(c,{gap:"tight",children:[t($,{label:r,value:s||"",onValueChange:b,onOpenChange:x,placeholder:g||l("reference.placeholder",{label:r})||`Select ${r}`,emptyMessage:l("reference.noResults")||"No results found",options:v,required:h,variant:a?"destructive":void 0,isLoading:u,clearable:!!s}),a&&d(c,{id:y,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),o]}),o&&!a&&t("p",{id:C,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var L=q;export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import n from"./TextAreaComponent";const p=m(()=>typeof window<"u"?import("./internal/TiptapEditor").catch(()=>({default:()=>null})):Promise.resolve({default:()=>null})),x=({label:l,value:a="",onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})=>{const[c,h]=f(!1);return g(()=>{h(!0)},[]),c?e(v,{gap:"tight",children:e(b,{fallback:e(n,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u}),children:p?e(p,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u}):e(n,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})})}):e(n,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})};var C=x;export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{Switch as k,Text as l,Stack as n}from"@donotdev/components";const p=({label:a,checked:d=!1,onChange:t,uncheckedLabel:h,checkedLabel:s,helperText:c})=>{const i=o=>{t&&t({target:{checked:o}})};return e(n,{gap:"tight",children:[e(n,{direction:"row",align:"center",style:{flexWrap:"wrap"},children:[e(l,{level:"body",textAlign:"start",children:[a,":"]}),r(k,{checked:d,onCheckedChange:i,"aria-label":a,variant:"muted",uncheckedLabel:h,checkedLabel:s})]}),c&&r(l,{as:"p",variant:"muted",level:"small",children:c})]})};var g=p;export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as L,useId as N,useRef as F,useEffect as j}from"react";import{Textarea as q,FloatingLabel as A,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,value:o="",onChange:b,error:h,helperText:s,rows:y=3,loading:l=!1,maxLength:r,showCharCount:v=!1,autoResize:i=!1,required:z=!1,disabled:g=!1,className:w,...S})=>{const e=N(),[I,f]=L(!1),d=F(null),a=!!h,c=o.length,$=r&&c>r*.8,C=r&&c>r;return j(()=>{if(i&&d.current){const u=d.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[o,i]),n(p,{gap:"tight",children:[t(A,{htmlFor:e,label:x,disabled:g||l,required:z,children:n("div",{className:"dndev-relative",children:[t(q,{ref:d,id:e,value:o,onChange:b,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||l,maxLength:r,rows:i?1:y,bare:!0,"aria-describedby":m(a&&`${e}-error`,s&&!a&&`${e}-helper`,v&&`${e}-count`),"aria-invalid":a,className:m("dndev-w-full",i&&"dndev-overflow-hidden",w),"data-variant":a?"destructive":void 0,style:{resize:i?"none":void 0},...S}),l&&t("div",{className:"dndev-absolute",style:{right:"var(--gap-md)",top:"var(--gap-md)"},children:t(k,{"aria-label":"Loading"})})]})}),v&&r&&n("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:C?"var(--destructive-foreground)":$?"var(--warning)":"var(--muted-foreground)"},children:[c,"/",r]}),a&&n(p,{as:"p",id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),h]}),s&&!a&&t("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:s})]})};var E=B;export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n,jsxs as o}from"react/jsx-runtime";import{useId as C}from"react";import{Input as S,cn as c,Stack as u}from"@donotdev/components";function j({label:h,value:d="",onChange:v,error:l,helperText:a,type:f="text",loading:g=!1,maxLength:r,showCharCount:s=!1,required:p=!1,disabled:m=!1,className:x,ref:z,...$}){const e=C(),t=!!l,i=d.length,b=r&&i>r*.8,y=r&&i>r,{children:A,...w}=$;return o(u,{gap:"tight",children:[n(S,{ref:z,id:e,type:f,value:d,onChange:v,label:h,disabled:m||g,maxLength:r,required:p,"aria-describedby":c(t&&`${e}-error`,a&&!t&&`${e}-helper`,s&&`${e}-count`),"aria-invalid":t,className:c("dndev-w-full",x),"data-variant":t?"destructive":void 0,...w}),s&&r&&o("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:y?"var(--destructive-foreground)":b?"var(--warning)":"var(--muted-foreground)"},children:[i,"/",r]}),t&&o(u,{id:`${e}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[n("span",{children:"\u26A0"}),l]}),a&&!t&&n("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})}var q=j;export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import d from"./DateFieldComponent";const g=({label:a,value:e,onChange:r,error:o,helperText:l,mode:n="datetime-local",required:u})=>{const i=e?new Date(e).toISOString():"";return s(d,{label:a,value:i,onChange:t=>{if(t){const m={target:{value:new Date(t).toISOString()}};r(m)}else r({target:{value:""}})},error:o,helperText:l,mode:n,required:u})};var p=g;export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as
|
|
1
|
+
import{default as o}from"./AvatarFieldComponent";import{default as t}from"./BadgeFieldComponent";import{default as e}from"./TextFieldComponent";import{default as a}from"./NumberFieldComponent";import{default as m}from"./DateFieldComponent";import{default as r}from"./CheckboxFieldComponent";import{default as n}from"./ComboboxComponent";import{default as p}from"./DropdownComponent";import{default as s}from"./MultiDropdownComponent";import{default as i}from"./FileFieldComponent";import{default as d}from"./ImageFieldComponent";import{default as f}from"./DocumentFieldComponent";import{default as l}from"./TextAreaComponent";import{default as u}from"./SwitchFieldComponent";import{default as C}from"./RadioFieldComponent";import{default as F}from"./RangeFieldComponent";import{default as T}from"./RatingFieldComponent";import{default as R}from"./DurationFieldComponent";import{DURATION_PRESETS as x}from"./DurationFieldComponent";import{default as D}from"./PhoneNumberComponent";import{default as c}from"./GeoPointFieldComponent";import{default as P}from"./MapFieldComponent";import{default as b}from"./TimestampFieldComponent";import{default as A}from"./MultiInputTextFieldComponent";import{default as S}from"./ButtonFieldComponent";import{default as g}from"./HiddenFieldComponent";import{default as h}from"./PasswordFieldComponent";import{default as w}from"./AddressFieldComponent";import{default as E}from"./CurrencyFieldComponent";import{default as I}from"./PriceFieldComponent";import{default as N}from"./RichTextComponent";import{default as M}from"./GdprConsentFieldComponent";export{w as AddressFieldComponent,o as AvatarFieldComponent,t as BadgeFieldComponent,S as ButtonFieldComponent,r as CheckboxFieldComponent,n as ComboboxComponent,E as CurrencyFieldComponent,x as DURATION_PRESETS,m as DateFieldComponent,f as DocumentFieldComponent,p as DropdownComponent,R as DurationFieldComponent,i as FileFieldComponent,M as GdprConsentFieldComponent,c as GeoPointFieldComponent,g as HiddenFieldComponent,d as ImageFieldComponent,P as MapFieldComponent,s as MultiDropdownComponent,A as MultiInputTextFieldComponent,a as NumberFieldComponent,h as PasswordFieldComponent,D as PhoneNumberComponent,I as PriceFieldComponent,C as RadioFieldComponent,F as RangeFieldComponent,T as RatingFieldComponent,N as RichTextComponent,u as SwitchFieldComponent,l as TextAreaComponent,e as TextFieldComponent,b as TimestampFieldComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as
|
|
1
|
+
"use client";import{jsx as i,jsxs as m}from"react/jsx-runtime";import{useEffect as u,useState as f}from"react";import{Stack as M}from"@donotdev/components";const x=({label:s,value:r="",onChange:d,error:e,helperText:n,required:o,disabled:a,placeholder:l,className:c,modules:g})=>{const{useEditor:v,EditorContent:p,StarterKit:h,Placeholder:b}=g,t=v({extensions:[h.configure({heading:{levels:[1,2,3]}}),b.configure({placeholder:l||"Start typing..."})],content:r,editable:!a,onUpdate:({editor:P})=>{const y={target:{value:P.getHTML()}};d(y)}});return u(()=>{t&&r!==t.getHTML()&&t.commands.setContent(r||"")},[r,t]),t?m(M,{gap:"tight",children:[m("label",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:e?"var(--destructive-foreground)":"var(--foreground)"},children:[s,o&&i("span",{style:{color:"var(--destructive)"},children:" *"})]}),i("div",{className:c,"data-variant":e?"destructive":void 0,style:{border:"var(--border-hairline) solid",borderColor:e?"var(--destructive)":"var(--line-2)",borderRadius:"var(--radius-interactive)",padding:"var(--gap-md)",minHeight:"200px",backgroundColor:a?"var(--muted)":"transparent",opacity:a?"var(--opacity-muted)":void 0},children:i(p,{editor:t})}),n&&i("p",{style:{fontSize:"var(--font-size-xs)",color:e?"var(--destructive-foreground)":"var(--muted-foreground)"},children:n}),i("style",{children:`
|
|
2
2
|
.ProseMirror {
|
|
3
3
|
outline: none;
|
|
4
4
|
min-height: 150px;
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
margin: 0.5em 0;
|
|
50
50
|
color: var(--muted-foreground);
|
|
51
51
|
}
|
|
52
|
-
`})]}):null},
|
|
52
|
+
`})]}):null},z=s=>{const[r,d]=f(null),[e,n]=f(!1);return u(()=>{r||e||(async()=>{try{const[{useEditor:o,EditorContent:a},l,c]=await Promise.all([import("@tiptap/react"),import("@tiptap/starter-kit"),import("@tiptap/extension-placeholder")]);d({useEditor:o,EditorContent:a,StarterKit:l.default,Placeholder:c.default})}catch(o){o instanceof Error&&(o.message.includes("Cannot find module '@tiptap")||o.message.includes("Failed to fetch dynamically imported module")),n(!0)}})()},[r,e]),e||!r?null:i(x,{...s,modules:r})};var C=z;export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as re,jsxs as
|
|
1
|
+
"use client";import{jsx as e,Fragment as re,jsxs as a}from"react/jsx-runtime";import{ChevronLeft as ne,ChevronRight as le,RotateCcw as M,RotateCw as B,Trash2 as de,Check as ce,Undo2 as se,ZoomIn as ge,ZoomOut as me,Maximize2 as pe,Grid3X3 as he}from"lucide-react";import{useCallback as g,useEffect as H,useState as c,useRef as ue}from"react";import ve from"react-easy-crop";import{Button as o,BUTTON_VARIANT as r,Sheet as fe,Stack as l,Text as u,Slider as F,ToggleGroup as ye}from"@donotdev/components";import{useTranslation as we}from"@donotdev/core";import{processImage as Ce}from"../../../utils/imageProcessing";import{createPreviewURL as be,revokePreviewURL as ke}from"../../../utils/imageUtils";const xe={free:void 0,"1:1":1,"4:3":4/3,"16:9":16/9,"3:2":3/2};function Y({images:h,selectedIndex:n,open:T,onClose:U,onUpdate:Z,onDelete:E,onNavigate:m,multiple:L=!1}){const{t}=we("crud"),[D,C]=c({x:0,y:0}),[v,p]=c(1),[b,f]=c(0),[N,$]=c(null),[S,z]=c("free"),[k,q]=c(!0),[y,w]=c(!1),[A,G]=c(!1),[X,x]=c(!1),I=ue({crop:{x:0,y:0},zoom:1,rotation:0}),d=h[n],R=L&&n>0,O=L&&n<h.length-1;H(()=>{if(d){const i={x:0,y:0};C(i),p(1),f(d.rotation*90),z("free"),w(!1),x(!1),I.current={crop:i,zoom:1,rotation:d.rotation*90}}},[d]);const _=g((i,s)=>{$(s)},[]),J=g(()=>{C(I.current.crop),p(I.current.zoom),f(I.current.rotation)},[]),P=g(()=>{f(i=>(i-90+360)%360)},[]),V=g(()=>{f(i=>(i+90)%360)},[]),K=g(()=>{p(i=>Math.min(i+.25,3))},[]),Q=g(()=>{p(i=>Math.max(i-.25,1))},[]),ee=g(()=>{p(1),C({x:0,y:0})},[]),ie=async()=>{if(!(!d||!N)){G(!0);try{const i=await Ce(d.file,{crop:N,maxWidth:2048,maxHeight:2048,quality:.95}),s=new File([i.fullBlob],d.file.name,{type:"image/webp"}),oe=be(s);d.previewURL.startsWith("blob:")&&ke(d.previewURL),Z(n,{file:s,previewURL:oe,uploaded:null,uploadProgress:null,error:null,rotation:0}),w(!1)}catch{}finally{G(!1)}}},te=g(()=>{E(n),x(!1),h.length===1?U():n>=h.length-1&&m(n-1)},[n,h.length,E,U,m]);if(H(()=>{if(!T)return;const i=s=>{s.key==="ArrowLeft"&&R?m(n-1):s.key==="ArrowRight"&&O?m(n+1):s.key==="Escape"&&y&&w(!1)};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[T,R,O,n,m,y]),!d)return null;const W=d.uploadProgress!==null&&d.uploadProgress<100,j=d.uploaded?.fullUrl||d.previewURL,ae=L?t("image.editor.titleWithIndex",{current:n+1,total:h.length}):t("image.editor.title");return e(fe,{open:T,onOpenChange:i=>!i&&U(),side:"right",title:ae,description:t("image.editor.description"),noSwipe:y,children:a(l,{gap:"large",style:{height:"100%"},children:[e("div",{style:{position:"relative",flex:1,minHeight:300,backgroundColor:"var(--surface-muted)",borderRadius:"var(--radius-lg)",overflow:"hidden"},children:y?e(ve,{image:j,crop:D,zoom:v,rotation:b,aspect:xe[S],onCropChange:C,onCropComplete:_,onZoomChange:p,showGrid:k,style:{containerStyle:{position:"absolute",top:0,left:0,right:0,bottom:0},cropAreaStyle:{border:"2px solid var(--primary)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.5)"}}}):a(re,{children:[R&&e(o,{variant:r.GHOST,icon:ne,onClick:()=>m(n-1),"aria-label":t("image.editor.previousImage"),style:{position:"absolute",left:"var(--gap-sm)",top:"50%",transform:"translateY(-50%)",zIndex:10,backgroundColor:"rgba(0,0,0,0.3)",color:"white"}}),e("img",{src:j,alt:`Image ${n+1}`,style:{width:"100%",height:"100%",objectFit:"contain",transform:`rotate(${b}deg)`,transition:"transform var(--dur-normal) var(--ease-out)"}}),O&&e(o,{variant:r.GHOST,icon:le,onClick:()=>m(n+1),"aria-label":t("image.editor.nextImage"),style:{position:"absolute",right:"var(--gap-sm)",top:"50%",transform:"translateY(-50%)",zIndex:10,backgroundColor:"rgba(0,0,0,0.3)",color:"white"}})]})}),y?a(l,{children:[a(l,{gap:"tight",children:[e(u,{level:"small",variant:"muted",children:t("image.editor.aspectRatio")}),e(ye,{type:"single",value:S,onValueChange:i=>i&&z(i),items:[{value:"free",label:t("image.editor.aspectFree")},{value:"1:1",label:"1:1"},{value:"4:3",label:"4:3"},{value:"16:9",label:"16:9"}]})]}),a(l,{gap:"tight",children:[a(l,{direction:"row",justify:"between",align:"center",children:[e(u,{level:"small",variant:"muted",children:t("image.editor.zoom")}),a(u,{level:"small",variant:"muted",children:[Math.round(v*100),"%"]})]}),a(l,{direction:"row",gap:"tight",align:"center",children:[e(o,{variant:r.OUTLINE,icon:me,display:"compact",onClick:Q,disabled:v<=1}),e(F,{value:[v],min:1,max:3,step:.05,onValueChange:i=>p(i[0]??1),style:{flex:1}}),e(o,{variant:r.OUTLINE,icon:ge,display:"compact",onClick:K,disabled:v>=3})]})]}),a(l,{gap:"tight",children:[a(l,{direction:"row",justify:"between",align:"center",children:[e(u,{level:"small",variant:"muted",children:t("image.editor.rotation")}),a(u,{level:"small",variant:"muted",children:[b,"\xB0"]})]}),a(l,{direction:"row",gap:"tight",align:"center",children:[e(o,{variant:r.OUTLINE,icon:M,display:"compact",onClick:P,tooltip:t("image.editor.rotateLeft")}),e(F,{value:[b],min:0,max:360,step:1,onValueChange:i=>f(i[0]??0),style:{flex:1}}),e(o,{variant:r.OUTLINE,icon:B,display:"compact",onClick:V,tooltip:t("image.editor.rotateRight")})]})]}),a(l,{direction:"row",gap:"tight",children:[e(o,{variant:r.OUTLINE,icon:pe,display:"compact",onClick:ee,tooltip:t("image.editor.fitToView")}),e(o,{variant:r.OUTLINE,icon:he,display:"compact",onClick:()=>q(!k),tooltip:t(k?"image.editor.hideGrid":"image.editor.showGrid"),"data-active":k||void 0}),e(o,{variant:r.OUTLINE,icon:se,display:"compact",onClick:J,tooltip:t("image.editor.reset")})]}),a(l,{direction:"row",style:{marginTop:"var(--gap-md)"},children:[e(o,{variant:r.OUTLINE,onClick:()=>w(!1),fullWidth:!0,children:t("image.editor.cancel")}),e(o,{variant:r.PRIMARY,icon:ce,onClick:ie,disabled:A,fullWidth:!0,children:t(A?"image.editor.processing":"image.editor.apply")})]})]}):a(l,{children:[a(l,{direction:"row",gap:"tight",justify:"center",children:[e(o,{variant:r.OUTLINE,icon:M,display:"compact",onClick:P,tooltip:t("image.editor.rotateLeft")}),e(o,{variant:r.PRIMARY,onClick:()=>w(!0),disabled:W,children:t("image.editor.editButton")}),e(o,{variant:r.OUTLINE,icon:B,display:"compact",onClick:V,tooltip:t("image.editor.rotateRight")})]}),X?a(l,{style:{border:"1px solid var(--destructive)",padding:"var(--gap-md)",borderRadius:"var(--radius-md)"},children:[e(u,{variant:"destructive",level:"small",textAlign:"center",children:t("image.editor.deleteConfirm")}),a(l,{direction:"row",gap:"tight",children:[e(o,{variant:r.OUTLINE,onClick:()=>x(!1),fullWidth:!0,children:t("image.editor.cancel")}),e(o,{variant:r.DESTRUCTIVE,onClick:te,fullWidth:!0,children:t("actions.delete")})]})]}):e(o,{variant:r.GHOST,icon:de,onClick:()=>x(!0),disabled:W,style:{color:"var(--destructive)"},children:t("image.editor.deleteImage")})]})]})})}var Ie=Y;export{Y as ImageViewerDialog,Ie as default};
|
|
@@ -17,6 +17,8 @@ export * from './form';
|
|
|
17
17
|
export { EntityFilters } from './EntityFilters';
|
|
18
18
|
export { matchesFilter } from '../utils/matchesFilter';
|
|
19
19
|
export type { EntityFiltersProps } from './EntityFilters';
|
|
20
|
+
export { YearFilter } from './YearFilter';
|
|
21
|
+
export type { YearFilterValue, YearFilterProps } from './YearFilter';
|
|
20
22
|
export * from './fields/display';
|
|
21
23
|
export { DisplayThumbnail } from './DisplayThumbnail';
|
|
22
24
|
export { CrudCard } from './CrudCard';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as
|
|
1
|
+
import{default as r}from"./CrudButton";import{FormFieldRenderer as a}from"./FormFieldRenderer";import{DisplayFieldRenderer as e,formatValue as o}from"./DisplayFieldRenderer";import{default as t}from"./FormLayout";export*from"./controlled";export*from"./form";import{EntityFilters as m}from"./EntityFilters";import{matchesFilter as s}from"../utils/matchesFilter";import{YearFilter as i}from"./YearFilter";export*from"./fields/display";import{DisplayThumbnail as l}from"./DisplayThumbnail";import{CrudCard as p}from"./CrudCard";export{r as CrudButton,p as CrudCard,e as DisplayFieldRenderer,l as DisplayThumbnail,m as EntityFilters,a as FormFieldRenderer,t as FormLayout,i as YearFilter,o as formatValue,s as matchesFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{createContext as n,useContext as i}from"react";const e=n(void 0);function s({formId:o,children:r}){return t(e.Provider,{value:o,children:r})}function a(){return i(e)}export{s as UploadProvider,a as useUploadContext};
|
package/dist/contexts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UploadProvider as
|
|
1
|
+
import{UploadProvider as o,useUploadContext as a}from"./UploadContext";export{o as UploadProvider,a as useUploadContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{getFieldRegistry as
|
|
1
|
+
"use client";import{getFieldRegistry as i}from"./FieldRegistry";import{registerAllBuiltinFieldTypes as s}from"./registerBuiltinFieldTypes";import{setRegistrationInit as r,getMetadataRegistry as l}from"./fieldTypeRegistry.store";r(e=>{s(e,i())});import{getFieldTypeMetadata as o,getFilterType as p,getDisplayFormatter as g,isFilterable as y,getValueType as n,clearFieldTypeRegistry as F}from"./fieldTypeRegistry.store";function d(e){const{type:a,components:t}=e;t&&i().registerComponent(a,t.controlled,t.uncontrolled),l().set(a,e)}export{F as clearFieldTypeRegistry,g as getDisplayFormatter,o as getFieldTypeMetadata,p as getFilterType,n as getValueType,y as isFilterable,d as registerBuiltinFieldType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{getGlobalSingleton as
|
|
1
|
+
"use client";import{getGlobalSingleton as n}from"@donotdev/core";import{getFieldRegistry as i}from"./FieldRegistry";function r(){return n("field-type-metadata",()=>({registry:new Map,builtinsRegistered:!1,initFn:null}))}function a(t){r().initFn=t}function e(){const t=r();return t.builtinsRegistered||(t.builtinsRegistered=!0,t.initFn?.(t.registry)),t.registry}function s(t){return e().get(t)}function l(t){return i().getFilterType(t)||e().get(t)?.filterType}function g(t){return i().getDisplayFormatter(t)||e().get(t)?.displayFormatter}function u(t){return i().isFilterable(t)?!0:e().get(t)?.filterable??!1}function o(t){return e().get(t)?.valueType}function y(){e().clear()}export{y as clearFieldTypeRegistry,g as getDisplayFormatter,s as getFieldTypeMetadata,l as getFilterType,e as getMetadataRegistry,o as getValueType,u as isFilterable,a as setRegistrationInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEntityForm as
|
|
1
|
+
import{useEntityForm as t}from"./useEntityForm";import{useEntityField as o}from"./useEntityField";import{useController as r}from"./useController";export{r as useController,o as useEntityField,t as useEntityForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useController as
|
|
1
|
+
"use client";import{useController as o}from"react-hook-form";function e(r){return o(r)}export{e as useController};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyEntity } from '@donotdev/core';
|
|
2
2
|
import type { EntityFormReturn, InferEntityData, EntityFieldReturn } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Granular hook for single field control within an entity form.
|
|
@@ -54,5 +54,5 @@ import type { EntityFormReturn, InferEntityData, EntityFieldReturn } from '../ty
|
|
|
54
54
|
* @since 0.0.1
|
|
55
55
|
* @author AMBROISE PARK Consulting
|
|
56
56
|
*/
|
|
57
|
-
export declare function useEntityField<E extends
|
|
57
|
+
export declare function useEntityField<E extends AnyEntity, K extends keyof InferEntityData<E>>(form: EntityFormReturn<E>, fieldName: K): EntityFieldReturn<E, K>;
|
|
58
58
|
//# sourceMappingURL=useEntityField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityField.d.ts","sourceRoot":"","sources":["../../../src/forms/hooks/useEntityField.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useEntityField.d.ts","sourceRoot":"","sources":["../../../src/forms/hooks/useEntityField.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,gBAAgB,CAAC;AAM7D,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,cAAc,CAC5B,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,MAAM,eAAe,CAAC,CAAC,CAAC,EAClC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAkFlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useMemo as o,useCallback as p}from"react";import{useController as v}from"./useController";import{formatValue as h}from"../../components/DisplayFieldRenderer";import{isFieldEditable as
|
|
1
|
+
"use client";import{useMemo as o,useCallback as p}from"react";import{useController as v}from"./useController";import{formatValue as h}from"../../components/DisplayFieldRenderer";import{isFieldEditable as g}from"../utils";function D(s,e){const{entity:b,operation:r,viewerRole:d,fields:u}=s,l=b.fields[e],i=o(()=>l?{...l,name:l.name||e,label:l.label||e}:{name:e,type:"text",label:e,visibility:"user"},[e,l]),a=o(()=>u.some(n=>n.name===e),[u,e]),c=o(()=>!a||r==="edit"&&i.visibility==="technical"&&i.editable===void 0?!1:g(i.editable,d,r),[a,r,i.visibility,i.editable,d]),{field:m,fieldState:t}=v({name:e,control:s.control}),f=o(()=>({error:t.error?.message,touched:t.isTouched,isDirty:t.isDirty}),[t.error?.message,t.isTouched,t.isDirty]),y=p(n=>h(m.value,i,s.t,n),[m.value,i,s.t]);return{field:m,meta:f,config:i,isEditable:c,isVisible:a,display:y}}export{D as useEntityField};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyEntity } from '@donotdev/core';
|
|
2
2
|
import type { UseEntityFormOptions, EntityFormReturn } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a type-safe form instance from an entity definition.
|
|
5
5
|
*
|
|
6
6
|
* Simple, predictable behavior:
|
|
7
|
-
* - Edit mode: defaultValues (DB object) is used as-is, auto-save to
|
|
8
|
-
* - Create mode: starts empty, auto-save to
|
|
7
|
+
* - Edit mode: defaultValues (DB object) is used as-is, auto-save to FormStore
|
|
8
|
+
* - Create mode: starts empty, auto-save to FormStore
|
|
9
9
|
* - Draft restored on mount with dismissible toast
|
|
10
10
|
*
|
|
11
11
|
* When formId is provided:
|
|
@@ -18,5 +18,5 @@ import type { UseEntityFormOptions, EntityFormReturn } from '../types';
|
|
|
18
18
|
* @param options - Form configuration options
|
|
19
19
|
* @returns Form instance with React Hook Form API plus entity-aware extensions
|
|
20
20
|
*/
|
|
21
|
-
export declare function useEntityForm<E extends
|
|
21
|
+
export declare function useEntityForm<E extends AnyEntity>(entity: E, options?: UseEntityFormOptions<E>): EntityFormReturn<E>;
|
|
22
22
|
//# sourceMappingURL=useEntityForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityForm.d.ts","sourceRoot":"","sources":["../../../src/forms/hooks/useEntityForm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEntityForm.d.ts","sourceRoot":"","sources":["../../../src/forms/hooks/useEntityForm.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAWhD,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAuElB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,SAAS,EAC/C,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,oBAAoB,CAAC,CAAC,CAAM,GACpC,gBAAgB,CAAC,CAAC,CAAC,CAuoBrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{valibotResolver as
|
|
1
|
+
"use client";import{valibotResolver as B}from"@hookform/resolvers/valibot";import{useMemo as C,useEffect as O,useRef as y,createElement as ce}from"react";import{useForm as fe}from"react-hook-form";import{toast as G,ToastAction as de}from"@donotdev/components";import{BACKEND_GENERATED_FIELD_NAMES as me,createSchemas as ge}from"@donotdev/core";import{useFormStore as d,useFormStatus as pe,useUploadProgress as be}from"../../stores";import{useUploadStore as w}from"../../stores/UploadStore";import{checkForBlobUrls as Se,isStorageUrl as ye}from"../../utils/uploadValidation";import{getFieldsForOperation as he}from"../utils";import{buildInitialFromRecord as ve,buildSchemaDefaults as Ee}from"../utils/buildInitialValues";const je=t=>t;function K(t,f){const e={...t};for(const b of Object.keys(f)){const l=t[b],h=f[b];h!==null&&typeof h=="object"&&!Array.isArray(h)&&l!==null&&typeof l=="object"&&!Array.isArray(l)?e[b]=K(l,h):e[b]=h}return e}function L(t){if(t==null)return t;if(typeof t=="string")return t.startsWith("blob:")?null:t;if(Array.isArray(t)){const f=t.map(L).filter(e=>e!==null);return f.length>0?f:null}if(typeof t=="object"){const f=t;if("fullUrl"in f&&typeof f.fullUrl=="string")return ye(f.fullUrl)?f:null;const e={};for(const[b,l]of Object.entries(f))e[b]=L(l);return e}return t}function De(t,f={}){const{formId:e,operation:b,defaultValues:l,viewerRole:h,mode:W="onBlur",t:Y,loading:F=!1}=f,S=Y??je,N=h??"guest",c=b??(l?"edit":"create"),H=pe(e??""),J=be(e??""),T=C(()=>ge(t),[t.name]),Q=C(()=>{const r=B(T.create),o=B(T.draft),n=B(T.update);return async(a,s,i)=>c==="edit"?n(a,s,i):(a?.status??l?.status??"draft")==="draft"?o(a,s,i):r(a,s,i)},[T,c,l?.status]),A=C(()=>Ee(t),[t]),U=l,m=C(()=>{if(!F)return c==="edit"?U?ve(t,U):void 0:U?{...A,...U}:A},[F,c,A,t,U]),u=fe({defaultValues:c==="create"?m:void 0,mode:W,resolver:Q,shouldUnregister:!1,shouldFocusError:!0}),E=y(u);O(()=>{E.current=u},[u]);const I=y(null);O(()=>{if(c==="edit"&&m){const r=m.id??null;r&&r!==I.current?(E.current.reset(m),I.current=r):!r&&I.current===null&&(E.current.reset(m),I.current="initialized")}},[c,m]);const k=l?.id,x=`${t.name.toLowerCase()}-form-draft`,v=c==="create"?x:k?`${x}-${k}`:`${x}-edit`,j=y(!1),_=y(F);_.current&&!F&&(j.current=!1),_.current=F,O(()=>{if(j.current)return;const r=d.getState().loadDraft(v),o=n=>{const a=()=>{d.getState().clearDraft(v),n&&E.current.reset(n)};G({toastType:"info",title:S("draft.restored",{defaultValue:"Draft restored"}),description:S("draft.restoredDescription",{defaultValue:"Your unsaved changes were recovered"}),action:ce(de,{altText:S("draft.discard",{defaultValue:"Discard"}),onClick:a},S("draft.discard",{defaultValue:"Discard"})),duration:8e3})};if(c==="create"&&!l){r&&(u.reset(r.data),o(A)),j.current=!0;return}if(c==="edit"&&m){if(r){const n=K(m,r.data);u.reset(n),o(m)}j.current=!0}},[c,l,v,u,m,S,A]);const P=y(!1),V=y(null);O(()=>{const r=u.watch(o=>{P.current||!j.current||(V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{if(o&&Object.values(o).some(n=>n!=null&&n!=="")){const n=L(o);d.getState().saveDraft(v,n,t.name,k)}},3e3))});return()=>{r.unsubscribe(),V.current&&clearTimeout(V.current)}},[u,v,t.name,k]);const D=y(null),$=y(!1),X=async r=>{if(!e)return{};const o=w.getState(),n=d.getState();if(!o.hasPendingUploads(e))return{};const a=setInterval(()=>{const s=w.getState().getTotalProgress(e);d.getState().setUploading(e,s)},200);try{return n.setUploading(e,0),await o.uploadAll(e,r),r?.aborted?null:w.getState().getResults(e)}catch(s){const i=w.getState().uploads[e];i&&Object.entries(i).forEach(([g,R])=>{R.status==="error"&&R.error&&u.setError(g,{type:"upload",message:R.error})});const p=s instanceof Error?s.message:"File upload failed";return d.getState().setError(e,p),null}finally{clearInterval(a)}},Z=r=>c!=="create"?r:Object.fromEntries(Object.entries(r).filter(([o])=>!me.includes(o))),ee=(r,o)=>{const n={...o};for(const[a,s]of Object.entries(r.fields))if(s.type==="price"&&a in n){const i=n[a];(i==null||i.amount==null)&&(n[a]=null)}return n},te=r=>{if(typeof window>"u")return;const o=Object.keys(r).find(a=>a!=="root"&&r[a]);if(!o)return;const n=document.querySelector(`input[name="${o}"][aria-invalid="true"], textarea[name="${o}"][aria-invalid="true"], select[name="${o}"][aria-invalid="true"]`)??document.querySelector(`[name="${o}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.focus())},re=u.handleSubmit,ae=((r,o)=>async n=>{if(n?.preventDefault?.(),$.current)return;const a=e?d.getState():null;await re(async(s,i)=>{if($.current)return;$.current=!0,D.current?.abort();const p=new AbortController;D.current=p,P.current=!0;try{e&&a&&a.startSubmit(e);const g=await X(p.signal);if(g===null||p.signal.aborted)return;e&&a&&a.setSubmitting(e);const R={...s,...g},ue=Z(R),M=ee(t,ue),z=Se(M);if(z.length>0){const le=`Cannot save: blob URLs detected at ${z.join(", ")}. Re-upload the files.`;e&&a&&a.setError(e,le);return}if(p.signal.aborted)return;await r(M,i),d.getState().clearDraft(v),E.current.reset(E.current.getValues()),e&&a&&a.setSuccess(e)}catch(g){throw e&&a&&a.setError(e,g instanceof Error?g.message:"Submission failed"),g}finally{if(P.current=!1,$.current=!1,D.current===p&&(D.current=null),e){const g=d.getState().forms[e]?.status;(g==="uploading"||g==="validating"||g==="submitting")&&d.getState().reset(e)}}},s=>{const i=Object.keys(s).filter(p=>p!=="root"&&s[p]);G({toastType:"error",title:S("validation.failed",{defaultValue:"Validation failed"}),description:S("validation.fixErrorsCount",{count:i.length,fields:i.join(", "),defaultValue:`${i.length} field(s) need attention: ${i.join(", ")}`}),duration:8e3}),te(s),o?.(s)})(n)}),ne=()=>{d.getState().clearDraft(v),u.reset(m),j.current=!1},q=()=>{D.current?.abort(),e&&(d.getState().cleanup(e),w.getState().cleanup(e))};O(()=>q,[]);const oe=()=>{D.current?.abort(),e&&(w.getState().abortAll(e),d.getState().reset(e)),$.current=!1},se=he(t,{operation:c,viewerRole:N,availableFields:void 0}),ie=u.formState.isSubmitted||Object.keys(u.formState.touchedFields||{}).length>0;return{...u,handleSubmit:ae,fields:se,operation:c,entity:t,t:S,viewerRole:N,formId:e,formStatus:e?H:"idle",uploadProgress:e?J:0,cleanup:q,cancel:oe,isDirty:u.formState.isDirty,hasUserInteracted:ie,resetForm:ne,originalValues:m}}export{De as useEntityForm};
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export { useController } from './hooks/useController';
|
|
|
35
35
|
export type { UseControllerProps, UseControllerReturn, ControllerRenderProps, ControllerFieldState, } from './hooks/useController';
|
|
36
36
|
export { isFieldEditable, getFieldsForOperation, validateEntity, translateFieldLabel, translateLabel, } from './utils';
|
|
37
37
|
export type { ViewerRole, RenderableField, GetFieldsForOperationOptions, EntityFieldsInput, SchemaOperation, ValidationIssue, ValidationResult, } from './utils';
|
|
38
|
-
export type { InferEntityData, InferEntityInput, InferEntityOutput, UseEntityFormOptions, EntityFormReturn, EntityFieldReturn, Entity, EntityField, FieldType, Visibility, Editable, ValidationRules, dndevSchema, } from './types';
|
|
38
|
+
export type { InferEntityData, InferEntityCreate, InferEntityInput, InferEntityOutput, UseEntityFormOptions, EntityFormReturn, EntityFieldReturn, Entity, EntityField, FieldType, Visibility, Editable, ValidationRules, dndevSchema, } from './types';
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,YAAY,EAEV,UAAU,EACV,eAAe,EACf,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAEV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAEjB,MAAM,EACN,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,YAAY,EAEV,UAAU,EACV,eAAe,EACf,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAEV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAEjB,MAAM,EACN,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
package/dist/forms/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEntityForm as
|
|
1
|
+
import{useEntityForm as a}from"./hooks/useEntityForm";import{useEntityField as t}from"./hooks/useEntityField";import{useController as e}from"./hooks/useController";import{isFieldEditable as s,getFieldsForOperation as i,validateEntity as l,translateFieldLabel as r,translateLabel as o}from"./utils";export{i as getFieldsForOperation,s as isFieldEditable,r as translateFieldLabel,o as translateLabel,e as useController,t as useEntityField,a as useEntityForm,l as validateEntity};
|
package/dist/forms/types.d.ts
CHANGED
|
@@ -6,17 +6,16 @@
|
|
|
6
6
|
* @since 0.0.1
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
|
-
import type { Entity, EntityField, FieldType,
|
|
9
|
+
import type { AnyEntity, CrudCreateInput, Entity, EntityField, FieldType, InferEntityRow, Visibility, Editable, ValidationRules, dndevSchema } from '@donotdev/core';
|
|
10
10
|
import type { RenderableField, ViewerRole } from './utils';
|
|
11
11
|
import type { FormStatus } from '../stores/FormStore';
|
|
12
12
|
import type { ReactElement } from 'react';
|
|
13
13
|
import type { UseFormReturn, ControllerRenderProps, FieldPath } from 'react-hook-form';
|
|
14
|
-
export type { Entity, EntityField, FieldType, Visibility, Editable, ValidationRules, dndevSchema, RenderableField, ViewerRole, };
|
|
14
|
+
export type { AnyEntity, Entity, EntityField, FieldType, Visibility, Editable, ValidationRules, dndevSchema, RenderableField, ViewerRole, };
|
|
15
15
|
/**
|
|
16
16
|
* Infers the data type from an entity definition.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* based on the field's `type` property.
|
|
18
|
+
* Alias of {@link InferEntityRow} — single source of truth with CRUD hooks and `defineEntity` field maps.
|
|
20
19
|
*
|
|
21
20
|
* @template E - Entity type from defineEntity()
|
|
22
21
|
*
|
|
@@ -40,11 +39,17 @@ export type { Entity, EntityField, FieldType, Visibility, Editable, ValidationRu
|
|
|
40
39
|
* @since 0.0.1
|
|
41
40
|
* @author AMBROISE PARK Consulting
|
|
42
41
|
*/
|
|
43
|
-
export type InferEntityData<E extends
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
export type InferEntityData<E extends AnyEntity> = InferEntityRow<E>;
|
|
43
|
+
/**
|
|
44
|
+
* Payload for {@link useCrud} `add` and bulk `inserts`: document shape without a
|
|
45
|
+
* stable row `id` (matches {@link CrudCreateInput} over {@link InferEntityRow}).
|
|
46
|
+
*
|
|
47
|
+
* @template E - Entity from `defineEntity()`
|
|
48
|
+
*
|
|
49
|
+
* @version 0.1.0
|
|
50
|
+
* @since 0.2.0
|
|
51
|
+
*/
|
|
52
|
+
export type InferEntityCreate<E extends AnyEntity> = CrudCreateInput<InferEntityRow<E>>;
|
|
48
53
|
/**
|
|
49
54
|
* Infers form input type (values before validation).
|
|
50
55
|
* All fields are optional/partial since form may be incomplete.
|
|
@@ -55,7 +60,7 @@ export type InferEntityData<E extends Entity> = {
|
|
|
55
60
|
* @since 0.0.1
|
|
56
61
|
* @author AMBROISE PARK Consulting
|
|
57
62
|
*/
|
|
58
|
-
export type InferEntityInput<E extends
|
|
63
|
+
export type InferEntityInput<E extends AnyEntity> = Partial<InferEntityData<E>>;
|
|
59
64
|
/**
|
|
60
65
|
* Infers form output type (values after validation).
|
|
61
66
|
* Represents validated, complete data ready for submission.
|
|
@@ -66,7 +71,7 @@ export type InferEntityInput<E extends Entity> = Partial<InferEntityData<E>>;
|
|
|
66
71
|
* @since 0.0.1
|
|
67
72
|
* @author AMBROISE PARK Consulting
|
|
68
73
|
*/
|
|
69
|
-
export type InferEntityOutput<E extends
|
|
74
|
+
export type InferEntityOutput<E extends AnyEntity> = InferEntityData<E>;
|
|
70
75
|
/**
|
|
71
76
|
* Options for useEntityForm hook.
|
|
72
77
|
*
|
|
@@ -76,7 +81,7 @@ export type InferEntityOutput<E extends Entity> = InferEntityData<E>;
|
|
|
76
81
|
* @since 0.0.1
|
|
77
82
|
* @author AMBROISE PARK Consulting
|
|
78
83
|
*/
|
|
79
|
-
export interface UseEntityFormOptions<E extends
|
|
84
|
+
export interface UseEntityFormOptions<E extends AnyEntity> {
|
|
80
85
|
/**
|
|
81
86
|
* Form ID for tracking form/upload state.
|
|
82
87
|
* Required for deferred file uploads and form status tracking.
|
|
@@ -112,6 +117,13 @@ export interface UseEntityFormOptions<E extends Entity> {
|
|
|
112
117
|
* If not provided, uses entity labels or generates from field names.
|
|
113
118
|
*/
|
|
114
119
|
t?: (key: string, options?: Record<string, unknown>) => string;
|
|
120
|
+
/**
|
|
121
|
+
* Whether the form data is still loading (e.g. async fetch in edit mode).
|
|
122
|
+
* When true, form initialization and draft restoration are deferred until false.
|
|
123
|
+
* Transitions from true → false reset the draft guard so draft loads against the correct data.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
loading?: boolean;
|
|
115
127
|
}
|
|
116
128
|
/**
|
|
117
129
|
* Return type for useEntityForm hook.
|
|
@@ -124,7 +136,7 @@ export interface UseEntityFormOptions<E extends Entity> {
|
|
|
124
136
|
* @since 0.0.1
|
|
125
137
|
* @author AMBROISE PARK Consulting
|
|
126
138
|
*/
|
|
127
|
-
export interface EntityFormReturn<E extends
|
|
139
|
+
export interface EntityFormReturn<E extends AnyEntity> extends UseFormReturn<InferEntityData<E>> {
|
|
128
140
|
/**
|
|
129
141
|
* Pre-filtered fields ready for rendering.
|
|
130
142
|
* Already filtered by operation and visibility.
|
|
@@ -204,7 +216,7 @@ export interface EntityFormReturn<E extends Entity> extends UseFormReturn<InferE
|
|
|
204
216
|
* @since 0.0.1
|
|
205
217
|
* @author AMBROISE PARK Consulting
|
|
206
218
|
*/
|
|
207
|
-
export interface EntityFieldReturn<E extends
|
|
219
|
+
export interface EntityFieldReturn<E extends AnyEntity, K extends keyof InferEntityData<E>> {
|
|
208
220
|
/**
|
|
209
221
|
* React Hook Form field props (value, onChange, onBlur, etc.)
|
|
210
222
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/forms/types.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACX,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/forms/types.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,WAAW,EACX,SAAS,EACT,cAAc,EACd,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,GACX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,SAAS,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,SAAS,IAAI,eAAe,CAClE,cAAc,CAAC,CAAC,CAAC,CAClB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,SAAS,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,SAAS;IACvD;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAE9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,KAAK,CAAC;IAEhE;;;OAGG;IACH,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;IAE/D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,aAAa,CAC1E,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;OAGG;IACH,MAAM,EAAE,eAAe,EAAE,CAAC;IAE1B;;OAEG;IACH,SAAS,EAAE,QAAQ,GAAG,MAAM,CAAC;IAE7B;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;IAEV;;OAEG;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;IAE9D;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAE3B;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IAEpB;;;OAGG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACzD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB,CAChC,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,MAAM,eAAe,CAAC,CAAC,CAAC;IAElC;;OAEG;IACH,KAAK,EAAE,qBAAqB,CAC1B,eAAe,CAAC,CAAC,CAAC,EAClB,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAC9B,CAAC;IAEF;;OAEG;IACH,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IAEF;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;;;OAOG;IACH,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,KAAK,MAAM,GAAG,YAAY,CAAC;CAC7B"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* These helpers provide a single, canonical "initialValues" snapshot that
|
|
9
9
|
* React Hook Form can use as its dirty baseline.
|
|
10
10
|
*/
|
|
11
|
-
import type {
|
|
11
|
+
import type { AnyEntity } from '@donotdev/core';
|
|
12
12
|
import type { InferEntityData } from '../types';
|
|
13
13
|
/**
|
|
14
14
|
* Build initial values for an existing DB record.
|
|
@@ -18,7 +18,7 @@ import type { InferEntityData } from '../types';
|
|
|
18
18
|
* - If the record has a non-null, non-undefined value, keep it.
|
|
19
19
|
* - Otherwise, apply the same type-specific defaults we use in forms.
|
|
20
20
|
*/
|
|
21
|
-
export declare function buildInitialFromRecord<E extends
|
|
21
|
+
export declare function buildInitialFromRecord<E extends AnyEntity>(entity: E, record: Partial<InferEntityData<E>>): Partial<InferEntityData<E>>;
|
|
22
22
|
/**
|
|
23
23
|
* Build schema defaults for create-mode forms.
|
|
24
24
|
*
|
|
@@ -26,5 +26,5 @@ export declare function buildInitialFromRecord<E extends Entity>(entity: E, reco
|
|
|
26
26
|
* buildInitialFromRecord.
|
|
27
27
|
* - This represents "what a brand-new object would look like" before any user edits.
|
|
28
28
|
*/
|
|
29
|
-
export declare function buildSchemaDefaults<E extends
|
|
29
|
+
export declare function buildSchemaDefaults<E extends AnyEntity>(entity: E): Partial<InferEntityData<E>>;
|
|
30
30
|
//# sourceMappingURL=buildInitialValues.d.ts.map
|