import React from 'react';
import { PisellHierarchicalSummaryList } from "./PisellHierarchicalSummaryList";
var demoItems = [{
  key: 'l1',
  label: 'Label',
  value: /*#__PURE__*/React.createElement("span", {
    style: {
      color: '#1570EF'
    }
  }, "Value"),
  children: [{
    key: 'l2',
    label: 'Label',
    value: 'Value',
    children: [{
      key: 'l3-1',
      label: 'Label',
      itemsCount: 'N items',
      value: 'Value'
    }, {
      key: 'l3-2',
      label: 'Label',
      infoTooltip: 'Tooltip',
      value: 'Value'
    }, {
      key: 'l3-3',
      label: 'Label',
      value: 'Value'
    }, {
      key: 'l3-4',
      label: 'Label',
      itemsCount: '2 items',
      value: 'Value',
      children: [{
        key: 'l4-1',
        label: /*#__PURE__*/React.createElement("span", {
          style: {
            color: '#667085'
          }
        }, "\u2022 Label"),
        value: /*#__PURE__*/React.createElement("span", {
          style: {
            color: '#667085'
          }
        }, "Value")
      }, {
        key: 'l4-2',
        label: /*#__PURE__*/React.createElement("span", {
          style: {
            color: '#667085'
          }
        }, "\u2022 Label"),
        value: /*#__PURE__*/React.createElement("span", {
          style: {
            color: '#667085'
          }
        }, "Value")
      }]
    }]
  }]
}];
var meta = {
  title: 'Data Display/PisellHierarchicalSummaryList',
  component: PisellHierarchicalSummaryList,
  tags: ['autodocs'],
  argTypes: {
    defaultExpandedLevel: {
      control: 'number',
      description: '默认展开层级（非受控初始化）'
    },
    accordion: {
      control: 'boolean',
      description: '手风琴模式（同级仅一个展开）'
    },
    maxRenderLevel: {
      control: 'number',
      description: '最大渲染层级'
    },
    maxExpandLevel: {
      control: 'number',
      description: '最大可展开层级'
    },
    indent: {
      control: 'number',
      description: '缩进（px）'
    },
    rowGap: {
      control: 'number',
      description: '行间距（px）'
    }
  }
};
export default meta;
export var Default = {
  args: {
    items: demoItems,
    defaultExpandedLevel: 2
  }
};
export var Accordion = {
  args: {
    items: demoItems,
    defaultExpandedLevel: 3,
    accordion: true
  }
};
export var MaxExpandLevel = {
  args: {
    items: demoItems,
    defaultExpandedLevel: 5,
    maxExpandLevel: 2
  }
};
export var AggregateSum = {
  args: {
    items: [{
      key: 'sum-root',
      label: 'Total',
      children: [{
        key: 'a',
        label: 'A',
        value: 10
      }, {
        key: 'b',
        label: 'B',
        value: 20
      }, {
        key: 'c',
        label: 'C',
        value: 5,
        children: [{
          key: 'c-1',
          label: 'C-1',
          value: 2
        }]
      }]
    }],
    defaultExpandedLevel: 2,
    aggregate: {
      mode: 'sum',
      format: function format(sum) {
        return "$".concat(sum);
      }
    }
  }
};
export var FullFeatured = {
  args: {
    items: demoItems,
    defaultExpandedLevel: 3,
    accordion: false,
    maxRenderLevel: 4,
    maxExpandLevel: 3,
    indent: 16,
    rowGap: 8,
    levelConfig: {
      1: {
        rowStyle: {
          background: '#F5F5F5',
          padding: '8px 12px',
          borderRadius: 8
        },
        labelTextStyle: {
          fontWeight: 700
        },
        valueTextStyle: {
          color: '#1570EF',
          fontWeight: 700
        }
      },
      2: {
        rowStyle: {
          padding: '4px 8px'
        },
        labelTextStyle: {
          fontWeight: 600
        },
        showDotSeparator: true
      },
      3: {
        rowStyle: {
          padding: '2px 8px'
        },
        labelTextStyle: {
          color: '#1B1B1B',
          fontWeight: 500
        },
        valueTextStyle: {
          color: '#1B1B1B',
          fontWeight: 500
        }
      },
      4: {
        rowStyle: {
          paddingLeft: 0
        },
        labelTextStyle: {
          color: '#667085',
          fontWeight: 400
        },
        valueTextStyle: {
          color: '#667085',
          fontWeight: 400
        }
      }
    },
    aggregate: {
      mode: 'sum',
      getNumberValue: function getNumberValue(item) {
        if (typeof item.value === 'number') return item.value;
        return null;
      },
      format: function format(sum, _ref) {
        var level = _ref.level;
        return level === 1 ? "Total $".concat(sum) : "$".concat(sum);
      }
    },
    renderLabel: function renderLabel(item, ctx) {
      if (ctx.level === 1) {
        return /*#__PURE__*/React.createElement("span", null, item.label, ' ', item.itemsCount ? /*#__PURE__*/React.createElement("span", {
          style: {
            color: '#667085',
            marginLeft: 4
          }
        }, item.itemsCount) : null);
      }
      return item.label;
    },
    renderValue: function renderValue(item, ctx) {
      var _item$value;
      if (ctx.aggregatedValue !== undefined) {
        return ctx.aggregatedValue;
      }
      return (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : '—';
    }
  }
};