tdesign-mobile-vue
Version:
tdesign-mobile-vue
59 lines (55 loc) • 2.4 kB
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _typeof from '@babel/runtime/helpers/typeof';
import { toRefs, ref, watch, onMounted } from 'vue';
import { useChildSlots } from '../../shared/useChildSlots/index.js';
import '@babel/runtime/helpers/toConsumableArray';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var getOptionListBySlots = function getOptionListBySlots(nodes) {
var arr = [];
nodes === null || nodes === void 0 || nodes.forEach(function (node) {
var option = node.props;
if ((option === null || option === void 0 ? void 0 : option["check-all"]) === "" || (option === null || option === void 0 ? void 0 : option["check-all"]) === true) {
option.checkAll = true;
}
option && arr.push(option);
});
return arr;
};
var getOptions = function getOptions(props, slots) {
var _toRefs = toRefs(props),
options = _toRefs.options;
var optionList = ref([]);
watch(options, function (options2) {
if (!options2) return [];
optionList.value = options2.map(function (item) {
var r = {};
if (_typeof(item) !== "object") {
r = {
label: String(item),
value: item
};
} else {
r = _objectSpread({}, item);
r.disabled = r.disabled === void 0 ? props.disabled : r.disabled;
}
return r;
});
}, {
immediate: true
});
onMounted(function () {
var nodes = slots.default && slots.default();
if (nodes !== void 0) {
optionList.value = getOptionListBySlots(useChildSlots("t-checkbox"));
}
});
return optionList;
};
export { getOptionListBySlots, getOptions };
//# sourceMappingURL=getOptions.js.map