Browse Source
More specific the logic of DirectionUnitDependetAttributes (DUDA) extending classes and corresponding Modifier-call methods. Set the old link<CallMethod> methods @deprecated. Now you can call an DUDA-CallMethod with either: - default value (usually number): returns modifier - nothing: returns DUDA-Ext-Chain - DUDA-Ext: returns modifier Introduced mixins to extend DUDA-Extensions with (unified) returns to modifier or component methods. Rearanged, added and updated some doc Moved some of the DUDA-Ext into their own files under src/modifier/.dev-feat-component_preview v1.3.2.1
10 changed files with 589 additions and 318 deletions
@ -0,0 +1,53 @@ |
|||
/** |
|||
* @inheritdoc |
|||
* @extends Sides |
|||
*/ |
|||
class Margin extends Sides { |
|||
/** |
|||
* |
|||
* @param {number|string} defaultValue |
|||
* @param {SizeUnits} defaultUnit |
|||
*/ |
|||
constructor(defaultValue = 0, defaultUnit = SizeUnits.PIXEL) { |
|||
super("margin",defaultValue, defaultUnit); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @ATTENTION since it just increases complexity to constantly use padding and margin |
|||
* it is recommended to use padding and to stick to that as often as possible. |
|||
* Padding values take affect inside/within the element. |
|||
* @inheritdoc |
|||
* @extends Margin |
|||
* @mixes |
|||
*/ |
|||
class MarginChain extends mixinModSubChainEndings(Margin) { |
|||
/** |
|||
* |
|||
* @param {Modifier} modifier |
|||
*/ |
|||
constructor(modifier) { |
|||
super(modifier); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* |
|||
* @ATTENTION since it just increases complexity to constantly use padding and margin |
|||
* it is recommended to use padding and to stick to that as often as possible. |
|||
* Padding values take affect inside/within the element. |
|||
* @inheritdoc |
|||
* @extends MarginChain |
|||
* @mixin ModificationDefinition |
|||
*/ |
|||
class MarginChainedModifier extends mixinModSubChainComponentMethods(Margin) { |
|||
/** |
|||
* |
|||
* @param {ChainableModifier} modifier |
|||
*/ |
|||
constructor(modifier) { |
|||
super(modifier); |
|||
} |
|||
} |
@ -0,0 +1,163 @@ |
|||
class ModificationSubChain { |
|||
|
|||
_modifier; |
|||
_modMethod; |
|||
|
|||
/** |
|||
* |
|||
* @param {Modifier} modifier |
|||
* @param {string} modMethod |
|||
*/ |
|||
constructor(modifier, modMethod) { |
|||
this._modifier = modifier; |
|||
this._modMethod = modMethod; |
|||
} |
|||
|
|||
/** |
|||
* Returns the Modifier SubChain to the Modifier |
|||
* @returns {Modifier|ChainableModifier} |
|||
*/ |
|||
toModifier() { |
|||
return this._modifier[this._modMethod](this); |
|||
} |
|||
|
|||
/** |
|||
* Returns chain to the Modifier |
|||
* @returns {Modifier|ChainableModifier} |
|||
*/ |
|||
ensureModifier() { |
|||
return this.toModifier() |
|||
} |
|||
} |
|||
|
|||
|
|||
class ModificationSubChainReComp extends ModificationSubChain { |
|||
/** |
|||
* |
|||
* @param {ChainableModifier} modifier |
|||
* @param {string} modMethod |
|||
*/ |
|||
constructor(modifier) { |
|||
super(); |
|||
this._modifier = modifier; |
|||
} |
|||
|
|||
/** |
|||
* Returns chain to the component that is under modification |
|||
* @returns {Component} the Component that was (supposed to be) modified by this obj. |
|||
*/ |
|||
toComponent() { |
|||
return this._modifier[this._modMethod](this) |
|||
.toComponent(); |
|||
} |
|||
|
|||
/** |
|||
* Returns chain to the component that is under modification |
|||
* and adds the given innerComponent as children to the component. |
|||
* @param {Component|Array<Component>} innerComponent |
|||
* @returns {Component} |
|||
*/ |
|||
childContext(innerComponent) { |
|||
return this._modifier[this._modMethod](this) |
|||
.toComponent() |
|||
.childContext(innerComponent); |
|||
} |
|||
|
|||
/** |
|||
* Closes modifier chain and returns builder to define the next child of the component |
|||
* @returns {Component} |
|||
*/ |
|||
chainChild() { |
|||
return this._modifier[this._modMethod](this) |
|||
.toComponent() |
|||
.chainChild(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* Function is a mixin to add endings to a Modifier SubChain. |
|||
* Explicitly used for "link..." methods called from a Modifier, |
|||
* that is unaware of its component. |
|||
* |
|||
* @param {typeof DirectionUnitDependentAttribute} classToExtend |
|||
* @returns {typeof ModificationSubChain} |
|||
*/ |
|||
function mixinModSubChainEndings(classToExtend) { |
|||
return class extends classToExtend { |
|||
|
|||
_modifier; |
|||
|
|||
/** |
|||
* |
|||
* @param {Modifier} modifier |
|||
* @param {string} modMethod |
|||
*/ |
|||
constructor(modifier) { |
|||
super(); |
|||
this._modifier = modifier; |
|||
} |
|||
|
|||
/** |
|||
* Returns the Modifier SubChain to the Modifier |
|||
* @returns {Modifier|ChainableModifier} |
|||
*/ |
|||
toModifier() { |
|||
let tmp = this._modifier[this._modMethod]; |
|||
return this._modifier[this._modMethod](this); |
|||
} |
|||
|
|||
/** |
|||
* Returns chain to the Modifier |
|||
* @returns {Modifier|ChainableModifier} |
|||
*/ |
|||
ensureModifier() { |
|||
return this.toModifier() |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* |
|||
* Function is a mixin to add "return" methods to a Modifier SubChain. |
|||
* Explicitly used for "link..." methods called from a ChainableModifier. |
|||
* |
|||
* @param {typeof DirectionUnitDependentAttribute} classToExtend |
|||
* @returns {typeof ModificationSubChainReComp} |
|||
*/ |
|||
function mixinModSubChainComponentMethods(classToExtend) { |
|||
return class extends mixinModSubChainEndings(classToExtend) { |
|||
/** |
|||
* Returns chain to the component that is under modification |
|||
* @returns {Component} the Component that was (supposed to be) modified by this obj. |
|||
*/ |
|||
toComponent() { |
|||
return this._modifier[this._modMethod](this) |
|||
.toComponent(); |
|||
} |
|||
|
|||
/** |
|||
* Returns chain to the component that is under modification |
|||
* and adds the given innerComponent as children to the component. |
|||
* @param {Component|Array<Component>} innerComponent |
|||
* @returns {Component} |
|||
*/ |
|||
childContext(innerComponent) { |
|||
return this._modifier[this._modMethod](this) |
|||
.toComponent() |
|||
.childContext(innerComponent); |
|||
} |
|||
|
|||
/** |
|||
* Closes modifier chain and returns builder to define the next child of the component |
|||
* @returns {Component} |
|||
*/ |
|||
chainChild() { |
|||
return this._modifier[this._modMethod](this) |
|||
.toComponent() |
|||
.chainChild(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
/** |
|||
* @inheritdoc |
|||
* @extends Sides |
|||
*/ |
|||
class Padding extends Sides { |
|||
/** |
|||
* |
|||
* @param {number|string} defaultValue |
|||
* @param {SizeUnits} defaultUnit |
|||
*/ |
|||
constructor(defaultValue = 0, defaultUnit = SizeUnits.PIXEL) { |
|||
super("padding", defaultValue, defaultUnit); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @inheritdoc |
|||
* @extends Padding |
|||
*/ |
|||
class PaddingChain extends mixinModSubChainEndings(Padding){ |
|||
/** |
|||
* |
|||
* @param {Modifier} modifier |
|||
*/ |
|||
constructor(modifier) { |
|||
super(modifier); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @inheritdoc |
|||
* @extends PaddingChain |
|||
*/ |
|||
class PaddingChainedModifier extends mixinModSubChainComponentMethods(Padding){ |
|||
/** |
|||
* |
|||
* @param {Modifier} modifier |
|||
*/ |
|||
constructor(modifier) { |
|||
super(modifier); |
|||
} |
|||
} |
Loading…
Reference in new issue