Skip to content

Commit 1d215b7

Browse files
committed
form label-width
1 parent 27500ba commit 1d215b7

File tree

8 files changed

+50
-2
lines changed

8 files changed

+50
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ui-form v-on:success="submit" label-width="100px">
2+
<ui-input kind="inline" label="First Name" placeholder="Please enter first name" v-model="firstName"></ui-input>
3+
<ui-input kind="inline" label="Last Name" placeholder="Please enter last name" v-model="lastName"></ui-input>
4+
<ui-button class="positive">Submit</ui-button>
5+
</ui-form>

demo/src/demo/form/inline/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component } from 'vue-typed'
2+
import * as Vue from 'vue'
3+
import { Base } from '../../base'
4+
5+
@Component({ template: require('./index.html') })
6+
export class FormInline extends Base {
7+
firstName: string = 'Budi'
8+
lastName: string = 'Adiono'
9+
10+
submit() {
11+
this.$ui.toast.success('Changes saved!')
12+
}
13+
}

demo/src/demo/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FormBasic } from './form/basic';
2+
import { FormInline } from './form/inline';
23
import { FormComponentBasic } from './form-component/basic';
34
import { FormComponentReplace } from './form-component/replace';
45
import { Input } from './input';
@@ -25,6 +26,7 @@ import { Focus } from './focus';
2526
// Main routes builder
2627
const m = [
2728
{ group: 'component/form', text: 'Form Basic', path: 'form/basic', component: FormBasic },
29+
{ group: 'component/form', text: 'Inline Form', path: 'form/inline', component: FormInline },
2830
{ group: 'decorator/form', text: 'Basic', path: 'form-component/basic', component: FormComponentBasic },
2931
{ group: 'decorator/form', text: 'Replace', path: 'form-component/replace', component: FormComponentReplace },
3032
{ group: 'component/input', text: 'Input', path: 'input', component: Input },

dist/vue-typed-ui.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ __decorate([vueTyped.Prop()], _FormBase.prototype, "validator", void 0);
306306
__decorate([vueTyped.Prop({
307307
type: Boolean
308308
})], _FormBase.prototype, "validateInline", void 0);
309+
__decorate([vueTyped.Prop({
310+
type: String
311+
})], _FormBase.prototype, "labelWidth", void 0);
309312

310313
var Form = function (_FormBase2) {
311314
inherits(Form, _FormBase2);
@@ -338,6 +341,9 @@ var Form = function (_FormBase2) {
338341
e.preventDefault();
339342
});
340343
$(this.$el).form(opt);
344+
if (this.labelWidth) {
345+
$(this.$el).find('.field.inline > label, .fields.inline > label').width(this.labelWidth);
346+
}
341347
}
342348
}, {
343349
key: 'destroyed',

doc/api.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,11 @@
475475
"type": "component",
476476
"readme": false,
477477
"props": {
478-
"validateInline": {
478+
"label-width": {
479+
"type": "string",
480+
"description": "Width of fields label when displayed 'inline'."
481+
},
482+
"validate-inline": {
479483
"type": "boolean",
480484
"description": "Show validation message inline"
481485
},

src/components/form-inputs/form/_base.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,14 @@ export abstract class _FormBase extends Vue {
2626
})
2727
validateInline: boolean
2828

29+
/**
30+
* Width of fields label when displayed 'inline'.
31+
*
32+
* @type {string}
33+
*/
34+
@Prop({
35+
type: String
36+
})
37+
labelWidth: string
38+
2939
}

src/components/form-inputs/form/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export class Form extends _FormBase {
3131

3232
$(this.$el).form(opt)
3333

34+
if (this.labelWidth) {
35+
$(this.$el).find('.field.inline > label, .fields.inline > label').width(this.labelWidth)
36+
}
37+
3438
}
3539

3640
destroyed() {

src/components/form-inputs/form/schema/props.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
"type": "any",
88
"description": "Fields validation object. See: http://semantic-ui.com/behaviors/form.html#specifying-validation-rules"
99
},
10-
"validateInline": {
10+
"validate-inline": {
1111
"type": "boolean",
1212
"description": "Show validation message inline"
13+
},
14+
"label-width": {
15+
"type": "string",
16+
"description": "Width of fields label when displayed 'inline'."
1317
}
1418
}
1519
}

0 commit comments

Comments
 (0)