@fangzhongya/icons 0.0.47 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  var index_default = {
3
3
  prefix: "fang-icons",
4
4
  info: {},
5
- lastModified: 1768655512379,
5
+ lastModified: 1768658195728,
6
6
  icons: {
7
7
  bar: {
8
8
  body: '<path d="M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z"></path>'
@@ -2,7 +2,7 @@
2
2
  var index_default = {
3
3
  prefix: "fang-icons",
4
4
  info: {},
5
- lastModified: 1768655512379,
5
+ lastModified: 1768658195728,
6
6
  icons: {
7
7
  bar: {
8
8
  body: '<path d="M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z"></path>'
package/dist/index.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "prefix": "fang-icons",
3
3
  "info": {},
4
- "lastModified": 1768655512379,
4
+ "lastModified": 1768658195728,
5
5
  "icons": {
6
6
  "bar": {
7
7
  "body": "<path d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\"></path>"
package/dist/json.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkEAFBDDBAcjs = require('./chunk-EAFBDDBA.cjs');
3
+ var _chunk5BK6X4ZAcjs = require('./chunk-5BK6X4ZA.cjs');
4
4
  require('./chunk-75ZPJI57.cjs');
5
5
 
6
6
 
7
- exports.default = _chunkEAFBDDBAcjs.json_default;
7
+ exports.default = _chunk5BK6X4ZAcjs.json_default;
package/dist/json.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  var prefix = "fang-icons";
2
2
  var info = {
3
3
  };
4
- var lastModified = 1768655512379;
4
+ var lastModified = 1768658195728;
5
5
  var icons = {
6
6
  bar: {
7
7
  body: "<path d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\"></path>"
package/dist/json.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  var prefix = "fang-icons";
2
2
  var info = {
3
3
  };
4
- var lastModified = 1768655512379;
4
+ var lastModified = 1768658195728;
5
5
  var icons = {
6
6
  bar: {
7
7
  body: "<path d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\"></path>"
package/dist/json.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  json_default
3
- } from "./chunk-3KD5D7YV.js";
3
+ } from "./chunk-3KXKNLJB.js";
4
4
  import "./chunk-MLKGABMK.js";
5
5
  export {
6
6
  json_default as default
@@ -3,7 +3,7 @@
3
3
  var _chunkYJVFENGGcjs = require('../chunk-YJVFENGG.cjs');
4
4
 
5
5
 
6
- var _chunkEAFBDDBAcjs = require('../chunk-EAFBDDBA.cjs');
6
+ var _chunk5BK6X4ZAcjs = require('../chunk-5BK6X4ZA.cjs');
7
7
 
8
8
 
9
9
  var _chunkBXEIRESQcjs = require('../chunk-BXEIRESQ.cjs');
@@ -929,6 +929,7 @@ function simpleFangIcon(options = {}) {
929
929
  dynamic = true,
930
930
  virtual = false,
931
931
  replaced = true,
932
+ alias = "icon",
932
933
  customReplacement
933
934
  } = options;
934
935
  if (options.mobile) {
@@ -988,6 +989,7 @@ function simpleFangIcon(options = {}) {
988
989
  import FangIcon from '@fangzhongya/icons/icon/index'
989
990
  import { icons } from '@fangzhongya/icons/async'
990
991
  import { lineToLargeHump } from '@fangzhongya/utils/name/lineToLargeHump';
992
+ const alias = lineToLargeHump(${alias})
991
993
  const component = defineComponent({
992
994
  name: '${name}',
993
995
  props: {
@@ -1011,7 +1013,11 @@ function simpleFangIcon(options = {}) {
1011
1013
  const name = props.name;
1012
1014
  if (typeof name === 'string' && (props.type === '${runType}' ||
1013
1015
  (!props.type && props.default === '${runType}'))) {
1014
- const icon = icons[lineToLargeHump(name)];
1016
+ let n = lineToLargeHump(name)
1017
+ if(n.startsWith(alias)){
1018
+ n = n.substring(alias.length);
1019
+ }
1020
+ const icon = icons[n];
1015
1021
  if(icon) return icon;
1016
1022
  }
1017
1023
  return name;
@@ -1089,7 +1095,8 @@ function simpleFangIcon(options = {}) {
1089
1095
  component,
1090
1096
  type,
1091
1097
  dynamic,
1092
- customReplacement
1098
+ customReplacement,
1099
+ alias
1093
1100
  );
1094
1101
  imports.add(imptext);
1095
1102
  if (text !== component.fullMatch) {
@@ -1222,42 +1229,49 @@ function findComponents(code, name) {
1222
1229
  }
1223
1230
  return components;
1224
1231
  }
1225
- function getText(iconName, match) {
1226
- const svg = _chunkYJVFENGGcjs.getIconifySVG.call(void 0, _chunkEAFBDDBAcjs.json_default, iconName);
1232
+ function getText(iconName, match, name) {
1233
+ const svg = _chunkYJVFENGGcjs.getIconifySVG.call(void 0, _chunk5BK6X4ZAcjs.json_default, name);
1227
1234
  const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`</${match.componentName}>`, "");
1228
1235
  const text = `${s}${svg}</${match.componentName}>`;
1229
1236
  return { text, imptext: "" };
1230
1237
  }
1231
- function getImportName(iconName) {
1232
- return _chunkBXEIRESQcjs.lineToLargeHump.call(void 0, "fang-icon-" + iconName);
1238
+ function getImportName(iconName, alias) {
1239
+ return _chunkBXEIRESQcjs.lineToLargeHump.call(void 0, alias + "-" + iconName);
1233
1240
  }
1234
- function getVue(iconName, match) {
1241
+ function getVue(iconName, match, name, alias = "icon") {
1235
1242
  const text = match.fullMatch.replace(
1236
1243
  `name="${iconName}"`,
1237
- `:name="${getImportName(iconName)}"`
1244
+ `:name="${getImportName(name, alias)}"`
1238
1245
  );
1239
1246
  return {
1240
1247
  text,
1241
1248
  imptext: `import ${getImportName(
1242
- iconName
1243
- )} from '@fangzhongya/icons/vue/${iconName}'`
1249
+ name,
1250
+ alias
1251
+ )} from '@fangzhongya/icons/vue/${name}'`
1244
1252
  };
1245
1253
  }
1246
- function replaceComponent(match, type, dynamic, customReplacement) {
1254
+ function replaceComponent(match, type, dynamic, customReplacement, alias) {
1247
1255
  const { attributes } = match;
1248
1256
  const iconName = attributes.name;
1249
1257
  if (customReplacement) {
1250
- return customReplacement(iconName, attributes);
1258
+ return customReplacement(iconName, attributes, alias);
1251
1259
  }
1252
- let svgContent = _chunkEAFBDDBAcjs.json_default.icons[iconName];
1260
+ let name = iconName;
1261
+ if (alias) {
1262
+ if (iconName && iconName.startsWith(alias + "-")) {
1263
+ name = iconName.substring(alias.length + 1);
1264
+ }
1265
+ }
1266
+ let svgContent = _chunk5BK6X4ZAcjs.json_default.icons[iconName] || _chunk5BK6X4ZAcjs.json_default.icons[name];
1253
1267
  if (!svgContent) {
1254
1268
  return { text: match.fullMatch, imptext: "" };
1255
1269
  }
1256
1270
  if (!attributes.type && type == runType || attributes.type === runType) {
1257
1271
  if (dynamic) {
1258
- return getVue(iconName, match);
1272
+ return getVue(iconName, match, name, alias);
1259
1273
  } else {
1260
- return getText(iconName, match);
1274
+ return getText(iconName, match, name);
1261
1275
  }
1262
1276
  }
1263
1277
  if (type === "pub" && !attributes.type && !attributes.default) {
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- type IconReplacement = (iconName: string, attributes: ComponentAttributes) => {
3
+ type IconReplacement = (iconName: string, attributes: ComponentAttributes, alias?: string) => {
4
4
  text: string;
5
5
  imptext: string;
6
6
  };
@@ -34,6 +34,10 @@ interface PluginOptions {
34
34
  * 是否动态更新
35
35
  */
36
36
  dynamic?: boolean;
37
+ /**
38
+ * 别名
39
+ */
40
+ alias?: string;
37
41
  }
38
42
  interface ComponentAttributes {
39
43
  name: string;
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- type IconReplacement = (iconName: string, attributes: ComponentAttributes) => {
3
+ type IconReplacement = (iconName: string, attributes: ComponentAttributes, alias?: string) => {
4
4
  text: string;
5
5
  imptext: string;
6
6
  };
@@ -34,6 +34,10 @@ interface PluginOptions {
34
34
  * 是否动态更新
35
35
  */
36
36
  dynamic?: boolean;
37
+ /**
38
+ * 别名
39
+ */
40
+ alias?: string;
37
41
  }
38
42
  interface ComponentAttributes {
39
43
  name: string;
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-YGLV5TML.js";
4
4
  import {
5
5
  json_default
6
- } from "../chunk-3KD5D7YV.js";
6
+ } from "../chunk-3KXKNLJB.js";
7
7
  import {
8
8
  lineToLargeHump
9
9
  } from "../chunk-J4G2OFZ4.js";
@@ -929,6 +929,7 @@ function simpleFangIcon(options = {}) {
929
929
  dynamic = true,
930
930
  virtual = false,
931
931
  replaced = true,
932
+ alias = "icon",
932
933
  customReplacement
933
934
  } = options;
934
935
  if (options.mobile) {
@@ -988,6 +989,7 @@ function simpleFangIcon(options = {}) {
988
989
  import FangIcon from '@fangzhongya/icons/icon/index'
989
990
  import { icons } from '@fangzhongya/icons/async'
990
991
  import { lineToLargeHump } from '@fangzhongya/utils/name/lineToLargeHump';
992
+ const alias = lineToLargeHump(${alias})
991
993
  const component = defineComponent({
992
994
  name: '${name}',
993
995
  props: {
@@ -1011,7 +1013,11 @@ function simpleFangIcon(options = {}) {
1011
1013
  const name = props.name;
1012
1014
  if (typeof name === 'string' && (props.type === '${runType}' ||
1013
1015
  (!props.type && props.default === '${runType}'))) {
1014
- const icon = icons[lineToLargeHump(name)];
1016
+ let n = lineToLargeHump(name)
1017
+ if(n.startsWith(alias)){
1018
+ n = n.substring(alias.length);
1019
+ }
1020
+ const icon = icons[n];
1015
1021
  if(icon) return icon;
1016
1022
  }
1017
1023
  return name;
@@ -1089,7 +1095,8 @@ function simpleFangIcon(options = {}) {
1089
1095
  component,
1090
1096
  type,
1091
1097
  dynamic,
1092
- customReplacement
1098
+ customReplacement,
1099
+ alias
1093
1100
  );
1094
1101
  imports.add(imptext);
1095
1102
  if (text !== component.fullMatch) {
@@ -1222,42 +1229,49 @@ function findComponents(code, name) {
1222
1229
  }
1223
1230
  return components;
1224
1231
  }
1225
- function getText(iconName, match) {
1226
- const svg = getIconifySVG(json_default, iconName);
1232
+ function getText(iconName, match, name) {
1233
+ const svg = getIconifySVG(json_default, name);
1227
1234
  const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`</${match.componentName}>`, "");
1228
1235
  const text = `${s}${svg}</${match.componentName}>`;
1229
1236
  return { text, imptext: "" };
1230
1237
  }
1231
- function getImportName(iconName) {
1232
- return lineToLargeHump("fang-icon-" + iconName);
1238
+ function getImportName(iconName, alias) {
1239
+ return lineToLargeHump(alias + "-" + iconName);
1233
1240
  }
1234
- function getVue(iconName, match) {
1241
+ function getVue(iconName, match, name, alias = "icon") {
1235
1242
  const text = match.fullMatch.replace(
1236
1243
  `name="${iconName}"`,
1237
- `:name="${getImportName(iconName)}"`
1244
+ `:name="${getImportName(name, alias)}"`
1238
1245
  );
1239
1246
  return {
1240
1247
  text,
1241
1248
  imptext: `import ${getImportName(
1242
- iconName
1243
- )} from '@fangzhongya/icons/vue/${iconName}'`
1249
+ name,
1250
+ alias
1251
+ )} from '@fangzhongya/icons/vue/${name}'`
1244
1252
  };
1245
1253
  }
1246
- function replaceComponent(match, type, dynamic, customReplacement) {
1254
+ function replaceComponent(match, type, dynamic, customReplacement, alias) {
1247
1255
  const { attributes } = match;
1248
1256
  const iconName = attributes.name;
1249
1257
  if (customReplacement) {
1250
- return customReplacement(iconName, attributes);
1258
+ return customReplacement(iconName, attributes, alias);
1251
1259
  }
1252
- let svgContent = json_default.icons[iconName];
1260
+ let name = iconName;
1261
+ if (alias) {
1262
+ if (iconName && iconName.startsWith(alias + "-")) {
1263
+ name = iconName.substring(alias.length + 1);
1264
+ }
1265
+ }
1266
+ let svgContent = json_default.icons[iconName] || json_default.icons[name];
1253
1267
  if (!svgContent) {
1254
1268
  return { text: match.fullMatch, imptext: "" };
1255
1269
  }
1256
1270
  if (!attributes.type && type == runType || attributes.type === runType) {
1257
1271
  if (dynamic) {
1258
- return getVue(iconName, match);
1272
+ return getVue(iconName, match, name, alias);
1259
1273
  } else {
1260
- return getText(iconName, match);
1274
+ return getText(iconName, match, name);
1261
1275
  }
1262
1276
  }
1263
1277
  if (type === "pub" && !attributes.type && !attributes.default) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fangzhongya/icons",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.0.47",
5
+ "version": "0.0.48",
6
6
  "description ": "个人图标库",
7
7
  "author": "fangzhongya ",
8
8
  "license": "MIT",