@madebywild/sanity-quote-field 0.0.2 → 0.0.3
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 +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +12 -5
package/dist/index.cjs
CHANGED
|
@@ -31,23 +31,29 @@ const typeName = "wild.quote", wildSanityQuoteFieldPlugin = sanity.definePlugin(
|
|
|
31
31
|
}]
|
|
32
32
|
})] : [sanity.defineField({
|
|
33
33
|
type: "string",
|
|
34
|
-
name: "
|
|
34
|
+
name: "authorName",
|
|
35
|
+
title: "Author",
|
|
36
|
+
description: "The author name of the quote."
|
|
37
|
+
}), sanity.defineField({
|
|
38
|
+
type: "text",
|
|
39
|
+
rows: 2,
|
|
40
|
+
name: "authorDescription",
|
|
35
41
|
title: "Author",
|
|
36
|
-
description: "The author of the quote."
|
|
42
|
+
description: "The author description of the quote."
|
|
37
43
|
})]
|
|
38
44
|
],
|
|
39
45
|
preview: {
|
|
40
46
|
select: {
|
|
41
47
|
quote: "quote",
|
|
42
|
-
|
|
48
|
+
authorName: config?.authorTypeName ? "author.title" : "authorName"
|
|
43
49
|
},
|
|
44
50
|
prepare({
|
|
45
51
|
quote,
|
|
46
|
-
|
|
52
|
+
authorName
|
|
47
53
|
}) {
|
|
48
54
|
return {
|
|
49
55
|
title: quote ? `"${quote}"` : "No quote",
|
|
50
|
-
subtitle:
|
|
56
|
+
subtitle: authorName ? `\u2014 ${authorName}` : void 0
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
59
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/types.tsx","../src/index.tsx"],"sourcesContent":["import type { FieldOptions as RichtextOptions } from \"@madebywild/sanity-richtext-field\";\nimport type { ObjectDefinition, ObjectOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.quote\" as const;\n\n/** @public */\nexport type PluginConfig = {\n authorTypeName?: string;\n richtextOptions?: RichtextOptions;\n};\n\n/** @public */\nexport type FieldOptions = ObjectOptions;\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<ObjectDefinition, \"type\" | \"fields\" | \"options\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { type PluginConfig, typeName } from \"./types\";\n\n/** @public */\n// biome-ignore lint/suspicious/noConfusingVoidType: it can be void.\nconst wildSanityQuoteFieldPlugin = definePlugin<PluginConfig | void>((config) => {\n return {\n name: \"@madebywild/sanity-quote-field\",\n schema: {\n types: [\n defineType({\n name: typeName,\n type: \"object\",\n title: \"Quote\",\n description: \"A stylized quote with optional author.\",\n fields: [\n defineField({\n name: \"quote\",\n type: \"wild.richtext\",\n title: \"Quote\",\n description: \"The quote text.\",\n options: {\n preset: \"basic\",\n ...config?.richtextOptions,\n },\n }),\n // Display a reference field if the user provided a author typeName.\n ...(config?.authorTypeName\n ? [\n defineField({\n type: \"reference\",\n name: \"author\",\n title: \"Author\",\n description: \"The author of the quote.\",\n to: [{ type: config.authorTypeName }],\n }),\n ]\n : [\n defineField({\n type: \"string\",\n name: \"author\",\n title: \"Author\",\n description: \"The author of the quote.\",\n }),\n ]),\n ],\n preview: {\n select: {\n quote: \"quote\",\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/types.tsx","../src/index.tsx"],"sourcesContent":["import type { FieldOptions as RichtextOptions } from \"@madebywild/sanity-richtext-field\";\nimport type { ObjectDefinition, ObjectOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.quote\" as const;\n\n/** @public */\nexport type PluginConfig = {\n authorTypeName?: string;\n richtextOptions?: RichtextOptions;\n};\n\n/** @public */\nexport type FieldOptions = ObjectOptions;\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<ObjectDefinition, \"type\" | \"fields\" | \"options\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { type PluginConfig, typeName } from \"./types\";\n\n/** @public */\n// biome-ignore lint/suspicious/noConfusingVoidType: it can be void.\nconst wildSanityQuoteFieldPlugin = definePlugin<PluginConfig | void>((config) => {\n return {\n name: \"@madebywild/sanity-quote-field\",\n schema: {\n types: [\n defineType({\n name: typeName,\n type: \"object\",\n title: \"Quote\",\n description: \"A stylized quote with optional author.\",\n fields: [\n defineField({\n name: \"quote\",\n type: \"wild.richtext\",\n title: \"Quote\",\n description: \"The quote text.\",\n options: {\n preset: \"basic\",\n ...config?.richtextOptions,\n },\n }),\n // Display a reference field if the user provided a author typeName.\n ...(config?.authorTypeName\n ? [\n defineField({\n type: \"reference\",\n name: \"author\",\n title: \"Author\",\n description: \"The author of the quote.\",\n to: [{ type: config.authorTypeName }],\n }),\n ]\n : [\n defineField({\n type: \"string\",\n name: \"authorName\",\n title: \"Author\",\n description: \"The author name of the quote.\",\n }),\n defineField({\n type: \"text\",\n rows: 2,\n name: \"authorDescription\",\n title: \"Author\",\n description: \"The author description of the quote.\",\n }),\n ]),\n ],\n preview: {\n select: {\n quote: \"quote\",\n authorName: config?.authorTypeName ? \"author.title\" : \"authorName\",\n },\n prepare({ quote, authorName }) {\n return {\n title: quote ? `\"${quote}\"` : \"No quote\",\n subtitle: authorName ? `— ${authorName}` : undefined,\n };\n },\n },\n }),\n ],\n },\n };\n});\n\nexport { wildSanityQuoteFieldPlugin, typeName };\n"],"names":["typeName","wildSanityQuoteFieldPlugin","definePlugin","config","name","schema","types","defineType","type","title","description","fields","defineField","options","preset","richtextOptions","authorTypeName","to","rows","preview","select","quote","authorName","prepare","subtitle","undefined"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;AAAA,MAAA;AAAA,IACF,CACD,CAAC;AAAA,EAAA;AAGR,EACD;;;"}
|
package/dist/index.js
CHANGED
|
@@ -29,23 +29,29 @@ const typeName = "wild.quote", wildSanityQuoteFieldPlugin = definePlugin((config
|
|
|
29
29
|
}]
|
|
30
30
|
})] : [defineField({
|
|
31
31
|
type: "string",
|
|
32
|
-
name: "
|
|
32
|
+
name: "authorName",
|
|
33
|
+
title: "Author",
|
|
34
|
+
description: "The author name of the quote."
|
|
35
|
+
}), defineField({
|
|
36
|
+
type: "text",
|
|
37
|
+
rows: 2,
|
|
38
|
+
name: "authorDescription",
|
|
33
39
|
title: "Author",
|
|
34
|
-
description: "The author of the quote."
|
|
40
|
+
description: "The author description of the quote."
|
|
35
41
|
})]
|
|
36
42
|
],
|
|
37
43
|
preview: {
|
|
38
44
|
select: {
|
|
39
45
|
quote: "quote",
|
|
40
|
-
|
|
46
|
+
authorName: config?.authorTypeName ? "author.title" : "authorName"
|
|
41
47
|
},
|
|
42
48
|
prepare({
|
|
43
49
|
quote,
|
|
44
|
-
|
|
50
|
+
authorName
|
|
45
51
|
}) {
|
|
46
52
|
return {
|
|
47
53
|
title: quote ? `"${quote}"` : "No quote",
|
|
48
|
-
subtitle:
|
|
54
|
+
subtitle: authorName ? `\u2014 ${authorName}` : void 0
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/types.tsx","../src/index.tsx"],"sourcesContent":["import type { FieldOptions as RichtextOptions } from \"@madebywild/sanity-richtext-field\";\nimport type { ObjectDefinition, ObjectOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.quote\" as const;\n\n/** @public */\nexport type PluginConfig = {\n authorTypeName?: string;\n richtextOptions?: RichtextOptions;\n};\n\n/** @public */\nexport type FieldOptions = ObjectOptions;\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<ObjectDefinition, \"type\" | \"fields\" | \"options\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { type PluginConfig, typeName } from \"./types\";\n\n/** @public */\n// biome-ignore lint/suspicious/noConfusingVoidType: it can be void.\nconst wildSanityQuoteFieldPlugin = definePlugin<PluginConfig | void>((config) => {\n return {\n name: \"@madebywild/sanity-quote-field\",\n schema: {\n types: [\n defineType({\n name: typeName,\n type: \"object\",\n title: \"Quote\",\n description: \"A stylized quote with optional author.\",\n fields: [\n defineField({\n name: \"quote\",\n type: \"wild.richtext\",\n title: \"Quote\",\n description: \"The quote text.\",\n options: {\n preset: \"basic\",\n ...config?.richtextOptions,\n },\n }),\n // Display a reference field if the user provided a author typeName.\n ...(config?.authorTypeName\n ? [\n defineField({\n type: \"reference\",\n name: \"author\",\n title: \"Author\",\n description: \"The author of the quote.\",\n to: [{ type: config.authorTypeName }],\n }),\n ]\n : [\n defineField({\n type: \"string\",\n name: \"author\",\n title: \"Author\",\n description: \"The author of the quote.\",\n }),\n ]),\n ],\n preview: {\n select: {\n quote: \"quote\",\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/types.tsx","../src/index.tsx"],"sourcesContent":["import type { FieldOptions as RichtextOptions } from \"@madebywild/sanity-richtext-field\";\nimport type { ObjectDefinition, ObjectOptions } from \"sanity\";\n\n/** @public */\nexport const typeName = \"wild.quote\" as const;\n\n/** @public */\nexport type PluginConfig = {\n authorTypeName?: string;\n richtextOptions?: RichtextOptions;\n};\n\n/** @public */\nexport type FieldOptions = ObjectOptions;\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<ObjectDefinition, \"type\" | \"fields\" | \"options\"> & {\n type: typeof typeName;\n options?: FieldOptions;\n };\n }\n}\n","import { defineField, definePlugin, defineType } from \"sanity\";\nimport { type PluginConfig, typeName } from \"./types\";\n\n/** @public */\n// biome-ignore lint/suspicious/noConfusingVoidType: it can be void.\nconst wildSanityQuoteFieldPlugin = definePlugin<PluginConfig | void>((config) => {\n return {\n name: \"@madebywild/sanity-quote-field\",\n schema: {\n types: [\n defineType({\n name: typeName,\n type: \"object\",\n title: \"Quote\",\n description: \"A stylized quote with optional author.\",\n fields: [\n defineField({\n name: \"quote\",\n type: \"wild.richtext\",\n title: \"Quote\",\n description: \"The quote text.\",\n options: {\n preset: \"basic\",\n ...config?.richtextOptions,\n },\n }),\n // Display a reference field if the user provided a author typeName.\n ...(config?.authorTypeName\n ? [\n defineField({\n type: \"reference\",\n name: \"author\",\n title: \"Author\",\n description: \"The author of the quote.\",\n to: [{ type: config.authorTypeName }],\n }),\n ]\n : [\n defineField({\n type: \"string\",\n name: \"authorName\",\n title: \"Author\",\n description: \"The author name of the quote.\",\n }),\n defineField({\n type: \"text\",\n rows: 2,\n name: \"authorDescription\",\n title: \"Author\",\n description: \"The author description of the quote.\",\n }),\n ]),\n ],\n preview: {\n select: {\n quote: \"quote\",\n authorName: config?.authorTypeName ? \"author.title\" : \"authorName\",\n },\n prepare({ quote, authorName }) {\n return {\n title: quote ? `\"${quote}\"` : \"No quote\",\n subtitle: authorName ? `— ${authorName}` : undefined,\n };\n },\n },\n }),\n ],\n },\n };\n});\n\nexport { wildSanityQuoteFieldPlugin, typeName };\n"],"names":["typeName","wildSanityQuoteFieldPlugin","definePlugin","config","name","schema","types","defineType","type","title","description","fields","defineField","options","preset","richtextOptions","authorTypeName","to","rows","preview","select","quote","authorName","prepare","subtitle","undefined"],"mappings":";AAIO,MAAMA,WAAW,cCClBC,6BAA6BC,aAAmCC,CAAAA,YAC7D;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,QAAQ;AAAA,QACNC,YAAY;AAAA,UACVR,MAAM;AAAA,UACNI,MAAM;AAAA,UACNC,OAAO;AAAA,UACPC,aAAa;AAAA,UACbG,SAAS;AAAA,YACPC,QAAQ;AAAA,YACR,GAAGX,QAAQY;AAAAA,UAAAA;AAAAA,QACb,CACD;AAAA;AAAA,QAED,GAAIZ,QAAQa,iBACR,CACEJ,YAAY;AAAA,UACVJ,MAAM;AAAA,UACNJ,MAAM;AAAA,UACNK,OAAO;AAAA,UACPC,aAAa;AAAA,UACbO,IAAI,CAAC;AAAA,YAAET,MAAML,OAAOa;AAAAA,UAAAA,CAAgB;AAAA,QAAA,CACrC,CAAC,IAEJ,CACEJ,YAAY;AAAA,UACVJ,MAAM;AAAA,UACNJ,MAAM;AAAA,UACNK,OAAO;AAAA,UACPC,aAAa;AAAA,QAAA,CACd,GACDE,YAAY;AAAA,UACVJ,MAAM;AAAA,UACNU,MAAM;AAAA,UACNd,MAAM;AAAA,UACNK,OAAO;AAAA,UACPC,aAAa;AAAA,QAAA,CACd,CAAC;AAAA,MAAA;AAAA,MAGVS,SAAS;AAAA,QACPC,QAAQ;AAAA,UACNC,OAAO;AAAA,UACPC,YAAYnB,QAAQa,iBAAiB,iBAAiB;AAAA,QAAA;AAAA,QAExDO,QAAQ;AAAA,UAAEF;AAAAA,UAAOC;AAAAA,QAAAA,GAAc;AAC7B,iBAAO;AAAA,YACLb,OAAOY,QAAQ,IAAIA,KAAK,MAAM;AAAA,YAC9BG,UAAUF,aAAa,UAAKA,UAAU,KAAKG;AAAAA,UAAAA;AAAAA,QAE/C;AAAA,MAAA;AAAA,IACF,CACD,CAAC;AAAA,EAAA;AAGR,EACD;"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -38,21 +38,28 @@ const wildSanityQuoteFieldPlugin = definePlugin<PluginConfig | void>((config) =>
|
|
|
38
38
|
: [
|
|
39
39
|
defineField({
|
|
40
40
|
type: "string",
|
|
41
|
-
name: "
|
|
41
|
+
name: "authorName",
|
|
42
42
|
title: "Author",
|
|
43
|
-
description: "The author of the quote.",
|
|
43
|
+
description: "The author name of the quote.",
|
|
44
|
+
}),
|
|
45
|
+
defineField({
|
|
46
|
+
type: "text",
|
|
47
|
+
rows: 2,
|
|
48
|
+
name: "authorDescription",
|
|
49
|
+
title: "Author",
|
|
50
|
+
description: "The author description of the quote.",
|
|
44
51
|
}),
|
|
45
52
|
]),
|
|
46
53
|
],
|
|
47
54
|
preview: {
|
|
48
55
|
select: {
|
|
49
56
|
quote: "quote",
|
|
50
|
-
|
|
57
|
+
authorName: config?.authorTypeName ? "author.title" : "authorName",
|
|
51
58
|
},
|
|
52
|
-
prepare({ quote,
|
|
59
|
+
prepare({ quote, authorName }) {
|
|
53
60
|
return {
|
|
54
61
|
title: quote ? `"${quote}"` : "No quote",
|
|
55
|
-
subtitle:
|
|
62
|
+
subtitle: authorName ? `— ${authorName}` : undefined,
|
|
56
63
|
};
|
|
57
64
|
},
|
|
58
65
|
},
|