@ttoss/forms 0.22.3 → 0.22.5

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.
@@ -833,13 +833,13 @@ var MultistepFormStepper = ({
833
833
  // src/MultistepForm/MultistepHeader.tsx
834
834
  var import_ui17 = require("@ttoss/ui");
835
835
 
836
- // ../react-icons/dist/esm/index.js
836
+ // ../react-icons/src/Icon.tsx
837
837
  var React4 = __toESM(require("react"));
838
838
 
839
- // ../../node_modules/.pnpm/@iconify-icon+react@1.0.8_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
839
+ // ../../node_modules/.pnpm/@iconify-icon+react@2.0.1_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
840
840
  var import_react = __toESM(require("react"), 1);
841
841
 
842
- // ../../node_modules/.pnpm/iconify-icon@1.0.8/node_modules/iconify-icon/dist/iconify-icon.mjs
842
+ // ../../node_modules/.pnpm/iconify-icon@2.0.0/node_modules/iconify-icon/dist/iconify-icon.mjs
843
843
  var defaultIconDimensions = Object.freeze({
844
844
  left: 0,
845
845
  top: 0,
@@ -1213,7 +1213,7 @@ function addCollection$1(data, provider) {
1213
1213
  const storage2 = getStorage(provider, prefix);
1214
1214
  return !!addIconSet(storage2, data);
1215
1215
  }
1216
- function iconExists$1(name) {
1216
+ function iconLoaded$1(name) {
1217
1217
  return !!getIconData(name);
1218
1218
  }
1219
1219
  function getIcon$1(name) {
@@ -1675,6 +1675,7 @@ var browserCacheCountKey = browserCachePrefix + "-count";
1675
1675
  var browserCacheVersionKey = browserCachePrefix + "-version";
1676
1676
  var browserStorageHour = 36e5;
1677
1677
  var browserStorageCacheExpiration = 168;
1678
+ var browserStorageLimit = 50;
1678
1679
  function getStoredItem(func, key) {
1679
1680
  try {
1680
1681
  return func.getItem(key);
@@ -1818,7 +1819,7 @@ function storeInBrowserStorage(storage2, data) {
1818
1819
  set.delete(index = Array.from(set).shift());
1819
1820
  } else {
1820
1821
  index = getBrowserStorageItemsCount(func);
1821
- if (!setBrowserStorageItemsCount(func, index + 1)) {
1822
+ if (index >= browserStorageLimit || !setBrowserStorageItemsCount(func, index + 1)) {
1822
1823
  return;
1823
1824
  }
1824
1825
  }
@@ -2012,7 +2013,6 @@ function parseIconValue(value, onload) {
2012
2013
  // could be 'null' -> icon is missing
2013
2014
  };
2014
2015
  }
2015
-
2016
2016
  const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
2017
2017
  return {
2018
2018
  value,
@@ -2077,6 +2077,34 @@ function calculateSize$1(size, ratio, precision) {
2077
2077
  isNumber = !isNumber;
2078
2078
  }
2079
2079
  }
2080
+ function splitSVGDefs(content, tag = "defs") {
2081
+ let defs = "";
2082
+ const index = content.indexOf("<" + tag);
2083
+ while (index >= 0) {
2084
+ const start = content.indexOf(">", index);
2085
+ const end = content.indexOf("</" + tag);
2086
+ if (start === -1 || end === -1) {
2087
+ break;
2088
+ }
2089
+ const endEnd = content.indexOf(">", end);
2090
+ if (endEnd === -1) {
2091
+ break;
2092
+ }
2093
+ defs += content.slice(start + 1, end).trim();
2094
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
2095
+ }
2096
+ return {
2097
+ defs,
2098
+ content
2099
+ };
2100
+ }
2101
+ function mergeDefsAndContent(defs, content) {
2102
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
2103
+ }
2104
+ function wrapSVGContent(body, start, end) {
2105
+ const split = splitSVGDefs(body);
2106
+ return mergeDefsAndContent(split.defs, start + split.content + end);
2107
+ }
2080
2108
  var isUnsetKeyword = value => value === "unset" || value === "undefined" || value === "none";
2081
2109
  function iconToSVG(icon, customisations) {
2082
2110
  const fullIcon = {
@@ -2143,7 +2171,7 @@ function iconToSVG(icon, customisations) {
2143
2171
  }
2144
2172
  }
2145
2173
  if (transformations.length) {
2146
- body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
2174
+ body = wrapSVGContent(body, '<g transform="' + transformations.join(" ") + '">', "</g>");
2147
2175
  }
2148
2176
  });
2149
2177
  const customisationsWidth = fullCustomisations.width;
@@ -2167,12 +2195,30 @@ function iconToSVG(icon, customisations) {
2167
2195
  };
2168
2196
  setAttr("width", width);
2169
2197
  setAttr("height", height);
2170
- attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
2198
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
2199
+ attributes.viewBox = viewBox.join(" ");
2171
2200
  return {
2172
2201
  attributes,
2202
+ viewBox,
2173
2203
  body
2174
2204
  };
2175
2205
  }
2206
+ function iconToHTML$1(body, attributes) {
2207
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
2208
+ for (const attr in attributes) {
2209
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
2210
+ }
2211
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
2212
+ }
2213
+ function encodeSVGforURL(svg) {
2214
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
2215
+ }
2216
+ function svgToData(svg) {
2217
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
2218
+ }
2219
+ function svgToURL$1(svg) {
2220
+ return 'url("' + svgToData(svg) + '")';
2221
+ }
2176
2222
  var detectFetch = () => {
2177
2223
  let callback;
2178
2224
  try {
@@ -2397,13 +2443,16 @@ function exportFunctions() {
2397
2443
  return {
2398
2444
  enableCache: storage2 => toggleBrowserCache(storage2, true),
2399
2445
  disableCache: storage2 => toggleBrowserCache(storage2, false),
2400
- iconExists: iconExists$1,
2446
+ iconLoaded: iconLoaded$1,
2447
+ iconExists: iconLoaded$1,
2401
2448
  getIcon: getIcon$1,
2402
2449
  listIcons: listIcons$1,
2403
2450
  addIcon: addIcon$1,
2404
2451
  addCollection: addCollection$1,
2405
2452
  calculateSize: calculateSize$1,
2406
2453
  buildIcon: iconToSVG,
2454
+ iconToHTML: iconToHTML$1,
2455
+ svgToURL: svgToURL$1,
2407
2456
  loadIcons: loadIcons$1,
2408
2457
  loadIcon: loadIcon$1,
2409
2458
  addAPIProvider: addAPIProvider$1,
@@ -2411,22 +2460,6 @@ function exportFunctions() {
2411
2460
  _api: _api2
2412
2461
  };
2413
2462
  }
2414
- function iconToHTML(body, attributes) {
2415
- let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
2416
- for (const attr in attributes) {
2417
- renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
2418
- }
2419
- return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
2420
- }
2421
- function encodeSVGforURL(svg) {
2422
- return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
2423
- }
2424
- function svgToData(svg) {
2425
- return "data:image/svg+xml," + encodeSVGforURL(svg);
2426
- }
2427
- function svgToURL(svg) {
2428
- return 'url("' + svgToData(svg) + '")';
2429
- }
2430
2463
  var monotoneProps = {
2431
2464
  "background-color": "currentColor"
2432
2465
  };
@@ -2459,12 +2492,12 @@ function renderSPAN(data, icon, useMask) {
2459
2492
  body += "<!-- " + Date.now() + " -->";
2460
2493
  }
2461
2494
  const renderAttribs = data.attributes;
2462
- const html = iconToHTML(body, {
2495
+ const html = iconToHTML$1(body, {
2463
2496
  ...renderAttribs,
2464
2497
  width: icon.width + "",
2465
2498
  height: icon.height + ""
2466
2499
  });
2467
- const url = svgToURL(html);
2500
+ const url = svgToURL$1(html);
2468
2501
  const svgStyle = node.style;
2469
2502
  const styles = {
2470
2503
  "--svg": url,
@@ -2507,10 +2540,16 @@ function renderSVG(data) {
2507
2540
  if (style) {
2508
2541
  attr.style = style;
2509
2542
  }
2510
- const html = iconToHTML(data.body, attr);
2543
+ const html = iconToHTML$1(data.body, attr);
2511
2544
  node.innerHTML = cleanUpInnerHTML(html);
2512
2545
  return node.firstChild;
2513
2546
  }
2547
+ function findIconElement(parent) {
2548
+ return Array.from(parent.childNodes).find(node => {
2549
+ const tag = node.tagName && node.tagName.toUpperCase();
2550
+ return tag === "SPAN" || tag === "SVG";
2551
+ });
2552
+ }
2514
2553
  function renderIcon(parent, state) {
2515
2554
  const iconData = state.icon.data;
2516
2555
  const customisations = state.customisations;
@@ -2530,10 +2569,7 @@ function renderIcon(parent, state) {
2530
2569
  ...iconData
2531
2570
  }, mode === "mask");
2532
2571
  }
2533
- const oldNode = Array.from(parent.childNodes).find(node2 => {
2534
- const tag = node2.tagName && node2.tagName.toUpperCase();
2535
- return tag === "SPAN" || tag === "SVG";
2536
- });
2572
+ const oldNode = findIconElement(parent);
2537
2573
  if (oldNode) {
2538
2574
  if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
2539
2575
  oldNode.setAttribute("style", node.getAttribute("style"));
@@ -2573,16 +2609,23 @@ function defineIconifyIcon(name = "iconify-icon") {
2573
2609
  // Icon
2574
2610
  "icon",
2575
2611
  // Mode
2576
- "mode", "inline",
2612
+ "mode", "inline", "observe",
2577
2613
  // Customisations
2578
2614
  "width", "height", "rotate", "flip"];
2579
- const IconifyIcon = class extends ParentClass {
2615
+ const IconifyIcon2 = class extends ParentClass {
2580
2616
  // Root
2581
2617
  _shadowRoot;
2582
- // State
2618
+ // Initialised
2619
+ _initialised = false;
2620
+ // Icon state
2583
2621
  _state;
2584
2622
  // Attributes check queued
2585
2623
  _checkQueued = false;
2624
+ // Connected
2625
+ _connected = false;
2626
+ // Observer
2627
+ _observer = null;
2628
+ _visible = true;
2586
2629
  /**
2587
2630
  * Constructor
2588
2631
  */
@@ -2598,6 +2641,20 @@ function defineIconifyIcon(name = "iconify-icon") {
2598
2641
  }, inline);
2599
2642
  this._queueCheck();
2600
2643
  }
2644
+ /**
2645
+ * Connected to DOM
2646
+ */
2647
+ connectedCallback() {
2648
+ this._connected = true;
2649
+ this.startObserver();
2650
+ }
2651
+ /**
2652
+ * Disconnected from DOM
2653
+ */
2654
+ disconnectedCallback() {
2655
+ this._connected = false;
2656
+ this.stopObserver();
2657
+ }
2601
2658
  /**
2602
2659
  * Observed attributes
2603
2660
  */
@@ -2625,15 +2682,29 @@ function defineIconifyIcon(name = "iconify-icon") {
2625
2682
  * Attribute has changed
2626
2683
  */
2627
2684
  attributeChangedCallback(name2) {
2628
- if (name2 === "inline") {
2629
- const newInline = getInline(this);
2630
- const state = this._state;
2631
- if (newInline !== state.inline) {
2632
- state.inline = newInline;
2633
- updateStyle(this._shadowRoot, newInline);
2634
- }
2635
- } else {
2636
- this._queueCheck();
2685
+ switch (name2) {
2686
+ case "inline":
2687
+ {
2688
+ const newInline = getInline(this);
2689
+ const state = this._state;
2690
+ if (newInline !== state.inline) {
2691
+ state.inline = newInline;
2692
+ updateStyle(this._shadowRoot, newInline);
2693
+ }
2694
+ break;
2695
+ }
2696
+ case "observer":
2697
+ {
2698
+ const value = this.observer;
2699
+ if (value) {
2700
+ this.startObserver();
2701
+ } else {
2702
+ this.stopObserver();
2703
+ }
2704
+ break;
2705
+ }
2706
+ default:
2707
+ this._queueCheck();
2637
2708
  }
2638
2709
  }
2639
2710
  /**
@@ -2667,6 +2738,19 @@ function defineIconifyIcon(name = "iconify-icon") {
2667
2738
  this.removeAttribute("inline");
2668
2739
  }
2669
2740
  }
2741
+ /**
2742
+ * Get/set observer
2743
+ */
2744
+ get observer() {
2745
+ return this.hasAttribute("observer");
2746
+ }
2747
+ set observer(value) {
2748
+ if (value) {
2749
+ this.setAttribute("observer", "true");
2750
+ } else {
2751
+ this.removeAttribute("observer");
2752
+ }
2753
+ }
2670
2754
  /**
2671
2755
  * Restart animation
2672
2756
  */
@@ -2715,12 +2799,12 @@ function defineIconifyIcon(name = "iconify-icon") {
2715
2799
  this._iconChanged(newIcon);
2716
2800
  return;
2717
2801
  }
2718
- if (!state.rendered) {
2802
+ if (!state.rendered || !this._visible) {
2719
2803
  return;
2720
2804
  }
2721
2805
  const mode = this.getAttribute("mode");
2722
2806
  const customisations = getCustomisations(this);
2723
- if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations)) {
2807
+ if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations) || !findIconElement(this._shadowRoot)) {
2724
2808
  this._renderIcon(state.icon, customisations, mode);
2725
2809
  }
2726
2810
  }
@@ -2750,6 +2834,19 @@ function defineIconifyIcon(name = "iconify-icon") {
2750
2834
  this._state = setPendingState(icon, this._state.inline, this._state);
2751
2835
  }
2752
2836
  }
2837
+ /**
2838
+ * Force render icon on state change
2839
+ */
2840
+ _forceRender() {
2841
+ if (!this._visible) {
2842
+ const node = findIconElement(this._shadowRoot);
2843
+ if (node) {
2844
+ this._shadowRoot.removeChild(node);
2845
+ }
2846
+ return;
2847
+ }
2848
+ this._queueCheck();
2849
+ }
2753
2850
  /**
2754
2851
  * Got new icon data, icon is ready to (re)render
2755
2852
  */
@@ -2772,10 +2869,47 @@ function defineIconifyIcon(name = "iconify-icon") {
2772
2869
  renderedMode
2773
2870
  });
2774
2871
  }
2872
+ /**
2873
+ * Start observer
2874
+ */
2875
+ startObserver() {
2876
+ if (!this._observer) {
2877
+ try {
2878
+ this._observer = new IntersectionObserver(entries => {
2879
+ const intersecting = entries.some(entry => entry.isIntersecting);
2880
+ if (intersecting !== this._visible) {
2881
+ this._visible = intersecting;
2882
+ this._forceRender();
2883
+ }
2884
+ });
2885
+ this._observer.observe(this);
2886
+ } catch (err) {
2887
+ if (this._observer) {
2888
+ try {
2889
+ this._observer.disconnect();
2890
+ } catch (err2) {}
2891
+ this._observer = null;
2892
+ }
2893
+ }
2894
+ }
2895
+ }
2896
+ /**
2897
+ * Stop observer
2898
+ */
2899
+ stopObserver() {
2900
+ if (this._observer) {
2901
+ this._observer.disconnect();
2902
+ this._observer = null;
2903
+ this._visible = true;
2904
+ if (this._connected) {
2905
+ this._forceRender();
2906
+ }
2907
+ }
2908
+ }
2775
2909
  };
2776
2910
  attributes.forEach(attr => {
2777
- if (!(attr in IconifyIcon.prototype)) {
2778
- Object.defineProperty(IconifyIcon.prototype, attr, {
2911
+ if (!(attr in IconifyIcon2.prototype)) {
2912
+ Object.defineProperty(IconifyIcon2.prototype, attr, {
2779
2913
  get: function () {
2780
2914
  return this.getAttribute(attr);
2781
2915
  },
@@ -2791,29 +2925,33 @@ function defineIconifyIcon(name = "iconify-icon") {
2791
2925
  });
2792
2926
  const functions = exportFunctions();
2793
2927
  for (const key in functions) {
2794
- IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
2928
+ IconifyIcon2[key] = IconifyIcon2.prototype[key] = functions[key];
2795
2929
  }
2796
- customElements.define(name, IconifyIcon);
2797
- return IconifyIcon;
2930
+ customElements.define(name, IconifyIcon2);
2931
+ return IconifyIcon2;
2798
2932
  }
2799
2933
  var IconifyIconComponent = defineIconifyIcon() || exportFunctions();
2800
2934
  var {
2801
2935
  enableCache,
2802
2936
  disableCache,
2937
+ iconLoaded,
2803
2938
  iconExists,
2939
+ // deprecated, kept to avoid breaking changes
2804
2940
  getIcon,
2805
2941
  listIcons,
2806
2942
  addIcon,
2807
2943
  addCollection,
2808
2944
  calculateSize,
2809
2945
  buildIcon,
2946
+ iconToHTML,
2947
+ svgToURL,
2810
2948
  loadIcons,
2811
2949
  loadIcon,
2812
2950
  addAPIProvider,
2813
2951
  _api
2814
2952
  } = IconifyIconComponent;
2815
2953
 
2816
- // ../../node_modules/.pnpm/@iconify-icon+react@1.0.8_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
2954
+ // ../../node_modules/.pnpm/@iconify-icon+react@2.0.1_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
2817
2955
  var Icon = import_react.default.forwardRef((props, ref) => {
2818
2956
  const newProps = {
2819
2957
  ...props,
@@ -2831,9 +2969,9 @@ var Icon = import_react.default.forwardRef((props, ref) => {
2831
2969
  return import_react.default.createElement("iconify-icon", newProps);
2832
2970
  });
2833
2971
 
2834
- // ../react-icons/dist/esm/index.js
2972
+ // ../react-icons/src/Icon.tsx
2835
2973
  var import_jsx_runtime20 = require("react/jsx-runtime");
2836
- var Icon2 = /* @__PURE__ */React4.forwardRef((props, ref) => {
2974
+ var Icon2 = React4.forwardRef((props, ref) => {
2837
2975
  return /* @__PURE__ */(0, import_jsx_runtime20.jsx)(Icon, {
2838
2976
  ref,
2839
2977
  "data-testid": "iconify-icon",
@@ -3045,6 +3183,6 @@ iconify-icon/dist/iconify-icon.mjs:
3045
3183
  * Licensed under MIT.
3046
3184
  *
3047
3185
  * @license MIT
3048
- * @version 1.0.8
3186
+ * @version 2.0.0
3049
3187
  *)
3050
3188
  */
@@ -151,13 +151,13 @@ var MultistepFormStepper = ({
151
151
  // src/MultistepForm/MultistepHeader.tsx
152
152
  import { CloseButton, Flex as Flex4, Image as Image2, Text as Text4 } from "@ttoss/ui";
153
153
 
154
- // ../react-icons/dist/esm/index.js
154
+ // ../react-icons/src/Icon.tsx
155
155
  import * as React2 from "react";
156
156
 
157
- // ../../node_modules/.pnpm/@iconify-icon+react@1.0.8_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
157
+ // ../../node_modules/.pnpm/@iconify-icon+react@2.0.1_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
158
158
  import React from "react";
159
159
 
160
- // ../../node_modules/.pnpm/iconify-icon@1.0.8/node_modules/iconify-icon/dist/iconify-icon.mjs
160
+ // ../../node_modules/.pnpm/iconify-icon@2.0.0/node_modules/iconify-icon/dist/iconify-icon.mjs
161
161
  var defaultIconDimensions = Object.freeze({
162
162
  left: 0,
163
163
  top: 0,
@@ -531,7 +531,7 @@ function addCollection$1(data, provider) {
531
531
  const storage2 = getStorage(provider, prefix);
532
532
  return !!addIconSet(storage2, data);
533
533
  }
534
- function iconExists$1(name) {
534
+ function iconLoaded$1(name) {
535
535
  return !!getIconData(name);
536
536
  }
537
537
  function getIcon$1(name) {
@@ -993,6 +993,7 @@ var browserCacheCountKey = browserCachePrefix + "-count";
993
993
  var browserCacheVersionKey = browserCachePrefix + "-version";
994
994
  var browserStorageHour = 36e5;
995
995
  var browserStorageCacheExpiration = 168;
996
+ var browserStorageLimit = 50;
996
997
  function getStoredItem(func, key) {
997
998
  try {
998
999
  return func.getItem(key);
@@ -1136,7 +1137,7 @@ function storeInBrowserStorage(storage2, data) {
1136
1137
  set.delete(index = Array.from(set).shift());
1137
1138
  } else {
1138
1139
  index = getBrowserStorageItemsCount(func);
1139
- if (!setBrowserStorageItemsCount(func, index + 1)) {
1140
+ if (index >= browserStorageLimit || !setBrowserStorageItemsCount(func, index + 1)) {
1140
1141
  return;
1141
1142
  }
1142
1143
  }
@@ -1330,7 +1331,6 @@ function parseIconValue(value, onload) {
1330
1331
  // could be 'null' -> icon is missing
1331
1332
  };
1332
1333
  }
1333
-
1334
1334
  const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
1335
1335
  return {
1336
1336
  value,
@@ -1395,6 +1395,34 @@ function calculateSize$1(size, ratio, precision) {
1395
1395
  isNumber = !isNumber;
1396
1396
  }
1397
1397
  }
1398
+ function splitSVGDefs(content, tag = "defs") {
1399
+ let defs = "";
1400
+ const index = content.indexOf("<" + tag);
1401
+ while (index >= 0) {
1402
+ const start = content.indexOf(">", index);
1403
+ const end = content.indexOf("</" + tag);
1404
+ if (start === -1 || end === -1) {
1405
+ break;
1406
+ }
1407
+ const endEnd = content.indexOf(">", end);
1408
+ if (endEnd === -1) {
1409
+ break;
1410
+ }
1411
+ defs += content.slice(start + 1, end).trim();
1412
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
1413
+ }
1414
+ return {
1415
+ defs,
1416
+ content
1417
+ };
1418
+ }
1419
+ function mergeDefsAndContent(defs, content) {
1420
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
1421
+ }
1422
+ function wrapSVGContent(body, start, end) {
1423
+ const split = splitSVGDefs(body);
1424
+ return mergeDefsAndContent(split.defs, start + split.content + end);
1425
+ }
1398
1426
  var isUnsetKeyword = value => value === "unset" || value === "undefined" || value === "none";
1399
1427
  function iconToSVG(icon, customisations) {
1400
1428
  const fullIcon = {
@@ -1461,7 +1489,7 @@ function iconToSVG(icon, customisations) {
1461
1489
  }
1462
1490
  }
1463
1491
  if (transformations.length) {
1464
- body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
1492
+ body = wrapSVGContent(body, '<g transform="' + transformations.join(" ") + '">', "</g>");
1465
1493
  }
1466
1494
  });
1467
1495
  const customisationsWidth = fullCustomisations.width;
@@ -1485,12 +1513,30 @@ function iconToSVG(icon, customisations) {
1485
1513
  };
1486
1514
  setAttr("width", width);
1487
1515
  setAttr("height", height);
1488
- attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
1516
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
1517
+ attributes.viewBox = viewBox.join(" ");
1489
1518
  return {
1490
1519
  attributes,
1520
+ viewBox,
1491
1521
  body
1492
1522
  };
1493
1523
  }
1524
+ function iconToHTML$1(body, attributes) {
1525
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1526
+ for (const attr in attributes) {
1527
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1528
+ }
1529
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1530
+ }
1531
+ function encodeSVGforURL(svg) {
1532
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1533
+ }
1534
+ function svgToData(svg) {
1535
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1536
+ }
1537
+ function svgToURL$1(svg) {
1538
+ return 'url("' + svgToData(svg) + '")';
1539
+ }
1494
1540
  var detectFetch = () => {
1495
1541
  let callback;
1496
1542
  try {
@@ -1715,13 +1761,16 @@ function exportFunctions() {
1715
1761
  return {
1716
1762
  enableCache: storage2 => toggleBrowserCache(storage2, true),
1717
1763
  disableCache: storage2 => toggleBrowserCache(storage2, false),
1718
- iconExists: iconExists$1,
1764
+ iconLoaded: iconLoaded$1,
1765
+ iconExists: iconLoaded$1,
1719
1766
  getIcon: getIcon$1,
1720
1767
  listIcons: listIcons$1,
1721
1768
  addIcon: addIcon$1,
1722
1769
  addCollection: addCollection$1,
1723
1770
  calculateSize: calculateSize$1,
1724
1771
  buildIcon: iconToSVG,
1772
+ iconToHTML: iconToHTML$1,
1773
+ svgToURL: svgToURL$1,
1725
1774
  loadIcons: loadIcons$1,
1726
1775
  loadIcon: loadIcon$1,
1727
1776
  addAPIProvider: addAPIProvider$1,
@@ -1729,22 +1778,6 @@ function exportFunctions() {
1729
1778
  _api: _api2
1730
1779
  };
1731
1780
  }
1732
- function iconToHTML(body, attributes) {
1733
- let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1734
- for (const attr in attributes) {
1735
- renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1736
- }
1737
- return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1738
- }
1739
- function encodeSVGforURL(svg) {
1740
- return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1741
- }
1742
- function svgToData(svg) {
1743
- return "data:image/svg+xml," + encodeSVGforURL(svg);
1744
- }
1745
- function svgToURL(svg) {
1746
- return 'url("' + svgToData(svg) + '")';
1747
- }
1748
1781
  var monotoneProps = {
1749
1782
  "background-color": "currentColor"
1750
1783
  };
@@ -1777,12 +1810,12 @@ function renderSPAN(data, icon, useMask) {
1777
1810
  body += "<!-- " + Date.now() + " -->";
1778
1811
  }
1779
1812
  const renderAttribs = data.attributes;
1780
- const html = iconToHTML(body, {
1813
+ const html = iconToHTML$1(body, {
1781
1814
  ...renderAttribs,
1782
1815
  width: icon.width + "",
1783
1816
  height: icon.height + ""
1784
1817
  });
1785
- const url = svgToURL(html);
1818
+ const url = svgToURL$1(html);
1786
1819
  const svgStyle = node.style;
1787
1820
  const styles = {
1788
1821
  "--svg": url,
@@ -1825,10 +1858,16 @@ function renderSVG(data) {
1825
1858
  if (style) {
1826
1859
  attr.style = style;
1827
1860
  }
1828
- const html = iconToHTML(data.body, attr);
1861
+ const html = iconToHTML$1(data.body, attr);
1829
1862
  node.innerHTML = cleanUpInnerHTML(html);
1830
1863
  return node.firstChild;
1831
1864
  }
1865
+ function findIconElement(parent) {
1866
+ return Array.from(parent.childNodes).find(node => {
1867
+ const tag = node.tagName && node.tagName.toUpperCase();
1868
+ return tag === "SPAN" || tag === "SVG";
1869
+ });
1870
+ }
1832
1871
  function renderIcon(parent, state) {
1833
1872
  const iconData = state.icon.data;
1834
1873
  const customisations = state.customisations;
@@ -1848,10 +1887,7 @@ function renderIcon(parent, state) {
1848
1887
  ...iconData
1849
1888
  }, mode === "mask");
1850
1889
  }
1851
- const oldNode = Array.from(parent.childNodes).find(node2 => {
1852
- const tag = node2.tagName && node2.tagName.toUpperCase();
1853
- return tag === "SPAN" || tag === "SVG";
1854
- });
1890
+ const oldNode = findIconElement(parent);
1855
1891
  if (oldNode) {
1856
1892
  if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
1857
1893
  oldNode.setAttribute("style", node.getAttribute("style"));
@@ -1891,16 +1927,23 @@ function defineIconifyIcon(name = "iconify-icon") {
1891
1927
  // Icon
1892
1928
  "icon",
1893
1929
  // Mode
1894
- "mode", "inline",
1930
+ "mode", "inline", "observe",
1895
1931
  // Customisations
1896
1932
  "width", "height", "rotate", "flip"];
1897
- const IconifyIcon = class extends ParentClass {
1933
+ const IconifyIcon2 = class extends ParentClass {
1898
1934
  // Root
1899
1935
  _shadowRoot;
1900
- // State
1936
+ // Initialised
1937
+ _initialised = false;
1938
+ // Icon state
1901
1939
  _state;
1902
1940
  // Attributes check queued
1903
1941
  _checkQueued = false;
1942
+ // Connected
1943
+ _connected = false;
1944
+ // Observer
1945
+ _observer = null;
1946
+ _visible = true;
1904
1947
  /**
1905
1948
  * Constructor
1906
1949
  */
@@ -1916,6 +1959,20 @@ function defineIconifyIcon(name = "iconify-icon") {
1916
1959
  }, inline);
1917
1960
  this._queueCheck();
1918
1961
  }
1962
+ /**
1963
+ * Connected to DOM
1964
+ */
1965
+ connectedCallback() {
1966
+ this._connected = true;
1967
+ this.startObserver();
1968
+ }
1969
+ /**
1970
+ * Disconnected from DOM
1971
+ */
1972
+ disconnectedCallback() {
1973
+ this._connected = false;
1974
+ this.stopObserver();
1975
+ }
1919
1976
  /**
1920
1977
  * Observed attributes
1921
1978
  */
@@ -1943,15 +2000,29 @@ function defineIconifyIcon(name = "iconify-icon") {
1943
2000
  * Attribute has changed
1944
2001
  */
1945
2002
  attributeChangedCallback(name2) {
1946
- if (name2 === "inline") {
1947
- const newInline = getInline(this);
1948
- const state = this._state;
1949
- if (newInline !== state.inline) {
1950
- state.inline = newInline;
1951
- updateStyle(this._shadowRoot, newInline);
1952
- }
1953
- } else {
1954
- this._queueCheck();
2003
+ switch (name2) {
2004
+ case "inline":
2005
+ {
2006
+ const newInline = getInline(this);
2007
+ const state = this._state;
2008
+ if (newInline !== state.inline) {
2009
+ state.inline = newInline;
2010
+ updateStyle(this._shadowRoot, newInline);
2011
+ }
2012
+ break;
2013
+ }
2014
+ case "observer":
2015
+ {
2016
+ const value = this.observer;
2017
+ if (value) {
2018
+ this.startObserver();
2019
+ } else {
2020
+ this.stopObserver();
2021
+ }
2022
+ break;
2023
+ }
2024
+ default:
2025
+ this._queueCheck();
1955
2026
  }
1956
2027
  }
1957
2028
  /**
@@ -1985,6 +2056,19 @@ function defineIconifyIcon(name = "iconify-icon") {
1985
2056
  this.removeAttribute("inline");
1986
2057
  }
1987
2058
  }
2059
+ /**
2060
+ * Get/set observer
2061
+ */
2062
+ get observer() {
2063
+ return this.hasAttribute("observer");
2064
+ }
2065
+ set observer(value) {
2066
+ if (value) {
2067
+ this.setAttribute("observer", "true");
2068
+ } else {
2069
+ this.removeAttribute("observer");
2070
+ }
2071
+ }
1988
2072
  /**
1989
2073
  * Restart animation
1990
2074
  */
@@ -2033,12 +2117,12 @@ function defineIconifyIcon(name = "iconify-icon") {
2033
2117
  this._iconChanged(newIcon);
2034
2118
  return;
2035
2119
  }
2036
- if (!state.rendered) {
2120
+ if (!state.rendered || !this._visible) {
2037
2121
  return;
2038
2122
  }
2039
2123
  const mode = this.getAttribute("mode");
2040
2124
  const customisations = getCustomisations(this);
2041
- if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations)) {
2125
+ if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations) || !findIconElement(this._shadowRoot)) {
2042
2126
  this._renderIcon(state.icon, customisations, mode);
2043
2127
  }
2044
2128
  }
@@ -2068,6 +2152,19 @@ function defineIconifyIcon(name = "iconify-icon") {
2068
2152
  this._state = setPendingState(icon, this._state.inline, this._state);
2069
2153
  }
2070
2154
  }
2155
+ /**
2156
+ * Force render icon on state change
2157
+ */
2158
+ _forceRender() {
2159
+ if (!this._visible) {
2160
+ const node = findIconElement(this._shadowRoot);
2161
+ if (node) {
2162
+ this._shadowRoot.removeChild(node);
2163
+ }
2164
+ return;
2165
+ }
2166
+ this._queueCheck();
2167
+ }
2071
2168
  /**
2072
2169
  * Got new icon data, icon is ready to (re)render
2073
2170
  */
@@ -2090,10 +2187,47 @@ function defineIconifyIcon(name = "iconify-icon") {
2090
2187
  renderedMode
2091
2188
  });
2092
2189
  }
2190
+ /**
2191
+ * Start observer
2192
+ */
2193
+ startObserver() {
2194
+ if (!this._observer) {
2195
+ try {
2196
+ this._observer = new IntersectionObserver(entries => {
2197
+ const intersecting = entries.some(entry => entry.isIntersecting);
2198
+ if (intersecting !== this._visible) {
2199
+ this._visible = intersecting;
2200
+ this._forceRender();
2201
+ }
2202
+ });
2203
+ this._observer.observe(this);
2204
+ } catch (err) {
2205
+ if (this._observer) {
2206
+ try {
2207
+ this._observer.disconnect();
2208
+ } catch (err2) {}
2209
+ this._observer = null;
2210
+ }
2211
+ }
2212
+ }
2213
+ }
2214
+ /**
2215
+ * Stop observer
2216
+ */
2217
+ stopObserver() {
2218
+ if (this._observer) {
2219
+ this._observer.disconnect();
2220
+ this._observer = null;
2221
+ this._visible = true;
2222
+ if (this._connected) {
2223
+ this._forceRender();
2224
+ }
2225
+ }
2226
+ }
2093
2227
  };
2094
2228
  attributes.forEach(attr => {
2095
- if (!(attr in IconifyIcon.prototype)) {
2096
- Object.defineProperty(IconifyIcon.prototype, attr, {
2229
+ if (!(attr in IconifyIcon2.prototype)) {
2230
+ Object.defineProperty(IconifyIcon2.prototype, attr, {
2097
2231
  get: function () {
2098
2232
  return this.getAttribute(attr);
2099
2233
  },
@@ -2109,29 +2243,33 @@ function defineIconifyIcon(name = "iconify-icon") {
2109
2243
  });
2110
2244
  const functions = exportFunctions();
2111
2245
  for (const key in functions) {
2112
- IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
2246
+ IconifyIcon2[key] = IconifyIcon2.prototype[key] = functions[key];
2113
2247
  }
2114
- customElements.define(name, IconifyIcon);
2115
- return IconifyIcon;
2248
+ customElements.define(name, IconifyIcon2);
2249
+ return IconifyIcon2;
2116
2250
  }
2117
2251
  var IconifyIconComponent = defineIconifyIcon() || exportFunctions();
2118
2252
  var {
2119
2253
  enableCache,
2120
2254
  disableCache,
2255
+ iconLoaded,
2121
2256
  iconExists,
2257
+ // deprecated, kept to avoid breaking changes
2122
2258
  getIcon,
2123
2259
  listIcons,
2124
2260
  addIcon,
2125
2261
  addCollection,
2126
2262
  calculateSize,
2127
2263
  buildIcon,
2264
+ iconToHTML,
2265
+ svgToURL,
2128
2266
  loadIcons,
2129
2267
  loadIcon,
2130
2268
  addAPIProvider,
2131
2269
  _api
2132
2270
  } = IconifyIconComponent;
2133
2271
 
2134
- // ../../node_modules/.pnpm/@iconify-icon+react@1.0.8_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
2272
+ // ../../node_modules/.pnpm/@iconify-icon+react@2.0.1_react@18.2.0/node_modules/@iconify-icon/react/dist/iconify.mjs
2135
2273
  var Icon = /*#__PURE__*/React.forwardRef((props, ref) => {
2136
2274
  const newProps = {
2137
2275
  ...props,
@@ -2149,9 +2287,9 @@ var Icon = /*#__PURE__*/React.forwardRef((props, ref) => {
2149
2287
  return /*#__PURE__*/React.createElement("iconify-icon", newProps);
2150
2288
  });
2151
2289
 
2152
- // ../react-icons/dist/esm/index.js
2290
+ // ../react-icons/src/Icon.tsx
2153
2291
  import { jsx as jsx6 } from "react/jsx-runtime";
2154
- var Icon2 = /* @__PURE__ */React2.forwardRef((props, ref) => {
2292
+ var Icon2 = /*#__PURE__*/React2.forwardRef((props, ref) => {
2155
2293
  return /* @__PURE__ */jsx6(Icon, {
2156
2294
  ref,
2157
2295
  "data-testid": "iconify-icon",
@@ -2360,6 +2498,6 @@ iconify-icon/dist/iconify-icon.mjs:
2360
2498
  * Licensed under MIT.
2361
2499
  *
2362
2500
  * @license MIT
2363
- * @version 1.0.8
2501
+ * @version 2.0.0
2364
2502
  *)
2365
2503
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.22.3",
3
+ "version": "0.22.5",
4
4
  "author": "ttoss",
5
5
  "contributors": [
6
6
  "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com/contact)"
@@ -36,25 +36,25 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=16.8.0",
39
- "@ttoss/react-i18n": "^1.26.0",
40
- "@ttoss/ui": "^4.1.1"
39
+ "@ttoss/react-i18n": "^1.26.1",
40
+ "@ttoss/ui": "^4.1.3"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/jest": "^29.5.11",
44
- "@types/react": "^18.2.48",
43
+ "@types/jest": "^29.5.12",
44
+ "@types/react": "^18.2.58",
45
45
  "jest": "^29.7.0",
46
46
  "react": "^18.2.0",
47
47
  "react-error-boundary": "^4.0.12",
48
48
  "react-hook-form": "^7.50.1",
49
- "theme-ui": "^0.16.1",
50
- "tsup": "^8.0.1",
49
+ "theme-ui": "^0.16.2",
50
+ "tsup": "^8.0.2",
51
51
  "yup": "^1.3.3",
52
- "@ttoss/config": "^1.31.4",
53
- "@ttoss/i18n-cli": "^0.7.5",
54
- "@ttoss/react-i18n": "^1.26.0",
55
- "@ttoss/react-icons": "^0.3.0",
56
- "@ttoss/test-utils": "^2.1.0",
57
- "@ttoss/ui": "^4.1.1"
52
+ "@ttoss/config": "^1.31.5",
53
+ "@ttoss/i18n-cli": "^0.7.6",
54
+ "@ttoss/react-i18n": "^1.26.1",
55
+ "@ttoss/test-utils": "^2.1.1",
56
+ "@ttoss/react-icons": "^0.3.1",
57
+ "@ttoss/ui": "^4.1.3"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public",