Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/insert-menu

Package Overview
Dependencies
Maintainers
55
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/insert-menu - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

95

dist/index.js

@@ -8,5 +8,4 @@ import { jsx, jsxs } from "react/jsx-runtime";

function getSchemaTypeIcon(schemaType) {
var _a, _b, _c, _d;
const referenceIcon = isReferenceSchemaType(schemaType) && ((_a = schemaType.to) != null ? _a : []).length === 1 ? schemaType.to[0].icon : void 0;
return (_d = (_c = schemaType.icon) != null ? _c : (_b = schemaType.type) == null ? void 0 : _b.icon) != null ? _d : referenceIcon;
const referenceIcon = isReferenceSchemaType(schemaType) && (schemaType.to ?? []).length === 1 ? schemaType.to[0].icon : void 0;
return schemaType.icon ?? schemaType.type?.icon ?? referenceIcon;
}

@@ -30,3 +29,2 @@ function isReferenceSchemaType(type) {

function InsertMenu(props) {
var _a;
const showIcons = props.showIcons === void 0 ? !0 : props.showIcons, showFilter = props.filter === void 0 || props.filter === "auto" ? props.schemaTypes.length > 5 : props.filter, [state, send] = useReducer(fullInsertMenuReducer, {

@@ -42,3 +40,3 @@ query: "",

] : [],
views: ((_a = props.views) != null ? _a : [{ name: "list" }]).map((view, index) => ({
views: (props.views ?? [{ name: "list" }]).map((view, index) => ({
...view,

@@ -83,49 +81,40 @@ selected: index === 0

] }) : null,
showingTabs ? /* @__PURE__ */ jsx(Box, { paddingTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx(TabList, { space: 1, children: state.groups.map((group) => {
var _a2;
return /* @__PURE__ */ jsx(
Tab,
{
id: `${group.name}-tab`,
"aria-controls": `${group.name}-panel`,
label: (_a2 = group.title) != null ? _a2 : startCase(group.name),
selected: group.selected,
onClick: () => {
send({ type: "select group", name: group.name });
}
},
group.name
);
}) }) }) : null
showingTabs ? /* @__PURE__ */ jsx(Box, { paddingTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx(TabList, { space: 1, children: state.groups.map((group) => /* @__PURE__ */ jsx(
Tab,
{
id: `${group.name}-tab`,
"aria-controls": `${group.name}-panel`,
label: group.title ?? startCase(group.name),
selected: group.selected,
onClick: () => {
send({ type: "select group", name: group.name });
}
},
group.name
)) }) }) : null
]
}
),
/* @__PURE__ */ jsx(Box, { padding: 1, children: filteredSchemaTypes.length === 0 ? /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: props.labels["insert-menu.search.no-results"] }) }) : selectedView ? selectedView.name === "grid" ? /* @__PURE__ */ jsx(Grid, { autoRows: "auto", flex: 1, gap: 1, style: gridStyle, children: filteredSchemaTypes.map((schemaType) => {
var _a2;
return /* @__PURE__ */ jsx(
GridMenuItem,
{
icon: showIcons ? getSchemaTypeIcon(schemaType) : void 0,
onClick: () => {
props.onSelect(schemaType);
},
previewImageUrl: (_a2 = selectedView.previewImageUrl) == null ? void 0 : _a2.call(selectedView, schemaType.name),
schemaType
/* @__PURE__ */ jsx(Box, { padding: 1, children: filteredSchemaTypes.length === 0 ? /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: props.labels["insert-menu.search.no-results"] }) }) : selectedView ? selectedView.name === "grid" ? /* @__PURE__ */ jsx(Grid, { autoRows: "auto", flex: 1, gap: 1, style: gridStyle, children: filteredSchemaTypes.map((schemaType) => /* @__PURE__ */ jsx(
GridMenuItem,
{
icon: showIcons ? getSchemaTypeIcon(schemaType) : void 0,
onClick: () => {
props.onSelect(schemaType);
},
schemaType.name
);
}) }) : /* @__PURE__ */ jsx(Stack, { flex: 1, space: 1, children: filteredSchemaTypes.map((schemaType) => {
var _a2;
return /* @__PURE__ */ jsx(
MenuItem,
{
icon: showIcons ? getSchemaTypeIcon(schemaType) : void 0,
onClick: () => {
props.onSelect(schemaType);
},
text: (_a2 = schemaType.title) != null ? _a2 : startCase(schemaType.name)
previewImageUrl: selectedView.previewImageUrl?.(schemaType.name),
schemaType
},
schemaType.name
)) }) : /* @__PURE__ */ jsx(Stack, { flex: 1, space: 1, children: filteredSchemaTypes.map((schemaType) => /* @__PURE__ */ jsx(
MenuItem,
{
icon: showIcons ? getSchemaTypeIcon(schemaType) : void 0,
onClick: () => {
props.onSelect(schemaType);
},
schemaType.name
);
}) }) : null })
text: schemaType.title ?? startCase(schemaType.name)
},
schemaType.name
)) }) : null })
] }) });

