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 { PisellPhone } from "./PisellPhone";
import React from 'react';

/**
 * PisellPhone 是一个电话号码输入/展示组件。
 * 
 * ## 功能特性
 * - 支持三种状态：只读、编辑、禁用
 * - 国家码选择（预设24个常见国家）
 * - 自动格式化
 * - 格式校验
 * - 移动端拨号
 * - 号码脱敏
 */
var meta = {
  title: '表单/表单组件/PisellPhone',
  component: PisellPhone,
  parameters: {
    layout: 'centered',
    docs: {
      description: {
        component: '电话号码输入/展示组件，支持国家码选择和自动格式化。'
      }
    }
  },
  tags: ['autodocs'],
  argTypes: {
    mode: {
      control: 'radio',
      options: ['read', 'edit'],
      description: '状态模式'
    },
    disabled: {
      control: 'boolean',
      description: '是否禁用'
    },
    countryCode: {
      control: 'text',
      description: '国家码'
    },
    showCountrySelector: {
      control: 'boolean',
      description: '显示国家码选择器'
    },
    autoFormat: {
      control: 'boolean',
      description: '自动格式化'
    },
    enableDial: {
      control: 'boolean',
      description: '启用拨号（移动端）'
    },
    enableMasking: {
      control: 'boolean',
      description: '启用脱敏'
    },
    showFlag: {
      control: 'boolean',
      description: '显示国旗图标'
    }
  }
};
export default meta;
/**
 * 基础编辑态（中国手机号）
 */
export var Basic = {
  args: {
    mode: 'edit',
    placeholder: '请输入手机号',
    countryCode: '+86'
  }
};

/**
 * 国家码选择器（显示所有国家）
 */
export var WithCountrySelector = {
  args: {
    mode: 'edit',
    showCountrySelector: true,
    placeholder: '请输入电话号码'
  }
};

/**
 * 国家码选择器（过滤显示）
 */
export var FilteredCountries = {
  args: {
    mode: 'edit',
    showCountrySelector: true,
    availableCountryCodes: ['+86', '+852', '+1', '+44'],
    placeholder: '请输入电话号码'
  }
};

/**
 * 国家码选择器（常用国家置顶）
 */
export var CommonCountriesTop = {
  args: {
    mode: 'edit',
    showCountrySelector: true,
    commonCountryCodes: ['+86', '+1'],
    placeholder: '请输入电话号码'
  }
};

/**
 * 只读态 - 格式化显示
 */
export var ReadMode = {
  args: {
    mode: 'read',
    value: '13800000000',
    countryCode: '+86'
  }
};

/**
 * 只读态 - 脱敏显示（中间）
 */
export var ReadModeMaskedMiddle = {
  args: {
    mode: 'read',
    value: '13800000000',
    countryCode: '+86',
    enableMasking: true,
    maskPattern: 'middle'
  }
};

/**
 * 只读态 - 脱敏显示（末尾）
 */
export var ReadModeMaskedLast = {
  args: {
    mode: 'read',
    value: '13800000000',
    countryCode: '+86',
    enableMasking: true,
    maskPattern: 'last'
  }
};

/**
 * 只读态 - 可拨号（移动端）
 */
export var ReadModeDialable = {
  args: {
    mode: 'read',
    value: '13800000000',
    countryCode: '+86',
    enableDial: true,
    showDialIcon: true
  }
};

/**
 * 禁用态
 */
export var Disabled = {
  args: {
    mode: 'edit',
    value: '13800000000',
    disabled: true
  }
};

/**
 * 必填校验
 */
export var Required = {
  args: {
    mode: 'edit',
    placeholder: '请输入手机号（必填）',
    required: true,
    validateTrigger: 'onBlur'
  }
};

/**
 * 格式校验
 */
export var FormatValidation = {
  args: {
    mode: 'edit',
    placeholder: '请输入手机号',
    countryCode: '+86',
    validateFormat: true,
    validateTrigger: 'onChange'
  }
};

/**
 * 美国号码
 */
export var USPhone = {
  args: {
    mode: 'edit',
    countryCode: '+1',
    showCountrySelector: false,
    placeholder: '请输入电话号码'
  }
};

/**
 * 自动格式化对比
 */
