hongluan-ui
Version:
Hongluan Component Library for Vue 3
147 lines (142 loc) • 6.33 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../hooks/index.js');
var index$1 = require('../../icon/index.js');
require('../../system-icon/index.js');
var checkbox = require('./checkbox.js');
require('./composables/index.js');
var index = require('../../../hooks/use-namespace/index.js');
var useCheckbox = require('./composables/use-checkbox.js');
var indeterminate = require('../../system-icon/src/indeterminate.js');
var checked = require('../../system-icon/src/checked.js');
const __default__ = vue.defineComponent({
name: "Checkbox"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: checkbox.checkboxProps,
emits: checkbox.checkboxEmits,
setup(__props) {
const props = __props;
const slots = vue.useSlots();
const { namespace } = index.useNamespace("checkbox");
const {
inputId,
isLabeledByFormItem,
isChecked,
isDisabled,
isFocused,
isCustom,
isRound,
isFill,
checkboxType,
checkboxSize,
hasOwnLabel,
model,
actualValue,
handleChange,
onClickRoot
} = useCheckbox.useCheckbox(props, slots);
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(!vue.unref(hasOwnLabel) && vue.unref(isLabeledByFormItem) ? "span" : "label"), {
class: vue.normalizeClass([
vue.unref(namespace),
vue.unref(checkboxType) || "",
vue.unref(checkboxSize) || "",
{ "round": vue.unref(isRound) },
{ "fill": vue.unref(isFill) },
{ "is-disabled": vue.unref(isDisabled) },
{ "is-checked": vue.unref(isChecked) },
{ "is-indeterminate": _ctx.indeterminate },
{ "is-focus": vue.unref(isFocused) },
{ "custom": vue.unref(isCustom) },
{ "show-label": _ctx.showLabel }
]),
"aria-controls": _ctx.indeterminate ? _ctx.controls || _ctx.ariaControls : null,
tabindex: _ctx.indeterminate ? 0 : void 0,
role: _ctx.indeterminate ? "checkbox" : void 0,
"aria-checked": _ctx.indeterminate ? "mixed" : void 0,
onClick: vue.unref(onClickRoot)
}, {
default: vue.withCtx(() => {
var _a, _b;
return [
_ctx.trueValue || _ctx.falseValue || _ctx.trueLabel || _ctx.falseLabel ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("input", {
key: 0,
id: vue.unref(inputId),
"onUpdate:modelValue": ($event) => vue.isRef(model) ? model.value = $event : null,
class: "checkbox-input",
type: "checkbox",
indeterminate: _ctx.indeterminate,
name: _ctx.name,
tabindex: _ctx.tabindex,
disabled: vue.unref(isDisabled),
"true-value": (_a = _ctx.trueValue) != null ? _a : _ctx.trueLabel,
"false-value": (_b = _ctx.falseValue) != null ? _b : _ctx.falseLabel,
onChange: vue.unref(handleChange),
onFocus: ($event) => isFocused.value = true,
onBlur: ($event) => isFocused.value = false,
onClick: vue.withModifiers(() => {
}, ["stop"])
}, null, 40, ["id", "onUpdate:modelValue", "indeterminate", "name", "tabindex", "disabled", "true-value", "false-value", "onChange", "onFocus", "onBlur", "onClick"])), [
[vue.vModelCheckbox, vue.unref(model)]
]) : vue.withDirectives((vue.openBlock(), vue.createElementBlock("input", {
key: 1,
id: vue.unref(inputId),
"onUpdate:modelValue": ($event) => vue.isRef(model) ? model.value = $event : null,
class: "checkbox-input",
type: "checkbox",
indeterminate: _ctx.indeterminate,
disabled: vue.unref(isDisabled),
value: vue.unref(actualValue),
name: _ctx.name,
tabindex: _ctx.tabindex,
onChange: vue.unref(handleChange),
onFocus: ($event) => isFocused.value = true,
onBlur: ($event) => isFocused.value = false,
onClick: vue.withModifiers(() => {
}, ["stop"])
}, null, 40, ["id", "onUpdate:modelValue", "indeterminate", "disabled", "value", "name", "tabindex", "onChange", "onFocus", "onBlur", "onClick"])), [
[vue.vModelCheckbox, vue.unref(model)]
]),
!vue.unref(isCustom) ? (vue.openBlock(), vue.createElementBlock("em", {
key: 2,
class: "checkbox-inner"
}, [
_ctx.indeterminate ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.HlIcon), {
key: 0,
class: "icon-indeterminate"
}, {
default: vue.withCtx(() => [
_ctx.indeterminate ? (vue.openBlock(), vue.createBlock(vue.unref(indeterminate["default"]), { key: 0 })) : vue.createCommentVNode("v-if", true)
]),
_: 1
})) : (vue.openBlock(), vue.createBlock(vue.unref(index$1.HlIcon), {
key: 1,
class: "icon-checked"
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(checked["default"]))
]),
_: 1
}))
])) : vue.createCommentVNode("v-if", true),
vue.unref(isCustom) ? vue.renderSlot(_ctx.$slots, "default", { key: 3 }) : vue.unref(hasOwnLabel) && _ctx.showLabel ? (vue.openBlock(), vue.createElementBlock("span", {
key: 4,
class: "checkbox-label"
}, [
vue.renderSlot(_ctx.$slots, "default"),
!_ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
], 2112)) : vue.createCommentVNode("v-if", true)
])) : vue.createCommentVNode("v-if", true)
];
}),
_: 3
}, 8, ["class", "aria-controls", "tabindex", "role", "aria-checked", "onClick"]);
};
}
});
exports["default"] = _sfc_main;
//# sourceMappingURL=checkbox2.js.map