UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

144 lines (143 loc) • 6.84 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { c } from "react-compiler-runtime"; import { useGetI18nText, CommandList, useI18nText } from "sanity"; import { Button } from "./generate-help-url.esm.mjs"; import "../_singletons.mjs"; import "./StructureToolProvider.mjs"; import { usePaneLayout, PaneContent, PaneItem, useStructureTool, usePane, PaneHeader, PaneHeaderActions, BackLink, Pane, _DEBUG } from "./pane.mjs"; import { Box, Text } from "@sanity/ui"; import { styled } from "styled-components"; import { ArrowLeftIcon } from "@sanity/icons"; const DividerContainer = styled(Box)` display: flex; align-items: center; gap: 1rem; margin: 0.75rem 0 0.25rem 0; `, Divider = styled.hr` flex: 1; background-color: var(--card-border-color); height: 1px; margin: 0; border: none; `, DividerTitle = styled(Text)` padding-bottom: 0.75rem; padding-left: 0.5rem; padding-right: 0.5rem; `; function DividerItem(t0) { const $ = c(5), { item } = t0, { title: dividerTitle } = useI18nText(item); let t1; $[0] !== dividerTitle ? (t1 = /* @__PURE__ */ jsx(DividerTitle, { weight: "semibold", muted: !0, size: 1, children: dividerTitle }), $[0] = dividerTitle, $[1] = t1) : t1 = $[1]; let t2; $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Divider, {}), $[2] = t2) : t2 = $[2]; let t3; return $[3] !== t1 ? (t3 = /* @__PURE__ */ jsxs(DividerContainer, { children: [ t1, t2 ] }), $[3] = t1, $[4] = t3) : t3 = $[4], t3; } function ListPaneContent(props) { const $ = c(20), { childItemId, items, isActive, layout, showIcons, title } = props, { collapsed: layoutCollapsed } = usePaneLayout(); let t0; $[0] !== items ? (t0 = items?.filter(_temp), $[0] = items, $[1] = t0) : t0 = $[1]; const getI18nText = useGetI18nText(t0); let t1; $[2] !== items ? (t1 = (itemIndex) => items?.find((_, i) => i === itemIndex)?.type === "divider", $[2] = items, $[3] = t1) : t1 = $[3]; const getItemDisabled = t1; let t2; $[4] !== showIcons ? (t2 = (item_0) => { const itemShowIcon = item_0.displayOptions?.showIcon; return typeof itemShowIcon < "u" ? itemShowIcon !== !1 : showIcons !== !1; }, $[4] = showIcons, $[5] = t2) : t2 = $[5]; const shouldShowIconForItem = t2; let t3; $[6] !== childItemId || $[7] !== getI18nText || $[8] !== isActive || $[9] !== layout || $[10] !== shouldShowIconForItem ? (t3 = (item_1, ctx) => { const { virtualIndex: itemIndex_0 } = ctx; if (item_1.type === "divider") return /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: item_1.title ? /* @__PURE__ */ jsx(DividerItem, { item: item_1 }) : /* @__PURE__ */ jsx(Divider, {}) }, `divider-${itemIndex_0}`); const pressed = !isActive && childItemId === item_1.id, selected = isActive && childItemId === item_1.id, value = item_1._id && item_1.schemaType ? { _id: item_1._id, _type: item_1.schemaType.name, title: item_1.title } : void 0; return /* @__PURE__ */ jsx(PaneItem, { icon: shouldShowIconForItem(item_1) ? item_1.icon : !1, id: item_1.id, layout, marginBottom: 1, pressed, schemaType: item_1.schemaType, selected, title: getI18nText(item_1).title, value }, item_1.id); }, $[6] = childItemId, $[7] = getI18nText, $[8] = isActive, $[9] = layout, $[10] = shouldShowIconForItem, $[11] = t3) : t3 = $[11]; const renderItem = t3, t4 = layoutCollapsed ? "hidden" : "auto"; let t5; $[12] !== getItemDisabled || $[13] !== items || $[14] !== renderItem || $[15] !== title ? (t5 = items && items.length > 0 && /* @__PURE__ */ jsx(CommandList, { activeItemDataAttr: "data-hovered", ariaLabel: title, canReceiveFocus: !0, getItemDisabled, itemHeight: 51, items, onlyShowSelectionWhenActive: !0, paddingBottom: 1, paddingX: 3, renderItem, wrapAround: !1 }), $[12] = getItemDisabled, $[13] = items, $[14] = renderItem, $[15] = title, $[16] = t5) : t5 = $[16]; let t6; return $[17] !== t4 || $[18] !== t5 ? (t6 = /* @__PURE__ */ jsx(PaneContent, { overflow: t4, children: t5 }), $[17] = t4, $[18] = t5, $[19] = t6) : t6 = $[19], t6; } function _temp(item) { return item.type !== "divider"; } const ListPaneHeader = (t0) => { const $ = c(11), { index, menuItems, menuItemGroups, title } = t0, { features } = useStructureTool(), { collapsed, isLast } = usePane(), tabIndex = isLast && !collapsed ? -1 : 0; let t1; $[0] !== menuItemGroups || $[1] !== menuItems ? (t1 = /* @__PURE__ */ jsx(PaneHeaderActions, { menuItems, menuItemGroups }), $[0] = menuItemGroups, $[1] = menuItems, $[2] = t1) : t1 = $[2]; let t2; $[3] !== features.backButton || $[4] !== index ? (t2 = features.backButton && index > 0 && /* @__PURE__ */ jsx(Button, { as: BackLink, "data-as": "a", icon: ArrowLeftIcon, mode: "bleed", tooltipProps: { content: "Back" } }), $[3] = features.backButton, $[4] = index, $[5] = t2) : t2 = $[5]; let t3; return $[6] !== t1 || $[7] !== t2 || $[8] !== tabIndex || $[9] !== title ? (t3 = /* @__PURE__ */ jsx(PaneHeader, { actions: t1, backButton: t2, tabIndex, title }), $[6] = t1, $[7] = t2, $[8] = tabIndex, $[9] = title, $[10] = t3) : t3 = $[10], t3; }; function ListPane(props) { const $ = c(21), { childItemId, index, isActive, isSelected, pane, paneKey } = props, { defaultLayout, displayOptions, items, menuItems, menuItemGroups } = pane, showIcons = displayOptions?.showIcons !== !1, { title } = useI18nText(pane); let t0; $[0] !== pane.source ? (t0 = _DEBUG, $[0] = pane.source, $[1] = t0) : t0 = $[1]; let t1; $[2] !== index || $[3] !== menuItemGroups || $[4] !== menuItems || $[5] !== title ? (t1 = /* @__PURE__ */ jsx(ListPaneHeader, { index, menuItems, menuItemGroups, title }), $[2] = index, $[3] = menuItemGroups, $[4] = menuItems, $[5] = title, $[6] = t1) : t1 = $[6]; let t2; $[7] !== childItemId || $[8] !== defaultLayout || $[9] !== isActive || $[10] !== items || $[11] !== paneKey || $[12] !== showIcons || $[13] !== title ? (t2 = /* @__PURE__ */ jsx(ListPaneContent, { childItemId, isActive, items, layout: defaultLayout, showIcons, title }, paneKey), $[7] = childItemId, $[8] = defaultLayout, $[9] = isActive, $[10] = items, $[11] = paneKey, $[12] = showIcons, $[13] = title, $[14] = t2) : t2 = $[14]; let t3; return $[15] !== isSelected || $[16] !== paneKey || $[17] !== t0 || $[18] !== t1 || $[19] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Pane, { currentMaxWidth: 350, "data-testid": "structure-tool-list-pane", "data-ui": "ListPane", id: paneKey, maxWidth: 640, minWidth: 320, selected: isSelected, children: [ t0, t1, t2 ] }), $[15] = isSelected, $[16] = paneKey, $[17] = t0, $[18] = t1, $[19] = t2, $[20] = t3) : t3 = $[20], t3; } export { ListPane as default }; //# sourceMappingURL=index2.mjs.map