@symbo.ls/uikit 2.10.268 → 2.10.271

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/index.cjs.js CHANGED
@@ -1603,11 +1603,15 @@ var require_cjs = __commonJS({
1603
1603
  };
1604
1604
  var import_utils72 = __toESM2(require_cjs32(), 1);
1605
1605
  var generateSprite = (icons) => {
1606
- let sprite = '<svg aria-hidden="true" width="0" height="0" style="position:absolute">';
1606
+ const CONFIG2 = getActiveConfig();
1607
+ let sprite = "";
1607
1608
  for (const key in icons) {
1609
+ if (CONFIG2.__svg_cache[key])
1610
+ continue;
1611
+ else
1612
+ CONFIG2.__svg_cache[key] = true;
1608
1613
  sprite += icons[key];
1609
1614
  }
1610
- sprite += "</svg>";
1611
1615
  return sprite;
1612
1616
  };
1613
1617
  var parseRootAttributes = (htmlString) => {
@@ -1635,8 +1639,8 @@ var require_cjs = __commonJS({
1635
1639
  "<svg",
1636
1640
  `<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
1637
1641
  );
1638
- symbol = symbol.replace(/width="[^"]*/, "");
1639
- symbol = symbol.replace(/height="[^"]*/, "");
1642
+ symbol = symbol.replace(/width="[^"]*"/, "");
1643
+ symbol = symbol.replace(/height="[^"]*"/, "");
1640
1644
  symbol = symbol.replace("</svg", "</symbol");
1641
1645
  return symbol;
1642
1646
  };
@@ -2269,18 +2273,10 @@ var require_cjs = __commonJS({
2269
2273
  };
2270
2274
  var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
2271
2275
  const CONFIG2 = getActiveConfig();
2272
- const doc = options.document || import_globals2.document;
2273
2276
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
2274
2277
  for (const key in LIBRARY)
2275
2278
  lib[key] = CONFIG2.SVG[key];
2276
- const SVGsprite = generateSprite(lib);
2277
- if (!doc) {
2278
- console.warn("To append SVG sprites it should be run in browser environment");
2279
- return SVGsprite;
2280
- }
2281
- const svgSpriteDOM = doc.createElement("template");
2282
- svgSpriteDOM.innerHTML = SVGsprite;
2283
- doc.body.appendChild(svgSpriteDOM.content);
2279
+ appendSVG(lib, options);
2284
2280
  };
2285
2281
  var setIcon = (val, key) => {
2286
2282
  const CONFIG2 = getActiveConfig();
@@ -2291,18 +2287,42 @@ var require_cjs = __commonJS({
2291
2287
  };
2292
2288
  var appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
2293
2289
  const CONFIG2 = getActiveConfig();
2294
- const doc = options.document || import_globals2.document;
2295
2290
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
2296
2291
  for (const key in LIBRARY)
2297
2292
  lib[key] = CONFIG2.ICONS[key];
2298
- const SVGsprite = generateSprite(lib);
2293
+ appendSVG(lib, options);
2294
+ };
2295
+ var createSVGSpriteElement = (options = { isRoot: true }) => {
2296
+ const svgElem = import_globals2.document.createElementNS("http://www.w3.org/2000/svg", "svg");
2297
+ if (options.isRoot) {
2298
+ svgElem.setAttribute("aria-hidden", "true");
2299
+ svgElem.setAttribute("width", "0");
2300
+ svgElem.setAttribute("height", "0");
2301
+ svgElem.setAttribute("style", "position:absolute");
2302
+ svgElem.setAttribute("id", "svgSprite");
2303
+ }
2304
+ return svgElem;
2305
+ };
2306
+ var appendSVG = (lib, options = DEF_OPTIONS) => {
2307
+ const CONFIG2 = getActiveConfig();
2308
+ const doc = options.document || import_globals2.document;
2299
2309
  if (!doc) {
2300
- console.warn("To append SVG Icon sprites it should be run in browser environment");
2301
- return SVGsprite;
2310
+ if (CONFIG2.verbose) {
2311
+ console.warn("To append SVG sprites it should be run in browser environment");
2312
+ }
2313
+ return generateSprite(lib);
2314
+ }
2315
+ const exists = doc.querySelector("#svgSprite");
2316
+ const SVGsprite = generateSprite(lib);
2317
+ if (exists) {
2318
+ const tempSVG = createSVGSpriteElement({ isRoot: false });
2319
+ tempSVG.innerHTML = SVGsprite;
2320
+ exists.append(...tempSVG.children);
2321
+ } else {
2322
+ const svgSpriteDOM = createSVGSpriteElement();
2323
+ svgSpriteDOM.innerHTML = SVGsprite;
2324
+ doc.body.prepend(svgSpriteDOM);
2302
2325
  }
2303
- const iconsSpriteDOM = doc.createElement("template");
2304
- iconsSpriteDOM.innerHTML = SVGsprite;
2305
- doc.body.appendChild(iconsSpriteDOM.content);
2306
2326
  };
2307
2327
  var import_utils24 = __toESM2(require_cjs32(), 1);
2308
2328
  var applyReset = (reset = {}) => {
@@ -2540,6 +2560,8 @@ var require_cjs = __commonJS({
2540
2560
  CONFIG2.globalTheme = globalTheme;
2541
2561
  if (CONFIG2.verbose)
2542
2562
  console.log(CONFIG2);
2563
+ if (!CONFIG2.__svg_cache)
2564
+ CONFIG2.__svg_cache = {};
2543
2565
  const keys = Object.keys(config);
2544
2566
  keys.map((key) => setEach(key, config[key]));
2545
2567
  applyTypographySequence();
@@ -3494,8 +3516,8 @@ __export(domql_exports, {
3494
3516
  H5: () => H5,
3495
3517
  H6: () => H6,
3496
3518
  Hoverable: () => Hoverable,
3497
- Icon: () => Icon,
3498
- IconText: () => IconText,
3519
+ Icon: () => Icon2,
3520
+ IconText: () => IconText2,
3499
3521
  Iframe: () => Iframe,
3500
3522
  Img: () => Img,
3501
3523
  Input: () => Input,
@@ -6073,12 +6095,13 @@ var Icon = {
6073
6095
  validIconName = "noIcon";
6074
6096
  }
6075
6097
  const iconFromLibrary = ICONS[validIconName];
6098
+ const directSrc = parent.props.src || props3.src;
6076
6099
  return {
6077
6100
  width: "A",
6078
6101
  height: "A",
6079
6102
  display: "inline-block",
6080
- spriteId: useIconSprite && validIconName,
6081
- src: iconFromLibrary,
6103
+ spriteId: useIconSprite && !directSrc && validIconName,
6104
+ src: directSrc || iconFromLibrary,
6082
6105
  style: { fill: "currentColor" }
6083
6106
  };
6084
6107
  },
@@ -6361,6 +6384,61 @@ var DropdownParent = {
6361
6384
  }
6362
6385
  };
6363
6386
 
6387
+ // node_modules/@symbo.ls/icon/index.js
6388
+ var Icon2 = {
6389
+ extend: Svg,
6390
+ props: ({ key, props: props3, parent, context }) => {
6391
+ const { ICONS, useIconSprite, verbose } = context && context.designSystem;
6392
+ const { toCamelCase } = context && context.utils;
6393
+ const iconName = props3.inheritedString || props3.name || props3.icon || key;
6394
+ const camelCase = toCamelCase(iconName);
6395
+ const isArray5 = camelCase.split(/([a-z])([A-Z])/g);
6396
+ let activeIconName;
6397
+ if (props3.active) {
6398
+ activeIconName = props3[".active"].name || props3[".active"].icon;
6399
+ }
6400
+ if (parent && parent.props && parent.props.active && parent.props[".active"] && parent.props[".active"].icon) {
6401
+ activeIconName = parent.props[".active"].icon.name || parent.props[".active"].icon.icon || parent.props[".active"].icon;
6402
+ }
6403
+ let validIconName;
6404
+ if (ICONS[activeIconName])
6405
+ validIconName = activeIconName;
6406
+ if (ICONS[camelCase])
6407
+ validIconName = camelCase;
6408
+ else if (ICONS[isArray5[0] + isArray5[1]])
6409
+ validIconName = isArray5[0] + isArray5[1];
6410
+ else if (ICONS[isArray5[0]])
6411
+ validIconName = isArray5[0];
6412
+ else {
6413
+ if (verbose)
6414
+ console.warn("Can't find icon:", iconName, validIconName);
6415
+ validIconName = "noIcon";
6416
+ }
6417
+ const iconFromLibrary = ICONS[validIconName];
6418
+ return {
6419
+ width: "A",
6420
+ height: "A",
6421
+ display: "inline-block",
6422
+ spriteId: useIconSprite && validIconName,
6423
+ src: iconFromLibrary,
6424
+ style: { fill: "currentColor" }
6425
+ };
6426
+ },
6427
+ attr: { viewBox: "0 0 24 24" }
6428
+ };
6429
+ var IconText2 = {
6430
+ extend: Flex,
6431
+ props: {
6432
+ align: "center center",
6433
+ lineHeight: 1
6434
+ },
6435
+ icon: {
6436
+ extend: Icon2,
6437
+ if: ({ parent }) => parent.props.icon
6438
+ },
6439
+ text: ({ props: props3 }) => props3.text
6440
+ };
6441
+
6364
6442
  // Link/index.js
6365
6443
  var import_router = __toESM(require_cjs5());
6366
6444
  var Link = {