@madebywild/sanity-color-field 1.0.0 → 1.1.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/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/input.tsx +2 -2
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/input.tsx","../src/types.tsx","../src/index.tsx"],"sourcesContent":["import { AsyncAutocomplete } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport { Avatar, Box, Card, Flex, Text } from \"@sanity/ui\";\nimport { type StringInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\n/** @public */\nfunction defaultRenderSelected(value: React.
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/input.tsx","../src/types.tsx","../src/index.tsx"],"sourcesContent":["import { AsyncAutocomplete } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport { Avatar, Box, Card, Flex, Text } from \"@sanity/ui\";\nimport { type StringInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\n/** @public */\nfunction defaultRenderSelected(value: React.JSX.Element | string) {\n if (typeof value === \"string\") return <Avatar style={{ backgroundColor: value }} />;\n return value;\n}\n\n/** @public */\nfunction defaultRenderOption({ label, value }: { label?: React.JSX.Element | string; value: React.JSX.Element | string }) {\n const Color = typeof value === \"string\" ? <Avatar size={1} style={{ backgroundColor: value }} /> : value;\n const Label = typeof label === \"string\" ? <Text size={2}>{label}</Text> : (label ?? value);\n\n return (\n <Card as=\"button\">\n <Flex align=\"center\" padding={2}>\n {Color}\n <Box flex={1} padding={2}>\n {Label}\n </Box>\n </Flex>\n </Card>\n );\n}\n\nfunction ColorInput({\n pluginConfig,\n ...props\n}: StringInputProps & {\n pluginConfig: PluginConfig;\n}) {\n const options = props.schemaType.options as FieldOptions | undefined;\n const colorList = pluginConfig.colorList;\n const renderOption = pluginConfig.renderOption ?? defaultRenderOption;\n const renderSelected = pluginConfig.renderSelected ?? defaultRenderSelected;\n\n const whitelist = options?.whitelist;\n const blacklist = options?.blacklist;\n\n return (\n <AsyncAutocomplete\n placeholder=\"Select color\"\n noOptionsPlaceholder=\"No colors found\"\n listItems={colorList}\n whitelist={whitelist}\n blacklist={blacklist}\n value={props.value}\n renderValue={(value, opt) => opt?.label ?? value}\n onChange={(value) => {\n const next = value ? set(value) : unset();\n return props.onChange(next);\n }}\n renderSelected={(value) => {\n return renderSelected(value);\n }}\n renderOption={({ label, value }) => {\n return renderOption({ label, value });\n }}\n />\n );\n}\n\nexport { ColorInput, defaultRenderSelected, defaultRenderOption };\n","import type { ListItems } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport type { ObjectOptions, StringDefinition } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.color\" as const;\n\n/** @public */\nexport type PluginConfig = {\n /**\n * A list of colors to show in the color picker.\n * In addition to the value, the field will also calculate\n * and store the color's luminance in a separate field.\n * @example\n * ```ts\n * colorList: [\n * { label: \"Red\", value: \"#ff0000\" },\n * { label: \"Green\", value: \"#00ff00\" },\n * { label: \"Blue\", value: \"#0000ff\" },\n * ]\n * ```\n */\n colorList: ListItems;\n /**\n * A function to render the selected color value.\n * Note: Import `defaultRenderSelected` to use the default rendering.\n * @example\n * ```ts\n * renderSelected: (value) => <div style={{ backgroundColor: value, width: 20, height: 20 }} />\n * ```\n */\n renderSelected?: (value: string) => React.JSX.Element;\n /** A function to render each color option in the dropdown.\n * Note: Import `defaultRenderOption` to use the default rendering.\n * @example\n * ```ts\n * renderOption: (item) => <div>{item.label}</div>\n * ```\n */\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\n};\n\n/** @public */\nexport type FieldOptions = ObjectOptions & {\n /**\n * Whitelist colors by their values.\n */\n whitelist?: string[];\n /**\n * Blacklist colors by their values.\n */\n blacklist?: string[];\n};\n\n// Add the custom field definition to Sanity's intrinsic definitions\n// so that type checking works correctly when using this field type.\ndeclare module \"sanity\" {\n export interface IntrinsicDefinitions {\n [typeName]: Omit<StringDefinition, \"type\" | \"fields\" | \"options\" | \"components\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { definePlugin, defineType } from \"sanity\";\nimport { ColorInput, defaultRenderOption, defaultRenderSelected } from \"./input\";\nimport { type FieldOptions, type PluginConfig, typeName } from \"./types\";\n\n/** @public */\nconst wildSanityColorFieldPlugin = definePlugin<PluginConfig>((config) => {\n return {\n name: \"@madebywild/sanity-color-field\",\n schema: {\n types: [\n defineType({\n name: typeName,\n type: \"string\",\n title: \"Color\",\n description: \"Select a color.\",\n icon: () => <>🎨</>,\n components: {\n input: (props) => <ColorInput pluginConfig={config} {...props} />,\n },\n }),\n ],\n },\n };\n});\n\nexport { wildSanityColorFieldPlugin, typeName, defaultRenderOption, defaultRenderSelected, type PluginConfig, type FieldOptions };\n"],"names":["defaultRenderSelected","value","jsx","Avatar","backgroundColor","defaultRenderOption","label","Card","Flex","Color","Box","Label","Text","ColorInput","t0","$","_c","pluginConfig","props","options","schemaType","colorList","renderOption","renderSelected","whitelist","blacklist","t1","value_0","next","set","unset","onChange","t2","value_1","t3","t4","value_2","AsyncAutocomplete","_temp","opt","typeName","wildSanityColorFieldPlugin","definePlugin","config","name","schema","types","defineType","type","title","description","icon","Fragment","components","input"],"mappings":";;;AAMA,SAASA,sBAAsBC,OAAmC;AAChE,SAAI,OAAOA,SAAU,WAAiBC,2BAAAA,IAACC,GAAAA,UAAO,OAAO;AAAA,IAAEC,iBAAiBH;AAAAA,EAAAA,GAAQ,IACzEA;AACT;AAGA,SAASI,oBAAoB;AAAA,EAAEC;AAAAA,EAAOL;AAAiF,GAAG;AAIxH,SACEC,2BAAAA,IAACK,GAAAA,QAAK,IAAG,UACP,0CAACC,GAAAA,MAAA,EAAK,OAAM,UAAS,SAAS,GAC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AW,cAAcyC,QAAQ,GAAIzB,MAAAA,CAAM;AAAA,MAAA;AAAA,IAChE,CACD,CAAC;AAAA,EAAA;AAGR,EACD;;;;;"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as sanity0 from "sanity";
|
|
2
2
|
import { ObjectOptions, StringDefinition } from "sanity";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react2 from "react";
|
|
4
4
|
/** @public */
|
|
5
5
|
type ListItem = {
|
|
6
6
|
value: string;
|
|
@@ -68,15 +68,15 @@ declare module "sanity" {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
/** @public */
|
|
71
|
-
declare function defaultRenderSelected(value: React.
|
|
71
|
+
declare function defaultRenderSelected(value: React.JSX.Element | string): react2.JSX.Element;
|
|
72
72
|
/** @public */
|
|
73
73
|
declare function defaultRenderOption({
|
|
74
74
|
label,
|
|
75
75
|
value
|
|
76
76
|
}: {
|
|
77
|
-
label?: React.
|
|
78
|
-
value: React.
|
|
79
|
-
}):
|
|
77
|
+
label?: React.JSX.Element | string;
|
|
78
|
+
value: React.JSX.Element | string;
|
|
79
|
+
}): react2.JSX.Element;
|
|
80
80
|
/** @public */
|
|
81
81
|
declare const wildSanityColorFieldPlugin: sanity0.Plugin<PluginConfig>;
|
|
82
82
|
export { type FieldOptions, type PluginConfig, defaultRenderOption, defaultRenderSelected, typeName, wildSanityColorFieldPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as sanity0 from "sanity";
|
|
2
2
|
import { ObjectOptions, StringDefinition } from "sanity";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react2 from "react";
|
|
4
4
|
/** @public */
|
|
5
5
|
type ListItem = {
|
|
6
6
|
value: string;
|
|
@@ -68,15 +68,15 @@ declare module "sanity" {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
/** @public */
|
|
71
|
-
declare function defaultRenderSelected(value: React.
|
|
71
|
+
declare function defaultRenderSelected(value: React.JSX.Element | string): react2.JSX.Element;
|
|
72
72
|
/** @public */
|
|
73
73
|
declare function defaultRenderOption({
|
|
74
74
|
label,
|
|
75
75
|
value
|
|
76
76
|
}: {
|
|
77
|
-
label?: React.
|
|
78
|
-
value: React.
|
|
79
|
-
}):
|
|
77
|
+
label?: React.JSX.Element | string;
|
|
78
|
+
value: React.JSX.Element | string;
|
|
79
|
+
}): react2.JSX.Element;
|
|
80
80
|
/** @public */
|
|
81
81
|
declare const wildSanityColorFieldPlugin: sanity0.Plugin<PluginConfig>;
|
|
82
82
|
export { type FieldOptions, type PluginConfig, defaultRenderOption, defaultRenderSelected, typeName, wildSanityColorFieldPlugin };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/input.tsx","../src/types.tsx","../src/index.tsx"],"sourcesContent":["import { AsyncAutocomplete } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport { Avatar, Box, Card, Flex, Text } from \"@sanity/ui\";\nimport { type StringInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\n/** @public */\nfunction defaultRenderSelected(value: React.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/input.tsx","../src/types.tsx","../src/index.tsx"],"sourcesContent":["import { AsyncAutocomplete } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport { Avatar, Box, Card, Flex, Text } from \"@sanity/ui\";\nimport { type StringInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\n/** @public */\nfunction defaultRenderSelected(value: React.JSX.Element | string) {\n if (typeof value === \"string\") return <Avatar style={{ backgroundColor: value }} />;\n return value;\n}\n\n/** @public */\nfunction defaultRenderOption({ label, value }: { label?: React.JSX.Element | string; value: React.JSX.Element | string }) {\n const Color = typeof value === \"string\" ? <Avatar size={1} style={{ backgroundColor: value }} /> : value;\n const Label = typeof label === \"string\" ? <Text size={2}>{label}</Text> : (label ?? value);\n\n return (\n <Card as=\"button\">\n <Flex align=\"center\" padding={2}>\n {Color}\n <Box flex={1} padding={2}>\n {Label}\n </Box>\n </Flex>\n </Card>\n );\n}\n\nfunction ColorInput({\n pluginConfig,\n ...props\n}: StringInputProps & {\n pluginConfig: PluginConfig;\n}) {\n const options = props.schemaType.options as FieldOptions | undefined;\n const colorList = pluginConfig.colorList;\n const renderOption = pluginConfig.renderOption ?? defaultRenderOption;\n const renderSelected = pluginConfig.renderSelected ?? defaultRenderSelected;\n\n const whitelist = options?.whitelist;\n const blacklist = options?.blacklist;\n\n return (\n <AsyncAutocomplete\n placeholder=\"Select color\"\n noOptionsPlaceholder=\"No colors found\"\n listItems={colorList}\n whitelist={whitelist}\n blacklist={blacklist}\n value={props.value}\n renderValue={(value, opt) => opt?.label ?? value}\n onChange={(value) => {\n const next = value ? set(value) : unset();\n return props.onChange(next);\n }}\n renderSelected={(value) => {\n return renderSelected(value);\n }}\n renderOption={({ label, value }) => {\n return renderOption({ label, value });\n }}\n />\n );\n}\n\nexport { ColorInput, defaultRenderSelected, defaultRenderOption };\n","import type { ListItems } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport type { ObjectOptions, StringDefinition } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.color\" as const;\n\n/** @public */\nexport type PluginConfig = {\n /**\n * A list of colors to show in the color picker.\n * In addition to the value, the field will also calculate\n * and store the color's luminance in a separate field.\n * @example\n * ```ts\n * colorList: [\n * { label: \"Red\", value: \"#ff0000\" },\n * { label: \"Green\", value: \"#00ff00\" },\n * { label: \"Blue\", value: \"#0000ff\" },\n * ]\n * ```\n */\n colorList: ListItems;\n /**\n * A function to render the selected color value.\n * Note: Import `defaultRenderSelected` to use the default rendering.\n * @example\n * ```ts\n * renderSelected: (value) => <div style={{ backgroundColor: value, width: 20, height: 20 }} />\n * ```\n */\n renderSelected?: (value: string) => React.JSX.Element;\n /** A function to render each color option in the dropdown.\n * Note: Import `defaultRenderOption` to use the default rendering.\n * @example\n * ```ts\n * renderOption: (item) => <div>{item.label}</div>\n * ```\n */\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\n};\n\n/** @public */\nexport type FieldOptions = ObjectOptions & {\n /**\n * Whitelist colors by their values.\n */\n whitelist?: string[];\n /**\n * Blacklist colors by their values.\n */\n blacklist?: string[];\n};\n\n// Add the custom field definition to Sanity's intrinsic definitions\n// so that type checking works correctly when using this field type.\ndeclare module \"sanity\" {\n export interface IntrinsicDefinitions {\n [typeName]: Omit<StringDefinition, \"type\" | \"fields\" | \"options\" | \"components\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { definePlugin, defineType } from \"sanity\";\nimport { ColorInput, defaultRenderOption, defaultRenderSelected } from \"./input\";\nimport { type FieldOptions, type PluginConfig, typeName } from \"./types\";\n\n/** @public */\nconst wildSanityColorFieldPlugin = definePlugin<PluginConfig>((config) => {\n return {\n name: \"@madebywild/sanity-color-field\",\n schema: {\n types: [\n defineType({\n name: typeName,\n type: \"string\",\n title: \"Color\",\n description: \"Select a color.\",\n icon: () => <>🎨</>,\n components: {\n input: (props) => <ColorInput pluginConfig={config} {...props} />,\n },\n }),\n ],\n },\n };\n});\n\nexport { wildSanityColorFieldPlugin, typeName, defaultRenderOption, defaultRenderSelected, type PluginConfig, type FieldOptions };\n"],"names":["defaultRenderSelected","value","backgroundColor","defaultRenderOption","label","Color","Label","ColorInput","t0","$","_c","pluginConfig","props","options","schemaType","colorList","renderOption","renderSelected","whitelist","blacklist","t1","value_0","next","set","unset","onChange","t2","value_1","t3","t4","value_2","_temp","opt","typeName","wildSanityColorFieldPlugin","definePlugin","config","name","schema","types","defineType","type","title","description","icon","components","input"],"mappings":";;;;;AAMA,SAASA,sBAAsBC,OAAmC;AAChE,SAAI,OAAOA,SAAU,WAAiB,oBAAC,UAAO,OAAO;AAAA,IAAEC,iBAAiBD;AAAAA,EAAAA,GAAQ,IACzEA;AACT;AAGA,SAASE,o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AAU,oBAAC,cAAW,cAAcwB,QAAQ,GAAIxB,MAAAA,CAAM;AAAA,MAAA;AAAA,IAChE,CACD,CAAC;AAAA,EAAA;AAGR,EACD;"}
|
package/package.json
CHANGED
package/src/input.tsx
CHANGED
|
@@ -4,13 +4,13 @@ import { type StringInputProps, set, unset } from "sanity";
|
|
|
4
4
|
import type { FieldOptions, PluginConfig } from "./types";
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
|
-
function defaultRenderSelected(value: React.
|
|
7
|
+
function defaultRenderSelected(value: React.JSX.Element | string) {
|
|
8
8
|
if (typeof value === "string") return <Avatar style={{ backgroundColor: value }} />;
|
|
9
9
|
return value;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/** @public */
|
|
13
|
-
function defaultRenderOption({ label, value }: { label?: React.
|
|
13
|
+
function defaultRenderOption({ label, value }: { label?: React.JSX.Element | string; value: React.JSX.Element | string }) {
|
|
14
14
|
const Color = typeof value === "string" ? <Avatar size={1} style={{ backgroundColor: value }} /> : value;
|
|
15
15
|
const Label = typeof label === "string" ? <Text size={2}>{label}</Text> : (label ?? value);
|
|
16
16
|
|