@web-portfolio/icons-sanity 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +15 -0
  2. package/dist/index.js +12 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -231,6 +231,21 @@ schema.
231
231
 
232
232
  ## Changelog
233
233
 
234
+ **Icon picker: grid fixes + reliable auto-focus**
235
+ - **Fixed overlap:** grid tiles' icon row was sized off an unrelated Sanity UI
236
+ theme token, which was shorter than the icon itself — the glyph visually
237
+ spilled down over its own label. The row now sizes off the actual icon
238
+ dimension, so this can't happen regardless of icon or theme.
239
+ - **Icons are 20% bigger** in the grid (24px → 29px) for better legibility.
240
+ - **Fewer icons per page** (96 → 48), matching the larger tiles so a page
241
+ still renders as a comfortable handful of rows.
242
+ - **Search field now reliably auto-focuses** when the dialog opens. Sanity
243
+ UI's `Dialog` unconditionally focuses its own header close button on mount
244
+ (it's the first focusable element in the DOM), which was winning a race
245
+ against the search field's `autoFocus` — the field now explicitly reclaims
246
+ focus after Dialog's own mount behavior runs, so opening the picker always
247
+ drops you straight into search.
248
+
234
249
  **v3.0.0 — ESM-only, built with `@sanity/plugin-kit`**
235
250
  - The build now uses [`@sanity/plugin-kit`](https://github.com/sanity-io/plugins/tree/main/packages/@sanity/plugin-kit)
236
251
  and [`@sanity/pkg-utils`](https://github.com/sanity-io/pkg-utils) instead
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { definePlugin, defineType, set, unset } from "sanity";
2
- import { useCallback, useEffect, useMemo, useState } from "react";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Badge, Box, Button, Card, Dialog, Flex, Grid, Select, Stack, Text, TextInput, Tooltip, rem } from "@sanity/ui";
4
4
  import { ImageIcon, SearchIcon, TrashIcon, WarningOutlineIcon } from "@sanity/icons";
5
5
  import { styled } from "styled-components";
@@ -5194,22 +5194,22 @@ const metadata = {
5194
5194
  }
5195
5195
  }, PreviewFrame = styled(Card).withConfig({
5196
5196
  displayName: "PreviewFrame",
5197
- componentId: "sc-0esdoi-0"
5197
+ componentId: "sc-s8zqt7-0"
5198
5198
  })`flex-shrink:0;width:${({ theme }) => rem(28 + theme.sanity.space[3] * 2)};height:${({ theme }) => rem(28 + theme.sanity.space[3] * 2)};`, ResultsScroller = styled(Box).withConfig({
5199
5199
  displayName: "ResultsScroller",
5200
- componentId: "sc-0esdoi-1"
5200
+ componentId: "sc-s8zqt7-1"
5201
5201
  })`max-height:${rem(400)};overflow-y:auto;overscroll-behavior:contain;`, IconTile = styled(Card).withConfig({
5202
5202
  displayName: "IconTile",
5203
- componentId: "sc-0esdoi-2"
5203
+ componentId: "sc-s8zqt7-2"
5204
5204
  })`&&[data-as='button']{cursor:pointer;border:1px solid var(--card-border-color);min-width:0;overflow:hidden;}`, GlyphRow = styled(Flex).withConfig({
5205
5205
  displayName: "GlyphRow",
5206
- componentId: "sc-0esdoi-3"
5206
+ componentId: "sc-s8zqt7-3"
5207
5207
  })`height:${rem(37)};`, LabelRow = styled(Box).withConfig({
5208
5208
  displayName: "LabelRow",
5209
- componentId: "sc-0esdoi-4"
5209
+ componentId: "sc-s8zqt7-4"
5210
5210
  })`min-height:${rem(20)};`, CategorySelectBox = styled(Box).withConfig({
5211
5211
  displayName: "CategorySelectBox",
5212
- componentId: "sc-0esdoi-5"
5212
+ componentId: "sc-s8zqt7-5"
5213
5213
  })`width:${rem(180)};`;
5214
5214
  function matchesQuery(name, entry, query) {
5215
5215
  if (!query.trim()) return !0;
@@ -5242,7 +5242,7 @@ function formatCategoryLabel(category) {
5242
5242
  return CATEGORY_LABEL_OVERRIDES[category] ? CATEGORY_LABEL_OVERRIDES[category] : category.split(/[-_]/).filter(Boolean).map((word) => word[0].toUpperCase() + word.slice(1)).join(" ");
5243
5243
  }
5244
5244
  function IconPickerInput(props) {
5245
- let { value, onChange, readOnly, elementProps } = props, [open, setOpen] = useState(!1), [query, setQuery] = useState(""), [category, setCategory] = useState(""), [visibleCount, setVisibleCount] = useState(48), names = useMemo(() => Object.keys(metadata).sort(), []), categories = useMemo(() => {
5245
+ let { value, onChange, readOnly, elementProps } = props, [open, setOpen] = useState(!1), [query, setQuery] = useState(""), [category, setCategory] = useState(""), [visibleCount, setVisibleCount] = useState(48), searchInputRef = useRef(null), names = useMemo(() => Object.keys(metadata).sort(), []), categories = useMemo(() => {
5246
5246
  let found = /* @__PURE__ */ new Set();
5247
5247
  for (let name of names) {
5248
5248
  let entry = metadata[name];
@@ -5262,7 +5262,9 @@ function IconPickerInput(props) {
5262
5262
  ]);
5263
5263
  useEffect(() => {
5264
5264
  setVisibleCount(48);
5265
- }, [query, category]);
5265
+ }, [query, category]), useEffect(() => {
5266
+ open && searchInputRef.current?.focus();
5267
+ }, [open]);
5266
5268
  let visible = filtered.slice(0, visibleCount), remaining = filtered.length - visible.length, selectedEntry = value ? metadata[value] : void 0, hasUnknownValue = !!(value && !selectedEntry), closeDialog = useCallback(() => {
5267
5269
  setOpen(!1), setQuery(""), setCategory("");
5268
5270
  }, []), handleSelect = useCallback((name) => {
@@ -5395,6 +5397,7 @@ function IconPickerInput(props) {
5395
5397
  children: [/* @__PURE__ */ jsx(Box, {
5396
5398
  flex: 1,
5397
5399
  children: /* @__PURE__ */ jsx(TextInput, {
5400
+ ref: searchInputRef,
5398
5401
  icon: SearchIcon,
5399
5402
  placeholder: "Search by name, label, or tag…",
5400
5403
  value: query,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web-portfolio/icons-sanity",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Sanity Studio icon picker input, backed by the same bundled registry as @web-portfolio/icons.",
5
5
  "license": "MIT",
6
6
  "keywords": [