@web-portfolio/icons-sanity 3.0.2 → 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.
- package/README.md +15 -0
- package/dist/index.js +17 -14
- 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-
|
|
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-
|
|
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-
|
|
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-
|
|
5207
|
-
})`height:${
|
|
5206
|
+
componentId: "sc-s8zqt7-3"
|
|
5207
|
+
})`height:${rem(37)};`, LabelRow = styled(Box).withConfig({
|
|
5208
5208
|
displayName: "LabelRow",
|
|
5209
|
-
componentId: "sc-
|
|
5209
|
+
componentId: "sc-s8zqt7-4"
|
|
5210
5210
|
})`min-height:${rem(20)};`, CategorySelectBox = styled(Box).withConfig({
|
|
5211
5211
|
displayName: "CategorySelectBox",
|
|
5212
|
-
componentId: "sc-
|
|
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(
|
|
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];
|
|
@@ -5261,8 +5261,10 @@ function IconPickerInput(props) {
|
|
|
5261
5261
|
category
|
|
5262
5262
|
]);
|
|
5263
5263
|
useEffect(() => {
|
|
5264
|
-
setVisibleCount(
|
|
5265
|
-
}, [query, category])
|
|
5264
|
+
setVisibleCount(48);
|
|
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,
|
|
@@ -5476,7 +5479,7 @@ function IconPickerInput(props) {
|
|
|
5476
5479
|
justify: "center",
|
|
5477
5480
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
5478
5481
|
name,
|
|
5479
|
-
size:
|
|
5482
|
+
size: 29
|
|
5480
5483
|
})
|
|
5481
5484
|
}), /* @__PURE__ */ jsx(LabelRow, { children: /* @__PURE__ */ jsx(Text, {
|
|
5482
5485
|
size: 0,
|
|
@@ -5492,8 +5495,8 @@ function IconPickerInput(props) {
|
|
|
5492
5495
|
}), remaining > 0 && /* @__PURE__ */ jsx(Button, {
|
|
5493
5496
|
mode: "ghost",
|
|
5494
5497
|
width: "fill",
|
|
5495
|
-
text: `Show ${Math.min(remaining,
|
|
5496
|
-
onClick: () => setVisibleCount((count) => count +
|
|
5498
|
+
text: `Show ${Math.min(remaining, 48)} more`,
|
|
5499
|
+
onClick: () => setVisibleCount((count) => count + 48)
|
|
5497
5500
|
})]
|
|
5498
5501
|
}) })]
|
|
5499
5502
|
})
|