sanity-plugin-seofields 1.10.0 → 1.10.1

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.js CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  getTwitterTitleValidation,
26
26
  hasKeywordOveruse,
27
27
  hasMatchingKeyword
28
- } from "./chunk-HHO2AKAP.js";
28
+ } from "./chunk-DB5MBPRK.js";
29
29
  import {
30
30
  __spreadProps,
31
31
  __spreadValues
@@ -927,14 +927,22 @@ import { useMemo as useMemo3 } from "react";
927
927
  import { PatchEvent as PatchEvent4, set as set4, useFormValue as useFormValue6 } from "sanity";
928
928
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
929
929
  var MetaDescription = (props) => {
930
+ var _a, _b;
930
931
  const { value, renderDefault, path, schemaType, onChange } = props;
931
932
  const { options } = schemaType;
932
933
  const parent = useFormValue6([path[0]]);
933
934
  const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
934
935
  const keywords = useMemo3(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
936
+ const rootDoc = useFormValue6([]);
937
+ const keywordsVisible = (_b = (_a = options == null ? void 0 : options.isKeywordsVisible) == null ? void 0 : _a.call(options, rootDoc == null ? void 0 : rootDoc._type)) != null ? _b : true;
935
938
  const feedbackItems = useMemo3(
936
- () => getMetaDescriptionValidationMessages(value || "", keywords, isParentseoField),
937
- [value, keywords, isParentseoField]
939
+ () => getMetaDescriptionValidationMessages(
940
+ value || "",
941
+ keywords,
942
+ isParentseoField,
943
+ keywordsVisible
944
+ ),
945
+ [value, keywords, isParentseoField, keywordsVisible]
938
946
  );
939
947
  const readability = useMemo3(() => analyzeReadability(value || ""), [value]);
940
948
  return /* @__PURE__ */ jsxs7(Stack5, { space: 3, children: [
@@ -1225,7 +1233,7 @@ import { useEffect as useEffect3, useMemo as useMemo6, useState as useState6 } f
1225
1233
  import { PatchEvent as PatchEvent5, set as set5, useClient as useClient3, useFormValue as useFormValue9 } from "sanity";
1226
1234
  import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
1227
1235
  var MetaTitle = (props) => {
1228
- var _a, _b, _c;
1236
+ var _a, _b, _c, _d, _e;
1229
1237
  const { value, renderDefault, path, schemaType, onChange } = props;
1230
1238
  const { options } = schemaType;
1231
1239
  const parent = useFormValue9([path[0]]);
@@ -1269,9 +1277,16 @@ var MetaTitle = (props) => {
1269
1277
  return titleSuffixOption;
1270
1278
  }, [titleSuffixQuery, groqTitleSuffix, titleSuffixOption, rootDoc]);
1271
1279
  const suffixLength = resolvedSuffix ? resolvedSuffix.length + 3 : 0;
1280
+ const keywordsVisible = (_e = (_d = options == null ? void 0 : options.isKeywordsVisible) == null ? void 0 : _d.call(options, rootDoc == null ? void 0 : rootDoc._type)) != null ? _e : true;
1272
1281
  const feedbackItems = useMemo6(
1273
- () => getMetaTitleValidationMessages(value || "", keywords, isParentseoField, suffixLength),
1274
- [value, keywords, isParentseoField, suffixLength]
1282
+ () => getMetaTitleValidationMessages(
1283
+ value || "",
1284
+ keywords,
1285
+ isParentseoField,
1286
+ suffixLength,
1287
+ keywordsVisible
1288
+ ),
1289
+ [value, keywords, isParentseoField, suffixLength, keywordsVisible]
1275
1290
  );
1276
1291
  return /* @__PURE__ */ jsxs10(Stack8, { space: 3, children: [
1277
1292
  renderDefault(props),
@@ -1455,6 +1470,9 @@ var getFieldHiddenFunction = (fieldName, config) => {
1455
1470
  return isFieldHidden(fieldName, config, documentType);
1456
1471
  };
1457
1472
  };
1473
+ var getKeywordsVisibilityChecker = (config) => {
1474
+ return (documentType) => !isFieldHidden("keywords", config, documentType);
1475
+ };
1458
1476
 
1459
1477
  // src/utils/utils.ts
1460
1478
  var isEmpty = (value) => {
@@ -1470,14 +1488,17 @@ import { useMemo as useMemo7 } from "react";
1470
1488
  import { PatchEvent as PatchEvent6, set as set6, useFormValue as useFormValue10 } from "sanity";
1471
1489
  import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
1472
1490
  var OgDescription = (props) => {
1491
+ var _a, _b;
1473
1492
  const { value, renderDefault, path, schemaType, onChange } = props;
1474
1493
  const { options } = schemaType;
1475
1494
  const parent = useFormValue10([path[0]]);
1476
1495
  const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
1477
1496
  const keywords = useMemo7(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
1497
+ const rootDoc = useFormValue10([]);
1498
+ const keywordsVisible = (_b = (_a = options == null ? void 0 : options.isKeywordsVisible) == null ? void 0 : _a.call(options, rootDoc == null ? void 0 : rootDoc._type)) != null ? _b : true;
1478
1499
  const feedbackItems = useMemo7(
1479
- () => getOgDescriptionValidation(value || "", keywords, isParentseoField),
1480
- [value, keywords, isParentseoField]
1500
+ () => getOgDescriptionValidation(value || "", keywords, isParentseoField, keywordsVisible),
1501
+ [value, keywords, isParentseoField, keywordsVisible]
1481
1502
  );
1482
1503
  return /* @__PURE__ */ jsxs11(Stack9, { space: 3, children: [
1483
1504
  renderDefault(props),
@@ -1578,14 +1599,17 @@ import { useMemo as useMemo10 } from "react";
1578
1599
  import { PatchEvent as PatchEvent7, set as set7, useFormValue as useFormValue13 } from "sanity";
1579
1600
  import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
1580
1601
  var OgTitle = (props) => {
1602
+ var _a, _b;
1581
1603
  const { value, renderDefault, path, schemaType, onChange } = props;
1582
1604
  const { options } = schemaType;
1583
1605
  const parent = useFormValue13([path[0]]);
1584
1606
  const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
1585
1607
  const keywords = useMemo10(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
1608
+ const rootDoc = useFormValue13([]);
1609
+ const keywordsVisible = (_b = (_a = options == null ? void 0 : options.isKeywordsVisible) == null ? void 0 : _a.call(options, rootDoc == null ? void 0 : rootDoc._type)) != null ? _b : true;
1586
1610
  const feedbackItems = useMemo10(
1587
- () => getOgTitleValidation(value || "", keywords, isParentseoField),
1588
- [value, keywords, isParentseoField]
1611
+ () => getOgTitleValidation(value || "", keywords, isParentseoField, keywordsVisible),
1612
+ [value, keywords, isParentseoField, keywordsVisible]
1589
1613
  );
1590
1614
  return /* @__PURE__ */ jsxs14(Stack12, { space: 3, children: [
1591
1615
  renderDefault(props),
@@ -1638,7 +1662,9 @@ function openGraph(config = {}) {
1638
1662
  components: {
1639
1663
  input: OgTitle_default
1640
1664
  },
1641
- options: __spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {})
1665
+ options: __spreadProps(__spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {}), {
1666
+ isKeywordsVisible: getKeywordsVisibilityChecker(config)
1667
+ })
1642
1668
  })),
1643
1669
  defineField(__spreadProps(__spreadValues({
1644
1670
  name: "description"
@@ -1649,7 +1675,9 @@ function openGraph(config = {}) {
1649
1675
  components: {
1650
1676
  input: OgDescription_default
1651
1677
  },
1652
- options: __spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {})
1678
+ options: __spreadProps(__spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {}), {
1679
+ isKeywordsVisible: getKeywordsVisibilityChecker(config)
1680
+ })
1653
1681
  })),
1654
1682
  defineField(__spreadProps(__spreadValues({
1655
1683
  name: "siteName"
@@ -1741,14 +1769,17 @@ import { useMemo as useMemo11 } from "react";
1741
1769
  import { PatchEvent as PatchEvent8, set as set8, useFormValue as useFormValue14 } from "sanity";
1742
1770
  import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
1743
1771
  var TwitterDescription = (props) => {
1772
+ var _a, _b;
1744
1773
  const { value, renderDefault, path, schemaType, onChange } = props;
1745
1774
  const { options } = schemaType;
1746
1775
  const parent = useFormValue14([path[0]]);
1747
1776
  const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
1748
1777
  const keywords = useMemo11(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
1778
+ const rootDoc = useFormValue14([]);
1779
+ const keywordsVisible = (_b = (_a = options == null ? void 0 : options.isKeywordsVisible) == null ? void 0 : _a.call(options, rootDoc == null ? void 0 : rootDoc._type)) != null ? _b : true;
1749
1780
  const feedbackItems = useMemo11(
1750
- () => getTwitterDescriptionValidation(value || "", keywords, isParentseoField),
1751
- [value, keywords, isParentseoField]
1781
+ () => getTwitterDescriptionValidation(value || "", keywords, isParentseoField, keywordsVisible),
1782
+ [value, keywords, isParentseoField, keywordsVisible]
1752
1783
  );
1753
1784
  return /* @__PURE__ */ jsxs15(Stack13, { space: 3, children: [
1754
1785
  renderDefault(props),
@@ -1852,14 +1883,17 @@ import { useMemo as useMemo14 } from "react";
1852
1883
  import { PatchEvent as PatchEvent9, set as set9, useFormValue as useFormValue17 } from "sanity";
1853
1884
  import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
1854
1885
  var TwitterTitle = (props) => {
1886
+ var _a, _b;
1855
1887
  const { value, renderDefault, path, schemaType, onChange } = props;
1856
1888
  const { options } = schemaType;
1857
1889
  const parent = useFormValue17([path[0]]);
1858
1890
  const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
1859
1891
  const keywords = useMemo14(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
1892
+ const rootDoc = useFormValue17([]);
1893
+ const keywordsVisible = (_b = (_a = options == null ? void 0 : options.isKeywordsVisible) == null ? void 0 : _a.call(options, rootDoc == null ? void 0 : rootDoc._type)) != null ? _b : true;
1860
1894
  const feedbackItems = useMemo14(
1861
- () => getTwitterTitleValidation(value || "", keywords, isParentseoField),
1862
- [value, keywords, isParentseoField]
1895
+ () => getTwitterTitleValidation(value || "", keywords, isParentseoField, keywordsVisible),
1896
+ [value, keywords, isParentseoField, keywordsVisible]
1863
1897
  );
1864
1898
  return /* @__PURE__ */ jsxs18(Stack16, { space: 3, children: [
1865
1899
  renderDefault(props),
@@ -1933,7 +1967,9 @@ function twitter(config = {}) {
1933
1967
  components: {
1934
1968
  input: twitterTitle_default
1935
1969
  },
1936
- options: __spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {})
1970
+ options: __spreadProps(__spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {}), {
1971
+ isKeywordsVisible: getKeywordsVisibilityChecker(config)
1972
+ })
1937
1973
  })),
1938
1974
  defineField2(__spreadProps(__spreadValues({
1939
1975
  name: "description",
@@ -1944,7 +1980,9 @@ function twitter(config = {}) {
1944
1980
  components: {
1945
1981
  input: twitterDescription_default
1946
1982
  },
1947
- options: __spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {})
1983
+ options: __spreadProps(__spreadValues({}, config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {}), {
1984
+ isKeywordsVisible: getKeywordsVisibilityChecker(config)
1985
+ })
1948
1986
  })),
1949
1987
  defineField2(__spreadProps(__spreadValues({
1950
1988
  name: "imageType"
@@ -2003,7 +2041,7 @@ function twitter(config = {}) {
2003
2041
  }
2004
2042
 
2005
2043
  // src/schemas/index.ts
2006
- var LazySeoPreview = lazy(() => import("./SeoPreview-UNQBKTQO.js"));
2044
+ var LazySeoPreview = lazy(() => import("./SeoPreview-TATJQFMP.js"));
2007
2045
  var SeoPreviewWrapper = (props) => createElement(Suspense, { fallback: null }, createElement(LazySeoPreview, props));
2008
2046
  function buildFieldGroupMap(groups) {
2009
2047
  const map = /* @__PURE__ */ new Map();
@@ -2067,7 +2105,9 @@ function getAiOption(config) {
2067
2105
  return config.ai ? { ai: withLicense(config.ai, config.licenseKey) } : {};
2068
2106
  }
2069
2107
  function getTitleFieldOptions(config) {
2070
- return __spreadValues(__spreadValues(__spreadValues({}, config.apiVersion ? { apiVersion: config.apiVersion } : {}), getSeoPreviewSuffixOptions(config.seoPreview)), getAiOption(config));
2108
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, config.apiVersion ? { apiVersion: config.apiVersion } : {}), getSeoPreviewSuffixOptions(config.seoPreview)), getAiOption(config)), {
2109
+ isKeywordsVisible: getKeywordsVisibilityChecker(config)
2110
+ });
2071
2111
  }
2072
2112
  function buildGeoChecklistField(config, fieldGroupMap) {
2073
2113
  if (config.geo === false) return [];
@@ -2163,7 +2203,9 @@ function seoFieldsSchema(config = {}) {
2163
2203
  components: {
2164
2204
  input: MetaDescription_default
2165
2205
  },
2166
- options: getAiOption(config),
2206
+ options: __spreadProps(__spreadValues({}, getAiOption(config)), {
2207
+ isKeywordsVisible: getKeywordsVisibilityChecker(config)
2208
+ }),
2167
2209
  hidden: getFieldHiddenFunction("description", config)
2168
2210
  })),
2169
2211
  fieldGroupMap