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

89 lines (88 loc) 2.75 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { useState, createElement, isValidElement } from "react"; import { isValidElementType } from "react-is"; import { useI18nText } from "sanity"; import { Box } from "@sanity/ui"; import { B as Button } from "./getJsonStream.js"; import { X as usePane, W as useStructureTool, Y as PaneHeader, Z as PaneHeaderActions, _ as BackLink, $ as Pane } from "./StructureToolProvider.js"; import { ArrowLeftIcon } from "@sanity/icons"; import "sanity/router"; import "@sanity/types"; import "@sanity/util/paths"; import "lodash/omit.js"; import "lodash/isNumber.js"; import "lodash/isString.js"; import "react-rx"; import styled from "styled-components"; const Root = styled(Box)` position: relative; `; function UserComponentPaneContent(props) { const { children } = props, { collapsed } = usePane(); return /* @__PURE__ */ jsx(Root, { hidden: collapsed, height: "fill", overflow: "auto", children }); } function UserComponentPaneHeader(props) { const { actionHandlers, index, menuItems, menuItemGroups, title } = props, { features } = useStructureTool(); return !(menuItems != null && menuItems.length) && !title ? null : /* @__PURE__ */ jsx( PaneHeader, { actions: /* @__PURE__ */ jsx( PaneHeaderActions, { menuItems, menuItemGroups, actionHandlers } ), backButton: features.backButton && index > 0 && /* @__PURE__ */ jsx( Button, { as: BackLink, "data-as": "a", icon: ArrowLeftIcon, mode: "bleed", tooltipProps: { content: "Back" } } ), title } ); } function UserComponentPane(props) { const { index, pane, paneKey, ...restProps } = props, { child, component, menuItems, menuItemGroups, // eslint-disable-next-line @typescript-eslint/no-unused-vars type: _unused, ...restPane } = pane, [ref, setRef] = useState(null), { title = "" } = useI18nText(pane); return /* @__PURE__ */ jsxs(Pane, { id: paneKey, minWidth: 320, selected: restProps.isSelected, children: [ /* @__PURE__ */ jsx( UserComponentPaneHeader, { actionHandlers: ref == null ? void 0 : ref.actionHandlers, index, menuItems, menuItemGroups, title } ), /* @__PURE__ */ jsxs(UserComponentPaneContent, { children: [ isValidElementType(component) && createElement(component, { ...restProps, ...restPane, ref: setRef, child, // @todo: Fix typings paneKey }), isValidElement(component) && component ] }) ] }); } export { UserComponentPane as default }; //# sourceMappingURL=index.js.map