@unocss/preset-icons 0.49.4 → 0.49.6

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.
package/dist/browser.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cdn = require('./shared/preset-icons.6dc3d443.cjs');
5
+ const cdn = require('./shared/preset-icons.b2d93e3f.cjs');
6
6
  const core = require('./core.cjs');
7
7
  require('ofetch');
8
8
  require('@unocss/core');
package/dist/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.903721a3.mjs';
1
+ import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.a568b68a.mjs';
2
2
  import { createPresetIcons } from './core.mjs';
3
3
  export { combineLoaders, createPresetIcons } from './core.mjs';
4
4
  import 'ofetch';
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cdn = require('./shared/preset-icons.6dc3d443.cjs');
5
+ const cdn = require('./shared/preset-icons.b2d93e3f.cjs');
6
6
  const core = require('./core.cjs');
7
7
  require('ofetch');
8
8
  require('@unocss/core');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.903721a3.mjs';
1
+ import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.a568b68a.mjs';
2
2
  import { createPresetIcons, combineLoaders } from './core.mjs';
3
3
  export { combineLoaders, createPresetIcons } from './core.mjs';
4
4
  import 'ofetch';
@@ -28,7 +28,9 @@ const defaultIconSizeCustomisations = Object.freeze({
28
28
  height: null
29
29
  });
30
30
  const defaultIconCustomisations = Object.freeze({
31
+ // Dimensions
31
32
  ...defaultIconSizeCustomisations,
33
+ // Transformations
32
34
  ...defaultIconTransformations
33
35
  });
34
36
 
@@ -157,6 +159,7 @@ function calculateSize(size, ratio, precision) {
157
159
  }
158
160
  }
159
161
 
