UNPKG

sanity-plugin-note-field

Version:
37 lines (36 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), startCase = require("lodash/startCase.js"); function _interopDefaultCompat(e) { return e && typeof e == "object" && "default" in e ? e : { default: e }; } var startCase__default = /* @__PURE__ */ _interopDefaultCompat(startCase); 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__default.default(pathId) === title ? null : title, Icon = options?.icon, tone = options?.tone ?? "primary"; return !displayTitle && !description ? null : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { ref, "data-note": pathId, padding: 4, radius: 2, tone, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { children: [ Icon && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { color: "var(--card-icon-color)" }, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {}) }) }), /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { flex: 1, marginLeft: Icon ? 3 : 0, children: [ displayTitle && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginBottom: description ? 3 : 0, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: displayTitle }) }), description && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: description }) ] }) ] }) }); }; NoteInput.displayName = "NoteInput"; const noteField = sanity.definePlugin(() => ({ name: "sanity-plugin-note-field", schema: { types: [ sanity.defineType({ title: "Note", name: "note", type: "string", components: { input: NoteInput, field: (props) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children }) } }) ] } })); exports.noteField = noteField; //# sourceMappingURL=index.cjs.map