@madebywild/sanity-color-field 0.2.2 → 0.2.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/dist/index.cjs +62 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +63 -48
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/types.tsx +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), asyncAutocomplete = require("@madebywild/sanity-utils/async-autocomplete"), ui = require("@sanity/ui"), color2k = require("color2k");
|
|
3
|
+
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), compilerRuntime = require("react/compiler-runtime"), asyncAutocomplete = require("@madebywild/sanity-utils/async-autocomplete"), ui = require("@sanity/ui"), color2k = require("color2k");
|
|
4
4
|
function maybeGetLuminance(maybeColor) {
|
|
5
5
|
try {
|
|
6
6
|
const safeVar = maybeColor.replace(/^var\((.*)\)$/, "$1"), color = (safeVar.startsWith("--") ? getComputedStyle(document.documentElement).getPropertyValue(safeVar) : void 0)?.trim() || maybeColor;
|
|
@@ -10,57 +10,71 @@ function maybeGetLuminance(maybeColor) {
|
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
function ColorInput({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
13
|
+
function ColorInput(t0) {
|
|
14
|
+
const $ = compilerRuntime.c(15);
|
|
15
|
+
let pluginConfig, props;
|
|
16
|
+
$[0] !== t0 ? ({
|
|
17
|
+
pluginConfig,
|
|
18
|
+
...props
|
|
19
|
+
} = t0, $[0] = t0, $[1] = pluginConfig, $[2] = props) : (pluginConfig = $[1], props = $[2]);
|
|
20
|
+
const options = props.schemaType.options, colorList = options?.colorList ?? pluginConfig.colorList, renderOption = options?.renderOption ?? pluginConfig.renderOption, renderSelected = options?.renderSelected ?? pluginConfig.renderSelected, t1 = props.value?.value;
|
|
21
|
+
let t2;
|
|
22
|
+
$[3] !== props ? (t2 = (value_0) => {
|
|
23
|
+
if (!value_0)
|
|
24
|
+
return props.onChange(sanity.unset());
|
|
25
|
+
const luminance = maybeGetLuminance(value_0);
|
|
26
|
+
return props.onChange(sanity.set({
|
|
27
|
+
...props.value,
|
|
28
|
+
value: value_0,
|
|
29
|
+
luminance
|
|
30
|
+
}));
|
|
31
|
+
}, $[3] = props, $[4] = t2) : t2 = $[4];
|
|
32
|
+
let t3;
|
|
33
|
+
$[5] !== renderSelected ? (t3 = (value_1) => renderSelected ? renderSelected(value_1) : /* @__PURE__ */ jsxRuntime.jsx(ui.Avatar, { style: {
|
|
34
|
+
backgroundColor: value_1
|
|
35
|
+
} }), $[5] = renderSelected, $[6] = t3) : t3 = $[6];
|
|
36
|
+
let t4;
|
|
37
|
+
$[7] !== renderOption ? (t4 = (t52) => {
|
|
38
|
+
const {
|
|
39
|
+
label,
|
|
40
|
+
value: value_2
|
|
41
|
+
} = t52;
|
|
42
|
+
return renderOption ? renderOption({
|
|
43
|
+
label,
|
|
44
|
+
value: value_2
|
|
45
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "button", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", padding: 2, children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Avatar, { size: 1, style: {
|
|
47
|
+
backgroundColor: value_2
|
|
48
|
+
} }),
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 2, children: label }) })
|
|
50
|
+
] }) });
|
|
51
|
+
}, $[7] = renderOption, $[8] = t4) : t4 = $[8];
|
|
52
|
+
let t5;
|
|
53
|
+
return $[9] !== colorList || $[10] !== t1 || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(asyncAutocomplete.AsyncAutocomplete, { placeholder: "Select color", noOptionsPlaceholder: "No colors found", listItems: colorList, value: t1, renderValue: _temp, onChange: t2, renderSelected: t3, renderOption: t4 }), $[9] = colorList, $[10] = t1, $[11] = t2, $[12] = t3, $[13] = t4, $[14] = t5) : t5 = $[14], t5;
|
|
54
|
+
}
|
|
55
|
+
function _temp(value, opt) {
|
|
56
|
+
return opt?.label ?? value;
|
|
38
57
|
}
|
|
39
58
|
const typeName = "wild.color", wildSanityColorFieldPlugin = sanity.definePlugin((config) => ({
|
|
40
59
|
name: "@madebywild/sanity-color-field",
|
|
41
60
|
schema: {
|
|
42
|
-
types: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type: "number"
|
|
60
|
-
})
|
|
61
|
-
]
|
|
62
|
-
})
|
|
63
|
-
]
|
|
61
|
+
types: [sanity.defineType({
|
|
62
|
+
name: typeName,
|
|
63
|
+
type: "object",
|
|
64
|
+
title: "Color",
|
|
65
|
+
description: "Select a color.",
|
|
66
|
+
icon: () => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u{1F3A8}" }),
|
|
67
|
+
components: {
|
|
68
|
+
input: (props) => /* @__PURE__ */ jsxRuntime.jsx(ColorInput, { pluginConfig: config, ...props })
|
|
69
|
+
},
|
|
70
|
+
fields: [sanity.defineField({
|
|
71
|
+
name: "value",
|
|
72
|
+
type: "string"
|
|
73
|
+
}), sanity.defineField({
|
|
74
|
+
name: "luminance",
|
|
75
|
+
type: "number"
|
|
76
|
+
})]
|
|
77
|
+
})]
|
|
64
78
|
}
|
|
65
79
|
}));
|
|
66
80
|
exports.typeName = typeName;
|
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 { getLuminance } from \"color2k\";\nimport { type ObjectInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\ntype FieldValues = {\n // The selected value from the color list.\n value?: string;\n // The calculated luminance of the selected color (0 to 1).\n luminance?: number;\n};\n\nfunction maybeGetLuminance(maybeColor: string) {\n try {\n // Try to unwrap CSS variable and look up its value.\n // If it's not a CSS variable, assume it's a valid color string.\n const safeVar = maybeColor.replace(/^var\\((.*)\\)$/, \"$1\");\n const parsedVar = safeVar.startsWith(\"--\") ? getComputedStyle(document.documentElement).getPropertyValue(safeVar) : undefined;\n const color = parsedVar?.trim() || maybeColor;\n return getLuminance(color);\n } catch (e) {\n console.warn(\"Failed to extract color luminance\", e);\n return undefined;\n }\n}\n\nfunction ColorInput({\n pluginConfig,\n ...props\n}: ObjectInputProps<FieldValues> & {\n pluginConfig: PluginConfig;\n}) {\n const options = props.schemaType.options as FieldOptions | undefined;\n const colorList = options?.colorList ?? pluginConfig.colorList;\n const renderOption = options?.renderOption ?? pluginConfig.renderOption;\n const renderSelected = options?.renderSelected ?? pluginConfig.renderSelected;\n\n return (\n <AsyncAutocomplete\n placeholder=\"Select color\"\n noOptionsPlaceholder=\"No colors found\"\n listItems={colorList}\n value={props.value?.value}\n renderValue={(value, opt) => opt?.label ?? value}\n onChange={(value) => {\n if (!value) return props.onChange(unset());\n const luminance = maybeGetLuminance(value);\n return props.onChange(set({ ...props.value, value, luminance }));\n }}\n renderSelected={(value) => {\n if (renderSelected) return renderSelected(value);\n return <Avatar style={{ backgroundColor: value }} />;\n }}\n renderOption={({ label, value }) => {\n if (renderOption) return renderOption({ label, value });\n return (\n <Card as=\"button\">\n <Flex align=\"center\" padding={2}>\n <Avatar size={1} style={{ backgroundColor: value }} />\n <Box flex={1} padding={2}>\n <Text size={2}>{label}</Text>\n </Box>\n </Flex>\n </Card>\n );\n }}\n />\n );\n}\n\nexport { ColorInput };\n","import type { ListItems } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport type { StringDefinition, StringOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.color\" as const;\n\n/** @public */\nexport type PluginConfig = {\n colorList: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\n};\n\n/** @public */\nexport type FieldOptions = StringOptions & {\n colorList?: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\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\"> & {\n type: typeof typeName;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { ColorInput } 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: \"object\",\n title: \"Color\",\n description: \"Select a color.\",\n icon: () => <>🎨</>,\n components: {\n input: (props) => <ColorInput pluginConfig={config} {...props} />,\n },\n fields: [\n defineField({\n name: \"value\",\n type: \"string\",\n }),\n defineField({\n name: \"luminance\",\n type: \"number\",\n }),\n ],\n }),\n ],\n },\n };\n});\n\nexport { wildSanityColorFieldPlugin, typeName, type PluginConfig, type FieldOptions };\n"],"names":["getLuminance","
|
|
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 { getLuminance } from \"color2k\";\nimport { type ObjectInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\ntype FieldValues = {\n // The selected value from the color list.\n value?: string;\n // The calculated luminance of the selected color (0 to 1).\n luminance?: number;\n};\n\nfunction maybeGetLuminance(maybeColor: string) {\n try {\n // Try to unwrap CSS variable and look up its value.\n // If it's not a CSS variable, assume it's a valid color string.\n const safeVar = maybeColor.replace(/^var\\((.*)\\)$/, \"$1\");\n const parsedVar = safeVar.startsWith(\"--\") ? getComputedStyle(document.documentElement).getPropertyValue(safeVar) : undefined;\n const color = parsedVar?.trim() || maybeColor;\n return getLuminance(color);\n } catch (e) {\n console.warn(\"Failed to extract color luminance\", e);\n return undefined;\n }\n}\n\nfunction ColorInput({\n pluginConfig,\n ...props\n}: ObjectInputProps<FieldValues> & {\n pluginConfig: PluginConfig;\n}) {\n const options = props.schemaType.options as FieldOptions | undefined;\n const colorList = options?.colorList ?? pluginConfig.colorList;\n const renderOption = options?.renderOption ?? pluginConfig.renderOption;\n const renderSelected = options?.renderSelected ?? pluginConfig.renderSelected;\n\n return (\n <AsyncAutocomplete\n placeholder=\"Select color\"\n noOptionsPlaceholder=\"No colors found\"\n listItems={colorList}\n value={props.value?.value}\n renderValue={(value, opt) => opt?.label ?? value}\n onChange={(value) => {\n if (!value) return props.onChange(unset());\n const luminance = maybeGetLuminance(value);\n return props.onChange(set({ ...props.value, value, luminance }));\n }}\n renderSelected={(value) => {\n if (renderSelected) return renderSelected(value);\n return <Avatar style={{ backgroundColor: value }} />;\n }}\n renderOption={({ label, value }) => {\n if (renderOption) return renderOption({ label, value });\n return (\n <Card as=\"button\">\n <Flex align=\"center\" padding={2}>\n <Avatar size={1} style={{ backgroundColor: value }} />\n <Box flex={1} padding={2}>\n <Text size={2}>{label}</Text>\n </Box>\n </Flex>\n </Card>\n );\n }}\n />\n );\n}\n\nexport { ColorInput };\n","import type { ListItems } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport type { StringDefinition, StringOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.color\" as const;\n\n/** @public */\nexport type PluginConfig = {\n colorList: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\n};\n\n/** @public */\nexport type FieldOptions = StringOptions & {\n colorList?: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\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\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { ColorInput } 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: \"object\",\n title: \"Color\",\n description: \"Select a color.\",\n icon: () => <>🎨</>,\n components: {\n input: (props) => <ColorInput pluginConfig={config} {...props} />,\n },\n fields: [\n defineField({\n name: \"value\",\n type: \"string\",\n }),\n defineField({\n name: \"luminance\",\n type: \"number\",\n }),\n ],\n }),\n ],\n },\n };\n});\n\nexport { wildSanityColorFieldPlugin, typeName, type PluginConfig, type FieldOptions };\n"],"names":["maybeGetLuminance","maybeColor","safeVar","replace","color","startsWith","getComputedStyle","document","documentElement","getPropertyValue","undefined","trim","getLuminance","e","console","warn","ColorInput","t0","$","_c","pluginConfig","props","options","schemaType","colorList","renderOption","renderSelected","t1","value","t2","value_0","onChange","unset","luminance","set","t3","value_1","jsx","Avatar","backgroundColor","t4","t5","label","value_2","Card","jsxs","Flex","Box","Text","AsyncAutocomplete","_temp","opt","typeName","wildSanityColorFieldPlugin","definePlugin","config","name","schema","types","defineType","type","title","description","icon","Fragment","components","input","fields","defineField"],"mappings":";;;AAaA,SAASA,kBAAkBC,YAAoB;AAC7C,MAAI;AAGF,UAAMC,UAAUD,WAAWE,QAAQ,iBAAiB,IAAI,GAElDC,SADYF,QAAQG,WAAW,IAAI,IAAIC,iBAAiBC,SAASC,eAAe,EAAEC,iBAAiBP,OAAO,IAAIQ,SAC3FC,UAAUV;AACnC,WAAOW,QAAAA,aAAaR,KAAK;AAAA,EAC3B,SAASS,GAAG;AACVC,YAAQC,KAAK,qCAAqCF,CAAC;AACnD;AAAA,EACF;AACF;AAEA,SAAAG,WAAAC,IAAA;AAAA,QAAAC,IAAAC,gBAAAA,EAAA,EAAA;AAAA,MAAAC,cAAAC;AAAAH,WAAAD,MAAoB;AAAA,IAAAG;AAAAA,IAAA,GAAAC;AAAAA,EAAAA,IAAAJ,IAKnBC,OAAAD,IAAAC,OAAAE,cAAAF,OAAAG,UAAAD,eAAAF,EAAA,CAAA,GAAAG,QAAAH,EAAA,CAAA;AACC,QAAAI,UAAgBD,MAAKE,WAAWD,SAChCE,YAAkBF,SAAOE,aAAeJ,aAAYI,WACpDC,eAAqBH,SAAOG,gBAAkBL,aAAYK,cAC1DC,iBAAuBJ,SAAOI,kBAAoBN,aAAYM,gBAOnDC,KAAAN,MAAKO,OAAaA;AAAA,MAAAC;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30,9 @@ type FieldOptions = StringOptions & {
|
|
|
30
30
|
};
|
|
31
31
|
declare module "sanity" {
|
|
32
32
|
interface IntrinsicDefinitions {
|
|
33
|
-
[typeName]: Omit<StringDefinition, "type" | "fields"> & {
|
|
33
|
+
[typeName]: Omit<StringDefinition, "type" | "fields" | "options"> & {
|
|
34
34
|
type: typeof typeName;
|
|
35
|
+
options?: FieldOptions;
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,8 +30,9 @@ type FieldOptions = StringOptions & {
|
|
|
30
30
|
};
|
|
31
31
|
declare module "sanity" {
|
|
32
32
|
interface IntrinsicDefinitions {
|
|
33
|
-
[typeName]: Omit<StringDefinition, "type" | "fields"> & {
|
|
33
|
+
[typeName]: Omit<StringDefinition, "type" | "fields" | "options"> & {
|
|
34
34
|
type: typeof typeName;
|
|
35
|
+
options?: FieldOptions;
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { unset, set, definePlugin, defineType, defineField } from "sanity";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { AsyncAutocomplete } from "@madebywild/sanity-utils/async-autocomplete";
|
|
4
|
-
import { Card, Flex,
|
|
5
|
+
import { Avatar, Card, Flex, Box, Text } from "@sanity/ui";
|
|
5
6
|
import { getLuminance } from "color2k";
|
|
6
7
|
function maybeGetLuminance(maybeColor) {
|
|
7
8
|
try {
|
|
@@ -12,57 +13,71 @@ function maybeGetLuminance(maybeColor) {
|
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
function ColorInput({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
16
|
+
function ColorInput(t0) {
|
|
17
|
+
const $ = c(15);
|
|
18
|
+
let pluginConfig, props;
|
|
19
|
+
$[0] !== t0 ? ({
|
|
20
|
+
pluginConfig,
|
|
21
|
+
...props
|
|
22
|
+
} = t0, $[0] = t0, $[1] = pluginConfig, $[2] = props) : (pluginConfig = $[1], props = $[2]);
|
|
23
|
+
const options = props.schemaType.options, colorList = options?.colorList ?? pluginConfig.colorList, renderOption = options?.renderOption ?? pluginConfig.renderOption, renderSelected = options?.renderSelected ?? pluginConfig.renderSelected, t1 = props.value?.value;
|
|
24
|
+
let t2;
|
|
25
|
+
$[3] !== props ? (t2 = (value_0) => {
|
|
26
|
+
if (!value_0)
|
|
27
|
+
return props.onChange(unset());
|
|
28
|
+
const luminance = maybeGetLuminance(value_0);
|
|
29
|
+
return props.onChange(set({
|
|
30
|
+
...props.value,
|
|
31
|
+
value: value_0,
|
|
32
|
+
luminance
|
|
33
|
+
}));
|
|
34
|
+
}, $[3] = props, $[4] = t2) : t2 = $[4];
|
|
35
|
+
let t3;
|
|
36
|
+
$[5] !== renderSelected ? (t3 = (value_1) => renderSelected ? renderSelected(value_1) : /* @__PURE__ */ jsx(Avatar, { style: {
|
|
37
|
+
backgroundColor: value_1
|
|
38
|
+
} }), $[5] = renderSelected, $[6] = t3) : t3 = $[6];
|
|
39
|
+
let t4;
|
|
40
|
+
$[7] !== renderOption ? (t4 = (t52) => {
|
|
41
|
+
const {
|
|
42
|
+
label,
|
|
43
|
+
value: value_2
|
|
44
|
+
} = t52;
|
|
45
|
+
return renderOption ? renderOption({
|
|
46
|
+
label,
|
|
47
|
+
value: value_2
|
|
48
|
+
}) : /* @__PURE__ */ jsx(Card, { as: "button", children: /* @__PURE__ */ jsxs(Flex, { align: "center", padding: 2, children: [
|
|
49
|
+
/* @__PURE__ */ jsx(Avatar, { size: 1, style: {
|
|
50
|
+
backgroundColor: value_2
|
|
51
|
+
} }),
|
|
52
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 2, children: label }) })
|
|
53
|
+
] }) });
|
|
54
|
+
}, $[7] = renderOption, $[8] = t4) : t4 = $[8];
|
|
55
|
+
let t5;
|
|
56
|
+
return $[9] !== colorList || $[10] !== t1 || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 ? (t5 = /* @__PURE__ */ jsx(AsyncAutocomplete, { placeholder: "Select color", noOptionsPlaceholder: "No colors found", listItems: colorList, value: t1, renderValue: _temp, onChange: t2, renderSelected: t3, renderOption: t4 }), $[9] = colorList, $[10] = t1, $[11] = t2, $[12] = t3, $[13] = t4, $[14] = t5) : t5 = $[14], t5;
|
|
57
|
+
}
|
|
58
|
+
function _temp(value, opt) {
|
|
59
|
+
return opt?.label ?? value;
|
|
40
60
|
}
|
|
41
61
|
const typeName = "wild.color", wildSanityColorFieldPlugin = definePlugin((config) => ({
|
|
42
62
|
name: "@madebywild/sanity-color-field",
|
|
43
63
|
schema: {
|
|
44
|
-
types: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
type: "number"
|
|
62
|
-
})
|
|
63
|
-
]
|
|
64
|
-
})
|
|
65
|
-
]
|
|
64
|
+
types: [defineType({
|
|
65
|
+
name: typeName,
|
|
66
|
+
type: "object",
|
|
67
|
+
title: "Color",
|
|
68
|
+
description: "Select a color.",
|
|
69
|
+
icon: () => /* @__PURE__ */ jsx(Fragment, { children: "\u{1F3A8}" }),
|
|
70
|
+
components: {
|
|
71
|
+
input: (props) => /* @__PURE__ */ jsx(ColorInput, { pluginConfig: config, ...props })
|
|
72
|
+
},
|
|
73
|
+
fields: [defineField({
|
|
74
|
+
name: "value",
|
|
75
|
+
type: "string"
|
|
76
|
+
}), defineField({
|
|
77
|
+
name: "luminance",
|
|
78
|
+
type: "number"
|
|
79
|
+
})]
|
|
80
|
+
})]
|
|
66
81
|
}
|
|
67
82
|
}));
|
|
68
83
|
export {
|
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 { getLuminance } from \"color2k\";\nimport { type ObjectInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\ntype FieldValues = {\n // The selected value from the color list.\n value?: string;\n // The calculated luminance of the selected color (0 to 1).\n luminance?: number;\n};\n\nfunction maybeGetLuminance(maybeColor: string) {\n try {\n // Try to unwrap CSS variable and look up its value.\n // If it's not a CSS variable, assume it's a valid color string.\n const safeVar = maybeColor.replace(/^var\\((.*)\\)$/, \"$1\");\n const parsedVar = safeVar.startsWith(\"--\") ? getComputedStyle(document.documentElement).getPropertyValue(safeVar) : undefined;\n const color = parsedVar?.trim() || maybeColor;\n return getLuminance(color);\n } catch (e) {\n console.warn(\"Failed to extract color luminance\", e);\n return undefined;\n }\n}\n\nfunction ColorInput({\n pluginConfig,\n ...props\n}: ObjectInputProps<FieldValues> & {\n pluginConfig: PluginConfig;\n}) {\n const options = props.schemaType.options as FieldOptions | undefined;\n const colorList = options?.colorList ?? pluginConfig.colorList;\n const renderOption = options?.renderOption ?? pluginConfig.renderOption;\n const renderSelected = options?.renderSelected ?? pluginConfig.renderSelected;\n\n return (\n <AsyncAutocomplete\n placeholder=\"Select color\"\n noOptionsPlaceholder=\"No colors found\"\n listItems={colorList}\n value={props.value?.value}\n renderValue={(value, opt) => opt?.label ?? value}\n onChange={(value) => {\n if (!value) return props.onChange(unset());\n const luminance = maybeGetLuminance(value);\n return props.onChange(set({ ...props.value, value, luminance }));\n }}\n renderSelected={(value) => {\n if (renderSelected) return renderSelected(value);\n return <Avatar style={{ backgroundColor: value }} />;\n }}\n renderOption={({ label, value }) => {\n if (renderOption) return renderOption({ label, value });\n return (\n <Card as=\"button\">\n <Flex align=\"center\" padding={2}>\n <Avatar size={1} style={{ backgroundColor: value }} />\n <Box flex={1} padding={2}>\n <Text size={2}>{label}</Text>\n </Box>\n </Flex>\n </Card>\n );\n }}\n />\n );\n}\n\nexport { ColorInput };\n","import type { ListItems } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport type { StringDefinition, StringOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.color\" as const;\n\n/** @public */\nexport type PluginConfig = {\n colorList: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\n};\n\n/** @public */\nexport type FieldOptions = StringOptions & {\n colorList?: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\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\"> & {\n type: typeof typeName;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { ColorInput } 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: \"object\",\n title: \"Color\",\n description: \"Select a color.\",\n icon: () => <>🎨</>,\n components: {\n input: (props) => <ColorInput pluginConfig={config} {...props} />,\n },\n fields: [\n defineField({\n name: \"value\",\n type: \"string\",\n }),\n defineField({\n name: \"luminance\",\n type: \"number\",\n }),\n ],\n }),\n ],\n },\n };\n});\n\nexport { wildSanityColorFieldPlugin, typeName, type PluginConfig, type FieldOptions };\n"],"names":[],"mappings":"
|
|
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 { getLuminance } from \"color2k\";\nimport { type ObjectInputProps, set, unset } from \"sanity\";\nimport type { FieldOptions, PluginConfig } from \"./types\";\n\ntype FieldValues = {\n // The selected value from the color list.\n value?: string;\n // The calculated luminance of the selected color (0 to 1).\n luminance?: number;\n};\n\nfunction maybeGetLuminance(maybeColor: string) {\n try {\n // Try to unwrap CSS variable and look up its value.\n // If it's not a CSS variable, assume it's a valid color string.\n const safeVar = maybeColor.replace(/^var\\((.*)\\)$/, \"$1\");\n const parsedVar = safeVar.startsWith(\"--\") ? getComputedStyle(document.documentElement).getPropertyValue(safeVar) : undefined;\n const color = parsedVar?.trim() || maybeColor;\n return getLuminance(color);\n } catch (e) {\n console.warn(\"Failed to extract color luminance\", e);\n return undefined;\n }\n}\n\nfunction ColorInput({\n pluginConfig,\n ...props\n}: ObjectInputProps<FieldValues> & {\n pluginConfig: PluginConfig;\n}) {\n const options = props.schemaType.options as FieldOptions | undefined;\n const colorList = options?.colorList ?? pluginConfig.colorList;\n const renderOption = options?.renderOption ?? pluginConfig.renderOption;\n const renderSelected = options?.renderSelected ?? pluginConfig.renderSelected;\n\n return (\n <AsyncAutocomplete\n placeholder=\"Select color\"\n noOptionsPlaceholder=\"No colors found\"\n listItems={colorList}\n value={props.value?.value}\n renderValue={(value, opt) => opt?.label ?? value}\n onChange={(value) => {\n if (!value) return props.onChange(unset());\n const luminance = maybeGetLuminance(value);\n return props.onChange(set({ ...props.value, value, luminance }));\n }}\n renderSelected={(value) => {\n if (renderSelected) return renderSelected(value);\n return <Avatar style={{ backgroundColor: value }} />;\n }}\n renderOption={({ label, value }) => {\n if (renderOption) return renderOption({ label, value });\n return (\n <Card as=\"button\">\n <Flex align=\"center\" padding={2}>\n <Avatar size={1} style={{ backgroundColor: value }} />\n <Box flex={1} padding={2}>\n <Text size={2}>{label}</Text>\n </Box>\n </Flex>\n </Card>\n );\n }}\n />\n );\n}\n\nexport { ColorInput };\n","import type { ListItems } from \"@madebywild/sanity-utils/async-autocomplete\";\nimport type { StringDefinition, StringOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.color\" as const;\n\n/** @public */\nexport type PluginConfig = {\n colorList: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\n};\n\n/** @public */\nexport type FieldOptions = StringOptions & {\n colorList?: ListItems;\n renderSelected?: (value: string) => React.JSX.Element;\n renderOption?: (item: { label?: string; value: string }) => React.JSX.Element;\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\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { ColorInput } 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: \"object\",\n title: \"Color\",\n description: \"Select a color.\",\n icon: () => <>🎨</>,\n components: {\n input: (props) => <ColorInput pluginConfig={config} {...props} />,\n },\n fields: [\n defineField({\n name: \"value\",\n type: \"string\",\n }),\n defineField({\n name: \"luminance\",\n type: \"number\",\n }),\n ],\n }),\n ],\n },\n };\n});\n\nexport { wildSanityColorFieldPlugin, typeName, type PluginConfig, type FieldOptions };\n"],"names":["maybeGetLuminance","maybeColor","safeVar","replace","color","startsWith","getComputedStyle","document","documentElement","getPropertyValue","undefined","trim","getLuminance","e","console","warn","ColorInput","t0","$","_c","pluginConfig","props","options","schemaType","colorList","renderOption","renderSelected","t1","value","t2","value_0","onChange","unset","luminance","set","t3","value_1","backgroundColor","t4","t5","label","value_2","_temp","opt","typeName","wildSanityColorFieldPlugin","definePlugin","config","name","schema","types","defineType","type","title","description","icon","components","input","fields","defineField"],"mappings":";;;;;;AAaA,SAASA,kBAAkBC,YAAoB;AAC7C,MAAI;AAGF,UAAMC,UAAUD,WAAWE,QAAQ,iBAAiB,IAAI,GAElDC,SADYF,QAAQG,WAAW,IAAI,IAAIC,iBAAiBC,SAASC,eAAe,EAAEC,iBAAiBP,OAAO,IAAIQ,SAC3FC,UAAUV;AACnC,WAAOW,aAAaR,KAAK;AAAA,EAC3B,SAASS,GAAG;AACVC,YAAQC,KAAK,qCAAqCF,CAAC;AACnD;AAAA,EACF;AACF;AAEA,SAAAG,WAAAC,IAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA;AAAA,MAAAC,cAAAC;AAAAH,WAAAD,MAAoB;AAAA,IAAAG;AAAAA,IAAA,GAAAC;AAAAA,EAAAA,IAAAJ,IAKnBC,OAAAD,IAAAC,OAAAE,cAAAF,OAAAG,UAAAD,eAAAF,EAAA,CAAA,GAAAG,QAAAH,EAAA,CAAA;AACC,QAAAI,UAAgBD,MAAKE,WAAWD,SAChCE,YAAkBF,SAAOE,aAAeJ,aAAYI,WACpDC,eAAqBH,SAAOG,gBAAkBL,aAAYK,cAC1DC,iBAAuBJ,SAAOI,kBAAoBN,aAAYM,gBAOnDC,KAAAN,MAAKO,OAAaA;AAAA,MAAAC;AAAAX,WAAAG,SAEfQ,KAAAC,CAAAA,YAAA;AACR,QAAI,CAACF;AAAK,aAASP,MAAKU,SAA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MA3BHC,yBAAC,mBAAA,EACa,aAAA,gBACS,sBAAA,mBACVf,sBACJ,OAAAG,IACM,aAAAe,OACH,UAAAb,IAKM,gBAAAM,IAIF,cAAAG,GAAAA,CAYb,GACDpB,OAAAM,WAAAN,QAAAS,IAAAT,QAAAW,IAAAX,QAAAiB,IAAAjB,QAAAoB,IAAApB,QAAAqB,MAAAA,KAAArB,EAAA,EAAA,GA5BFqB;AA4BE;AAxCN,SAAAG,MAAAd,OAAAe,KAAA;AAAA,SAiBmCA,KAAGH,SAAHZ;AAAmB;ACxC/C,MAAMgB,WAAW,cCClBC,6BAA6BC,aAA4BC,CAAAA,YACtD;AAAA,EACLC,MAAM;AAAA,EACNC,QAAQ;AAAA,IACNC,OAAO,CACLC,WAAW;AAAA,MACTH,MAAMJ;AAAAA,MACNQ,MAAM;AAAA,MACNC,OAAO;AAAA,MACPC,aAAa;AAAA,MACbC,MAAMA,MAAM,oBAAA,UAAA,EAAE,UAAA,YAAA,CAAE;AAAA,MAChBC,YAAY;AAAA,QACVC,OAAQpC,CAAAA,UAAU,oBAAC,cAAW,cAAc0B,QAAQ,GAAI1B,MAAAA,CAAM;AAAA,MAAA;AAAA,MAEhEqC,QAAQ,CACNC,YAAY;AAAA,QACVX,MAAM;AAAA,QACNI,MAAM;AAAA,MAAA,CACP,GACDO,YAAY;AAAA,QACVX,MAAM;AAAA,QACNI,MAAM;AAAA,MAAA,CACP,CAAC;AAAA,IAAA,CAEL,CAAC;AAAA,EAAA;AAGR,EACD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madebywild/sanity-color-field",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -22,22 +22,23 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"color2k": "2.0.3",
|
|
25
|
-
"@madebywild/sanity-utils": "0.2.
|
|
25
|
+
"@madebywild/sanity-utils": "0.2.4"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@sanity/ui": "^3.1",
|
|
29
|
-
"sanity": "^4.17",
|
|
30
29
|
"react": "^19",
|
|
31
|
-
"react-dom": "^19"
|
|
30
|
+
"react-dom": "^19",
|
|
31
|
+
"sanity": "^4.17"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@sanity/pkg-utils": "^9.2",
|
|
35
|
-
"
|
|
35
|
+
"@types/react": "^19",
|
|
36
|
+
"@types/react-dom": "^19",
|
|
37
|
+
"babel-plugin-react-compiler": "1.0.0",
|
|
36
38
|
"react": "^19",
|
|
37
39
|
"react-dom": "^19",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"@types/react-dom": "^19"
|
|
40
|
+
"sanity": "^4.17",
|
|
41
|
+
"typescript": "^5"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "pkg-utils build --strict",
|
package/src/types.tsx
CHANGED
|
@@ -22,8 +22,9 @@ export type FieldOptions = StringOptions & {
|
|
|
22
22
|
// so that type checking works correctly when using this field type.
|
|
23
23
|
declare module "sanity" {
|
|
24
24
|
export interface IntrinsicDefinitions {
|
|
25
|
-
[typeName]: Omit<StringDefinition, "type" | "fields"> & {
|
|
25
|
+
[typeName]: Omit<StringDefinition, "type" | "fields" | "options"> & {
|
|
26
26
|
type: typeof typeName;
|
|
27
|
+
options?: FieldOptions;
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
}
|