@donotdev/crud 0.2.3 → 0.3.0
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.d.ts +13 -14
- package/dist/CrudService.bulk.d.ts.map +1 -1
- package/dist/CrudService.bulk.js +1 -1
- package/dist/CrudService.bulkAcross.d.ts +12 -7
- package/dist/CrudService.bulkAcross.d.ts.map +1 -1
- package/dist/CrudService.bulkAcross.js +1 -1
- package/dist/CrudService.bulkReconciliation.d.ts +4 -0
- package/dist/CrudService.bulkReconciliation.d.ts.map +1 -0
- package/dist/CrudService.bulkReconciliation.js +1 -0
- package/dist/CrudService.cache.d.ts +1 -1
- package/dist/CrudService.cache.d.ts.map +1 -1
- package/dist/CrudService.cache.js +1 -1
- package/dist/CrudService.d.ts +35 -6
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.js +1 -1
- package/dist/CrudService.mutations.d.ts +3 -3
- package/dist/CrudService.mutations.d.ts.map +1 -1
- package/dist/CrudService.mutations.js +1 -1
- package/dist/CrudService.optimistic.d.ts +2 -2
- package/dist/CrudService.optimistic.d.ts.map +1 -1
- package/dist/CrudService.optimistic.js +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/CrudService.writeRules.d.ts +57 -0
- package/dist/CrudService.writeRules.d.ts.map +1 -0
- package/dist/CrudService.writeRules.js +1 -0
- package/dist/CrudService.writeSchema.d.ts +64 -0
- package/dist/CrudService.writeSchema.d.ts.map +1 -0
- package/dist/CrudService.writeSchema.js +1 -0
- package/dist/CrudStore.d.ts +10 -1
- package/dist/CrudStore.d.ts.map +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +1 -1
- package/dist/FieldRegistry.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.d.ts +3 -3
- package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.d.ts +3 -2
- package/dist/components/CrudButton.d.ts.map +1 -1
- package/dist/components/CrudCard.d.ts.map +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/EntityFilters.d.ts +23 -4
- package/dist/components/EntityFilters.d.ts.map +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.d.ts +21 -4
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.d.ts.map +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/SortableCardList.d.ts +47 -0
- package/dist/components/SortableCardList.d.ts.map +1 -0
- package/dist/components/SortableCardList.js +1 -0
- package/dist/components/YearFilter.js +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts +9 -0
- package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
- package/dist/components/controlled/fieldOptions.d.ts +9 -0
- package/dist/components/controlled/fieldOptions.d.ts.map +1 -1
- package/dist/components/controlled/fieldOptions.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.d.ts.map +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/ControlledNumberField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledNumberField.js +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
- package/dist/components/controlled/input/ControlledPriceField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPriceField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledTextField.js +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.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/ControlledReferenceField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
- package/dist/components/controlled/select/ControlledYearField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledYearField.js +1 -1
- package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/MapFieldDisplay.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/TextFieldDisplay.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.d.ts +3 -1
- package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/AddressFieldComponent.js +1 -1
- package/dist/components/form/fields/ComboboxComponent.d.ts +2 -0
- package/dist/components/form/fields/ComboboxComponent.d.ts.map +1 -1
- package/dist/components/form/fields/ComboboxComponent.js +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.d.ts +2 -0
- package/dist/components/form/fields/CurrencyFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.d.ts +2 -0
- package/dist/components/form/fields/DateFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.d.ts +2 -0
- package/dist/components/form/fields/DropdownComponent.d.ts.map +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/DurationFieldComponent.d.ts.map +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.d.ts.map +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.d.ts.map +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.d.ts +2 -0
- package/dist/components/form/fields/MultiDropdownComponent.d.ts.map +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts +2 -0
- package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.d.ts +2 -0
- package/dist/components/form/fields/NumberFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.d.ts +2 -0
- package/dist/components/form/fields/PasswordFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.d.ts +11 -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 +2 -0
- 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/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.d.ts +3 -1
- package/dist/components/form/fields/ReferenceFieldComponent.d.ts.map +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.d.ts +2 -0
- package/dist/components/form/fields/TextAreaComponent.d.ts.map +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.d.ts +3 -1
- package/dist/components/form/fields/TextFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.d.ts +2 -0
- package/dist/components/form/fields/TimestampFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.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/fieldTypeRegistry.d.ts +2 -2
- package/dist/fieldTypeRegistry.d.ts.map +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/fieldTypeRegistry.store.d.ts +0 -2
- package/dist/fieldTypeRegistry.store.d.ts.map +1 -1
- package/dist/fieldTypeRegistry.store.js +1 -1
- package/dist/fieldTypeRegistry.types.d.ts +8 -9
- package/dist/fieldTypeRegistry.types.d.ts.map +1 -1
- package/dist/forms/FormNavigation.d.ts +24 -0
- package/dist/forms/FormNavigation.d.ts.map +1 -0
- package/dist/forms/FormNavigation.js +1 -0
- package/dist/forms/childRows.d.ts +184 -0
- package/dist/forms/childRows.d.ts.map +1 -0
- package/dist/forms/childRows.js +1 -0
- package/dist/forms/extend.d.ts +88 -0
- package/dist/forms/extend.d.ts.map +1 -0
- package/dist/forms/extend.js +1 -0
- package/dist/forms/hooks/useEntityField.d.ts +11 -5
- 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 +50 -5
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/hooks/useFormDraftState.d.ts +53 -0
- package/dist/forms/hooks/useFormDraftState.d.ts.map +1 -0
- package/dist/forms/hooks/useFormDraftState.js +1 -0
- package/dist/forms/index.d.ts +6 -2
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/types.d.ts +171 -25
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.d.ts +32 -17
- package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/conditionAwareResolver.d.ts +35 -0
- package/dist/forms/utils/conditionAwareResolver.d.ts.map +1 -0
- package/dist/forms/utils/conditionAwareResolver.js +1 -0
- package/dist/forms/utils/emptyValue.d.ts +34 -0
- package/dist/forms/utils/emptyValue.d.ts.map +1 -0
- package/dist/forms/utils/emptyValue.js +1 -0
- package/dist/forms/utils/getFieldsForOperation.d.ts +30 -19
- package/dist/forms/utils/getFieldsForOperation.d.ts.map +1 -1
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/index.d.ts +1 -0
- package/dist/forms/utils/index.d.ts.map +1 -1
- package/dist/forms/utils/index.js +1 -1
- package/dist/forms/utils/isFieldEditable.d.ts +21 -22
- package/dist/forms/utils/isFieldEditable.d.ts.map +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/writableFields.d.ts +19 -0
- package/dist/forms/utils/writableFields.d.ts.map +1 -0
- package/dist/forms/utils/writableFields.js +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useChildRows.d.ts +161 -0
- package/dist/hooks/useChildRows.d.ts.map +1 -0
- package/dist/hooks/useChildRows.js +1 -0
- package/dist/hooks/useCrudFilters.d.ts +21 -1
- package/dist/hooks/useCrudFilters.d.ts.map +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useExtensionRows.d.ts +24 -0
- package/dist/hooks/useExtensionRows.d.ts.map +1 -0
- package/dist/hooks/useExtensionRows.js +1 -0
- package/dist/hooks/useFieldConditions.d.ts +2 -2
- package/dist/hooks/useFieldConditions.d.ts.map +1 -1
- package/dist/hooks/useFieldConditions.js +1 -1
- package/dist/hooks/useReferenceResolver.d.ts +4 -1
- package/dist/hooks/useReferenceResolver.d.ts.map +1 -1
- package/dist/hooks/useReferenceResolver.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/registerBuiltinFieldTypes.d.ts +2 -0
- package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
- package/dist/registerBuiltinFieldTypes.js +1 -1
- package/dist/stores/FormStore.d.ts +116 -5
- package/dist/stores/FormStore.d.ts.map +1 -1
- package/dist/stores/FormStore.js +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 +38 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/useCrud.d.ts +7 -5
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudDoc.js +1 -1
- package/dist/utils/clientListProcessing.d.ts +9 -12
- package/dist/utils/clientListProcessing.d.ts.map +1 -1
- package/dist/utils/clientListProcessing.js +1 -1
- package/dist/utils/collections.d.ts.map +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/filterUrl.d.ts +45 -0
- package/dist/utils/filterUrl.d.ts.map +1 -0
- package/dist/utils/filterUrl.js +1 -0
- package/dist/utils/matchesFilter.d.ts +27 -3
- package/dist/utils/matchesFilter.d.ts.map +1 -1
- package/dist/utils/matchesFilter.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/utils/useRowTranslator.js +1 -1
- package/guidelines/COMPONENTS.md +82 -11
- package/guidelines/CRUD.md +242 -7
- package/guidelines/GOTCHAS.md +17 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import"lucide-react";import{useMemo as A,useId as $}from"react";import{Combobox as j,Stack as c}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";const L=({label:r,info:p,value:l,onChange:u,options:n,isLoading:f=!1,error:h,helperText:o,required:m,onBlur:g,onCreate:I,placeholder:v})=>{const{t:s}=q("crud"),i=$(),b=A(()=>n.map(e=>({value:e.id,label:e.label,description:e.description})),[n]),x=e=>{const S=Array.isArray(e)?e[0]||"":e;u(S)},y=e=>{e||g?.()},a=!!h,C=`${i}-error`,z=`${i}-helper`;return d(c,{gap:"tight",children:[t(j,{label:r,info:p,value:l||"",onValueChange:x,onOpenChange:y,placeholder:v||s("reference.placeholder",{label:r})||`Select ${r}`,emptyMessage:s("reference.noResults")||"No results found",options:b,required:m,variant:a?"destructive":void 0,isLoading:f,clearable:!!l}),a&&d(c,{id:C,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[t("span",{children:"\u26A0"}),o]}),o&&!a&&t("p",{id:z,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:o})]})};var M=L;export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import{lazy as m,Suspense as b,useState as f,useEffect as g}from"react";import{Stack as v}from"@donotdev/components";import h from"./TextAreaComponent";const p=m(()=>typeof window<"u"?import("./internal/TiptapEditor").catch(()=>({default:()=>null})):Promise.resolve({default:()=>null})),x=({label:l,value:a="",onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})=>{const[c,n]=f(!1);return g(()=>{n(!0)},[]),c?e(v,{gap:"tight",children:e(b,{fallback:e(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder: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(h,{label:l,value:a,onChange:r,error:s,helperText:o,required:d,disabled:t,placeholder:i,className:u})})}):e(h,{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};
|
|
@@ -3,6 +3,8 @@ import { Textarea } from '@donotdev/components';
|
|
|
3
3
|
export interface TextAreaComponentProps extends Omit<ComponentProps<typeof Textarea>, 'value' | 'onChange'> {
|
|
4
4
|
/** Field label */
|
|
5
5
|
label: string;
|
|
6
|
+
/** Help text (entity field `hint`): an (i) after the label shows it */
|
|
7
|
+
info?: string;
|
|
6
8
|
/** Current value */
|
|
7
9
|
value?: string;
|
|
8
10
|
/** Change handler */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TextAreaComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EACL,QAAQ,EAKT,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,cAAc,CAAC,OAAO,QAAQ,CAAC,EAC/B,OAAO,GAAG,UAAU,CACrB;IACC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IAC5D,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,iBAAiB,EAAE,aAAa,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"TextAreaComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TextAreaComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EACL,QAAQ,EAKT,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,cAAc,CAAC,OAAO,QAAQ,CAAC,EAC/B,OAAO,GAAG,UAAU,CACrB;IACC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAC;IAC5D,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,iBAAiB,EAAE,aAAa,CAAC,sBAAsB,CAgJ5D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as o}from"react/jsx-runtime";import{useState as N,useId as F,useRef as j,useEffect as q}from"react";import{Textarea as A,FloatingLabel as R,Spinner as k,cn as m,Stack as p}from"@donotdev/components";const B=({label:x,info:b,value:s="",onChange:y,error:h,helperText:n,rows:z=3,loading:d=!1,maxLength:r,showCharCount:v=!1,autoResize:i=!1,required:w=!1,disabled:g=!1,className:$,...S})=>{const e=F(),[I,f]=N(!1),l=j(null),a=!!h,c=s.length,C=r&&c>r*.8,L=r&&c>r;return q(()=>{if(i&&l.current){const u=l.current;u.style.height="auto",u.style.height=`${u.scrollHeight}px`}},[s,i]),o(p,{gap:"tight",children:[t(R,{htmlFor:e,label:x,info:b,disabled:g||d,required:w,children:o("div",{className:"dndev-relative",children:[t(A,{ref:l,id:e,value:s,onChange:y,onFocus:()=>f(!0),onBlur:()=>f(!1),disabled:g||d,maxLength:r,rows:i?1:z,bare:!0,"aria-describedby":m(a&&`${e}-error`,n&&!a&&`${e}-helper`,v&&`${e}-count`),"aria-invalid":a,className:m("dndev-w-full",i&&"dndev-overflow-hidden",$),"data-variant":a?"destructive":void 0,style:{resize:i?"none":void 0},...S}),d&&t("div",{className:"dndev-absolute",style:{right:"var(--gap-md)",top:"var(--gap-md)"},children:t(k,{"aria-label":"Loading"})})]})}),v&&r&&o("div",{id:`${e}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:L?"var(--destructive-foreground)":C?"var(--warning)":"var(--muted-foreground)"},children:[c,"/",r]}),a&&o(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]}),n&&!a&&t("p",{id:`${e}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:n})]})};var E=B;export{E as default};
|
|
@@ -3,6 +3,8 @@ import { Input } from '@donotdev/components';
|
|
|
3
3
|
export interface TextFieldComponentProps extends Omit<ComponentProps<typeof Input>, 'value' | 'onChange'> {
|
|
4
4
|
/** Field label */
|
|
5
5
|
label: string;
|
|
6
|
+
/** Help text (entity field `hint`): an (i) after the label shows it */
|
|
7
|
+
info?: string;
|
|
6
8
|
/** Current value */
|
|
7
9
|
value?: string;
|
|
8
10
|
/** Change handler */
|
|
@@ -46,6 +48,6 @@ export interface TextFieldComponentProps extends Omit<ComponentProps<typeof Inpu
|
|
|
46
48
|
* @param props - TextFieldComponentProps
|
|
47
49
|
* @returns JSX.Element
|
|
48
50
|
*/
|
|
49
|
-
declare function TextFieldComponent({ label, value, onChange, error, helperText, type, loading, maxLength, showCharCount, required, disabled, className, ref, ...props }: TextFieldComponentProps): import("react").JSX.Element;
|
|
51
|
+
declare function TextFieldComponent({ label, info, value, onChange, error, helperText, type, loading, maxLength, showCharCount, required, disabled, className, ref, ...props }: TextFieldComponentProps): import("react").JSX.Element;
|
|
50
52
|
export default TextFieldComponent;
|
|
51
53
|
//# sourceMappingURL=TextFieldComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TextFieldComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,KAAK,EAA6B,MAAM,sBAAsB,CAAC;AAExE,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CACnD,cAAc,CAAC,OAAO,KAAK,CAAC,EAC5B,OAAO,GAAG,UAAU,CACrB;IACC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CACR,KAAK,EAAE,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,KACvD,IAAI,CAAC;IACV,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,KAAU,EACV,QAAQ,EACR,KAAK,EACL,UAAU,EACV,IAAa,EACb,OAAe,EACf,SAAS,EACT,aAAqB,EACrB,QAAgB,EAChB,QAAgB,EAChB,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,uBAAuB,+
|
|
1
|
+
{"version":3,"file":"TextFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TextFieldComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,KAAK,EAA6B,MAAM,sBAAsB,CAAC;AAExE,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CACnD,cAAc,CAAC,OAAO,KAAK,CAAC,EAC5B,OAAO,GAAG,UAAU,CACrB;IACC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,CACR,KAAK,EAAE,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,KACvD,IAAI,CAAC;IACV,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,IAAI,EACJ,KAAU,EACV,QAAQ,EACR,KAAK,EACL,UAAU,EACV,IAAa,EACb,OAAe,EACf,SAAS,EACT,aAAqB,EACrB,QAAgB,EAChB,QAAgB,EAChB,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,uBAAuB,+BAyFzB;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as o,jsxs as i}from"react/jsx-runtime";import{useId as S}from"react";import{Input as j,cn as c,Stack as u}from"@donotdev/components";function q({label:f,info:h,value:d="",onChange:v,error:l,helperText:a,type:g="text",loading:p=!1,maxLength:e,showCharCount:s=!1,required:m=!1,disabled:x=!1,className:z,ref:b,...y}){const r=S(),t=!!l,n=d.length,$=e&&n>e*.8,w=e&&n>e,{children:I,...C}=y;return i(u,{gap:"tight",children:[o(j,{ref:b,id:r,type:g,value:d,onChange:v,label:f,info:h,disabled:x||p,maxLength:e,required:m,"aria-describedby":c(t&&`${r}-error`,a&&!t&&`${r}-helper`,s&&`${r}-count`),"aria-invalid":t,className:c("dndev-w-full",z),"data-variant":t?"destructive":void 0,...C}),s&&e&&i("div",{id:`${r}-count`,style:{fontSize:"var(--font-size-xs)",textAlign:"right",color:w?"var(--destructive-foreground)":$?"var(--warning)":"var(--muted-foreground)"},children:[n,"/",e]}),t&&i(u,{id:`${r}-error`,direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)",color:"var(--destructive-foreground)"},role:"alert",children:[o("span",{children:"\u26A0"}),l]}),a&&!t&&o("p",{id:`${r}-helper`,style:{fontSize:"var(--font-size-xs)",color:"var(--muted-foreground)"},children:a})]})}var A=q;export{A as default};
|
|
@@ -10,6 +10,8 @@ import type { ChangeEvent, ComponentType } from 'react';
|
|
|
10
10
|
export interface TimestampFieldComponentProps {
|
|
11
11
|
/** Field label */
|
|
12
12
|
label: string;
|
|
13
|
+
/** Help text (entity field `hint`): an (i) after the label shows it */
|
|
14
|
+
info?: string;
|
|
13
15
|
/** Current Date value or null */
|
|
14
16
|
value?: Date | null;
|
|
15
17
|
/** Change handler - accepts both event and direct value */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimestampFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TimestampFieldComponent.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAIxD,MAAM,WAAW,4BAA4B;IAC3C,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtE,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,uBAAuB,EAAE,aAAa,CAAC,4BAA4B,
|
|
1
|
+
{"version":3,"file":"TimestampFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/TimestampFieldComponent.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAIxD,MAAM,WAAW,4BAA4B;IAC3C,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtE,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,uBAAuB,EAAE,aAAa,CAAC,4BAA4B,CAyCxE,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import f from"./DateFieldComponent";const g=({label:o,info:a,value:e,onChange:r,error:l,helperText:n,mode:i="datetime-local",required:m})=>{const s=e?new Date(e).toISOString():"";return d(f,{label:o,info:a,value:s,onChange:t=>{if(t){const u={target:{value:new Date(t).toISOString()}};r(u)}else r({target:{value:""}})},error:l,helperText:n,mode:i,required:m})};var p=g;export{p as default};
|
|
@@ -22,4 +22,6 @@ export type { YearFilterValue, YearFilterProps } from './YearFilter';
|
|
|
22
22
|
export * from './fields/display';
|
|
23
23
|
export { DisplayThumbnail } from './DisplayThumbnail';
|
|
24
24
|
export { CrudCard } from './CrudCard';
|
|
25
|
+
export { SortableCardList } from './SortableCardList';
|
|
26
|
+
export type { SortableCardListProps } from './SortableCardList';
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,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"}
|
|
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;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"./CrudButton";import{FormFieldRenderer as a}from"./FormFieldRenderer";import{DisplayFieldRenderer as
|
|
1
|
+
import{default as r}from"./CrudButton";import{FormFieldRenderer as a}from"./FormFieldRenderer";import{DisplayFieldRenderer as t,formatValue as e}from"./DisplayFieldRenderer";import{default as o}from"./FormLayout";export*from"./controlled";export*from"./form";import{EntityFilters as m}from"./EntityFilters";import{matchesFilter as s}from"../utils/matchesFilter";import{YearFilter as i}from"./YearFilter";export*from"./fields/display";import{DisplayThumbnail as l}from"./DisplayThumbnail";import{CrudCard as p}from"./CrudCard";import{SortableCardList as d}from"./SortableCardList";export{r as CrudButton,p as CrudCard,t as DisplayFieldRenderer,l as DisplayThumbnail,m as EntityFilters,a as FormFieldRenderer,o as FormLayout,d as SortableCardList,i as YearFilter,e as formatValue,s as matchesFilter};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldTypeMetadata } from './fieldTypeRegistry.types';
|
|
2
|
-
export type { FilterType,
|
|
3
|
-
export { getFieldTypeMetadata, getFilterType, getDisplayFormatter, isFilterable,
|
|
2
|
+
export type { FilterType, DisplayFormatterOptions, DisplayFormatter, ComponentRegistration, FieldTypeMetadata, } from './fieldTypeRegistry.types';
|
|
3
|
+
export { getFieldTypeMetadata, getFilterType, getDisplayFormatter, isFilterable, clearFieldTypeRegistry, } from './fieldTypeRegistry.store';
|
|
4
4
|
/**
|
|
5
5
|
* Register a built-in field type with all metadata.
|
|
6
6
|
* For internal/plugin use — consumers should use registerFieldType() instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldTypeRegistry.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAUnE,YAAY,EACV,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"fieldTypeRegistry.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAUnE,YAAY,EACV,UAAU,EACV,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAInC;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAa1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{getFieldRegistry as
|
|
1
|
+
"use client";import{getFieldRegistry as a}from"./FieldRegistry";import{setRegistrationInit as s,getMetadataRegistry as r}from"./fieldTypeRegistry.store";import{registerAllBuiltinFieldTypes as l}from"./registerBuiltinFieldTypes";s(e=>{l(e,a())});import{getFieldTypeMetadata as o,getFilterType as p,getDisplayFormatter as g,isFilterable as n,clearFieldTypeRegistry as y}from"./fieldTypeRegistry.store";function F(e){const{type:i,components:t}=e;t&&a().registerComponent(i,t.controlled,t.uncontrolled),r().set(i,e)}export{y as clearFieldTypeRegistry,g as getDisplayFormatter,o as getFieldTypeMetadata,p as getFilterType,n as isFilterable,F as registerBuiltinFieldType};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { FieldTypeMetadata } from './fieldTypeRegistry.types';
|
|
2
2
|
import type { DisplayFormatter } from './fieldTypeRegistry.types';
|
|
3
3
|
import type { FilterType } from './fieldTypeRegistry.types';
|
|
4
|
-
import type { ValueType } from './fieldTypeRegistry.types';
|
|
5
4
|
/**
|
|
6
5
|
* Called once by fieldTypeRegistry.ts to wire the lazy init callback.
|
|
7
6
|
* Keeps this file free of imports from registerBuiltinFieldTypes.
|
|
@@ -12,6 +11,5 @@ export declare function getFieldTypeMetadata(type: string): FieldTypeMetadata |
|
|
|
12
11
|
export declare function getFilterType(type: string): FilterType | undefined;
|
|
13
12
|
export declare function getDisplayFormatter(type: string): DisplayFormatter | undefined;
|
|
14
13
|
export declare function isFilterable(type: string): boolean;
|
|
15
|
-
export declare function getValueType(type: string): ValueType | undefined;
|
|
16
14
|
export declare function clearFieldTypeRegistry(): void;
|
|
17
15
|
//# sourceMappingURL=fieldTypeRegistry.store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldTypeRegistry.store.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.store.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"fieldTypeRegistry.store.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.store.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAiB5D;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAAK,IAAI,GACrD,IAAI,CAEN;AAED,wBAAgB,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAOpE;AAID,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GACX,iBAAiB,GAAG,SAAS,CAE/B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAIlE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,SAAS,CAI9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -1 +1 @@
|
|
|
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(
|
|
1
|
+
"use client";import{getGlobalSingleton as n}from"@donotdev/core";import{getFieldRegistry as i}from"./FieldRegistry";function r(){return n("field-type-metadata",()=>({registry:new Map,builtinsRegistered:!1,initFn:null}))}function a(e){r().initFn=e}function t(){const e=r();return e.builtinsRegistered||(e.builtinsRegistered=!0,e.initFn?.(e.registry)),e.registry}function s(e){return t().get(e)}function l(e){return i().getFilterType(e)||t().get(e)?.filterType}function g(e){return i().getDisplayFormatter(e)||t().get(e)?.displayFormatter}function o(e){return i().isFilterable(e)?!0:t().get(e)?.filterable??!1}function u(){t().clear()}export{u as clearFieldTypeRegistry,g as getDisplayFormatter,s as getFieldTypeMetadata,l as getFilterType,t as getMetadataRegistry,o as isFilterable,a as setRegistrationInit};
|
|
@@ -6,13 +6,14 @@ import type { ComponentType, ReactElement } from 'react';
|
|
|
6
6
|
import type { EntityField, FieldType } from '@donotdev/core';
|
|
7
7
|
import type { ControlledFieldProps, UncontrolledFieldProps } from './FieldRegistry';
|
|
8
8
|
/**
|
|
9
|
-
* Filter type metadata for EntityFilters component
|
|
9
|
+
* Filter type metadata for EntityFilters component. Matching (`matchesFilter`):
|
|
10
|
+
* - `text`, `address`: case-insensitive substring
|
|
11
|
+
* - `select`, `multiselect`, `reference`: exact value; an array value matches when any
|
|
12
|
+
* of its items is selected (any-of); `reference` options are the referenced
|
|
13
|
+
* documents' labels, matched by id
|
|
14
|
+
* - `range`: min/max; `rating`: minimum
|
|
10
15
|
*/
|
|
11
|
-
export type FilterType = 'text' | 'range' | 'select' | 'none' | 'address' | 'multiselect' | 'rating';
|
|
12
|
-
/**
|
|
13
|
-
* Value type for type checking
|
|
14
|
-
*/
|
|
15
|
-
export type ValueType = 'string' | 'number' | 'boolean' | 'date' | 'object' | 'array';
|
|
16
|
+
export type FilterType = 'text' | 'range' | 'select' | 'none' | 'address' | 'multiselect' | 'rating' | 'reference';
|
|
16
17
|
/**
|
|
17
18
|
* Display formatter function
|
|
18
19
|
*/
|
|
@@ -37,7 +38,7 @@ export interface ComponentRegistration {
|
|
|
37
38
|
/**
|
|
38
39
|
* Complete metadata for a built-in field type
|
|
39
40
|
*
|
|
40
|
-
* NOTE:
|
|
41
|
+
* NOTE: Values (schema + storage kind) live in BUILTIN_VALUES (@donotdev/core, core/schemas/src/common/fieldSemantics.ts)
|
|
41
42
|
* This registry only handles UI components + filter/display metadata
|
|
42
43
|
*/
|
|
43
44
|
export interface FieldTypeMetadata {
|
|
@@ -49,8 +50,6 @@ export interface FieldTypeMetadata {
|
|
|
49
50
|
filterType?: FilterType;
|
|
50
51
|
/** Display formatter function */
|
|
51
52
|
displayFormatter?: DisplayFormatter;
|
|
52
|
-
/** Runtime value type */
|
|
53
|
-
valueType?: ValueType;
|
|
54
53
|
/** UI components */
|
|
55
54
|
components?: ComponentRegistration;
|
|
56
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldTypeRegistry.types.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAEzB
|
|
1
|
+
{"version":3,"file":"fieldTypeRegistry.types.d.ts","sourceRoot":"","sources":["../src/fieldTypeRegistry.types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,GACT,aAAa,GACb,QAAQ,GACR,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,4GAA4G;IAC5G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAE7B,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,WAAW,EAEnB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,EACzD,OAAO,CAAC,EAAE,uBAAuB,KAC9B,MAAM,GAAG,YAAY,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAEpC,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1D,YAAY,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CACtD;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uCAAuC;IACvC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,oBAAoB;IACpB,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Router access a form needs to leave on save and return on failure. */
|
|
2
|
+
export interface FormNavigation {
|
|
3
|
+
/** Navigate to an app path. */
|
|
4
|
+
navigate: (path: string) => void;
|
|
5
|
+
/** Current app path, read at call time. */
|
|
6
|
+
currentPath: () => string;
|
|
7
|
+
/** Previous breadcrumb of the current path (nearest existing parent route, else home). */
|
|
8
|
+
parentPath: () => string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Provides router access to every `useEntityForm` below it.
|
|
12
|
+
* `@donotdev/ui` mounts it in `UIProviders`; apps do not mount it themselves.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <FormNavigationProvider value={{ navigate, currentPath, parentPath }}>
|
|
17
|
+
* {children}
|
|
18
|
+
* </FormNavigationProvider>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const FormNavigationProvider: import("react").Provider<FormNavigation | null>;
|
|
22
|
+
/** Router access for forms, or null when no router provided it. */
|
|
23
|
+
export declare function useFormNavigation(): FormNavigation | null;
|
|
24
|
+
//# sourceMappingURL=FormNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormNavigation.d.ts","sourceRoot":"","sources":["../../src/forms/FormNavigation.ts"],"names":[],"mappings":"AAgBA,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,2CAA2C;IAC3C,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,0FAA0F;IAC1F,UAAU,EAAE,MAAM,MAAM,CAAC;CAC1B;AAQD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,iDAAiC,CAAC;AAErE,mEAAmE;AACnE,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAEzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as r,useContext as t}from"react";const o=r(null),e=o.Provider;function n(){return t(o)}export{e as FormNavigationProvider,n as useFormNavigation};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createSchemas } from '@donotdev/core';
|
|
2
|
+
import type { AnyEntity, BulkAcrossBatch } from '@donotdev/core';
|
|
3
|
+
import type { ChildRowEdits } from '../stores/FormStore';
|
|
4
|
+
import type { ResolvedExtension } from './extend';
|
|
5
|
+
import { writableFields } from './utils/writableFields';
|
|
6
|
+
export { writableFields };
|
|
7
|
+
/** No edits. Shared constant: compare by reference to skip store writes. */
|
|
8
|
+
export declare const EMPTY_CHILD_EDITS: ChildRowEdits;
|
|
9
|
+
/** A row as the child list sees it. */
|
|
10
|
+
export type ChildRow = Record<string, unknown> & {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
/** Why a field of a row is invalid: empty while required, or a value the rules reject. */
|
|
14
|
+
export type ChildRowErrorKind = 'required' | 'invalid';
|
|
15
|
+
/** Invalid fields by row id: `errors[rowId][field]` (extension fields prefixed). */
|
|
16
|
+
export type ChildRowErrorKinds = Record<string, Record<string, ChildRowErrorKind>>;
|
|
17
|
+
/**
|
|
18
|
+
* The entity's `createSchemas`, built once per entity (validation runs on every
|
|
19
|
+
* change; repeated writes carry the same schemas).
|
|
20
|
+
*
|
|
21
|
+
* @param entity - The entity
|
|
22
|
+
*/
|
|
23
|
+
export declare function schemasOf(entity: AnyEntity): ReturnType<typeof createSchemas>;
|
|
24
|
+
/**
|
|
25
|
+
* Collection of the parent record: the child field's referenced collection
|
|
26
|
+
* (descriptor `value.kind === 'ref'`: any field type with `validation.reference`,
|
|
27
|
+
* custom ones included). Throws when `field` is not a reference field of `entity`
|
|
28
|
+
* (a wrong parent would silently list nothing).
|
|
29
|
+
*
|
|
30
|
+
* @param entity - The child entity
|
|
31
|
+
* @param field - The child's field pointing at the parent
|
|
32
|
+
* @returns The parent collection
|
|
33
|
+
*/
|
|
34
|
+
export declare function parentCollectionOf(entity: AnyEntity, field: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* The child entity of a joined list, from its collection (entities register on
|
|
37
|
+
* `defineEntity`). Throws when no entity defines it.
|
|
38
|
+
*
|
|
39
|
+
* @param collection - The child collection
|
|
40
|
+
* @returns The child entity
|
|
41
|
+
*/
|
|
42
|
+
export declare function childEntityOf(collection: string): AnyEntity;
|
|
43
|
+
/** What the viewer may do on the child entity (`entity.access`). */
|
|
44
|
+
export interface ChildRowsAccess {
|
|
45
|
+
/** Add rows (`access.create`) */
|
|
46
|
+
create: boolean;
|
|
47
|
+
/** Edit saved rows (`access.update`) */
|
|
48
|
+
update: boolean;
|
|
49
|
+
/** Remove saved rows (`access.delete`) */
|
|
50
|
+
delete: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What the viewer may do on the entity, from its `access` roles.
|
|
54
|
+
*
|
|
55
|
+
* @param entity - The child entity
|
|
56
|
+
* @param viewerRole - The viewer's role
|
|
57
|
+
*/
|
|
58
|
+
export declare function childRowsAccess(entity: AnyEntity, viewerRole: string): ChildRowsAccess;
|
|
59
|
+
/** Whether the edits hold anything a Save would write. */
|
|
60
|
+
export declare function hasChildEdits(edits: ChildRowEdits): boolean;
|
|
61
|
+
/** Pending count: edited cells + added rows + removed rows. */
|
|
62
|
+
export declare function countChildEdits(edits: ChildRowEdits): number;
|
|
63
|
+
/**
|
|
64
|
+
* Rows as shown: saved rows minus removed ones, then added rows. `base` holds
|
|
65
|
+
* them without cell changes (a DataTable's data under its pending changes),
|
|
66
|
+
* `items` with them applied.
|
|
67
|
+
*
|
|
68
|
+
* @param saved - The saved rows
|
|
69
|
+
* @param edits - The unsaved edits
|
|
70
|
+
*/
|
|
71
|
+
export declare function applyChildEdits<T extends ChildRow>(saved: readonly T[], edits: ChildRowEdits): {
|
|
72
|
+
base: T[];
|
|
73
|
+
items: T[];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Set field values of one row: a value equal to the row's base value drops the
|
|
77
|
+
* pending change (as a table cell set back to its saved value).
|
|
78
|
+
*
|
|
79
|
+
* @param edits - Current edits
|
|
80
|
+
* @param base - The row without changes (saved or added)
|
|
81
|
+
* @param patch - Field values to set
|
|
82
|
+
*/
|
|
83
|
+
export declare function setChildValues(edits: ChildRowEdits, base: ChildRow, patch: Record<string, unknown>): ChildRowEdits;
|
|
84
|
+
/**
|
|
85
|
+
* Remove rows: an added row is dropped, a saved row is marked for deletion.
|
|
86
|
+
* Their cell changes are dropped either way.
|
|
87
|
+
*
|
|
88
|
+
* @param edits - Current edits
|
|
89
|
+
* @param ids - Rows to remove
|
|
90
|
+
*/
|
|
91
|
+
export declare function removeChildRows(edits: ChildRowEdits, ids: readonly string[]): ChildRowEdits;
|
|
92
|
+
/**
|
|
93
|
+
* Settle edits against the saved rows (after a load, a refetch, a partly
|
|
94
|
+
* failed write): an added row now saved was written (its remaining changes
|
|
95
|
+
* apply to the saved row), a removed row no longer saved was deleted, a change
|
|
96
|
+
* equal to the saved value was written, a change of a row that exists nowhere
|
|
97
|
+
* is dropped. Returns `edits` itself when nothing changed.
|
|
98
|
+
*
|
|
99
|
+
* @param edits - Current edits
|
|
100
|
+
* @param saved - The saved rows (loaded)
|
|
101
|
+
*/
|
|
102
|
+
export declare function reconcileChildEdits(edits: ChildRowEdits, saved: readonly ChildRow[]): ChildRowEdits;
|
|
103
|
+
/**
|
|
104
|
+
* Edits made while a write was in flight, minus what that write submitted
|
|
105
|
+
* (written on success): submitted added rows and removals leave, changes equal
|
|
106
|
+
* to the submitted ones leave.
|
|
107
|
+
*
|
|
108
|
+
* @param current - Edits now
|
|
109
|
+
* @param submitted - Edits the write carried
|
|
110
|
+
*/
|
|
111
|
+
export declare function rebaseChildEdits(current: ChildRowEdits, submitted: ChildRowEdits): ChildRowEdits;
|
|
112
|
+
/** Only the given keys of a record. */
|
|
113
|
+
export declare function pickFields(values: Record<string, unknown>, keys: ReadonlySet<string>): Record<string, unknown>;
|
|
114
|
+
/** What a child list knows to validate and write its rows. */
|
|
115
|
+
export interface ChildRowsContext {
|
|
116
|
+
/** The child entity */
|
|
117
|
+
entity: AnyEntity;
|
|
118
|
+
/** The child's parent field and the parent record id (none: every record) */
|
|
119
|
+
parent?: {
|
|
120
|
+
field: string;
|
|
121
|
+
value: string;
|
|
122
|
+
};
|
|
123
|
+
/** 1:1 extensions of the rows, resolved for the viewer */
|
|
124
|
+
extensions?: readonly ResolvedExtension[];
|
|
125
|
+
/** Existing extension row ids: `extensionIds[rowId][key]` (absent: inserted on Save) */
|
|
126
|
+
extensionIds?: Record<string, Record<string, string>>;
|
|
127
|
+
/** Stored rows by id (as loaded, extensions merged under their key): edits are checked merged with them */
|
|
128
|
+
savedRows?: ReadonlyMap<string, ChildRow>;
|
|
129
|
+
/**
|
|
130
|
+
* Id of the extension row inserted for a record (`key` from `extensionMintKey`):
|
|
131
|
+
* the same on every call until written. Default: a new id per call.
|
|
132
|
+
*/
|
|
133
|
+
mintId?: (key: string) => string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Edits read back from a form draft (browser storage: untrusted, possibly from
|
|
137
|
+
* an older page version), kept only as far as the entity's rules allow: fields
|
|
138
|
+
* the viewer may write (extension fields `key.field` included), values of the
|
|
139
|
+
* right type, ids of record shape; added rows belong to the parent. Throws when
|
|
140
|
+
* the shape is not an edits object.
|
|
141
|
+
*
|
|
142
|
+
* @param context - The child entity, parent and extensions
|
|
143
|
+
* @param raw - The stored value
|
|
144
|
+
* @param viewerRole - The viewer's role
|
|
145
|
+
*/
|
|
146
|
+
export declare function parseChildEdits(context: ChildRowsContext, raw: unknown, viewerRole: string): ChildRowEdits;
|
|
147
|
+
/**
|
|
148
|
+
* Fields a Save would reject, by row, checked on every change. A grid is a
|
|
149
|
+
* shortcut onto the same records, so it follows the record form's rules: the CRUD
|
|
150
|
+
* rules (core/schemas crud/), as every writer and the server apply them:
|
|
151
|
+
* - added row (and a missing extension row, inserted on Save: its defaults and
|
|
152
|
+
* edits): `prepareCreate`;
|
|
153
|
+
* - edited stored row: `prepareUpdate` with the changed fields on the stored row (a
|
|
154
|
+
* draft may leave required fields empty; leaving draft checks the whole record).
|
|
155
|
+
* Extension rows the same way. Only fields the viewer can see are checked (a row
|
|
156
|
+
* read for the viewer carries only those). Only rows with edits are checked.
|
|
157
|
+
* Extension fields are reported prefixed.
|
|
158
|
+
*
|
|
159
|
+
* @param context - The child entity, parent, extensions and stored rows
|
|
160
|
+
* @param edits - The edits
|
|
161
|
+
* @param viewerRole - The viewer's role
|
|
162
|
+
* @returns `errors[rowId][field]` = kind (empty when all are valid)
|
|
163
|
+
*/
|
|
164
|
+
export declare function childEditsErrors(context: ChildRowsContext, edits: ChildRowEdits, viewerRole?: string): ChildRowErrorKinds;
|
|
165
|
+
/**
|
|
166
|
+
* The `bulkAcross` batches writing the edits: the child collection (inserts =
|
|
167
|
+
* added rows with their changes and the parent id, pre-minted ids kept;
|
|
168
|
+
* updates; deletes) and one per extension (updates of existing extension rows,
|
|
169
|
+
* inserts of missing ones; an extension of an added row depends on its insert).
|
|
170
|
+
* Each batch carries its entity's schemas.
|
|
171
|
+
*
|
|
172
|
+
* @param context - The child entity, parent, extensions and extension ids
|
|
173
|
+
* @param edits - The edits to write
|
|
174
|
+
* @param viewerRole - The viewer's role (extension defaults)
|
|
175
|
+
*/
|
|
176
|
+
export declare function childEditsBatches(context: ChildRowsContext, edits: ChildRowEdits, viewerRole?: string): BulkAcrossBatch[];
|
|
177
|
+
/**
|
|
178
|
+
* Batches of the same collection merged into one (`bulkAcross` takes one batch
|
|
179
|
+
* per collection), e.g. two child lists of one entity under different parents.
|
|
180
|
+
*
|
|
181
|
+
* @param batches - Batches to merge
|
|
182
|
+
*/
|
|
183
|
+
export declare function mergeBatches(batches: BulkAcrossBatch[]): BulkAcrossBatch[];
|
|
184
|
+
//# sourceMappingURL=childRows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childRows.d.ts","sourceRoot":"","sources":["../../src/forms/childRows.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,aAAa,EAQd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,EAAE,aAI/B,CAAC;AAiBF,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,0FAA0F;AAC1F,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,SAAS,CAAC;AAEvD,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAInF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAO7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAQ3D;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,GACjB,eAAe,CAMjB;AAWD,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAM3D;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAS5D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,EAChD,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,aAAa,GACnB;IAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,CAAA;CAAE,CAY3B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,aAAa,CAUf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,SAAS,MAAM,EAAE,GACrB,aAAa,CAef;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,SAAS,QAAQ,EAAE,GACzB,aAAa,CAsBf;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,aAAa,GACvB,aAAa,CAoBf;AAmBD,uCAAuC;AACvC,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,0DAA0D;IAC1D,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC1C,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,2GAA2G;IAC3G,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC1C;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CAClC;AAiBD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAE,OAAO,EACZ,UAAU,EAAE,MAAM,GACjB,aAAa,CAuDf;AA4BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,aAAa,EACpB,UAAU,SAAU,GACnB,kBAAkB,CAuEpB;AAmBD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,aAAa,EACpB,UAAU,SAAU,GACnB,eAAe,EAAE,CAqFnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAuB1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as p from"valibot";import{createSchemas as q,describeEntity as z,generateUUID as H,getEntityByCollection as Y,hasRoleAccess as K,isFieldVisible as Z,prepareCreate as G,prepareUpdate as Q}from"@donotdev/core";import{extensionMintKey as X}from"../stores/FormStore";import{injectScope as J}from"../utils/scopeUtils";import{extensionFieldName as B,extensionWritable as $,splitExtensionField as A,splitPatch as x,withoutLinkField as P}from"./extend";import{buildSchemaDefaults as ee}from"./utils/buildInitialValues";import{writableFields as D}from"./utils/writableFields";const M={changes:{},added:[],removed:[]},I=/^[A-Za-z0-9_-]{1,128}$/,te=p.object({changes:p.record(p.pipe(p.string(),p.regex(I)),p.record(p.string(),p.unknown())),added:p.array(p.looseObject({id:p.pipe(p.string(),p.regex(I))})),removed:p.array(p.pipe(p.string(),p.regex(I)))}),U=new WeakMap;function C(e){let t=U.get(e);return t||(t=q(e),U.set(e,t)),t}function ne(e,t){const n=z(e).fields[t]?.value;if(n?.kind!=="ref"||n.ref===void 0)throw new Error(`useChildRows: parent field "${t}" is not a reference field of entity "${e.name}".`);return n.ref}function se(e){const t=Y(e);if(!t)throw new Error(`useEntityForm: no entity defines collection "${e}" (joined child rows). Define it with defineEntity().`);return t}function W(e,t){return{create:K(t,e.access.create),update:K(t,e.access.update),delete:K(t,e.access.delete)}}function N(e,t){const n=e??null,s=t??null;return n===s?!0:typeof n!="object"||typeof s!="object"?!1:JSON.stringify(n)===JSON.stringify(s)}function E(e){return Object.keys(e.changes).length>0||e.added.length>0||e.removed.length>0}function ie(e){return Object.values(e.changes).reduce((t,n)=>t+Object.keys(n).length,0)+e.added.length+e.removed.length}function oe(e,t){if(!E(t))return{base:[...e],items:[...e]};const n=new Set(t.removed),s=[...e.filter(r=>!n.has(r.id)),...t.added],o=s.map(r=>t.changes[r.id]?{...r,...t.changes[r.id]}:r);return{base:s,items:o}}function re(e,t,n){const s={...e.changes[t.id]};for(const[r,c]of Object.entries(n))N(c,t[r])?delete s[r]:s[r]=c;const o={...e.changes};return Object.keys(s).length===0?delete o[t.id]:o[t.id]=s,{...e,changes:o}}function ce(e,t){const n=new Set(t),s=new Set(e.added.map(o=>o.id));return{changes:Object.fromEntries(Object.entries(e.changes).filter(([o])=>!n.has(o))),added:e.added.filter(o=>!n.has(o.id)),removed:[...new Set([...e.removed,...t.filter(o=>!s.has(o))])]}}function de(e,t){if(!E(e))return e;const n=new Map(t.map(a=>[a.id,a])),s=e.added.filter(a=>!n.has(a.id)),o=new Set(s.map(a=>a.id)),r=e.removed.filter(a=>n.has(a)),c={};for(const[a,b]of Object.entries(e.changes)){const j=n.get(a);if(!j){o.has(a)&&(c[a]=b);continue}const d=Object.fromEntries(Object.entries(b).filter(([u,g])=>!N(g,j[u])));Object.keys(d).length>0&&(c[a]=d)}const w={changes:c,added:s,removed:r};return JSON.stringify(w)===JSON.stringify(e)?e:w}function ae(e,t){if(e===t)return M;const n=new Set(t.added.map(c=>c.id)),s=new Set(t.removed),o={};for(const[c,w]of Object.entries(e.changes)){const a=t.changes[c]??{},b=Object.fromEntries(Object.entries(w).filter(([j,d])=>!(j in a&&N(d,a[j]))));Object.keys(b).length>0&&(o[c]=b)}const r={changes:o,added:e.added.filter(c=>!n.has(c.id)),removed:e.removed.filter(c=>!s.has(c))};return E(r)?r:M}function _(e,t,n){const s=p.safeParse(C(e).update,{...n,id:t}),o=new Set(Object.keys(n));if(!s.success)for(const r of s.issues){const c=r.path?.[0]?.key;typeof c=="string"&&o.delete(c)}return o}function F(e,t){return Object.fromEntries(Object.entries(e).filter(([n])=>t.has(n)))}const le=e=>new Set([...e].map(t=>A(t)?.[1]??t));function L(e,t){return ee(e.entity,le($(e,t,"create")))}function fe(e,t,n){const{entity:s,parent:o,extensions:r=[]}=e,c=p.parse(te,t),w=W(s,n),a=r.flatMap(i=>[...$(i,n,"create")]),b=[...a,...r.flatMap(i=>[...$(i,n,"edit")])],j=new Set([...D(s,n,"edit"),...b]),d=new Set([...D(s,n,"create"),...a]);o&&d.delete(o.field);const u=(i,m)=>{const{own:h,byKey:l}=x(m,r),k=_(s,i,h);for(const S of r){const R=l[S.key];if(R)for(const V of _(S.entity,i,R))k.add(B(S.key,V))}return F(m,k)},g=(w.create?c.added:[]).map(i=>({...u(i.id,F(i,d)),id:i.id,...o&&{[o.field]:o.value}})),y=new Set(g.map(i=>i.id)),f={};for(const[i,m]of Object.entries(c.changes)){const h=y.has(i)?d:new Set([...j].filter(k=>A(k)!==null||w.update)),l=u(i,F(m,h));Object.keys(l).length>0&&(f[i]=l)}const O=w.delete?[...new Set(c.removed.filter(i=>!y.has(i)))]:[],v={changes:f,added:g,removed:O};return E(v)?v:M}const T=new WeakMap;function he(e,t){let n=T.get(e);n||(n=new Map,T.set(e,n));let s=n.get(t);return s||(s={...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([,o])=>Z(o.visibility??"guest",t)))},n.set(t,s)),s}function ue(e,t,n="guest"){const{entity:s,extensions:o=[],savedRows:r}=e;if(!E(t))return{};const c=new Set(t.added.map(d=>d.id)),w=new Set(t.removed),a={},b=(d,u,g,y,f,O)=>{const v=C(he(d,n)),i=f===void 0?G(v,g):Q(v,{id:String(f.id??u),patch:O??{},stored:f});if(!i.ok)for(const m of i.issues){const h=m.path?.[0]?.key;if(typeof h!="string")continue;const l=m.path?.[0]?.value,k=l==null||l===""?"required":"invalid",S=y?B(y,h):h;a[u]={...a[u],[S]:a[u]?.[S]??k}}},j=(d,u,g,y)=>{for(const f of o){const O=g[f.key],v=y?void 0:u?.[f.key];ge(v)?O&&b(P(f),d,{...v,...O},f.key,v,O):(y&&f.create||O)&&b(P(f),d,{...L(f,n),...O},f.key)}};for(const d of t.added){const{id:u,...g}={...d,...t.changes[d.id]},{own:y,byKey:f}=x(g,o);b(s,u,y,""),j(u,void 0,f,!0)}for(const[d,u]of Object.entries(t.changes)){if(c.has(d)||w.has(d))continue;const g=r?.get(d);if(!g)continue;const{own:y,byKey:f}=x(u,o);Object.keys(y).length>0&&b(s,d,pe(g,y),"",g,y),j(d,g,f,!1)}return a}function pe(e,t){const n={};for(const[s,o]of Object.entries(e))A(s)||(n[s]=o);return{...n,...t}}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ye(e,t,n="guest"){const{entity:s,parent:o,extensions:r=[],extensionIds:c={},mintId:w=()=>H()}=e,a=C(s),b=new Set(t.added.map(i=>i.id)),j=new Set(t.removed),d={},u={},g=new Set,y=(i,m,h)=>{for(const l of r){const k=m[l.key],S=h?void 0:c[i]?.[l.key];if(S){if(!k)continue;if(!l.update)throw new Error(`extend.${l.key}: the viewer may not edit it.`);(u[l.key]??=[]).push({id:S,patch:k})}else if(h&&l.create||k){if(!l.create)throw new Error(`extend.${l.key}: the viewer may not create it.`);(d[l.key]??=[]).push(J({...L(l,n),...k,id:w(X(l.entity.collection,i)),[l.field]:i},l.entity.scope)),h&&g.add(l.key)}}},f=t.added.map(i=>{const{own:m,byKey:h}=x({...i,...t.changes[i.id]},r);return y(i.id,h,!0),J({...m,id:i.id,...o&&{[o.field]:o.value}},s.scope)}),O=Object.entries(t.changes).filter(([i])=>!b.has(i)&&!j.has(i)).flatMap(([i,m])=>{const{own:h,byKey:l}=x(m,r);return y(i,l,!1),Object.keys(h).length>0?[{id:i,patch:h}]:[]}),v=[];(f.length>0||O.length>0||t.removed.length>0)&&v.push({collection:s.collection,...f.length>0&&{inserts:f},...O.length>0&&{updates:O},...t.removed.length>0&&{deletes:[...t.removed]},schemas:a});for(const i of r){const m=d[i.key]??[],h=u[i.key]??[];if(m.length===0&&h.length===0)continue;const l=C(i.entity);v.push({collection:i.entity.collection,...m.length>0&&{inserts:m},...h.length>0&&{updates:h},schemas:l,...g.has(i.key)&&{dependsOn:[s.collection]}})}return v}function me(e){const t=new Map;for(const n of e){const s=t.get(n.collection);if(!s){t.set(n.collection,n);continue}const o=[...s.inserts??[],...n.inserts??[]],r=[...s.updates??[],...n.updates??[]],c=[...s.deletes??[],...n.deletes??[]],w=[...new Set([...s.dependsOn??[],...n.dependsOn??[]])];t.set(n.collection,{...s,...o.length>0&&{inserts:o},...r.length>0&&{updates:r},...c.length>0&&{deletes:c},...w.length>0&&{dependsOn:w}})}return[...t.values()]}export{M as EMPTY_CHILD_EDITS,oe as applyChildEdits,ye as childEditsBatches,ue as childEditsErrors,se as childEntityOf,W as childRowsAccess,ie as countChildEdits,E as hasChildEdits,me as mergeBatches,ne as parentCollectionOf,fe as parseChildEdits,F as pickFields,ae as rebaseChildEdits,de as reconcileChildEdits,ce as removeChildRows,C as schemasOf,re as setChildValues,D as writableFields};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { AnyEntity, EntityExtensions } from '@donotdev/core';
|
|
2
|
+
import type { RenderableField } from './utils/getFieldsForOperation';
|
|
3
|
+
/**
|
|
4
|
+
* Largest `in` list sent in one extension query: Firestore's `in` limit, the
|
|
5
|
+
* strictest of the supported adapters. Longer id lists are read in chunks.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EXTENSION_IN_CHUNK = 30;
|
|
8
|
+
/** An extension resolved for a viewer. */
|
|
9
|
+
export interface ResolvedExtension {
|
|
10
|
+
/** Name its fields are addressed under (`offer`) */
|
|
11
|
+
key: string;
|
|
12
|
+
/** The extension entity */
|
|
13
|
+
entity: AnyEntity;
|
|
14
|
+
/** Its reference field pointing at the extended record */
|
|
15
|
+
field: string;
|
|
16
|
+
/** The viewer may read it (`access.read`); otherwise it does not exist for them */
|
|
17
|
+
readable: boolean;
|
|
18
|
+
/** The viewer may insert / update it (`access.create` / `access.update`) */
|
|
19
|
+
create: boolean;
|
|
20
|
+
update: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate and resolve `extend` for a viewer. Throws on a key with `.`, a key
|
|
24
|
+
* equal to a field of the extended entity, or a `field` that is not a reference
|
|
25
|
+
* to the extended entity's collection.
|
|
26
|
+
*
|
|
27
|
+
* @param entity - The extended entity
|
|
28
|
+
* @param extend - The extensions (`undefined`: none)
|
|
29
|
+
* @param viewerRole - The viewer's role
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveExtensions(entity: AnyEntity, extend: EntityExtensions | undefined, viewerRole: string): ResolvedExtension[];
|
|
32
|
+
/** Stable signature of `extend` (memo key: callers pass object literals). */
|
|
33
|
+
export declare function extensionsSignature(extend: EntityExtensions | undefined): string;
|
|
34
|
+
/** `key.field` */
|
|
35
|
+
export declare const extensionFieldName: (key: string, field: string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* `[key, field]` of a prefixed extension field name, or `null` for a field of
|
|
38
|
+
* the extended entity itself.
|
|
39
|
+
*/
|
|
40
|
+
export declare function splitExtensionField(name: string): [key: string, field: string] | null;
|
|
41
|
+
/**
|
|
42
|
+
* The extension entity without its link field: the extended record sets it, the
|
|
43
|
+
* viewer never edits it (validation of extension values ignores it).
|
|
44
|
+
*/
|
|
45
|
+
export declare function withoutLinkField(ext: ResolvedExtension): AnyEntity;
|
|
46
|
+
/**
|
|
47
|
+
* Renderable fields of an extension for a viewer, prefixed `key.` (form fields,
|
|
48
|
+
* list columns): visible to the viewer, without its id, link field, status and
|
|
49
|
+
* backend-generated fields. Labels are bound to the extension's namespace;
|
|
50
|
+
* `scope` is the key (conditions read the extension's values). Editable and
|
|
51
|
+
* written (derived fields) only when the viewer may write the extension
|
|
52
|
+
* (`create` / `update` access).
|
|
53
|
+
*
|
|
54
|
+
* @param ext - The resolved extension
|
|
55
|
+
* @param viewerRole - The viewer's role
|
|
56
|
+
* @param operation - `'create'` when the extension row does not exist yet
|
|
57
|
+
*/
|
|
58
|
+
export declare function extensionFields(ext: ResolvedExtension, viewerRole: string, operation: 'create' | 'edit'): RenderableField[];
|
|
59
|
+
/**
|
|
60
|
+
* Extension field names (prefixed) the viewer may write for an operation: inputs
|
|
61
|
+
* editable for the viewer and derived (`editable: 'computed'`) fields, with their
|
|
62
|
+
* i18n companions (`<name>I18n`).
|
|
63
|
+
*
|
|
64
|
+
* @param ext - The resolved extension
|
|
65
|
+
* @param viewerRole - The viewer's role
|
|
66
|
+
* @param operation - `'create'` (insert of the extension) or `'edit'` (update)
|
|
67
|
+
*/
|
|
68
|
+
export declare function extensionWritable(ext: ResolvedExtension, viewerRole: string, operation: 'create' | 'edit'): Set<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Split a flat patch into the extended record's own values and each
|
|
71
|
+
* extension's values (unprefixed). Throws on a prefixed field of an unknown key.
|
|
72
|
+
*
|
|
73
|
+
* @param patch - Flat values (`price`, `offer.priceExclVat`)
|
|
74
|
+
* @param extensions - The resolved extensions
|
|
75
|
+
*/
|
|
76
|
+
export declare function splitPatch(patch: Record<string, unknown>, extensions: readonly ResolvedExtension[]): {
|
|
77
|
+
own: Record<string, unknown>;
|
|
78
|
+
byKey: Record<string, Record<string, unknown>>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Set a value at a dotted path (`offer.image`) in a copy of `values`.
|
|
82
|
+
*
|
|
83
|
+
* @param values - The values
|
|
84
|
+
* @param path - Field name, dotted for an extension field
|
|
85
|
+
* @param value - The value
|
|
86
|
+
*/
|
|
87
|
+
export declare function setAtPath(values: Record<string, unknown>, path: string, value: unknown): Record<string, unknown>;
|
|
88
|
+
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../src/forms/extend.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,QAAQ,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACjB;AAaD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,UAAU,EAAE,MAAM,GACjB,iBAAiB,EAAE,CA2BrB;AAED,6EAA6E;AAC7E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,MAAM,CAKR;AAED,kBAAkB;AAClB,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,MAC7C,CAAC;AAEpB;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAGrC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,CAalE;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,iBAAiB,EACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,QAAQ,GAAG,MAAM,GAC3B,eAAe,EAAE,CAkBnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,iBAAiB,EACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,QAAQ,GAAG,MAAM,GAC3B,GAAG,CAAC,MAAM,CAAC,CAUb;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,UAAU,EAAE,SAAS,iBAAiB,EAAE,GACvC;IAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,CAgBlF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BACKEND_GENERATED_FIELD_NAMES as b,describeEntity as w,hasRoleAccess as f}from"@donotdev/core";import{getFieldsForOperation as $}from"./utils/getFieldsForOperation";const E=30;function x(e,n){return n===e.field||n==="status"||b.includes(n)}function g(e,n,i){return n?Object.entries(n).map(([o,t])=>{if(o.includes(".")||o in e.fields)throw new Error(`extend: key "${o}" must not contain "." nor be a field of entity "${e.name}".`);const s=t.entity.fields[t.field];if(s?.type!=="reference"||s.validation?.reference!==e.collection)throw new Error(`extend.${o}: "${t.field}" is not a reference of entity "${t.entity.name}" to "${e.collection}".`);const r=f(i,t.entity.access.read);return{key:o,entity:t.entity,field:t.field,readable:r,create:r&&f(i,t.entity.access.create),update:r&&f(i,t.entity.access.update)}}):[]}function k(e){return e?Object.entries(e).map(([n,i])=>`${n}:${i.entity.collection}:${i.field}`).join("|"):""}const c=(e,n)=>`${e}.${n}`;function l(e){const n=e.indexOf(".");return n===-1?null:[e.slice(0,n),e.slice(n+1)]}function N(e){let n=d.get(e.entity);n||(n=new Map,d.set(e.entity,n));let i=n.get(e.field);if(!i){const{[e.field]:o,...t}=e.entity.fields;i={...e.entity,fields:t},n.set(e.field,i)}return i}const d=new WeakMap;function u(e,n,i){if(!e.readable)return[];const o=i==="create"?e.create:e.update;return $(e.entity,{operation:i,viewerRole:n}).filter(t=>!x(e,t.name)).map(t=>({name:c(e.key,t.name),config:{...t.config,name:c(e.key,t.name),label:(t.config.label||t.name).includes(":")?t.config.label||t.name:`${e.entity.namespace}:${t.config.label||t.name}`},editable:t.editable&&o,written:t.written&&o,scope:e.key}))}function h(e,n,i){const{fields:o}=w(e.entity);return new Set(u(e,n,i).filter(t=>t.written).flatMap(t=>{const s=o[l(t.name)?.[1]??t.name]?.companion;return s?[t.name,c(e.key,s)]:[t.name]}))}function A(e,n){const i={},o={};for(const[t,s]of Object.entries(e)){const r=l(t);if(!r){i[t]=s;continue}const[a,m]=r;if(!n.some(p=>p.key===a))throw new Error(`extend: no extension "${a}" for field "${t}".`);o[a]={...o[a],[m]:s}}return{own:i,byKey:o}}function y(e,n,i){const o=l(n);if(!o)return{...e,[n]:i};const[t,s]=o,r=e[t],a=typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{};return{...e,[t]:y(a,s,i)}}export{E as EXTENSION_IN_CHUNK,c as extensionFieldName,u as extensionFields,h as extensionWritable,k as extensionsSignature,g as resolveExtensions,y as setAtPath,l as splitExtensionField,A as splitPatch,N as withoutLinkField};
|