@contentful/field-editor-boolean 0.12.6 → 0.13.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 +13 -100
- package/README.md +0 -1
- package/dist/field-editor-boolean.cjs.development.js +10 -11
- package/dist/field-editor-boolean.cjs.development.js.map +1 -1
- package/dist/field-editor-boolean.cjs.production.min.js +1 -1
- package/dist/field-editor-boolean.cjs.production.min.js.map +1 -1
- package/dist/field-editor-boolean.esm.js +7 -8
- package/dist/field-editor-boolean.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,205 +3,118 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
6
|
+
# [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.6...@contentful/field-editor-boolean@0.13.0) (2021-11-04)
|
|
9
7
|
|
|
8
|
+
### Features
|
|
10
9
|
|
|
10
|
+
- Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
|
|
11
11
|
|
|
12
|
+
### BREAKING CHANGES
|
|
12
13
|
|
|
14
|
+
- adopts a new Forma v4 beta
|
|
13
15
|
|
|
14
|
-
## [0.12.
|
|
16
|
+
## [0.12.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.5...@contentful/field-editor-boolean@0.12.6) (2021-10-14)
|
|
15
17
|
|
|
16
18
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
17
19
|
|
|
20
|
+
## [0.12.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.4...@contentful/field-editor-boolean@0.12.5) (2021-10-06)
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
21
23
|
|
|
22
24
|
## [0.12.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.3...@contentful/field-editor-boolean@0.12.4) (2021-09-17)
|
|
23
25
|
|
|
24
26
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
28
|
## [0.12.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.2...@contentful/field-editor-boolean@0.12.3) (2021-09-16)
|
|
31
29
|
|
|
32
30
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
32
|
## [0.12.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.1...@contentful/field-editor-boolean@0.12.2) (2021-08-19)
|
|
39
33
|
|
|
40
34
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
36
|
## [0.12.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.12.0...@contentful/field-editor-boolean@0.12.1) (2021-07-29)
|
|
47
37
|
|
|
48
38
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
40
|
# [0.12.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.6...@contentful/field-editor-boolean@0.12.0) (2021-07-23)
|
|
55
41
|
|
|
56
|
-
|
|
57
42
|
### Features
|
|
58
43
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
44
|
+
- 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
|
|
64
45
|
|
|
65
46
|
## [0.11.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.3...@contentful/field-editor-boolean@0.11.6) (2021-07-06)
|
|
66
47
|
|
|
67
48
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
50
|
## [0.11.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.3...@contentful/field-editor-boolean@0.11.5) (2021-07-06)
|
|
74
51
|
|
|
75
52
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
54
|
## [0.11.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.3...@contentful/field-editor-boolean@0.11.4) (2021-06-23)
|
|
82
55
|
|
|
83
56
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
84
57
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
58
|
## [0.11.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.2...@contentful/field-editor-boolean@0.11.3) (2021-06-23)
|
|
90
59
|
|
|
91
60
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
92
61
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
62
|
## [0.11.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.1...@contentful/field-editor-boolean@0.11.2) (2021-06-22)
|
|
98
63
|
|
|
99
64
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
100
65
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
66
|
## [0.11.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.11.0...@contentful/field-editor-boolean@0.11.1) (2021-03-05)
|
|
106
67
|
|
|
107
68
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
108
69
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
70
|
# [0.11.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.10.2...@contentful/field-editor-boolean@0.11.0) (2021-02-19)
|
|
114
71
|
|
|
115
|
-
|
|
116
72
|
### Features
|
|
117
73
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
74
|
+
- bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
|
|
123
75
|
|
|
124
76
|
## [0.10.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.10.1...@contentful/field-editor-boolean@0.10.2) (2021-02-09)
|
|
125
77
|
|
|
126
78
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
127
79
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
80
|
## [0.10.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.10.0...@contentful/field-editor-boolean@0.10.1) (2021-02-01)
|
|
133
81
|
|
|
134
82
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
135
83
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
84
|
# [0.10.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.9.0...@contentful/field-editor-boolean@0.10.0) (2021-01-20)
|
|
141
85
|
|
|
142
|
-
|
|
143
86
|
### Features
|
|
144
87
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
88
|
+
- update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
|
|
150
89
|
|
|
151
90
|
# [0.9.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.6...@contentful/field-editor-boolean@0.9.0) (2021-01-12)
|
|
152
91
|
|
|
153
|
-
|
|
154
92
|
### Features
|
|
155
93
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
94
|
+
- update minimal required Forma version to the 3.73.12 ([#552](https://github.com/contentful/field-editors/issues/552)) ([2816fd9](https://github.com/contentful/field-editors/commit/2816fd960c28815faebf49a9ef8f4c4c0d91fc36))
|
|
161
95
|
|
|
162
96
|
## [0.8.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.5...@contentful/field-editor-boolean@0.8.6) (2021-01-11)
|
|
163
97
|
|
|
164
|
-
|
|
165
98
|
### Bug Fixes
|
|
166
99
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
100
|
+
- clear button should respect disabled state ([#551](https://github.com/contentful/field-editors/issues/551)) ([a33c3ec](https://github.com/contentful/field-editors/commit/a33c3ec1f88753dfcea09fb62f5c1725fe379120))
|
|
172
101
|
|
|
173
102
|
## [0.8.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.4...@contentful/field-editor-boolean@0.8.5) (2020-12-16)
|
|
174
103
|
|
|
175
104
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
176
105
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
106
|
## [0.8.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.3...@contentful/field-editor-boolean@0.8.4) (2020-11-06)
|
|
182
107
|
|
|
183
108
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
184
109
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
110
|
## [0.8.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.2...@contentful/field-editor-boolean@0.8.3) (2020-11-06)
|
|
190
111
|
|
|
191
112
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
192
113
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
114
|
## [0.8.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.1...@contentful/field-editor-boolean@0.8.2) (2020-10-28)
|
|
198
115
|
|
|
199
116
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
|
200
117
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
118
|
## [0.8.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-boolean@0.8.0...@contentful/field-editor-boolean@0.8.1) (2020-08-24)
|
|
206
119
|
|
|
207
120
|
**Note:** Version bump only for package @contentful/field-editor-boolean
|
package/README.md
CHANGED
|
@@ -7,6 +7,5 @@ npm install @contentful/field-editor-boolean
|
|
|
7
7
|
This package contains a React `BooleanEditor` component that is used as default for `Boolean` field type in the Contentful web application.
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
|
-
import '@contentful/forma-36-react-components/dist/styles.css';
|
|
11
10
|
import { BooleanEditor } from '@contentful/field-editor-boolean';
|
|
12
11
|
```
|
|
@@ -8,7 +8,7 @@ var React = require('react');
|
|
|
8
8
|
var get = _interopDefault(require('lodash/get'));
|
|
9
9
|
var nanoid = require('nanoid');
|
|
10
10
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
11
|
-
var
|
|
11
|
+
var f36Components = require('@contentful/f36-components');
|
|
12
12
|
|
|
13
13
|
function BooleanEditor(props) {
|
|
14
14
|
var field = props.field;
|
|
@@ -38,32 +38,31 @@ function BooleanEditor(props) {
|
|
|
38
38
|
setValue(null);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
return React.createElement(
|
|
41
|
+
return React.createElement(f36Components.Flex, {
|
|
42
42
|
testId: "boolean-editor",
|
|
43
43
|
alignItems: "center",
|
|
44
44
|
marginTop: "spacingS"
|
|
45
45
|
}, options.map(function (item) {
|
|
46
46
|
var id = ['entity', field.id, field.locale, item.value, item.id].join('.');
|
|
47
47
|
var checked = value === item.value;
|
|
48
|
-
return React.createElement(
|
|
48
|
+
return React.createElement(f36Components.Flex, {
|
|
49
49
|
marginRight: "spacingM",
|
|
50
50
|
key: id
|
|
51
|
-
}, React.createElement(
|
|
52
|
-
labelIsLight: true,
|
|
51
|
+
}, React.createElement(f36Components.Radio, {
|
|
53
52
|
id: id,
|
|
54
|
-
|
|
55
|
-
labelText: item.label,
|
|
56
|
-
disabled: disabled,
|
|
53
|
+
isDisabled: disabled,
|
|
57
54
|
value: item.value === undefined ? '' : String(item.value),
|
|
55
|
+
isChecked: checked,
|
|
58
56
|
onChange: function onChange(e) {
|
|
59
57
|
if (e.target.checked) {
|
|
60
58
|
setOption(e.target.value);
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
|
-
}));
|
|
64
|
-
}), value !== undefined && React.createElement(
|
|
61
|
+
}, item.label));
|
|
62
|
+
}), value !== undefined && React.createElement(f36Components.TextLink, {
|
|
63
|
+
as: "button",
|
|
65
64
|
testId: "boolean-editor-clear",
|
|
66
|
-
|
|
65
|
+
isDisabled: disabled,
|
|
67
66
|
onClick: clearOption
|
|
68
67
|
}, "Clear"));
|
|
69
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-boolean.cjs.development.js","sources":["../src/BooleanEditor.tsx"],"sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { nanoid } from 'nanoid';\nimport { FieldAPI, ParametersAPI, FieldConnector } from '@contentful/field-editor-shared';\nimport {
|
|
1
|
+
{"version":3,"file":"field-editor-boolean.cjs.development.js","sources":["../src/BooleanEditor.tsx"],"sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { nanoid } from 'nanoid';\nimport { FieldAPI, ParametersAPI, FieldConnector } from '@contentful/field-editor-shared';\n\nimport { TextLink, Flex, Radio } from '@contentful/f36-components';\n\nexport interface BooleanEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.parameters\n */\n parameters?: ParametersAPI & {\n instance: {\n trueLabel?: string;\n falseLabel?: string;\n };\n };\n}\n\nexport function BooleanEditor(props: BooleanEditorProps) {\n const { field } = props;\n\n const options = [\n { value: true, label: get(props.parameters, ['instance', 'trueLabel'], 'Yes'), id: nanoid(6) },\n { value: false, label: get(props.parameters, ['instance', 'falseLabel'], 'No'), id: nanoid(6) },\n ];\n\n return (\n <FieldConnector<boolean>\n throttle={0}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ disabled, value, setValue }) => {\n const setOption = (value: string) => {\n setValue(value === 'true' ? true : false);\n };\n\n const clearOption = () => {\n setValue(null);\n };\n\n return (\n <Flex testId=\"boolean-editor\" alignItems=\"center\" marginTop=\"spacingS\">\n {options.map((item) => {\n const id = ['entity', field.id, field.locale, item.value, item.id].join('.');\n const checked = value === item.value;\n return (\n <Flex marginRight=\"spacingM\" key={id}>\n <Radio\n id={id}\n isDisabled={disabled}\n value={item.value === undefined ? '' : String(item.value)}\n isChecked={checked}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.checked) {\n setOption(e.target.value);\n }\n }}>\n {item.label}\n </Radio>\n </Flex>\n );\n })}\n {value !== undefined && (\n <TextLink\n as=\"button\"\n testId=\"boolean-editor-clear\"\n isDisabled={disabled}\n onClick={clearOption}>\n Clear\n </TextLink>\n )}\n </Flex>\n );\n }}\n </FieldConnector>\n );\n}\n\nBooleanEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["BooleanEditor","props","field","options","value","label","get","parameters","id","nanoid","React","FieldConnector","throttle","isInitiallyDisabled","disabled","setValue","setOption","clearOption","Flex","testId","alignItems","marginTop","map","item","locale","join","checked","marginRight","key","Radio","isDisabled","undefined","String","isChecked","onChange","e","target","TextLink","as","onClick","defaultProps"],"mappings":";;;;;;;;;;;;SA6BgBA,cAAcC;AAC5B,MAAQC,KAAR,GAAkBD,KAAlB,CAAQC,KAAR;AAEA,MAAMC,OAAO,GAAG,CACd;AAAEC,IAAAA,KAAK,EAAE,IAAT;AAAeC,IAAAA,KAAK,EAAEC,GAAG,CAACL,KAAK,CAACM,UAAP,EAAmB,CAAC,UAAD,EAAa,WAAb,CAAnB,EAA8C,KAA9C,CAAzB;AAA+EC,IAAAA,EAAE,EAAEC,aAAM,CAAC,CAAD;AAAzF,GADc,EAEd;AAAEL,IAAAA,KAAK,EAAE,KAAT;AAAgBC,IAAAA,KAAK,EAAEC,GAAG,CAACL,KAAK,CAACM,UAAP,EAAmB,CAAC,UAAD,EAAa,YAAb,CAAnB,EAA+C,IAA/C,CAA1B;AAAgFC,IAAAA,EAAE,EAAEC,aAAM,CAAC,CAAD;AAA1F,GAFc,CAAhB;AAKA,SACEC,mBAAA,CAACC,gCAAD;AACEC,IAAAA,QAAQ,EAAE;AACVV,IAAAA,KAAK,EAAEA;AACPW,IAAAA,mBAAmB,EAAEZ,KAAK,CAACY;GAH7B,EAIG;QAAGC,gBAAAA;QAAUV,aAAAA;QAAOW,gBAAAA;;AACnB,QAAMC,SAAS,GAAG,SAAZA,SAAY,CAACZ,KAAD;AAChBW,MAAAA,QAAQ,CAACX,KAAK,KAAK,MAAV,GAAmB,IAAnB,GAA0B,KAA3B,CAAR;AACD,KAFD;;AAIA,QAAMa,WAAW,GAAG,SAAdA,WAAc;AAClBF,MAAAA,QAAQ,CAAC,IAAD,CAAR;AACD,KAFD;;AAIA,WACEL,mBAAA,CAACQ,kBAAD;AAAMC,MAAAA,MAAM,EAAC;AAAiBC,MAAAA,UAAU,EAAC;AAASC,MAAAA,SAAS,EAAC;KAA5D,EACGlB,OAAO,CAACmB,GAAR,CAAY,UAACC,IAAD;AACX,UAAMf,EAAE,GAAG,CAAC,QAAD,EAAWN,KAAK,CAACM,EAAjB,EAAqBN,KAAK,CAACsB,MAA3B,EAAmCD,IAAI,CAACnB,KAAxC,EAA+CmB,IAAI,CAACf,EAApD,EAAwDiB,IAAxD,CAA6D,GAA7D,CAAX;AACA,UAAMC,OAAO,GAAGtB,KAAK,KAAKmB,IAAI,CAACnB,KAA/B;AACA,aACEM,mBAAA,CAACQ,kBAAD;AAAMS,QAAAA,WAAW,EAAC;AAAWC,QAAAA,GAAG,EAAEpB;OAAlC,EACEE,mBAAA,CAACmB,mBAAD;AACErB,QAAAA,EAAE,EAAEA;AACJsB,QAAAA,UAAU,EAAEhB;AACZV,QAAAA,KAAK,EAAEmB,IAAI,CAACnB,KAAL,KAAe2B,SAAf,GAA2B,EAA3B,GAAgCC,MAAM,CAACT,IAAI,CAACnB,KAAN;AAC7C6B,QAAAA,SAAS,EAAEP;AACXQ,QAAAA,QAAQ,EAAE,kBAACC,CAAD;AACR,cAAIA,CAAC,CAACC,MAAF,CAASV,OAAb,EAAsB;AACpBV,YAAAA,SAAS,CAACmB,CAAC,CAACC,MAAF,CAAShC,KAAV,CAAT;AACD;AACF;OATH,EAUGmB,IAAI,CAAClB,KAVR,CADF,CADF;AAgBD,KAnBA,CADH,EAqBGD,KAAK,KAAK2B,SAAV,IACCrB,mBAAA,CAAC2B,sBAAD;AACEC,MAAAA,EAAE,EAAC;AACHnB,MAAAA,MAAM,EAAC;AACPW,MAAAA,UAAU,EAAEhB;AACZyB,MAAAA,OAAO,EAAEtB;KAJX,SAAA,CAtBJ,CADF;AAiCD,GA9CH,CADF;AAkDD;AAEDjB,aAAa,CAACwC,YAAd,GAA6B;AAC3B3B,EAAAA,mBAAmB,EAAE;AADM,CAA7B;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=require("lodash/get"))&&"object"==typeof e&&"default"in e?e.default:e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=require("lodash/get"))&&"object"==typeof e&&"default"in e?e.default:e,i=require("nanoid"),l=require("@contentful/field-editor-shared"),n=require("@contentful/f36-components");function r(e){var r=e.field,o=[{value:!0,label:a(e.parameters,["instance","trueLabel"],"Yes"),id:i.nanoid(6)},{value:!1,label:a(e.parameters,["instance","falseLabel"],"No"),id:i.nanoid(6)}];return t.createElement(l.FieldConnector,{throttle:0,field:r,isInitiallyDisabled:e.isInitiallyDisabled},(function(e){var a=e.disabled,i=e.value,l=e.setValue;return t.createElement(n.Flex,{testId:"boolean-editor",alignItems:"center",marginTop:"spacingS"},o.map((function(e){var o=["entity",r.id,r.locale,e.value,e.id].join("."),d=i===e.value;return t.createElement(n.Flex,{marginRight:"spacingM",key:o},t.createElement(n.Radio,{id:o,isDisabled:a,value:void 0===e.value?"":String(e.value),isChecked:d,onChange:function(e){e.target.checked&&function(e){l("true"===e)}(e.target.value)}},e.label))})),void 0!==i&&t.createElement(n.TextLink,{as:"button",testId:"boolean-editor-clear",isDisabled:a,onClick:function(){l(null)}},"Clear"))}))}r.defaultProps={isInitiallyDisabled:!0},exports.BooleanEditor=r;
|
|
2
2
|
//# sourceMappingURL=field-editor-boolean.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-boolean.cjs.production.min.js","sources":["../src/BooleanEditor.tsx"],"sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { nanoid } from 'nanoid';\nimport { FieldAPI, ParametersAPI, FieldConnector } from '@contentful/field-editor-shared';\nimport {
|
|
1
|
+
{"version":3,"file":"field-editor-boolean.cjs.production.min.js","sources":["../src/BooleanEditor.tsx"],"sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { nanoid } from 'nanoid';\nimport { FieldAPI, ParametersAPI, FieldConnector } from '@contentful/field-editor-shared';\n\nimport { TextLink, Flex, Radio } from '@contentful/f36-components';\n\nexport interface BooleanEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.parameters\n */\n parameters?: ParametersAPI & {\n instance: {\n trueLabel?: string;\n falseLabel?: string;\n };\n };\n}\n\nexport function BooleanEditor(props: BooleanEditorProps) {\n const { field } = props;\n\n const options = [\n { value: true, label: get(props.parameters, ['instance', 'trueLabel'], 'Yes'), id: nanoid(6) },\n { value: false, label: get(props.parameters, ['instance', 'falseLabel'], 'No'), id: nanoid(6) },\n ];\n\n return (\n <FieldConnector<boolean>\n throttle={0}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ disabled, value, setValue }) => {\n const setOption = (value: string) => {\n setValue(value === 'true' ? true : false);\n };\n\n const clearOption = () => {\n setValue(null);\n };\n\n return (\n <Flex testId=\"boolean-editor\" alignItems=\"center\" marginTop=\"spacingS\">\n {options.map((item) => {\n const id = ['entity', field.id, field.locale, item.value, item.id].join('.');\n const checked = value === item.value;\n return (\n <Flex marginRight=\"spacingM\" key={id}>\n <Radio\n id={id}\n isDisabled={disabled}\n value={item.value === undefined ? '' : String(item.value)}\n isChecked={checked}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.checked) {\n setOption(e.target.value);\n }\n }}>\n {item.label}\n </Radio>\n </Flex>\n );\n })}\n {value !== undefined && (\n <TextLink\n as=\"button\"\n testId=\"boolean-editor-clear\"\n isDisabled={disabled}\n onClick={clearOption}>\n Clear\n </TextLink>\n )}\n </Flex>\n );\n }}\n </FieldConnector>\n );\n}\n\nBooleanEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["BooleanEditor","props","field","options","value","label","get","parameters","id","nanoid","React","FieldConnector","throttle","isInitiallyDisabled","disabled","setValue","Flex","testId","alignItems","marginTop","map","item","locale","join","checked","marginRight","key","Radio","isDisabled","undefined","String","isChecked","onChange","e","target","setOption","TextLink","as","onClick","defaultProps"],"mappings":"0RA6BgBA,EAAcC,OACpBC,EAAUD,EAAVC,MAEFC,EAAU,CACd,CAAEC,OAAO,EAAMC,MAAOC,EAAIL,EAAMM,WAAY,CAAC,WAAY,aAAc,OAAQC,GAAIC,SAAO,IAC1F,CAAEL,OAAO,EAAOC,MAAOC,EAAIL,EAAMM,WAAY,CAAC,WAAY,cAAe,MAAOC,GAAIC,SAAO,YAI3FC,gBAACC,kBACCC,SAAU,EACVV,MAAOA,EACPW,oBAAqBZ,EAAMY,sBAC1B,gBAAGC,IAAAA,SAAUV,IAAAA,MAAOW,IAAAA,gBAUjBL,gBAACM,QAAKC,OAAO,iBAAiBC,WAAW,SAASC,UAAU,YACzDhB,EAAQiB,KAAI,SAACC,OACNb,EAAK,CAAC,SAAUN,EAAMM,GAAIN,EAAMoB,OAAQD,EAAKjB,MAAOiB,EAAKb,IAAIe,KAAK,KAClEC,EAAUpB,IAAUiB,EAAKjB,aAE7BM,gBAACM,QAAKS,YAAY,WAAWC,IAAKlB,GAChCE,gBAACiB,SACCnB,GAAIA,EACJoB,WAAYd,EACZV,WAAsByB,IAAfR,EAAKjB,MAAsB,GAAK0B,OAAOT,EAAKjB,OACnD2B,UAAWP,EACXQ,SAAU,SAACC,GACLA,EAAEC,OAAOV,SArBT,SAACpB,GACjBW,EAAmB,SAAVX,GAqBK+B,CAAUF,EAAEC,OAAO9B,SAGtBiB,EAAKhB,gBAKHwB,IAAVzB,GACCM,gBAAC0B,YACCC,GAAG,SACHpB,OAAO,uBACPW,WAAYd,EACZwB,QA/BY,WAClBvB,EAAS,qBAyCnBf,EAAcuC,aAAe,CAC3B1B,qBAAqB"}
|
|
@@ -2,7 +2,7 @@ import { createElement } from 'react';
|
|
|
2
2
|
import get from 'lodash-es/get';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
import { FieldConnector } from '@contentful/field-editor-shared';
|
|
5
|
-
import { Flex,
|
|
5
|
+
import { Flex, Radio, TextLink } from '@contentful/f36-components';
|
|
6
6
|
|
|
7
7
|
function BooleanEditor(props) {
|
|
8
8
|
var field = props.field;
|
|
@@ -42,22 +42,21 @@ function BooleanEditor(props) {
|
|
|
42
42
|
return createElement(Flex, {
|
|
43
43
|
marginRight: "spacingM",
|
|
44
44
|
key: id
|
|
45
|
-
}, createElement(
|
|
46
|
-
labelIsLight: true,
|
|
45
|
+
}, createElement(Radio, {
|
|
47
46
|
id: id,
|
|
48
|
-
|
|
49
|
-
labelText: item.label,
|
|
50
|
-
disabled: disabled,
|
|
47
|
+
isDisabled: disabled,
|
|
51
48
|
value: item.value === undefined ? '' : String(item.value),
|
|
49
|
+
isChecked: checked,
|
|
52
50
|
onChange: function onChange(e) {
|
|
53
51
|
if (e.target.checked) {
|
|
54
52
|
setOption(e.target.value);
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
|
-
}));
|
|
55
|
+
}, item.label));
|
|
58
56
|
}), value !== undefined && createElement(TextLink, {
|
|
57
|
+
as: "button",
|
|
59
58
|
testId: "boolean-editor-clear",
|
|
60
|
-
|
|
59
|
+
isDisabled: disabled,
|
|
61
60
|
onClick: clearOption
|
|
62
61
|
}, "Clear"));
|
|
63
62
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-boolean.esm.js","sources":["../src/BooleanEditor.tsx"],"sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { nanoid } from 'nanoid';\nimport { FieldAPI, ParametersAPI, FieldConnector } from '@contentful/field-editor-shared';\nimport {
|
|
1
|
+
{"version":3,"file":"field-editor-boolean.esm.js","sources":["../src/BooleanEditor.tsx"],"sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { nanoid } from 'nanoid';\nimport { FieldAPI, ParametersAPI, FieldConnector } from '@contentful/field-editor-shared';\n\nimport { TextLink, Flex, Radio } from '@contentful/f36-components';\n\nexport interface BooleanEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.parameters\n */\n parameters?: ParametersAPI & {\n instance: {\n trueLabel?: string;\n falseLabel?: string;\n };\n };\n}\n\nexport function BooleanEditor(props: BooleanEditorProps) {\n const { field } = props;\n\n const options = [\n { value: true, label: get(props.parameters, ['instance', 'trueLabel'], 'Yes'), id: nanoid(6) },\n { value: false, label: get(props.parameters, ['instance', 'falseLabel'], 'No'), id: nanoid(6) },\n ];\n\n return (\n <FieldConnector<boolean>\n throttle={0}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ disabled, value, setValue }) => {\n const setOption = (value: string) => {\n setValue(value === 'true' ? true : false);\n };\n\n const clearOption = () => {\n setValue(null);\n };\n\n return (\n <Flex testId=\"boolean-editor\" alignItems=\"center\" marginTop=\"spacingS\">\n {options.map((item) => {\n const id = ['entity', field.id, field.locale, item.value, item.id].join('.');\n const checked = value === item.value;\n return (\n <Flex marginRight=\"spacingM\" key={id}>\n <Radio\n id={id}\n isDisabled={disabled}\n value={item.value === undefined ? '' : String(item.value)}\n isChecked={checked}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.checked) {\n setOption(e.target.value);\n }\n }}>\n {item.label}\n </Radio>\n </Flex>\n );\n })}\n {value !== undefined && (\n <TextLink\n as=\"button\"\n testId=\"boolean-editor-clear\"\n isDisabled={disabled}\n onClick={clearOption}>\n Clear\n </TextLink>\n )}\n </Flex>\n );\n }}\n </FieldConnector>\n );\n}\n\nBooleanEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["BooleanEditor","props","field","options","value","label","get","parameters","id","nanoid","React","FieldConnector","throttle","isInitiallyDisabled","disabled","setValue","setOption","clearOption","Flex","testId","alignItems","marginTop","map","item","locale","join","checked","marginRight","key","Radio","isDisabled","undefined","String","isChecked","onChange","e","target","TextLink","as","onClick","defaultProps"],"mappings":";;;;;;SA6BgBA,cAAcC;AAC5B,MAAQC,KAAR,GAAkBD,KAAlB,CAAQC,KAAR;AAEA,MAAMC,OAAO,GAAG,CACd;AAAEC,IAAAA,KAAK,EAAE,IAAT;AAAeC,IAAAA,KAAK,EAAEC,GAAG,CAACL,KAAK,CAACM,UAAP,EAAmB,CAAC,UAAD,EAAa,WAAb,CAAnB,EAA8C,KAA9C,CAAzB;AAA+EC,IAAAA,EAAE,EAAEC,MAAM,CAAC,CAAD;AAAzF,GADc,EAEd;AAAEL,IAAAA,KAAK,EAAE,KAAT;AAAgBC,IAAAA,KAAK,EAAEC,GAAG,CAACL,KAAK,CAACM,UAAP,EAAmB,CAAC,UAAD,EAAa,YAAb,CAAnB,EAA+C,IAA/C,CAA1B;AAAgFC,IAAAA,EAAE,EAAEC,MAAM,CAAC,CAAD;AAA1F,GAFc,CAAhB;AAKA,SACEC,aAAA,CAACC,cAAD;AACEC,IAAAA,QAAQ,EAAE;AACVV,IAAAA,KAAK,EAAEA;AACPW,IAAAA,mBAAmB,EAAEZ,KAAK,CAACY;GAH7B,EAIG;QAAGC,gBAAAA;QAAUV,aAAAA;QAAOW,gBAAAA;;AACnB,QAAMC,SAAS,GAAG,SAAZA,SAAY,CAACZ,KAAD;AAChBW,MAAAA,QAAQ,CAACX,KAAK,KAAK,MAAV,GAAmB,IAAnB,GAA0B,KAA3B,CAAR;AACD,KAFD;;AAIA,QAAMa,WAAW,GAAG,SAAdA,WAAc;AAClBF,MAAAA,QAAQ,CAAC,IAAD,CAAR;AACD,KAFD;;AAIA,WACEL,aAAA,CAACQ,IAAD;AAAMC,MAAAA,MAAM,EAAC;AAAiBC,MAAAA,UAAU,EAAC;AAASC,MAAAA,SAAS,EAAC;KAA5D,EACGlB,OAAO,CAACmB,GAAR,CAAY,UAACC,IAAD;AACX,UAAMf,EAAE,GAAG,CAAC,QAAD,EAAWN,KAAK,CAACM,EAAjB,EAAqBN,KAAK,CAACsB,MAA3B,EAAmCD,IAAI,CAACnB,KAAxC,EAA+CmB,IAAI,CAACf,EAApD,EAAwDiB,IAAxD,CAA6D,GAA7D,CAAX;AACA,UAAMC,OAAO,GAAGtB,KAAK,KAAKmB,IAAI,CAACnB,KAA/B;AACA,aACEM,aAAA,CAACQ,IAAD;AAAMS,QAAAA,WAAW,EAAC;AAAWC,QAAAA,GAAG,EAAEpB;OAAlC,EACEE,aAAA,CAACmB,KAAD;AACErB,QAAAA,EAAE,EAAEA;AACJsB,QAAAA,UAAU,EAAEhB;AACZV,QAAAA,KAAK,EAAEmB,IAAI,CAACnB,KAAL,KAAe2B,SAAf,GAA2B,EAA3B,GAAgCC,MAAM,CAACT,IAAI,CAACnB,KAAN;AAC7C6B,QAAAA,SAAS,EAAEP;AACXQ,QAAAA,QAAQ,EAAE,kBAACC,CAAD;AACR,cAAIA,CAAC,CAACC,MAAF,CAASV,OAAb,EAAsB;AACpBV,YAAAA,SAAS,CAACmB,CAAC,CAACC,MAAF,CAAShC,KAAV,CAAT;AACD;AACF;OATH,EAUGmB,IAAI,CAAClB,KAVR,CADF,CADF;AAgBD,KAnBA,CADH,EAqBGD,KAAK,KAAK2B,SAAV,IACCrB,aAAA,CAAC2B,QAAD;AACEC,MAAAA,EAAE,EAAC;AACHnB,MAAAA,MAAM,EAAC;AACPW,MAAAA,UAAU,EAAEhB;AACZyB,MAAAA,OAAO,EAAEtB;KAJX,SAAA,CAtBJ,CADF;AAiCD,GA9CH,CADF;AAkDD;AAEDjB,aAAa,CAACwC,YAAd,GAA6B;AAC3B3B,EAAAA,mBAAmB,EAAE;AADM,CAA7B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-boolean",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/field-editor-boolean.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"tsc": "tsc -p ./ --noEmit"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@contentful/
|
|
25
|
-
"@contentful/
|
|
26
|
-
"@contentful/
|
|
24
|
+
"@contentful/f36-components": "beta",
|
|
25
|
+
"@contentful/f36-tokens": "beta",
|
|
26
|
+
"@contentful/field-editor-shared": "^0.26.0",
|
|
27
27
|
"emotion": "^10.0.17",
|
|
28
28
|
"lodash": "^4.17.15",
|
|
29
29
|
"lodash-es": "^4.17.15",
|
|
30
30
|
"nanoid": "^3.1.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@contentful/field-editor-test-utils": "^0.
|
|
33
|
+
"@contentful/field-editor-test-utils": "^0.19.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=16.8.0"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "f86ba28db3f34cffc0dc2580bf21297542f331c9"
|
|
49
49
|
}
|