@donotdev/crud 0.2.2 → 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 +17 -16
- package/dist/CrudService.bulk.d.ts.map +1 -1
- package/dist/CrudService.bulk.js +1 -1
- package/dist/CrudService.bulkAcross.d.ts +15 -8
- 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 +22 -3
- package/dist/CrudService.cache.d.ts.map +1 -1
- package/dist/CrudService.cache.js +1 -1
- package/dist/CrudService.d.ts +42 -11
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.internal.d.ts +3 -2
- package/dist/CrudService.internal.d.ts.map +1 -1
- package/dist/CrudService.internal.js +2 -2
- package/dist/CrudService.js +1 -1
- package/dist/CrudService.mutations.d.ts +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.queries.d.ts.map +1 -1
- package/dist/CrudService.queries.js +1 -1
- package/dist/CrudService.subscriptions.d.ts.map +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/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/CrudButton.js +1 -1
- package/dist/components/CrudCard.d.ts +2 -2
- 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/DisplayFieldRenderer.d.ts +5 -2
- package/dist/components/DisplayFieldRenderer.d.ts.map +1 -1
- package/dist/components/DisplayFieldRenderer.js +1 -1
- package/dist/components/DisplayThumbnail.d.ts.map +1 -1
- package/dist/components/DisplayThumbnail.js +1 -1
- package/dist/components/EntityFilters.d.ts +26 -4
- package/dist/components/EntityFilters.d.ts.map +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.d.ts +21 -12
- 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/ControlledGeoPointField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMapField.d.ts.map +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/ControlledRichTextField.d.ts.map +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 +48 -0
- package/dist/components/controlled/fieldOptions.d.ts.map +1 -0
- package/dist/components/controlled/fieldOptions.js +1 -0
- package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.d.ts.map +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.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledDurationField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.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/ControlledRangeField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledRangeField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.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/ControlledRadioField.d.ts.map +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/controlled/types.d.ts.map +1 -1
- package/dist/components/fields/display/AvatarFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
- package/dist/components/fields/display/BadgeFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/ButtonFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/DateFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/DateFieldDisplay.js +1 -1
- package/dist/components/fields/display/DropdownDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/FileFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/FileFieldDisplay.js +1 -1
- package/dist/components/fields/display/GeoPointFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/HiddenFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/ImageFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
- package/dist/components/fields/display/MapFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/MultiDropdownDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/MultiInputTextFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/NumberFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
- package/dist/components/fields/display/PasswordFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
- package/dist/components/fields/display/PhoneNumberDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/RadioFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/RangeFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/ReferenceFieldDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
- package/dist/components/fields/display/RichTextDisplay.d.ts.map +1 -1
- package/dist/components/fields/display/TextAreaDisplay.d.ts.map +1 -1
- 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.d.ts.map +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/AvatarFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
- package/dist/components/form/fields/BadgeFieldComponent.d.ts.map +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.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/MapFieldComponent.d.ts.map +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/RatingFieldComponent.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/SwitchFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/SwitchFieldComponent.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/form/fields/internal/InlineFieldRow.d.ts +24 -0
- package/dist/components/form/fields/internal/InlineFieldRow.d.ts.map +1 -0
- package/dist/components/form/fields/internal/InlineFieldRow.js +1 -0
- package/dist/components/form/fields/internal/TiptapEditor.d.ts.map +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/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/useController.js +1 -1
- 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/translateFieldLabel.d.ts +1 -9
- package/dist/forms/utils/translateFieldLabel.d.ts.map +1 -1
- package/dist/forms/utils/translateFieldLabel.js +1 -1
- package/dist/forms/utils/validateEntity.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/useCrudPageSize.js +1 -1
- package/dist/hooks/useEntityFavorites.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/useFileUpload.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/hooks/useRelatedItems.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 +4 -2
- 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 +40 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/useBaseCrudList.d.ts.map +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.d.ts +20 -9
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudDoc.d.ts.map +1 -1
- package/dist/useCrudDoc.js +1 -1
- package/dist/useCrudList.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/imageProcessing.js +1 -1
- 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/referenceEntity.d.ts +11 -0
- package/dist/utils/referenceEntity.d.ts.map +1 -0
- package/dist/utils/referenceEntity.js +1 -0
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/utils/useRowTranslator.d.ts +21 -0
- package/dist/utils/useRowTranslator.d.ts.map +1 -0
- package/dist/utils/useRowTranslator.js +1 -0
- package/dist/workflows/defineWorkflow.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/guidelines/COMPONENTS.md +87 -10
- package/guidelines/CRUD.md +336 -17
- package/guidelines/GOTCHAS.md +19 -1
- package/package.json +8 -8
- package/dist/builtinFieldTypes.d.ts +0 -23
- package/dist/builtinFieldTypes.d.ts.map +0 -1
- package/dist/builtinFieldTypes.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toast as
|
|
1
|
+
import{toast as l}from"@donotdev/components";import{generateUUID as Q,getI18nInstance as h,handleError as U,prepareCreate as $,prepareUpdate as j}from"@donotdev/core";import{checkUniquenessFromCache as K,getItemFromListCache as F,updateListCaches as w}from"./CrudService.cache";import{auditCrud as A,decryptPiiRow as b,ensureAdapter as I,getEntityName as y,rateLimitKey as L,runSerializedMutation as _,shouldShowSuccessToast as C,withResilience as R}from"./CrudService.internal";import{CRUD_OPERATION as g}from"./types";import{entitySchemasOf as k,storedRowsFor as q,writtenOf as N}from"./CrudService.writeRules";async function v(t,e,s,O,m){const a=k(e),r=$(a,s),c=a[r.schemaKey],n=N(r,e,"addOptimistic");await I(t);const f=K(t,e,n,c);if(f)return{...n,id:f};t.security&&await t.security.checkRateLimit(L(t,e),"write");const u=`temp_${Q()}`,E={...n,id:u,_optimistic:!0};t.store&&t.store.getState().addOptimistic(e,u,E);try{if(!t.adapter)throw new Error("Adapter not initialized");const i=t.adapter,p=await R(()=>i.add(e,n,c,{readSchema:m?.readSchema})),o=p.id,d=p.data;if(w(t,e,u,null,g.DELETE),w(t,e,o,d,g.ADD),t.store&&t.store.getState().confirmOptimistic(e,u,o,d),A(t,"crud.create",e,o),C(t,m)){const S=h(),D=y(e);l("success",S.t("messages.createSuccess",{ns:"crud",entity:D}))}return d}catch(i){w(t,e,u,null,g.DELETE),t.store&&t.store.getState().rejectOptimistic(e,u);const p=U(i,{userMessage:`Failed to create ${e}`,showNotification:!0}),o=h(),d=y(e);throw l("error",o.t("messages.createError",{ns:"crud",entity:d})),p}}async function x(t,e,s,O,m,a){await I(t);const r=k(e),c=O,n=await q(t,e,[{id:s,patch:c}],r.get),f=j(r,{id:s,patch:c,stored:n.get(s)}),u=r[f.schemaKey],E=N(f,e,"updateOptimistic");t.security&&await t.security.checkRateLimit(L(t,e),"write");const i=t.getQueryClient().getQueryData(["crud",e,"get",s])??F(t,e,s),p=i?{...i,...E,_optimistic:!0}:{...E,id:s,_optimistic:!0};t.store&&i&&t.store.getState().updateOptimistic(e,s,p,i);try{if(!t.adapter)throw new Error("Adapter not initialized");const o=t.adapter,d=await _(t,e,s,()=>R(()=>o.update(e,s,E,{readSchema:a?.readSchema}))),S=b(t,u,d),{_optimistic:D,...z}=p,T={...z,...S};if(w(t,e,s,T,g.UPDATE),t.store&&t.store.getState().confirmUpdate(e,s),A(t,"crud.update",e,s),C(t,a)){const M=h(),P=y(e);l("success",M.t("messages.updateSuccess",{ns:"crud",entity:P}))}return T}catch(o){i&&w(t,e,s,i,g.UPDATE),t.store&&t.store.getState().rejectUpdate(e,s);const d=U(o,{userMessage:`Failed to update ${e}`,showNotification:!0}),S=h(),D=y(e);throw l("error",S.t("messages.updateError",{ns:"crud",entity:D})),d}}async function B(t,e,s,O){await I(t),t.security&&await t.security.checkRateLimit(L(t,e),"write");const m=t.getQueryClient().getQueryData(["crud",e,"get",s])??F(t,e,s);t.store&&m&&t.store.getState().deleteOptimistic(e,s,m);try{if(!t.adapter)throw new Error("Adapter not initialized");const a=t.adapter;if(await _(t,e,s,async()=>{await R(()=>a.delete(e,s))}),w(t,e,s,null,g.DELETE),t.store&&t.store.getState().confirmDelete(e,s),A(t,"crud.delete",e,s),t.security?.recordAnomaly?.("bulk.deletes",t.currentUserId??void 0),C(t,O)){const r=h(),c=y(e);l("success",r.t("messages.deleteSuccess",{ns:"crud",entity:c}))}}catch(a){t.store&&t.store.getState().rejectDelete(e,s);const r=U(a,{userMessage:`Failed to delete ${e}`,showNotification:!0}),c=h(),n=y(e);throw l("error",c.t("messages.deleteError",{ns:"crud",entity:n})),r}}export{v as addOptimisticImpl,B as deleteOptimisticImpl,x as updateOptimisticImpl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudService.queries.d.ts","sourceRoot":"","sources":["../src/CrudService.queries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEb,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACf,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"CrudService.queries.d.ts","sourceRoot":"","sources":["../src/CrudService.queries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEb,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAYjE;;;GAGG;AACH,w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ptPiiRow as f,ensureAdapter as u,withResilience as w}from"./CrudService.internal";import{cachedListRow as T,listQueryKey as p}from"./CrudService.cache";const l=1/0,d=new WeakMap;function L(t,e,r){if(d.has(e))return!0;const s=t.adapter?.forAccessToken?.(r);return s?(d.set(e,s),!0):!1}function q(t,e,r,s,a,o=y.LIST){return{queryKey:p(e,r),queryFn:async({client:i})=>{if(await u(t),!t.adapter)throw new Error("Adapter not initialized");const n=d.get(i)??t.adapter;return m(t,n,e,r,s,o)},staleTime:a?.staleTime??l}}async function h(t,e,r,s,a){g(e,r,a);const o=await w(()=>e.get(r,s,a));return o?f(t,a,o):null}async function m(t,e,r,s,a,o){g(e,r,a);const i=await w(()=>e.query(r,s,a,o));return{...i,items:i.items.map(n=>f(t,a,n))}}function A(t,e,r,s,a){return{queryKey:["crud",e,"get",r],queryFn:async({client:o})=>{if(await u(t),!t.adapter)throw new Error("Adapter not initialized");const i=d.get(o)??t.adapter;return h(t,i,e,r,s)},staleTime:a?.staleTime??l}}async function F(t,e,r,s,a){if(await u(t),a?.noCache)return S(t,e,r,s);t.store&&(t.store.getState().setLoading(e,!0),t.store.getState().setError(e,null));try{const o=t.getQueryClient(),i=T(o,e,r);return await o.fetchQuery({queryKey:["crud",e,"get",r],...i&&{initialData:i.data,initialDataUpdatedAt:i.updatedAt},queryFn:()=>S(t,e,r,s,!1),staleTime:a?.staleTime??l})}catch(o){const i=c(o,{userMessage:`Failed to fetch ${e}`,showNotification:!0});throw t.store&&t.store.getState().setError(e,i),i}finally{t.store&&t.store.getState().setLoading(e,!1)}}async function S(t,e,r,s,a=!0){t.store&&a&&(t.store.getState().setLoading(e,!0),t.store.getState().setError(e,null));try{if(!t.adapter)throw new Error("Adapter not initialized");return await h(t,t.adapter,e,r,s)}catch(o){const i=c(o,{userMessage:`Failed to fetch ${e}`,showNotification:!0});throw t.store&&t.store.getState().setError(e,i),i}finally{t.store&&a&&t.store.getState().setLoading(e,!1)}}async function I(t,e,r,s,a,o=y.LIST){if(await u(t),a?.noCache)return E(t,e,r,s,!0,o);t.store&&(t.store.getState().setLoading(e,!0),t.store.getState().setError(e,null));try{return await t.getQueryClient().fetchQuery({queryKey:p(e,r),queryFn:()=>E(t,e,r,s,!1,o),staleTime:a?.staleTime??l})}catch(i){const n=c(i,{userMessage:`Failed to query ${e}`,showNotification:!0});throw t.store&&t.store.getState().setError(e,n),n}finally{t.store&&t.store.getState().setLoading(e,!1)}}async function E(t,e,r,s,a=!0,o=y.LIST){t.store&&a&&(t.store.getState().setLoading(e,!0),t.store.getState().setError(e,null));try{if(!t.adapter)throw new Error("Adapter not initialized");return await m(t,t.adapter,e,r,s,o)}catch(i){const n=c(i,{userMessage:`Failed to query ${e}`,showNotification:!0});throw t.store&&t.store.getState().setError(e,n),n}finally{t.store&&a&&t.store.getState().setLoading(e,!1)}}export{L as bindRequestAccessToken,A as getDocQueryOptionsImpl,F as getImpl,q as getListQueryOptionsImpl,I as queryImpl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudService.subscriptions.d.ts","sourceRoot":"","sources":["../src/CrudService.subscriptions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEb,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"CrudService.subscriptions.d.ts","sourceRoot":"","sources":["../src/CrudService.subscriptions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEb,MAAM,gBAAgB,CAAC;AASxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EACjD,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,MAAM,IAAI,CAwBZ;AA2CD,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EAC5C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,MAAM,IAAI,CA4BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as l}from"@donotdev/core";import{assertCanAccess as p,decryptPiiRow as d,ensureAdapter as b}from"./CrudService.internal";function
|
|
1
|
+
import{handleError as l}from"@donotdev/core";import{assertCanAccess as p,decryptPiiRow as d,ensureAdapter as b}from"./CrudService.internal";import{listQueryKey as y}from"./CrudService.cache";function h(r,n,o,e,i){if(!r.adapter){let t=!1,u=null;return b(r).then(()=>{t||(u=m(r,n,o,e,i))}).catch(c=>{t||e(null,l(c))}),()=>{t=!0,u?.()}}return m(r,n,o,e,i)}function m(r,n,o,e,i){try{const t=r.adapter;return t?t.subscribe?(p(r.adapter,n,i),t.subscribe(n,o,(u,c)=>{const a=u&&d(r,i,u);a&&r.getQueryClient().setQueryData(["crud",n,"get",o],a),e(a,c)},i)):()=>{}:(e(null,new Error("Adapter not initialized")),()=>{})}catch(t){return e(null,l(t)),()=>{}}}function C(r,n,o,e,i){if(!r.adapter){let t=!1,u=null;return b(r).then(()=>{t||(u=f(r,n,o,e,i))}).catch(c=>{t||e([],l(c))}),()=>{t=!0,u?.()}}return f(r,n,o,e,i)}function f(r,n,o,e,i){try{const t=r.adapter;return t?t.subscribeToCollection?(p(r.adapter,n,i),t.subscribeToCollection(n,o,(u,c)=>{const a=u?.map(s=>d(r,i,s));a&&r.getQueryClient().setQueryData(y(n,o),s=>s?{...s,items:a}:{items:a}),e(a,c)},i)):()=>{}:(e([],new Error("Adapter not initialized")),()=>{})}catch(t){return e([],l(t)),()=>{}}}export{h as subscribeImpl,C as subscribeToCollectionImpl};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { dndevSchema, OperationSchemas, PreparedWrite } from '@donotdev/core';
|
|
2
|
+
import type { CrudServiceInternal } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The schemas the CRUD rules run on for a collection: `createSchemas` of the entity
|
|
5
|
+
* `defineEntity()` registered for it. Writers resolve them here, so callers keep passing
|
|
6
|
+
* what they always passed (a schema, or nothing).
|
|
7
|
+
*
|
|
8
|
+
* @param collection - Collection written
|
|
9
|
+
* @returns `createSchemas(entity)` (cached per entity)
|
|
10
|
+
* @throws {DoNotDevError} `internal` when no entity is defined for the collection: a write
|
|
11
|
+
* is never left unvalidated
|
|
12
|
+
*
|
|
13
|
+
* @version 0.1.0
|
|
14
|
+
* @since 0.3.0
|
|
15
|
+
* @author AMBROISE PARK Consulting
|
|
16
|
+
*/
|
|
17
|
+
export declare function entitySchemasOf(collection: string): OperationSchemas;
|
|
18
|
+
/** One update as a writer receives it. */
|
|
19
|
+
export interface UpdateRowInput {
|
|
20
|
+
id: string;
|
|
21
|
+
patch: Readonly<Record<string, unknown>>;
|
|
22
|
+
/** The stored row the patch was made against (a form's record); omitted: cache, else read */
|
|
23
|
+
stored?: Readonly<Record<string, unknown>> | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The stored row of each update that needs one (`updateNeedsStored`): the caller's,
|
|
27
|
+
* else the `get` cache, else one read (`noCache`). A list-cache row is a projection and
|
|
28
|
+
* never stands in for the record.
|
|
29
|
+
*
|
|
30
|
+
* @param self - CRUD service
|
|
31
|
+
* @param collection - Collection updated
|
|
32
|
+
* @param updates - The updates
|
|
33
|
+
* @param readSchema - `createSchemas(entity).get`
|
|
34
|
+
* @returns Stored row by id (ids whose patch needs none are absent)
|
|
35
|
+
* @throws {DoNotDevError} `not-found` when a needed row does not exist
|
|
36
|
+
*
|
|
37
|
+
* @version 0.1.0
|
|
38
|
+
* @since 0.3.0
|
|
39
|
+
* @author AMBROISE PARK Consulting
|
|
40
|
+
*/
|
|
41
|
+
export declare function storedRowsFor(self: CrudServiceInternal, collection: string, updates: readonly UpdateRowInput[], readSchema: dndevSchema<unknown>): Promise<Map<string, Readonly<Record<string, unknown>>>>;
|
|
42
|
+
/**
|
|
43
|
+
* The values a client write sends, or a throw. Unknown fields (CRUD rule 8) show the
|
|
44
|
+
* user a warning naming them; the known fields are written.
|
|
45
|
+
*
|
|
46
|
+
* @param result - The CRUD rule result
|
|
47
|
+
* @param collection - Collection written
|
|
48
|
+
* @param context - Write site, named in the error (e.g. `useCrud.update`)
|
|
49
|
+
* @returns The rule's `written`
|
|
50
|
+
* @throws {DoNotDevError} `validation-failed` with `details.issues` when the write is invalid
|
|
51
|
+
*
|
|
52
|
+
* @version 0.1.0
|
|
53
|
+
* @since 0.3.0
|
|
54
|
+
* @author AMBROISE PARK Consulting
|
|
55
|
+
*/
|
|
56
|
+
export declare function writtenOf(result: PreparedWrite, collection: string, context: string): Record<string, unknown>;
|
|
57
|
+
//# sourceMappingURL=CrudService.writeRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrudService.writeRules.d.ts","sourceRoot":"","sources":["../src/CrudService.writeRules.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAa,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAapE;AAED,0CAA0C;AAC1C,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,6FAA6F;IAC7F,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CACnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,GAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAezD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toast as w}from"@donotdev/components";import{assertWrite as l,createSchemas as g,DoNotDevError as i,getEntityByCollection as m,getI18nInstance as y,updateNeedsStored as h}from"@donotdev/core";import{getImpl as p}from"./CrudService.queries";const c=new WeakMap;function $(e){const t=m(e);if(!t)throw new i(`[dndev] "${e}": no entity defined for this collection (defineEntity); the CRUD rules need it to validate writes.`,"internal");const n=c.get(t);if(n)return n;const o=g(t);return c.set(t,o),o}async function C(e,t,n,o){const r=new Map,f=e.getQueryClient();for(const{id:s,patch:d,stored:u}of n){if(!h(d))continue;const a=u??f.getQueryData(["crud",t,"get",s])??await p(e,t,s,o,{noCache:!0});if(!a)throw new i(`${t}/${s} not found`,"not-found");r.set(s,a)}return r}function D(e,t,n){const o=l(e,`${n}(${t})`);return e.unknownKeys.length>0&&w("warning",y().t("messages.unknownFields",{ns:"crud",fields:e.unknownKeys.join(", ")})),o}export{$ as entitySchemasOf,C as storedRowsFor,D as writtenOf};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { dndevSchema, WriteSchemaForInput } from '@donotdev/core';
|
|
2
|
+
/** Write schemas a caller passes, keyed like `createSchemas(entity)`. */
|
|
3
|
+
export interface WriteSchemaSet<S> {
|
|
4
|
+
create?: S;
|
|
5
|
+
draft?: S;
|
|
6
|
+
update?: S;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The schema of one write: `schemas[writeSchemaFor(input)]`. A write whose caller
|
|
10
|
+
* passes no write schema at all is not validated (`undefined`, the bulk contract:
|
|
11
|
+
* schemas are optional). Throws when the caller passes schemas but not the one the
|
|
12
|
+
* resulting status needs (e.g. a draft row with only `create`): no other schema
|
|
13
|
+
* stands in for it.
|
|
14
|
+
*
|
|
15
|
+
* @param schemas - The schemas the caller passes
|
|
16
|
+
* @param input - Operation, sent status, stored status
|
|
17
|
+
* @param collection - Collection written (named in the error)
|
|
18
|
+
* @returns The schema, or `undefined` when the caller passes none
|
|
19
|
+
* @throws When `schemas` has entries but not the needed one
|
|
20
|
+
*
|
|
21
|
+
* @version 0.1.0
|
|
22
|
+
* @since 0.2.5
|
|
23
|
+
* @author AMBROISE PARK Consulting
|
|
24
|
+
*/
|
|
25
|
+
export declare function writeSchemaOf<S>(schemas: Readonly<WriteSchemaSet<S>>, input: WriteSchemaForInput, collection: string): S | undefined;
|
|
26
|
+
/** One update patch to validate (`validatedPatch`). */
|
|
27
|
+
export interface UpdatePatchInput<S> {
|
|
28
|
+
/** Id of the updated row */
|
|
29
|
+
id: string;
|
|
30
|
+
/** The patch as sent */
|
|
31
|
+
patch: Record<string, unknown>;
|
|
32
|
+
/** Sent status, stored status (`op: 'update'`) */
|
|
33
|
+
statusInput: WriteSchemaForInput;
|
|
34
|
+
/** The patch's write schema (`writeSchemaOf`); `undefined`: not validated */
|
|
35
|
+
schema: S | undefined;
|
|
36
|
+
/** The stored row (from the caches), `null` / `undefined` when unknown */
|
|
37
|
+
stored: Readonly<Record<string, unknown>> | null | undefined;
|
|
38
|
+
/** Validation context, named in errors */
|
|
39
|
+
context: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validates an update patch like the server functions and returns what is written:
|
|
43
|
+
* - entering a visible status (`entersVisibleStatus`, a draft published) with a known
|
|
44
|
+
* stored row: the stored row merged with the patch is checked against `update`
|
|
45
|
+
* (a required field left empty while it was a draft is rejected); keys the stored
|
|
46
|
+
* row lacks (a list projection) are not checked here, the server checks the whole row;
|
|
47
|
+
* - resulting draft: the stored row merged with the patch (`status: 'draft'`, the
|
|
48
|
+
* resulting status, so a stored status known only from the caller works) against the
|
|
49
|
+
* draft schema;
|
|
50
|
+
* - otherwise: the patch with its id against its schema.
|
|
51
|
+
* Only the sent keys are written, as parsed (`id` never). Without a schema the patch is
|
|
52
|
+
* returned as sent.
|
|
53
|
+
*
|
|
54
|
+
* @param schemas - The schemas the caller passes (`update` for the publish check)
|
|
55
|
+
* @param input - The patch, its schema, status input and stored row
|
|
56
|
+
* @returns The parsed patch (sent keys only)
|
|
57
|
+
* @throws {DoNotDevError} `validation-failed` when the patch or the published row fails
|
|
58
|
+
*
|
|
59
|
+
* @version 0.1.0
|
|
60
|
+
* @since 0.2.5
|
|
61
|
+
* @author AMBROISE PARK Consulting
|
|
62
|
+
*/
|
|
63
|
+
export declare function validatedPatch<S extends dndevSchema<unknown>>(schemas: Readonly<WriteSchemaSet<S>>, input: UpdatePatchInput<S>): Record<string, unknown>;
|
|
64
|
+
//# sourceMappingURL=CrudService.writeSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrudService.writeSchema.d.ts","sourceRoot":"","sources":["../src/CrudService.writeSchema.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,yEAAyE;AACzE,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACpC,KAAK,EAAE,mBAAmB,EAC1B,UAAU,EAAE,MAAM,GACjB,CAAC,GAAG,SAAS,CASf;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,kDAAkD;IAClD,WAAW,EAAE,mBAAmB,CAAC;IACjC,6EAA6E;IAC7E,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;IACtB,0EAA0E;IAC1E,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7D,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,EAC3D,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACpC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{entersVisibleStatus as m,validateWithSchema as u,writeSchemaFor as h}from"@donotdev/core";function p(s,a,r){const t=h(a),i=s[t];if(i)return i;const n=["create","draft","update"].filter(e=>s[e]);if(n.length!==0)throw new Error(`[dndev] "${r}": this ${a.op} (resulting status "${a.status??a.storedStatus??"none"}") is validated with schemas.${t} (createSchemas(entity).${t}); only ${n.map(e=>`schemas.${e}`).join(", ")} passed.`)}function l(s,a){const{id:r,patch:t,statusInput:i,schema:n,stored:e,context:o}=a;if(s.update&&e&&m(i)&&u(s.update,{...e,...t,id:r},o),!n)return t;const f=h(i)==="draft"?{...e,...t,status:"draft",id:r}:{...t,id:r},c=u(n,f,o);return Object.fromEntries(Object.keys(t).filter(d=>d!=="id"&&Object.hasOwn(c,d)).map(d=>[d,c[d]]))}export{l as validatedPatch,p as writeSchemaOf};
|
package/dist/CrudStore.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CrudState, CrudActions } from './types';
|
|
1
|
+
import type { CrudState, CrudActions, FilterState } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* CRUD store hook for accessing CRUD state and actions
|
|
4
4
|
*
|
|
@@ -7,4 +7,13 @@ import type { CrudState, CrudActions } from './types';
|
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
9
|
export declare const useCrudStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CrudState & CrudActions & import("@donotdev/stores").DoNotDevStore>>;
|
|
10
|
+
/**
|
|
11
|
+
* Filter state of a key for render: the stored state, else, for a URL-synced key on
|
|
12
|
+
* the client that is not seeded yet, the filters its `f_*` params encode. Reads only:
|
|
13
|
+
* never writes the store, so render can call it without notifying other components
|
|
14
|
+
* (the store is seeded by `syncFiltersFromUrl`, from an effect). Same reference while
|
|
15
|
+
* neither the store nor the URL changes (a `useSyncExternalStore` snapshot).
|
|
16
|
+
* Internal to `useCrudFilters`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function peekFilters(key: string): FilterState;
|
|
10
19
|
//# sourceMappingURL=CrudStore.d.ts.map
|
package/dist/CrudStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAEV,SAAS,EACT,WAAW,EAEX,WAAW,EAEZ,MAAM,SAAS,CAAC;AA4EjB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iIAigBvB,CAAC;AAWH;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAcpD"}
|
package/dist/CrudStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as
|
|
1
|
+
import{createDoNotDevStore as T,getEntityByCollection as v,isClient as u}from"@donotdev/core";import{OPTIMISTIC_STATUSES as g,CRUD_OPERATION as p}from"./types";import{encodeFilterParams as w,readFilterParams as D,writeFilterParams as P}from"./utils/filterUrl";const E=new Map,m=new Map,I=500;let U=!1;const d=new Set;function f(n){const l=E.get(n);return l!==void 0?l:v(n)??null}function N(n,l){const t=new URLSearchParams(location.search);P(t,n,l);const i=t.toString();i!==location.search.replace(/^\?/,"")&&history.replaceState(history.state,"",`${location.pathname}${i?`?${i}`:""}${location.hash}`)}const C={filters:{},showFavoritesOnly:!1};function a(){return{loading:!1,error:null,lastUpdated:0,optimistic:{},ui:{...C}}}const L={crudService:null,hideSuccessToasts:!1,collections:{}},h=T({name:"crud-store",createStore:(n,l)=>({...L,setCrudService:t=>{n({crudService:t})},setHideSuccessToasts:t=>{n({hideSuccessToasts:t})},setLoading:(t,i)=>{n(o=>{const e=o.collections[t]||a();return{collections:{...o.collections,[t]:{...e,loading:i}}}})},setError:(t,i)=>{n(o=>{const e=o.collections[t]||a();return{collections:{...o.collections,[t]:{...e,error:i,loading:!1}}}})},setFilters:(t,i)=>{if(n(c=>{const r=c.collections[t]||a();return{collections:{...c.collections,[t]:{...r,ui:{...r.ui,filters:i}}}}}),!u())return;const o=f(t);if(!o)return;S(),d.add(t);const e=m.get(t);e&&clearTimeout(e.timer);const s=location.pathname;m.set(t,{pathname:s,timer:setTimeout(()=>{m.delete(t),location.pathname===s&&N(i,o)},I)})},setFilterUrlSync:(t,i)=>{E.set(t,i)},syncFiltersFromUrl:t=>{if(!u())return;const i=f(t);if(!i)return;S(),d.add(t);const o=m.get(t);if(o){if(o.pathname===location.pathname)return;clearTimeout(o.timer),m.delete(t)}const e=D(location.search,i),s=l().collections[t]?.ui?.filters??{};w(e,i)!==w(s,i)&&n(c=>{const r=c.collections[t]||a();return{collections:{...c.collections,[t]:{...r,ui:{...r.ui,filters:e}}}}})},setShowFavoritesOnly:(t,i)=>{n(o=>{const e=o.collections[t]||a();return{collections:{...o.collections,[t]:{...e,ui:{...e.ui,showFavoritesOnly:i}}}}})},getFilters:t=>{const i=l().collections[t]?.ui?.filters;if(i)return i;const o=u()?f(t):null;if(!o)return{};S(),d.add(t);const e=D(location.search,o);return Object.keys(e).length>0?(n(s=>{const c=s.collections[t]||a();return{collections:{...s.collections,[t]:{...c,ui:{...c.ui,filters:e}}}}}),e):{}},getShowFavoritesOnly:t=>l().collections[t]?.ui?.showFavoritesOnly||!1,setPageSize:(t,i)=>{n(o=>{const e=o.collections[t]||a();return{collections:{...o.collections,[t]:{...e,ui:{...e.ui,pageSize:i}}}}})},getPageSize:t=>l().collections[t]?.ui?.pageSize,clearCollection:t=>{n(i=>{const{[t]:o,...e}=i.collections;return{collections:e}})},clearError:t=>{n(i=>{const o=i.collections[t];return o?{collections:{...i.collections,[t]:{...o,error:null}}}:i})},addOptimistic:(t,i,o)=>{n(e=>{const s=e.collections[t]||a();return{collections:{...e.collections,[t]:{...s,optimistic:{...s.optimistic,[i]:{tempId:i,originalData:null,optimisticData:o,status:g.PENDING,operation:p.ADD}},lastUpdated:Date.now()}}}})},confirmOptimistic:(t,i,o,e)=>{n(s=>{const c=s.collections[t];if(!c)return s;const{[i]:r,...F}=c.optimistic;return{collections:{...s.collections,[t]:{...c,optimistic:F,lastUpdated:Date.now()}}}})},rejectOptimistic:(t,i)=>{n(o=>{const e=o.collections[t];if(!e)return o;const{[i]:s,...c}=e.optimistic;return{collections:{...o.collections,[t]:{...e,optimistic:c,lastUpdated:Date.now()}}}})},updateOptimistic:(t,i,o,e)=>{n(s=>{const c=s.collections[t]||a();return{collections:{...s.collections,[t]:{...c,optimistic:{...c.optimistic,[i]:{tempId:i,originalData:e,optimisticData:o,status:g.PENDING,operation:p.UPDATE}},lastUpdated:Date.now()}}}})},confirmUpdate:(t,i)=>{n(o=>{const e=o.collections[t];if(!e)return o;const{[i]:s,...c}=e.optimistic;return{collections:{...o.collections,[t]:{...e,optimistic:c}}}})},rejectUpdate:(t,i)=>{n(o=>{const e=o.collections[t];if(!e)return o;const s=e.optimistic[i];if(!s||s.operation!==p.UPDATE)return o;const{[i]:c,...r}=e.optimistic;return{collections:{...o.collections,[t]:{...e,optimistic:r,lastUpdated:Date.now()}}}})},deleteOptimistic:(t,i,o)=>{n(e=>{const s=e.collections[t];return s?{collections:{...e.collections,[t]:{...s,optimistic:{...s.optimistic,[i]:{tempId:i,originalData:o,optimisticData:null,status:g.PENDING,operation:p.DELETE}},lastUpdated:Date.now()}}}:e})},confirmDelete:(t,i)=>{n(o=>{const e=o.collections[t];if(!e)return o;const{[i]:s,...c}=e.optimistic;return{collections:{...o.collections,[t]:{...e,optimistic:c}}}})},rejectDelete:(t,i)=>{n(o=>{const e=o.collections[t];if(!e)return o;const s=e.optimistic[i];if(!s||s.operation!==p.DELETE)return o;const{[i]:c,...r}=e.optimistic;return{collections:{...o.collections,[t]:{...e,optimistic:r,lastUpdated:Date.now()}}}})},getLoading:t=>l().collections[t]?.loading||!1,getError:t=>l().collections[t]?.error||null,isOptimistic:(t,i)=>l().collections[t]?.optimistic[i]?.status==="pending",getOptimisticStatus:(t,i)=>l().collections[t]?.optimistic[i]?.status??null,getOptimisticData:(t,i)=>l().collections[t]?.optimistic[i]?.optimisticData??null})}),O={},y=new Map;function A(n){const l=h.getState().collections[n]?.ui?.filters;if(l)return l;if(!u())return O;const t=f(n);if(!t)return O;const i=location.search,o=y.get(n);if(o&&o.search===i&&o.entity===t)return o.filters;const e=D(i,t);return y.set(n,{search:i,entity:t,filters:e}),e}function S(){if(U||!u())return;U=!0;const n=()=>{const{syncFiltersFromUrl:t}=h.getState();d.forEach(i=>t(i))},l=window.navigation;l?l.addEventListener("currententrychange",n):window.addEventListener("popstate",n)}export{A as peekFilters,h as useCrudStore};
|
package/dist/FieldRegistry.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type CustomDisplayFormatter = (value: unknown, config: EntityField, t: (k
|
|
|
32
32
|
asString?: boolean;
|
|
33
33
|
}) => string | ReactElement;
|
|
34
34
|
/** Filter UI type for EntityFilters; must match fieldTypeRegistry.FilterType */
|
|
35
|
-
export type CustomFilterType = 'text' | 'range' | 'select' | 'none' | 'address' | 'multiselect';
|
|
35
|
+
export type CustomFilterType = 'text' | 'range' | 'select' | 'none' | 'address' | 'multiselect' | 'reference';
|
|
36
36
|
/**
|
|
37
37
|
* Registration for custom field types (UI components only)
|
|
38
38
|
* Schemas must be defined in entity.validation.schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRegistry.d.ts","sourceRoot":"","sources":["../src/FieldRegistry.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,EAAE,SAAS,SAAS,GAAG,SAAS;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC7B,QA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,EACpD,YAAY,EAAE,qBAAqB,CAAC,EAAE,CAAC,GACtC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
@@ -44,8 +44,8 @@ export declare class FunctionsAdapter implements ICrudAdapter {
|
|
|
44
44
|
*/
|
|
45
45
|
private getCallableFn;
|
|
46
46
|
get<T>(collectionName: string, id: string, schema: dndevSchema<unknown>): Promise<T | null>;
|
|
47
|
-
set<T>(collectionName: string, id: string, data: T, schema: dndevSchema<T>): Promise<
|
|
48
|
-
update<T>(collectionName: string, id: string, data: Partial<T>): Promise<
|
|
47
|
+
set<T>(collectionName: string, id: string, data: T, schema: dndevSchema<T>): Promise<Record<string, unknown>>;
|
|
48
|
+
update<T>(collectionName: string, id: string, data: Partial<T>): Promise<Record<string, unknown>>;
|
|
49
49
|
delete(collectionName: string, id: string): Promise<void>;
|
|
50
50
|
/**
|
|
51
51
|
* Bulk transactional operation via the `bulk_${collection}` callable.
|
|
@@ -65,7 +65,7 @@ export declare class FunctionsAdapter implements ICrudAdapter {
|
|
|
65
65
|
* — malformed payloads fail loud locally.
|
|
66
66
|
* 4. Invokes the callable via the provider registry (identical path to
|
|
67
67
|
* `add` / `update` / `delete`).
|
|
68
|
-
* 5. Validates the server reply with {@link
|
|
68
|
+
* 5. Validates the server reply with {@link validateBulkOutcome} — a
|
|
69
69
|
* malformed server response surfaces as a clean error, never as a
|
|
70
70
|
* silent zeroed result.
|
|
71
71
|
* 6. Any other failure is wrapped via {@link wrapCrudError} to preserve
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionsAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/FunctionsAdapter.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,cAAc,EAGd,UAAU,EACV,oBAAoB,EACpB,WAAW,EAEX,YAAY,EACZ,cAAc,EACd,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AA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AI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EACxB,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,UAAU,CAAC;IA4FhB,GAAG,CAAC,CAAC,EACT,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IA0BnD,KAAK,CAAC,CAAC,EACX,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAC5B,UAAU,GAAE,cAAsC,GACjD,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAqEnC,SAAS,CAAC,CAAC,KAAK,MAAM,IAAI;IAS1B,qBAAqB,CAAC,CAAC,KAAK,MAAM,IAAI;CAQvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as h from"valibot";import{BulkCollisionError as y,BulkRequestSchema as g,
|
|
1
|
+
import*as h from"valibot";import{BulkCollisionError as y,BulkRequestSchema as g,validateBulkOutcome as A,detectBulkCollisions as m,DoNotDevError as f,getProvider as C,validateWithSchema as w,wrapCrudError as l}from"@donotdev/core";import{LIST_SCHEMA_TYPE as b}from"@donotdev/core";class E{serverSideOnly=!0;getCallable(){return C("callable")}async getCallableFn(a){const t=this.getCallable();return async s=>({data:await t.call(a,s)})}async get(a,t,s){const n=`get_${a}`,i=await this.getCallableFn(n);try{const e=(await i({id:t})).data;return s?{...w(s,e,"FunctionsAdapter.get"),id:t}:{...e,id:t}}catch(e){throw l(e,"FunctionsAdapter","get",a,t)}}async set(a,t,s,n){const i=n?w(n,s,"FunctionsAdapter.set"):s,e=`update_${a}`,d=await this.getCallableFn(e);try{return await d({id:t,payload:i})}catch(r){throw l(r,"FunctionsAdapter","set",a,t)}}async update(a,t,s){const n=`update_${a}`,i=await this.getCallableFn(n);try{return await i({id:t,payload:s})}catch(e){throw l(e,"FunctionsAdapter","update",a,t)}}async delete(a,t){const s=`delete_${a}`,n=await this.getCallableFn(s);try{await n({id:t})}catch(i){throw l(i,"FunctionsAdapter","delete",a,t)}}async bulk(a,t,s,n){const i=m({inserts:t.inserts,updates:t.updates,deletes:t.deletes});if(i.where!==null)throw new y(i.collisions,i.where);const e=t.inserts??[],d=t.updates??[],r=t.deletes??[];if(e.length===0&&d.length===0&&r.length===0)return{insertedIds:[],updatedIds:[],deletedIds:[],failed:[]};let u;try{u=h.parse(g,{inserts:e,updates:d,deletes:r})}catch(o){throw new f(`FunctionsAdapter.bulk(${a}): invalid bulk request payload`,"validation-failed",{details:{issues:o instanceof h.ValiError?o.issues:void 0},source:"validation",originalError:o instanceof Error?o:new Error(String(o))})}const F=await this.getCallableFn(`bulk_${a}`);try{const o=await F(u);if(!o.data)throw l(new Error("Bulk function returned no data"),"FunctionsAdapter","bulk",a);let p;try{p=A(u,o.data)}catch(c){throw new f(`FunctionsAdapter.bulk(${a}): malformed server response`,"validation-failed",{details:{issues:c instanceof h.ValiError?c.issues:void 0,response:o.data},source:"validation",originalError:c instanceof Error?c:new Error(String(c))})}return p}catch(o){throw o instanceof y?o:l(o,"FunctionsAdapter","bulk",a)}}async add(a,t,s){const n=s?w(s,t,"FunctionsAdapter.add"):t,i=`create_${a}`,e=await this.getCallableFn(i);try{const d=await e({payload:n});if(!d.data)throw l(new Error("Create function returned no data"),"FunctionsAdapter","add",a);return{id:d.data.id,data:d.data}}catch(d){throw l(d,"FunctionsAdapter","add",a)}}async query(a,t,s,n=b.LIST){const i=n===b.LIST_CARD?`listCard_${a}`:`list_${a}`,e={};t.where&&(e.where=t.where.map(r=>[r.field,r.operator,r.value])),t.orderBy&&(e.orderBy=t.orderBy.map(r=>[r.field,r.direction||"asc"])),t.limit&&(e.limit=t.limit),t.startAfter&&(e.startAfterId=t.startAfter);const d=await this.getCallableFn(i);try{const r=await d(e);if(!r.data)throw l(new Error("Query function returned no data"),"FunctionsAdapter","query",a);return{items:r.data.items,total:r.data.count,hasMore:r.data.hasMore,lastVisible:r.data.lastVisible}}catch(r){throw l(r,"FunctionsAdapter","query",a)}}subscribe(){return()=>{}}subscribeToCollection(){return()=>{}}}export{E as FunctionsAdapter};
|
|
@@ -44,11 +44,12 @@ export interface CrudButtonProps<T = unknown> extends Omit<ActionButtonProps<T>,
|
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
46
|
* ```tsx
|
|
47
|
-
*
|
|
47
|
+
* // `remove` = logical delete (status `deleted`); `delete` = hard delete
|
|
48
|
+
* const { remove } = useCrud(itemEntity);
|
|
48
49
|
* const user = useAuth('user');
|
|
49
50
|
*
|
|
50
51
|
* <CrudButton
|
|
51
|
-
* action={() =>
|
|
52
|
+
* action={() => remove(itemId)}
|
|
52
53
|
* user={user}
|
|
53
54
|
* loadingText="Deleting..."
|
|
54
55
|
* confirmText="Delete this item?"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudButton.d.ts","sourceRoot":"","sources":["../../src/components/CrudButton.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,gGAAgG;AAChG,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,IAAI,CACxD,iBAAiB,CAAC,CAAC,CAAC,EACpB,UAAU,CACX;IACC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"CrudButton.d.ts","sourceRoot":"","sources":["../../src/components/CrudButton.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,gGAAgG;AAChG,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,IAAI,CACxD,iBAAiB,CAAC,CAAC,CAAC,EACpB,UAAU,CACX;IACC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,iBAAS,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,EAC/B,YAAmB,EACnB,IAAI,EACJ,QAAgB,EAChB,QAAQ,EACR,GAAG,iBAAiB,EACrB,EAAE,eAAe,CAAC,CAAC,CAAC,+BAYpB;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as d}from"react/jsx-runtime";import{ActionButton as n}from"@donotdev/components";import{useCrudStore as a}from"../CrudStore";function c({requiresAuth:r=!0,user:e,disabled:t=!1,children:
|
|
1
|
+
"use client";import{jsx as d}from"react/jsx-runtime";import{ActionButton as n}from"@donotdev/components";import{useCrudStore as a}from"../CrudStore";function c({requiresAuth:r=!0,user:e,disabled:t=!1,children:o,...i}){const s=a(u=>!!u.crudService);return d(n,{...i,disabled:t||!s||r&&!e,children:o})}var l=c;export{l as default};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CrudCardProps } from '@donotdev/core';
|
|
2
2
|
/**
|
|
3
3
|
* CrudCard — Presentational card from entity + item + field slots.
|
|
4
|
-
*
|
|
4
|
+
* Navigation: `href` renders a real link (router-aware); `onClick` for other interactions.
|
|
5
5
|
*/
|
|
6
|
-
export declare function CrudCard({ item, entity, onClick, titleFields: titleFieldsProp, subtitleFields: subtitleFieldsProp, contentFields: contentFieldsProp, footerFields: footerFieldsProp, showDelete, renderActions, renderOverlay, className, }: CrudCardProps): import("react").JSX.Element;
|
|
6
|
+
export declare function CrudCard({ item, entity, onClick, href, titleFields: titleFieldsProp, subtitleFields: subtitleFieldsProp, contentFields: contentFieldsProp, footerFields: footerFieldsProp, showDelete, renderActions, renderOverlay, className, }: CrudCardProps): import("react").JSX.Element;
|
|
7
7
|
export default CrudCard;
|
|
8
8
|
//# sourceMappingURL=CrudCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudCard.d.ts","sourceRoot":"","sources":["../../src/components/CrudCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CrudCard.d.ts","sourceRoot":"","sources":["../../src/components/CrudCard.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAW,MAAM,gBAAgB,CAAC;AA2C7D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,OAAO,EACP,IAAI,EACJ,WAAW,EAAE,eAAe,EAC5B,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,gBAAgB,EAC9B,UAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,GACV,EAAE,aAAa,+BA4Mf;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as D}from"react/jsx-runtime";import{useMemo as y}from"react";import{Card as G,Stack as N,Text as j,ActionButton as H}from"@donotdev/components";import{useTranslation as P,getListCardFieldNames as J}from"@donotdev/core";import{formatValue as F}from"./DisplayFieldRenderer";import{DisplayThumbnail as L}from"./DisplayThumbnail";import{translateFieldLabel as K}from"../forms/utils/translateFieldLabel";import{useCrud as Q}from"../useCrud";function d(t){return t==="image"||t==="images"}function U(t){return y(()=>{const e=t.listCardFields;if(e&&!Array.isArray(e))return{titleFields:e.title??[],subtitleFields:e.subtitle??[],contentFields:e.content??[],footerFields:e.footer??[]};const u=J(t),m=u.filter(p=>!d(t.fields[p]?.type)),C=u.filter(p=>d(t.fields[p]?.type)),b=m.length>0?[m[0]]:[],S=[...m.slice(1,4),...C];return{titleFields:b,subtitleFields:[],contentFields:S,footerFields:[]}},[t])}function M({item:t,entity:e,onClick:u,href:m,titleFields:C,subtitleFields:b,contentFields:S,footerFields:p,showDelete:w=!1,renderActions:k,renderOverlay:V,className:E}){const{t:s}=P([e.namespace,"crud"]),{t:a}=P("crud"),h=U(e),x=C??h.titleFields,A=b??h.subtitleFields,B=S??h.contentFields,g=p??h.footerFields,c=t,T=y(()=>{if(!x?.length)return t.id??"";const r=x.filter(i=>typeof i=="string").filter(i=>!d(e.fields[i]?.type)).map(i=>{const n=e.fields[i],v=t[i],f=n?F(v,n,s,{compact:!0,asString:!0,item:c}):v;return typeof f=="string"?f:String(f??"")}).filter(Boolean),l=!Array.isArray(e.listCardFields)&&e.listCardFields?.titleSeparator!=null?e.listCardFields.titleSeparator:" ";return r.join(l)||String(t.id??"")},[t,e.fields,x,e.listCardFields,s]),I=y(()=>A?.length&&A.filter(r=>typeof r=="string").filter(r=>!d(e.fields[r]?.type)).map(r=>{const l=e.fields[r],i=t[r],n=l?F(i,l,s,{compact:!0,asString:!0,item:c}):i;return typeof n=="string"?n:String(n??"")}).filter(Boolean).join(" ")||void 0,[t,e.fields,A,s]),O=y(()=>{if(!B?.length)return null;const r=B.map(l=>{const i=e.fields[l];if(!i||i.options?.displayValue?.(t[l],c,s)===null)return null;if(d(i.type)){const n=t[l];return n==null?null:o(L,{pictures:n,alt:String(T),aspectRatio:"16/9"},l)}return D("div",{children:[o(j,{level:"small",variant:"muted",children:K(l,i,s)}),o(j,{children:F(t[l],i,s,{compact:!0,item:c})})]},l)}).filter(Boolean);return r.length>0?o(N,{direction:"column",gap:"tight",children:r}):null},[t,e.fields,B,T,s]),R=y(()=>{if(!g?.length)return;if(g.some(l=>d(e.fields[l]?.type))){const l=g.map(i=>{const n=e.fields[i];if(!n)return null;if(d(n.type)){const f=t[i];return f==null?null:o(L,{pictures:f,alt:"",aspectRatio:"1"},i)}const v=F(t[i],n,s,{compact:!0,item:c});return o("span",{children:v},i)});return o(N,{direction:"row",gap:"tight",align:"center",children:l.filter(Boolean)})}const r=g.map(l=>{const i=e.fields[l];return i?F(t[l],i,s,{compact:!0,item:c}):t[l]});return o(j,{level:"small",children:r.join(" \xB7 ")})},[t,e.fields,g,s]),q=Q(e).remove,z=k||w?D("div",{style:{display:"flex",alignItems:"flex-start",gap:"var(--gap-sm)",pointerEvents:"auto"},onClick:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),children:[k,w&&o(H,{action:async()=>{await q(t.id)},confirmText:a("delete.confirm"),confirmTitle:a("delete.title"),loadingText:a("delete.loading"),confirmLabel:a("actions.delete"),cancelLabel:a("actions.cancel"),intent:"remove","aria-label":a("actions.delete"),children:a("actions.delete")})]}):null;return o(G,{title:String(T??""),subtitle:I,content:O??void 0,footer:R,clickable:!0,elevated:!0,href:m,onClick:u?()=>u(t.id):void 0,className:E,overlay:z??void 0,overlayPosition:"top-right",fullOverlay:V??void 0})}var W=M;export{M as CrudCard,W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as k,Fragment as ht}from"react/jsx-runtime";import{X as ut}from"lucide-react";import{useState as T}from"react";import{Button as x,Calendar as St,FloatingLabel as Dt,Sheet as N,Text as M}from"@donotdev/components";import{formatDate as $t}from"@donotdev/core";function ft({label:S,fieldType:xt,value:d,onChange:D,tCrud:l,locale:O="en"}){const[F,i]=T(!1),[C,$]=T(null),W=d?typeof d=="object"&&d!==null&&"min"in d?{min:d.min||"",max:d.max||""}:{min:"",max:""}:{min:"",max:""},Y=t=>{if(!t)return"";try{const n=new Date(t+"T00:00:00");return $t(n,O)}catch{return t}},E=()=>{const t=new Date;t.setHours(0,0,0,0);const n=t.getFullYear(),g=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=`${n}-${g}-${r}`,s=new Date(t);s.setDate(s.getDate()-1);const v=s.getFullYear(),f=String(s.getMonth()+1).padStart(2,"0"),H=String(s.getDate()).padStart(2,"0"),L=`${v}-${f}-${H}`,m=new Date(t);m.setDate(m.getDate()+1);const V=m.getFullYear(),X=String(m.getMonth()+1).padStart(2,"0"),q=String(m.getDate()).padStart(2,"0"),z=`${V}-${X}-${q}`,p=new Date(t);p.setDate(p.getDate()-7);const A=p.getFullYear(),G=String(p.getMonth()+1).padStart(2,"0"),J=String(p.getDate()).padStart(2,"0"),K=`${A}-${G}-${J}`,c=new Date(t);c.setDate(c.getDate()-30);const P=c.getFullYear(),Q=String(c.getMonth()+1).padStart(2,"0"),R=String(c.getDate()).padStart(2,"0"),U=`${P}-${Q}-${R}`,h=new Date(t);h.setDate(h.getDate()+7);const Z=h.getFullYear(),_=String(h.getMonth()+1).padStart(2,"0"),tt=String(h.getDate()).padStart(2,"0"),et=`${Z}-${_}-${tt}`,u=new Date(t);u.setDate(u.getDate()+30);const at=u.getFullYear(),nt=String(u.getMonth()+1).padStart(2,"0"),rt=String(u.getDate()).padStart(2,"0"),lt=`${at}-${nt}-${rt}`,y=new Date(t.getFullYear(),t.getMonth(),1),it=y.getFullYear(),st=String(y.getMonth()+1).padStart(2,"0"),dt=String(y.getDate()).padStart(2,"0"),gt=`${it}-${st}-${dt}`,w=new Date(t.getFullYear(),t.getMonth()+1,0),ot=w.getFullYear(),mt=String(w.getMonth()+1).padStart(2,"0"),pt=String(w.getDate()).padStart(2,"0"),ct=`${ot}-${mt}-${pt}`;return{today:o,yesterday:L,tomorrow:z,last7Days:K,last30Days:U,next7Days:et,next30Days:lt,thisMonthStart:gt,thisMonthEnd:ct}},a=W,I=E(),B=!!(a?.min||a?.max),b=t=>{const n=t==="start",g=n?a?.min:a?.max;return e("div",{style:{padding:"var(--gap-md)"},children:k("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-md)"},children:[e("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-sm)"},children:(n?["today","yesterday","last7Days","last30Days","thisMonthStart"]:["today","tomorrow","next7Days","next30Days","thisMonthEnd"]).map(r=>{const o=I[r];return e(x,{variant:"outline",onClick:()=>{D({min:n?o:a?.min||"",max:n?a?.max||"":o}),i(!1)},children:l(`filter.${r}`,{defaultValue:r})},r)})}),e(St,{selected:g?new Date(g+"T00:00:00"):void 0,mode:"single",onSelect:r=>{if(!r)return;const o=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),v=String(r.getDate()).padStart(2,"0"),f=`${o}-${s}-${v}`;D({min:n?f:a?.min||"",max:n?a?.max||"":f}),i(!1)},defaultMonth:g?new Date(g+"T00:00:00"):new Date}),e(x,{variant:"ghost",display:"compact",onClick:()=>{D({min:n?"":a?.min||"",max:n&&a?.max||""}),i(!1)},children:l("filter.clear")})]})})},j=k(ht,{children:[e(N,{trigger:e(x,{variant:"ghost",onClick:()=>{$("start"),i(!0)},style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingInlineStart:"var(--gap-md)",justifyContent:"flex-start"},children:a?.min?Y(a.min):e(M,{as:"span",level:"small",variant:"muted",children:l("filter.min")})}),title:`${S} - ${l("filter.min")}`,open:F&&C==="start",onOpenChange:t=>{i(t),t||$(null)},children:b("start")}),e(M,{level:"small",variant:"muted",className:"dndev-range-input-separator",children:"\u2013"}),e(N,{trigger:e(x,{variant:"ghost",onClick:()=>{$("end"),i(!0)},style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingInlineStart:"var(--gap-md)",justifyContent:"flex-start"},children:a?.max?Y(a.max):e(M,{as:"span",level:"small",variant:"muted",children:l("filter.max")})}),title:`${S} - ${l("filter.max")}`,open:F&&C==="end",onOpenChange:t=>{i(t),t||$(null)},children:b("end")}),e("button",{type:"button",className:"dndev-inline-action-btn",onClick:()=>{D(void 0)},disabled:!B,"aria-label":l("filter.clear"),children:e(ut,{})})]});return S?e(Dt,{label:S,children:e("div",{className:"dndev-range-input",children:j})}):e("div",{className:"dndev-range-input",children:j})}export{ft as DateFilter};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @author AMBROISE PARK Consulting
|
|
9
9
|
*/
|
|
10
10
|
import type { ReactElement } from 'react';
|
|
11
|
-
import type {
|
|
11
|
+
import type { EntityField, FieldType } from '@donotdev/core';
|
|
12
12
|
import type { DisplayFormatterOptions } from '../fieldTypeRegistry';
|
|
13
13
|
/** Props for {@link DisplayFieldRenderer}, renders a field value as read-only text. */
|
|
14
14
|
export interface DisplayFieldRendererProps<T extends FieldType = FieldType> {
|
|
@@ -22,7 +22,10 @@ export interface DisplayFieldRendererProps<T extends FieldType = FieldType> {
|
|
|
22
22
|
t: (key: string, options?: Record<string, any>) => string;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Formats a value for display based on field type
|
|
25
|
+
* Formats a value for display based on field type.
|
|
26
|
+
* Text output (`asString`, `displayKey`, `displayValue`) is `formatFieldText` from
|
|
27
|
+
* `@donotdev/core`, the same text entity SEO uses; other output is the registered
|
|
28
|
+
* display formatter's (React).
|
|
26
29
|
*
|
|
27
30
|
* @param value - Field value to format
|
|
28
31
|
* @param config - Field configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/DisplayFieldRenderer.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DisplayFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/DisplayFieldRenderer.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAU1C,OAAO,KAAK,EACV,WAAW,EAEX,SAAS,EACV,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGpE,uFAAuF;AACvF,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IACxE,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,0BAA0B;IAE1B,KAAK,EAAE,GAAG,CAAC;IACX,2BAA2B;IAE3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;CAC3D;AAyDD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAEzB,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,GAChC,MAAM,GAAG,YAAY,CA0DvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,EACpE,IAAI,EACJ,MAAM,EACN,KAAK,EACL,CAAC,GACF,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAAG,YAAY,CAyC7C;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{jsx as n,Fragment as x,jsxs as m}from"react/jsx-runtime";import{Text as d,Stack as F}from"@donotdev/components";import{FIELD_TEXT_FORMATTERS as S,formatFieldText as T,getI18nInstance as f,handleError as p,isEmptyFieldValue as E}from"@donotdev/core";import{getDisplayFormatter as u}from"../fieldTypeRegistry";import{translateFieldLabel as w}from"../forms/utils";function g(e){p(new Error(`Display formatter not registered for field type: ${e.type}`),{userMessage:`Field type "${e.type}" is missing display formatter`,context:{fieldType:e.type,fieldName:e.label||"unknown",operation:"display_format",fix:"Add displayFormatter to registerBuiltinFieldType() in registerBuiltinFieldTypes.tsx"},severity:"warning"})}function y(e,t){p(t,{userMessage:`Error formatting field "${e.label||e.name}"`,context:{fieldType:e.type,fieldName:e.label||"unknown",operation:"display_format"},severity:"warning"})}function b(e,t){const o=u(e.type);if(!o){g(e);return}return(r,i,l,{locale:c})=>{try{const a=o(r,i,l,{...t,asString:!0});if(typeof a=="string")return a}catch(a){y(e,a)}const s=S[i.type];return s?s(r,i,l,{locale:c}):String(r)}}function h(e,t,o,r){r&&!r.locale?r.locale=f()?.language:r||(r={locale:f()?.language});const i=r.compact??!1,l=r.asString??!1,c=!!(t.options?.displayValue&&r.item);if(!c&&E(e))return l?"\u2014":i?n("span",{style:{color:"var(--muted-foreground)"},children:"\u2014"}):n(d,{variant:"muted",children:"\u2014"});if(l||c||t.options?.displayKey){const a=T(e,t,o,{item:r.item,locale:r.locale,formatter:b(t,r)});return a!==null?a:l?"":n(x,{})}const s=u(t.type);if(s)try{return s(e,t,o,r)}catch(a){return y(t,a),i?n("span",{style:{color:"var(--muted-foreground)"},children:String(e)}):n(d,{variant:"muted",children:String(e)})}return g(t),i?n("span",{style:{color:"var(--muted-foreground)"},children:String(e)}):n(d,{variant:"muted",children:String(e)})}function v({name:e,config:t,value:o,t:r}){const i=h(o,t,r,{compact:!1}),l=w(e,t,r);return m(F,{direction:"row",align:"baseline",style:{marginBottom:"var(--gap-sm)",padding:"var(--gap-sm)",minHeight:"38px",alignItems:"center"},children:[m(d,{variant:"muted",style:{fontSize:"var(--font-size-sm)",fontWeight:500,minWidth:"fit-content",flexShrink:0},children:[l,":"]}),n("div",{style:{flex:1,display:"flex",alignItems:"center"},children:typeof i=="string"?n(d,{children:i}):i})]})}var D=v;export{v as DisplayFieldRenderer,D as default,h as formatValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayThumbnail.d.ts","sourceRoot":"","sources":["../../src/components/DisplayThumbnail.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,mGAAmG;AACnG,MAAM,WAAW,qBAAqB;IACpC,uFAAuF;IACvF,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,6BAA6B;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;
|
|
1
|
+
{"version":3,"file":"DisplayThumbnail.d.ts","sourceRoot":"","sources":["../../src/components/DisplayThumbnail.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,mGAAmG;AACnG,MAAM,WAAW,qBAAqB;IACpC,uFAAuF;IACvF,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,6BAA6B;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAgBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,GAAQ,EACR,WAAoB,EACpB,SAAS,EACT,KAAK,GACN,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CA8BnD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a}from"react/jsx-runtime";import{handleImageError as s}from"@donotdev/components";function u(
|
|
1
|
+
"use client";import{jsx as a}from"react/jsx-runtime";import{handleImageError as s}from"@donotdev/components";function u(r){if(r==null)return null;if(typeof r=="string")return r||null;const l=Array.isArray(r)?r[0]:r;if(!l||typeof l!="object")return null;const t=l.thumbUrl??l.fullUrl;return typeof t=="string"?t:null}function o({pictures:r,alt:l="",aspectRatio:t="16/9",className:i,style:n}){const e=u(r);return e?a("div",{className:i,style:{width:"100%",aspectRatio:t,borderRadius:"var(--radius-md)",overflow:"hidden",backgroundColor:"var(--muted)",position:"relative",...n},children:a("img",{src:e,alt:l,loading:"lazy",onError:s,style:{width:"100%",height:"100%",objectFit:"cover"}})}):null}var c=o;export{o as DisplayThumbnail,c as default};
|