inferred-types 0.55.18 → 0.55.20

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.
@@ -222,6 +222,7 @@ __export(index_exports, {
222
222
  isHmUrl: () => isHmUrl,
223
223
  isHomeDepotUrl: () => isHomeDepotUrl,
224
224
  isHtml: () => isHtml,
225
+ isHtmlComponentTag: () => isHtmlComponentTag,
225
226
  isHtmlElement: () => isHtmlElement,
226
227
  isIkeaUrl: () => isIkeaUrl,
227
228
  isIndexable: () => isIndexable,
@@ -368,6 +369,7 @@ __export(index_exports, {
368
369
  isValidAtomicTag: () => isValidAtomicTag,
369
370
  isValidBlockTag: () => isValidBlockTag,
370
371
  isValidHtml: () => isValidHtml,
372
+ isValidHtmlTag: () => isValidHtmlTag,
371
373
  isVariable: () => isVariable,
372
374
  isVisa: () => isVisa,
373
375
  isVisaMastercard: () => isVisaMastercard,
@@ -494,6 +496,7 @@ __export(index_exports, {
494
496
  unset: () => unset,
495
497
  uppercase: () => uppercase,
496
498
  urlMeta: () => urlMeta,
499
+ validHtmlAttributes: () => validHtmlAttributes,
497
500
  valuesOf: () => valuesOf,
498
501
  widen: () => widen,
499
502
  withDefaults: () => withDefaults,
@@ -2443,17 +2446,17 @@ var TW_HUE = {
2443
2446
  ...TW_HUE_STATIC
2444
2447
  };
2445
2448
  var TW_LUMINOSITY = {
2446
- 50: 97.78,
2447
- 100: 93.56,
2448
- 200: 88.11,
2449
- 300: 82.67,
2450
- 400: 74.22,
2451
- 500: 64.78,
2452
- 600: 57.33,
2453
- 700: 46.89,
2454
- 800: 39.44,
2455
- 900: 32,
2456
- 950: 23.78
2449
+ "50": 97.78,
2450
+ "100": 93.56,
2451
+ "200": 88.11,
2452
+ "300": 82.67,
2453
+ "400": 74.22,
2454
+ "500": 64.78,
2455
+ "600": 57.33,
2456
+ "700": 46.89,
2457
+ "800": 39.44,
2458
+ "900": 32,
2459
+ "950": 23.78
2457
2460
  };
2458
2461
  var TW_LUMIN_50 = TW_LUMINOSITY["50"];
2459
2462
  var TW_LUMIN_100 = TW_LUMINOSITY["100"];
@@ -2467,17 +2470,17 @@ var TW_LUMIN_800 = TW_LUMINOSITY["800"];
2467
2470
  var TW_LUMIN_900 = TW_LUMINOSITY["900"];
2468
2471
  var TW_LUMIN_950 = TW_LUMINOSITY["950"];
2469
2472
  var TW_CHROMA = {
2470
- 50: 0.0108,
2471
- 100: 0.0321,
2472
- 200: 0.0609,
2473
- 300: 0.0908,
2474
- 400: 0.1398,
2475
- 500: 0.1472,
2476
- 600: 0.1299,
2477
- 700: 0.1067,
2478
- 800: 0.0898,
2479
- 900: 0.0726,
2480
- 950: 0.054
2473
+ "50": 0.0108,
2474
+ "100": 0.0321,
2475
+ "200": 0.0609,
2476
+ "300": 0.0908,
2477
+ "400": 0.1398,
2478
+ "500": 0.1472,
2479
+ "600": 0.1299,
2480
+ "700": 0.1067,
2481
+ "800": 0.0898,
2482
+ "900": 0.0726,
2483
+ "950": 0.054
2481
2484
  };
2482
2485
  var TW_CHROMA_50 = TW_CHROMA["50"];
2483
2486
  var TW_CHROMA_100 = TW_CHROMA["100"];
@@ -4000,6 +4003,36 @@ function startsWith(startingWith) {
4000
4003
  };
4001
4004
  }
4002
4005
 
4006
+ // src/type-guards/html/component-tags.ts
4007
+ function isHtmlComponentTag(...names) {
4008
+ return (val) => {
4009
+ if (typeof val !== "string")
4010
+ return false;
4011
+ const trimmedVal = val.trim();
4012
+ const tagRegex = /^<\/?([\w-]+)(.*?)>$/;
4013
+ const match = tagRegex.exec(trimmedVal);
4014
+ if (!match) {
4015
+ return false;
4016
+ }
4017
+ const [, tagName, attributes] = match;
4018
+ const isClosingTag = trimmedVal.startsWith("</");
4019
+ const isKebabCase = /^[a-z][a-z0-9-]*$/.test(tagName);
4020
+ const isPascalCase = /^[A-Z][a-zA-Z0-9]*$/.test(tagName);
4021
+ const normalizedKebabCase = toKebabCase(tagName);
4022
+ const normalizedPascalCase = toPascalCase(tagName);
4023
+ const isValidName = names.some(
4024
+ (name) => isKebabCase && normalizedKebabCase === toKebabCase(name) || isPascalCase && normalizedPascalCase === toPascalCase(name)
4025
+ );
4026
+ if (!isValidName) {
4027
+ return false;
4028
+ }
4029
+ if (isClosingTag) {
4030
+ return attributes.trim() === "";
4031
+ }
4032
+ return validHtmlAttributes(attributes);
4033
+ };
4034
+ }
4035
+
4003
4036
  // src/type-guards/html/hasHtml.ts
4004
4037
  function hasHtml(val) {
4005
4038
  if (typeof val !== "string")
@@ -4046,6 +4079,39 @@ function isValidBlockTag(val) {
4046
4079
  function isValidAtomicTag(val) {
4047
4080
  return isString(val) && HTML_ATOMIC_TAGS.includes(val.toLowerCase());
4048
4081
  }
4082
+ function isValidHtmlTag(...tags) {
4083
+ return (val) => {
4084
+ if (typeof val !== "string")
4085
+ return false;
4086
+ const trimmedVal = val.trim();
4087
+ const tagRegex = /^<\/?(\w+)(.*?)>$/;
4088
+ const match = tagRegex.exec(trimmedVal);
4089
+ if (!match) {
4090
+ return false;
4091
+ }
4092
+ const [, tagName, attributes] = match;
4093
+ const normalizedTagName = tagName.toLowerCase();
4094
+ const isClosingTag = trimmedVal.startsWith("</");
4095
+ const isAtomicTag = HTML_ATOMIC_TAGS.includes(normalizedTagName);
4096
+ const isBlockTag = HTML_BLOCK_TAGS.includes(normalizedTagName);
4097
+ if (
4098
+ // Validate tag name is within the provided `tags` scope
4099
+ !tags.map((t) => t.toLowerCase()).includes(normalizedTagName)
4100
+ ) {
4101
+ return false;
4102
+ }
4103
+ if (isClosingTag) {
4104
+ return attributes.trim() === "" && !isAtomicTag;
4105
+ }
4106
+ if (isAtomicTag) {
4107
+ return attributes.trim() === "" || validHtmlAttributes(attributes);
4108
+ }
4109
+ if (isBlockTag) {
4110
+ return validHtmlAttributes(attributes);
4111
+ }
4112
+ return false;
4113
+ };
4114
+ }
4049
4115
 
4050
4116
  // src/type-guards/html/isHtml.ts
4051
4117
  function isHtml(val) {
@@ -4093,6 +4159,16 @@ function isHtmlElement(val) {
4093
4159
  return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
4094
4160
  }
4095
4161
 
4162
+ // src/type-guards/html/validHtmlAttributes.ts
4163
+ function validHtmlAttributes(val) {
4164
+ if (typeof val !== "string")
4165
+ return false;
4166
+ const quoteRegex = /["']/g;
4167
+ const unmatchedQuotes = (val.match(quoteRegex)?.length || 0) % 2 !== 0;
4168
+ const invalidAssignment = /(\w+=)(?=\s|>|$)/.test(val);
4169
+ return !val.includes(">") && !unmatchedQuotes && !invalidAssignment;
4170
+ }
4171
+
4096
4172
  // src/type-guards/isAlpha.ts
4097
4173
  function isAlpha(value) {
4098
4174
  return isString(value) && split(value).every((v) => ALPHA_CHARS.includes(v));
@@ -6674,6 +6750,7 @@ function asVueRef(value) {
6674
6750
  isHmUrl,
6675
6751
  isHomeDepotUrl,
6676
6752
  isHtml,
6753
+ isHtmlComponentTag,
6677
6754
  isHtmlElement,
6678
6755
  isIkeaUrl,
6679
6756
  isIndexable,
@@ -6820,6 +6897,7 @@ function asVueRef(value) {
6820
6897
  isValidAtomicTag,
6821
6898
  isValidBlockTag,
6822
6899
  isValidHtml,
6900
+ isValidHtmlTag,
6823
6901
  isVariable,
6824
6902
  isVisa,
6825
6903
  isVisaMastercard,
@@ -6946,6 +7024,7 @@ function asVueRef(value) {
6946
7024
  unset,
6947
7025
  uppercase,
6948
7026
  urlMeta,
7027
+ validHtmlAttributes,
6949
7028
  valuesOf,
6950
7029
  widen,
6951
7030
  withDefaults,