@contentful/field-editor-radio 0.13.3 → 0.15.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 +22 -83
- package/README.md +0 -1
- package/dist/field-editor-radio.cjs.development.js +11 -12
- package/dist/field-editor-radio.cjs.development.js.map +1 -1
- package/dist/field-editor-radio.cjs.production.min.js +1 -1
- package/dist/field-editor-radio.cjs.production.min.js.map +1 -1
- package/dist/field-editor-radio.esm.js +9 -10
- package/dist/field-editor-radio.esm.js.map +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,181 +3,120 @@
|
|
|
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-radio
|
|
6
|
+
# [0.15.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.14.1...@contentful/field-editor-radio@0.15.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.
|
|
16
|
+
## [0.14.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.14.0...@contentful/field-editor-radio@0.14.1) (2021-10-14)
|
|
15
17
|
|
|
16
18
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
17
19
|
|
|
20
|
+
# [0.14.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.13.4...@contentful/field-editor-radio@0.14.0) (2021-10-06)
|
|
18
21
|
|
|
22
|
+
### Features
|
|
19
23
|
|
|
24
|
+
- [EXT-3161] bump app sdk to v4 ([#881](https://github.com/contentful/field-editors/issues/881)) ([9c4a2af](https://github.com/contentful/field-editors/commit/9c4a2af07da203d59fb5f15c3a5188ecc64b1d44))
|
|
20
25
|
|
|
26
|
+
## [0.13.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.13.3...@contentful/field-editor-radio@0.13.4) (2021-09-17)
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
29
|
+
|
|
30
|
+
## [0.13.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.13.2...@contentful/field-editor-radio@0.13.3) (2021-09-16)
|
|
23
31
|
|
|
24
32
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
25
33
|
|
|
34
|
+
## [0.13.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.13.1...@contentful/field-editor-radio@0.13.2) (2021-08-19)
|
|
26
35
|
|
|
36
|
+
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
27
37
|
|
|
38
|
+
## [0.13.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.13.0...@contentful/field-editor-radio@0.13.1) (2021-07-29)
|
|
28
39
|
|
|
40
|
+
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
29
41
|
|
|
30
42
|
# [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.6...@contentful/field-editor-radio@0.13.0) (2021-07-23)
|
|
31
43
|
|
|
32
|
-
|
|
33
44
|
### Features
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
- 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
|
|
40
47
|
|
|
41
48
|
## [0.12.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.3...@contentful/field-editor-radio@0.12.6) (2021-07-06)
|
|
42
49
|
|
|
43
50
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
52
|
## [0.12.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.3...@contentful/field-editor-radio@0.12.5) (2021-07-06)
|
|
50
53
|
|
|
51
54
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
56
|
## [0.12.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.3...@contentful/field-editor-radio@0.12.4) (2021-06-23)
|
|
58
57
|
|
|
59
58
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
60
|
## [0.12.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.2...@contentful/field-editor-radio@0.12.3) (2021-06-23)
|
|
66
61
|
|
|
67
62
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
64
|
## [0.12.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.1...@contentful/field-editor-radio@0.12.2) (2021-06-22)
|
|
74
65
|
|
|
75
66
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
68
|
## [0.12.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.12.0...@contentful/field-editor-radio@0.12.1) (2021-03-05)
|
|
82
69
|
|
|
83
70
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
72
|
# [0.12.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.11.1...@contentful/field-editor-radio@0.12.0) (2021-02-19)
|
|
90
73
|
|
|
91
|
-
|
|
92
74
|
### Features
|
|
93
75
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
- bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
|
|
99
77
|
|
|
100
78
|
## [0.11.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.11.1...@contentful/field-editor-radio@0.11.2) (2021-02-09)
|
|
101
79
|
|
|
102
80
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
103
81
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
82
|
## [0.11.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.11.0...@contentful/field-editor-radio@0.11.1) (2021-02-01)
|
|
109
83
|
|
|
110
84
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
111
85
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
86
|
# [0.11.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.10.1...@contentful/field-editor-radio@0.11.0) (2021-01-20)
|
|
117
87
|
|
|
118
|
-
|
|
119
88
|
### Features
|
|
120
89
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
90
|
+
- 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))
|
|
126
91
|
|
|
127
92
|
## [0.10.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.10.0...@contentful/field-editor-radio@0.10.1) (2021-01-15)
|
|
128
93
|
|
|
129
|
-
|
|
130
94
|
### Bug Fixes
|
|
131
95
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
96
|
+
- 🐛 small layout adjustments ([#555](https://github.com/contentful/field-editors/issues/555)) ([235c594](https://github.com/contentful/field-editors/commit/235c5941db152d2921a9ef134c1a71b0069a4dc2))
|
|
137
97
|
|
|
138
98
|
# [0.10.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.9.5...@contentful/field-editor-radio@0.10.0) (2021-01-12)
|
|
139
99
|
|
|
140
|
-
|
|
141
100
|
### Features
|
|
142
101
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
102
|
+
- 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))
|
|
148
103
|
|
|
149
104
|
## [0.9.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.9.4...@contentful/field-editor-radio@0.9.5) (2020-12-16)
|
|
150
105
|
|
|
151
106
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
152
107
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
108
|
## [0.9.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.9.3...@contentful/field-editor-radio@0.9.4) (2020-11-06)
|
|
158
109
|
|
|
159
110
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
160
111
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
112
|
## [0.9.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.9.2...@contentful/field-editor-radio@0.9.3) (2020-11-06)
|
|
166
113
|
|
|
167
114
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
168
115
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
116
|
## [0.9.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.9.1...@contentful/field-editor-radio@0.9.2) (2020-10-28)
|
|
174
117
|
|
|
175
118
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
|
176
119
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
120
|
## [0.9.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-radio@0.9.0...@contentful/field-editor-radio@0.9.1) (2020-08-24)
|
|
182
121
|
|
|
183
122
|
**Note:** Version bump only for package @contentful/field-editor-radio
|
package/README.md
CHANGED
|
@@ -7,6 +7,5 @@ npm install @contentful/field-editor-radio
|
|
|
7
7
|
This package contains a React `RadioEditor` component that is used for the `Text`,`Symbol`,`Integer` and `Number` field types in the Contentful web application.
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
|
-
import '@contentful/forma-36-react-components/dist/styles.css';
|
|
11
10
|
import { RadioEditor } from '@contentful/field-editor-radio';
|
|
12
11
|
```
|
|
@@ -8,8 +8,8 @@ var React = require('react');
|
|
|
8
8
|
var emotion = require('emotion');
|
|
9
9
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
10
10
|
var fieldEditorDropdown = require('@contentful/field-editor-dropdown');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var tokens = _interopDefault(require('@contentful/f36-tokens'));
|
|
12
|
+
var f36Components = require('@contentful/f36-components');
|
|
13
13
|
|
|
14
14
|
var form = /*#__PURE__*/emotion.css({
|
|
15
15
|
marginTop: tokens.spacingS
|
|
@@ -49,29 +49,28 @@ function RadioEditor(props) {
|
|
|
49
49
|
setValue(undefined);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
return React.createElement(
|
|
52
|
+
return React.createElement(f36Components.Form, {
|
|
53
53
|
testId: "radio-editor",
|
|
54
|
-
spacing: "condensed",
|
|
55
54
|
className: emotion.cx(form, direction === 'rtl' ? rightToLeft : '')
|
|
56
55
|
}, options.map(function (item, index) {
|
|
57
56
|
var id = ['entity', field.id, field.locale, index, item.id].join('.');
|
|
58
57
|
var checked = value === item.value;
|
|
59
|
-
return React.createElement(
|
|
58
|
+
return React.createElement(f36Components.Flex, {
|
|
60
59
|
key: id,
|
|
61
|
-
alignItems: "center"
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
marginBottom: "spacingS"
|
|
62
|
+
}, React.createElement(f36Components.Radio, {
|
|
64
63
|
id: id,
|
|
65
|
-
|
|
66
|
-
labelText: item.label,
|
|
67
|
-
disabled: disabled,
|
|
64
|
+
isDisabled: disabled,
|
|
68
65
|
value: item.value === undefined ? '' : String(item.value),
|
|
66
|
+
isChecked: checked,
|
|
69
67
|
onChange: function onChange(e) {
|
|
70
68
|
if (e.target.checked) {
|
|
71
69
|
setOption(e.target.value);
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
|
-
}), checked && React.createElement(
|
|
72
|
+
}, item.label), checked && React.createElement(f36Components.TextLink, {
|
|
73
|
+
as: "button",
|
|
75
74
|
className: clearBtn,
|
|
76
75
|
onClick: clearOption
|
|
77
76
|
}, "Clear"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-radio.cjs.development.js","sources":["../src/styles.ts","../src/RadioEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/
|
|
1
|
+
{"version":3,"file":"field-editor-radio.cjs.development.js","sources":["../src/styles.ts","../src/RadioEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const form = css({\n marginTop: tokens.spacingS,\n});\n\nexport const rightToLeft = css({\n direction: 'rtl',\n});\n\nexport const clearBtn = css({ marginLeft: tokens.spacingL });\n","import * as React from 'react';\nimport { cx } from 'emotion';\nimport {\n FieldAPI,\n FieldConnector,\n PredefinedValuesError,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { getOptions, parseValue } from '@contentful/field-editor-dropdown';\nimport * as styles from './styles';\n\nimport { TextLink, Flex, Radio, Form } from '@contentful/f36-components';\n\nexport interface RadioEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function RadioEditor(props: RadioEditorProps) {\n const { field, locales } = props;\n\n const options = getOptions(field);\n const misconfigured = options.length === 0;\n\n if (misconfigured) {\n return <PredefinedValuesError />;\n }\n\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string | number>\n throttle={0}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ disabled, value, setValue }) => {\n const setOption = (value: string) => {\n setValue(parseValue(value, field.type));\n };\n const clearOption = () => {\n setValue(undefined);\n };\n\n return (\n <Form\n testId=\"radio-editor\"\n className={cx(styles.form, direction === 'rtl' ? styles.rightToLeft : '')}>\n {options.map((item, index) => {\n const id = ['entity', field.id, field.locale, index, item.id].join('.');\n const checked = value === item.value;\n return (\n <Flex key={id} alignItems=\"center\" marginBottom=\"spacingS\">\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 {checked && (\n <TextLink as=\"button\" className={styles.clearBtn} onClick={clearOption}>\n Clear\n </TextLink>\n )}\n </Flex>\n );\n })}\n </Form>\n );\n }}\n </FieldConnector>\n );\n}\n\nRadioEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["form","css","marginTop","tokens","spacingS","rightToLeft","direction","clearBtn","marginLeft","spacingL","RadioEditor","props","field","locales","options","getOptions","misconfigured","length","React","PredefinedValuesError","locale","FieldConnector","throttle","isInitiallyDisabled","disabled","value","setValue","setOption","parseValue","type","clearOption","undefined","Form","testId","className","cx","styles","map","item","index","id","join","checked","Flex","key","alignItems","marginBottom","Radio","isDisabled","String","isChecked","onChange","e","target","label","TextLink","as","onClick","defaultProps"],"mappings":";;;;;;;;;;;;;AAGO,IAAMA,IAAI,gBAAGC,WAAG,CAAC;AACtBC,EAAAA,SAAS,EAAEC,MAAM,CAACC;AADI,CAAD,CAAhB;AAIA,IAAMC,WAAW,gBAAGJ,WAAG,CAAC;AAC7BK,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;AAIA,IAAMC,QAAQ,gBAAGN,WAAG,CAAC;AAAEO,EAAAA,UAAU,EAAEL,MAAM,CAACM;AAArB,CAAD,CAApB;;SCmBSC,YAAYC;AAC1B,MAAQC,KAAR,GAA2BD,KAA3B,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAA2BF,KAA3B,CAAeE,OAAf;AAEA,MAAMC,OAAO,GAAGC,8BAAU,CAACH,KAAD,CAA1B;AACA,MAAMI,aAAa,GAAGF,OAAO,CAACG,MAAR,KAAmB,CAAzC;;AAEA,MAAID,aAAJ,EAAmB;AACjB,WAAOE,mBAAA,CAACC,uCAAD,MAAA,CAAP;AACD;;AAED,MAAMb,SAAS,GAAGO,OAAO,CAACP,SAAR,CAAkBM,KAAK,CAACQ,MAAxB,KAAmC,KAArD;AAEA,SACEF,mBAAA,CAACG,gCAAD;AACEC,IAAAA,QAAQ,EAAE;AACVV,IAAAA,KAAK,EAAEA;AACPW,IAAAA,mBAAmB,EAAEZ,KAAK,CAACY;GAH7B,EAIG;QAAGC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;;AACnB,QAAMC,SAAS,GAAG,SAAZA,SAAY,CAACF,KAAD;AAChBC,MAAAA,QAAQ,CAACE,8BAAU,CAACH,KAAD,EAAQb,KAAK,CAACiB,IAAd,CAAX,CAAR;AACD,KAFD;;AAGA,QAAMC,WAAW,GAAG,SAAdA,WAAc;AAClBJ,MAAAA,QAAQ,CAACK,SAAD,CAAR;AACD,KAFD;;AAIA,WACEb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AA2B;AACzBnC,EAAAA,mBAAmB,EAAE;AADI,CAA3B;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),i=require("emotion"),r=require("@contentful/field-editor-shared"),n=require("@contentful/field-editor-dropdown"),l=(e=require("@contentful/f36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,a=require("@contentful/f36-components"),o=i.css({marginTop:l.spacingS}),c=i.css({direction:"rtl"}),s=i.css({marginLeft:l.spacingL});function d(e){var l=e.field,d=e.locales,u=n.getOptions(l);if(0===u.length)return t.createElement(r.PredefinedValuesError,null);var f=d.direction[l.locale]||"ltr";return t.createElement(r.FieldConnector,{throttle:0,field:l,isInitiallyDisabled:e.isInitiallyDisabled},(function(e){var r=e.disabled,d=e.value,m=e.setValue,p=function(){m(void 0)};return t.createElement(a.Form,{testId:"radio-editor",className:i.cx(o,"rtl"===f?c:"")},u.map((function(e,i){var o=["entity",l.id,l.locale,i,e.id].join("."),c=d===e.value;return t.createElement(a.Flex,{key:o,alignItems:"center",marginBottom:"spacingS"},t.createElement(a.Radio,{id:o,isDisabled:r,value:void 0===e.value?"":String(e.value),isChecked:c,onChange:function(e){e.target.checked&&function(e){m(n.parseValue(e,l.type))}(e.target.value)}},e.label),c&&t.createElement(a.TextLink,{as:"button",className:s,onClick:p},"Clear"))})))}))}d.defaultProps={isInitiallyDisabled:!0},exports.RadioEditor=d;
|
|
2
2
|
//# sourceMappingURL=field-editor-radio.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-radio.cjs.production.min.js","sources":["../src/styles.ts","../src/RadioEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/
|
|
1
|
+
{"version":3,"file":"field-editor-radio.cjs.production.min.js","sources":["../src/styles.ts","../src/RadioEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const form = css({\n marginTop: tokens.spacingS,\n});\n\nexport const rightToLeft = css({\n direction: 'rtl',\n});\n\nexport const clearBtn = css({ marginLeft: tokens.spacingL });\n","import * as React from 'react';\nimport { cx } from 'emotion';\nimport {\n FieldAPI,\n FieldConnector,\n PredefinedValuesError,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { getOptions, parseValue } from '@contentful/field-editor-dropdown';\nimport * as styles from './styles';\n\nimport { TextLink, Flex, Radio, Form } from '@contentful/f36-components';\n\nexport interface RadioEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function RadioEditor(props: RadioEditorProps) {\n const { field, locales } = props;\n\n const options = getOptions(field);\n const misconfigured = options.length === 0;\n\n if (misconfigured) {\n return <PredefinedValuesError />;\n }\n\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string | number>\n throttle={0}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ disabled, value, setValue }) => {\n const setOption = (value: string) => {\n setValue(parseValue(value, field.type));\n };\n const clearOption = () => {\n setValue(undefined);\n };\n\n return (\n <Form\n testId=\"radio-editor\"\n className={cx(styles.form, direction === 'rtl' ? styles.rightToLeft : '')}>\n {options.map((item, index) => {\n const id = ['entity', field.id, field.locale, index, item.id].join('.');\n const checked = value === item.value;\n return (\n <Flex key={id} alignItems=\"center\" marginBottom=\"spacingS\">\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 {checked && (\n <TextLink as=\"button\" className={styles.clearBtn} onClick={clearOption}>\n Clear\n </TextLink>\n )}\n </Flex>\n );\n })}\n </Form>\n );\n }}\n </FieldConnector>\n );\n}\n\nRadioEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["form","css","marginTop","tokens","spacingS","rightToLeft","direction","clearBtn","marginLeft","spacingL","RadioEditor","props","field","locales","options","getOptions","length","React","PredefinedValuesError","locale","FieldConnector","throttle","isInitiallyDisabled","disabled","value","setValue","clearOption","undefined","Form","testId","className","cx","styles","map","item","index","id","join","checked","Flex","key","alignItems","marginBottom","Radio","isDisabled","String","isChecked","onChange","e","target","parseValue","type","setOption","label","TextLink","as","onClick","defaultProps"],"mappings":"6UAGaA,EAAOC,MAAI,CACtBC,UAAWC,EAAOC,WAGPC,EAAcJ,MAAI,CAC7BK,UAAW,QAGAC,EAAWN,MAAI,CAAEO,WAAYL,EAAOM,oBCmBjCC,EAAYC,OAClBC,EAAmBD,EAAnBC,MAAOC,EAAYF,EAAZE,QAETC,EAAUC,aAAWH,MACc,IAAnBE,EAAQE,cAGrBC,gBAACC,kCAGJZ,EAAYO,EAAQP,UAAUM,EAAMO,SAAW,aAGnDF,gBAACG,kBACCC,SAAU,EACVT,MAAOA,EACPU,oBAAqBX,EAAMW,sBAC1B,gBAAGC,IAAAA,SAAUC,IAAAA,MAAOC,IAAAA,SAIbC,EAAc,WAClBD,OAASE,WAITV,gBAACW,QACCC,OAAO,eACPC,UAAWC,KAAGC,EAA2B,QAAd1B,EAAsB0B,EAAqB,KACrElB,EAAQmB,KAAI,SAACC,EAAMC,OACZC,EAAK,CAAC,SAAUxB,EAAMwB,GAAIxB,EAAMO,OAAQgB,EAAOD,EAAKE,IAAIC,KAAK,KAC7DC,EAAUd,IAAUU,EAAKV,aAE7BP,gBAACsB,QAAKC,IAAKJ,EAAIK,WAAW,SAASC,aAAa,YAC9CzB,gBAAC0B,SACCP,GAAIA,EACJQ,WAAYrB,EACZC,WAAsBG,IAAfO,EAAKV,MAAsB,GAAKqB,OAAOX,EAAKV,OACnDsB,UAAWR,EACXS,SAAU,SAACC,GACLA,EAAEC,OAAOX,SAtBT,SAACd,GACjBC,EAASyB,aAAW1B,EAAOZ,EAAMuC,OAsBnBC,CAAUJ,EAAEC,OAAOzB,SAGtBU,EAAKmB,OAEPf,GACCrB,gBAACqC,YAASC,GAAG,SAASzB,UAAWE,EAAiBwB,QAAS9B,oBAc/EhB,EAAY+C,aAAe,CACzBnC,qBAAqB"}
|
|
@@ -2,8 +2,8 @@ import { createElement } from 'react';
|
|
|
2
2
|
import { css, cx } from 'emotion';
|
|
3
3
|
import { PredefinedValuesError, FieldConnector } from '@contentful/field-editor-shared';
|
|
4
4
|
import { getOptions, parseValue } from '@contentful/field-editor-dropdown';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import tokens from '@contentful/f36-tokens';
|
|
6
|
+
import { Form, Flex, Radio, TextLink } from '@contentful/f36-components';
|
|
7
7
|
|
|
8
8
|
var form = /*#__PURE__*/css({
|
|
9
9
|
marginTop: tokens.spacingS
|
|
@@ -45,27 +45,26 @@ function RadioEditor(props) {
|
|
|
45
45
|
|
|
46
46
|
return createElement(Form, {
|
|
47
47
|
testId: "radio-editor",
|
|
48
|
-
spacing: "condensed",
|
|
49
48
|
className: cx(form, direction === 'rtl' ? rightToLeft : '')
|
|
50
49
|
}, options.map(function (item, index) {
|
|
51
50
|
var id = ['entity', field.id, field.locale, index, item.id].join('.');
|
|
52
51
|
var checked = value === item.value;
|
|
53
52
|
return createElement(Flex, {
|
|
54
53
|
key: id,
|
|
55
|
-
alignItems: "center"
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
marginBottom: "spacingS"
|
|
56
|
+
}, createElement(Radio, {
|
|
58
57
|
id: id,
|
|
59
|
-
|
|
60
|
-
labelText: item.label,
|
|
61
|
-
disabled: disabled,
|
|
58
|
+
isDisabled: disabled,
|
|
62
59
|
value: item.value === undefined ? '' : String(item.value),
|
|
60
|
+
isChecked: checked,
|
|
63
61
|
onChange: function onChange(e) {
|
|
64
62
|
if (e.target.checked) {
|
|
65
63
|
setOption(e.target.value);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
|
-
}), checked && createElement(TextLink, {
|
|
66
|
+
}, item.label), checked && createElement(TextLink, {
|
|
67
|
+
as: "button",
|
|
69
68
|
className: clearBtn,
|
|
70
69
|
onClick: clearOption
|
|
71
70
|
}, "Clear"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-radio.esm.js","sources":["../src/styles.ts","../src/RadioEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/
|
|
1
|
+
{"version":3,"file":"field-editor-radio.esm.js","sources":["../src/styles.ts","../src/RadioEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const form = css({\n marginTop: tokens.spacingS,\n});\n\nexport const rightToLeft = css({\n direction: 'rtl',\n});\n\nexport const clearBtn = css({ marginLeft: tokens.spacingL });\n","import * as React from 'react';\nimport { cx } from 'emotion';\nimport {\n FieldAPI,\n FieldConnector,\n PredefinedValuesError,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { getOptions, parseValue } from '@contentful/field-editor-dropdown';\nimport * as styles from './styles';\n\nimport { TextLink, Flex, Radio, Form } from '@contentful/f36-components';\n\nexport interface RadioEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function RadioEditor(props: RadioEditorProps) {\n const { field, locales } = props;\n\n const options = getOptions(field);\n const misconfigured = options.length === 0;\n\n if (misconfigured) {\n return <PredefinedValuesError />;\n }\n\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string | number>\n throttle={0}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ disabled, value, setValue }) => {\n const setOption = (value: string) => {\n setValue(parseValue(value, field.type));\n };\n const clearOption = () => {\n setValue(undefined);\n };\n\n return (\n <Form\n testId=\"radio-editor\"\n className={cx(styles.form, direction === 'rtl' ? styles.rightToLeft : '')}>\n {options.map((item, index) => {\n const id = ['entity', field.id, field.locale, index, item.id].join('.');\n const checked = value === item.value;\n return (\n <Flex key={id} alignItems=\"center\" marginBottom=\"spacingS\">\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 {checked && (\n <TextLink as=\"button\" className={styles.clearBtn} onClick={clearOption}>\n Clear\n </TextLink>\n )}\n </Flex>\n );\n })}\n </Form>\n );\n }}\n </FieldConnector>\n );\n}\n\nRadioEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["form","css","marginTop","tokens","spacingS","rightToLeft","direction","clearBtn","marginLeft","spacingL","RadioEditor","props","field","locales","options","getOptions","misconfigured","length","React","PredefinedValuesError","locale","FieldConnector","throttle","isInitiallyDisabled","disabled","value","setValue","setOption","parseValue","type","clearOption","undefined","Form","testId","className","cx","styles","map","item","index","id","join","checked","Flex","key","alignItems","marginBottom","Radio","isDisabled","String","isChecked","onChange","e","target","label","TextLink","as","onClick","defaultProps"],"mappings":";;;;;;;AAGO,IAAMA,IAAI,gBAAGC,GAAG,CAAC;AACtBC,EAAAA,SAAS,EAAEC,MAAM,CAACC;AADI,CAAD,CAAhB;AAIA,IAAMC,WAAW,gBAAGJ,GAAG,CAAC;AAC7BK,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;AAIA,IAAMC,QAAQ,gBAAGN,GAAG,CAAC;AAAEO,EAAAA,UAAU,EAAEL,MAAM,CAACM;AAArB,CAAD,CAApB;;SCmBSC,YAAYC;AAC1B,MAAQC,KAAR,GAA2BD,KAA3B,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAA2BF,KAA3B,C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,QAAAA,UAAU,EAAC;AAASC,QAAAA,YAAY,EAAC;OAAhD,EACE5B,aAAA,CAAC6B,KAAD;AACEP,QAAAA,EAAE,EAAEA;AACJQ,QAAAA,UAAU,EAAExB;AACZC,QAAAA,KAAK,EAAEa,IAAI,CAACb,KAAL,KAAeM,SAAf,GAA2B,EAA3B,GAAgCkB,MAAM,CAACX,IAAI,CAACb,KAAN;AAC7CyB,QAAAA,SAAS,EAAER;AACXS,QAAAA,QAAQ,EAAE,kBAACC,CAAD;AACR,cAAIA,CAAC,CAACC,MAAF,CAASX,OAAb,EAAsB;AACpBf,YAAAA,SAAS,CAACyB,CAAC,CAACC,MAAF,CAAS5B,KAAV,CAAT;AACD;AACF;OATH,EAUGa,IAAI,CAACgB,KAVR,CADF,EAaGZ,OAAO,IACNxB,aAAA,CAACqC,QAAD;AAAUC,QAAAA,EAAE,EAAC;AAAStB,QAAAA,SAAS,EAAEE;AAAiBqB,QAAAA,OAAO,EAAE3B;OAA3D,SAAA,CAdJ,CADF;AAqBD,KAxBA,CAHH,CADF;AA+BD,GA3CH,CADF;AA+CD;AAEDpB,WAAW,CAACgD,YAAZ,GAA2B;AACzBnC,EAAAA,mBAAmB,EAAE;AADI,CAA3B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-radio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/field-editor-radio.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,17 +21,18 @@
|
|
|
21
21
|
"tsc": "tsc -p ./ --noEmit"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@contentful/
|
|
25
|
-
"@contentful/
|
|
26
|
-
"@contentful/
|
|
27
|
-
"@contentful/
|
|
24
|
+
"@contentful/f36-components": "beta",
|
|
25
|
+
"@contentful/f36-tokens": "beta",
|
|
26
|
+
"@contentful/field-editor-dropdown": "^0.16.0",
|
|
27
|
+
"@contentful/field-editor-shared": "^0.26.0",
|
|
28
28
|
"emotion": "^10.0.17",
|
|
29
29
|
"lodash": "^4.17.15",
|
|
30
30
|
"lodash-es": "^4.17.15",
|
|
31
31
|
"nanoid": "^3.1.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@contentful/field-editor-test-utils": "^0.
|
|
34
|
+
"@contentful/field-editor-test-utils": "^0.19.0",
|
|
35
|
+
"contentful-management": "^7.42.1"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"react": ">=16.8.0"
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f86ba28db3f34cffc0dc2580bf21297542f331c9"
|
|
50
51
|
}
|