162
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
160
163
  function iconToSVG(icon, customisations) {
161
164
  const fullIcon = {
162
165
  ...defaultIconProps,
@@ -248,15 +251,19 @@ function iconToSVG(icon, customisations) {
248
251
  width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
249
252
  height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
250
253
  }
251
- const result = {
252
- attributes: {
253
- width: width.toString(),
254
- height: height.toString(),
255
- viewBox: box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString()
256
- },
254
+ const attributes = {};
255
+ const setAttr = (prop, value) => {
256
+ if (!isUnsetKeyword(value)) {
257
+ attributes[prop] = value.toString();
258
+ }
259
+ };
260
+ setAttr("width", width);
261
+ setAttr("height", height);
262
+ attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
263
+ return {
264
+ attributes,
257
265
  body
258
266
  };
259
- return result;
260
267
  }
261
268
 
262
269
  "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
@@ -441,30 +448,27 @@ add("whitesmoke", [245]);
441
448
  add("yellow", [255, 255, 0]);
442
449
  add("yellowgreen", [154, 205, 50]);
443
450
 
444
- const svgWidthRegex = /width\s*=\s*["'](\w+)["']/;
445
- const svgHeightRegex = /height\s*=\s*["'](\w+)["']/;
451
+ const svgWidthRegex = /\swidth\s*=\s*["'](\w+)["']/;
452
+ const svgHeightRegex = /\sheight\s*=\s*["'](\w+)["']/;
446
453
  const svgTagRegex = /<svg\s+/;
447
454
  function configureSvgSize(svg, props, scale) {
448
455
  const svgNode = svg.slice(0, svg.indexOf(">"));
449
- let result = svgWidthRegex.exec(svgNode);
450
- const w = result != null;
451
- if (typeof props.width === "undefined" || props.width === null) {
452
- if (typeof scale === "number") {
453
- props.width = `${scale}em`;
454
- } else if (result) {
455
- props.width = result[1];
456
- }
457
- }
458
- result = svgHeightRegex.exec(svgNode);
459
- const h = result != null;
460
- if (typeof props.height === "undefined" || props.height === null) {
461
- if (typeof scale === "number") {
462
- props.height = `${scale}em`;
463
- } else if (result) {
464
- props.height = result[1];
456
+ const check = (prop, regex) => {
457
+ const result = regex.exec(svgNode);
458
+ const isSet = result != null;
459
+ const propValue = props[prop];
460
+ if (!propValue && !isUnsetKeyword(propValue)) {
461
+ if (typeof scale === "number") {
462
+ if (scale > 0) {
463
+ props[prop] = `${scale}em`;
464
+ }
465
+ } else if (result) {
466
+ props[prop] = result[1];
467
+ }
465
468
  }
466
- }
467
- return [w, h];
469
+ return isSet;
470
+ };
471
+ return [check("width", svgWidthRegex), check("height", svgHeightRegex)];
468
472
  }
469
473
  async function mergeIconProps(svg, collection, icon, options, propsProvider, afterCustomizations) {
470
474
  const { scale, addXmlNs = false } = options ?? {};
@@ -563,6 +567,7 @@ async function searchForIcon(iconSet, collection, ids, options) {
563
567
  } = iconToSVG(iconData, defaultCustomizations);
564
568
  const scale = options?.scale;
565
569
  return await mergeIconProps(
570
+ // DON'T remove space on <svg >
566
571
  `<svg >${body}</svg>`,
567
572
  collection,
568
573
  id,
@@ -571,20 +576,29 @@ async function searchForIcon(iconSet, collection, ids, options) {
571
576
  return { ...restAttributes };
572
577
  },
573
578
  (props) => {
574
- if (typeof props.width === "undefined" || props.width === null) {
575
- if (typeof scale === "number") {
576
- props.width = `${scale}em`;
577
- } else {
578
- props.width = width;
579
+ const check = (prop, defaultValue) => {
580
+ const propValue = props[prop];
581
+ let value;
582
+ if (!isUnsetKeyword(propValue)) {
583
+ if (propValue) {
584
+ return;
585
+ }
586
+ if (typeof scale === "number") {
587
+ if (scale) {
588
+ value = `${scale}em`;
589
+ }
590
+ } else {
591
+ value = defaultValue;
592
+ }
579
593
  }
580
- }
581
- if (typeof props.height === "undefined" || props.height === null) {
582
- if (typeof scale === "number") {
583
- props.height = `${scale}em`;
594
+ if (!value) {
595
+ delete props[prop];
584
596
  } else {
585
- props.height = height;
597
+ props[prop] = value;
586
598
  }
587
- }
599
+ };
600
+ check("width", width);
601
+ check("height", height);
588
602
  }
589
603
  );
590
604
  }
@@ -631,6 +645,7 @@ var collections = [
631
645
  "akar-icons",
632
646
  "ant-design",
633
647
  "arcticons",
648
+ "basil",
634
649
  "bi",
635
650
  "bpmn",
636
651
  "brandico",
@@ -723,10 +738,12 @@ var collections = [
723
738
  "mdi-light",
724
739
  "mdi",
725
740
  "medical-icon",
741
+ "memory",
726
742
  "mi",
727
743
  "mingcute",
728
744
  "mono-icons",
729
745
  "nimbus",
746
+ "nonicons",
730
747
  "noto-v1",
731
748
  "noto",
732
749
  "octicon",
@@ -748,7 +765,9 @@ var collections = [
748
765
  "si-glyph",
749
766
  "simple-icons",
750
767
  "simple-line-icons",
768
+ "skill-icons",
751
769
  "subway",
770
+ "svg-spinners",
752
771
  "system-uicons",
753
772
  "tabler",
754
773
  "teenyicons",
@@ -30,7 +30,9 @@ const defaultIconSizeCustomisations = Object.freeze({
30
30
  height: null
31
31
  });
32
32
  const defaultIconCustomisations = Object.freeze({
33
+ // Dimensions
33
34
  ...defaultIconSizeCustomisations,
35
+ // Transformations
34
36
  ...defaultIconTransformations
35
37
  });
36
38
 
@@ -159,6 +161,7 @@ function calculateSize(size, ratio, precision) {
159
161
  }
160
162
  }
161
163
 
164
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
162
165
  function iconToSVG(icon, customisations) {
163
166
  const fullIcon = {
164
167
  ...defaultIconProps,
@@ -250,15 +253,19 @@ function iconToSVG(icon, customisations) {
250
253
  width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
251
254
  height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
252
255
  }
253
- const result = {
254
- attributes: {
255
- width: width.toString(),
256
- height: height.toString(),
257
- viewBox: box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString()
258
- },
256
+ const attributes = {};
257
+ const setAttr = (prop, value) => {
258
+ if (!isUnsetKeyword(value)) {
259
+ attributes[prop] = value.toString();
260
+ }
261
+ };
262
+ setAttr("width", width);
263
+ setAttr("height", height);
264
+ attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
265
+ return {
266
+ attributes,
259
267
  body
260
268
  };
261
- return result;
262
269
  }
263
270
 
264
271
  "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
@@ -443,30 +450,27 @@ add("whitesmoke", [245]);
443
450
  add("yellow", [255, 255, 0]);
444
451
  add("yellowgreen", [154, 205, 50]);
445
452
 
446
- const svgWidthRegex = /width\s*=\s*["'](\w+)["']/;
447
- const svgHeightRegex = /height\s*=\s*["'](\w+)["']/;
453
+ const svgWidthRegex = /\swidth\s*=\s*["'](\w+)["']/;
454
+ const svgHeightRegex = /\sheight\s*=\s*["'](\w+)["']/;
448
455
  const svgTagRegex = /<svg\s+/;
449
456
  function configureSvgSize(svg, props, scale) {
450
457
  const svgNode = svg.slice(0, svg.indexOf(">"));
451
- let result = svgWidthRegex.exec(svgNode);
452
- const w = result != null;
453
- if (typeof props.width === "undefined" || props.width === null) {
454
- if (typeof scale === "number") {
455
- props.width = `${scale}em`;
456
- } else if (result) {
457
- props.width = result[1];
458
- }
459
- }
460
- result = svgHeightRegex.exec(svgNode);
461
- const h = result != null;
462
- if (typeof props.height === "undefined" || props.height === null) {
463
- if (typeof scale === "number") {
464
- props.height = `${scale}em`;
465
- } else if (result) {
466
- props.height = result[1];
458
+ const check = (prop, regex) => {
459
+ const result = regex.exec(svgNode);
460
+ const isSet = result != null;
461
+ const propValue = props[prop];
462
+ if (!propValue && !isUnsetKeyword(propValue)) {
463
+ if (typeof scale === "number") {
464
+ if (scale > 0) {
465
+ props[prop] = `${scale}em`;
466
+ }
467
+ } else if (result) {
468
+ props[prop] = result[1];
469
+ }
467
470
  }
468
- }
469
- return [w, h];
471
+ return isSet;
472
+ };
473
+ return [check("width", svgWidthRegex), check("height", svgHeightRegex)];
470
474
  }
471
475
  async function mergeIconProps(svg, collection, icon, options, propsProvider, afterCustomizations) {
472
476
  const { scale, addXmlNs = false } = options ?? {};
@@ -565,6 +569,7 @@ async function searchForIcon(iconSet, collection, ids, options) {
565
569
  } = iconToSVG(iconData, defaultCustomizations);
566
570
  const scale = options?.scale;
567
571
  return await mergeIconProps(
572
+ // DON'T remove space on <svg >
568
573
  `<svg >${body}</svg>`,
569
574
  collection,
570
575
  id,
@@ -573,20 +578,29 @@ async function searchForIcon(iconSet, collection, ids, options) {
573
578
  return { ...restAttributes };
574
579
  },
575
580
  (props) => {
576
- if (typeof props.width === "undefined" || props.width === null) {
577
- if (typeof scale === "number") {
578
- props.width = `${scale}em`;
579
- } else {
580
- props.width = width;
581
+ const check = (prop, defaultValue) => {
582
+ const propValue = props[prop];
583
+ let value;
584
+ if (!isUnsetKeyword(propValue)) {
585
+ if (propValue) {
586
+ return;
587
+ }
588
+ if (typeof scale === "number") {
589
+ if (scale) {
590
+ value = `${scale}em`;
591
+ }
592
+ } else {
593
+ value = defaultValue;
594
+ }
581
595
  }
582
- }
583
- if (typeof props.height === "undefined" || props.height === null) {
584
- if (typeof scale === "number") {
585
- props.height = `${scale}em`;
596
+ if (!value) {
597
+ delete props[prop];
586
598
  } else {
587
- props.height = height;
599
+ props[prop] = value;
588
600
  }
589
- }
601
+ };
602
+ check("width", width);
603
+ check("height", height);
590
604
  }
591
605
  );
592
606
  }
@@ -633,6 +647,7 @@ var collections = [
633
647
  "akar-icons",
634
648
  "ant-design",
635
649
  "arcticons",
650
+ "basil",
636
651
  "bi",
637
652
  "bpmn",
638
653
  "brandico",
@@ -725,10 +740,12 @@ var collections = [
725
740
  "mdi-light",
726
741
  "mdi",
727
742
  "medical-icon",
743
+ "memory",
728
744
  "mi",
729
745
  "mingcute",
730
746
  "mono-icons",
731
747
  "nimbus",
748
+ "nonicons",
732
749
  "noto-v1",
733
750
  "noto",
734
751
  "octicon",
@@ -750,7 +767,9 @@ var collections = [
750
767
  "si-glyph",
751
768
  "simple-icons",
752
769
  "simple-line-icons",
770
+ "skill-icons",
753
771
  "subway",
772
+ "svg-spinners",
754
773
  "system-uicons",
755
774
  "tabler",
756
775
  "teenyicons",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-icons",
3
- "version": "0.49.4",
3
+ "version": "0.49.6",
4
4
  "description": "Pure CSS Icons for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -47,9 +47,9 @@
47
47
  "*.css"
48
48
  ],
49
49
  "dependencies": {
50
- "@iconify/utils": "^2.0.10",
51
- "@unocss/core": "0.49.4",
52
- "ofetch": "^0.4.21"
50
+ "@iconify/utils": "^2.1.3",
51
+ "@unocss/core": "0.49.6",
52
+ "ofetch": "^1.0.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@iconify/types": "^2.0.0"