function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import { PisellRating } from "./PisellRating";
import { useState } from 'react';
import { Form } from 'antd';
import { HeartFilled, SmileFilled } from '@ant-design/icons';
var meta = {
  title: '表单/表单组件/PisellRating',
  component: PisellRating,
  tags: ['autodocs']
};
export default meta;
/**
 * 基础示例
 */
export var Basic = {
  args: {
    value: 3
  },
  render: function render(args) {
    var _useState = useState(args.value),
      _useState2 = _slicedToArray(_useState, 2),
      value = _useState2[0],
      setValue = _useState2[1];
    return /*#__PURE__*/React.createElement(PisellRating, _extends({}, args, {
      value: value,
      onChange: setValue
    }));
  }
};

/**
 * 只读态
 */
export var ReadOnly = {
  args: {
    mode: 'read',
    value: 4.5,
    allowHalf: true
  }
};

/**
 * 禁用态
 */
export var Disabled = {
  args: {
    disabled: true,
    value: 3
  }
};

/**
 * 半星评分
 */
export var HalfStar = {
  render: function render() {
    var _useState3 = useState(3.5),
      _useState4 = _slicedToArray(_useState3, 2),
      value = _useState4[0],
      setValue = _useState4[1];
    return /*#__PURE__*/React.createElement(PisellRating, {
      value: value,
      onChange: setValue,
      allowHalf: true
    });
  }
};

/**
 * 显示数值
 */
export var WithValue = {
  args: {
    mode: 'read',
    value: 4.2,
    allowHalf: true,
    showValue: true
  }
};

/**
 * 显示评分人数
 */
export var WithCount = {
  args: {
    mode: 'read',
    value: 4.5,
    allowHalf: true,
    showValue: true,
    showCount: true,
    reviewCount: 328
  }
};

/**
 * 带评分描述
 */
export var WithTooltips = {
  render: function render() {
    var _useState5 = useState(0),
      _useState6 = _slicedToArray(_useState5, 2),
      value = _useState6[0],
      setValue = _useState6[1];
    return /*#__PURE__*/React.createElement(PisellRating, {
      value: value,
      onChange: setValue,
      tooltips: ['很差', '差', '一般', '好', '很好']
    });
  }
};

/**
 * 自定义星星数量
 */
export var CustomCount = {
  render: function render() {
    var _useState7 = useState(6),
      _useState8 = _slicedToArray(_useState7, 2),
      value = _useState8[0],
      setValue = _useState8[1];
    return /*#__PURE__*/React.createElement(PisellRating, {
      value: value,
      onChange: setValue,
      max: 10
    });
  }
};

/**
 * 自定义图标 - 爱心
 */
export var HeartIcon = {
  render: function render() {
    var _useState9 = useState(3),
      _useState10 = _slicedToArray(_useState9, 2),
      value = _useState10[0],
      setValue = _useState10[1];
    return /*#__PURE__*/React.createElement(PisellRating, {
      value: value,
      onChange: setValue,
      character: /*#__PURE__*/React.createElement(HeartFilled, null),
      color: "#ff4d4f"
    });
  }
};

/**
 * 自定义图标 - 笑脸
 */
export var SmileIcon = {
  render: function render() {
    var _useState11 = useState(4),
      _useState12 = _slicedToArray(_useState11, 2),
      value = _useState12[0],
      setValue = _useState12[1];
    return /*#__PURE__*/React.createElement(PisellRating, {
      value: value,
      onChange: setValue,
      character: /*#__PURE__*/React.createElement(SmileFilled, null),
      color: "#52c41a"
    });
  }
};

/**
 * 商品评分场景
 */
export var ProductReview = {
  render: function render() {
    var _useState13 = useState(0),
      _useState14 = _slicedToArray(_useState13, 2),
      userRating = _useState14[0],
      setUserRating = _useState14[1];
    var averageRating = 4.2;
    var reviewCount = 328;
    return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
      style: {
        marginBottom: 24
      }
    }, /*#__PURE__*/React.createElement("div", {
      style: {
        marginBottom: 8,
        fontWeight: 'bold'
      }
    }, "\u5546\u54C1\u8BC4\u5206"), /*#__PURE__*/React.createElement(PisellRating, {
      mode: "read",
      value: averageRating,
      allowHalf: true,
      showValue: true,
      showCount: true,
      reviewCount: reviewCount
    })), /*#__PURE__*/React.createElement(Form.Item, {
      label: "\u60A8\u7684\u8BC4\u5206"
    }, /*#__PURE__*/React.createElement(PisellRating, {
      value: userRating,
      onChange: setUserRating,
      allowHalf: true,
      tooltips: ['非常差', '差', '一般', '满意', '非常满意']
    })));
  }
};

/**
 * 不同尺寸
 */
export var Sizes = {
  render: function render() {
    return /*#__PURE__*/React.createElement("div", {
      style: {
        display: 'flex',
        flexDirection: 'column',
        gap: 16
      }
    }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
      style: {
        marginRight: 8
      }
    }, "\u5C0F\uFF1A"), /*#__PURE__*/React.createElement(PisellRating, {
      value: 4,
      size: 16
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
      style: {
        marginRight: 8
      }
    }, "\u9ED8\u8BA4\uFF1A"), /*#__PURE__*/React.createElement(PisellRating, {
      value: 4,
      size: 20
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
      style: {
        marginRight: 8
      }
    }, "\u5927\uFF1A"), /*#__PURE__*/React.createElement(PisellRating, {
      value: 4,
      size: 24
    })));
  }
};