@fangzhongya/icons 0.0.10 → 0.0.12

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.
@@ -187,7 +187,10 @@ var icon_default = defineComponent({
187
187
  const arr = computed(() => {
188
188
  var _a, _b, _c;
189
189
  if (slots.default) {
190
- return slots.default();
190
+ return slots.default({
191
+ class: [props.iconClass],
192
+ style: contStyle
193
+ });
191
194
  } else if (!outputName.value) {
192
195
  return void 0;
193
196
  } else if (outputType.value === "svg") {
@@ -187,7 +187,10 @@ var icon_default = _vue.defineComponent.call(void 0, {
187
187
  const arr = _vue.computed.call(void 0, () => {
188
188
  var _a, _b, _c;
189
189
  if (slots.default) {
190
- return slots.default();
190
+ return slots.default({
191
+ class: [props.iconClass],
192
+ style: contStyle
193
+ });
191
194
  } else if (!outputName.value) {
192
195
  return void 0;
193
196
  } else if (outputType.value === "svg") {
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkS2UC3QOVcjs = require('../chunk-S2UC3QOV.cjs');
3
+ var _chunkTKXFLY5Vcjs = require('../chunk-TKXFLY5V.cjs');
4
4
  require('../chunk-75ZPJI57.cjs');
5
5
 
6
6
 
7
- exports.default = _chunkS2UC3QOVcjs.icon_default;
7
+ exports.default = _chunkTKXFLY5Vcjs.icon_default;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  icon_default
3
- } from "../chunk-HOVIIPWX.js";
3
+ } from "../chunk-2GZYNEO5.js";
4
4
  import "../chunk-MLKGABMK.js";
5
5
  export {
6
6
  icon_default as default
package/dist/iconify.cjs CHANGED
@@ -93,7 +93,31 @@ function iconifySVG(obj, name) {
93
93
  });
94
94
  }
95
95
  }
96
+ function getIconifySVG(obj, name) {
97
+ var _a;
98
+ const icons = obj.icons;
99
+ const aliases = obj.aliases;
100
+ const ap = (_a = aliases[name]) == null ? void 0 : _a.parent;
101
+ const n = _nullishCoalesce(icons[name], () => ( (ap ? icons[ap] : void 0)));
102
+ if (n) {
103
+ const v = {
104
+ prefix: obj.prefix,
105
+ name,
106
+ width: obj.width,
107
+ height: obj.height,
108
+ ...n
109
+ };
110
+ const viewBox = [
111
+ v.left || 0,
112
+ v.top || 0,
113
+ v.width || 1024,
114
+ v.height || 1024
115
+ ].join(" ");
116
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}">${n.body}</svg>`;
117
+ }
118
+ }
119
+
96
120
 
97
121
 
98
122
 
99
- exports.iconify = iconify; exports.iconifySVG = iconifySVG;
123
+ exports.getIconifySVG = getIconifySVG; exports.iconify = iconify; exports.iconifySVG = iconifySVG;
@@ -37,5 +37,6 @@ type Iconify = {
37
37
  * @returns 返回一个Vue组件实例,用于渲染SVG图标
38
38
  */
39
39
  declare function iconifySVG(obj: Iconify, name: string): vue.DefineComponent<{}, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
40
+ declare function getIconifySVG(obj: Iconify, name: string): string;
40
41
 
41
- export { iconify, iconifySVG };
42
+ export { getIconifySVG, iconify, iconifySVG };
package/dist/iconify.d.ts CHANGED
@@ -37,5 +37,6 @@ type Iconify = {
37
37
  * @returns 返回一个Vue组件实例,用于渲染SVG图标
38
38
  */
39
39
  declare function iconifySVG(obj: Iconify, name: string): vue.DefineComponent<{}, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
40
+ declare function getIconifySVG(obj: Iconify, name: string): string;
40
41
 
41
- export { iconify, iconifySVG };
42
+ export { getIconifySVG, iconify, iconifySVG };
package/dist/iconify.js CHANGED
@@ -93,7 +93,31 @@ function iconifySVG(obj, name) {
93
93
  });
94
94
  }
95
95
  }
96
+ function getIconifySVG(obj, name) {
97
+ var _a;
98
+ const icons = obj.icons;
99
+ const aliases = obj.aliases;
100
+ const ap = (_a = aliases[name]) == null ? void 0 : _a.parent;
101
+ const n = icons[name] ?? (ap ? icons[ap] : void 0);
102
+ if (n) {
103
+ const v = {
104
+ prefix: obj.prefix,
105
+ name,
106
+ width: obj.width,
107
+ height: obj.height,
108
+ ...n
109
+ };
110
+ const viewBox = [
111
+ v.left || 0,
112
+ v.top || 0,
113
+ v.width || 1024,
114
+ v.height || 1024
115
+ ].join(" ");
116
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}">${n.body}</svg>`;
117
+ }
118
+ }
96
119
  export {
120
+ getIconifySVG,
97
121
  iconify,
98
122
  iconifySVG
99
123
  };
package/dist/index.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "prefix": "fang-icons",
3
3
  "info": {},
4
- "lastModified": 1767779324784,
4
+ "lastModified": 1767796433253,
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>"
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkS2UC3QOVcjs = require('../chunk-S2UC3QOV.cjs');
3
+ var _chunkTKXFLY5Vcjs = require('../chunk-TKXFLY5V.cjs');
4
4
 
5
5
 
6
6
  var _chunkEEMF44IHcjs = require('../chunk-EEMF44IH.cjs');
@@ -107,7 +107,7 @@ var picker_default = _vue.defineComponent.call(void 0, {
107
107
  }
108
108
  },
109
109
  [
110
- _vue.h.call(void 0, _chunkS2UC3QOVcjs.icon_default, {
110
+ _vue.h.call(void 0, _chunkTKXFLY5Vcjs.icon_default, {
111
111
  type: props.type,
112
112
  size: props.size,
113
113
  name: props.modelValue,
@@ -189,7 +189,7 @@ var picker_default = _vue.defineComponent.call(void 0, {
189
189
  },
190
190
  name.value
191
191
  ),
192
- _vue.h.call(void 0, _chunkS2UC3QOVcjs.icon_default, {
192
+ _vue.h.call(void 0, _chunkTKXFLY5Vcjs.icon_default, {
193
193
  type: props.type,
194
194
  size: props.size,
195
195
  name: name.value,
@@ -241,7 +241,7 @@ var picker_default = _vue.defineComponent.call(void 0, {
241
241
  }
242
242
  },
243
243
  [
244
- _vue.h.call(void 0, _chunkS2UC3QOVcjs.icon_default, {
244
+ _vue.h.call(void 0, _chunkTKXFLY5Vcjs.icon_default, {
245
245
  style: {
246
246
  margin: "5px",
247
247
  marginBottom: 0,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  icon_default
3
- } from "../chunk-HOVIIPWX.js";
3
+ } from "../chunk-2GZYNEO5.js";
4
4
  import {
5
5
  dialog_default
6
6
  } from "../chunk-I5KQLZMG.js";
@@ -907,22 +907,111 @@ function runDev(config, configCallback, callback) {
907
907
  }
908
908
 
909
909
  // packages/vite/index.ts
910
+
910
911
  var virtualModuleId = "virtual:fang-icon";
911
912
  function simpleFangIcon(options = {}) {
912
- const { type = "svg", directory = "./svg" } = options;
913
+ const { name = "FangIcon", type = "svg", directory = "./svg" } = options;
913
914
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
914
915
  if (type === "pub" && options.mobile) {
915
- console.log("runDev");
916
+ const outDir = _path.join.call(void 0, "./public/", directory);
917
+ console.log("outDir", outDir);
916
918
  runDev({
917
919
  issort: true,
918
920
  dir: "./node_modules/@fangzhongya/icons/dist/svg",
919
- outDir: "./public/" + directory,
921
+ outDir,
920
922
  extensions: ["svg"],
921
923
  read: true,
922
924
  fileCover: true,
923
925
  isNeader: false
924
926
  });
925
927
  }
928
+ const pub = `
929
+ import { defineComponent, h,} from 'vue'
930
+ import FangIcon from '@fangzhongya/icons/icon/index'
931
+ const component = defineComponent({
932
+ name: '${name}',
933
+ props: {
934
+ name: {
935
+ type: [String, Object],
936
+ },
937
+ default: {
938
+ type: String,
939
+ default: '${type}'
940
+ },
941
+ directory: {
942
+ type: String,
943
+ default: '${directory}'
944
+ }
945
+ },
946
+ setup(props, { attrs }) {
947
+ return () => {
948
+ return h(FangIcon, {
949
+ ...attrs,
950
+ name: props.name,
951
+ default: props.default,
952
+ directory: props.directory
953
+ });
954
+ };
955
+ }
956
+ });
957
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
958
+ export const install = (app) => {
959
+ app.component('${name}', component)
960
+ };
961
+
962
+ export default component;`;
963
+ const svg = `
964
+ import { defineComponent, h, computed} from 'vue'
965
+ import FangIcon from '@fangzhongya/icons/icon/index'
966
+ import { icons } from '@fangzhongya/icons/vue'
967
+ const component = defineComponent({
968
+ name: '${name}',
969
+ props: {
970
+ name: {
971
+ type: [String, Object],
972
+ },
973
+ type: {
974
+ type: String,
975
+ },
976
+ default: {
977
+ type: String,
978
+ default: '${type}'
979
+ },
980
+ directory: {
981
+ type: String,
982
+ default: '${directory}'
983
+ }
984
+ },
985
+ setup(props, { attrs }) {
986
+ const iconName = computed(() => {
987
+ const name = props.name;
988
+ if (typeof name === 'string' && (props.type === 'svg' ||
989
+ (props.type === undefined && props.default === 'svg'))) {
990
+ const icon = icons[name];
991
+ if(icon){
992
+ return icon;
993
+ }
994
+ }
995
+ return name;
996
+ });
997
+ return () => {
998
+ return h(FangIcon, {
999
+ ...attrs,
1000
+ name: iconName.value,
1001
+ type: props.type,
1002
+ default: props.default,
1003
+ directory: props.directory
1004
+ });
1005
+ };
1006
+ }
1007
+ });
1008
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
1009
+ export const install = (app) => {
1010
+ app.component('${name}', component)
1011
+ };
1012
+
1013
+ export default component;`;
1014
+ const text = type === "svg" ? svg : pub;
926
1015
  return {
927
1016
  name: "simple-fang-icon",
928
1017
  resolveId(id) {
@@ -933,35 +1022,7 @@ function simpleFangIcon(options = {}) {
933
1022
  },
934
1023
  load(id) {
935
1024
  if (id === resolvedVirtualModuleId) {
936
- return `
937
- import { defineComponent, h,} from 'vue'
938
- import FangIcon from '@fangzhongya/icons/icon/index'
939
- export default defineComponent({
940
- props: {
941
- name: {
942
- type: [String, Object],
943
- },
944
- type: {
945
- type: String,
946
- default: '${type}'
947
- },
948
- directory: {
949
- type: String,
950
- default: '${directory}'
951
- }
952
- },
953
- setup(props, { attrs }) {
954
- return () => {
955
- return h(FangIcon, {
956
- ...attrs,
957
- type: props.type,
958
- name: props.name,
959
- directory: props.directory
960
- });
961
- };
962
- }
963
- })
964
- `;
1025
+ return text;
965
1026
  }
966
1027
  return null;
967
1028
  }
@@ -1,9 +1,11 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
3
  interface PluginOptions {
4
+ name?: string;
4
5
  type?: string;
5
6
  directory?: string;
6
7
  mobile?: boolean;
8
+ dynamic?: boolean;
7
9
  }
8
10
  declare function simpleFangIcon(options?: PluginOptions): Plugin;
9
11
 
@@ -1,9 +1,11 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
3
  interface PluginOptions {
4
+ name?: string;
4
5
  type?: string;
5
6
  directory?: string;
6
7
  mobile?: boolean;
8
+ dynamic?: boolean;
7
9
  }
8
10
  declare function simpleFangIcon(options?: PluginOptions): Plugin;
9
11
 
@@ -907,22 +907,111 @@ function runDev(config, configCallback, callback) {
907
907
  }
908
908
 
909
909
  // packages/vite/index.ts
910
+ import { join as join5 } from "path";
910
911
  var virtualModuleId = "virtual:fang-icon";
911
912
  function simpleFangIcon(options = {}) {
912
- const { type = "svg", directory = "./svg" } = options;
913
+ const { name = "FangIcon", type = "svg", directory = "./svg" } = options;
913
914
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
914
915
  if (type === "pub" && options.mobile) {
915
- console.log("runDev");
916
+ const outDir = join5("./public/", directory);
917
+ console.log("outDir", outDir);
916
918
  runDev({
917
919
  issort: true,
918
920
  dir: "./node_modules/@fangzhongya/icons/dist/svg",
919
- outDir: "./public/" + directory,
921
+ outDir,
920
922
  extensions: ["svg"],
921
923
  read: true,
922
924
  fileCover: true,
923
925
  isNeader: false
924
926
  });
925
927
  }
928
+ const pub = `
929
+ import { defineComponent, h,} from 'vue'
930
+ import FangIcon from '@fangzhongya/icons/icon/index'
931
+ const component = defineComponent({
932
+ name: '${name}',
933
+ props: {
934
+ name: {
935
+ type: [String, Object],
936
+ },
937
+ default: {
938
+ type: String,
939
+ default: '${type}'
940
+ },
941
+ directory: {
942
+ type: String,
943
+ default: '${directory}'
944
+ }
945
+ },
946
+ setup(props, { attrs }) {
947
+ return () => {
948
+ return h(FangIcon, {
949
+ ...attrs,
950
+ name: props.name,
951
+ default: props.default,
952
+ directory: props.directory
953
+ });
954
+ };
955
+ }
956
+ });
957
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
958
+ export const install = (app) => {
959
+ app.component('${name}', component)
960
+ };
961
+
962
+ export default component;`;
963
+ const svg = `
964
+ import { defineComponent, h, computed} from 'vue'
965
+ import FangIcon from '@fangzhongya/icons/icon/index'
966
+ import { icons } from '@fangzhongya/icons/vue'
967
+ const component = defineComponent({
968
+ name: '${name}',
969
+ props: {
970
+ name: {
971
+ type: [String, Object],
972
+ },
973
+ type: {
974
+ type: String,
975
+ },
976
+ default: {
977
+ type: String,
978
+ default: '${type}'
979
+ },
980
+ directory: {
981
+ type: String,
982
+ default: '${directory}'
983
+ }
984
+ },
985
+ setup(props, { attrs }) {
986
+ const iconName = computed(() => {
987
+ const name = props.name;
988
+ if (typeof name === 'string' && (props.type === 'svg' ||
989
+ (props.type === undefined && props.default === 'svg'))) {
990
+ const icon = icons[name];
991
+ if(icon){
992
+ return icon;
993
+ }
994
+ }
995
+ return name;
996
+ });
997
+ return () => {
998
+ return h(FangIcon, {
999
+ ...attrs,
1000
+ name: iconName.value,
1001
+ type: props.type,
1002
+ default: props.default,
1003
+ directory: props.directory
1004
+ });
1005
+ };
1006
+ }
1007
+ });
1008
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
1009
+ export const install = (app) => {
1010
+ app.component('${name}', component)
1011
+ };
1012
+
1013
+ export default component;`;
1014
+ const text = type === "svg" ? svg : pub;
926
1015
  return {
927
1016
  name: "simple-fang-icon",
928
1017
  resolveId(id) {
@@ -933,35 +1022,7 @@ function simpleFangIcon(options = {}) {
933
1022
  },
934
1023
  load(id) {
935
1024
  if (id === resolvedVirtualModuleId) {
936
- return `
937
- import { defineComponent, h,} from 'vue'
938
- import FangIcon from '@fangzhongya/icons/icon/index'
939
- export default defineComponent({
940
- props: {
941
- name: {
942
- type: [String, Object],
943
- },
944
- type: {
945
- type: String,
946
- default: '${type}'
947
- },
948
- directory: {
949
- type: String,
950
- default: '${directory}'
951
- }
952
- },
953
- setup(props, { attrs }) {
954
- return () => {
955
- return h(FangIcon, {
956
- ...attrs,
957
- type: props.type,
958
- name: props.name,
959
- directory: props.directory
960
- });
961
- };
962
- }
963
- })
964
- `;
1025
+ return text;
965
1026
  }
966
1027
  return null;
967
1028
  }
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.10",
5
+ "version": "0.0.12",
6
6
  "description ": "个人图标库",
7
7
  "author": "fangzhongya ",
8
8
  "license": "MIT",