inferred-types 0.55.18 → 0.55.19

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.
@@ -426,6 +426,7 @@ __export(index_exports, {
426
426
  isHmUrl: () => isHmUrl,
427
427
  isHomeDepotUrl: () => isHomeDepotUrl,
428
428
  isHtml: () => isHtml,
429
+ isHtmlComponentTag: () => isHtmlComponentTag,
429
430
  isHtmlElement: () => isHtmlElement,
430
431
  isIkeaUrl: () => isIkeaUrl,
431
432
  isIndexable: () => isIndexable,
@@ -572,6 +573,7 @@ __export(index_exports, {
572
573
  isValidAtomicTag: () => isValidAtomicTag,
573
574
  isValidBlockTag: () => isValidBlockTag,
574
575
  isValidHtml: () => isValidHtml,
576
+ isValidHtmlTag: () => isValidHtmlTag,
575
577
  isVariable: () => isVariable,
576
578
  isVisa: () => isVisa,
577
579
  isVisaMastercard: () => isVisaMastercard,
@@ -698,6 +700,7 @@ __export(index_exports, {
698
700
  unset: () => unset,
699
701
  uppercase: () => uppercase,
700
702
  urlMeta: () => urlMeta,
703
+ validHtmlAttributes: () => validHtmlAttributes,
701
704
  valuesOf: () => valuesOf,
702
705
  widen: () => widen,
703
706
  withDefaults: () => withDefaults,
@@ -6675,6 +6678,34 @@ function startsWith(startingWith) {
6675
6678
  return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
6676
6679
  };
6677
6680
  }
6681
+ function isHtmlComponentTag(...names) {
6682
+ return (val) => {
6683
+ if (typeof val !== "string")
6684
+ return false;
6685
+ const trimmedVal = val.trim();
6686
+ const tagRegex = /^<\/?([\w-]+)(.*?)>$/;
6687
+ const match = tagRegex.exec(trimmedVal);
6688
+ if (!match) {
6689
+ return false;
6690
+ }
6691
+ const [, tagName, attributes] = match;
6692
+ const isClosingTag = trimmedVal.startsWith("</");
6693
+ const isKebabCase = /^[a-z][a-z0-9-]*$/.test(tagName);
6694
+ const isPascalCase = /^[A-Z][a-zA-Z0-9]*$/.test(tagName);
6695
+ const normalizedKebabCase = toKebabCase(tagName);
6696
+ const normalizedPascalCase = toPascalCase(tagName);
6697
+ const isValidName = names.some(
6698
+ (name) => isKebabCase && normalizedKebabCase === toKebabCase(name) || isPascalCase && normalizedPascalCase === toPascalCase(name)
6699
+ );
6700
+ if (!isValidName) {
6701
+ return false;
6702
+ }
6703
+ if (isClosingTag) {
6704
+ return attributes.trim() === "";
6705
+ }
6706
+ return validHtmlAttributes(attributes);
6707
+ };
6708
+ }
6678
6709
  function hasHtml(val) {
6679
6710
  if (typeof val !== "string")
6680
6711
  return false;
@@ -6718,6 +6749,39 @@ function isValidBlockTag(val) {
6718
6749
  function isValidAtomicTag(val) {
6719
6750
  return isString(val) && HTML_ATOMIC_TAGS2.includes(val.toLowerCase());
6720
6751
  }
6752
+ function isValidHtmlTag(...tags) {
6753
+ return (val) => {
6754
+ if (typeof val !== "string")
6755
+ return false;
6756
+ const trimmedVal = val.trim();
6757
+ const tagRegex = /^<\/?(\w+)(.*?)>$/;
6758
+ const match = tagRegex.exec(trimmedVal);
6759
+ if (!match) {
6760
+ return false;
6761
+ }
6762
+ const [, tagName, attributes] = match;
6763
+ const normalizedTagName = tagName.toLowerCase();
6764
+ const isClosingTag = trimmedVal.startsWith("</");
6765
+ const isAtomicTag = HTML_ATOMIC_TAGS2.includes(normalizedTagName);
6766
+ const isBlockTag = HTML_BLOCK_TAGS2.includes(normalizedTagName);
6767
+ if (
6768
+ // Validate tag name is within the provided `tags` scope
6769
+ !tags.map((t) => t.toLowerCase()).includes(normalizedTagName)
6770
+ ) {
6771
+ return false;
6772
+ }
6773
+ if (isClosingTag) {
6774
+ return attributes.trim() === "" && !isAtomicTag;
6775
+ }
6776
+ if (isAtomicTag) {
6777
+ return attributes.trim() === "" || validHtmlAttributes(attributes);
6778
+ }
6779
+ if (isBlockTag) {
6780
+ return validHtmlAttributes(attributes);
6781
+ }
6782
+ return false;
6783
+ };
6784
+ }
6721
6785
  function isHtml(val) {
6722
6786
  if (typeof val !== "string")
6723
6787
  return false;
@@ -6760,6 +6824,14 @@ function isValidHtml(val) {
6760
6824
  function isHtmlElement(val) {
6761
6825
  return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
6762
6826
  }
6827
+ function validHtmlAttributes(val) {
6828
+ if (typeof val !== "string")
6829
+ return false;
6830
+ const quoteRegex = /["']/g;
6831
+ const unmatchedQuotes = (val.match(quoteRegex)?.length || 0) % 2 !== 0;
6832
+ const invalidAssignment = /(\w+=)(?=\s|>|$)/.test(val);
6833
+ return !val.includes(">") && !unmatchedQuotes && !invalidAssignment;
6834
+ }
6763
6835
  function isAlpha(value) {
6764
6836
  return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
6765
6837
  }
@@ -9383,6 +9455,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
9383
9455
  isHmUrl,
9384
9456
  isHomeDepotUrl,
9385
9457
  isHtml,
9458
+ isHtmlComponentTag,
9386
9459
  isHtmlElement,
9387
9460
  isIkeaUrl,
9388
9461
  isIndexable,
@@ -9529,6 +9602,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
9529
9602
  isValidAtomicTag,
9530
9603
  isValidBlockTag,
9531
9604
  isValidHtml,
9605
+ isValidHtmlTag,
9532
9606
  isVariable,
9533
9607
  isVisa,
9534
9608
  isVisaMastercard,
@@ -9655,6 +9729,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
9655
9729
  unset,
9656
9730
  uppercase,
9657
9731
  urlMeta,
9732
+ validHtmlAttributes,
9658
9733
  valuesOf,
9659
9734
  widen,
9660
9735
  withDefaults,