@sanity/color-input 4.0.6 → 5.0.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/README.md +3 -20
- package/dist/_chunks-es/ColorInput.js +340 -0
- package/dist/_chunks-es/ColorInput.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -67
- package/lib/_chunks-cjs/ColorInput.js +0 -1041
- package/lib/_chunks-cjs/ColorInput.js.map +0 -1
- package/lib/_chunks-es/ColorInput.mjs +0 -1051
- package/lib/_chunks-es/ColorInput.mjs.map +0 -1
- package/lib/_legacy/ColorInput.esm.js +0 -1051
- package/lib/_legacy/ColorInput.esm.js.map +0 -1
- package/lib/index.d.mts +0 -93
- package/lib/index.d.ts +0 -93
- package/lib/index.esm.js +0 -114
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -114
- package/lib/index.js.map +0 -1
- package/lib/index.mjs +0 -114
- package/lib/index.mjs.map +0 -1
- package/sanity.json +0 -8
- package/src/ColorInput.tsx +0 -97
- package/src/ColorList.tsx +0 -70
- package/src/ColorPicker.tsx +0 -152
- package/src/ColorPickerFields.tsx +0 -144
- package/src/LazyColorInput.tsx +0 -3
- package/src/index.ts +0 -18
- package/src/schemas/color.tsx +0 -98
- package/src/schemas/hslaColor.ts +0 -13
- package/src/schemas/hsvaColor.ts +0 -13
- package/src/schemas/rgbaColor.ts +0 -13
- package/src/types.ts +0 -19
- package/v2-incompatible.js +0 -11
package/src/schemas/color.tsx
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {defineType, type ObjectDefinition} from 'sanity'
|
|
2
|
-
|
|
3
|
-
import {ColorInput} from '../LazyColorInput'
|
|
4
|
-
import {type ColorOptions} from '../types'
|
|
5
|
-
|
|
6
|
-
const round = (val: number = 1) => Math.round(val * 100)
|
|
7
|
-
|
|
8
|
-
const colorTypeName = 'color' as const
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {
|
|
14
|
-
type: typeof colorTypeName
|
|
15
|
-
options?: ColorOptions
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare module '@sanity/types' {
|
|
19
|
-
// makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember
|
|
20
|
-
export interface IntrinsicDefinitions {
|
|
21
|
-
color: ColorDefinition
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const color = defineType({
|
|
26
|
-
name: colorTypeName,
|
|
27
|
-
type: 'object',
|
|
28
|
-
title: 'Color',
|
|
29
|
-
components: {input: ColorInput},
|
|
30
|
-
fields: [
|
|
31
|
-
{
|
|
32
|
-
title: 'Hex',
|
|
33
|
-
name: 'hex',
|
|
34
|
-
type: 'string',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
title: 'Alpha',
|
|
38
|
-
name: 'alpha',
|
|
39
|
-
type: 'number',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: 'Hue Saturation Lightness',
|
|
43
|
-
name: 'hsl',
|
|
44
|
-
type: 'hslaColor',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
title: 'Hue Saturation Value',
|
|
48
|
-
name: 'hsv',
|
|
49
|
-
type: 'hsvaColor',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: 'Red Green Blue (rgb)',
|
|
53
|
-
name: 'rgb',
|
|
54
|
-
type: 'rgbaColor',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
preview: {
|
|
58
|
-
select: {
|
|
59
|
-
title: 'hex',
|
|
60
|
-
alpha: 'alpha',
|
|
61
|
-
hex: 'hex',
|
|
62
|
-
hsl: 'hsl',
|
|
63
|
-
},
|
|
64
|
-
prepare({
|
|
65
|
-
title,
|
|
66
|
-
hex,
|
|
67
|
-
hsl,
|
|
68
|
-
alpha,
|
|
69
|
-
}: {
|
|
70
|
-
title?: string
|
|
71
|
-
alpha?: number
|
|
72
|
-
hex?: string
|
|
73
|
-
hsl?: {h: number; s: number; l: number}
|
|
74
|
-
}) {
|
|
75
|
-
let subtitle = hex || 'No color set'
|
|
76
|
-
if (hsl) {
|
|
77
|
-
subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
title: title,
|
|
81
|
-
subtitle: subtitle,
|
|
82
|
-
media: () => (
|
|
83
|
-
<div
|
|
84
|
-
style={{
|
|
85
|
-
backgroundColor: hex ?? '#000',
|
|
86
|
-
opacity: alpha ?? 1,
|
|
87
|
-
position: 'absolute',
|
|
88
|
-
height: '100%',
|
|
89
|
-
width: '100%',
|
|
90
|
-
top: '0',
|
|
91
|
-
left: '0',
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
),
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
})
|
package/src/schemas/hslaColor.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {defineType} from 'sanity'
|
|
2
|
-
|
|
3
|
-
export const hslaColor = defineType({
|
|
4
|
-
title: 'Hue Saturation Lightness',
|
|
5
|
-
name: 'hslaColor',
|
|
6
|
-
type: 'object',
|
|
7
|
-
fields: [
|
|
8
|
-
{name: 'h', type: 'number', title: 'Hue'},
|
|
9
|
-
{name: 's', type: 'number', title: 'Saturation'},
|
|
10
|
-
{name: 'l', type: 'number', title: 'Lightness'},
|
|
11
|
-
{name: 'a', type: 'number', title: 'Alpha'},
|
|
12
|
-
],
|
|
13
|
-
})
|
package/src/schemas/hsvaColor.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {defineType} from 'sanity'
|
|
2
|
-
|
|
3
|
-
export const hsvaColor = defineType({
|
|
4
|
-
title: 'Hue Saturation Value',
|
|
5
|
-
name: 'hsvaColor',
|
|
6
|
-
type: 'object',
|
|
7
|
-
fields: [
|
|
8
|
-
{name: 'h', type: 'number', title: 'Hue'},
|
|
9
|
-
{name: 's', type: 'number', title: 'Saturation'},
|
|
10
|
-
{name: 'v', type: 'number', title: 'Value'},
|
|
11
|
-
{name: 'a', type: 'number', title: 'Alpha'},
|
|
12
|
-
],
|
|
13
|
-
})
|
package/src/schemas/rgbaColor.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {defineType} from 'sanity'
|
|
2
|
-
|
|
3
|
-
export const rgbaColor = defineType({
|
|
4
|
-
title: 'Red Green Blue (rgb)',
|
|
5
|
-
name: 'rgbaColor',
|
|
6
|
-
type: 'object',
|
|
7
|
-
fields: [
|
|
8
|
-
{name: 'r', type: 'number', title: 'Red'},
|
|
9
|
-
{name: 'g', type: 'number', title: 'Green'},
|
|
10
|
-
{name: 'b', type: 'number', title: 'Blue'},
|
|
11
|
-
{name: 'a', type: 'number', title: 'Alpha'},
|
|
12
|
-
],
|
|
13
|
-
})
|
package/src/types.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type {Color, HSLColor, HSVColor, RGBColor} from 'react-color'
|
|
2
|
-
import type {ObjectInputProps, ObjectOptions, ObjectSchemaType} from 'sanity'
|
|
3
|
-
|
|
4
|
-
export interface ColorValue {
|
|
5
|
-
hex: string
|
|
6
|
-
hsl: HSLColor
|
|
7
|
-
hsv: HSVColor
|
|
8
|
-
rgb: RGBColor
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ColorOptions extends Omit<ObjectOptions, 'columns'> {
|
|
12
|
-
disableAlpha?: boolean
|
|
13
|
-
colorList?: Array<Color>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type ColorSchemaType = Omit<ObjectSchemaType, 'options'> & {
|
|
17
|
-
options?: ColorOptions
|
|
18
|
-
}
|
|
19
|
-
export type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>
|
package/v2-incompatible.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const {showIncompatiblePluginDialog} = require('@sanity/incompatible-plugin')
|
|
2
|
-
const {name, version, sanityExchangeUrl} = require('./package.json')
|
|
3
|
-
|
|
4
|
-
export default showIncompatiblePluginDialog({
|
|
5
|
-
name: name,
|
|
6
|
-
versions: {
|
|
7
|
-
v3: version,
|
|
8
|
-
v2: '^2.30.0',
|
|
9
|
-
},
|
|
10
|
-
sanityExchangeUrl,
|
|
11
|
-
})
|