@sanity/color-input 2.35.2 → 2.36.0-v2-studio.1
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/.eslintrc.js +25 -0
- package/.github/workflows/main.yml +133 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc +8 -0
- package/.releaserc.json +4 -0
- package/.semantic-release/sanity-color-input-2.36.0-v2-studio.1.tgz +0 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE +1 -1
- package/README.md +11 -1
- package/assets/color-input.png +0 -0
- package/assets/no-alpha.png +0 -0
- package/commitlint.config.js +3 -0
- package/lib/ColorInput.js +5 -4
- package/lib/ColorInput.js.map +1 -0
- package/lib/ColorPicker.js +2 -1
- package/lib/ColorPicker.js.map +1 -0
- package/lib/ColorPickerFields.js +2 -1
- package/lib/ColorPickerFields.js.map +1 -0
- package/lib/schemas/color.js +2 -1
- package/lib/schemas/color.js.map +1 -0
- package/lib/schemas/hslaColor.js +2 -1
- package/lib/schemas/hslaColor.js.map +1 -0
- package/lib/schemas/hsvaColor.js +2 -1
- package/lib/schemas/hsvaColor.js.map +1 -0
- package/lib/schemas/rgbaColor.js +2 -1
- package/lib/schemas/rgbaColor.js.map +1 -0
- package/lint-staged.config.js +4 -0
- package/package.json +38 -20
- package/sanity.json +2 -2
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: '@babel/eslint-parser',
|
|
4
|
+
globals: {
|
|
5
|
+
__DEV__: true,
|
|
6
|
+
JSX: true,
|
|
7
|
+
},
|
|
8
|
+
env: {
|
|
9
|
+
node: true,
|
|
10
|
+
browser: true,
|
|
11
|
+
},
|
|
12
|
+
settings: {
|
|
13
|
+
react: {version: '16.9.0'},
|
|
14
|
+
},
|
|
15
|
+
extends: ['sanity', 'sanity/react', 'plugin:react-hooks/recommended', 'prettier'],
|
|
16
|
+
rules: {
|
|
17
|
+
camelcase: ['error', {allow: ['^unstable_', '^Unstable_']}],
|
|
18
|
+
'prettier/prettier': 'error',
|
|
19
|
+
'react/prop-types': 'off',
|
|
20
|
+
'react/forbid-prop-types': 'off',
|
|
21
|
+
'react/jsx-no-bind': 'off',
|
|
22
|
+
'react/require-default-props': 'off',
|
|
23
|
+
},
|
|
24
|
+
plugins: ['prettier', 'react'],
|
|
25
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CI & Release
|
|
3
|
+
|
|
4
|
+
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
|
|
5
|
+
run-name: >-
|
|
6
|
+
${{
|
|
7
|
+
inputs.release && inputs.test && format('Build {0} ➤ Test ➤ Publish to NPM', github.ref_name) ||
|
|
8
|
+
inputs.release && !inputs.test && format('Build {0} ➤ Skip Tests ➤ Publish to NPM', github.ref_name) ||
|
|
9
|
+
github.event_name == 'workflow_dispatch' && inputs.test && format('Build {0} ➤ Test', github.ref_name) ||
|
|
10
|
+
github.event_name == 'workflow_dispatch' && !inputs.test && format('Build {0} ➤ Skip Tests', github.ref_name) ||
|
|
11
|
+
''
|
|
12
|
+
}}
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
# Build on pushes branches that have a PR (including drafts)
|
|
16
|
+
pull_request:
|
|
17
|
+
# Build on commits pushed to branches without a PR if it's in the allowlist
|
|
18
|
+
push:
|
|
19
|
+
branches: [main,studio-v2]
|
|
20
|
+
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
|
|
21
|
+
workflow_dispatch:
|
|
22
|
+
inputs:
|
|
23
|
+
test:
|
|
24
|
+
description: Run tests
|
|
25
|
+
required: true
|
|
26
|
+
default: true
|
|
27
|
+
type: boolean
|
|
28
|
+
release:
|
|
29
|
+
description: Release new version
|
|
30
|
+
required: true
|
|
31
|
+
default: false
|
|
32
|
+
type: boolean
|
|
33
|
+
|
|
34
|
+
concurrency:
|
|
35
|
+
# On PRs builds will cancel if new pushes happen before the CI completes, as it defines `github.head_ref` and gives it the name of the branch the PR wants to merge into
|
|
36
|
+
# Otherwise `github.run_id` ensures that you can quickly merge a queue of PRs without causing tests to auto cancel on any of the commits pushed to main.
|
|
37
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
38
|
+
cancel-in-progress: true
|
|
39
|
+
|
|
40
|
+
jobs:
|
|
41
|
+
log-the-inputs:
|
|
42
|
+
name: Log inputs
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
steps:
|
|
45
|
+
- run: |
|
|
46
|
+
echo "Inputs: $INPUTS"
|
|
47
|
+
env:
|
|
48
|
+
INPUTS: ${{ toJSON(inputs) }}
|
|
49
|
+
|
|
50
|
+
build:
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
name: Lint & Build
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
|
|
55
|
+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
|
|
56
|
+
with:
|
|
57
|
+
cache: npm
|
|
58
|
+
node-version: lts/*
|
|
59
|
+
- run: npm ci
|
|
60
|
+
# Linting can be skipped
|
|
61
|
+
- run: npm run lint --if-present
|
|
62
|
+
if: github.event.inputs.test != 'false'
|
|
63
|
+
# But not the build script, as semantic-release will crash if this command fails so it makes sense to test it early
|
|
64
|
+
- run: npm run prepublishOnly --if-present
|
|
65
|
+
|
|
66
|
+
# test:
|
|
67
|
+
# needs: build
|
|
68
|
+
# # The test matrix can be skipped, in case a new release needs to be fast-tracked and tests are already passing on main
|
|
69
|
+
# if: github.event.inputs.test != 'false'
|
|
70
|
+
# runs-on: ${{ matrix.os }}
|
|
71
|
+
# name: Node.js ${{ matrix.node }} / ${{ matrix.os }}
|
|
72
|
+
# strategy:
|
|
73
|
+
# # A test failing on windows doesn't mean it'll fail on macos. It's useful to let all tests run to its completion to get the full picture
|
|
74
|
+
# fail-fast: false
|
|
75
|
+
# matrix:
|
|
76
|
+
# # Run the testing suite on each major OS with the latest LTS release of Node.js
|
|
77
|
+
# os: [macos-latest, ubuntu-latest, windows-latest]
|
|
78
|
+
# node: [lts/*]
|
|
79
|
+
# # It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
|
|
80
|
+
# include:
|
|
81
|
+
# - os: ubuntu-latest
|
|
82
|
+
# # Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
|
|
83
|
+
# node: lts/-2
|
|
84
|
+
# - os: ubuntu-latest
|
|
85
|
+
# # Test the actively developed version that will become the latest LTS release next October
|
|
86
|
+
# node: current
|
|
87
|
+
# steps:
|
|
88
|
+
# # It's only necessary to do this for windows, as mac and ubuntu are sane OS's that already use LF
|
|
89
|
+
# - name: Set git to use LF
|
|
90
|
+
# if: matrix.os == 'windows-latest'
|
|
91
|
+
# run: |
|
|
92
|
+
# git config --global core.autocrlf false
|
|
93
|
+
# git config --global core.eol lf
|
|
94
|
+
# - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
|
|
95
|
+
# - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
|
|
96
|
+
# with:
|
|
97
|
+
# cache: npm
|
|
98
|
+
# node-version: ${{ matrix.node }}
|
|
99
|
+
# - run: npm i
|
|
100
|
+
# - run: npm test --if-present
|
|
101
|
+
|
|
102
|
+
release:
|
|
103
|
+
# needs: [build, test]
|
|
104
|
+
needs: [build]
|
|
105
|
+
# only run if opt-in during workflow_dispatch
|
|
106
|
+
if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
|
|
107
|
+
runs-on: ubuntu-latest
|
|
108
|
+
name: Semantic release
|
|
109
|
+
steps:
|
|
110
|
+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
|
|
111
|
+
with:
|
|
112
|
+
# Need to fetch entire commit history to
|
|
113
|
+
# analyze every commit since last release
|
|
114
|
+
fetch-depth: 0
|
|
115
|
+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
|
|
116
|
+
with:
|
|
117
|
+
cache: npm
|
|
118
|
+
node-version: lts/*
|
|
119
|
+
- run: npm ci
|
|
120
|
+
# Branches that will release new versions are defined in .releaserc.json
|
|
121
|
+
- run: npx semantic-release
|
|
122
|
+
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
|
|
123
|
+
# e.g. git tags were pushed but it exited before `npm publish`
|
|
124
|
+
if: always()
|
|
125
|
+
env:
|
|
126
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
127
|
+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
|
128
|
+
# Re-run semantic release with rich logs if it failed to publish for easier debugging
|
|
129
|
+
- run: npx semantic-release --dry-run --debug
|
|
130
|
+
if: failure()
|
|
131
|
+
env:
|
|
132
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
133
|
+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
package/.prettierrc
ADDED
package/.releaserc.json
ADDED
|
Binary file
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!-- markdownlint-disable --><!-- textlint-disable -->
|
|
2
|
+
|
|
3
|
+
# 📓 Changelog
|
|
4
|
+
|
|
5
|
+
All notable changes to this project will be documented in this file. See
|
|
6
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
|
+
|
|
8
|
+
## [2.36.0-v2-studio.1](https://github.com/sanity-io/color-input/compare/v2.35.2...v2.36.0-v2-studio.1) (2022-11-23)
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- @sanity/color-input (standalone) for Sanity Studio v2 ([d3a8655](https://github.com/sanity-io/color-input/commit/d3a8655747e6e52c4f09486ea7970b029f80b860))
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# @sanity/color-input
|
|
2
2
|
|
|
3
|
+
> This is a **Sanity Studio v2** plugin.
|
|
4
|
+
> For the v3 version, please refer to the [v3-branch](https://github.com/sanity-io/color-input).
|
|
5
|
+
|
|
3
6
|
Color input for [Sanity](https://sanity.io/) that stores selected colors in hex, hsl, hsv and rgb format.
|
|
4
7
|
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
10
|
+
```sh
|
|
11
|
+
yarn add @sanity/color-input@studio-v2
|
|
7
12
|
```
|
|
8
|
-
|
|
13
|
+
|
|
14
|
+
Next, add `"@sanity/color-input"` to `sanity.json` plugins array:
|
|
15
|
+
```json
|
|
16
|
+
"plugins": [
|
|
17
|
+
@sanity/color-input
|
|
18
|
+
]
|
|
9
19
|
```
|
|
10
20
|
|
|
11
21
|
## Usage
|
|
Binary file
|
|
Binary file
|
package/lib/ColorInput.js
CHANGED
|
@@ -4,17 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
9
|
var _formBuilder = require("part:@sanity/form-builder");
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
11
|
var _ui = require("@sanity/ui");
|
|
12
12
|
var _icons = require("@sanity/icons");
|
|
13
13
|
var _components = require("@sanity/base/components");
|
|
14
14
|
var _ColorPicker = _interopRequireDefault(require("./ColorPicker"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
19
|
var set = _formBuilder.patches.set,
|
|
20
20
|
unset = _formBuilder.patches.unset,
|
|
@@ -60,7 +60,7 @@ class ColorInput extends _react.PureComponent {
|
|
|
60
60
|
_type: type.name
|
|
61
61
|
}), set(type.name, ['_type']), set(nextColor.rgb.a, ['alpha']), ...fieldPatches]));
|
|
62
62
|
});
|
|
63
|
-
_defineProperty(this, "handleColorChange", (0,
|
|
63
|
+
_defineProperty(this, "handleColorChange", (0, _lodash.debounce)(this.emitSetColor, 100));
|
|
64
64
|
_defineProperty(this, "handleCreateColor", () => {
|
|
65
65
|
this.emitSetColor(DEFAULT_COLOR);
|
|
66
66
|
});
|
|
@@ -117,4 +117,5 @@ _defineProperty(ColorInput, "propTypes", {
|
|
|
117
117
|
hex: _propTypes.default.string,
|
|
118
118
|
alpha: _propTypes.default.number
|
|
119
119
|
})
|
|
120
|
-
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=ColorInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorInput.js","names":["set","patches","unset","setIfMissing","DEFAULT_COLOR","hex","hsl","h","s","l","a","hsv","v","rgb","r","g","b","source","ColorInput","PureComponent","React","createRef","nextColor","props","onChange","type","fieldPatches","fields","filter","field","name","map","nextFieldValue","isObject","jsonType","Object","assign","_type","PatchEvent","from","debounce","emitSetColor","focus","focusRef","current","render","readOnly","value","level","title","description","handleColorChange","options","disableAlpha","handleUnset","AddIcon","Boolean","handleCreateColor","PropTypes","shape","string","arrayOf","isRequired","func","bool","alpha","number"],"sources":["../src/ColorInput.js"],"sourcesContent":["///<reference types=\"@sanity/types/parts\" />\n\n/* eslint-disable id-length */\nimport React, {PureComponent} from 'react'\nimport PropTypes from 'prop-types'\nimport {PatchEvent, patches} from 'part:@sanity/form-builder'\nimport {debounce} from 'lodash'\nimport {Button} from '@sanity/ui'\nimport {AddIcon} from '@sanity/icons'\nimport {FormField} from '@sanity/base/components'\nimport ColorPicker from './ColorPicker'\n\nconst {set, unset, setIfMissing} = patches\n\nconst DEFAULT_COLOR = {\n hex: '#24a3e3',\n hsl: {h: 200, s: 0.7732, l: 0.5156, a: 1},\n hsv: {h: 200, s: 0.8414, v: 0.8901, a: 1},\n rgb: {r: 46, g: 163, b: 227, a: 1},\n source: 'hex',\n}\n\nexport default class ColorInput extends PureComponent {\n focusRef = React.createRef()\n static propTypes = {\n type: PropTypes.shape({\n name: PropTypes.string,\n title: PropTypes.string,\n description: PropTypes.string,\n fields: PropTypes.arrayOf(\n PropTypes.shape({\n name: PropTypes.string.isRequired,\n })\n ),\n }).isRequired,\n onChange: PropTypes.func.isRequired,\n readOnly: PropTypes.bool,\n value: PropTypes.shape({\n hex: PropTypes.string,\n alpha: PropTypes.number,\n }),\n }\n\n focus() {\n // todo: make the ColorPicker component support .focus()\n if (this.focusRef.current && this.focusRef.current.focus) {\n this.focusRef.current.focus()\n }\n }\n\n emitSetColor = (nextColor) => {\n const {onChange, type} = this.props\n\n const fieldPatches = type.fields\n .filter((field) => field.name in nextColor)\n .map((field) => {\n const nextFieldValue = nextColor[field.name]\n const isObject = field.type.jsonType === 'object'\n return set(\n isObject ? Object.assign({_type: field.type.name}, nextFieldValue) : nextFieldValue,\n [field.name]\n )\n })\n\n onChange(\n PatchEvent.from([\n setIfMissing({_type: type.name}),\n set(type.name, ['_type']),\n set(nextColor.rgb.a, ['alpha']),\n ...fieldPatches,\n ])\n )\n }\n\n // The color picker emits onChange events continuously while the user is sliding the\n // hue/saturation/alpha selectors. This debounces the event to avoid excessive patches\n handleColorChange = debounce(this.emitSetColor, 100)\n\n handleCreateColor = () => {\n this.emitSetColor(DEFAULT_COLOR)\n }\n\n handleUnset = () => {\n this.props.onChange(PatchEvent.from(unset()))\n }\n\n render() {\n const {type, readOnly, value, level} = this.props\n return (\n <FormField title={type.title} description={type.description} level={level}>\n {value ? (\n <ColorPicker\n ref={this.focusRef}\n color={value.hsl || value.hex}\n readOnly={readOnly || type.readOnly}\n onChange={this.handleColorChange}\n disableAlpha={type.options && type.options.disableAlpha}\n onUnset={this.handleUnset}\n />\n ) : (\n <Button\n icon={AddIcon}\n mode=\"ghost\"\n text=\"Create color\"\n ref={this.focusRef}\n disabled={Boolean(readOnly)}\n onClick={this.handleCreateColor}\n />\n )}\n </FormField>\n )\n }\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAuC;AAAA;AAAA;AAAA;AAEvC,IAAOA,GAAG,GAAyBC,oBAAO,CAAnCD,GAAG;EAAEE,KAAK,GAAkBD,oBAAO,CAA9BC,KAAK;EAAEC,YAAY,GAAIF,oBAAO,CAAvBE,YAAY;AAE/B,IAAMC,aAAa,GAAG;EACpBC,GAAG,EAAE,SAAS;EACdC,GAAG,EAAE;IAACC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AC2B,OAAO,CAACC,YAAa;MACxD,OAAO,EAAE,IAAI,CAACC;IAAY,EAC1B,gBAEF,6BAAC,UAAM;MACL,IAAI,EAAEC,cAAQ;MACd,IAAI,EAAC,OAAO;MACZ,IAAI,EAAC,cAAc;MACnB,GAAG,EAAE,IAAI,CAACZ,QAAS;MACnB,QAAQ,EAAEa,OAAO,CAACV,QAAQ,CAAE;MAC5B,OAAO,EAAE,IAAI,CAACW;IAAkB,EAEnC,CACS;EAEhB;AACF;AAAC;AAAA,gBA1FoBvC,UAAU,eAEV;EACjBO,IAAI,EAAEiC,kBAAS,CAACC,KAAK,CAAC;IACpB7B,IAAI,EAAE4B,kBAAS,CAACE,MAAM;IACtBX,KAAK,EAAES,kBAAS,CAACE,MAAM;IACvBV,WAAW,EAAEQ,kBAAS,CAACE,MAAM;IAC7BjC,MAAM,EAAE+B,kBAAS,CAACG,OAAO,CACvBH,kBAAS,CAACC,KAAK,CAAC;MACd7B,IAAI,EAAE4B,kBAAS,CAACE,MAAM,CAACE;IACzB,CAAC,CAAC;EAEN,CAAC,CAAC,CAACA,UAAU;EACbtC,QAAQ,EAAEkC,kBAAS,CAACK,IAAI,CAACD,UAAU;EACnChB,QAAQ,EAAEY,kBAAS,CAACM,IAAI;EACxBjB,KAAK,EAAEW,kBAAS,CAACC,KAAK,CAAC;IACrBtD,GAAG,EAAEqD,kBAAS,CAACE,MAAM;IACrBK,KAAK,EAAEP,kBAAS,CAACQ;EACnB,CAAC;AACH,CAAC"}
|
package/lib/ColorPicker.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPicker.js","names":["ColorBox","styled","Box","ReadOnlyContainer","Flex","ColorPicker","width","rgb","hex","hsv","hsl","onChange","onUnset","disableAlpha","renderers","readOnly","position","height","minWidth","backgroundColor","r","g","b","a","Math","round","h","s","l","TrashIcon","propTypes","PropTypes","string","object","func","bool","defaultProps","ColorWrap"],"sources":["../src/ColorPicker.js"],"sourcesContent":["import React from 'react'\nimport PropTypes from 'prop-types'\nimport {ColorWrap, Checkboard, Saturation, Hue, Alpha} from 'react-color/lib/components/common'\nimport {Box, Card, Flex, Button, Inline, Stack, Text} from '@sanity/ui'\nimport {TrashIcon} from '@sanity/icons'\nimport styled from 'styled-components'\nimport {ColorPickerFields} from './ColorPickerFields'\n\nconst ColorBox = styled(Box)`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n`\n\nconst ReadOnlyContainer = styled(Flex)`\n margin-top: 6rem;\n background-color: var(--card-bg-color);\n position: relative;\n width: 100%;\n`\n\nconst ColorPicker = ({\n width,\n rgb,\n hex,\n hsv,\n hsl,\n onChange,\n onUnset,\n disableAlpha,\n renderers,\n readOnly,\n}) => {\n return (\n <div style={{width}}>\n <Card padding={1} border radius={1}>\n <Stack space={2}>\n {!readOnly && (\n <>\n <Card overflow=\"hidden\" style={{position: 'relative', height: '5em'}}>\n <Saturation is=\"Saturation\" onChange={onChange} hsl={hsl} hsv={hsv} />\n </Card>\n\n <Card\n shadow={1}\n radius={3}\n overflow=\"hidden\"\n style={{position: 'relative', height: '10px'}}\n >\n <Hue is=\"Hue\" hsl={hsl} onChange={!readOnly && onChange} />\n </Card>\n\n {!disableAlpha && (\n <Card\n shadow={1}\n radius={3}\n overflow=\"hidden\"\n style={{position: 'relative', height: '10px'}}\n >\n <Alpha is=\"Alpha\" rgb={rgb} hsl={hsl} renderers={renderers} onChange={onChange} />\n </Card>\n )}\n </>\n )}\n <Flex>\n <Card\n flex={1}\n radius={2}\n overflow=\"hidden\"\n style={{position: 'relative', minWidth: '4em'}}\n >\n <Checkboard />\n <ColorBox style={{backgroundColor: `rgba(${rgb.r},${rgb.g},${rgb.b},${rgb.a})`}} />\n\n {readOnly && (\n <ReadOnlyContainer\n padding={2}\n paddingBottom={1}\n sizing=\"border\"\n justify=\"space-between\"\n >\n <Stack space={3} marginTop={1}>\n <Text size={3} weight=\"bold\">\n {hex}\n </Text>\n\n <Inline space={3}>\n <Text size={1}>\n <strong>RGB: </strong>\n {rgb.r} {rgb.g} {rgb.b}\n </Text>\n <Text size={1}>\n <strong>HSL: </strong> {Math.round(hsl.h)} {Math.round(hsl.s)}%{' '}\n {Math.round(hsl.l)}\n </Text>\n </Inline>\n </Stack>\n </ReadOnlyContainer>\n )}\n </Card>\n\n {!readOnly && (\n <Flex align=\"flex-start\" marginLeft={2}>\n <Box style={{width: 200}}>\n <ColorPickerFields\n rgb={rgb}\n hsl={hsl}\n hex={hex}\n onChange={onChange}\n disableAlpha={disableAlpha}\n />\n </Box>\n <Box marginLeft={2}>\n <Button onClick={onUnset} title=\"Delete color\" icon={TrashIcon} tone=\"critical\" />\n </Box>\n </Flex>\n )}\n </Flex>\n </Stack>\n </Card>\n </div>\n )\n}\n\nColorPicker.propTypes = {\n width: PropTypes.string,\n hex: PropTypes.string,\n hsl: PropTypes.object,\n hsv: PropTypes.object,\n rgb: PropTypes.object,\n onChange: PropTypes.func,\n disableAlpha: PropTypes.bool,\n readOnly: PropTypes.bool,\n renderers: PropTypes.func,\n onUnset: PropTypes.func,\n}\n\nColorPicker.defaultProps = {\n disableAlpha: false,\n}\n\nexport default ColorWrap(ColorPicker)\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAqD;AAAA;AAAA;AAErD,IAAMA,QAAQ,GAAG,IAAAC,yBAAM,EAACC,OAAG,CAAC,sJAM3B;AAED,IAAMC,iBAAiB,GAAG,IAAAF,yBAAM,EAACG,QAAI,CAAC,gLAKrC;AAED,IAAMC,WAAW,GAAG,QAWd;EAAA,IAVJC,KAAK,QAALA,KAAK;IACLC,GAAG,QAAHA,GAAG;IACHC,GAAG,QAAHA,GAAG;IACHC,GAAG,QAAHA,GAAG;IACHC,GAAG,QAAHA,GAAG;IACHC,QAAQ,QAARA,QAAQ;IACRC,OAAO,QAAPA,OAAO;IACPC,YAAY,QAAZA,YAAY;IACZC,SAAS,QAATA,SAAS;IACTC,QAAQ,QAARA,QAAQ;EAER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IACT,QAAQ,EAAEG,QAAS;IACnB,YAAY,EAAEE;EAAa,EAC3B,CACE,eACN,6BAAC,OAAG;IAAC,UAAU,EAAE;EAAE,gBACjB,6BAAC,UAAM;IAAC,OAAO,EAAED,OAAQ;IAAC,KAAK,EAAC,cAAc;IAAC,IAAI,EAAEiB,gBAAU;IAAC,IAAI,EAAC;EAAU,EAAG,CAC9E,CAET,CACI,CACD,CACH,CACH;AAEV,CAAC;AAEDxB,WAAW,CAACyB,SAAS,GAAG;EACtBxB,KAAK,EAAEyB,kBAAS,CAACC,MAAM;EACvBxB,GAAG,EAAEuB,kBAAS,CAACC,MAAM;EACrBtB,GAAG,EAAEqB,kBAAS,CAACE,MAAM;EACrBxB,GAAG,EAAEsB,kBAAS,CAACE,MAAM;EACrB1B,GAAG,EAAEwB,kBAAS,CAACE,MAAM;EACrBtB,QAAQ,EAAEoB,kBAAS,CAACG,IAAI;EACxBrB,YAAY,EAAEkB,kBAAS,CAACI,IAAI;EAC5BpB,QAAQ,EAAEgB,kBAAS,CAACI,IAAI;EACxBrB,SAAS,EAAEiB,kBAAS,CAACG,IAAI;EACzBtB,OAAO,EAAEmB,kBAAS,CAACG;AACrB,CAAC;AAED7B,WAAW,CAAC+B,YAAY,GAAG;EACzBvB,YAAY,EAAE;AAChB,CAAC;AAAA,eAEc,IAAAwB,iBAAS,EAAChC,WAAW,CAAC;AAAA"}
|
package/lib/ColorPickerFields.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerFields.js","names":["ColorPickerFields","onChange","rgb","hsl","hex","disableAlpha","useTheme","sanity","inputStyles","input","width","padding","border","boxShadow","color","default","enabled","fg","backgroundColor","bg","fontSize","fonts","text","sizes","textAlign","label","display","base","paddingTop","paddingBottom","textTransform","handleChange","data","e","isValidHex","source","r","g","b","a","h","s","l","replace","Math","round"],"sources":["../src/ColorPickerFields.js"],"sourcesContent":["import React from 'react'\nimport * as color from 'react-color/lib/helpers/color'\nimport {EditableInput} from 'react-color/lib/components/common'\nimport {Box, Flex, useTheme} from '@sanity/ui'\n\nexport const ColorPickerFields = ({onChange, rgb, hsl, hex, disableAlpha}) => {\n const {sanity} = useTheme()\n\n const inputStyles = {\n input: {\n width: '80%',\n padding: '4px 10% 3px',\n border: 'none',\n boxShadow: `inset 0 0 0 1px ${sanity.color.input.default.enabled.border}`,\n color: sanity.color.input.default.enabled.fg,\n backgroundColor: sanity.color.input.default.enabled.bg,\n fontSize: sanity.fonts.text.sizes[0].fontSize,\n textAlign: 'center',\n },\n label: {\n display: 'block',\n textAlign: 'center',\n fontSize: sanity.fonts.label.sizes[0].fontSize,\n color: sanity.color.base.fg,\n paddingTop: '3px',\n paddingBottom: '4px',\n textTransform: 'capitalize',\n },\n }\n\n const handleChange = (data, e) => {\n if (data.hex && color.isValidHex(data.hex)) {\n onChange(\n {\n hex: data.hex,\n source: 'hex',\n },\n e\n )\n } else if (data.r || data.g || data.b) {\n onChange(\n {\n r: data.r || rgb.r,\n g: data.g || rgb.g,\n b: data.b || rgb.b,\n a: rgb.a,\n source: 'rgb',\n },\n e\n )\n } else if (data.a) {\n if (data.a < 0) {\n data.a = 0\n } else if (data.a > 100) {\n data.a = 100\n }\n\n data.a /= 100\n onChange(\n {\n h: hsl.h,\n s: hsl.s,\n l: hsl.l,\n a: data.a,\n source: 'rgb',\n },\n e\n )\n }\n }\n\n return (\n <Flex>\n <Box flex={2} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"hex\"\n value={hex.replace('#', '')}\n onChange={handleChange}\n />\n </Box>\n <Box flex={1} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"r\"\n value={rgb.r}\n onChange={handleChange}\n dragLabel=\"true\"\n dragMax=\"255\"\n />\n </Box>\n <Box flex={1} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"g\"\n value={rgb.g}\n onChange={handleChange}\n dragLabel=\"true\"\n dragMax=\"255\"\n />\n </Box>\n <Box flex={1} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"b\"\n value={rgb.b}\n onChange={handleChange}\n dragLabel=\"true\"\n dragMax=\"255\"\n />\n </Box>\n {!disableAlpha && (\n <Box flex={1}>\n <EditableInput\n style={inputStyles}\n label=\"a\"\n value={Math.round(rgb.a * 100)}\n onChange={handleChange}\n dragLabel=\"true\"\n dragMax=\"100\"\n />\n </Box>\n )}\n </Flex>\n )\n}\n\nexport default ColorPickerFields\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAA8C;AAAA;AAAA;AAEvC,IAAMA,iBAAiB,GAAG,QAA6C;EAAA,IAA3CC,QAAQ,QAARA,QAAQ;IAAEC,GAAG,QAAHA,GAAG;IAAEC,GAAG,QAAHA,GAAG;IAAEC,GAAG,QAAHA,GAAG;IAAEC,YAAY,QAAZA,YAAY;EACtE,gBAAiB,IAAAC,YAAQ,GAAE;IAApBC,MAAM,aAANA,MAAM;EAEb,IAAMC,WAAW,GAAG;IAClBC,KAAK,EAAE;MACLC,KAAK,EAAE,KAAK;MACZC,OAAO,EAAE,aAAa;MACtBC,MAAM,EAAE,MAAM;MACdC,SAAS,4BAAqBN,MAAM,CAACO,KAAK,CAACL,KAAK,CAACM,OAAO,CAACC,OAAO,CAACJ,MAAM,CAAE;MACzEE,KAAK,EAAEP,MAAM,CAACO,KAAK,CAACL,KAAK,CAACM,OAAO,CAACC,OAAO,CAACC,EAAE;MAC5CC,eAAe,EAAEX,MAAM,CAACO,KAAK,CAACL,KAAK,CAACM,OAAO,CAACC,OAAO,CAACG,EAAE;MACtDC,QAAQ,EAAEb,MAAM,CAACc,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAACH,QAAQ;MAC7CI,SAAS,EAAE;IACb,CAAC;IACDC,KAAK,EAAE;MACLC,OAAO,EAAE,OAAO;MAChBF,SAAS,EAAE,QAAQ;MACnBJ,QAAQ,EAAEb,MAAM,CAACc,KAAK,CAACI,KAAK,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC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AC,qBAAa;IACZ,KAAK,EAAEG,WAAY;IACnB,KAAK,EAAC,GAAG;IACT,KAAK,EAAEoC,IAAI,CAACC,KAAK,CAAC3C,GAAG,CAACqC,CAAC,GAAG,GAAG,CAAE;IAC/B,QAAQ,EAAER,YAAa;IACvB,SAAS,EAAC,MAAM;IAChB,OAAO,EAAC;EAAK,EACb,CAEL,CACI;AAEX,CAAC;AAAA;AAAA,eAEc/B,iBAAiB;AAAA"}
|
package/lib/schemas/color.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","names":["round","val","Math","name","type","title","inputComponent","ColorInput","fields","preview","select","alpha","hex","hsl","prepare","subtitle","l","media","backgroundColor","opacity","position","height","width","top","left"],"sources":["../../src/schemas/color.js"],"sourcesContent":["/* eslint-disable react/display-name */\nimport React from 'react'\nimport ColorInput from '../ColorInput'\n\nconst round = (val) => Math.round(val * 100)\n\nexport default {\n name: 'color',\n type: 'object',\n title: 'Color',\n inputComponent: 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({title, hex, hsl, alpha}) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.l)} S:${round(hsl.l)} 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 },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OAAO;QACLN,KAAK,EAAEA,KAAK;QACZU,QAAQ,EAAEA,QAAQ;QAClBE,KAAK,EAAE,mBACL;UACE,KAAK,EAAE;YACLC,eAAe,EAAEN,GAAG,IAAI,MAAM;YAC9BO,OAAO,EAAER,KAAK,IAAI,CAAC;YACnBS,QAAQ,EAAE,UAAU;YACpBC,MAAM,EAAE,MAAM;YACdC,KAAK,EAAE,MAAM;YACbC,GAAG,EAAE,GAAG;YACRC,IAAI,EAAE;UACR;QAAE;MAGR,CAAC;IACH;EACF;AACF,CAAC;AAAA"}
|
package/lib/schemas/hslaColor.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hslaColor.js","names":["title","name","type","fields"],"sources":["../../src/schemas/hslaColor.js"],"sourcesContent":["export default {\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"],"mappings":";;;;;;eAAe;EACbA,KAAK,EAAE,0BAA0B;EACjCC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,CACN;IAACF,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAK,CAAC,EACzC;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAY,CAAC,EAChD;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAW,CAAC,EAC/C;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAO,CAAC;AAE/C,CAAC;AAAA"}
|
package/lib/schemas/hsvaColor.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hsvaColor.js","names":["title","name","type","fields"],"sources":["../../src/schemas/hsvaColor.js"],"sourcesContent":["export default {\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"],"mappings":";;;;;;eAAe;EACbA,KAAK,EAAE,sBAAsB;EAC7BC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,CACN;IAACF,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAK,CAAC,EACzC;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAY,CAAC,EAChD;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAO,CAAC,EAC3C;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAO,CAAC;AAE/C,CAAC;AAAA"}
|
package/lib/schemas/rgbaColor.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rgbaColor.js","names":["title","name","type","fields"],"sources":["../../src/schemas/rgbaColor.js"],"sourcesContent":["export default {\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"],"mappings":";;;;;;eAAe;EACbA,KAAK,EAAE,sBAAsB;EAC7BC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,CACN;IAACF,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAK,CAAC,EACzC;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAO,CAAC,EAC3C;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAM,CAAC,EAC1C;IAACC,IAAI,EAAE,GAAG;IAAEC,IAAI,EAAE,QAAQ;IAAEF,KAAK,EAAE;EAAO,CAAC;AAE/C,CAAC;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/color-input",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Color input",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"author": "Sanity.io <hello@sanity.io>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"clean": "rimraf lib dest"
|
|
10
|
-
},
|
|
3
|
+
"version": "2.36.0-v2-studio.1",
|
|
4
|
+
"description": "Color input for Sanity Studio",
|
|
11
5
|
"keywords": [
|
|
12
6
|
"sanity",
|
|
13
7
|
"cms",
|
|
@@ -17,6 +11,26 @@
|
|
|
17
11
|
"color-input",
|
|
18
12
|
"sanity-plugin"
|
|
19
13
|
],
|
|
14
|
+
"homepage": "https://www.sanity.io/",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "git@github.com:sanity-io//issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git@github.com:sanity-io/color-input.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
24
|
+
"main": "lib/schemas/color.js",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prebuild": "npm run clean",
|
|
27
|
+
"build": "sanipack build",
|
|
28
|
+
"clean": "rimraf lib",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"prepare": "husky install",
|
|
31
|
+
"prepublishOnly": "sanipack build",
|
|
32
|
+
"watch": "sanipack build --watch"
|
|
33
|
+
},
|
|
20
34
|
"dependencies": {
|
|
21
35
|
"@sanity/icons": "^1.3.4",
|
|
22
36
|
"@sanity/ui": "^0.37.22",
|
|
@@ -24,10 +38,24 @@
|
|
|
24
38
|
"react-color": "^2.13.8"
|
|
25
39
|
},
|
|
26
40
|
"devDependencies": {
|
|
41
|
+
"@commitlint/cli": "^17.3.0",
|
|
42
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
27
43
|
"@sanity/base": "2.35.2",
|
|
44
|
+
"@sanity/semantic-release-preset": "^2.0.1",
|
|
28
45
|
"@sanity/types": "2.35.0",
|
|
46
|
+
"eslint": "^8.27.0",
|
|
47
|
+
"eslint-config-prettier": "^8.5.0",
|
|
48
|
+
"eslint-config-sanity": "^6.0.0",
|
|
49
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
50
|
+
"eslint-plugin-react": "^7.31.10",
|
|
51
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
52
|
+
"husky": "^8.0.1",
|
|
53
|
+
"lint-staged": "^13.0.3",
|
|
54
|
+
"prettier": "^2.7.1",
|
|
55
|
+
"prettier-plugin-packagejson": "^2.3.0",
|
|
29
56
|
"react": "17.0.1",
|
|
30
|
-
"rimraf": "^2.7.1"
|
|
57
|
+
"rimraf": "^2.7.1",
|
|
58
|
+
"sanipack": "^2.1.0"
|
|
31
59
|
},
|
|
32
60
|
"peerDependencies": {
|
|
33
61
|
"@sanity/base": "^2.14",
|
|
@@ -36,17 +64,7 @@
|
|
|
36
64
|
"react": "^16.9 || ^17",
|
|
37
65
|
"styled-components": "^5.2.0"
|
|
38
66
|
},
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/sanity-io/sanity/issues"
|
|
41
|
-
},
|
|
42
|
-
"homepage": "https://www.sanity.io/",
|
|
43
|
-
"repository": {
|
|
44
|
-
"type": "git",
|
|
45
|
-
"url": "git+https://github.com/sanity-io/sanity.git",
|
|
46
|
-
"directory": "packages/@sanity/color-input"
|
|
47
|
-
},
|
|
48
67
|
"publishConfig": {
|
|
49
68
|
"access": "public"
|
|
50
|
-
}
|
|
51
|
-
"gitHead": "9bf408d4cc8b3e14bac0bf94d3305d6960181d3c"
|
|
69
|
+
}
|
|
52
70
|
}
|
package/sanity.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
},
|
|
6
6
|
"parts": [
|
|
7
7
|
{
|
|
8
|
-
"name": "part:@sanity/
|
|
8
|
+
"name": "part:@sanity/color-input/input/color",
|
|
9
9
|
"description": "Color input"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
|
-
"implements": "part:@sanity/
|
|
12
|
+
"implements": "part:@sanity/color-input/input/color",
|
|
13
13
|
"path": "ColorInput"
|
|
14
14
|
},
|
|
15
15
|
{
|