From 58a6ff72999bf07065bebfd7ebdb4e551ef598c1 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 6 Feb 2024 04:00:20 +0400 Subject: [PATCH] Up trait doc --- docs/api/trait.md | 47 ++++++++++++++------------------ src/trait_manager/model/Trait.ts | 3 +- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/docs/api/trait.md b/docs/api/trait.md index 772771a1c..c24c79d1d 100644 --- a/docs/api/trait.md +++ b/docs/api/trait.md @@ -2,13 +2,6 @@ ## Trait - - -### Parameters - -* `prop` **TraitProperties** -* `em` **EditorModel** - ### Properties * `id` **[String][1]** Trait id, eg. `my-trait-id`. @@ -20,29 +13,29 @@ * `category` **[String][1]?** Trait category. * `changeProp` **[Boolean][2]** If `true`, the trait value is applied on the component property, otherwise, on component attributes. -### getId +## getId Get the trait id. Returns **[String][1]** -### getType +## getType Get the trait type. Returns **[String][1]** -### getName +## getName Get the trait name. Returns **[String][1]** -### getLabel +## getLabel Get the trait label. -#### Parameters +### Parameters * `opts` **[Object][3]** Options. (optional, default `{}`) @@ -50,12 +43,12 @@ Get the trait label. Returns **[String][1]** -### getValue +## getValue Get the trait value. The value is taken from component attributes by default or from properties if the trait has the `changeProp` enabled. -#### Parameters +### Parameters * `opts` **[Object][3]** Options. (optional, default `{}`) @@ -63,53 +56,53 @@ The value is taken from component attributes by default or from properties if th Returns **any** -### setValue +## setValue Update the trait value. The value is applied on component attributes by default or on properties if the trait has the `changeProp` enabled. -#### Parameters +### Parameters * `value` **any** Value of the trait. * `opts` **[Object][3]** Options. (optional, default `{}`) * `opts.partial` **[Boolean][2]?** If `true` the update won't be considered complete (not stored in UndoManager). -### getDefault +## getDefault Get default value. -### getOptions +## getOptions Get trait options. Returns **[Array][4]\** -### getOption +## getOption Get current selected option or by id. -#### Parameters +### Parameters * `id` **[String][1]?** Option id. Returns **([Object][3] | null)** -### getOptionId +## getOptionId Get the option id from the option object. -#### Parameters +### Parameters * `option` **[Object][3]** Option object Returns **[String][1]** Option id -### getOptionLabel +## getOptionLabel Get option label. -#### Parameters +### Parameters * `id` **([String][1] | [Object][3])** Option id or the option object * `opts` **[Object][3]** Options (optional, default `{}`) @@ -118,11 +111,11 @@ Get option label. Returns **[String][1]** Option label -### getCategoryLabel +## getCategoryLabel Get category label. -#### Parameters +### Parameters * `opts` **[Object][3]** Options. (optional, default `{}`) @@ -130,7 +123,7 @@ Get category label. Returns **[String][1]** -### runCommand +## runCommand Run the trait command (used on the button trait type). diff --git a/src/trait_manager/model/Trait.ts b/src/trait_manager/model/Trait.ts index 3ff1d0976..b5a3a10eb 100644 --- a/src/trait_manager/model/Trait.ts +++ b/src/trait_manager/model/Trait.ts @@ -9,7 +9,6 @@ import TraitView from '../view/TraitView'; import Traits from './Traits'; /** - * @typedef Trait * @property {String} id Trait id, eg. `my-trait-id`. * @property {String} type Trait type, defines how the trait should be rendered. Possible values: `text` (default), `number`, `select`, `checkbox`, `color`, `button` * @property {String} label The trait label to show for the rendered trait. @@ -19,6 +18,8 @@ import Traits from './Traits'; * @property {String} [category=''] Trait category. * @property {Boolean} changeProp If `true`, the trait value is applied on the component property, otherwise, on component attributes. * + * @module docsjs.Trait + * */ export default class Trait extends Model { target!: Component;