sanity-plugin-iconify 1.1.1 → 2.0.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Wannes Salomé
3
+ Copyright (c) 2024 Wannes Salomé
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  ---
12
12
 
13
13
  ## 📒 Table of Contents
14
+
14
15
  - [📒 Table of Contents](#-table-of-contents)
15
16
  - [📍 Overview](#-overview)
16
17
  - [🚀 Getting Started](#-getting-started)
@@ -30,7 +31,6 @@
30
31
 
31
32
  ---
32
33
 
33
-
34
34
  ## 📍 Overview
35
35
 
36
36
  Enhance your [Sanity](https://www.sanity.io/) project with the Iconify plugin, which introduces an Icon schema type and a custom input component. Leveraging the extensive library of open-source vector icons available through the [Iconify](https://iconify.design/), this plugin enables you to effortlessly select and integrate over 150,000 icons from popular icon sets directly into your Sanity project.
@@ -158,9 +158,11 @@ import { defineConfig } from 'sanity';
158
158
 
159
159
  export default defineConfig({
160
160
  //...
161
- plugins: [iconify({
162
- showName: true, // <-- Shows the selected icon name and collection underneath all icon pickers
163
- })],
161
+ plugins: [
162
+ iconify({
163
+ showName: true, // <-- Shows the selected icon name and collection underneath all icon pickers
164
+ }),
165
+ ],
164
166
  });
165
167
  ```
166
168
 
@@ -200,7 +202,7 @@ This name can be utilized in your frontend to render the icon dynamically. For i
200
202
  ```tsx
201
203
  import { Icon } from '@iconify/react';
202
204
 
203
- <Icon icon={icon.name} />
205
+ <Icon icon={icon.name} />;
204
206
  ```
205
207
 
206
208
  This will render an SVG on demand, which looks great and is very performant. There are also libraries/API's for:
@@ -214,7 +216,7 @@ For further information, you may refer to the [official documentation](https://i
214
216
 
215
217
  ### Preview
216
218
 
217
- The plugin includes a custom list preview that automatically renders the selected icon accompanied by its name and collection.
219
+ The plugin includes a custom list preview that automatically renders the selected icon accompanied by its name and collection.
218
220
 
219
221
  <img width="618" alt="array-of-icons" src="https://github.com/waspeer/sanity-plugin-iconify/assets/11842931/0c1c32a1-e796-434f-ae64-c134f9b51ab9">
220
222
 
@@ -255,18 +257,24 @@ Contributions, whether in the form of code enhancements, bug fixes, documentatio
255
257
  1. Fork the project repository. This creates a copy of the project on your account that you can modify without affecting the original project.
256
258
  2. Clone the forked repository to your local machine using a Git client like Git or GitHub Desktop.
257
259
  3. Create a new branch with a descriptive name (e.g., `new-feature-branch` or `bugfix-issue-123`).
260
+
258
261
  ```sh
259
262
  git checkout -b new-feature-branch
260
263
  ```
264
+
261
265
  1. Make changes to the project's codebase.
262
266
  2. Commit your changes to your local branch with a clear conventional commit message that explains the changes you've made.
267
+
263
268
  ```sh
264
269
  git commit -m 'feat: Implemented new feature.'
265
270
  ```
271
+
266
272
  1. Push your changes to your forked repository on GitHub using the following command
273
+
267
274
  ```sh
268
275
  git push origin new-feature-branch
269
276
  ```
277
+
270
278
  1. Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they are necessary. Make sure to update or add documentation as relevant. I will review your changes, provide feedback, or merge them into the main branch.
271
279
 
272
280
  ## 🧪 Develop & test
package/dist/index.cjs ADDED
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: !0 });
3
+ var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), theme = require("@sanity/ui/theme"), react = require("react"), react$1 = require("@headlessui/react"), tsPattern = require("ts-pattern"), reactQuery = require("@tanstack/react-query"), useDebounce = require("use-debounce"), styled = require("styled-components"), react$2 = require("@iconify/react"), icons = require("@sanity/icons"), utils = require("@iconify/utils"), changeCase = require("change-case");
4
+ function _interopDefaultCompat(e) {
5
+ return e && typeof e == "object" && "default" in e ? e : { default: e };
6
+ }
7
+ var styled__default = /* @__PURE__ */ _interopDefaultCompat(styled);
8
+ const BASE_API_URL = "https://api.iconify.design";
9
+ function fetchJson({ url, signal }) {
10
+ return fetch(url, { signal }).then((response) => {
11
+ if (!response.ok)
12
+ throw new Error(`Network error: status ${response.status}`);
13
+ return response.json();
14
+ }).then(
15
+ (result) => result,
16
+ (error) => {
17
+ throw error instanceof Error ? error : (console.error(`Unknown error: ${error}`), new Error("Something went wrong"));
18
+ }
19
+ );
20
+ }
21
+ function useSearch({ collections }) {
22
+ const queryClient2 = reactQuery.useQueryClient(), [term, setTerm] = react.useState(""), [debouncedTerm, setDebouncedTerm] = useDebounce.useDebounce(term, 500), updateTerm = react.useCallback(
23
+ (newTerm, updateImmediately = !1) => {
24
+ setTerm(newTerm), updateImmediately && setDebouncedTerm(newTerm);
25
+ },
26
+ [setDebouncedTerm]
27
+ ), { isLoading, isError, error, data, isPlaceholderData } = reactQuery.useQuery({
28
+ queryKey: ["search", collections, debouncedTerm],
29
+ queryFn: async ({ signal }) => {
30
+ var _a;
31
+ const url = new URL("/search", BASE_API_URL);
32
+ url.searchParams.append("query", debouncedTerm), url.searchParams.append("limit", "60"), collections && url.searchParams.append("prefixes", collections.join(","));
33
+ const result = debouncedTerm ? await fetchJson({ url, signal }) : null;
34
+ return result && Object.entries(result.collections).forEach(([prefix, info]) => {
35
+ queryClient2.setQueryData(["iconSetInfo", prefix], info);
36
+ }), (_a = result == null ? void 0 : result.icons) != null ? _a : [];
37
+ },
38
+ enabled: debouncedTerm.length > 0,
39
+ placeholderData: reactQuery.keepPreviousData,
40
+ staleTime: 5 * 60 * 1e3
41
+ // 5 minutes
42
+ });
43
+ return {
44
+ term,
45
+ setTerm: updateTerm,
46
+ debouncedTerm,
47
+ isLoading,
48
+ isError,
49
+ error,
50
+ data,
51
+ isPreviousData: isPlaceholderData
52
+ };
53
+ }
54
+ function useIconSetInfo({ prefix }) {
55
+ return reactQuery.useQuery({
56
+ queryKey: ["iconSetInfo", prefix],
57
+ queryFn: async ({ signal }) => {
58
+ var _a;
59
+ if (!prefix) return null;
60
+ const url = new URL("/collection", BASE_API_URL);
61
+ url.searchParams.append("prefix", prefix), url.searchParams.append("info", "true");
62
+ const result = await fetchJson({ url, signal });
63
+ return (_a = result == null ? void 0 : result.info) != null ? _a : null;
64
+ },
65
+ staleTime: 1 / 0
66
+ });
67
+ }
68
+ const ComboboxWrapper = styled__default.default(ui.Grid)`
69
+ grid-template-columns: 1fr min-content;
70
+ position: relative;
71
+ `, OptionsWrapper = styled__default.default(ui.Box)`
72
+ box-sizing: border-box;
73
+ padding: 0.5rem;
74
+
75
+ & [role='listbox'] {
76
+ display: grid;
77
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 2.5rem), 1fr));
78
+ gap: 0.5rem;
79
+ margin: 0;
80
+ padding: 0;
81
+ list-style: none;
82
+
83
+ @media (min-width: 650px) {
84
+ grid-template-columns: repeat(10, minmax(min(100%, 2.5rem), 1fr));
85
+ }
86
+ }
87
+
88
+ & [role='option'] {
89
+ display: grid;
90
+ place-items: center;
91
+
92
+ & button {
93
+ cursor: pointer;
94
+ aspect-ratio: 1;
95
+ width: 100%;
96
+
97
+ & > [data-ui='Box'] {
98
+ display: flex;
99
+ }
100
+ }
101
+ }
102
+ `;
103
+ function MessageWrapper({ children }) {
104
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { align: "center", muted: !0, children }) });
105
+ }
106
+ const SearchInput = react.forwardRef((props, ref) => {
107
+ const { term, selectedIcon, onChange, suffix } = props;
108
+ return /* @__PURE__ */ jsxRuntime.jsx(
109
+ react$1.ComboboxInput,
110
+ {
111
+ as: ui.TextInput,
112
+ ref,
113
+ inputMode: "search",
114
+ value: term,
115
+ onChange,
116
+ icon: selectedIcon ? /* @__PURE__ */ jsxRuntime.jsx(react$2.Icon, { icon: selectedIcon }) : null,
117
+ placeholder: selectedIcon ? "Search and replace selected icon..." : "Search for an icon...",
118
+ suffix
119
+ }
120
+ );
121
+ });
122
+ SearchInput.displayName = "SearchInput";
123
+ function SearchResults(props) {
124
+ const { state, data } = props;
125
+ return state === "initial" ? /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Search for icons" }) : state === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Searching..." }) : state === "error" ? /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "Something went wrong..." }) : state === "empty" ? /* @__PURE__ */ jsxRuntime.jsx(MessageWrapper, { children: "No icons found" }) : /* @__PURE__ */ jsxRuntime.jsx(react$1.ComboboxOptions, { style: { opacity: state === "stale" ? 0.5 : 1 }, children: data.map((icon) => /* @__PURE__ */ jsxRuntime.jsx(react$1.ComboboxOption, { value: icon, children: ({ focus }) => /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { padding: 3, mode: "bleed", selected: focus, children: /* @__PURE__ */ jsxRuntime.jsx(react$2.Icon, { icon, width: "100%", height: "100%" }) }) }, icon)) });
126
+ }
127
+ function UnsetButton(props) {
128
+ const { onUnset } = props;
129
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, borderLeft: !1, padding: 1, display: "flex", radius: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.TrashIcon, {}), onClick: onUnset, mode: "bleed", fontSize: 1, padding: 2 }) });
130
+ }
131
+ function IconifyCombobox(props) {
132
+ const { selectedIcon, onSelect: pushSelection, collections } = props, id = react.useId(), toast = ui.useToast(), inputRef = react.useRef(null), { term, setTerm, debouncedTerm, isLoading, isError, error, data, isPreviousData } = useSearch({
133
+ collections
134
+ }), handleTermChange = react.useCallback(
135
+ (event) => setTerm(event.target.value),
136
+ [setTerm]
137
+ ), handleSelect = react.useCallback(
138
+ (icon) => {
139
+ pushSelection(icon), setTerm("", !0);
140
+ },
141
+ [pushSelection, setTerm]
142
+ ), handleUnset = react.useCallback(() => handleSelect(""), [handleSelect]);
143
+ return react.useEffect(() => {
144
+ isError && (console.error("Iconify input error:", error), toast.push({
145
+ id,
146
+ status: "error",
147
+ title: "Iconify input error",
148
+ description: error == null ? void 0 : error.message
149
+ }));
150
+ }, [error, id, isError, toast]), /* @__PURE__ */ jsxRuntime.jsx(ComboboxWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Combobox, { onChange: handleSelect, children: ({ open }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
151
+ /* @__PURE__ */ jsxRuntime.jsx(
152
+ SearchInput,
153
+ {
154
+ ref: inputRef,
155
+ term,
156
+ selectedIcon,
157
+ onChange: handleTermChange,
158
+ suffix: selectedIcon ? /* @__PURE__ */ jsxRuntime.jsx(UnsetButton, { onUnset: handleUnset }) : null
159
+ }
160
+ ),
161
+ /* @__PURE__ */ jsxRuntime.jsx(
162
+ ui.Popover,
163
+ {
164
+ open,
165
+ placement: "bottom",
166
+ arrow: !1,
167
+ matchReferenceWidth: !0,
168
+ portal: !0,
169
+ constrainSize: !0,
170
+ referenceElement: inputRef.current,
171
+ content: /* @__PURE__ */ jsxRuntime.jsx(OptionsWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
172
+ SearchResults,
173
+ {
174
+ state: tsPattern.match(!0).returnType().with(isLoading, () => "loading").with(!debouncedTerm, () => "initial").with(isError, () => "error").with(!data || data.length === 0, () => "empty").with(isPreviousData, () => "stale").otherwise(() => "data"),
175
+ data
176
+ }
177
+ ) })
178
+ }
179
+ )
180
+ ] }) }) });
181
+ }
182
+ const queryClient = new reactQuery.QueryClient();
183
+ function QueryClientProvider(props) {
184
+ return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children: props.children });
185
+ }
186
+ function usePrettyIconName(props) {
187
+ var _a, _b;
188
+ const { name } = props, iconMeta = react.useMemo(
189
+ () => {
190
+ var _a2;
191
+ return (_a2 = props.iconMeta) != null ? _a2 : name ? utils.stringToIcon(name) : null;
192
+ },
193
+ [name, props.iconMeta]
194
+ ), iconSetInfo = useIconSetInfo({ prefix: (_a = iconMeta == null ? void 0 : iconMeta.prefix) != null ? _a : null });
195
+ return react.useMemo(
196
+ () => {
197
+ var _a2, _b2;
198
+ return iconMeta ? {
199
+ name: changeCase.sentenceCase(iconMeta.name),
200
+ collection: (_b2 = (_a2 = iconSetInfo.data) == null ? void 0 : _a2.name) != null ? _b2 : iconMeta.prefix
201
+ } : null;
202
+ },
203
+ [iconMeta, (_b = iconSetInfo.data) == null ? void 0 : _b.name]
204
+ );
205
+ }
206
+ function IconifyInput(props) {
207
+ var _a, _b, _c, _d, _e;
208
+ const { config, value, onChange: pushChange, schemaType } = props, selectedIcon = (_a = value == null ? void 0 : value.name) != null ? _a : null, options = schemaType.options, collections = !!((_b = options == null ? void 0 : options.collections) != null && _b.length) && options.collections || !!((_c = config == null ? void 0 : config.collections) != null && _c.length) && config.collections || null, showName = (_e = (_d = options == null ? void 0 : options.showName) != null ? _d : config == null ? void 0 : config.showName) != null ? _e : !1, handleSelect = react.useCallback(
209
+ (icon) => {
210
+ pushChange(icon === "" ? sanity.unset() : sanity.set(icon, ["name"]));
211
+ },
212
+ [pushChange]
213
+ );
214
+ return /* @__PURE__ */ jsxRuntime.jsx(QueryClientProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.ThemeProvider, { theme: theme.buildTheme(), children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
215
+ /* @__PURE__ */ jsxRuntime.jsx(
216
+ IconifyCombobox,
217
+ {
218
+ selectedIcon,
219
+ onSelect: handleSelect,
220
+ collections
221
+ }
222
+ ),
223
+ showName && selectedIcon ? /* @__PURE__ */ jsxRuntime.jsx(IconifyNameDisplay, { name: selectedIcon }) : null
224
+ ] }) }) });
225
+ }
226
+ function IconifyNameDisplay(props) {
227
+ var _a;
228
+ const { name } = props, prettyName = usePrettyIconName({ name });
229
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
230
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "Selected:" }),
231
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: (_a = prettyName == null ? void 0 : prettyName.name) != null ? _a : name }),
232
+ (prettyName == null ? void 0 : prettyName.collection) && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, style: { fontStyle: "italic" }, children: [
233
+ "by ",
234
+ prettyName == null ? void 0 : prettyName.collection
235
+ ] })
236
+ ] });
237
+ }
238
+ function IconifyPreview(props) {
239
+ const { title } = props, iconName = typeof props.title == "string" ? utils.stringToIcon(props.title) : null;
240
+ return typeof title == "string" && iconName ? /* @__PURE__ */ jsxRuntime.jsx(QueryClientProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(IconifyPreviewInner, { ...props, iconName: title, iconMeta: iconName }) }) : props.renderDefault(props);
241
+ }
242
+ function IconifyPreviewInner(props) {
243
+ var _a;
244
+ const { iconMeta, iconName, ...previewProps } = props, prettyName = usePrettyIconName({ iconMeta });
245
+ return props.renderDefault({
246
+ ...previewProps,
247
+ media: /* @__PURE__ */ jsxRuntime.jsx(react$2.Icon, { icon: iconName }),
248
+ title: (_a = prettyName == null ? void 0 : prettyName.name) != null ? _a : iconName,
249
+ subtitle: prettyName == null ? void 0 : prettyName.collection
250
+ });
251
+ }
252
+ const iconify = sanity.definePlugin((config = {}) => ({
253
+ name: "sanity-plugin-iconify",
254
+ schema: {
255
+ types: [
256
+ {
257
+ name: "icon",
258
+ title: "Icon",
259
+ type: "object",
260
+ fields: [
261
+ {
262
+ name: "name",
263
+ title: "Name",
264
+ type: "string"
265
+ }
266
+ ],
267
+ components: {
268
+ input: (props) => /* @__PURE__ */ jsxRuntime.jsx(IconifyInput, { ...props, config }),
269
+ preview: IconifyPreview,
270
+ // This makes sure the input component is not indented
271
+ field: (props) => props.renderDefault({ ...props, level: 0 })
272
+ }
273
+ }
274
+ ]
275
+ }
276
+ }));
277
+ exports.iconify = iconify;
278
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/api.ts","../src/combobox/iconify-combobox.styles.tsx","../src/combobox/search-input.tsx","../src/combobox/search-result.tsx","../src/combobox/unset-button.tsx","../src/combobox/iconify-combobox.tsx","../src/lib/query-client.tsx","../src/lib/use-pretty-icon-name.ts","../src/iconify-input.tsx","../src/iconify-preview.tsx","../src/iconify-plugin.tsx"],"sourcesContent":["import type { IconifyInfo } from '@iconify/types';\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useCallback, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\nimport type { IconifySearchResult } from './types';\n\nconst BASE_API_URL = 'https://api.iconify.design';\n\nfunction fetchJson<T>({ url, signal }: { url: string | URL; signal?: AbortSignal }): Promise<T> {\n return fetch(url, { signal })\n .then((response) => {\n if (!response.ok) {\n throw new Error(`Network error: status ${response.status}`);\n }\n\n return response.json();\n })\n .then(\n (result) => result as T,\n (error) => {\n if (error instanceof Error) {\n throw error;\n } else {\n console.error(`Unknown error: ${error}`);\n throw new Error('Something went wrong');\n }\n },\n );\n}\n\nexport function useSearch({ collections }: { collections: string[] | null }) {\n const queryClient = useQueryClient();\n const [term, setTerm] = useState('');\n const [debouncedTerm, setDebouncedTerm] = useDebounce(term, 500);\n\n const updateTerm = useCallback(\n (newTerm: string, updateImmediately = false) => {\n setTerm(newTerm);\n\n if (updateImmediately) {\n setDebouncedTerm(newTerm);\n }\n },\n [setDebouncedTerm],\n );\n\n const { isLoading, isError, error, data, isPlaceholderData } = useQuery<string[], Error>({\n queryKey: ['search', collections, debouncedTerm],\n queryFn: async ({ signal }) => {\n const url = new URL(`/search`, BASE_API_URL);\n\n url.searchParams.append('query', debouncedTerm);\n url.searchParams.append('limit', '60');\n\n if (collections) {\n url.searchParams.append('prefixes', collections.join(','));\n }\n\n const result = debouncedTerm ? await fetchJson<IconifySearchResult>({ url, signal }) : null;\n\n if (result) {\n // Cache the info for each collection\n Object.entries(result.collections).forEach(([prefix, info]) => {\n queryClient.setQueryData<IconifyInfo>(['iconSetInfo', prefix], info);\n });\n }\n\n return result?.icons ?? [];\n },\n enabled: debouncedTerm.length > 0,\n placeholderData: keepPreviousData,\n staleTime: 5 * 60 * 1000, // 5 minutes\n });\n\n return {\n term,\n setTerm: updateTerm,\n debouncedTerm,\n isLoading,\n isError,\n error,\n data,\n isPreviousData: isPlaceholderData,\n };\n}\n\nexport function useIconSetInfo({ prefix }: { prefix?: string | null }) {\n return useQuery<IconifyInfo | null, Error>({\n queryKey: ['iconSetInfo', prefix],\n queryFn: async ({ signal }) => {\n if (!prefix) return null;\n\n const url = new URL('/collection', BASE_API_URL);\n\n url.searchParams.append('prefix', prefix);\n url.searchParams.append('info', 'true');\n\n const result = await fetchJson<{ info: IconifyInfo }>({ url, signal });\n\n return result?.info ?? null;\n },\n staleTime: Infinity,\n });\n}\n","import { Box, Card, Grid, Text } from '@sanity/ui';\nimport type { ReactNode } from 'react';\nimport styled from 'styled-components';\n\nexport const ComboboxWrapper = styled(Grid)`\n grid-template-columns: 1fr min-content;\n position: relative;\n`;\n\nexport const OptionsWrapper = styled(Box)`\n box-sizing: border-box;\n padding: 0.5rem;\n\n & [role='listbox'] {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 2.5rem), 1fr));\n gap: 0.5rem;\n margin: 0;\n padding: 0;\n list-style: none;\n\n @media (min-width: 650px) {\n grid-template-columns: repeat(10, minmax(min(100%, 2.5rem), 1fr));\n }\n }\n\n & [role='option'] {\n display: grid;\n place-items: center;\n\n & button {\n cursor: pointer;\n aspect-ratio: 1;\n width: 100%;\n\n & > [data-ui='Box'] {\n display: flex;\n }\n }\n }\n`;\n\nexport function MessageWrapper({ children }: { children: ReactNode }) {\n return (\n <Card padding={4}>\n <Text align=\"center\" muted>\n {children}\n </Text>\n </Card>\n );\n}\n","import { ComboboxInput } from '@headlessui/react';\nimport { Icon } from '@iconify/react';\nimport { TextInput } from '@sanity/ui';\nimport type { ChangeEventHandler } from 'react';\nimport { forwardRef } from 'react';\n\n// ------------ //\n// SEARCH INPUT //\n// ------------ //\n\ninterface SearchInputProps {\n term: string;\n selectedIcon: string | null;\n onChange: ChangeEventHandler<HTMLInputElement>;\n suffix?: React.ReactNode;\n}\n\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>((props, ref) => {\n const { term, selectedIcon, onChange, suffix } = props;\n\n return (\n <ComboboxInput\n as={TextInput}\n ref={ref}\n inputMode=\"search\"\n value={term}\n onChange={onChange}\n icon={selectedIcon ? <Icon icon={selectedIcon} /> : null}\n placeholder={selectedIcon ? 'Search and replace selected icon...' : 'Search for an icon...'}\n suffix={suffix}\n />\n );\n});\n\nSearchInput.displayName = 'SearchInput';\n","import { ComboboxOption, ComboboxOptions } from '@headlessui/react';\nimport { Icon } from '@iconify/react';\nimport { Button } from '@sanity/ui';\nimport { MessageWrapper } from './iconify-combobox.styles';\n\n// -------------- //\n// SEARCH RESULTS //\n// -------------- //\n\nexport interface SearchResultsProps {\n state: 'initial' | 'loading' | 'error' | 'empty' | 'data' | 'stale';\n data?: string[];\n}\n\nexport function SearchResults(props: SearchResultsProps) {\n const { state, data } = props;\n\n if (state === 'initial') {\n return <MessageWrapper>Search for icons</MessageWrapper>;\n }\n\n if (state === 'loading') {\n return <MessageWrapper>Searching...</MessageWrapper>;\n }\n\n if (state === 'error') {\n return <MessageWrapper>Something went wrong...</MessageWrapper>;\n }\n\n if (state === 'empty') {\n return <MessageWrapper>No icons found</MessageWrapper>;\n }\n\n return (\n <ComboboxOptions style={{ opacity: state === 'stale' ? 0.5 : 1 }}>\n {data!.map((icon) => (\n <ComboboxOption key={icon} value={icon}>\n {({ focus }) => (\n <Button padding={3} mode=\"bleed\" selected={focus}>\n <Icon icon={icon} width=\"100%\" height=\"100%\" />\n </Button>\n )}\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n );\n}\n","import { TrashIcon } from '@sanity/icons';\nimport { Button, Card } from '@sanity/ui';\n\n// ------------ //\n// UNSET BUTTON //\n// ------------ //\n\ninterface UnsetButtonProps {\n onUnset: () => void;\n}\n\nexport function UnsetButton(props: UnsetButtonProps) {\n const { onUnset } = props;\n\n return (\n <Card border borderLeft={false} padding={1} display=\"flex\" radius={2}>\n <Button icon={<TrashIcon />} onClick={onUnset} mode=\"bleed\" fontSize={1} padding={2} />\n </Card>\n );\n}\n","import { Combobox } from '@headlessui/react';\nimport { Popover, useToast } from '@sanity/ui';\nimport type { ChangeEventHandler } from 'react';\nimport { useCallback, useEffect, useId, useRef } from 'react';\nimport { match } from 'ts-pattern';\nimport { useSearch } from '../lib/api';\nimport { ComboboxWrapper, OptionsWrapper } from './iconify-combobox.styles';\nimport { SearchInput } from './search-input';\nimport type { SearchResultsProps } from './search-result';\nimport { SearchResults } from './search-result';\nimport { UnsetButton } from './unset-button';\n\nexport interface IconifyComboboxProps {\n selectedIcon: string | null;\n onSelect: (newValue: string) => void;\n collections: string[] | null;\n}\n\nexport function IconifyCombobox(props: IconifyComboboxProps) {\n const { selectedIcon, onSelect: pushSelection, collections } = props;\n\n const id = useId();\n const toast = useToast();\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { term, setTerm, debouncedTerm, isLoading, isError, error, data, isPreviousData } =\n useSearch({\n collections,\n });\n\n const handleTermChange: ChangeEventHandler<HTMLInputElement> = useCallback(\n (event) => setTerm(event.target.value),\n [setTerm],\n );\n\n const handleSelect = useCallback(\n (icon: string) => {\n pushSelection(icon);\n setTerm('', true);\n },\n [pushSelection, setTerm],\n );\n\n const handleUnset = useCallback(() => handleSelect(''), [handleSelect]);\n\n useEffect(() => {\n if (isError) {\n console.error('Iconify input error:', error);\n\n toast.push({\n id,\n status: 'error',\n title: 'Iconify input error',\n description: error?.message,\n });\n }\n }, [error, id, isError, toast]);\n\n return (\n <ComboboxWrapper>\n <Combobox onChange={handleSelect}>\n {({ open }) => (\n <>\n <SearchInput\n ref={inputRef}\n term={term}\n selectedIcon={selectedIcon}\n onChange={handleTermChange}\n suffix={selectedIcon ? <UnsetButton onUnset={handleUnset} /> : null}\n />\n\n <Popover\n open={open}\n placement=\"bottom\"\n arrow={false}\n matchReferenceWidth\n portal\n constrainSize\n referenceElement={inputRef.current}\n content={\n <OptionsWrapper>\n <SearchResults\n state={match<boolean>(true)\n .returnType<SearchResultsProps['state']>()\n .with(isLoading, () => 'loading')\n .with(!debouncedTerm, () => 'initial')\n .with(isError, () => 'error')\n .with(!data || data.length === 0, () => 'empty')\n .with(isPreviousData, () => 'stale')\n .otherwise(() => 'data')}\n data={data}\n />\n </OptionsWrapper>\n }\n />\n </>\n )}\n </Combobox>\n </ComboboxWrapper>\n );\n}\n","import {\n QueryClient,\n QueryClientProvider as ReactQueryClientProvider,\n} from '@tanstack/react-query';\nimport type { ReactNode } from 'react';\n\nexport const queryClient = new QueryClient();\n\nexport function QueryClientProvider(props: { children: ReactNode }) {\n return <ReactQueryClientProvider client={queryClient}>{props.children}</ReactQueryClientProvider>;\n}\n","import type { IconifyIconName } from '@iconify/utils';\nimport { stringToIcon } from '@iconify/utils';\nimport { sentenceCase } from 'change-case';\nimport { useMemo } from 'react';\nimport { useIconSetInfo } from './api';\n\ninterface UsePrettyIconNameProps {\n name?: string | null;\n iconMeta?: IconifyIconName | null;\n}\n\nexport function usePrettyIconName(props: UsePrettyIconNameProps) {\n const { name } = props;\n const iconMeta = useMemo(\n () => props.iconMeta ?? (name ? stringToIcon(name) : null),\n [name, props.iconMeta],\n );\n const iconSetInfo = useIconSetInfo({ prefix: iconMeta?.prefix ?? null });\n\n return useMemo(\n () =>\n iconMeta\n ? {\n name: sentenceCase(iconMeta.name),\n collection: iconSetInfo.data?.name ?? iconMeta.prefix,\n }\n : null,\n [iconMeta, iconSetInfo.data?.name],\n );\n}\n","import { Flex, Stack, Text, ThemeProvider } from '@sanity/ui';\nimport { buildTheme } from '@sanity/ui/theme';\nimport { useCallback } from 'react';\nimport type { ObjectInputProps } from 'sanity';\nimport { set, unset } from 'sanity';\nimport { IconifyCombobox } from './combobox';\nimport { QueryClientProvider } from './lib/query-client';\nimport type { IconifyPluginConfig, IconOptions } from './lib/types';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\n// -------------- //\n// ICONIFY INPUT //\n// -------------- //\n\ninterface IconifyInputProps extends ObjectInputProps {\n config: IconifyPluginConfig;\n}\n\nexport function IconifyInput(props: IconifyInputProps) {\n const { config, value, onChange: pushChange, schemaType } = props;\n\n const selectedIcon: string | null = value?.name ?? null;\n\n const options: IconOptions = schemaType.options;\n const collections =\n (!!options?.collections?.length && options.collections) ||\n (!!config?.collections?.length && config.collections) ||\n null;\n const showName = options?.showName ?? config?.showName ?? false;\n\n // const parentTheme = useTheme();\n // const theme: RootTheme = useMemo(\n // () => (parentTheme ? { ...parentTheme.sanity, color: studioTheme.color } : studioTheme),\n // [parentTheme],\n // );\n\n const handleSelect = useCallback(\n (icon: string) => {\n pushChange(icon === '' ? unset() : set(icon, ['name']));\n },\n [pushChange],\n );\n\n return (\n <QueryClientProvider>\n <ThemeProvider theme={buildTheme()}>\n <Stack space={2}>\n <IconifyCombobox\n selectedIcon={selectedIcon}\n onSelect={handleSelect}\n collections={collections}\n />\n\n {showName && selectedIcon ? <IconifyNameDisplay name={selectedIcon} /> : null}\n </Stack>\n </ThemeProvider>\n </QueryClientProvider>\n );\n}\n\ninterface IconifyNameDisplayProps {\n name?: string | null;\n}\n\nfunction IconifyNameDisplay(props: IconifyNameDisplayProps) {\n const { name } = props;\n const prettyName = usePrettyIconName({ name });\n\n return (\n <Flex gap={1}>\n <Text size={1} muted>\n Selected:\n </Text>\n\n <Text size={1} weight=\"semibold\">\n {prettyName?.name ?? name}\n </Text>\n\n {prettyName?.collection && (\n <Text size={1} muted style={{ fontStyle: 'italic' }}>\n by {prettyName?.collection}\n </Text>\n )}\n </Flex>\n );\n}\n","import { Icon } from '@iconify/react';\nimport type { IconifyIconName } from '@iconify/utils';\nimport { stringToIcon } from '@iconify/utils';\nimport type { PreviewProps } from 'sanity';\nimport { QueryClientProvider } from './lib/query-client';\nimport { usePrettyIconName } from './lib/use-pretty-icon-name';\n\n// --------------- //\n// ICONIFY PREVIEW //\n// --------------- //\n\nexport function IconifyPreview(props: PreviewProps) {\n const { title } = props;\n const iconName = typeof props.title === 'string' ? stringToIcon(props.title) : null;\n\n // We check this double to avoid the TS error\n if (typeof title === 'string' && iconName) {\n return (\n <QueryClientProvider>\n <IconifyPreviewInner {...props} iconName={title} iconMeta={iconName} />\n </QueryClientProvider>\n );\n }\n\n return props.renderDefault(props);\n}\n\n// --------------------- //\n// ICONIFY PREVIEW INNER //\n// --------------------- //\n\ninterface IconifyPreviewInnerProps extends PreviewProps {\n iconName: string;\n iconMeta: IconifyIconName;\n}\n\nfunction IconifyPreviewInner(props: IconifyPreviewInnerProps) {\n const { iconMeta, iconName, ...previewProps } = props;\n const prettyName = usePrettyIconName({ iconMeta });\n\n return props.renderDefault({\n ...previewProps,\n media: <Icon icon={iconName} />,\n title: prettyName?.name ?? iconName,\n subtitle: prettyName?.collection,\n });\n}\n","import type { FieldProps, ObjectInputProps } from 'sanity';\nimport { definePlugin } from 'sanity';\nimport { IconifyInput } from './iconify-input';\nimport { IconifyPreview } from './iconify-preview';\nimport type { IconifyPluginConfig } from './lib/types';\n\n/**\n * Usage in `sanity.config.ts` (or .js)\n *\n * ```ts\n * import { defineConfig } from 'sanity'\n * import { iconify } from 'sanity-plugin-iconify'\n *\n * export default defineConfig({\n * // ...\n * plugins: [iconify()],\n * })\n * ```\n */\nexport const iconify = definePlugin<IconifyPluginConfig | void>((config = {}) => {\n return {\n name: 'sanity-plugin-iconify',\n schema: {\n types: [\n {\n name: 'icon',\n title: 'Icon',\n type: 'object',\n fields: [\n {\n name: 'name',\n title: 'Name',\n type: 'string',\n },\n ],\n components: {\n input: (props: ObjectInputProps) => <IconifyInput {...props} config={config!} />,\n preview: IconifyPreview,\n\n // This makes sure the input component is not indented\n field: (props: FieldProps) => props.renderDefault({ ...props, level: 0 }),\n },\n },\n ],\n },\n };\n});\n"],"names":["queryClient","useQueryClient","useState","useDebounce","useCallback","useQuery","keepPreviousData","styled","Grid","Box","jsx","Card","Text","forwardRef","ComboboxInput","TextInput","Icon","ComboboxOptions","ComboboxOption","Button","TrashIcon","useId","useToast","useRef","useEffect","Combobox","jsxs","Fragment","Popover","match","QueryClient","ReactQueryClientProvider","useMemo","_a","stringToIcon","_b","sentenceCase","unset","set","ThemeProvider","buildTheme","Stack","Flex","definePlugin"],"mappings":";;;;;;;AAMA,MAAM,eAAe;AAErB,SAAS,UAAa,EAAE,KAAK,UAAmE;AACvF,SAAA,MAAM,KAAK,EAAE,OAAQ,CAAA,EACzB,KAAK,CAAC,aAAa;AAClB,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,yBAAyB,SAAS,MAAM,EAAE;AAG5D,WAAO,SAAS;EACjB,CAAA,EACA;AAAA,IACC,CAAC,WAAW;AAAA,IACZ,CAAC,UAAU;AACL,YAAA,iBAAiB,QACb,SAEN,QAAQ,MAAM,kBAAkB,KAAK,EAAE,GACjC,IAAI,MAAM,sBAAsB;AAAA,IAE1C;AAAA,EAAA;AAEN;AAEgB,SAAA,UAAU,EAAE,eAAiD;AAC3E,QAAMA,eAAcC,WAAAA,kBACd,CAAC,MAAM,OAAO,IAAIC,MAAAA,SAAS,EAAE,GAC7B,CAAC,eAAe,gBAAgB,IAAIC,wBAAY,MAAM,GAAG,GAEzD,aAAaC,MAAA;AAAA,IACjB,CAAC,SAAiB,oBAAoB,OAAU;AAC9C,cAAQ,OAAO,GAEX,qBACF,iBAAiB,OAAO;AAAA,IAE5B;AAAA,IACA,CAAC,gBAAgB;AAAA,EAAA,GAGb,EAAE,WAAW,SAAS,OAAO,MAAM,sBAAsBC,oBAA0B;AAAA,IACvF,UAAU,CAAC,UAAU,aAAa,aAAa;AAAA,IAC/C,SAAS,OAAO,EAAE,aAAa;AAhDnC,UAAA;AAiDM,YA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xB,2BAAAA,IAAA,qBAAA,EACC,yCAAC,qBAAqB,EAAA,GAAG,OAAO,UAAU,OAAO,UAAU,SAAA,CAAU,EACvE,CAAA,IAIG,MAAM,cAAc,KAAK;AAClC;AAWA,SAAS,oBAAoB,OAAiC;AApC9D,MAAA;AAqCQ,QAAA,EAAE,UAAU,UAAU,GAAG,aAAiB,IAAA,OAC1C,aAAa,kBAAkB,EAAE,SAAA,CAAU;AAEjD,SAAO,MAAM,cAAc;AAAA,IACzB,GAAG;AAAA,IACH,OAAOA,2BAAAA,IAACM,QAAAA,MAAK,EAAA,MAAM,SAAU,CAAA;AAAA,IAC7B,QAAO,KAAY,cAAA,OAAA,SAAA,WAAA,SAAZ,OAAoB,KAAA;AAAA,IAC3B,UAAU,cAAY,OAAA,SAAA,WAAA;AAAA,EAAA,CACvB;AACH;AC3BO,MAAM,UAAU2B,OAAA,aAAyC,CAAC,SAAS,QACjE;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN;AAAA,YACE,MAAM;AAAA,YACN,OAAO;AAAA,YACP,MAAM;AAAA,UACR;AAAA,QACF;AAAA,QACA,YAAY;AAAA,UACV,OAAO,CAAC,yCAA6B,cAAc,EAAA,GAAG,OAAO,QAAiB;AAAA,UAC9E,SAAS;AAAA;AAAA,UAGT,OAAO,CAAC,UAAsB,MAAM,cAAc,EAAE,GAAG,OAAO,OAAO,GAAG;AAAA,QAC1E;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,EACD;;"}
@@ -0,0 +1,222 @@
1
+ import { BaseSchemaDefinition } from 'sanity';
2
+ import type { IconifyInfo } from '@iconify/types';
3
+ import { Plugin as Plugin_2 } from 'sanity';
4
+
5
+ export { BaseSchemaDefinition };
6
+
7
+ /**
8
+ * Usage in `sanity.config.ts` (or .js)
9
+ *
10
+ * ```ts
11
+ * import { defineConfig } from 'sanity'
12
+ * import { iconify } from 'sanity-plugin-iconify'
13
+ *
14
+ * export default defineConfig({
15
+ * // ...
16
+ * plugins: [iconify()],
17
+ * })
18
+ * ```
19
+ */
20
+ export declare const iconify: Plugin_2<void | IconifyPluginConfig>;
21
+
22
+ export declare interface IconifyPluginConfig {
23
+ collections?: IconPrefix[];
24
+ showName?: boolean;
25
+ }
26
+
27
+ export declare interface IconifySearchResult {
28
+ icons: string[];
29
+ collections: Record<string, IconifyInfo>;
30
+ }
31
+
32
+ export declare interface IconOptions {
33
+ collections?: IconPrefix[];
34
+ showName?: boolean;
35
+ }
36
+
37
+ export declare type IconPrefix =
38
+ | 'material-symbols'
39
+ | 'material-symbols-light'
40
+ | 'ic'
41
+ | 'mdi'
42
+ | 'ph'
43
+ | 'solar'
44
+ | 'tabler'
45
+ | 'hugeicons'
46
+ | 'mingcute'
47
+ | 'ri'
48
+ | 'bi'
49
+ | 'carbon'
50
+ | 'iconamoon'
51
+ | 'iconoir'
52
+ | 'ion'
53
+ | 'lucide'
54
+ | 'uil'
55
+ | 'tdesign'
56
+ | 'teenyicons'
57
+ | 'clarity'
58
+ | 'bx'
59
+ | 'bxs'
60
+ | 'majesticons'
61
+ | 'ant-design'
62
+ | 'gg'
63
+ | 'gravity-ui'
64
+ | 'octicon'
65
+ | 'memory'
66
+ | 'cil'
67
+ | 'flowbite'
68
+ | 'mynaui'
69
+ | 'basil'
70
+ | 'pixelarticons'
71
+ | 'akar-icons'
72
+ | 'ci'
73
+ | 'system-uicons'
74
+ | 'typcn'
75
+ | 'radix-icons'
76
+ | 'zondicons'
77
+ | 'ep'
78
+ | 'circum'
79
+ | 'mdi-light'
80
+ | 'fe'
81
+ | 'eos-icons'
82
+ | 'bitcoin-icons'
83
+ | 'charm'
84
+ | 'prime'
85
+ | 'humbleicons'
86
+ | 'uiw'
87
+ | 'uim'
88
+ | 'uit'
89
+ | 'uis'
90
+ | 'maki'
91
+ | 'gridicons'
92
+ | 'mi'
93
+ | 'quill'
94
+ | 'gala'
95
+ | 'lets-icons'
96
+ | 'f7'
97
+ | 'mage'
98
+ | 'marketeq'
99
+ | 'fluent'
100
+ | 'icon-park-outline'
101
+ | 'icon-park-solid'
102
+ | 'icon-park-twotone'
103
+ | 'icon-park'
104
+ | 'vscode-icons'
105
+ | 'jam'
106
+ | 'heroicons'
107
+ | 'codicon'
108
+ | 'pajamas'
109
+ | 'pepicons-pop'
110
+ | 'pepicons-print'
111
+ | 'pepicons-pencil'
112
+ | 'bytesize'
113
+ | 'ei'
114
+ | 'streamline'
115
+ | 'guidance'
116
+ | 'fa6-solid'
117
+ | 'fa6-regular'
118
+ | 'ooui'
119
+ | 'nimbus'
120
+ | 'oui'
121
+ | 'formkit'
122
+ | 'line-md'
123
+ | 'meteocons'
124
+ | 'svg-spinners'
125
+ | 'openmoji'
126
+ | 'twemoji'
127
+ | 'noto'
128
+ | 'fluent-emoji'
129
+ | 'fluent-emoji-flat'
130
+ | 'fluent-emoji-high-contrast'
131
+ | 'noto-v1'
132
+ | 'emojione'
133
+ | 'emojione-monotone'
134
+ | 'emojione-v1'
135
+ | 'fxemoji'
136
+ | 'streamline-emojis'
137
+ | 'bxl'
138
+ | 'logos'
139
+ | 'simple-icons'
140
+ | 'cib'
141
+ | 'fa6-brands'
142
+ | 'nonicons'
143
+ | 'arcticons'
144
+ | 'cbi'
145
+ | 'file-icons'
146
+ | 'devicon'
147
+ | 'devicon-plain'
148
+ | 'skill-icons'
149
+ | 'unjs'
150
+ | 'brandico'
151
+ | 'entypo-social'
152
+ | 'token'
153
+ | 'token-branded'
154
+ | 'cryptocurrency'
155
+ | 'cryptocurrency-color'
156
+ | 'flag'
157
+ | 'circle-flags'
158
+ | 'flagpack'
159
+ | 'cif'
160
+ | 'gis'
161
+ | 'map'
162
+ | 'geo'
163
+ | 'game-icons'
164
+ | 'fad'
165
+ | 'academicons'
166
+ | 'wi'
167
+ | 'healthicons'
168
+ | 'medical-icon'
169
+ | 'covid'
170
+ | 'la'
171
+ | 'eva'
172
+ | 'dashicons'
173
+ | 'flat-color-icons'
174
+ | 'entypo'
175
+ | 'foundation'
176
+ | 'raphael'
177
+ | 'icons8'
178
+ | 'iwwa'
179
+ | 'heroicons-outline'
180
+ | 'heroicons-solid'
181
+ | 'fa-solid'
182
+ | 'fa-regular'
183
+ | 'fa-brands'
184
+ | 'fa'
185
+ | 'fluent-mdl2'
186
+ | 'fontisto'
187
+ | 'icomoon-free'
188
+ | 'subway'
189
+ | 'oi'
190
+ | 'wpf'
191
+ | 'simple-line-icons'
192
+ | 'et'
193
+ | 'el'
194
+ | 'vaadin'
195
+ | 'grommet-icons'
196
+ | 'whh'
197
+ | 'si-glyph'
198
+ | 'zmdi'
199
+ | 'ls'
200
+ | 'bpmn'
201
+ | 'flat-ui'
202
+ | 'vs'
203
+ | 'topcoat'
204
+ | 'il'
205
+ | 'websymbol'
206
+ | 'fontelico'
207
+ | 'ps'
208
+ | 'feather'
209
+ | 'mono-icons'
210
+ | 'pepicons';
211
+
212
+ export {};
213
+
214
+ declare module 'sanity' {
215
+ interface IconDefinition extends BaseSchemaDefinition {
216
+ type: 'icon';
217
+ options?: IconOptions;
218
+ }
219
+ interface IntrinsicDefinitions {
220
+ icon: IconDefinition;
221
+ }
222
+ }