sanity-plugin-iconify 1.1.2 → 2.0.1
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 +14 -6
- package/dist/index.cjs +106 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -8
- package/dist/index.d.ts +72 -8
- package/dist/index.js +106 -99
- package/dist/index.js.map +1 -1
- package/package.json +48 -54
- package/src/combobox/iconify-combobox.styles.tsx +9 -9
- package/src/combobox/iconify-combobox.tsx +64 -55
- package/src/combobox/search-input.tsx +7 -14
- package/src/combobox/search-result.tsx +36 -36
- package/src/combobox/unset-button.tsx +1 -1
- package/src/iconify-input.tsx +8 -17
- package/src/iconify-plugin.tsx +3 -3
- package/src/iconify-preview.tsx +3 -3
- package/src/lib/api.ts +2 -3
- package/src/lib/generate-types.js +0 -1
- package/src/lib/icon-types.gen.ts +1 -0
- package/src/lib/query-client.tsx +1 -1
- package/src/lib/types.ts +1 -1
- package/src/lib/use-pretty-icon-name.ts +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseSchemaDefinition } from 'sanity';
|
|
2
|
-
import { IconifyInfo } from '@iconify/types';
|
|
3
2
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
4
3
|
|
|
5
4
|
export { BaseSchemaDefinition };
|
|
@@ -19,6 +18,63 @@ export { BaseSchemaDefinition };
|
|
|
19
18
|
*/
|
|
20
19
|
export declare const iconify: Plugin_2<void | IconifyPluginConfig>;
|
|
21
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Icon set information block.
|
|
23
|
+
*/
|
|
24
|
+
declare interface IconifyInfo {
|
|
25
|
+
// Icon set name.
|
|
26
|
+
name: string;
|
|
27
|
+
|
|
28
|
+
// Total number of icons.
|
|
29
|
+
total?: number;
|
|
30
|
+
|
|
31
|
+
// Version string.
|
|
32
|
+
version?: string;
|
|
33
|
+
|
|
34
|
+
// Author information.
|
|
35
|
+
author: {
|
|
36
|
+
// Author name.
|
|
37
|
+
name: string;
|
|
38
|
+
|
|
39
|
+
// Link to author's website or icon set website.
|
|
40
|
+
url?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// License
|
|
44
|
+
license: {
|
|
45
|
+
// Human readable license.
|
|
46
|
+
title: string;
|
|
47
|
+
|
|
48
|
+
// SPDX license identifier.
|
|
49
|
+
spdx?: string;
|
|
50
|
+
|
|
51
|
+
// License URL.
|
|
52
|
+
url?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Array of icons that should be used for samples in icon sets list.
|
|
56
|
+
samples?: string[];
|
|
57
|
+
|
|
58
|
+
// Icon grid: number or array of numbers.
|
|
59
|
+
height?: number | number[];
|
|
60
|
+
|
|
61
|
+
// Display height for samples: 16 - 24
|
|
62
|
+
displayHeight?: number;
|
|
63
|
+
|
|
64
|
+
// Category on Iconify collections list.
|
|
65
|
+
category?: string;
|
|
66
|
+
|
|
67
|
+
// List of tags to group similar icon sets.
|
|
68
|
+
tags?: string[];
|
|
69
|
+
|
|
70
|
+
// Palette status. True if icons have predefined color scheme, false if icons use currentColor.
|
|
71
|
+
// Ideally, icon set should not mix icons with and without palette to simplify search.
|
|
72
|
+
palette?: boolean;
|
|
73
|
+
|
|
74
|
+
// If true, icon set should not appear in icon sets list.
|
|
75
|
+
hidden?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
22
78
|
export declare interface IconifyPluginConfig {
|
|
23
79
|
collections?: IconPrefix[];
|
|
24
80
|
showName?: boolean;
|
|
@@ -42,6 +98,7 @@ export declare type IconPrefix =
|
|
|
42
98
|
| 'ph'
|
|
43
99
|
| 'solar'
|
|
44
100
|
| 'tabler'
|
|
101
|
+
| 'hugeicons'
|
|
45
102
|
| 'mingcute'
|
|
46
103
|
| 'ri'
|
|
47
104
|
| 'bi'
|
|
@@ -50,6 +107,7 @@ export declare type IconPrefix =
|
|
|
50
107
|
| 'iconoir'
|
|
51
108
|
| 'ion'
|
|
52
109
|
| 'lucide'
|
|
110
|
+
| 'lucide-lab'
|
|
53
111
|
| 'uil'
|
|
54
112
|
| 'tdesign'
|
|
55
113
|
| 'teenyicons'
|
|
@@ -89,20 +147,20 @@ export declare type IconPrefix =
|
|
|
89
147
|
| 'maki'
|
|
90
148
|
| 'gridicons'
|
|
91
149
|
| 'mi'
|
|
150
|
+
| 'weui'
|
|
92
151
|
| 'quill'
|
|
93
152
|
| 'gala'
|
|
94
153
|
| 'lets-icons'
|
|
95
154
|
| 'f7'
|
|
96
155
|
| 'mage'
|
|
156
|
+
| 'marketeq'
|
|
97
157
|
| 'fluent'
|
|
98
158
|
| 'icon-park-outline'
|
|
99
159
|
| 'icon-park-solid'
|
|
100
160
|
| 'icon-park-twotone'
|
|
101
161
|
| 'icon-park'
|
|
102
|
-
| 'vscode-icons'
|
|
103
162
|
| 'jam'
|
|
104
163
|
| 'heroicons'
|
|
105
|
-
| 'codicon'
|
|
106
164
|
| 'pajamas'
|
|
107
165
|
| 'pepicons-pop'
|
|
108
166
|
| 'pepicons-print'
|
|
@@ -114,6 +172,7 @@ export declare type IconPrefix =
|
|
|
114
172
|
| 'fa6-solid'
|
|
115
173
|
| 'fa6-regular'
|
|
116
174
|
| 'ooui'
|
|
175
|
+
| 'rivet-icons'
|
|
117
176
|
| 'nimbus'
|
|
118
177
|
| 'oui'
|
|
119
178
|
| 'formkit'
|
|
@@ -140,13 +199,10 @@ export declare type IconPrefix =
|
|
|
140
199
|
| 'nonicons'
|
|
141
200
|
| 'arcticons'
|
|
142
201
|
| 'cbi'
|
|
143
|
-
| 'file-icons'
|
|
144
|
-
| 'devicon'
|
|
145
|
-
| 'devicon-plain'
|
|
146
|
-
| 'skill-icons'
|
|
147
|
-
| 'unjs'
|
|
148
202
|
| 'brandico'
|
|
149
203
|
| 'entypo-social'
|
|
204
|
+
| 'token'
|
|
205
|
+
| 'token-branded'
|
|
150
206
|
| 'cryptocurrency'
|
|
151
207
|
| 'cryptocurrency-color'
|
|
152
208
|
| 'flag'
|
|
@@ -156,6 +212,14 @@ export declare type IconPrefix =
|
|
|
156
212
|
| 'gis'
|
|
157
213
|
| 'map'
|
|
158
214
|
| 'geo'
|
|
215
|
+
| 'vscode-icons'
|
|
216
|
+
| 'codicon'
|
|
217
|
+
| 'file-icons'
|
|
218
|
+
| 'devicon'
|
|
219
|
+
| 'devicon-plain'
|
|
220
|
+
| 'catppuccin'
|
|
221
|
+
| 'skill-icons'
|
|
222
|
+
| 'unjs'
|
|
159
223
|
| 'game-icons'
|
|
160
224
|
| 'fad'
|
|
161
225
|
| 'academicons'
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseSchemaDefinition } from 'sanity';
|
|
2
|
-
import { IconifyInfo } from '@iconify/types';
|
|
3
2
|
import { Plugin as Plugin_2 } from 'sanity';
|
|
4
3
|
|
|
5
4
|
export { BaseSchemaDefinition };
|
|
@@ -19,6 +18,63 @@ export { BaseSchemaDefinition };
|
|
|
19
18
|
*/
|
|
20
19
|
export declare const iconify: Plugin_2<void | IconifyPluginConfig>;
|
|
21
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Icon set information block.
|
|
23
|
+
*/
|
|
24
|
+
declare interface IconifyInfo {
|
|
25
|
+
// Icon set name.
|
|
26
|
+
name: string;
|
|
27
|
+
|
|
28
|
+
// Total number of icons.
|
|
29
|
+
total?: number;
|
|
30
|
+
|
|
31
|
+
// Version string.
|
|
32
|
+
version?: string;
|
|
33
|
+
|
|
34
|
+
// Author information.
|
|
35
|
+
author: {
|
|
36
|
+
// Author name.
|
|
37
|
+
name: string;
|
|
38
|
+
|
|
39
|
+
// Link to author's website or icon set website.
|
|
40
|
+
url?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// License
|
|
44
|
+
license: {
|
|
45
|
+
// Human readable license.
|
|
46
|
+
title: string;
|
|
47
|
+
|
|
48
|
+
// SPDX license identifier.
|
|
49
|
+
spdx?: string;
|
|
50
|
+
|
|
51
|
+
// License URL.
|
|
52
|
+
url?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Array of icons that should be used for samples in icon sets list.
|
|
56
|
+
samples?: string[];
|
|
57
|
+
|
|
58
|
+
// Icon grid: number or array of numbers.
|
|
59
|
+
height?: number | number[];
|
|
60
|
+
|
|
61
|
+
// Display height for samples: 16 - 24
|
|
62
|
+
displayHeight?: number;
|
|
63
|
+
|
|
64
|
+
// Category on Iconify collections list.
|
|
65
|
+
category?: string;
|
|
66
|
+
|
|
67
|
+
// List of tags to group similar icon sets.
|
|
68
|
+
tags?: string[];
|
|
69
|
+
|
|
70
|
+
// Palette status. True if icons have predefined color scheme, false if icons use currentColor.
|
|
71
|
+
// Ideally, icon set should not mix icons with and without palette to simplify search.
|
|
72
|
+
palette?: boolean;
|
|
73
|
+
|
|
74
|
+
// If true, icon set should not appear in icon sets list.
|
|
75
|
+
hidden?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
22
78
|
export declare interface IconifyPluginConfig {
|
|
23
79
|
collections?: IconPrefix[];
|
|
24
80
|
showName?: boolean;
|
|
@@ -42,6 +98,7 @@ export declare type IconPrefix =
|
|
|
42
98
|
| 'ph'
|
|
43
99
|
| 'solar'
|
|
44
100
|
| 'tabler'
|
|
101
|
+
| 'hugeicons'
|
|
45
102
|
| 'mingcute'
|
|
46
103
|
| 'ri'
|
|
47
104
|
| 'bi'
|
|
@@ -50,6 +107,7 @@ export declare type IconPrefix =
|
|
|
50
107
|
| 'iconoir'
|
|
51
108
|
| 'ion'
|
|
52
109
|
| 'lucide'
|
|
110
|
+
| 'lucide-lab'
|
|
53
111
|
| 'uil'
|
|
54
112
|
| 'tdesign'
|
|
55
113
|
| 'teenyicons'
|
|
@@ -89,20 +147,20 @@ export declare type IconPrefix =
|
|
|
89
147
|
| 'maki'
|
|
90
148
|
| 'gridicons'
|
|
91
149
|
| 'mi'
|
|
150
|
+
| 'weui'
|
|
92
151
|
| 'quill'
|
|
93
152
|
| 'gala'
|
|
94
153
|
| 'lets-icons'
|
|
95
154
|
| 'f7'
|
|
96
155
|
| 'mage'
|
|
156
|
+
| 'marketeq'
|
|
97
157
|
| 'fluent'
|
|
98
158
|
| 'icon-park-outline'
|
|
99
159
|
| 'icon-park-solid'
|
|
100
160
|
| 'icon-park-twotone'
|
|
101
161
|
| 'icon-park'
|
|
102
|
-
| 'vscode-icons'
|
|
103
162
|
| 'jam'
|
|
104
163
|
| 'heroicons'
|
|
105
|
-
| 'codicon'
|
|
106
164
|
| 'pajamas'
|
|
107
165
|
| 'pepicons-pop'
|
|
108
166
|
| 'pepicons-print'
|
|
@@ -114,6 +172,7 @@ export declare type IconPrefix =
|
|
|
114
172
|
| 'fa6-solid'
|
|
115
173
|
| 'fa6-regular'
|
|
116
174
|
| 'ooui'
|
|
175
|
+
| 'rivet-icons'
|
|
117
176
|
| 'nimbus'
|
|
118
177
|
| 'oui'
|
|
119
178
|
| 'formkit'
|
|
@@ -140,13 +199,10 @@ export declare type IconPrefix =
|
|
|
140
199
|
| 'nonicons'
|
|
141
200
|
| 'arcticons'
|
|
142
201
|
| 'cbi'
|
|
143
|
-
| 'file-icons'
|
|
144
|
-
| 'devicon'
|
|
145
|
-
| 'devicon-plain'
|
|
146
|
-
| 'skill-icons'
|
|
147
|
-
| 'unjs'
|
|
148
202
|
| 'brandico'
|
|
149
203
|
| 'entypo-social'
|
|
204
|
+
| 'token'
|
|
205
|
+
| 'token-branded'
|
|
150
206
|
| 'cryptocurrency'
|
|
151
207
|
| 'cryptocurrency-color'
|
|
152
208
|
| 'flag'
|
|
@@ -156,6 +212,14 @@ export declare type IconPrefix =
|
|
|
156
212
|
| 'gis'
|
|
157
213
|
| 'map'
|
|
158
214
|
| 'geo'
|
|
215
|
+
| 'vscode-icons'
|
|
216
|
+
| 'codicon'
|
|
217
|
+
| 'file-icons'
|
|
218
|
+
| 'devicon'
|
|
219
|
+
| 'devicon-plain'
|
|
220
|
+
| 'catppuccin'
|
|
221
|
+
| 'skill-icons'
|
|
222
|
+
| 'unjs'
|
|
159
223
|
| 'game-icons'
|
|
160
224
|
| 'fad'
|
|
161
225
|
| 'academicons'
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { unset, set, definePlugin } from "sanity";
|
|
3
|
-
import { Grid, Box, Card, Text, TextInput, Button, useToast, Popover,
|
|
3
|
+
import { Grid, Box, Card, Text, TextInput, Button, useToast, Popover, ThemeProvider, Stack, Flex } from "@sanity/ui";
|
|
4
|
+
import { buildTheme } from "@sanity/ui/theme";
|
|
4
5
|
import { useState, useCallback, forwardRef, useId, useRef, useEffect, useMemo } from "react";
|
|
5
|
-
import {
|
|
6
|
+
import { useCombobox } from "downshift";
|
|
6
7
|
import { match } from "ts-pattern";
|
|
7
8
|
import { useQueryClient, useQuery, keepPreviousData, QueryClient, QueryClientProvider as QueryClientProvider$1 } from "@tanstack/react-query";
|
|
8
9
|
import { useDebounce } from "use-debounce";
|
|
@@ -33,13 +34,12 @@ function useSearch({ collections }) {
|
|
|
33
34
|
), { isLoading, isError, error, data, isPlaceholderData } = useQuery({
|
|
34
35
|
queryKey: ["search", collections, debouncedTerm],
|
|
35
36
|
queryFn: async ({ signal }) => {
|
|
36
|
-
var _a;
|
|
37
37
|
const url = new URL("/search", BASE_API_URL);
|
|
38
38
|
url.searchParams.append("query", debouncedTerm), url.searchParams.append("limit", "60"), collections && url.searchParams.append("prefixes", collections.join(","));
|
|
39
39
|
const result = debouncedTerm ? await fetchJson({ url, signal }) : null;
|
|
40
40
|
return result && Object.entries(result.collections).forEach(([prefix, info]) => {
|
|
41
41
|
queryClient2.setQueryData(["iconSetInfo", prefix], info);
|
|
42
|
-
}),
|
|
42
|
+
}), result?.icons ?? [];
|
|
43
43
|
},
|
|
44
44
|
enabled: debouncedTerm.length > 0,
|
|
45
45
|
placeholderData: keepPreviousData,
|
|
@@ -61,49 +61,46 @@ function useIconSetInfo({ prefix }) {
|
|
|
61
61
|
return useQuery({
|
|
62
62
|
queryKey: ["iconSetInfo", prefix],
|
|
63
63
|
queryFn: async ({ signal }) => {
|
|
64
|
-
|
|
65
|
-
if (!prefix)
|
|
66
|
-
return null;
|
|
64
|
+
if (!prefix) return null;
|
|
67
65
|
const url = new URL("/collection", BASE_API_URL);
|
|
68
|
-
url.searchParams.append("prefix", prefix), url.searchParams.append("info", "true");
|
|
69
|
-
const result = await fetchJson({ url, signal });
|
|
70
|
-
return (_a = result == null ? void 0 : result.info) != null ? _a : null;
|
|
66
|
+
return url.searchParams.append("prefix", prefix), url.searchParams.append("info", "true"), (await fetchJson({ url, signal }))?.info ?? null;
|
|
71
67
|
},
|
|
72
68
|
staleTime: 1 / 0
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
|
-
|
|
71
|
+
styled(Grid)`
|
|
76
72
|
grid-template-columns: 1fr min-content;
|
|
77
73
|
position: relative;
|
|
78
|
-
|
|
74
|
+
`;
|
|
75
|
+
const OptionsWrapper = styled(Box)`
|
|
79
76
|
box-sizing: border-box;
|
|
80
77
|
padding: 0.5rem;
|
|
81
78
|
|
|
82
79
|
& [role='listbox'] {
|
|
83
|
-
display:
|
|
84
|
-
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-wrap: wrap;
|
|
85
82
|
gap: 0.5rem;
|
|
86
|
-
list-style: none;
|
|
87
83
|
margin: 0;
|
|
88
84
|
padding: 0;
|
|
89
|
-
|
|
90
|
-
@media (min-width: 650px) {
|
|
91
|
-
grid-template-columns: repeat(10, minmax(min(100%, 2.5rem), 1fr));
|
|
92
|
-
}
|
|
85
|
+
list-style: none;
|
|
93
86
|
}
|
|
94
87
|
|
|
95
88
|
& [role='option'] {
|
|
96
89
|
display: grid;
|
|
97
90
|
place-items: center;
|
|
91
|
+
width: clamp(3rem, 10vw, 4rem);
|
|
98
92
|
|
|
99
93
|
& button {
|
|
100
|
-
aspect-ratio: 1;
|
|
101
94
|
cursor: pointer;
|
|
102
95
|
width: 100%;
|
|
103
96
|
|
|
104
97
|
& > [data-ui='Box'] {
|
|
105
98
|
display: flex;
|
|
106
99
|
}
|
|
100
|
+
|
|
101
|
+
& svg {
|
|
102
|
+
aspect-ratio: 1;
|
|
103
|
+
}
|
|
107
104
|
}
|
|
108
105
|
}
|
|
109
106
|
`;
|
|
@@ -111,80 +108,103 @@ function MessageWrapper({ children }) {
|
|
|
111
108
|
return /* @__PURE__ */ jsx(Card, { padding: 4, children: /* @__PURE__ */ jsx(Text, { align: "center", muted: !0, children }) });
|
|
112
109
|
}
|
|
113
110
|
const SearchInput = forwardRef((props, ref) => {
|
|
114
|
-
const {
|
|
111
|
+
const { selectedIcon, suffix, ...rest } = props;
|
|
115
112
|
return /* @__PURE__ */ jsx(
|
|
116
|
-
|
|
113
|
+
TextInput,
|
|
117
114
|
{
|
|
118
|
-
|
|
115
|
+
...rest,
|
|
119
116
|
ref,
|
|
120
117
|
inputMode: "search",
|
|
121
|
-
value: term,
|
|
122
|
-
onChange,
|
|
123
118
|
icon: selectedIcon ? /* @__PURE__ */ jsx(Icon, { icon: selectedIcon }) : null,
|
|
124
|
-
placeholder: selectedIcon ? "Search and replace selected icon..." : "Search for an icon..."
|
|
119
|
+
placeholder: selectedIcon ? "Search and replace selected icon..." : "Search for an icon...",
|
|
120
|
+
suffix
|
|
125
121
|
}
|
|
126
122
|
);
|
|
127
123
|
});
|
|
128
124
|
SearchInput.displayName = "SearchInput";
|
|
129
|
-
|
|
130
|
-
const { state, data } = props;
|
|
131
|
-
return
|
|
132
|
-
|
|
125
|
+
const SearchResults = forwardRef((props, ref) => {
|
|
126
|
+
const { state, data, getItemProps, highlightedIndex, ...rest } = props;
|
|
127
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
128
|
+
(() => {
|
|
129
|
+
switch (state) {
|
|
130
|
+
case "initial":
|
|
131
|
+
return /* @__PURE__ */ jsx(MessageWrapper, { children: "Search for icons" });
|
|
132
|
+
case "loading":
|
|
133
|
+
return /* @__PURE__ */ jsx(MessageWrapper, { children: "Searching..." });
|
|
134
|
+
case "error":
|
|
135
|
+
return /* @__PURE__ */ jsx(MessageWrapper, { children: "Something went wrong..." });
|
|
136
|
+
case "empty":
|
|
137
|
+
return /* @__PURE__ */ jsx(MessageWrapper, { children: "No icons found" });
|
|
138
|
+
}
|
|
139
|
+
})(),
|
|
140
|
+
/* @__PURE__ */ jsx("ul", { ...rest, ref, style: { opacity: state === "stale" ? 0.5 : 1 }, children: (state === "data" || state === "stale") && data?.map((icon, index) => /* @__PURE__ */ jsx("li", { ...getItemProps({ item: icon, index }), children: /* @__PURE__ */ jsx(Button, { padding: 3, mode: "bleed", selected: index === highlightedIndex, children: /* @__PURE__ */ jsx(Icon, { icon, width: "100%", height: "100%" }) }) }, icon)) })
|
|
141
|
+
] });
|
|
142
|
+
});
|
|
133
143
|
function UnsetButton(props) {
|
|
134
144
|
const { onUnset } = props;
|
|
135
|
-
return /* @__PURE__ */ jsx(Card, { border: !0, borderLeft: !1, padding: 1, display: "flex", children: /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(TrashIcon, {}), onClick: onUnset, mode: "bleed", fontSize: 1, padding: 2 }) });
|
|
145
|
+
return /* @__PURE__ */ jsx(Card, { border: !0, borderLeft: !1, padding: 1, display: "flex", radius: 2, children: /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(TrashIcon, {}), onClick: onUnset, mode: "bleed", fontSize: 1, padding: 2 }) });
|
|
136
146
|
}
|
|
137
147
|
function IconifyCombobox(props) {
|
|
138
148
|
const { selectedIcon, onSelect: pushSelection, collections } = props, id = useId(), toast = useToast(), inputRef = useRef(null), { term, setTerm, debouncedTerm, isLoading, isError, error, data, isPreviousData } = useSearch({
|
|
139
149
|
collections
|
|
140
|
-
}),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
}), {
|
|
151
|
+
isOpen,
|
|
152
|
+
getMenuProps,
|
|
153
|
+
getInputProps,
|
|
154
|
+
highlightedIndex,
|
|
155
|
+
getItemProps,
|
|
156
|
+
selectItem,
|
|
157
|
+
setInputValue
|
|
158
|
+
} = useCombobox({
|
|
159
|
+
items: data ?? [],
|
|
160
|
+
inputValue: term,
|
|
161
|
+
onInputValueChange({ inputValue, selectedItem }) {
|
|
162
|
+
inputValue !== selectedItem && setTerm(inputValue);
|
|
146
163
|
},
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
onSelectedItemChange({ selectedItem }) {
|
|
165
|
+
pushSelection(selectedItem), setTerm("", !0), setInputValue("");
|
|
166
|
+
}
|
|
167
|
+
}), handleUnset = useCallback(() => {
|
|
168
|
+
pushSelection(""), setTerm("", !0), selectItem("");
|
|
169
|
+
}, []);
|
|
149
170
|
return useEffect(() => {
|
|
150
171
|
isError && (console.error("Iconify input error:", error), toast.push({
|
|
151
172
|
id,
|
|
152
173
|
status: "error",
|
|
153
174
|
title: "Iconify input error",
|
|
154
|
-
description: error
|
|
175
|
+
description: error?.message
|
|
155
176
|
}));
|
|
156
|
-
}, [error, id, isError, toast]), /* @__PURE__ */ jsxs(
|
|
157
|
-
/* @__PURE__ */ jsx(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
selectedIcon ? /* @__PURE__ */ jsx(UnsetButton, { onUnset: handleUnset }) : null
|
|
177
|
+
}, [error, id, isError, toast]), /* @__PURE__ */ jsxs("div", { children: [
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
SearchInput,
|
|
180
|
+
{
|
|
181
|
+
...getInputProps({ ref: inputRef }),
|
|
182
|
+
selectedIcon,
|
|
183
|
+
suffix: selectedIcon ? /* @__PURE__ */ jsx(UnsetButton, { onUnset: handleUnset }) : null
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ jsx(
|
|
187
|
+
Popover,
|
|
188
|
+
{
|
|
189
|
+
open: !0,
|
|
190
|
+
style: { display: isOpen ? "block" : "none" },
|
|
191
|
+
placement: "bottom",
|
|
192
|
+
arrow: !1,
|
|
193
|
+
matchReferenceWidth: !0,
|
|
194
|
+
constrainSize: !0,
|
|
195
|
+
referenceElement: inputRef.current,
|
|
196
|
+
content: /* @__PURE__ */ jsx(OptionsWrapper, { children: /* @__PURE__ */ jsx(
|
|
197
|
+
SearchResults,
|
|
198
|
+
{
|
|
199
|
+
...getMenuProps(),
|
|
200
|
+
state: match(!0).returnType().with(isLoading, () => "loading").with(!debouncedTerm, () => "initial").with(isError, () => "error").with(!data || data.length === 0, () => "empty").with(isPreviousData, () => "stale").otherwise(() => "data"),
|
|
201
|
+
data,
|
|
202
|
+
getItemProps,
|
|
203
|
+
highlightedIndex
|
|
204
|
+
}
|
|
205
|
+
) })
|
|
206
|
+
}
|
|
207
|
+
)
|
|
188
208
|
] });
|
|
189
209
|
}
|
|
190
210
|
const queryClient = new QueryClient();
|
|
@@ -192,37 +212,26 @@ function QueryClientProvider(props) {
|
|
|
192
212
|
return /* @__PURE__ */ jsx(QueryClientProvider$1, { client: queryClient, children: props.children });
|
|
193
213
|
}
|
|
194
214
|
function usePrettyIconName(props) {
|
|
195
|
-
var _a, _b;
|
|
196
215
|
const { name } = props, iconMeta = useMemo(
|
|
197
|
-
() =>
|
|
198
|
-
var _a2;
|
|
199
|
-
return (_a2 = props.iconMeta) != null ? _a2 : name ? stringToIcon(name) : null;
|
|
200
|
-
},
|
|
216
|
+
() => props.iconMeta ?? (name ? stringToIcon(name) : null),
|
|
201
217
|
[name, props.iconMeta]
|
|
202
|
-
), iconSetInfo = useIconSetInfo({ prefix:
|
|
218
|
+
), iconSetInfo = useIconSetInfo({ prefix: iconMeta?.prefix ?? null });
|
|
203
219
|
return useMemo(
|
|
204
|
-
() => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
} : null;
|
|
210
|
-
},
|
|
211
|
-
[iconMeta, (_b = iconSetInfo.data) == null ? void 0 : _b.name]
|
|
220
|
+
() => iconMeta ? {
|
|
221
|
+
name: sentenceCase(iconMeta.name),
|
|
222
|
+
collection: iconSetInfo.data?.name ?? iconMeta.prefix
|
|
223
|
+
} : null,
|
|
224
|
+
[iconMeta, iconSetInfo.data?.name]
|
|
212
225
|
);
|
|
213
226
|
}
|
|
214
227
|
function IconifyInput(props) {
|
|
215
|
-
|
|
216
|
-
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, parentTheme = useTheme(), theme = useMemo(
|
|
217
|
-
() => parentTheme ? { ...parentTheme.sanity, color: studioTheme.color } : studioTheme,
|
|
218
|
-
[parentTheme]
|
|
219
|
-
), handleSelect = useCallback(
|
|
228
|
+
const { config, value, onChange: pushChange, schemaType } = props, selectedIcon = value?.name ?? null, options = schemaType.options, collections = !!options?.collections?.length && options.collections || !!config?.collections?.length && config.collections || null, showName = options?.showName ?? config?.showName ?? !1, handleSelect = useCallback(
|
|
220
229
|
(icon) => {
|
|
221
230
|
pushChange(icon === "" ? unset() : set(icon, ["name"]));
|
|
222
231
|
},
|
|
223
232
|
[pushChange]
|
|
224
233
|
);
|
|
225
|
-
return /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
234
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(ThemeProvider, { theme: buildTheme(), children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
226
235
|
/* @__PURE__ */ jsx(
|
|
227
236
|
IconifyCombobox,
|
|
228
237
|
{
|
|
@@ -235,14 +244,13 @@ function IconifyInput(props) {
|
|
|
235
244
|
] }) }) });
|
|
236
245
|
}
|
|
237
246
|
function IconifyNameDisplay(props) {
|
|
238
|
-
var _a;
|
|
239
247
|
const { name } = props, prettyName = usePrettyIconName({ name });
|
|
240
248
|
return /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
241
249
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "Selected:" }),
|
|
242
|
-
/* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children:
|
|
243
|
-
|
|
250
|
+
/* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: prettyName?.name ?? name }),
|
|
251
|
+
prettyName?.collection && /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, style: { fontStyle: "italic" }, children: [
|
|
244
252
|
"by ",
|
|
245
|
-
prettyName
|
|
253
|
+
prettyName?.collection
|
|
246
254
|
] })
|
|
247
255
|
] });
|
|
248
256
|
}
|
|
@@ -251,13 +259,12 @@ function IconifyPreview(props) {
|
|
|
251
259
|
return typeof title == "string" && iconName ? /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(IconifyPreviewInner, { ...props, iconName: title, iconMeta: iconName }) }) : props.renderDefault(props);
|
|
252
260
|
}
|
|
253
261
|
function IconifyPreviewInner(props) {
|
|
254
|
-
var _a;
|
|
255
262
|
const { iconMeta, iconName, ...previewProps } = props, prettyName = usePrettyIconName({ iconMeta });
|
|
256
263
|
return props.renderDefault({
|
|
257
264
|
...previewProps,
|
|
258
265
|
media: /* @__PURE__ */ jsx(Icon, { icon: iconName }),
|
|
259
|
-
title:
|
|
260
|
-
subtitle: prettyName
|
|
266
|
+
title: prettyName?.name ?? iconName,
|
|
267
|
+
subtitle: prettyName?.collection
|
|
261
268
|
});
|
|
262
269
|
}
|
|
263
270
|
const iconify = definePlugin((config = {}) => ({
|