@@ -141,4 +130,3 @@ }

function ViewToggle(props) {
var _a;
const viewIndex = props.views.findIndex((view) => view.selected), nextView = (_a = props.views[viewIndex + 1]) != null ? _a : props.views[0];
const viewIndex = props.views.findIndex((view) => view.selected), nextView = props.views[viewIndex + 1] ?? props.views[0];
return /* @__PURE__ */ jsx(

@@ -164,3 +152,2 @@ Tooltip,

function GridMenuItem(props) {
var _a;
const [failedToLoad, setFailedToLoad] = useState(!1);

@@ -226,3 +213,3 @@ return /* @__PURE__ */ jsx(MenuItem, { padding: 0, radius: 2, onClick: props.onClick, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, padding: 1, children: [

),
/* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: (_a = props.schemaType.title) != null ? _a : props.schemaType.name }) })
/* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: props.schemaType.title ?? props.schemaType.name }) })
] }) });

@@ -236,10 +223,8 @@ }

function passesQueryFilter(schemaType, query) {
var _a;
const sanitizedQuery = query.trim().toLowerCase();
return schemaType.title ? (_a = schemaType.title) == null ? void 0 : _a.toLowerCase().includes(sanitizedQuery) : schemaType.name.includes(sanitizedQuery);
return schemaType.title ? schemaType.title?.toLowerCase().includes(sanitizedQuery) : schemaType.name.includes(sanitizedQuery);
}
function passesGroupFilter(schemaType, groups) {
var _a;
const selectedGroup = groups.find((group) => group.selected);
return selectedGroup ? selectedGroup.name === ALL_ITEMS_GROUP_NAME ? !0 : (_a = selectedGroup.of) == null ? void 0 : _a.includes(schemaType.name) : !0;
return selectedGroup ? selectedGroup.name === ALL_ITEMS_GROUP_NAME ? !0 : selectedGroup.of?.includes(schemaType.name) : !0;
}

@@ -246,0 +231,0 @@ export {

{
"name": "@sanity/insert-menu",
"version": "1.0.7",
"version": "1.0.8",
"description": "",

@@ -36,4 +36,4 @@ "keywords": [],

"dependencies": {
"@sanity/icons": "^3.2.0",
"@sanity/ui": "^2.3.3",
"@sanity/icons": "^3.3.1",
"@sanity/ui": "^2.8.8",
"lodash.startcase": "^4.4.0"

@@ -43,4 +43,4 @@ },

"@sanity/pkg-utils": "^6.9.3",
"@sanity/types": "^3.47.1",
"@sanity/ui-workshop": "^2.0.15",
"@sanity/types": "^3.53.0",
"@sanity/ui-workshop": "^2.0.16",
"@types/lodash.startcase": "^4.4.9",

@@ -56,6 +56,6 @@ "@typescript-eslint/eslint-plugin": "^7.13.1",

"react-is": "^18.3.1",
"typescript": "^5.4.5"
"typescript": "5.4.5"
},
"peerDependencies": {
"@sanity/types": "^3.47.1",
"@sanity/types": "^3.53.0",
"react": "^18.3 || >=19.0.0-rc",

@@ -69,4 +69,5 @@ "react-dom": "^18.3 || >=19.0.0-rc",

"scripts": {
"build": "pkg build --strict --clean --check",
"dev": "workshop dev",
"build": "pkg build --strict --check --clean",
"dev": "pkg build --strict",
"dev:workshop": "workshop dev",
"lint": "eslint .",

@@ -73,0 +74,0 @@ "ts:check": "tsc --noEmit"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc