Skip to content

Commit 5427139

Browse files
committed
[dropdown] settings
1 parent fa3b26e commit 5427139

File tree

7 files changed

+38
-11
lines changed

7 files changed

+38
-11
lines changed

dist/vue-typed-ui.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,8 +1459,8 @@ __decorate([vueTyped.Prop({
14591459
type: Boolean
14601460
})], _DropdownBase.prototype, "multiple", void 0);
14611461
__decorate([vueTyped.Prop({
1462-
type: String
1463-
})], _DropdownBase.prototype, "css", void 0);
1462+
type: Object
1463+
})], _DropdownBase.prototype, "settings", void 0);
14641464

14651465
var Dropdown = function (_DropdownBase2) {
14661466
inherits(Dropdown, _DropdownBase2);
@@ -1483,9 +1483,7 @@ var Dropdown = function (_DropdownBase2) {
14831483
}, {
14841484
key: 'createComponent',
14851485
value: function createComponent(ch) {
1486-
var css = 'ui selection dropdown';
1487-
if (this.css) css += ' ' + this.css;
1488-
return ch('div', { 'class': css }, [ch('input', { attrs: { type: 'hidden', name: this.name } }), ch('i', { 'class': 'dropdown icon' }), ch('div', { 'class': 'default text' }, this.placeholder), ch('div', { 'class': 'menu', 'ref': 'menu' }, this.$slots['default'])]);
1486+
return ch('div', { 'class': 'ui selection dropdown' }, [ch('input', { attrs: { type: 'hidden', name: this.name } }), ch('i', { 'class': 'dropdown icon' }), ch('div', { 'class': 'default text' }, this.placeholder), ch('div', { 'class': 'menu', 'ref': 'menu' }, this.$slots['default'])]);
14891487
}
14901488
}, {
14911489
key: 'beforeUpdate',
@@ -1524,8 +1522,7 @@ var Dropdown = function (_DropdownBase2) {
15241522
} else {
15251523
this.selectedItems = this.value;
15261524
}
1527-
// init semantic-ui dropdown
1528-
this.sui({
1525+
var settings = _.merge({
15291526
forceSelection: false,
15301527
'onChange': function onChange(arg) {
15311528
if (!self.multiple) self.selectedItems = arg;
@@ -1537,7 +1534,9 @@ var Dropdown = function (_DropdownBase2) {
15371534
'onRemove': function onRemove(val) {
15381535
self.selectedItems.splice(self.selectedItems.indexOf(val), 1);
15391536
}
1540-
});
1537+
}, this.$UI.$settings.dropdown, this.settings || {});
1538+
// init semantic-ui dropdown
1539+
this.sui(settings);
15411540
// manual force selection
15421541
$(this.$el).find('input.search').on('blur', function (e) {
15431542
var text = $(e.target).val();

doc/api.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@
472472
"type": "boolean",
473473
"description": "A selection dropdown can allow a user to search through a large list of choices."
474474
},
475+
"settings": {
476+
"type": "object",
477+
"description": "Semantic UI dropdown settings. See: https://semantic-ui.com/modules/dropdown.html#/settings"
478+
},
475479
"value": {
476480
"type": "any",
477481
"description": "v-model binding"

lib/interface.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ export interface IDropdown {
457457
*/
458458
search: boolean
459459

460+
/**
461+
* Semantic UI dropdown settings. See: https://semantic-ui.com/modules/dropdown.html#/settings
462+
*/
463+
settings: object
464+
460465
/**
461466
* v-model binding
462467
*/

lib/settings.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface Settings {
55
timeFormat?: TimeFormat
66
numeric?: NumericSettings
77
toastr?: ToastrOptions
8+
dropdown?: SemanticUI.Dropdown.Settings
89
}
910

1011
export interface NumericSettings {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ export class _DropdownBase extends Mixin(FieldBase) {
6060
})
6161
multiple: boolean
6262

63+
/**
64+
* Semantic UI dropdown settings. See: https://semantic-ui.com/modules/dropdown.html#/settings
65+
*
66+
* @type {object}
67+
*/
68+
@Prop({
69+
type: Object
70+
})
71+
settings: object
72+
6373
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { FieldBase } from '../../fields/field-base';
44
import { Util } from '../../../utils';
55
import { _DropdownBase } from './_base';
66
import { IDropdown } from '../../../../lib/interface';
7+
import * as _ from 'lodash';
8+
79

810
@Component()
911
export class Dropdown extends _DropdownBase implements IDropdown {
@@ -63,8 +65,8 @@ export class Dropdown extends _DropdownBase implements IDropdown {
6365
this.selectedItems = this.value;
6466
}
6567

66-
// init semantic-ui dropdown
67-
this.sui({
68+
69+
let settings = _.merge({
6870
forceSelection: false,
6971
'onChange': function (arg) {
7072
if (!self.multiple) self.selectedItems = arg;
@@ -76,8 +78,10 @@ export class Dropdown extends _DropdownBase implements IDropdown {
7678
'onRemove': function (val) {
7779
self.selectedItems.splice(self.selectedItems.indexOf(val), 1);
7880
}
79-
});
81+
}, this.$UI.$settings.dropdown, this.settings || {})
8082

83+
// init semantic-ui dropdown
84+
this.sui(settings);
8185

8286
// manual force selection
8387
$(this.$el).find('input.search').on('blur', (e) => {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"multiple": {
2323
"type": "boolean",
2424
"description": "A selection dropdown can allow multiple selections"
25+
},
26+
"settings": {
27+
"type": "object",
28+
"description": "Semantic UI dropdown settings. See: https://semantic-ui.com/modules/dropdown.html#/settings"
2529
}
2630
},
2731
"methods": {

0 commit comments

Comments
 (0)