sanity-plugin-seofields 1.2.1 → 1.2.3

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.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import o, { useDebugValue, createElement, useRef, useContext, useState, useCallback, useEffect, useMemo } from "react";
2
- import { useClient, useFormValue, defineType, defineField, definePlugin } from "sanity";
2
+ import { useClient, useWorkspace, useFormValue, defineType, defineField, definePlugin } from "sanity";
3
3
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
4
4
  import { useIntentLink } from "sanity/router";
5
+ import { usePaneRouter } from "sanity/structure";
5
6
  import { Stack, Text, Box } from "@sanity/ui";
6
7
  var __assign = function() {
7
8
  return __assign = Object.assign || function(t) {
@@ -1191,16 +1192,9 @@ const DashboardContainer = dt.div`
1191
1192
  color: #6b7280;
1192
1193
  `, StatsGrid = dt.div`
1193
1194
  display: grid;
1194
- grid-template-columns: repeat(6, 1fr);
1195
+ grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
1195
1196
  gap: 14px;
1196
1197
  margin-bottom: 20px;
1197
-
1198
- @media (max-width: 1100px) {
1199
- grid-template-columns: repeat(3, 1fr);
1200
- }
1201
- @media (max-width: 600px) {
1202
- grid-template-columns: repeat(2, 1fr);
1203
- }
1204
1198
  `, StatCard = dt.div`
1205
1199
  background: #ffffff;
1206
1200
  border-radius: 10px;
@@ -1333,6 +1327,11 @@ const DashboardContainer = dt.div`
1333
1327
  align-items: center;
1334
1328
  gap: 4px;
1335
1329
  flex-wrap: wrap;
1330
+ min-width: 0;
1331
+ `, TitleCell = dt.div`
1332
+ min-width: 0;
1333
+ overflow: hidden;
1334
+ flex: 1;
1336
1335
  `, ColType = dt.div`
1337
1336
  flex: 0.8;
1338
1337
  min-width: 80px;
@@ -1524,13 +1523,37 @@ const DashboardContainer = dt.div`
1524
1523
  color: #374151;
1525
1524
  border-color: #9ca3af;
1526
1525
  }
1527
- `, DocTitleAnchor = ({
1526
+ `, DocTitleAnchor = ({ id, type, structureTool, children }) => {
1527
+ const { basePath } = useWorkspace(), { onClick: intentOnClick, href: intentHref } = useIntentLink({ intent: "edit", params: { id, type } }), href = structureTool ? `${basePath}/${structureTool}/intent/edit/id=${id};type=${type}/` : intentHref;
1528
+ return /* @__PURE__ */ jsx(DocTitleLink, { href, onClick: structureTool ? void 0 : intentOnClick, title: "Open document", children });
1529
+ }, PaneLinkWrapper = dt.span`
1530
+ display: block;
1531
+ min-width: 0;
1532
+ overflow: hidden;
1533
+
1534
+ a {
1535
+ font-size: 13px;
1536
+ font-weight: 600;
1537
+ color: #4f46e5;
1538
+ white-space: nowrap;
1539
+ overflow: hidden;
1540
+ text-overflow: ellipsis;
1541
+ text-decoration: none;
1542
+ display: block;
1543
+ transition: color 0.15s;
1544
+
1545
+ &:hover {
1546
+ color: #4338ca;
1547
+ text-decoration: underline;
1548
+ }
1549
+ }
1550
+ `, DocTitleAnchorPane = ({
1528
1551
  id,
1529
1552
  type,
1530
1553
  children
1531
1554
  }) => {
1532
- const { onClick, href } = useIntentLink({ intent: "edit", params: { id, type } });
1533
- return /* @__PURE__ */ jsx(DocTitleLink, { href, onClick, title: "Open document", children });
1555
+ const { ChildLink } = usePaneRouter();
1556
+ return /* @__PURE__ */ jsx(PaneLinkWrapper, { children: /* @__PURE__ */ jsx(ChildLink, { childId: id, childParameters: { type }, children }) });
1534
1557
  }, DocBadgeRenderer = ({ doc, docBadge }) => {
1535
1558
  const badge = docBadge(doc);
1536
1559
  return badge ? /* @__PURE__ */ jsx(CustomBadge, { $bgColor: badge.bgColor, $textColor: badge.textColor, $fontSize: badge.fontSize, children: badge.label }) : null;
@@ -1772,7 +1795,9 @@ const DashboardContainer = dt.div`
1772
1795
  loadingLicense,
1773
1796
  loadingDocuments,
1774
1797
  noDocuments,
1775
- previewMode = !1
1798
+ previewMode = !1,
1799
+ openInPane = !1,
1800
+ structureTool
1776
1801
  }) => {
1777
1802
  const client = useClient({ apiVersion }), [licenseStatus, setLicenseStatus] = useState("loading"), [documents, setDocuments] = useState([]), [loading, setLoading] = useState(!0), [searchQuery, setSearchQuery] = useState(""), [filterStatus, setFilterStatus] = useState("all"), [filterType, setFilterType] = useState("all"), [sortBy, setSortBy] = useState("score"), [activePopover, setActivePopover] = useState(null), VALIDATION_ENDPOINT = "https://sanity-plugin-seofields.thehardik.in/api/validate-license", CACHE_TTL_MS = 3600 * 1e3, validateLicense = useCallback(
1778
1803
  async (forceRefresh = !1) => {
@@ -2057,8 +2082,8 @@ export default defineConfig({
2057
2082
  ] }),
2058
2083
  filteredAndSortedDocs.map((doc) => /* @__PURE__ */ jsxs(TableRow, { children: [
2059
2084
  /* @__PURE__ */ jsx(ColTitle, { children: /* @__PURE__ */ jsxs(TitleWrapper, { children: [
2060
- /* @__PURE__ */ jsxs("div", { children: [
2061
- /* @__PURE__ */ jsx(DocTitleAnchor, { id: doc._id, type: doc._type, children: doc.title || "Untitled" }),
2085
+ /* @__PURE__ */ jsxs(TitleCell, { children: [
2086
+ openInPane ? /* @__PURE__ */ jsx(DocTitleAnchorPane, { id: doc._id, type: doc._type, children: doc.title || "Untitled" }) : /* @__PURE__ */ jsx(DocTitleAnchor, { id: doc._id, type: doc._type, structureTool, children: doc.title || "Untitled" }),
2062
2087
  showDocumentId && /* @__PURE__ */ jsx(DocId, { children: doc._id })
2063
2088
  ] }),
2064
2089
  docBadge && /* @__PURE__ */ jsx(
@@ -3080,7 +3105,8 @@ const resolveDashboardConfig = (healthDashboard) => {
3080
3105
  loadingLicense: cfg?.content?.loadingLicense,
3081
3106
  loadingDocuments: cfg?.content?.loadingDocuments,
3082
3107
  noDocuments: cfg?.content?.noDocuments,
3083
- previewMode: cfg?.previewMode
3108
+ previewMode: cfg?.previewMode,
3109
+ structureTool: cfg?.structureTool
3084
3110
  };
3085
3111
  }, seofields = definePlugin((config = {}) => {
3086
3112
  const { healthDashboard = !0 } = config, dash = resolveDashboardConfig(healthDashboard), BoundSeoHealthTool = () => o.createElement(SeoHealthTool, {
@@ -3101,7 +3127,8 @@ const resolveDashboardConfig = (healthDashboard) => {
3101
3127
  loadingLicense: dash.loadingLicense,
3102
3128
  loadingDocuments: dash.loadingDocuments,
3103
3129
  noDocuments: dash.noDocuments,
3104
- previewMode: dash.previewMode
3130
+ previewMode: dash.previewMode,
3131
+ structureTool: dash.structureTool
3105
3132
  });
3106
3133
  return {
3107
3134
  name: "sanity-plugin-seofields",
@@ -3120,10 +3147,18 @@ const resolveDashboardConfig = (healthDashboard) => {
3120
3147
  }
3121
3148
  };
3122
3149
  });
3150
+ function createSeoHealthPane(optionsOrS, optionsWhenS) {
3151
+ const S2 = optionsOrS, { query, openInPane = !0, title: paneTitle, ...rest } = optionsWhenS ?? {}, SeoHealthPane = () => /* @__PURE__ */ jsx(SeoHealthDashboard, { customQuery: query, openInPane, title: paneTitle, ...rest });
3152
+ return SeoHealthPane.displayName = "SeoHealthPane", S2.component(SeoHealthPane).title(paneTitle ?? "SEO Health").child((docId, { params }) => {
3153
+ const builder = S2.document().documentId(docId);
3154
+ return params?.type ? builder.schemaType(params.type) : builder;
3155
+ });
3156
+ }
3123
3157
  export {
3124
3158
  SeoHealthDashboard,
3125
3159
  SeoHealthTool,
3126
3160
  types as allSchemas,
3161
+ createSeoHealthPane,
3127
3162
  seofields as default,
3128
3163
  metaAttribute as metaAttributeSchema,
3129
3164
  metaTag as metaTagSchema,