@10x-media/fields 4.0.0-alpha.3 → 4.0.0-alpha.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @10x-media/fields
|
|
2
2
|
|
|
3
|
+
## 4.0.0-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The icon picker sizes its columns from the grid's width without the vertical scrollbar. At some widths, common in a nested drawer, it counted one column too many, so the last column was cut off and the grid scrolled sideways.
|
|
8
|
+
|
|
3
9
|
## 4.0.0-alpha.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -55,9 +55,10 @@ const IconDrawerContent = ({ activeLibrary, adapterComponents, adapters, onLibra
|
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
const element = gridRef.current;
|
|
57
57
|
if (!element) return;
|
|
58
|
-
const
|
|
58
|
+
const measure = () => setGridWidth(element.clientWidth);
|
|
59
|
+
const observer = new ResizeObserver(measure);
|
|
59
60
|
observer.observe(element);
|
|
60
|
-
|
|
61
|
+
measure();
|
|
61
62
|
return () => observer.disconnect();
|
|
62
63
|
}, []);
|
|
63
64
|
const columns = Math.max(3, Math.floor(gridWidth / CELL_SIZE));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconDrawerContent.js","names":["useTranslation"],"sources":["../../../../src/fields/icon/client/IconDrawerContent.tsx"],"sourcesContent":["'use client'\n\nimport { Button, ReactSelect, SearchIcon } from '@payloadcms/ui'\nimport { useVirtualizer } from '@tanstack/react-virtual'\nimport type React from 'react'\nimport { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'\nimport { keys } from '../../../translations'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport type { IconManifest, IconMeta, IconNodeMap } from '../../../types'\nimport type { AdapterComponentsEntry } from '../shared/adapterComponents'\nimport { buildIconSearchIndex, searchIcons } from '../shared/search'\nimport { IconGridCell } from './IconGridCell'\nimport { useRecentIcons } from './useRecentIcons'\n\n// One fixed size drives both the column count and the virtualizer row height. With no\n// in-flow label to vary a cell's height, every cell is an identical square and the grid\n// stays aligned regardless of icon name length.\nconst CELL_SIZE = 64\nconst RECENT = '__recent__'\nconst ALL = '__all__'\n\nexport type IconDrawerContentProps = {\n\tactiveLibrary: string\n\tadapterComponents: Record<string, AdapterComponentsEntry>\n\t/** Libraries available for selection: registered adapters already intersected with `available`. */\n\tadapters: { label: string; slug: string }[]\n\tonLibraryChange: (slug: string) => void\n\tonSelect: (library: string, icon: IconMeta) => void\n\tselected: { library: string; name: string } | null\n\tslugPrefix: string\n}\n\nconst IconDrawerContent: React.FC<IconDrawerContentProps> = ({\n\tactiveLibrary,\n\tadapterComponents,\n\tadapters,\n\tonLibraryChange,\n\tonSelect,\n\tselected,\n\tslugPrefix,\n}) => {\n\tconst { i18n, t } = useTranslation()\n\tconst [manifests, setManifests] = useState<Map<string, IconManifest>>(() => new Map())\n\tconst [nodeMaps, setNodeMaps] = useState<Map<string, IconNodeMap>>(() => new Map())\n\tconst [query, setQuery] = useState('')\n\tconst deferredQuery = useDeferredValue(query)\n\tconst [category, setCategory] = useState<string>(ALL)\n\tconst { addRecent, recent } = useRecentIcons(activeLibrary)\n\n\tconst manifest = manifests.get(activeLibrary)\n\tconst entry = adapterComponents[activeLibrary]\n\tconst Assets = entry?.Assets\n\tconst NodesLoader = entry?.Nodes\n\tconst nodeMap = nodeMaps.get(activeLibrary)\n\t// Libraries with a Nodes loader render the grid from bulk node-data; the grid\n\t// waits for that data before showing cells, others (radix) render immediately.\n\tconst nodesPending = Boolean(NodesLoader) && !nodeMap\n\tconst loading = !manifest || nodesPending\n\n\tconst handleManifest = useCallback(\n\t\t(loaded: IconManifest) => {\n\t\t\tsetManifests((previous) => new Map(previous).set(activeLibrary, loaded))\n\t\t},\n\t\t[activeLibrary]\n\t)\n\n\tconst handleNodes = useCallback(\n\t\t(loaded: IconNodeMap) => {\n\t\t\tsetNodeMaps((previous) => new Map(previous).set(activeLibrary, loaded))\n\t\t},\n\t\t[activeLibrary]\n\t)\n\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: activeLibrary is the trigger; the effect resets category and search when it changes\n\tuseEffect(() => {\n\t\tsetCategory(ALL)\n\t\tsetQuery('')\n\t}, [activeLibrary])\n\n\tconst byName = useMemo(\n\t\t() => new Map((manifest?.icons ?? []).map((icon) => [icon.name, icon])),\n\t\t[manifest]\n\t)\n\n\tconst categoryIcons = useMemo((): IconMeta[] => {\n\t\tif (!manifest) return []\n\t\tif (category === ALL) return manifest.icons\n\t\tif (category === RECENT) {\n\t\t\treturn recent\n\t\t\t\t.map((name) => byName.get(name))\n\t\t\t\t.filter((icon): icon is IconMeta => Boolean(icon))\n\t\t}\n\t\treturn manifest.icons.filter((icon) => icon.categories.includes(category))\n\t}, [byName, category, manifest, recent])\n\n\tconst index = useMemo(() => buildIconSearchIndex(categoryIcons), [categoryIcons])\n\tconst visible = useMemo(() => searchIcons(index, deferredQuery), [deferredQuery, index])\n\n\tconst gridRef = useRef<HTMLDivElement>(null)\n\tconst [gridWidth, setGridWidth] = useState(0)\n\tuseEffect(() => {\n\t\tconst element = gridRef.current\n\t\tif (!element) return\n\t\tconst observer = new ResizeObserver(() => setGridWidth(element.offsetWidth))\n\t\tobserver.observe(element)\n\t\tsetGridWidth(element.offsetWidth)\n\t\treturn () => observer.disconnect()\n\t}, [])\n\tconst columns = Math.max(3, Math.floor(gridWidth / CELL_SIZE))\n\tconst rowCount = Math.ceil(visible.length / columns)\n\t// Cell-box span of a full row (columns * CELL_SIZE), published to CSS as a custom property.\n\t// The header row and banner derive their width from this (inset to the button outlines in\n\t// icon-field.css) so the search, switcher, banner, and visible grid share one left and one\n\t// right edge. Sized only from CELL_SIZE.\n\tconst mainStyle = {\n\t\t'--tenx-icon-grid-width': `${columns * CELL_SIZE}px`,\n\t} as React.CSSProperties\n\n\tconst virtualizer = useVirtualizer({\n\t\tcount: rowCount,\n\t\testimateSize: () => CELL_SIZE,\n\t\tgetScrollElement: () => gridRef.current,\n\t\t// Cells are cheap inline SVG now, so a deeper overscan buys smoother fast scrolls.\n\t\toverscan: 8,\n\t})\n\n\tconst [focusIndex, setFocusIndex] = useState(0)\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: reset focus whenever the visible set changes\n\tuseEffect(() => setFocusIndex(0), [activeLibrary, category, deferredQuery])\n\tconst cellRefs = useRef(new Map<number, HTMLButtonElement>())\n\tconst registerRef = useCallback((cellIndex: number, element: HTMLButtonElement | null) => {\n\t\tif (element) cellRefs.current.set(cellIndex, element)\n\t\telse cellRefs.current.delete(cellIndex)\n\t}, [])\n\n\tconst focusCell = useCallback(\n\t\t(cellIndex: number) => {\n\t\t\tvirtualizer.scrollToIndex(Math.floor(cellIndex / columns))\n\t\t\trequestAnimationFrame(() => cellRefs.current.get(cellIndex)?.focus())\n\t\t},\n\t\t[columns, virtualizer]\n\t)\n\n\tconst handleGridKeyDown = useCallback(\n\t\t(event: React.KeyboardEvent<HTMLDivElement>) => {\n\t\t\tconst max = visible.length - 1\n\t\t\tif (max < 0) return\n\t\t\tlet next: number | null = null\n\t\t\tif (event.key === 'ArrowRight') next = Math.min(focusIndex + 1, max)\n\t\t\telse if (event.key === 'ArrowLeft') next = Math.max(focusIndex - 1, 0)\n\t\t\telse if (event.key === 'ArrowDown') next = Math.min(focusIndex + columns, max)\n\t\t\telse if (event.key === 'ArrowUp') next = Math.max(focusIndex - columns, 0)\n\t\t\telse if (event.key === 'Home') next = 0\n\t\t\telse if (event.key === 'End') next = max\n\t\t\tif (next === null) return\n\t\t\tevent.preventDefault()\n\t\t\tsetFocusIndex(next)\n\t\t\tfocusCell(next)\n\t\t},\n\t\t[columns, focusCell, focusIndex, visible.length]\n\t)\n\n\tconst handleSelect = useCallback(\n\t\t(icon: IconMeta) => {\n\t\t\taddRecent(icon.name)\n\t\t\tonSelect(activeLibrary, icon)\n\t\t},\n\t\t[activeLibrary, addRecent, onSelect]\n\t)\n\n\tconst railItems = useMemo(\n\t\t(): { key: string; label: string }[] => [\n\t\t\t{ key: ALL, label: t(keys.allIcons) },\n\t\t\t{ key: RECENT, label: t(keys.recent) },\n\t\t\t...(manifest?.categories ?? []).map((name) => ({ key: name, label: name })),\n\t\t],\n\t\t[manifest, t]\n\t)\n\n\tconst libraryOptions = useMemo(\n\t\t() => adapters.map((adapter) => ({ label: adapter.label, value: adapter.slug })),\n\t\t[adapters]\n\t)\n\tconst librarySelectId = `${slugPrefix}-library`\n\n\t// The stored value points at a library that is no longer offered for selection; the\n\t// full explanation lives here, the trigger only carries a compact marker.\n\tconst selectedUnavailable =\n\t\tselected !== null && !adapters.some((adapter) => adapter.slug === selected.library)\n\n\t// A listbox must own option children, so the grid only claims role=\"listbox\" (with\n\t// its keyboard nav and label) once cells exist. While loading it is an aria-busy\n\t// container; when empty it is a plain container holding the \"no icons\" message.\n\tconst gridPopulated = !loading && visible.length > 0\n\tconst gridA11y: React.HTMLAttributes<HTMLDivElement> = gridPopulated\n\t\t? { 'aria-label': t(keys.iconGrid), onKeyDown: handleGridKeyDown, role: 'listbox' }\n\t\t: { 'aria-busy': loading || undefined }\n\n\treturn (\n\t\t<div className=\"tenx-icon-drawer\">\n\t\t\t{/* Sibling loaders keyed distinctly per library: a shared key collides (\"two children\n\t\t\t with the same key\") when both mount on open, while distinct keys keep the per-library remount. */}\n\t\t\t{Assets && !manifest ? (\n\t\t\t\t<Assets key={`assets-${activeLibrary}`} onReady={handleManifest} />\n\t\t\t) : null}\n\t\t\t{NodesLoader && !nodeMap ? (\n\t\t\t\t<NodesLoader key={`nodes-${activeLibrary}`} onReady={handleNodes} />\n\t\t\t) : null}\n\t\t\t<div className=\"tenx-icon-drawer__body\">\n\t\t\t\t<nav aria-label={t(keys.iconCategories)} className=\"tenx-icon-drawer__rail\">\n\t\t\t\t\t{railItems.map((item) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-pressed={category === item.key}\n\t\t\t\t\t\t\tbuttonStyle={category === item.key ? 'pill' : 'ghost'}\n\t\t\t\t\t\t\tclassName=\"tenx-icon-drawer__rail-item\"\n\t\t\t\t\t\t\tkey={item.key}\n\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\tonClick={() => setCategory(item.key)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t))}\n\t\t\t\t</nav>\n\t\t\t\t<div className=\"tenx-icon-drawer__main\" style={mainStyle}>\n\t\t\t\t\t{selectedUnavailable ? (\n\t\t\t\t\t\t<div className=\"tenx-icon-drawer__banner\" role=\"status\">\n\t\t\t\t\t\t\t{t(keys.libraryUnavailable)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<div className=\"tenx-icon-drawer__header\">\n\t\t\t\t\t\t<div className=\"tenx-icon-drawer__search form-input-group\">\n\t\t\t\t\t\t\t<span aria-hidden=\"true\" className=\"tenx-icon-drawer__search-icon\">\n\t\t\t\t\t\t\t\t<SearchIcon />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\taria-label={t(keys.searchIcons)}\n\t\t\t\t\t\t\t\tclassName=\"form-input tenx-icon-drawer__search-input\"\n\t\t\t\t\t\t\t\tonChange={(event: React.ChangeEvent<HTMLInputElement>) =>\n\t\t\t\t\t\t\t\t\tsetQuery(event.target.value)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplaceholder={t(keys.searchIcons)}\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tvalue={query}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/* adapters is the available-filtered set; the switcher shows only with 2+ libraries, fixed width beside the growing search */}\n\t\t\t\t\t\t{adapters.length > 1 ? (\n\t\t\t\t\t\t\t<div className=\"tenx-icon-drawer__switcher\">\n\t\t\t\t\t\t\t\t<label className=\"tenx-icon-drawer__sr-only\" htmlFor={librarySelectId}>\n\t\t\t\t\t\t\t\t\t{t(keys.fieldIconLibraryLabel)}\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\t\tinputId={librarySelectId}\n\t\t\t\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\t\t\t\tonChange={(option) => {\n\t\t\t\t\t\t\t\t\t\tconst single = Array.isArray(option) ? option[0] : option\n\t\t\t\t\t\t\t\t\t\tif (single && typeof single.value === 'string') onLibraryChange(single.value)\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\toptions={libraryOptions}\n\t\t\t\t\t\t\t\t\tvalue={libraryOptions.find((option) => option.value === activeLibrary)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"tenx-icon-drawer__grid\" ref={gridRef} {...gridA11y}>\n\t\t\t\t\t\t{loading ? (\n\t\t\t\t\t\t\t<div className=\"tenx-icon-drawer__loading\">\n\t\t\t\t\t\t\t\t{Array.from({ length: 24 }, (_, skeletonIndex) => (\n\t\t\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: fixed-count static placeholders that never reorder\n\t\t\t\t\t\t\t\t\t<span className=\"tenx-icon-placeholder\" key={`skeleton-${skeletonIndex}`} />\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : visible.length === 0 ? (\n\t\t\t\t\t\t\t<div className=\"tenx-icon-drawer__empty\">{t(keys.noIconsFound)}</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\tstyle={{ height: virtualizer.getTotalSize(), position: 'relative', width: '100%' }}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{virtualizer.getVirtualItems().map((row) => (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclassName=\"tenx-icon-drawer__row\"\n\t\t\t\t\t\t\t\t\t\tdata-index={row.index}\n\t\t\t\t\t\t\t\t\t\tkey={row.key}\n\t\t\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\tleft: 0,\n\t\t\t\t\t\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\t\t\t\t\t\ttop: 0,\n\t\t\t\t\t\t\t\t\t\t\ttransform: `translateY(${row.start}px)`,\n\t\t\t\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{visible\n\t\t\t\t\t\t\t\t\t\t\t.slice(row.index * columns, row.index * columns + columns)\n\t\t\t\t\t\t\t\t\t\t\t.map((icon, columnIndex) => {\n\t\t\t\t\t\t\t\t\t\t\t\tconst cellIndex = row.index * columns + columnIndex\n\t\t\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<IconGridCell\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcanvas={entry?.canvas}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tentry={entry}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfocused={cellIndex === focusIndex}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={icon}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tindex={cellIndex}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tisSelected={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tselected?.library === activeLibrary && selected.name === icon.name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={icon.name}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlanguage={i18n.language}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnodes={NodesLoader ? nodeMap?.[icon.name] : undefined}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tregisterRef={registerRef}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div className=\"tenx-icon-drawer__footer\">\n\t\t\t\t{t(keys.resultsCount, { count: visible.length })}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nexport default IconDrawerContent\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,YAAY;AAClB,MAAM,SAAS;AACf,MAAM,MAAM;AAaZ,MAAM,qBAAuD,EAC5D,eACA,mBACA,UACA,iBACA,UACA,UACA,iBACK;CACL,MAAM,EAAE,MAAM,MAAMA,iBAAe;CACnC,MAAM,CAAC,WAAW,gBAAgB,+BAA0C,IAAI,IAAI,CAAC;CACrF,MAAM,CAAC,UAAU,eAAe,+BAAyC,IAAI,IAAI,CAAC;CAClF,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAAiB,GAAG;CACpD,MAAM,EAAE,WAAW,WAAW,eAAe,aAAa;CAE1D,MAAM,WAAW,UAAU,IAAI,aAAa;CAC5C,MAAM,QAAQ,kBAAkB;CAChC,MAAM,SAAS,OAAO;CACtB,MAAM,cAAc,OAAO;CAC3B,MAAM,UAAU,SAAS,IAAI,aAAa;CAI1C,MAAM,UAAU,CAAC,YADI,QAAQ,WAAW,KAAK,CAAC;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G,CAAA,IACF,QAAQ,WAAW,IACtB,oBAAC,OAAD;QAAK,WAAU;kBAA2B,EAAE,KAAK,YAAY;OAAO,CAAA,IAEpE,oBAAC,OAAD;QACC,MAAK;QACL,OAAO;SAAE,QAAQ,YAAY,aAAa;SAAG,UAAU;SAAY,OAAO;QAAO;kBAEhF,YAAY,gBAAgB,EAAE,KAAK,QACnC,oBAAC,OAAD;SACC,WAAU;SACV,cAAY,IAAI;SAEhB,MAAK;SACL,OAAO;UACN,MAAM;UACN,UAAU;UACV,KAAK;UACL,WAAW,cAAc,IAAI,MAAM;UACnC,OAAO;SACR;mBAEC,QACC,MAAM,IAAI,QAAQ,SAAS,IAAI,QAAQ,UAAU,OAAO,EACxD,KAAK,MAAM,gBAAgB;UAC3B,MAAM,YAAY,IAAI,QAAQ,UAAU;UACxC,OACC,oBAAC,cAAD;WACC,QAAQ,OAAO;WACR;WACP,SAAS,cAAc;WACjB;WACN,OAAO;WACP,YACC,UAAU,YAAY,iBAAiB,SAAS,SAAS,KAAK;WAG/D,UAAU,KAAK;WACf,OAAO,cAAc,UAAU,KAAK,QAAQ,KAAA;WAC5C,UAAU;WACG;UACb,GALK,KAAK,IAKV;SAEH,CAAC;QACE,GAhCC,IAAI,GAgCL,CACL;OACG,CAAA;MAEF,CAAA;KACD;MACD;;GACL,oBAAC,OAAD;IAAK,WAAU;cACb,EAAE,KAAK,cAAc,EAAE,OAAO,QAAQ,OAAO,CAAC;GAC3C,CAAA;EACD;;AAEP"}
|
|
1
|
+
{"version":3,"file":"IconDrawerContent.js","names":["useTranslation"],"sources":["../../../../src/fields/icon/client/IconDrawerContent.tsx"],"sourcesContent":["'use client'\n\nimport { Button, ReactSelect, SearchIcon } from '@payloadcms/ui'\nimport { useVirtualizer } from '@tanstack/react-virtual'\nimport type React from 'react'\nimport { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'\nimport { keys } from '../../../translations'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport type { IconManifest, IconMeta, IconNodeMap } from '../../../types'\nimport type { AdapterComponentsEntry } from '../shared/adapterComponents'\nimport { buildIconSearchIndex, searchIcons } from '../shared/search'\nimport { IconGridCell } from './IconGridCell'\nimport { useRecentIcons } from './useRecentIcons'\n\n// One fixed size drives both the column count and the virtualizer row height. With no\n// in-flow label to vary a cell's height, every cell is an identical square and the grid\n// stays aligned regardless of icon name length.\nconst CELL_SIZE = 64\nconst RECENT = '__recent__'\nconst ALL = '__all__'\n\nexport type IconDrawerContentProps = {\n\tactiveLibrary: string\n\tadapterComponents: Record<string, AdapterComponentsEntry>\n\t/** Libraries available for selection: registered adapters already intersected with `available`. */\n\tadapters: { label: string; slug: string }[]\n\tonLibraryChange: (slug: string) => void\n\tonSelect: (library: string, icon: IconMeta) => void\n\tselected: { library: string; name: string } | null\n\tslugPrefix: string\n}\n\nconst IconDrawerContent: React.FC<IconDrawerContentProps> = ({\n\tactiveLibrary,\n\tadapterComponents,\n\tadapters,\n\tonLibraryChange,\n\tonSelect,\n\tselected,\n\tslugPrefix,\n}) => {\n\tconst { i18n, t } = useTranslation()\n\tconst [manifests, setManifests] = useState<Map<string, IconManifest>>(() => new Map())\n\tconst [nodeMaps, setNodeMaps] = useState<Map<string, IconNodeMap>>(() => new Map())\n\tconst [query, setQuery] = useState('')\n\tconst deferredQuery = useDeferredValue(query)\n\tconst [category, setCategory] = useState<string>(ALL)\n\tconst { addRecent, recent } = useRecentIcons(activeLibrary)\n\n\tconst manifest = manifests.get(activeLibrary)\n\tconst entry = adapterComponents[activeLibrary]\n\tconst Assets = entry?.Assets\n\tconst NodesLoader = entry?.Nodes\n\tconst nodeMap = nodeMaps.get(activeLibrary)\n\t// Libraries with a Nodes loader render the grid from bulk node-data; the grid\n\t// waits for that data before showing cells, others (radix) render immediately.\n\tconst nodesPending = Boolean(NodesLoader) && !nodeMap\n\tconst loading = !manifest || nodesPending\n\n\tconst handleManifest = useCallback(\n\t\t(loaded: IconManifest) => {\n\t\t\tsetManifests((previous) => new Map(previous).set(activeLibrary, loaded))\n\t\t},\n\t\t[activeLibrary]\n\t)\n\n\tconst handleNodes = useCallback(\n\t\t(loaded: IconNodeMap) => {\n\t\t\tsetNodeMaps((previous) => new Map(previous).set(activeLibrary, loaded))\n\t\t},\n\t\t[activeLibrary]\n\t)\n\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: activeLibrary is the trigger; the effect resets category and search when it changes\n\tuseEffect(() => {\n\t\tsetCategory(ALL)\n\t\tsetQuery('')\n\t}, [activeLibrary])\n\n\tconst byName = useMemo(\n\t\t() => new Map((manifest?.icons ?? []).map((icon) => [icon.name, icon])),\n\t\t[manifest]\n\t)\n\n\tconst categoryIcons = useMemo((): IconMeta[] => {\n\t\tif (!manifest) return []\n\t\tif (category === ALL) return manifest.icons\n\t\tif (category === RECENT) {\n\t\t\treturn recent\n\t\t\t\t.map((name) => byName.get(name))\n\t\t\t\t.filter((icon): icon is IconMeta => Boolean(icon))\n\t\t}\n\t\treturn manifest.icons.filter((icon) => icon.categories.includes(category))\n\t}, [byName, category, manifest, recent])\n\n\tconst index = useMemo(() => buildIconSearchIndex(categoryIcons), [categoryIcons])\n\tconst visible = useMemo(() => searchIcons(index, deferredQuery), [deferredQuery, index])\n\n\tconst gridRef = useRef<HTMLDivElement>(null)\n\tconst [gridWidth, setGridWidth] = useState(0)\n\tuseEffect(() => {\n\t\tconst element = gridRef.current\n\t\tif (!element) return\n\t\t// clientWidth, not offsetWidth: the rows lay out beside the vertical scrollbar, so counting\n\t\t// it would size one column too many whenever the box sits just above a multiple of CELL_SIZE.\n\t\tconst measure = () => setGridWidth(element.clientWidth)\n\t\tconst observer = new ResizeObserver(measure)\n\t\tobserver.observe(element)\n\t\tmeasure()\n\t\treturn () => observer.disconnect()\n\t}, [])\n\tconst columns = Math.max(3, Math.floor(gridWidth / CELL_SIZE))\n\tconst rowCount = Math.ceil(visible.length / columns)\n\t// Cell-box span of a full row (columns * CELL_SIZE), published to CSS as a custom property.\n\t// The header row and banner derive their width from this (inset to the button outlines in\n\t// icon-field.css) so the search, switcher, banner, and visible grid share one left and one\n\t// right edge. Sized only from CELL_SIZE.\n\tconst mainStyle = {\n\t\t'--tenx-icon-grid-width': `${columns * CELL_SIZE}px`,\n\t} as React.CSSProperties\n\n\tconst virtualizer = useVirtualizer({\n\t\tcount: rowCount,\n\t\testimateSize: () => CELL_SIZE,\n\t\tgetScrollElement: () => gridRef.current,\n\t\t// Cells are cheap inline SVG now, so a deeper overscan buys smoother fast scrolls.\n\t\toverscan: 8,\n\t})\n\n\tconst [focusIndex, setFocusIndex] = useState(0)\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: reset focus whenever the visible set changes\n\tuseEffect(() => setFocusIndex(0), [activeLibrary, category, deferredQuery])\n\tconst cellRefs = useRef(new Map<number, HTMLButtonElement>())\n\tconst registerRef = useCallback((cellIndex: number, element: HTMLButtonElement | null) => {\n\t\tif (element) cellRefs.current.set(cellIndex, element)\n\t\telse cellRefs.current.delete(cellIndex)\n\t}, [])\n\n\tconst focusCell = useCallback(\n\t\t(cellIndex: number) => {\n\t\t\tvirtualizer.scrollToIndex(Math.floor(cellIndex / columns))\n\t\t\trequestAnimationFrame(() => cellRefs.current.get(cellIndex)?.focus())\n\t\t},\n\t\t[columns, virtualizer]\n\t)\n\n\tconst handleGridKeyDown = useCallback(\n\t\t(event: React.KeyboardEvent<HTMLDivElement>) => {\n\t\t\tconst max = visible.length - 1\n\t\t\tif (max < 0) return\n\t\t\tlet next: number | null = null\n\t\t\tif (event.key === 'ArrowRight') next = Math.min(focusIndex + 1, max)\n\t\t\telse if (event.key === 'ArrowLeft') next = Math.max(focusIndex - 1, 0)\n\t\t\telse if (event.key === 'ArrowDown') next = Math.min(focusIndex + columns, max)\n\t\t\telse if (event.key === 'ArrowUp') next = Math.max(focusIndex - columns, 0)\n\t\t\telse if (event.key === 'Home') next = 0\n\t\t\telse if (event.key === 'End') next = max\n\t\t\tif (next === null) return\n\t\t\tevent.preventDefault()\n\t\t\tsetFocusIndex(next)\n\t\t\tfocusCell(next)\n\t\t},\n\t\t[columns, focusCell, focusIndex, visible.length]\n\t)\n\n\tconst handleSelect = useCallback(\n\t\t(icon: IconMeta) => {\n\t\t\taddRecent(icon.name)\n\t\t\tonSelect(activeLibrary, icon)\n\t\t},\n\t\t[activeLibrary, addRecent, onSelect]\n\t)\n\n\tconst railItems = useMemo(\n\t\t(): { key: string; label: string }[] => [\n\t\t\t{ key: ALL, label: t(keys.allIcons) },\n\t\t\t{ key: RECENT, label: t(keys.recent) },\n\t\t\t...(manifest?.categories ?? []).map((name) => ({ key: name, label: name })),\n\t\t],\n\t\t[manifest, t]\n\t)\n\n\tconst libraryOptions = useMemo(\n\t\t() => adapters.map((adapter) => ({ label: adapter.label, value: adapter.slug })),\n\t\t[adapters]\n\t)\n\tconst librarySelectId = `${slugPrefix}-library`\n\n\t// The stored value points at a library that is no longer offered for selection; the\n\t// full explanation lives here, the trigger only carries a compact marker.\n\tconst selectedUnavailable =\n\t\tselected !== null && !adapters.some((adapter) => adapter.slug === selected.library)\n\n\t// A listbox must own option children, so the grid only claims role=\"listbox\" (with\n\t// its keyboard nav and label) once cells exist. While loading it is an aria-busy\n\t// container; when empty it is a plain container holding the \"no icons\" message.\n\tconst gridPopulated = !loading && visible.length > 0\n\tconst gridA11y: React.HTMLAttributes<HTMLDivElement> = gridPopulated\n\t\t? { 'aria-label': t(keys.iconGrid), onKeyDown: handleGridKeyDown, role: 'listbox' }\n\t\t: { 'aria-busy': loading || undefined }\n\n\treturn (\n\t\t<div className=\"tenx-icon-drawer\">\n\t\t\t{/* Sibling loaders keyed distinctly per library: a shared key collides (\"two children\n\t\t\t with the same key\") when both mount on open, while distinct keys keep the per-library remount. */}\n\t\t\t{Assets && !manifest ? (\n\t\t\t\t<Assets key={`assets-${activeLibrary}`} onReady={handleManifest} />\n\t\t\t) : null}\n\t\t\t{NodesLoader && !nodeMap ? (\n\t\t\t\t<NodesLoader key={`nodes-${activeLibrary}`} onReady={handleNodes} />\n\t\t\t) : null}\n\t\t\t<div className=\"tenx-icon-drawer__body\">\n\t\t\t\t<nav aria-label={t(keys.iconCategories)} className=\"tenx-icon-drawer__rail\">\n\t\t\t\t\t{railItems.map((item) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-pressed={category === item.key}\n\t\t\t\t\t\t\tbuttonStyle={category === item.key ? 'pill' : 'ghost'}\n\t\t\t\t\t\t\tclassName=\"tenx-icon-drawer__rail-item\"\n\t\t\t\t\t\t\tkey={item.key}\n\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\tonClick={() => setCategory(item.key)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t))}\n\t\t\t\t</nav>\n\t\t\t\t<div className=\"tenx-icon-drawer__main\" style={mainStyle}>\n\t\t\t\t\t{selectedUnavailable ? (\n\t\t\t\t\t\t<div className=\"tenx-icon-drawer__banner\" role=\"status\">\n\t\t\t\t\t\t\t{t(keys.libraryUnavailable)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<div className=\"tenx-icon-drawer__header\">\n\t\t\t\t\t\t<div className=\"tenx-icon-drawer__search form-input-group\">\n\t\t\t\t\t\t\t<span aria-hidden=\"true\" className=\"tenx-icon-drawer__search-icon\">\n\t\t\t\t\t\t\t\t<SearchIcon />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\taria-label={t(keys.searchIcons)}\n\t\t\t\t\t\t\t\tclassName=\"form-input tenx-icon-drawer__search-input\"\n\t\t\t\t\t\t\t\tonChange={(event: React.ChangeEvent<HTMLInputElement>) =>\n\t\t\t\t\t\t\t\t\tsetQuery(event.target.value)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplaceholder={t(keys.searchIcons)}\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tvalue={query}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{/* adapters is the available-filtered set; the switcher shows only with 2+ libraries, fixed width beside the growing search */}\n\t\t\t\t\t\t{adapters.length > 1 ? (\n\t\t\t\t\t\t\t<div className=\"tenx-icon-drawer__switcher\">\n\t\t\t\t\t\t\t\t<label className=\"tenx-icon-drawer__sr-only\" htmlFor={librarySelectId}>\n\t\t\t\t\t\t\t\t\t{t(keys.fieldIconLibraryLabel)}\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\t\tinputId={librarySelectId}\n\t\t\t\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\t\t\t\tonChange={(option) => {\n\t\t\t\t\t\t\t\t\t\tconst single = Array.isArray(option) ? option[0] : option\n\t\t\t\t\t\t\t\t\t\tif (single && typeof single.value === 'string') onLibraryChange(single.value)\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\toptions={libraryOptions}\n\t\t\t\t\t\t\t\t\tvalue={libraryOptions.find((option) => option.value === activeLibrary)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"tenx-icon-drawer__grid\" ref={gridRef} {...gridA11y}>\n\t\t\t\t\t\t{loading ? (\n\t\t\t\t\t\t\t<div className=\"tenx-icon-drawer__loading\">\n\t\t\t\t\t\t\t\t{Array.from({ length: 24 }, (_, skeletonIndex) => (\n\t\t\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: fixed-count static placeholders that never reorder\n\t\t\t\t\t\t\t\t\t<span className=\"tenx-icon-placeholder\" key={`skeleton-${skeletonIndex}`} />\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : visible.length === 0 ? (\n\t\t\t\t\t\t\t<div className=\"tenx-icon-drawer__empty\">{t(keys.noIconsFound)}</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\tstyle={{ height: virtualizer.getTotalSize(), position: 'relative', width: '100%' }}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{virtualizer.getVirtualItems().map((row) => (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclassName=\"tenx-icon-drawer__row\"\n\t\t\t\t\t\t\t\t\t\tdata-index={row.index}\n\t\t\t\t\t\t\t\t\t\tkey={row.key}\n\t\t\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\tleft: 0,\n\t\t\t\t\t\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\t\t\t\t\t\ttop: 0,\n\t\t\t\t\t\t\t\t\t\t\ttransform: `translateY(${row.start}px)`,\n\t\t\t\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{visible\n\t\t\t\t\t\t\t\t\t\t\t.slice(row.index * columns, row.index * columns + columns)\n\t\t\t\t\t\t\t\t\t\t\t.map((icon, columnIndex) => {\n\t\t\t\t\t\t\t\t\t\t\t\tconst cellIndex = row.index * columns + columnIndex\n\t\t\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<IconGridCell\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcanvas={entry?.canvas}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tentry={entry}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfocused={cellIndex === focusIndex}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={icon}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tindex={cellIndex}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tisSelected={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tselected?.library === activeLibrary && selected.name === icon.name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={icon.name}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlanguage={i18n.language}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnodes={NodesLoader ? nodeMap?.[icon.name] : undefined}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tregisterRef={registerRef}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div className=\"tenx-icon-drawer__footer\">\n\t\t\t\t{t(keys.resultsCount, { count: visible.length })}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nexport default IconDrawerContent\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,YAAY;AAClB,MAAM,SAAS;AACf,MAAM,MAAM;AAaZ,MAAM,qBAAuD,EAC5D,eACA,mBACA,UACA,iBACA,UACA,UACA,iBACK;CACL,MAAM,EAAE,MAAM,MAAMA,iBAAe;CACnC,MAAM,CAAC,WAAW,gBAAgB,+BAA0C,IAAI,IAAI,CAAC;CACrF,MAAM,CAAC,UAAU,eAAe,+BAAyC,IAAI,IAAI,CAAC;CAClF,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAAiB,GAAG;CACpD,MAAM,EAAE,WAAW,WAAW,eAAe,aAAa;CAE1D,MAAM,WAAW,UAAU,IAAI,aAAa;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hidden x overflow keeps a rounding pixel from
|
|
341
|
+
bringing a horizontal scrollbar back. */
|
|
342
|
+
overflow-x: hidden;
|
|
340
343
|
overflow-y: auto;
|
|
341
344
|
/* Promote the scroller to its own compositor layer so the virtualizer's
|
|
342
345
|
translateY rows repaint on the GPU during fast scrolls. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@10x-media/fields",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"description": "Reusable admin fields for Payload: color picker, icon picker, encrypted fields, and more",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -182,9 +182,9 @@
|
|
|
182
182
|
"typescript": "5.9.3",
|
|
183
183
|
"vitest": "4.1.7",
|
|
184
184
|
"@10x-media/payload-test-harness": "0.0.0",
|
|
185
|
-
"@10x-media/tsconfig": "0.0.0",
|
|
186
185
|
"@10x-media/tsdown-config": "0.0.0",
|
|
187
|
-
"@10x-media/vitest-config": "0.0.0"
|
|
186
|
+
"@10x-media/vitest-config": "0.0.0",
|
|
187
|
+
"@10x-media/tsconfig": "0.0.0"
|
|
188
188
|
},
|
|
189
189
|
"publishConfig": {
|
|
190
190
|
"access": "public"
|