@gitlab/ui
Version:
GitLab UI Components
74 lines (63 loc) • 2.21 kB
JavaScript
import GlButtonGroup from '../button_group/button_group';
import GlButton from '../button/button';
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
const validateOptionsProp = options => {
const requiredOptionPropType = {
value: ['string', 'number', 'boolean'],
disabled: ['boolean', 'undefined']
};
const optionProps = Object.keys(requiredOptionPropType);
return options.every(option => {
if (!option) {
return false;
}
return optionProps.every(name => requiredOptionPropType[name].includes(typeof option[name]));
});
};
var script = {
name: 'GlSegmentedControl',
components: {
GlButtonGroup,
GlButton
},
props: {
options: {
type: Array,
required: true,
validator: validateOptionsProp
},
value: {
type: [String, Number, Boolean],
required: true
}
}
};
/* script */
const __vue_script__ = script;
/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-button-group',_vm._l((_vm.options),function(option){return _c('gl-button',_vm._b({key:option.value,attrs:{"disabled":!!option.disabled,"selected":_vm.value === option.value},on:{"click":function($event){return _vm.$emit('input', option.value)}}},'gl-button',option.props,false),[_vm._t("button-content",function(){return [_vm._v("\n "+_vm._s(option.text)+"\n ")]},null,option)],2)}),1)};
var __vue_staticRenderFns__ = [];
/* style */
const __vue_inject_styles__ = undefined;
/* scoped */
const __vue_scope_id__ = undefined;
/* module identifier */
const __vue_module_identifier__ = undefined;
/* functional template */
const __vue_is_functional_template__ = false;
/* style inject */
/* style inject SSR */
/* style inject shadow dom */
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
__vue_inject_styles__,
__vue_script__,
__vue_scope_id__,
__vue_is_functional_template__,
__vue_module_identifier__,
false,
undefined,
undefined,
undefined
);
export { __vue_component__ as default };