9ae668b15781c18d6b2b153f14ac9d812234f21080561b3107813f6b025059de3683198ece2f290d7f5f769dca14d3e7148f24cc0fffe67d7305a6aaecbf12 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var checkbox = require('./checkbox2.js');
  5. var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
  6. var useCheckbox = require('./composables/use-checkbox.js');
  7. var index = require('../../../hooks/use-namespace/index.js');
  8. const __default__ = vue.defineComponent({
  9. name: "ElCheckbox"
  10. });
  11. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  12. ...__default__,
  13. props: checkbox.checkboxProps,
  14. emits: checkbox.checkboxEmits,
  15. setup(__props) {
  16. const props = __props;
  17. const slots = vue.useSlots();
  18. const {
  19. inputId,
  20. isLabeledByFormItem,
  21. isChecked,
  22. isDisabled,
  23. isFocused,
  24. checkboxSize,
  25. hasOwnLabel,
  26. model,
  27. actualValue,
  28. handleChange,
  29. onClickRoot
  30. } = useCheckbox.useCheckbox(props, slots);
  31. const inputBindings = vue.computed(() => {
  32. var _a, _b, _c, _d;
  33. if (props.trueValue || props.falseValue || props.trueLabel || props.falseLabel) {
  34. return {
  35. "true-value": (_b = (_a = props.trueValue) != null ? _a : props.trueLabel) != null ? _b : true,
  36. "false-value": (_d = (_c = props.falseValue) != null ? _c : props.falseLabel) != null ? _d : false
  37. };
  38. }
  39. return {
  40. value: actualValue.value
  41. };
  42. });
  43. const ns = index.useNamespace("checkbox");
  44. const compKls = vue.computed(() => {
  45. return [
  46. ns.b(),
  47. ns.m(checkboxSize.value),
  48. ns.is("disabled", isDisabled.value),
  49. ns.is("bordered", props.border),
  50. ns.is("checked", isChecked.value)
  51. ];
  52. });
  53. const spanKls = vue.computed(() => {
  54. return [
  55. ns.e("input"),
  56. ns.is("disabled", isDisabled.value),
  57. ns.is("checked", isChecked.value),
  58. ns.is("indeterminate", props.indeterminate),
  59. ns.is("focus", isFocused.value)
  60. ];
  61. });
  62. return (_ctx, _cache) => {
  63. return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(!vue.unref(hasOwnLabel) && vue.unref(isLabeledByFormItem) ? "span" : "label"), {
  64. class: vue.normalizeClass(vue.unref(compKls)),
  65. "aria-controls": _ctx.indeterminate ? _ctx.ariaControls : null,
  66. onClick: vue.unref(onClickRoot)
  67. }, {
  68. default: vue.withCtx(() => [
  69. vue.createElementVNode("span", {
  70. class: vue.normalizeClass(vue.unref(spanKls))
  71. }, [
  72. vue.withDirectives(vue.createElementVNode("input", vue.mergeProps({
  73. id: vue.unref(inputId),
  74. "onUpdate:modelValue": ($event) => vue.isRef(model) ? model.value = $event : null,
  75. class: vue.unref(ns).e("original"),
  76. type: "checkbox",
  77. indeterminate: _ctx.indeterminate,
  78. name: _ctx.name,
  79. tabindex: _ctx.tabindex,
  80. disabled: vue.unref(isDisabled)
  81. }, vue.unref(inputBindings), {
  82. onChange: vue.unref(handleChange),
  83. onFocus: ($event) => isFocused.value = true,
  84. onBlur: ($event) => isFocused.value = false,
  85. onClick: vue.withModifiers(() => {
  86. }, ["stop"])
  87. }), null, 16, ["id", "onUpdate:modelValue", "indeterminate", "name", "tabindex", "disabled", "onChange", "onFocus", "onBlur", "onClick"]), [
  88. [vue.vModelCheckbox, vue.unref(model)]
  89. ]),
  90. vue.createElementVNode("span", {
  91. class: vue.normalizeClass(vue.unref(ns).e("inner"))
  92. }, null, 2)
  93. ], 2),
  94. vue.unref(hasOwnLabel) ? (vue.openBlock(), vue.createElementBlock("span", {
  95. key: 0,
  96. class: vue.normalizeClass(vue.unref(ns).e("label"))
  97. }, [
  98. vue.renderSlot(_ctx.$slots, "default"),
  99. !_ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
  100. vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
  101. ], 64)) : vue.createCommentVNode("v-if", true)
  102. ], 2)) : vue.createCommentVNode("v-if", true)
  103. ]),
  104. _: 3
  105. }, 8, ["class", "aria-controls", "onClick"]);
  106. };
  107. }
  108. });
  109. var Checkbox = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "checkbox.vue"]]);
  110. exports["default"] = Checkbox;
  111. //# sourceMappingURL=checkbox.js.map