UNPKG

sanity-plugin-note-field

Version:
36 lines (35 loc) 1.71 kB
import { jsx, jsxs, Fragment } from "react/jsx-runtime"; import { definePlugin, defineType } from "sanity"; import { Card, Flex, Box, Text } from "@sanity/ui"; import startCase from "lodash/startCase.js"; const NoteInput = (props) => { const { ref, ...args } = props, { title, description } = args.schemaType, options = args.schemaType.options, pathId = String(args.path[args.path.length - 1] ?? ""), displayTitle = startCase(pathId) === title ? null : title, Icon = options?.icon, tone = options?.tone ?? "primary"; return !displayTitle && !description ? null : /* @__PURE__ */ jsx(Card, { ref, "data-note": pathId, padding: 4, radius: 2, tone, children: /* @__PURE__ */ jsxs(Flex, { children: [ Icon && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { size: 1, style: { color: "var(--card-icon-color)" }, children: /* @__PURE__ */ jsx(Icon, {}) }) }), /* @__PURE__ */ jsxs(Box, { flex: 1, marginLeft: Icon ? 3 : 0, children: [ displayTitle && /* @__PURE__ */ jsx(Box, { marginBottom: description ? 3 : 0, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: displayTitle }) }), description && /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: description }) ] }) ] }) }); }; NoteInput.displayName = "NoteInput"; const noteField = definePlugin(() => ({ name: "sanity-plugin-note-field", schema: { types: [ defineType({ title: "Note", name: "note", type: "string", components: { input: NoteInput, field: (props) => /* @__PURE__ */ jsx(Fragment, { children: props.children }) } }) ] } })); export { noteField }; //# sourceMappingURL=index.esm.js.map