Skip to content

Commit

Permalink
Merge pull request #1774 from kaliber5/glimmer-form
Browse files Browse the repository at this point in the history
Convert remaining form components to TO/Glimmer
  • Loading branch information
simonihmig committed Mar 21, 2022
2 parents 9a8037c + 84bdf1b commit 4881da8
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 119 deletions.
4 changes: 2 additions & 2 deletions addon/components/bs-form/element/errors.hbs
@@ -1,5 +1,5 @@
{{#if this.show}}
{{#if this.showMultipleErrors}}
{{#if @show}}
{{#if @showMultipleErrors}}
<div class="pre-scrollable">
{{#each @messages as |message|}}
<div class="invalid-feedback d-block">{{message}}</div>
Expand Down
39 changes: 0 additions & 39 deletions addon/components/bs-form/element/errors.js

This file was deleted.

4 changes: 2 additions & 2 deletions addon/components/bs-form/element/feedback-icon.hbs
@@ -1,3 +1,3 @@
{{#if this.show}}
<span class="form-control-feedback {{this.iconName}}" aria-hidden="true"></span>
{{#if @show}}
<span class="form-control-feedback {{@iconName}}" aria-hidden="true"></span>
{{/if}}
31 changes: 0 additions & 31 deletions addon/components/bs-form/element/feedback-icon.js

This file was deleted.

14 changes: 0 additions & 14 deletions addon/components/bs-form/element/help-text.js

This file was deleted.

13 changes: 12 additions & 1 deletion addon/components/bs-form/element/label.hbs
@@ -1,4 +1,15 @@
<label class="{{if (macroCondition (macroGetOwnConfig "isBS5")) "form-label"}} {{if this.invisibleLabel (if (macroCondition (macroGetOwnConfig "isBS5")) "visually-hidden" "sr-only")}} {{this.labelClass}} {{if this.isHorizontalAndNotCheckbox "col-form-label"}} {{if this.isCheckbox "form-check-label"}} {{if (bs-eq "switch" @controlType) (if (macroCondition (macroGetOwnConfig "isBS5")) "form-check-label" "custom-control-label")}} {{this.sizeClass}}" for={{@formElementId}}>
<label
class="
{{if (macroCondition (macroGetOwnConfig "isBS5")) "form-label"}}
{{if @invisibleLabel (if (macroCondition (macroGetOwnConfig "isBS5")) "visually-hidden" "sr-only")}}
{{@labelClass}}
{{if this.isHorizontalAndNotCheckbox "col-form-label"}}
{{if this.isCheckbox "form-check-label"}}
{{if (bs-eq "switch" @controlType) (if (macroCondition (macroGetOwnConfig "isBS5")) "form-check-label" "custom-control-label")}}
{{if this.isHorizontal (bs-size-class "col-form-label" @size)}}"
for={{@formElementId}}
...attributes
>
{{#if (has-block)}}
{{yield}}
{{/if}}
Expand Down
37 changes: 10 additions & 27 deletions addon/components/bs-form/element/label.js
@@ -1,10 +1,6 @@
import { tagName } from '@ember-decorators/component';
import { computed } from '@ember/object';
import { equal } from '@ember/object/computed';
import Component from '@ember/component';
import defaultValue from 'ember-bootstrap/utils/default-decorator';
import { isBlank } from '@ember/utils';
import Component from '@glimmer/component';
import deprecateSubclassing from 'ember-bootstrap/utils/deprecate-subclassing';
import arg from 'ember-bootstrap/utils/decorators/arg';

/**
Expand All @@ -13,7 +9,6 @@ import deprecateSubclassing from 'ember-bootstrap/utils/deprecate-subclassing';
@extends Ember.Component
@private
*/
@tagName('')
@deprecateSubclassing
export default class FormElementLabel extends Component {
/**
Expand All @@ -27,32 +22,18 @@ export default class FormElementLabel extends Component {
* @type boolean
* @public
*/
@defaultValue
invisibleLabel = false;

@computed('isHorizontal', 'isCheckbox')
get isHorizontalAndNotCheckbox() {
return this.isHorizontal && !this.isCheckbox;
}

@computed('size', 'isHorizontal')
get sizeClass() {
if (!this.isHorizontal) {
return undefined;
}
let size = this.size;
return isBlank(size) ? null : `col-form-label-${size}`;
}

/**
* [BS4 only] Property for size styling, set to 'lg', 'sm'
*
* @property size
* @type String
* @public
*/
@defaultValue
size = null;

/**
* @property formElementId
Expand Down Expand Up @@ -80,7 +61,7 @@ export default class FormElementLabel extends Component {
* @default 'vertical'
* @public
*/
@defaultValue
@arg
formLayout = 'vertical';

/**
Expand All @@ -98,7 +79,7 @@ export default class FormElementLabel extends Component {
* @default 'text'
* @public
*/
@defaultValue
@arg
controlType = 'text';

/**
Expand All @@ -108,8 +89,9 @@ export default class FormElementLabel extends Component {
* @type boolean
* @private
*/
@(equal('controlType', 'checkbox').readOnly())
isCheckbox;
get isCheckbox() {
return this.args.controlType === 'checkbox';
}

/**
* Indicates whether the form type equals `horizontal`
Expand All @@ -118,6 +100,7 @@ export default class FormElementLabel extends Component {
* @type boolean
* @private
*/
@(equal('formLayout', 'horizontal').readOnly())
isHorizontal;
get isHorizontal() {
return this.args.formLayout === 'horizontal';
}
}
8 changes: 7 additions & 1 deletion addon/components/bs-form/element/legend.hbs
@@ -1,4 +1,10 @@
<legend class="{{if this.invisibleLabel (if (macroCondition (macroGetOwnConfig "isBS5")) "visually-hidden" "sr-only")}} {{this.labelClass}} {{if this.isHorizontalAndNotCheckbox "col-form-label"}} {{this.sizeClass}}">
<legend
class="
{{if @invisibleLabel (if (macroCondition (macroGetOwnConfig "isBS5")) "visually-hidden" "sr-only")}}
{{@labelClass}}
{{if this.isHorizontalAndNotCheckbox "col-form-label"}}
{{if this.isHorizontal (bs-size-class "col-form-label" @size)}}"
>
{{#if (has-block)}}
{{yield}}
{{/if}}
Expand Down
2 changes: 0 additions & 2 deletions addon/components/bs-form/element/legend.js
@@ -1,8 +1,6 @@
import { tagName } from '@ember-decorators/component';
import FormElementLabel from 'ember-bootstrap/components/bs-form/element/label';
import deprecateSubclassing from 'ember-bootstrap/utils/deprecate-subclassing';

@tagName('')
@deprecateSubclassing
export default class FormElementLegend extends FormElementLabel {
'__ember-bootstrap_subclass' = true;
Expand Down

0 comments on commit 4881da8

Please sign in to comment.