index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _utils = require("../utils");
  5. var _field = require("../mixins/field");
  6. var _relation = require("../mixins/relation");
  7. var _createNamespace = (0, _utils.createNamespace)('checkbox-group'),
  8. createComponent = _createNamespace[0],
  9. bem = _createNamespace[1];
  10. var _default2 = createComponent({
  11. mixins: [(0, _relation.ParentMixin)('vanCheckbox'), _field.FieldMixin],
  12. props: {
  13. max: [Number, String],
  14. disabled: Boolean,
  15. direction: String,
  16. iconSize: [Number, String],
  17. checkedColor: String,
  18. value: {
  19. type: Array,
  20. default: function _default() {
  21. return [];
  22. }
  23. }
  24. },
  25. watch: {
  26. value: function value(val) {
  27. this.$emit('change', val);
  28. }
  29. },
  30. methods: {
  31. // @exposed-api
  32. toggleAll: function toggleAll(options) {
  33. if (options === void 0) {
  34. options = {};
  35. }
  36. if (typeof options === 'boolean') {
  37. options = {
  38. checked: options
  39. };
  40. }
  41. var _options = options,
  42. checked = _options.checked,
  43. skipDisabled = _options.skipDisabled;
  44. var children = this.children.filter(function (item) {
  45. if (item.disabled && skipDisabled) {
  46. return item.checked;
  47. }
  48. return checked != null ? checked : !item.checked;
  49. });
  50. var names = children.map(function (item) {
  51. return item.name;
  52. });
  53. this.$emit('input', names);
  54. }
  55. },
  56. render: function render() {
  57. var h = arguments[0];
  58. return h("div", {
  59. "class": bem([this.direction])
  60. }, [this.slots()]);
  61. }
  62. });
  63. exports.default = _default2;