@sanity/color-input 4.0.3 → 4.0.5
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 +1 -1
- package/README.md +0 -1
- package/lib/_chunks-cjs/ColorInput.js +16 -20
- package/lib/_chunks-cjs/ColorInput.js.map +1 -1
- package/lib/_chunks-es/ColorInput.mjs +16 -20
- package/lib/_chunks-es/ColorInput.mjs.map +1 -1
- package/lib/_legacy/ColorInput.esm.js +16 -20
- package/lib/_legacy/ColorInput.esm.js.map +1 -1
- package/lib/index.esm.js +2 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +2 -2
- package/lib/index.mjs.map +1 -1
- package/package.json +18 -13
- package/src/ColorInput.tsx +1 -1
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/LazyColorInput.tsx","../src/schemas/color.tsx","../src/schemas/hslaColor.ts","../src/schemas/hsvaColor.ts","../src/schemas/rgbaColor.ts","../src/index.ts"],"sourcesContent":["import {lazy} from 'react'\n\nexport const ColorInput = lazy(() => import('./ColorInput'))\n","import {defineType, type ObjectDefinition} from 'sanity'\n\nimport {ColorInput} from '../LazyColorInput'\nimport {type ColorOptions} from '../types'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nconst colorTypeName = 'color' as const\n\n/**\n * @public\n */\nexport interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {\n type: typeof colorTypeName\n options?: ColorOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n color: ColorDefinition\n }\n}\n\nexport const color = defineType({\n name: colorTypeName,\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n})\n","import {defineType} from 'sanity'\n\nexport const hslaColor = defineType({\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const hsvaColor = defineType({\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const rgbaColor = defineType({\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {definePlugin} from 'sanity'\n\nimport {color, type ColorDefinition} from './schemas/color'\nimport {hslaColor} from './schemas/hslaColor'\nimport {hsvaColor} from './schemas/hsvaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\n\nexport const colorInput = definePlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {color, hslaColor, hsvaColor, rgbaColor}\nexport {ColorInput} from './LazyColorInput'\nexport type {ColorDefinition}\nexport type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'\n"],"names":["lazy","defineType","jsx","definePlugin"],"mappings":";;;AAEO,MAAM,aAAaA,MAAAA,KAAK,MAAM,QAAA,QAAA,EAAA,KAAA,WAAA;AAAA,SAAA,QAAO,6BAAc;AAAC,CAAA,CAAA,GCGrD,QAAQ,CAAC,MAAc,MAAM,KAAK,MAAM,MAAM,GAAG,GAEjD,gBAAgB,SAiBT,QAAQC,OAAAA,WAAW;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,WAAU;AAAA,EAC9B,QAAQ;AAAA,IACN;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,EAEV;AAAA,EACA,SAAS;AAAA,IACP,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAMC;AACD,UAAI,WAAW,OAAO;AAClB,aAAA,QACF,WAAW,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,KAAK,CAAC,KAE7E;AAAA,QACL;AAAA,QACA;AAAA,QACA,OAAO,MACLC,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,iBAAiB,OAAO
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/LazyColorInput.tsx","../src/schemas/color.tsx","../src/schemas/hslaColor.ts","../src/schemas/hsvaColor.ts","../src/schemas/rgbaColor.ts","../src/index.ts"],"sourcesContent":["import {lazy} from 'react'\n\nexport const ColorInput = lazy(() => import('./ColorInput'))\n","import {defineType, type ObjectDefinition} from 'sanity'\n\nimport {ColorInput} from '../LazyColorInput'\nimport {type ColorOptions} from '../types'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nconst colorTypeName = 'color' as const\n\n/**\n * @public\n */\nexport interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {\n type: typeof colorTypeName\n options?: ColorOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n color: ColorDefinition\n }\n}\n\nexport const color = defineType({\n name: colorTypeName,\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n})\n","import {defineType} from 'sanity'\n\nexport const hslaColor = defineType({\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const hsvaColor = defineType({\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const rgbaColor = defineType({\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {definePlugin} from 'sanity'\n\nimport {color, type ColorDefinition} from './schemas/color'\nimport {hslaColor} from './schemas/hslaColor'\nimport {hsvaColor} from './schemas/hsvaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\n\nexport const colorInput = definePlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {color, hslaColor, hsvaColor, rgbaColor}\nexport {ColorInput} from './LazyColorInput'\nexport type {ColorDefinition}\nexport type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'\n"],"names":["lazy","defineType","jsx","definePlugin"],"mappings":";;;AAEO,MAAM,aAAaA,MAAAA,KAAK,MAAM,QAAA,QAAA,EAAA,KAAA,WAAA;AAAA,SAAA,QAAO,6BAAc;AAAC,CAAA,CAAA,GCGrD,QAAQ,CAAC,MAAc,MAAM,KAAK,MAAM,MAAM,GAAG,GAEjD,gBAAgB,SAiBT,QAAQC,OAAAA,WAAW;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,WAAU;AAAA,EAC9B,QAAQ;AAAA,IACN;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,EAEV;AAAA,EACA,SAAS;AAAA,IACP,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAMC;AACD,UAAI,WAAW,OAAO;AAClB,aAAA,QACF,WAAW,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,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MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,IAC1C,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,OAAM;AAAA,IACzC,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,EAAA;AAE9C,CAAC,GCLY,aAAaE,OAAAA,aAAa;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO,CAAC,WAAW,WAAW,WAAW,KAAK;AAAA,EAAA;AAElD,CAAC;;;;;;;"}
|
package/lib/index.mjs
CHANGED
|
@@ -54,8 +54,8 @@ const ColorInput = lazy(() => import("./_chunks-es/ColorInput.mjs")), round = (v
|
|
|
54
54
|
"div",
|
|
55
55
|
{
|
|
56
56
|
style: {
|
|
57
|
-
backgroundColor: hex
|
|
58
|
-
opacity: alpha
|
|
57
|
+
backgroundColor: hex ?? "#000",
|
|
58
|
+
opacity: alpha ?? 1,
|
|
59
59
|
position: "absolute",
|
|
60
60
|
height: "100%",
|
|
61
61
|
width: "100%",
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/LazyColorInput.tsx","../src/schemas/color.tsx","../src/schemas/hslaColor.ts","../src/schemas/hsvaColor.ts","../src/schemas/rgbaColor.ts","../src/index.ts"],"sourcesContent":["import {lazy} from 'react'\n\nexport const ColorInput = lazy(() => import('./ColorInput'))\n","import {defineType, type ObjectDefinition} from 'sanity'\n\nimport {ColorInput} from '../LazyColorInput'\nimport {type ColorOptions} from '../types'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nconst colorTypeName = 'color' as const\n\n/**\n * @public\n */\nexport interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {\n type: typeof colorTypeName\n options?: ColorOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n color: ColorDefinition\n }\n}\n\nexport const color = defineType({\n name: colorTypeName,\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n})\n","import {defineType} from 'sanity'\n\nexport const hslaColor = defineType({\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const hsvaColor = defineType({\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const rgbaColor = defineType({\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {definePlugin} from 'sanity'\n\nimport {color, type ColorDefinition} from './schemas/color'\nimport {hslaColor} from './schemas/hslaColor'\nimport {hsvaColor} from './schemas/hsvaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\n\nexport const colorInput = definePlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {color, hslaColor, hsvaColor, rgbaColor}\nexport {ColorInput} from './LazyColorInput'\nexport type {ColorDefinition}\nexport type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'\n"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,KAAK,MAAM,OAAO,6BAAc,CAAC,GCGrD,QAAQ,CAAC,MAAc,MAAM,KAAK,MAAM,MAAM,GAAG,GAEjD,gBAAgB,SAiBT,QAAQ,WAAW;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,WAAU;AAAA,EAC9B,QAAQ;AAAA,IACN;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,EAEV;AAAA,EACA,SAAS;AAAA,IACP,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAMC;AACD,UAAI,WAAW,OAAO;AAClB,aAAA,QACF,WAAW,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,KAAK,CAAC,KAE7E;AAAA,QACL;AAAA,QACA;AAAA,QACA,OAAO,MACL;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,iBAAiB,OAAO
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/LazyColorInput.tsx","../src/schemas/color.tsx","../src/schemas/hslaColor.ts","../src/schemas/hsvaColor.ts","../src/schemas/rgbaColor.ts","../src/index.ts"],"sourcesContent":["import {lazy} from 'react'\n\nexport const ColorInput = lazy(() => import('./ColorInput'))\n","import {defineType, type ObjectDefinition} from 'sanity'\n\nimport {ColorInput} from '../LazyColorInput'\nimport {type ColorOptions} from '../types'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nconst colorTypeName = 'color' as const\n\n/**\n * @public\n */\nexport interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {\n type: typeof colorTypeName\n options?: ColorOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n color: ColorDefinition\n }\n}\n\nexport const color = defineType({\n name: colorTypeName,\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n})\n","import {defineType} from 'sanity'\n\nexport const hslaColor = defineType({\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const hsvaColor = defineType({\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const rgbaColor = defineType({\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {definePlugin} from 'sanity'\n\nimport {color, type ColorDefinition} from './schemas/color'\nimport {hslaColor} from './schemas/hslaColor'\nimport {hsvaColor} from './schemas/hsvaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\n\nexport const colorInput = definePlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {color, hslaColor, hsvaColor, rgbaColor}\nexport {ColorInput} from './LazyColorInput'\nexport type {ColorDefinition}\nexport type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'\n"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,KAAK,MAAM,OAAO,6BAAc,CAAC,GCGrD,QAAQ,CAAC,MAAc,MAAM,KAAK,MAAM,MAAM,GAAG,GAEjD,gBAAgB,SAiBT,QAAQ,WAAW;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,WAAU;AAAA,EAC9B,QAAQ;AAAA,IACN;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,EAEV;AAAA,EACA,SAAS;AAAA,IACP,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAMC;AACD,UAAI,WAAW,OAAO;AAClB,aAAA,QACF,WAAW,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,MAAM,KAAK,CAAC,KAE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EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,EAAA;AAE9C,CAAC,GCLY,aAAa,aAAa;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO,CAAC,WAAW,WAAW,WAAW,KAAK;AAAA,EAAA;AAElD,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/color-input",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Color input",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@sanity/incompatible-plugin": "^1.0.5",
|
|
58
58
|
"@sanity/ui": "^2.10.10",
|
|
59
59
|
"react-color": "^2.19.3",
|
|
60
|
-
"use-effect-event": "^
|
|
60
|
+
"use-effect-event": "^2.0.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@commitlint/cli": "^19.5.0",
|
|
@@ -69,14 +69,13 @@
|
|
|
69
69
|
"@types/react": "^18.3.5",
|
|
70
70
|
"@types/react-color": "^2.17.11",
|
|
71
71
|
"@types/tinycolor2": "^1.4.6",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
73
|
-
"@typescript-eslint/parser": "^
|
|
74
|
-
"eslint": "^
|
|
75
|
-
"eslint-config-prettier": "^
|
|
76
|
-
"eslint-
|
|
77
|
-
"eslint-plugin-
|
|
78
|
-
"eslint-plugin-
|
|
79
|
-
"eslint-plugin-react-hooks": "^4.6.2",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.37.0",
|
|
74
|
+
"eslint": "^9.31.0",
|
|
75
|
+
"eslint-config-prettier": "^10.1.5",
|
|
76
|
+
"eslint-plugin-react": "^7.37.5",
|
|
77
|
+
"eslint-plugin-react-hooks": "0.0.0-experimental-dffacc7b-20250717",
|
|
78
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
80
79
|
"husky": "^8.0.1",
|
|
81
80
|
"lint-staged": "^13.0.3",
|
|
82
81
|
"npm-run-all2": "^5.0.0",
|
|
@@ -86,11 +85,12 @@
|
|
|
86
85
|
"sanity": "^3.67.1",
|
|
87
86
|
"semantic-release": "^24.1.1",
|
|
88
87
|
"styled-components": "^6.1",
|
|
89
|
-
"typescript": "^5.6.2"
|
|
88
|
+
"typescript": "^5.6.2",
|
|
89
|
+
"typescript-eslint": "^8.37.0"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"react": "^18.3 || ^19",
|
|
93
|
-
"sanity": "^3.23.0",
|
|
93
|
+
"sanity": "^3.23.0 || ^4.0.0-0",
|
|
94
94
|
"styled-components": "^6.1"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
@@ -102,5 +102,10 @@
|
|
|
102
102
|
"overrides": {
|
|
103
103
|
"conventional-changelog-conventionalcommits": ">= 8.0.0"
|
|
104
104
|
},
|
|
105
|
-
"sanityExchangeUrl": "https://www.sanity.io/plugins/color-input"
|
|
105
|
+
"sanityExchangeUrl": "https://www.sanity.io/plugins/color-input",
|
|
106
|
+
"sanityPlugin": {
|
|
107
|
+
"verifyPackage": {
|
|
108
|
+
"eslintImports": false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
106
111
|
}
|
package/src/ColorInput.tsx
CHANGED
|
@@ -54,7 +54,7 @@ export default function ColorInput(props: ObjectInputProps) {
|
|
|
54
54
|
if (!debouncedColor) return undefined
|
|
55
55
|
const raf = requestAnimationFrame(() => handleChange(debouncedColor))
|
|
56
56
|
return () => cancelAnimationFrame(raf)
|
|
57
|
-
}, [debouncedColor
|
|
57
|
+
}, [debouncedColor])
|
|
58
58
|
|
|
59
59
|
const handleCreateColor = useCallback(() => {
|
|
60
60
|
setColor(DEFAULT_COLOR)
|