export var AutoFormatComparison = {
  render: function render() {
    return /*#__PURE__*/React.createElement("div", {
      style: {
        display: 'flex',
        flexDirection: 'column',
        gap: '20px',
        width: '400px'
      }
    }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, "\u81EA\u52A8\u683C\u5F0F\u5316\uFF08\u5F00\u542F\uFF09"), /*#__PURE__*/React.createElement(PisellPhone, {
      defaultValue: "13800000000",
      countryCode: "+86",
      autoFormat: true,
      showCountrySelector: false
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, "\u81EA\u52A8\u683C\u5F0F\u5316\uFF08\u5173\u95ED\uFF09"), /*#__PURE__*/React.createElement(PisellPhone, {
      defaultValue: "13800000000",
      countryCode: "+86",
      autoFormat: false,
      showCountrySelector: false
    })));
  }
};

/**
 * 多国号码展示
 */
export var MultiCountryDisplay = {
  render: function render() {
    return /*#__PURE__*/React.createElement("div", {
      style: {
        display: 'flex',
        flexDirection: 'column',
        gap: '16px',
        width: '400px'
      }
    }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u4E2D\u56FD (+86):"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "13800000000",
      countryCode: "+86"
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u7F8E\u56FD (+1):"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "5551234567",
      countryCode: "+1"
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u82F1\u56FD (+44):"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "2012345678",
      countryCode: "+44"
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u9999\u6E2F (+852):"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "12345678",
      countryCode: "+852"
    })));
  }
};

/**
 * 脱敏模式对比
 */
export var MaskingComparison = {
  render: function render() {
    return /*#__PURE__*/React.createElement("div", {
      style: {
        display: 'flex',
        flexDirection: 'column',
        gap: '16px',
        width: '400px'
      }
    }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u4E0D\u8131\u654F:"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "13800000000",
      enableMasking: false
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u4E2D\u95F4\u8131\u654F:"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "13800000000",
      enableMasking: true,
      maskPattern: "middle"
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "\u672B\u5C3E\u8131\u654F:"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: "13800000000",
      enableMasking: true,
      maskPattern: "last"
    })));
  }
};

/**
 * 完整功能示例
 */
export var CompleteExample = {
  render: function render() {
    var _React$useState = React.useState(''),
      _React$useState2 = _slicedToArray(_React$useState, 2),
      value = _React$useState2[0],
      setValue = _React$useState2[1];
    var _React$useState3 = React.useState('+86'),
      _React$useState4 = _slicedToArray(_React$useState3, 2),
      countryCode = _React$useState4[0],
      setCountryCode = _React$useState4[1];
    return /*#__PURE__*/React.createElement("div", {
      style: {
        width: '500px',
        display: 'flex',
        flexDirection: 'column',
        gap: '24px'
      }
    }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "\u7F16\u8F91\u6001 - \u5B8C\u6574\u529F\u80FD"), /*#__PURE__*/React.createElement(PisellPhone, {
      value: value,
      onChange: setValue,
      countryCode: countryCode,
      showCountrySelector: true,
      commonCountryCodes: ['+86', '+1', '+44'],
      onCountryCodeChange: function onCountryCodeChange(code) {
        setCountryCode(code);
        console.log('国家码变更:', code);
      },
      placeholder: "\u8BF7\u8F93\u5165\u7535\u8BDD\u53F7\u7801",
      required: true,
      validateFormat: true,
      validateTrigger: "both",
      allowClear: true,
      onValidate: function onValidate(isValid, errors) {
        console.log('校验结果:', isValid, errors);
      }
    }), /*#__PURE__*/React.createElement("p", {
      style: {
        marginTop: '8px',
        color: '#667085',
        fontSize: '12px'
      }
    }, "\u5F53\u524D\u56FD\u5BB6\u7801\uFF1A", countryCode)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "\u53EA\u8BFB\u6001 - \u683C\u5F0F\u5316\u663E\u793A"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: value || '13800000000',
      countryCode: countryCode,
      enableDial: true,
      showDialIcon: true,
      onDial: function onDial(phone) {
        console.log('拨号:', phone);
      }
    })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "\u53EA\u8BFB\u6001 - \u8131\u654F\u663E\u793A"), /*#__PURE__*/React.createElement(PisellPhone, {
      mode: "read",
      value: value || '13800000000',
      countryCode: countryCode,
      enableMasking: true,
      maskPattern: "middle"
    })));
  }
};