From 1c939dd2b4a06fbf65b1ee65e23b4ef9f7636eb2 Mon Sep 17 00:00:00 2001 From: RayenRomdhane Date: Thu, 26 Oct 2023 14:34:06 +0100 Subject: [PATCH] update changelog --- changelog.md | 13 ++++ guides/migrations/0.22.0_to_0.23.0.md | 95 +++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 guides/migrations/0.22.0_to_0.23.0.md diff --git a/changelog.md b/changelog.md index ad64719d..da1a823b 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) +## [Unrelesed] + +### Added + +- Add `itemType` and `itemDefinition` attributes in `ComponentAttributeDefinition`. +- Add tests for new attributes and validation. + +### Changed + +- Change `__typeOfValueValidation` in `ComponentAttribute`: + - Enhanced validation for Array attributes by checking element types. + - Introduced support for the `itemType` attribute in Array attributes. + ## [0.22.0] - 2023/10/19 ### Added diff --git a/guides/migrations/0.22.0_to_0.23.0.md b/guides/migrations/0.22.0_to_0.23.0.md new file mode 100644 index 00000000..fad20eca --- /dev/null +++ b/guides/migrations/0.22.0_to_0.23.0.md @@ -0,0 +1,95 @@ +# Migrate from version 0.22.0 to 0.23.0 + +## Update in `ComponentAttributeDefinition` + +- Added itemType and itemDefinition attributes to ComponentAttributeDefinition class enabling precise configuration of array elements within the component attribute. + - itemType: Type of individual array elements + - itemDefinition: Definition of the structure for individual array elements (Required if itemType is equal to 'Object') + +```js +// Before: +constructor(props = { + name: null, + type: null, + displayName: null, + description: null, + url: null, + linkType: null, + linkRef: [], + linkColor: 'black', + linkWidth: 2, + linkDashStyle: null, + containerRef: null, + required: false, + definedAttributes: [], + rules: { + values: null, + min: null, + max: null, + regex: null, + }, +}) { +} +// Old way of using it: +const attribute = new ComponentAttributeDefinition({ + name: 'myAttribute', + type: 'Array', + definedAttributes: [ + new ComponentAttributeDefinition({ + name: 'subAttribute1', + type: 'Number', + }), + new ComponentAttributeDefinition({ + name: 'subAttribute2', + type: 'Number', + }), + ], +}); + +// After: +constructor(props = { + name: null, + ... + itemDefinition: [], + itemType: null, + ... +}) { +} +// New way of using it: +const attribute = new ComponentAttributeDefinition({ + name: 'myAttribute', + type: 'Array', + itemType: 'Number', + itemDefinition: [], + definedAttributes: [ + new ComponentAttributeDefinition({ + name: 'subAttribute1', + type: 'Number', + }), + new ComponentAttributeDefinition({ + name: 'subAttribute2', + type: 'Number', + }), + ], +}); +// Case of ArrayofObjects +const attribute = new ComponentAttributeDefinition({ + name: 'myAttribute', + type: 'Array', + itemType: 'Object', + itemDefinition: [ + new ComponentAttributeDefinition({ + type: 'Object', + definedAttributes: [ + new ComponentAttributeDefinition({ + name: 'subAttribute1', + type: 'String', + }), + new ComponentAttributeDefinition({ + name: 'subAttribute2', + type: 'Number', + }), + ], + }), + ], +}); \ No newline at end of file