all.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import * as IconMap from './map';
  2. function toPascalCase(val) {
  3. return val.replace(/(^\w|-\w)/g, function (c) {
  4. return c.slice(-1).toUpperCase();
  5. });
  6. }
  7. var options = {
  8. name: 'icon-park',
  9. props: ['type', 'theme', 'size', 'spin', 'fill', 'strokeLinecap', 'strokeLinejoin', 'strokeWidth'],
  10. inheritAttrs: true,
  11. render: function render(h) {
  12. var type = toPascalCase(this.type);
  13. var theme = this.theme,
  14. size = this.size,
  15. fill = this.fill,
  16. strokeLinecap = this.strokeLinecap,
  17. strokeLinejoin = this.strokeLinejoin,
  18. strokeWidth = this.strokeWidth,
  19. spin = this.spin;
  20. if (!(type in IconMap)) {
  21. throw new Error("".concat(type, " is not a valid icon type name"));
  22. }
  23. return h(IconMap[type], {
  24. props: {
  25. theme: theme,
  26. size: size,
  27. fill: fill,
  28. strokeLinecap: strokeLinecap,
  29. strokeLinejoin: strokeLinejoin,
  30. strokeWidth: strokeWidth,
  31. spin: spin
  32. }
  33. });
  34. }
  35. };
  36. export var IconPark = options;
  37. export function install(Vue, prefix) {
  38. Object.values(IconMap).forEach(function (icon) {
  39. Vue.component(prefix ? prefix + '-' + icon.name.slice(5) : icon.name, icon);
  40. });
  41. }