@open-keystone/fields-color 2.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/CHANGELOG.md ADDED
@@ -0,0 +1,169 @@
1
+ # @keystonejs/fields-color
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Changed @keystonejs scope to @open-keystone
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @open-keystone/fields@23.0.0
13
+ - @arch-ui/button@0.1.0
14
+ - @arch-ui/fields@3.1.0
15
+ - @arch-ui/popout@0.1.0
16
+
17
+ ## 1.1.2
18
+
19
+ ### Patch Changes
20
+
21
+ - [#95](https://github.com/keystonejs/keystone-5/pull/95) [`c8ff78b95`](https://github.com/keystonejs/keystone-5/commit/c8ff78b95af5d56d44bbc11c51e7cf28b81323b4) Thanks [@bladey](https://github.com/bladey)! - Renamed branch `master` to `main`.
22
+
23
+ - Updated dependencies [[`c8ff78b95`](https://github.com/keystonejs/keystone-5/commit/c8ff78b95af5d56d44bbc11c51e7cf28b81323b4)]:
24
+ - @arch-ui/button@0.0.25
25
+ - @arch-ui/fields@3.0.8
26
+ - @arch-ui/popout@0.0.26
27
+ - @keystonejs/fields@22.1.3
28
+
29
+ ## 1.1.1
30
+
31
+ ### Patch Changes
32
+
33
+ - [#95](https://github.com/keystonejs/keystone-5/pull/95) [`a890b0576`](https://github.com/keystonejs/keystone-5/commit/a890b057628b60c2d1870cc3f5afd8e87b03f7df) Thanks [@bladey](https://github.com/bladey)! - Renamed branch `master` to `main`.
34
+
35
+ - Updated dependencies [[`a890b0576`](https://github.com/keystonejs/keystone-5/commit/a890b057628b60c2d1870cc3f5afd8e87b03f7df)]:
36
+ - @arch-ui/button@0.0.24
37
+ - @arch-ui/fields@3.0.7
38
+ - @arch-ui/popout@0.0.25
39
+ - @keystonejs/fields@22.1.2
40
+
41
+ ## 1.1.0
42
+
43
+ ### Minor Changes
44
+
45
+ - [`345a5f0f6`](https://github.com/keystonejs/keystone-5/commit/345a5f0f66a34c75696230ad2fcfb7a2eac86cb4) [#23](https://github.com/keystonejs/keystone-5/pull/23) Thanks [@bladey](https://github.com/bladey)! - Keystone 5 is now in a 6 to 12 month active maintenance phase, packages will no longer have active development releases. For more information please read our Keystone 5 and beyond post located here - https://github.com/keystonejs/keystone-5/issues/21
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [[`345a5f0f6`](https://github.com/keystonejs/keystone-5/commit/345a5f0f66a34c75696230ad2fcfb7a2eac86cb4)]:
50
+ - @keystonejs/fields@22.1.0
51
+
52
+ ## 1.0.11
53
+
54
+ ### Patch Changes
55
+
56
+ - [`04bf1e4bb`](https://github.com/keystonejs/keystone-5/commit/04bf1e4bb0223f4e2e06664bbc9e95c51118eb84) [#2](https://github.com/keystonejs/keystone-5/pull/2) Thanks [@bladey](https://github.com/bladey)! - Updated repository URL in package.json.
57
+
58
+ - Updated dependencies [[`04bf1e4bb`](https://github.com/keystonejs/keystone-5/commit/04bf1e4bb0223f4e2e06664bbc9e95c51118eb84)]:
59
+ - @arch-ui/button@0.0.23
60
+ - @arch-ui/fields@3.0.6
61
+ - @arch-ui/popout@0.0.24
62
+ - @keystonejs/fields@22.0.1
63
+
64
+ ## 1.0.10
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [[`b97216a65`](https://github.com/keystonejs/keystone-5/commit/b97216a6526fffcca8232d86b115c28cb19587bf), [`4035218df`](https://github.com/keystonejs/keystone-5/commit/4035218df390beff3d42c0d3fc21335230d8a60d), [`8d0be8a89`](https://github.com/keystonejs/keystone-5/commit/8d0be8a89e2d9b89826365f81f47b8d8863b93d0)]:
69
+ - @keystonejs/fields@22.0.0
70
+
71
+ ## 1.0.9
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [[`364ac9254`](https://github.com/keystonejs/keystone-5/commit/364ac9254735befd2d4804789bb62464bb51ee5b), [`841be0bc9`](https://github.com/keystonejs/keystone-5/commit/841be0bc9d192cf64399231a543a9ba9ff41b9a0)]:
76
+ - @keystonejs/fields@21.0.0
77
+
78
+ ## 1.0.8
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [[`c62a35fe0`](https://github.com/keystonejs/keystone-5/commit/c62a35fe0834ec60e2472b22feedda539d18a918), [`8d7056c8e`](https://github.com/keystonejs/keystone-5/commit/8d7056c8ed8d4fccfd61e64fc5fc2caf65899cee)]:
83
+ - @keystonejs/fields@20.1.1
84
+ - @arch-ui/popout@0.0.23
85
+
86
+ ## 1.0.7
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [[`a5e40e6c4`](https://github.com/keystonejs/keystone-5/commit/a5e40e6c4af1ab38cc2079a0f6e27d39d6b7d546), [`2d660b2a1`](https://github.com/keystonejs/keystone-5/commit/2d660b2a1dd013787e022cad3a0c70dbe08c60da)]:
91
+ - @keystonejs/fields@20.0.0
92
+
93
+ ## 1.0.6
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [[`e5efd0ef3`](https://github.com/keystonejs/keystone-5/commit/e5efd0ef3d6943534cb6c728afe5dbf0caf43e74)]:
98
+ - @keystonejs/fields@19.0.0
99
+
100
+ ## 1.0.5
101
+
102
+ ### Patch Changes
103
+
104
+ - Updated dependencies [[`a02e69987`](https://github.com/keystonejs/keystone-5/commit/a02e69987902cfde38d820e68cb24b7a20ca1f6f), [`f70c9f1ba`](https://github.com/keystonejs/keystone-5/commit/f70c9f1ba7452b54a15ab71943a3777d5b6dade4)]:
105
+ - @keystonejs/fields@18.0.0
106
+
107
+ ## 1.0.4
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [[`b32f006ad`](https://github.com/keystonejs/keystone-5/commit/b32f006ad283f8aa1911f55bbecac9942f3f9f25), [`6f42b0a9d`](https://github.com/keystonejs/keystone-5/commit/6f42b0a9d231049f9e7523eb78ec621d9c9d6df9), [`ecbe1471f`](https://github.com/keystonejs/keystone-5/commit/ecbe1471fe22ca029a178a57dc216f6445b4053a), [`27783bbca`](https://github.com/keystonejs/keystone-5/commit/27783bbca3b1c5ff05402738c14ffa8db73e542b), [`304701d7c`](https://github.com/keystonejs/keystone-5/commit/304701d7c23e98c8dc40c0f3f5512a0370107c06), [`aa5b4aa26`](https://github.com/keystonejs/keystone-5/commit/aa5b4aa269eebc6931d30f6eddc315805c1f4fef), [`b6e160678`](https://github.com/keystonejs/keystone-5/commit/b6e160678b449707261a54a9d565b91663784831)]:
112
+ - @keystonejs/fields@17.1.3
113
+ - @arch-ui/popout@0.0.22
114
+ - @arch-ui/button@0.0.22
115
+ - @arch-ui/fields@3.0.5
116
+
117
+ ## 1.0.3
118
+
119
+ ### Patch Changes
120
+
121
+ - [`6c97a5534`](https://github.com/keystonejs/keystone-5/commit/6c97a5534e8a18d15aeac8b0471810fdd4d04f80) [#3577](https://github.com/keystonejs/keystone-5/pull/3577) Thanks [@timleslie](https://github.com/timleslie)! - Updated test framework to support more detailed field tests.
122
+
123
+ * [`2e6a06202`](https://github.com/keystonejs/keystone-5/commit/2e6a06202299b36c36fd3efd895f2280479eac31) [#3532](https://github.com/keystonejs/keystone-5/pull/3532) Thanks [@timleslie](https://github.com/timleslie)! - Consolidated filter tests across all field types.
124
+ Fixed errors with filtering by `null` in the `Decimal`, `MongoId` and `Uuid` field types.
125
+ * Updated dependencies [[`cd15192cd`](https://github.com/keystonejs/keystone-5/commit/cd15192cdae5e476f64a257c196ca569a9440d5a), [`d500613d8`](https://github.com/keystonejs/keystone-5/commit/d500613d8917e3cbcea2817501d607eddd3b1a8d), [`6c97a5534`](https://github.com/keystonejs/keystone-5/commit/6c97a5534e8a18d15aeac8b0471810fdd4d04f80), [`34fcc7052`](https://github.com/keystonejs/keystone-5/commit/34fcc7052a24db61f1f2f12c46110c060934f4ca), [`c3488c5e8`](https://github.com/keystonejs/keystone-5/commit/c3488c5e88628b15eb9fe804551c3c5c44c07e0f), [`e62b3308b`](https://github.com/keystonejs/keystone-5/commit/e62b3308bd841b5f58ac9fa1f84707f9187fda6b), [`7036585f2`](https://github.com/keystonejs/keystone-5/commit/7036585f25c3b690b7a6fd04c39b5b781ff5bcd9), [`2e6a06202`](https://github.com/keystonejs/keystone-5/commit/2e6a06202299b36c36fd3efd895f2280479eac31), [`a42ee3a30`](https://github.com/keystonejs/keystone-5/commit/a42ee3a306c899a7ae46909fe132522cbeff7812), [`438051442`](https://github.com/keystonejs/keystone-5/commit/4380514421020f4418a9f966c9fec60e014478b9), [`b3aa85031`](https://github.com/keystonejs/keystone-5/commit/b3aa850311cbc1622568f69f9cb4b9f46ab9db22), [`518718e19`](https://github.com/keystonejs/keystone-5/commit/518718e197d0a2d723c8e184552ddd5d8e165f12), [`28b88abd3`](https://github.com/keystonejs/keystone-5/commit/28b88abd369f0df12eae72107db7c24323eda4b5), [`16e4d91a2`](https://github.com/keystonejs/keystone-5/commit/16e4d91a20cc6a079c60ea9801381da55444b1e1)]:
126
+ - @keystonejs/fields@17.1.1
127
+ - @arch-ui/popout@0.0.21
128
+
129
+ ## 1.0.2
130
+
131
+ ### Patch Changes
132
+
133
+ - [`5935b89f8`](https://github.com/keystonejs/keystone-5/commit/5935b89f8862b36f14d09da68f056f759a860f3e) [#3477](https://github.com/keystonejs/keystone-5/pull/3477) Thanks [@Noviny](https://github.com/Noviny)! - Updating dependencies:
134
+
135
+ These changes bring the keystone dev experience inline with installing keystone from npm :D
136
+
137
+ * [`ac44568f9`](https://github.com/keystonejs/keystone-5/commit/ac44568f91fd54ccbc39accf83bcfb3276ce1a72) [#3500](https://github.com/keystonejs/keystone-5/pull/3500) Thanks [@timleslie](https://github.com/timleslie)! - Updated test scripts to be more consistent.
138
+
139
+ - [`483b20ec5`](https://github.com/keystonejs/keystone-5/commit/483b20ec53ff89f1d026c0495fdae5df60a7cf59) [#3487](https://github.com/keystonejs/keystone-5/pull/3487) Thanks [@singhArmani](https://github.com/singhArmani)! - Updated CRUD API tests for field types.
140
+
141
+ * [`ea367f759`](https://github.com/keystonejs/keystone-5/commit/ea367f7594f47efc3528d9917cce010b3a16bf4d) [#3435](https://github.com/keystonejs/keystone-5/pull/3435) Thanks [@singhArmani](https://github.com/singhArmani)! - Updated `required` and `uniqueness` tests for field API.
142
+
143
+ * Updated dependencies [[`6cb4476ff`](https://github.com/keystonejs/keystone-5/commit/6cb4476ff15923933862c1cd7d4b1ade794106c6), [`5935b89f8`](https://github.com/keystonejs/keystone-5/commit/5935b89f8862b36f14d09da68f056f759a860f3e), [`ac44568f9`](https://github.com/keystonejs/keystone-5/commit/ac44568f91fd54ccbc39accf83bcfb3276ce1a72), [`877a5a90d`](https://github.com/keystonejs/keystone-5/commit/877a5a90d608f0a13b6c0ea103cb96e3ac2caacc), [`483b20ec5`](https://github.com/keystonejs/keystone-5/commit/483b20ec53ff89f1d026c0495fdae5df60a7cf59), [`0fc878fa9`](https://github.com/keystonejs/keystone-5/commit/0fc878fa918c3196196f943f195ffaa62fce504b), [`ea367f759`](https://github.com/keystonejs/keystone-5/commit/ea367f7594f47efc3528d9917cce010b3a16bf4d), [`69d627813`](https://github.com/keystonejs/keystone-5/commit/69d627813adfc10d29707f5c882ca15621de12a5), [`0153168d7`](https://github.com/keystonejs/keystone-5/commit/0153168d73ce8cd7ede4eb9c8518e5e2bf859709)]:
144
+ - @arch-ui/popout@0.0.20
145
+ - @keystonejs/fields@17.1.0
146
+ - @arch-ui/button@0.0.21
147
+ - @arch-ui/fields@3.0.4
148
+
149
+ ## 1.0.1
150
+
151
+ ### Patch Changes
152
+
153
+ - [`c906858bb`](https://github.com/keystonejs/keystone-5/commit/c906858bb76630f284332b9532a17de75c0c0f33) [#3404](https://github.com/keystonejs/keystone-5/pull/3404) Thanks [@singhArmani](https://github.com/singhArmani)! - Updated filter and CRUD tests for `Color` field type.
154
+
155
+ - Updated dependencies [[`d38c9174f`](https://github.com/keystonejs/keystone-5/commit/d38c9174f8146ad6e268be87cf5d54d5074bc593), [`e8b2e4772`](https://github.com/keystonejs/keystone-5/commit/e8b2e477206acffb143f19fb14be1e3b4cd0eb91)]:
156
+ - @keystonejs/fields@17.0.0
157
+
158
+ ## 1.0.0
159
+
160
+ ### Major Changes
161
+
162
+ - [`e44102e9f`](https://github.com/keystonejs/keystone-5/commit/e44102e9f7f770b1528d642d763ccf9f88f3cbb1) [#3307](https://github.com/keystonejs/keystone-5/pull/3307) Thanks [@MadeByMike](https://github.com/MadeByMike)! - Moved the `Color` field from `@keystonejs/fields` to `@keystonejs/fields-color`.
163
+
164
+ Note: If using the `Color` field you need to update imports to point to `@keystonejs/fields-color`.
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [[`d38a41f25`](https://github.com/keystonejs/keystone-5/commit/d38a41f25a1b4c90c05d2fb85116dc385d4ee77a), [`5ede731fc`](https://github.com/keystonejs/keystone-5/commit/5ede731fc58a79e7322b852bdd2d971ece45281e), [`1d9068770`](https://github.com/keystonejs/keystone-5/commit/1d9068770d03658954044c530e56e66169667e25), [`694f3acfb`](https://github.com/keystonejs/keystone-5/commit/694f3acfb9faa78aebfcf48cf711165560f16ff7), [`149d6fd6f`](https://github.com/keystonejs/keystone-5/commit/149d6fd6ff057c17570346063c173376769dcc79), [`e44102e9f`](https://github.com/keystonejs/keystone-5/commit/e44102e9f7f770b1528d642d763ccf9f88f3cbb1)]:
169
+ - @keystonejs/fields@16.0.0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ <!--[meta]
2
+ section: api
3
+ subSection: field-types
4
+ title: Color
5
+ [meta]-->
6
+
7
+ # Color
8
+
9
+ > This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.
10
+
11
+ Stores hexadecimal RGBA (Red, Green, Blue, Alpha) color values.
12
+ Presented in the Admin UI as an interactive color picker.
13
+
14
+ ## Usage
15
+
16
+ ```js
17
+ const { Color } = require('@open-keystone/fields-color');
18
+
19
+ keystone.createList('Product', {
20
+ fields: {
21
+ heroColor: { type: Color },
22
+ },
23
+ });
24
+ ```
25
+
26
+ ## Config
27
+
28
+ | Option | Type | Default | Description |
29
+ | ------------ | --------- | ------- | --------------------------------------------------------------- |
30
+ | `isRequired` | `Boolean` | `false` | Does this field require a value? |
31
+ | `isUnique` | `Boolean` | `false` | Adds a unique index that allows only unique values to be stored |
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fields = require('@open-keystone/fields');
6
+ var path = require('path');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
+
10
+ var path__default = /*#__PURE__*/_interopDefault(path);
11
+
12
+ const pkgDir = path__default["default"].dirname(require.resolve('@open-keystone/fields-color/package.json'));
13
+ const Color = {
14
+ type: 'Color',
15
+ implementation: fields.Text.implementation,
16
+ views: {
17
+ Controller: fields.Text.views.Controller,
18
+ Field: path__default["default"].join(pkgDir, 'views/Field'),
19
+ Cell: path__default["default"].join(pkgDir, 'views/Cell'),
20
+ Filter: fields.Text.views.Filter
21
+ },
22
+ adapters: fields.Text.adapters
23
+ };
24
+
25
+ exports.Color = Color;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./fields-color.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./fields-color.cjs.dev.js");
7
+ }
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fields = require('@open-keystone/fields');
6
+ var path = require('path');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
+
10
+ var path__default = /*#__PURE__*/_interopDefault(path);
11
+
12
+ const pkgDir = path__default["default"].dirname(require.resolve('@open-keystone/fields-color/package.json'));
13
+ const Color = {
14
+ type: 'Color',
15
+ implementation: fields.Text.implementation,
16
+ views: {
17
+ Controller: fields.Text.views.Controller,
18
+ Field: path__default["default"].join(pkgDir, 'views/Field'),
19
+ Cell: path__default["default"].join(pkgDir, 'views/Cell'),
20
+ Filter: fields.Text.views.Filter
21
+ },
22
+ adapters: fields.Text.adapters
23
+ };
24
+
25
+ exports.Color = Color;
@@ -0,0 +1,17 @@
1
+ import { Text } from '@open-keystone/fields';
2
+ import path from 'path';
3
+
4
+ const pkgDir = path.dirname(require.resolve('@open-keystone/fields-color/package.json'));
5
+ const Color = {
6
+ type: 'Color',
7
+ implementation: Text.implementation,
8
+ views: {
9
+ Controller: Text.views.Controller,
10
+ Field: path.join(pkgDir, 'views/Field'),
11
+ Cell: path.join(pkgDir, 'views/Cell'),
12
+ Filter: Text.views.Filter
13
+ },
14
+ adapters: Text.adapters
15
+ };
16
+
17
+ export { Color };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@open-keystone/fields-color",
3
+ "description": "KeystoneJS Color Field Type",
4
+ "version": "2.0.0",
5
+ "author": "The KeystoneJS Development Team",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": ">=16.0.0"
9
+ },
10
+ "dependencies": {
11
+ "@arch-ui/button": "^0.1.0",
12
+ "@arch-ui/fields": "^3.1.0",
13
+ "@arch-ui/popout": "^0.1.0",
14
+ "@babel/runtime": "^7.14.6",
15
+ "@emotion/core": "^10.1.1",
16
+ "@open-keystone/fields": "^23.0.0",
17
+ "react-color": "^2.19.3"
18
+ },
19
+ "peerDependencies": {
20
+ "react": "^17.0.2"
21
+ },
22
+ "devDependencies": {
23
+ "@open-keystone/server-side-graphql-client": "^2.1.3",
24
+ "react": "^17.0.2"
25
+ },
26
+ "main": "dist/fields-color.cjs.js",
27
+ "module": "dist/fields-color.esm.js",
28
+ "repository": "https://github.com/keystonejs/keystone-5/tree/main/packages/fields-color",
29
+ "preconstruct": {
30
+ "entrypoints": [
31
+ "index.js",
32
+ "views/*.js"
33
+ ]
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }
package/src/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import { Text } from '@open-keystone/fields';
2
+ import path from 'path';
3
+
4
+ const pkgDir = path.dirname(require.resolve('@open-keystone/fields-color/package.json'));
5
+
6
+ export const Color = {
7
+ type: 'Color',
8
+ implementation: Text.implementation,
9
+ views: {
10
+ Controller: Text.views.Controller,
11
+ Field: path.join(pkgDir, 'views/Field'),
12
+ Cell: path.join(pkgDir, 'views/Cell'),
13
+ Filter: Text.views.Filter,
14
+ },
15
+ adapters: Text.adapters,
16
+ };
@@ -0,0 +1,43 @@
1
+ import { Text } from '@open-keystone/fields';
2
+ import { Color } from '.';
3
+
4
+ export const name = 'Color';
5
+ export const type = Color;
6
+ export const exampleValue = () => 'red';
7
+ export const exampleValue2 = () => 'green';
8
+ export const supportsUnique = true;
9
+ export const fieldName = 'testField';
10
+
11
+ export const getTestFields = () => ({ name: { type: Text }, testField: { type } });
12
+
13
+ export const initItems = () => {
14
+ return [
15
+ { name: 'a', testField: '' },
16
+ { name: 'b', testField: 'other' },
17
+ { name: 'c', testField: 'FOOBAR' },
18
+ { name: 'd', testField: 'fooBAR' },
19
+ { name: 'e', testField: 'foobar' },
20
+ { name: 'f', testField: null },
21
+ { name: 'g' },
22
+ ];
23
+ };
24
+
25
+ export const storedValues = () => [
26
+ { name: 'a', testField: '' },
27
+ { name: 'b', testField: 'other' },
28
+ { name: 'c', testField: 'FOOBAR' },
29
+ { name: 'd', testField: 'fooBAR' },
30
+ { name: 'e', testField: 'foobar' },
31
+ { name: 'f', testField: null },
32
+ { name: 'g', testField: null },
33
+ ];
34
+
35
+ export const supportedFilters = () => [
36
+ 'null_equality',
37
+ 'equality',
38
+ 'equality_case_insensitive',
39
+ 'in_empty_null',
40
+ 'in_value',
41
+ 'string',
42
+ 'string_case_insensitive',
43
+ ];
@@ -0,0 +1,39 @@
1
+ /** @jsx jsx */
2
+
3
+ import { jsx } from '@emotion/core';
4
+ import { Fragment } from 'react';
5
+
6
+ const Cell = props => {
7
+ if (!props.data) {
8
+ return null;
9
+ }
10
+
11
+ return (
12
+ <Fragment>
13
+ <div
14
+ style={{
15
+ // using inline styles instead of emotion for setting the color
16
+ // since emotion doesn't escape styles so it could be used for CSS injection
17
+ backgroundColor: props.data,
18
+ }}
19
+ css={{
20
+ borderRadius: 3,
21
+ display: 'inline-block',
22
+ height: 18,
23
+ width: 18,
24
+ marginRight: 10,
25
+ verticalAlign: 'middle',
26
+ }}
27
+ />
28
+ <span
29
+ css={{
30
+ verticalAlign: 'middle',
31
+ }}
32
+ >
33
+ {props.data}
34
+ </span>
35
+ </Fragment>
36
+ );
37
+ };
38
+
39
+ export default Cell;
@@ -0,0 +1,84 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/core';
3
+ import { Fragment, useMemo } from 'react';
4
+ import { FieldContainer, FieldLabel, FieldDescription, FieldInput } from '@arch-ui/fields';
5
+ import Popout from '@arch-ui/popout';
6
+ import { Button } from '@arch-ui/button';
7
+ import SketchPicker from 'react-color/lib/Sketch';
8
+
9
+ const ColorField = ({ field, value = '', errors, onChange, isDisabled }) => {
10
+ const htmlID = `ks-input-${field.path}`;
11
+
12
+ const colorPickerValue = useMemo(() => {
13
+ // keystone previously stored values as a hex string and this should still be supported
14
+ // it is now stored as an rgba string
15
+ if (value) {
16
+ if (value.indexOf('rgba', 0) === 0) {
17
+ const rgbaValues = value.replace(/^rgba\(|\s+|\)$/g, '').split(',');
18
+ return { r: rgbaValues[0], g: rgbaValues[1], b: rgbaValues[2], a: rgbaValues[3] };
19
+ }
20
+ return value;
21
+ }
22
+ return '';
23
+ }, [value]);
24
+
25
+ const target = props => (
26
+ <Button {...props} variant="ghost" isDisabled={isDisabled}>
27
+ {value ? (
28
+ <Fragment>
29
+ <div
30
+ style={{
31
+ // using inline styles instead of emotion for setting the color
32
+ // since emotion doesn't escape styles so it could be used for CSS injection
33
+ // this is also better in terms of memory since the value can change a lot
34
+ // and emotion caches everything
35
+ backgroundColor: value,
36
+ }}
37
+ css={{
38
+ borderRadius: 3,
39
+ display: 'inline-block',
40
+ height: 18,
41
+ width: 18,
42
+ marginRight: 10,
43
+ verticalAlign: 'middle',
44
+ }}
45
+ />
46
+ <span
47
+ css={{
48
+ verticalAlign: 'middle',
49
+ }}
50
+ >
51
+ {value}
52
+ </span>
53
+ </Fragment>
54
+ ) : (
55
+ 'Set Color'
56
+ )}
57
+ </Button>
58
+ );
59
+
60
+ return (
61
+ <FieldContainer>
62
+ <FieldLabel htmlFor={htmlID} field={field} errors={errors} />
63
+ <FieldDescription text={field.adminDoc} />
64
+ <FieldInput>
65
+ <Popout width={220} target={target}>
66
+ <SketchPicker
67
+ css={{
68
+ // using !important because react-color uses inline styles and applies a box shadow
69
+ // but Popout already applies a box shadow
70
+ boxShadow: 'none !important',
71
+ }}
72
+ presetColors={[]}
73
+ color={colorPickerValue}
74
+ onChange={({ rgb: { r, g, b, a } }) => {
75
+ onChange(`rgba(${r}, ${g}, ${b}, ${a})`);
76
+ }}
77
+ />
78
+ </Popout>
79
+ </FieldInput>
80
+ </FieldContainer>
81
+ );
82
+ };
83
+
84
+ export default ColorField;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@emotion/core');
6
+ var react = require('react');
7
+
8
+ /** @jsx jsx */
9
+ const Cell = props => {
10
+ if (!props.data) {
11
+ return null;
12
+ }
13
+ return core.jsx(react.Fragment, null, core.jsx("div", {
14
+ style: {
15
+ // using inline styles instead of emotion for setting the color
16
+ // since emotion doesn't escape styles so it could be used for CSS injection
17
+ backgroundColor: props.data
18
+ },
19
+ css: {
20
+ borderRadius: 3,
21
+ display: 'inline-block',
22
+ height: 18,
23
+ width: 18,
24
+ marginRight: 10,
25
+ verticalAlign: 'middle'
26
+ }
27
+ }), core.jsx("span", {
28
+ css: {
29
+ verticalAlign: 'middle'
30
+ }
31
+ }, props.data));
32
+ };
33
+
34
+ exports["default"] = Cell;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./fields-color.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./fields-color.cjs.dev.js");
7
+ }
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@emotion/core');
6
+ var react = require('react');
7
+
8
+ /** @jsx jsx */
9
+ const Cell = props => {
10
+ if (!props.data) {
11
+ return null;
12
+ }
13
+ return core.jsx(react.Fragment, null, core.jsx("div", {
14
+ style: {
15
+ // using inline styles instead of emotion for setting the color
16
+ // since emotion doesn't escape styles so it could be used for CSS injection
17
+ backgroundColor: props.data
18
+ },
19
+ css: {
20
+ borderRadius: 3,
21
+ display: 'inline-block',
22
+ height: 18,
23
+ width: 18,
24
+ marginRight: 10,
25
+ verticalAlign: 'middle'
26
+ }
27
+ }), core.jsx("span", {
28
+ css: {
29
+ verticalAlign: 'middle'
30
+ }
31
+ }, props.data));
32
+ };
33
+
34
+ exports["default"] = Cell;
@@ -0,0 +1,30 @@
1
+ import { jsx } from '@emotion/core';
2
+ import { Fragment } from 'react';
3
+
4
+ /** @jsx jsx */
5
+ const Cell = props => {
6
+ if (!props.data) {
7
+ return null;
8
+ }
9
+ return jsx(Fragment, null, jsx("div", {
10
+ style: {
11
+ // using inline styles instead of emotion for setting the color
12
+ // since emotion doesn't escape styles so it could be used for CSS injection
13
+ backgroundColor: props.data
14
+ },
15
+ css: {
16
+ borderRadius: 3,
17
+ display: 'inline-block',
18
+ height: 18,
19
+ width: 18,
20
+ marginRight: 10,
21
+ verticalAlign: 'middle'
22
+ }
23
+ }), jsx("span", {
24
+ css: {
25
+ verticalAlign: 'middle'
26
+ }
27
+ }, props.data));
28
+ };
29
+
30
+ export { Cell as default };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/fields-color.cjs.js",
3
+ "module": "dist/fields-color.esm.js"
4
+ }
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _extends = require('@babel/runtime/helpers/extends');
6
+ var core = require('@emotion/core');
7
+ var react = require('react');
8
+ var fields = require('@arch-ui/fields');
9
+ var Popout = require('@arch-ui/popout');
10
+ var button = require('@arch-ui/button');
11
+ var SketchPicker = require('react-color/lib/Sketch');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
+
15
+ var Popout__default = /*#__PURE__*/_interopDefault(Popout);
16
+ var SketchPicker__default = /*#__PURE__*/_interopDefault(SketchPicker);
17
+
18
+ const ColorField = ({
19
+ field,
20
+ value = '',
21
+ errors,
22
+ onChange,
23
+ isDisabled
24
+ }) => {
25
+ const htmlID = `ks-input-${field.path}`;
26
+ const colorPickerValue = react.useMemo(() => {
27
+ // keystone previously stored values as a hex string and this should still be supported
28
+ // it is now stored as an rgba string
29
+ if (value) {
30
+ if (value.indexOf('rgba', 0) === 0) {
31
+ const rgbaValues = value.replace(/^rgba\(|\s+|\)$/g, '').split(',');
32
+ return {
33
+ r: rgbaValues[0],
34
+ g: rgbaValues[1],
35
+ b: rgbaValues[2],
36
+ a: rgbaValues[3]
37
+ };
38
+ }
39
+ return value;
40
+ }
41
+ return '';
42
+ }, [value]);
43
+ const target = props => core.jsx(button.Button, _extends({}, props, {
44
+ variant: "ghost",
45
+ isDisabled: isDisabled
46
+ }), value ? core.jsx(react.Fragment, null, core.jsx("div", {
47
+ style: {
48
+ // using inline styles instead of emotion for setting the color
49
+ // since emotion doesn't escape styles so it could be used for CSS injection
50
+ // this is also better in terms of memory since the value can change a lot
51
+ // and emotion caches everything
52
+ backgroundColor: value
53
+ },
54
+ css: {
55
+ borderRadius: 3,
56
+ display: 'inline-block',
57
+ height: 18,
58
+ width: 18,
59
+ marginRight: 10,
60
+ verticalAlign: 'middle'
61
+ }
62
+ }), core.jsx("span", {
63
+ css: {
64
+ verticalAlign: 'middle'
65
+ }
66
+ }, value)) : 'Set Color');
67
+ return core.jsx(fields.FieldContainer, null, core.jsx(fields.FieldLabel, {
68
+ htmlFor: htmlID,
69
+ field: field,
70
+ errors: errors
71
+ }), core.jsx(fields.FieldDescription, {
72
+ text: field.adminDoc
73
+ }), core.jsx(fields.FieldInput, null, core.jsx(Popout__default["default"], {
74
+ width: 220,
75
+ target: target
76
+ }, core.jsx(SketchPicker__default["default"], {
77
+ css: {
78
+ // using !important because react-color uses inline styles and applies a box shadow
79
+ // but Popout already applies a box shadow
80
+ boxShadow: 'none !important'
81
+ },
82
+ presetColors: [],
83
+ color: colorPickerValue,
84
+ onChange: ({
85
+ rgb: {
86
+ r,
87
+ g,
88
+ b,
89
+ a
90
+ }
91
+ }) => {
92
+ onChange(`rgba(${r}, ${g}, ${b}, ${a})`);
93
+ }
94
+ }))));
95
+ };
96
+
97
+ exports["default"] = ColorField;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./fields-color.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./fields-color.cjs.dev.js");
7
+ }
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _extends = require('@babel/runtime/helpers/extends');
6
+ var core = require('@emotion/core');
7
+ var react = require('react');
8
+ var fields = require('@arch-ui/fields');
9
+ var Popout = require('@arch-ui/popout');
10
+ var button = require('@arch-ui/button');
11
+ var SketchPicker = require('react-color/lib/Sketch');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
+
15
+ var Popout__default = /*#__PURE__*/_interopDefault(Popout);
16
+ var SketchPicker__default = /*#__PURE__*/_interopDefault(SketchPicker);
17
+
18
+ const ColorField = ({
19
+ field,
20
+ value = '',
21
+ errors,
22
+ onChange,
23
+ isDisabled
24
+ }) => {
25
+ const htmlID = `ks-input-${field.path}`;
26
+ const colorPickerValue = react.useMemo(() => {
27
+ // keystone previously stored values as a hex string and this should still be supported
28
+ // it is now stored as an rgba string
29
+ if (value) {
30
+ if (value.indexOf('rgba', 0) === 0) {
31
+ const rgbaValues = value.replace(/^rgba\(|\s+|\)$/g, '').split(',');
32
+ return {
33
+ r: rgbaValues[0],
34
+ g: rgbaValues[1],
35
+ b: rgbaValues[2],
36
+ a: rgbaValues[3]
37
+ };
38
+ }
39
+ return value;
40
+ }
41
+ return '';
42
+ }, [value]);
43
+ const target = props => core.jsx(button.Button, _extends({}, props, {
44
+ variant: "ghost",
45
+ isDisabled: isDisabled
46
+ }), value ? core.jsx(react.Fragment, null, core.jsx("div", {
47
+ style: {
48
+ // using inline styles instead of emotion for setting the color
49
+ // since emotion doesn't escape styles so it could be used for CSS injection
50
+ // this is also better in terms of memory since the value can change a lot
51
+ // and emotion caches everything
52
+ backgroundColor: value
53
+ },
54
+ css: {
55
+ borderRadius: 3,
56
+ display: 'inline-block',
57
+ height: 18,
58
+ width: 18,
59
+ marginRight: 10,
60
+ verticalAlign: 'middle'
61
+ }
62
+ }), core.jsx("span", {
63
+ css: {
64
+ verticalAlign: 'middle'
65
+ }
66
+ }, value)) : 'Set Color');
67
+ return core.jsx(fields.FieldContainer, null, core.jsx(fields.FieldLabel, {
68
+ htmlFor: htmlID,
69
+ field: field,
70
+ errors: errors
71
+ }), core.jsx(fields.FieldDescription, {
72
+ text: field.adminDoc
73
+ }), core.jsx(fields.FieldInput, null, core.jsx(Popout__default["default"], {
74
+ width: 220,
75
+ target: target
76
+ }, core.jsx(SketchPicker__default["default"], {
77
+ css: {
78
+ // using !important because react-color uses inline styles and applies a box shadow
79
+ // but Popout already applies a box shadow
80
+ boxShadow: 'none !important'
81
+ },
82
+ presetColors: [],
83
+ color: colorPickerValue,
84
+ onChange: ({
85
+ rgb: {
86
+ r,
87
+ g,
88
+ b,
89
+ a
90
+ }
91
+ }) => {
92
+ onChange(`rgba(${r}, ${g}, ${b}, ${a})`);
93
+ }
94
+ }))));
95
+ };
96
+
97
+ exports["default"] = ColorField;
@@ -0,0 +1,88 @@
1
+ import _extends from '@babel/runtime/helpers/esm/extends';
2
+ import { jsx } from '@emotion/core';
3
+ import { useMemo, Fragment } from 'react';
4
+ import { FieldContainer, FieldLabel, FieldDescription, FieldInput } from '@arch-ui/fields';
5
+ import Popout from '@arch-ui/popout';
6
+ import { Button } from '@arch-ui/button';
7
+ import SketchPicker from 'react-color/lib/Sketch';
8
+
9
+ const ColorField = ({
10
+ field,
11
+ value = '',
12
+ errors,
13
+ onChange,
14
+ isDisabled
15
+ }) => {
16
+ const htmlID = `ks-input-${field.path}`;
17
+ const colorPickerValue = useMemo(() => {
18
+ // keystone previously stored values as a hex string and this should still be supported
19
+ // it is now stored as an rgba string
20
+ if (value) {
21
+ if (value.indexOf('rgba', 0) === 0) {
22
+ const rgbaValues = value.replace(/^rgba\(|\s+|\)$/g, '').split(',');
23
+ return {
24
+ r: rgbaValues[0],
25
+ g: rgbaValues[1],
26
+ b: rgbaValues[2],
27
+ a: rgbaValues[3]
28
+ };
29
+ }
30
+ return value;
31
+ }
32
+ return '';
33
+ }, [value]);
34
+ const target = props => jsx(Button, _extends({}, props, {
35
+ variant: "ghost",
36
+ isDisabled: isDisabled
37
+ }), value ? jsx(Fragment, null, jsx("div", {
38
+ style: {
39
+ // using inline styles instead of emotion for setting the color
40
+ // since emotion doesn't escape styles so it could be used for CSS injection
41
+ // this is also better in terms of memory since the value can change a lot
42
+ // and emotion caches everything
43
+ backgroundColor: value
44
+ },
45
+ css: {
46
+ borderRadius: 3,
47
+ display: 'inline-block',
48
+ height: 18,
49
+ width: 18,
50
+ marginRight: 10,
51
+ verticalAlign: 'middle'
52
+ }
53
+ }), jsx("span", {
54
+ css: {
55
+ verticalAlign: 'middle'
56
+ }
57
+ }, value)) : 'Set Color');
58
+ return jsx(FieldContainer, null, jsx(FieldLabel, {
59
+ htmlFor: htmlID,
60
+ field: field,
61
+ errors: errors
62
+ }), jsx(FieldDescription, {
63
+ text: field.adminDoc
64
+ }), jsx(FieldInput, null, jsx(Popout, {
65
+ width: 220,
66
+ target: target
67
+ }, jsx(SketchPicker, {
68
+ css: {
69
+ // using !important because react-color uses inline styles and applies a box shadow
70
+ // but Popout already applies a box shadow
71
+ boxShadow: 'none !important'
72
+ },
73
+ presetColors: [],
74
+ color: colorPickerValue,
75
+ onChange: ({
76
+ rgb: {
77
+ r,
78
+ g,
79
+ b,
80
+ a
81
+ }
82
+ }) => {
83
+ onChange(`rgba(${r}, ${g}, ${b}, ${a})`);
84
+ }
85
+ }))));
86
+ };
87
+
88
+ export { ColorField as default };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/fields-color.cjs.js",
3
+ "module": "dist/fields-color.esm.js"
4
+ }