@teambit/compositions 1.0.668 → 1.0.670

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.
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compositions_compositions@1.0.668/dist/compositions.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compositions_compositions@1.0.668/dist/compositions.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compositions_compositions@1.0.670/dist/compositions.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compositions_compositions@1.0.670/dist/compositions.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -7,6 +7,8 @@
7
7
  }
8
8
 
9
9
  .tab {
10
+ color: var(--on-background-color);
11
+
10
12
  > div:first-child {
11
13
  border: none;
12
14
  border-bottom: 1px solid var(--bit-border-color-lightest, #ededed);
@@ -75,74 +75,95 @@ function _liveControlInputModule() {
75
75
  return data;
76
76
  }
77
77
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
78
+ /* eslint-disable no-console */
79
+
78
80
  function ShortTextInput({
79
- id,
80
81
  value,
81
82
  onChange
82
83
  }) {
83
- const [inputValue, setInputValue] = _react().default.useState(value);
84
+ const [inputValue, setInputValue] = _react().default.useState(value || '');
85
+ _react().default.useEffect(() => {
86
+ setInputValue(value || '');
87
+ }, [value]);
84
88
  const handleChange = e => {
85
89
  const newValue = e.target.value;
86
- onChange(newValue);
87
- setInputValue(newValue);
90
+ onChange(newValue || '');
91
+ setInputValue(newValue || '');
88
92
  };
89
93
  return /*#__PURE__*/_react().default.createElement(_designInputs().InputText, {
90
- id: id,
91
94
  value: inputValue,
92
95
  onChange: handleChange
93
96
  });
94
97
  }
95
98
  function LongTextInput({
96
- id,
97
99
  value,
98
100
  onChange
99
101
  }) {
100
- const [inputValue, setInputValue] = _react().default.useState(value);
102
+ const [inputValue, setInputValue] = _react().default.useState(value || '');
103
+ _react().default.useEffect(() => {
104
+ setInputValue(value || '');
105
+ }, [value]);
101
106
  const handleChange = e => {
102
107
  const newValue = e.target.value;
103
- onChange(newValue);
104
- setInputValue(newValue);
108
+ onChange(newValue || '');
109
+ setInputValue(newValue || '');
105
110
  };
106
111
  return /*#__PURE__*/_react().default.createElement(_designInputs2().TextArea, {
107
- id: id,
108
112
  value: inputValue,
109
113
  onChange: handleChange
110
114
  });
111
115
  }
112
116
  function SelectInput({
113
- id,
114
117
  value,
115
118
  onChange,
116
119
  meta
117
120
  }) {
118
- const [selectedValue, setSelectedValue] = _react().default.useState(value);
121
+ const [selectedValue, setSelectedValue] = _react().default.useState(value || '');
122
+ _react().default.useEffect(() => {
123
+ setSelectedValue(value || '');
124
+ }, [value]);
119
125
  const handleChange = newValue => {
120
- onChange(newValue);
121
- setSelectedValue(newValue);
126
+ onChange(newValue || '');
127
+ setSelectedValue(newValue || '');
122
128
  };
123
- const placeholderContent = meta.options.find(o => o.value === selectedValue)?.label;
129
+ const options = _react().default.useMemo(() => {
130
+ if (!meta || !meta.options) return [];
131
+ return meta.options.map(option => {
132
+ if (typeof option === 'string') {
133
+ return {
134
+ label: option,
135
+ value: option
136
+ };
137
+ }
138
+ return option;
139
+ });
140
+ }, [meta]);
141
+ const placeholderContent = options.find(o => o.value === selectedValue)?.label;
124
142
  return /*#__PURE__*/_react().default.createElement("p", {
125
143
  className: (0, _classnames().default)(_liveControlInputModule().default.wrapper)
126
144
  }, /*#__PURE__*/_react().default.createElement(_designInputs3().Dropdown, {
127
- id: id,
128
145
  placeholderContent: placeholderContent
129
- }, meta.options.map(option => /*#__PURE__*/_react().default.createElement(_designInputsSelectors().MenuItem, {
130
- active: option.value === selectedValue,
131
- key: option.value,
132
- onClick: () => handleChange(option.value)
133
- }, option.label))));
146
+ }, options.map(option => {
147
+ return /*#__PURE__*/_react().default.createElement(_designInputsSelectors().MenuItem, {
148
+ active: option.value === selectedValue,
149
+ key: option.value,
150
+ onClick: () => handleChange(option.value)
151
+ }, option.label);
152
+ })));
134
153
  }
135
154
  function NumberInput({
136
- id,
137
155
  value,
138
156
  onChange
139
157
  }) {
140
- const [inputValue, setInputValue] = _react().default.useState(value);
158
+ const [inputValue, setInputValue] = _react().default.useState(value || 0);
159
+ _react().default.useEffect(() => {
160
+ setInputValue(value || 0);
161
+ }, [value]);
141
162
  const handleChange = e => {
142
163
  const newValue = e.target.value;
143
164
  if (!isNaN(Number(newValue))) {
144
- onChange(Number(newValue));
145
- setInputValue(Number(newValue));
165
+ onChange(Number(newValue) || 0);
166
+ setInputValue(Number(newValue) || 0);
146
167
  } else {
147
168
  // TODO: render error message
148
169
  // eslint-disable-next-line no-console
@@ -150,37 +171,39 @@ function NumberInput({
150
171
  }
151
172
  };
152
173
  return /*#__PURE__*/_react().default.createElement(_designInputs().InputText, {
153
- id: id,
154
174
  type: "number",
155
175
  value: inputValue,
156
176
  onChange: handleChange
157
177
  });
158
178
  }
159
179
  function ColorInput({
160
- id,
161
180
  value,
162
181
  onChange
163
182
  }) {
164
- const [inputValue, setInputValue] = _react().default.useState(value);
183
+ const [inputValue, setInputValue] = _react().default.useState(value || '');
184
+ _react().default.useEffect(() => {
185
+ setInputValue(value || '');
186
+ }, [value]);
165
187
  const handleChange = newValue => {
166
- onChange(newValue);
167
- setInputValue(newValue);
188
+ onChange(newValue || '');
189
+ setInputValue(newValue || '');
168
190
  };
169
191
  return /*#__PURE__*/_react().default.createElement("p", {
170
192
  className: (0, _classnames().default)(_liveControlInputModule().default.wrapper)
171
193
  }, /*#__PURE__*/_react().default.createElement(_designUiInput().ColorPicker, {
172
- id: id,
173
194
  value: inputValue,
174
195
  onColorSelect: handleChange,
175
196
  allowCustomColor: true
176
197
  }));
177
198
  }
178
199
  function DateInput({
179
- id,
180
200
  value,
181
201
  onChange
182
202
  }) {
183
203
  const [inputValue, setInputValue] = _react().default.useState(new Date(value));
204
+ _react().default.useEffect(() => {
205
+ setInputValue(new Date(value));
206
+ }, [value]);
184
207
  const handleChange = newValue => {
185
208
  if (newValue) {
186
209
  onChange(newValue.toISOString().split('T')[0]);
@@ -190,17 +213,18 @@ function DateInput({
190
213
  return /*#__PURE__*/_react().default.createElement("p", {
191
214
  className: (0, _classnames().default)(_liveControlInputModule().default.wrapper)
192
215
  }, /*#__PURE__*/_react().default.createElement(_designInputs4().DatePicker, {
193
- id: id,
194
216
  date: inputValue,
195
217
  onChange: handleChange
196
218
  }));
197
219
  }
198
220
  function ToggleInput({
199
- id,
200
221
  value,
201
222
  onChange
202
223
  }) {
203
- const [isChecked, setIsChecked] = _react().default.useState(value);
224
+ const [isChecked, setIsChecked] = _react().default.useState(!!value);
225
+ _react().default.useEffect(() => {
226
+ setIsChecked(!!value);
227
+ }, [value]);
204
228
  const handleChange = () => {
205
229
  setIsChecked(!isChecked);
206
230
  onChange(!isChecked);
@@ -208,17 +232,18 @@ function ToggleInput({
208
232
  return /*#__PURE__*/_react().default.createElement("p", {
209
233
  className: (0, _classnames().default)(_liveControlInputModule().default.wrapper)
210
234
  }, /*#__PURE__*/_react().default.createElement(_designInputs5().Toggle, {
211
- id: id,
212
235
  defaultChecked: isChecked,
213
236
  onChange: handleChange
214
237
  }));
215
238
  }
216
239
  function JsonInput({
217
- id,
218
240
  value,
219
241
  onChange
220
242
  }) {
221
243
  const [inputValue, setInputValue] = _react().default.useState(JSON.stringify(value, null, 2));
244
+ _react().default.useEffect(() => {
245
+ setInputValue(JSON.stringify(value, null, 2));
246
+ }, [value]);
222
247
  const [message, setMessage] = _react().default.useState('');
223
248
  const handleChange = e => {
224
249
  const newValue = e.target.value;
@@ -232,7 +257,6 @@ function JsonInput({
232
257
  setInputValue(newValue);
233
258
  };
234
259
  return /*#__PURE__*/_react().default.createElement("div", null, /*#__PURE__*/_react().default.createElement(_designInputs2().TextArea, {
235
- id: id,
236
260
  value: inputValue,
237
261
  onChange: handleChange
238
262
  }), message && /*#__PURE__*/_react().default.createElement("div", {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","data","_interopRequireDefault","require","_classnames","_designInputs","_designInputs2","_designInputs3","_designInputsSelectors","_designUiInput","_designInputs4","_designInputs5","_liveControlInputModule","e","__esModule","default","ShortTextInput","id","value","onChange","inputValue","setInputValue","React","useState","handleChange","newValue","target","createElement","InputText","LongTextInput","TextArea","SelectInput","meta","selectedValue","setSelectedValue","placeholderContent","options","find","o","label","className","classNames","styles","wrapper","Dropdown","map","option","MenuItem","active","key","onClick","NumberInput","isNaN","Number","console","error","type","ColorInput","ColorPicker","onColorSelect","allowCustomColor","DateInput","Date","toISOString","split","DatePicker","date","ToggleInput","isChecked","setIsChecked","Toggle","defaultChecked","JsonInput","JSON","stringify","message","setMessage","parsedValue","parse","style","color","getInputComponent","warn"],"sources":["live-control-input.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nimport { InputText } from '@teambit/design.inputs.input-text';\nimport { TextArea } from '@teambit/design.inputs.text-area';\nimport { Dropdown } from '@teambit/design.inputs.dropdown';\nimport { MenuItem } from '@teambit/design.inputs.selectors.menu-item';\nimport { ColorPicker } from '@teambit/design.ui.input.color-picker';\nimport { DatePicker } from '@teambit/design.inputs.date-picker';\nimport { Toggle } from '@teambit/design.inputs.toggle-switch';\n\nimport styles from './live-control-input.module.scss';\n\ntype InputComponentProps = {\n id: string;\n value: any;\n onChange: (value: any) => void;\n meta?: any;\n};\n\ntype InputComponent = React.FC<InputComponentProps>;\n\nfunction ShortTextInput({ id, value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value);\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n onChange(newValue);\n setInputValue(newValue);\n };\n return <InputText id={id} value={inputValue} onChange={handleChange} />;\n}\n\nfunction LongTextInput({ id, value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value);\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n onChange(newValue);\n setInputValue(newValue);\n };\n return <TextArea id={id} value={inputValue} onChange={handleChange} />;\n}\n\nfunction SelectInput({ id, value, onChange, meta }: InputComponentProps) {\n const [selectedValue, setSelectedValue] = React.useState(value);\n const handleChange = (newValue: any) => {\n onChange(newValue);\n setSelectedValue(newValue);\n };\n const placeholderContent = meta.options.find((o: any) => o.value === selectedValue)?.label;\n return (\n <p className={classNames(styles.wrapper)}>\n <Dropdown id={id} placeholderContent={placeholderContent}>\n {meta.options.map((option: any) => (\n <MenuItem\n active={option.value === selectedValue}\n key={option.value}\n onClick={() => handleChange(option.value)}\n >\n {option.label}\n </MenuItem>\n ))}\n </Dropdown>\n </p>\n );\n}\n\nfunction NumberInput({ id, value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value);\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n if (!isNaN(Number(newValue))) {\n onChange(Number(newValue));\n setInputValue(Number(newValue));\n } else {\n // TODO: render error message\n // eslint-disable-next-line no-console\n console.error('Invalid number input', newValue);\n }\n };\n return <InputText id={id} type=\"number\" value={inputValue} onChange={handleChange} />;\n}\n\nfunction ColorInput({ id, value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value);\n const handleChange = (newValue: string) => {\n onChange(newValue);\n setInputValue(newValue);\n };\n return (\n <p className={classNames(styles.wrapper)}>\n <ColorPicker id={id} value={inputValue} onColorSelect={handleChange} allowCustomColor />\n </p>\n );\n}\n\nfunction DateInput({ id, value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState<Date | null>(new Date(value));\n const handleChange = (newValue: Date | null) => {\n if (newValue) {\n onChange(newValue.toISOString().split('T')[0]);\n }\n setInputValue(newValue);\n };\n return (\n <p className={classNames(styles.wrapper)}>\n <DatePicker id={id} date={inputValue} onChange={handleChange} />\n </p>\n );\n}\n\nfunction ToggleInput({ id, value, onChange }: InputComponentProps) {\n const [isChecked, setIsChecked] = React.useState(value);\n const handleChange = () => {\n setIsChecked(!isChecked);\n onChange(!isChecked);\n };\n return (\n <p className={classNames(styles.wrapper)}>\n <Toggle id={id} defaultChecked={isChecked} onChange={handleChange} />\n </p>\n );\n}\n\nfunction JsonInput({ id, value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(JSON.stringify(value, null, 2));\n const [message, setMessage] = React.useState('');\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n try {\n const parsedValue = JSON.parse(newValue);\n onChange(parsedValue);\n setMessage('');\n } catch {\n setMessage('Invalid JSON');\n }\n setInputValue(newValue);\n };\n return (\n <div>\n <TextArea id={id} value={inputValue} onChange={handleChange} />\n {message && <div style={{ color: 'red' }}>{message}</div>}\n </div>\n );\n}\n\nexport function getInputComponent(type: string): InputComponent {\n switch (type) {\n case 'text':\n return ShortTextInput;\n case 'longtext':\n return LongTextInput;\n case 'select':\n return SelectInput;\n case 'number':\n return NumberInput;\n case 'color':\n return ColorInput;\n case 'date':\n return DateInput;\n case 'boolean':\n return ToggleInput;\n case 'json':\n return JsonInput;\n default:\n // eslint-disable-next-line no-console\n console.warn(`Unknown input type: ${type}`);\n return ShortTextInput;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA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K;IAC/B,IAAI;MACF,MAAM2D,WAAW,GAAGJ,IAAI,CAACK,KAAK,CAACrD,QAAQ,CAAC;MACxCN,QAAQ,CAAC0D,WAAW,CAAC;MACrBD,UAAU,CAAC,EAAE,CAAC;IAChB,CAAC,CAAC,MAAM;MACNA,UAAU,CAAC,cAAc,CAAC;IAC5B;IACAvD,aAAa,CAACI,QAAQ,CAAC;EACzB,CAAC;EACD,oBACEzB,MAAA,GAAAe,OAAA,CAAAY,aAAA,2BACE3B,MAAA,GAAAe,OAAA,CAAAY,aAAA,CAACrB,cAAA,GAAAwB,QAAQ;IAACb,EAAE,EAAEA,EAAG;IAACC,KAAK,EAAEE,UAAW;IAACD,QAAQ,EAAEK;EAAa,CAAE,CAAC,EAC9DmD,OAAO,iBAAI3E,MAAA,GAAAe,OAAA,CAAAY,aAAA;IAAKoD,KAAK,EAAE;MAAEC,KAAK,EAAE;IAAM;EAAE,GAAEL,OAAa,CACrD,CAAC;AAEV;AAEO,SAASM,iBAAiBA,CAACzB,IAAY,EAAkB;EAC9D,QAAQA,IAAI;IACV,KAAK,MAAM;MACT,OAAOxC,cAAc;IACvB,KAAK,UAAU;MACb,OAAOa,aAAa;IACtB,KAAK,QAAQ;MACX,OAAOE,WAAW;IACpB,KAAK,QAAQ;MACX,OAAOoB,WAAW;IACpB,KAAK,OAAO;MACV,OAAOM,UAAU;IACnB,KAAK,MAAM;MACT,OAAOI,SAAS;IAClB,KAAK,SAAS;MACZ,OAAOM,WAAW;IACpB,KAAK,MAAM;MACT,OAAOK,SAAS;IAClB;MACE;MACAlB,OAAO,CAAC4B,IAAI,CAAC,uBAAuB1B,IAAI,EAAE,CAAC;MAC3C,OAAOxC,cAAc;EACzB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_react","data","_interopRequireDefault","require","_classnames","_designInputs","_designInputs2","_designInputs3","_designInputsSelectors","_designUiInput","_designInputs4","_designInputs5","_liveControlInputModule","e","__esModule","default","ShortTextInput","value","onChange","inputValue","setInputValue","React","useState","useEffect","handleChange","newValue","target","createElement","InputText","LongTextInput","TextArea","SelectInput","meta","selectedValue","setSelectedValue","options","useMemo","map","option","label","placeholderContent","find","o","className","classNames","styles","wrapper","Dropdown","MenuItem","active","key","onClick","NumberInput","isNaN","Number","console","error","type","ColorInput","ColorPicker","onColorSelect","allowCustomColor","DateInput","Date","toISOString","split","DatePicker","date","ToggleInput","isChecked","setIsChecked","Toggle","defaultChecked","JsonInput","JSON","stringify","message","setMessage","parsedValue","parse","style","color","getInputComponent","warn"],"sources":["live-control-input.tsx"],"sourcesContent":["/* eslint-disable no-console */\n\nimport React from 'react';\nimport classNames from 'classnames';\n\nimport { InputText } from '@teambit/design.inputs.input-text';\nimport { TextArea } from '@teambit/design.inputs.text-area';\nimport { Dropdown } from '@teambit/design.inputs.dropdown';\nimport { MenuItem } from '@teambit/design.inputs.selectors.menu-item';\nimport { ColorPicker } from '@teambit/design.ui.input.color-picker';\nimport { DatePicker } from '@teambit/design.inputs.date-picker';\nimport { Toggle } from '@teambit/design.inputs.toggle-switch';\n\nimport { type SelectOption } from '@teambit/compositions.ui.composition-live-controls';\n\nimport styles from './live-control-input.module.scss';\n\ntype InputComponentProps = {\n id: string;\n value: any;\n onChange: (value: any) => void;\n meta?: any;\n};\n\ntype InputComponent = React.FC<InputComponentProps>;\n\nfunction ShortTextInput({ value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value || '');\n\n React.useEffect(() => {\n setInputValue(value || '');\n }, [value]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n onChange(newValue || '');\n setInputValue(newValue || '');\n };\n\n return <InputText value={inputValue} onChange={handleChange} />;\n}\n\nfunction LongTextInput({ value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value || '');\n\n React.useEffect(() => {\n setInputValue(value || '');\n }, [value]);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n onChange(newValue || '');\n setInputValue(newValue || '');\n };\n\n return <TextArea value={inputValue} onChange={handleChange} />;\n}\n\nfunction SelectInput({ value, onChange, meta }: InputComponentProps) {\n const [selectedValue, setSelectedValue] = React.useState(value || '');\n\n React.useEffect(() => {\n setSelectedValue(value || '');\n }, [value]);\n\n const handleChange = (newValue: any) => {\n onChange(newValue || '');\n setSelectedValue(newValue || '');\n };\n\n const options: {\n label: string;\n value: string;\n }[] = React.useMemo(() => {\n if (!meta || !meta.options) return [];\n return meta.options.map((option: SelectOption) => {\n if (typeof option === 'string') {\n return { label: option, value: option };\n }\n return option;\n });\n }, [meta]);\n\n const placeholderContent = options.find((o) => o.value === selectedValue)?.label;\n\n return (\n <p className={classNames(styles.wrapper)}>\n <Dropdown placeholderContent={placeholderContent}>\n {options.map((option) => {\n return (\n <MenuItem\n active={option.value === selectedValue}\n key={option.value}\n onClick={() => handleChange(option.value)}\n >\n {option.label}\n </MenuItem>\n );\n })}\n </Dropdown>\n </p>\n );\n}\n\nfunction NumberInput({ value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value || 0);\n\n React.useEffect(() => {\n setInputValue(value || 0);\n }, [value]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n if (!isNaN(Number(newValue))) {\n onChange(Number(newValue) || 0);\n setInputValue(Number(newValue) || 0);\n } else {\n // TODO: render error message\n // eslint-disable-next-line no-console\n console.error('Invalid number input', newValue);\n }\n };\n\n return <InputText type=\"number\" value={inputValue} onChange={handleChange} />;\n}\n\nfunction ColorInput({ value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(value || '');\n\n React.useEffect(() => {\n setInputValue(value || '');\n }, [value]);\n\n const handleChange = (newValue: string) => {\n onChange(newValue || '');\n setInputValue(newValue || '');\n };\n\n return (\n <p className={classNames(styles.wrapper)}>\n <ColorPicker value={inputValue} onColorSelect={handleChange} allowCustomColor />\n </p>\n );\n}\n\nfunction DateInput({ value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState<Date | null>(new Date(value));\n\n React.useEffect(() => {\n setInputValue(new Date(value));\n }, [value]);\n\n const handleChange = (newValue: Date | null) => {\n if (newValue) {\n onChange(newValue.toISOString().split('T')[0]);\n }\n setInputValue(newValue);\n };\n\n return (\n <p className={classNames(styles.wrapper)}>\n <DatePicker date={inputValue} onChange={handleChange} />\n </p>\n );\n}\n\nfunction ToggleInput({ value, onChange }: InputComponentProps) {\n const [isChecked, setIsChecked] = React.useState(!!value);\n\n React.useEffect(() => {\n setIsChecked(!!value);\n }, [value]);\n\n const handleChange = () => {\n setIsChecked(!isChecked);\n onChange(!isChecked);\n };\n\n return (\n <p className={classNames(styles.wrapper)}>\n <Toggle defaultChecked={isChecked} onChange={handleChange} />\n </p>\n );\n}\n\nfunction JsonInput({ value, onChange }: InputComponentProps) {\n const [inputValue, setInputValue] = React.useState(JSON.stringify(value, null, 2));\n\n React.useEffect(() => {\n setInputValue(JSON.stringify(value, null, 2));\n }, [value]);\n\n const [message, setMessage] = React.useState('');\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n try {\n const parsedValue = JSON.parse(newValue);\n onChange(parsedValue);\n setMessage('');\n } catch {\n setMessage('Invalid JSON');\n }\n setInputValue(newValue);\n };\n\n return (\n <div>\n <TextArea value={inputValue} onChange={handleChange} />\n {message && <div style={{ color: 'red' }}>{message}</div>}\n </div>\n );\n}\n\nexport function getInputComponent(type: string): InputComponent {\n switch (type) {\n case 'text':\n return ShortTextInput;\n case 'longtext':\n return LongTextInput;\n case 'select':\n return SelectInput;\n case 'number':\n return NumberInput;\n case 'color':\n return ColorInput;\n case 'date':\n return DateInput;\n case 'boolean':\n return ToggleInput;\n case 'json':\n return JsonInput;\n default:\n // eslint-disable-next-line no-console\n console.warn(`Unknown input type: ${type}`);\n return ShortTextInput;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC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AQ;MACX,OAAOE,WAAW;IACpB,KAAK,QAAQ;MACX,OAAOqB,WAAW;IACpB,KAAK,OAAO;MACV,OAAOM,UAAU;IACnB,KAAK,MAAM;MACT,OAAOI,SAAS;IAClB,KAAK,SAAS;MACZ,OAAOM,WAAW;IACpB,KAAK,MAAM;MACT,OAAOK,SAAS;IAClB;MACE;MACAlB,OAAO,CAAC4B,IAAI,CAAC,uBAAuB1B,IAAI,EAAE,CAAC;MAC3C,OAAOzC,cAAc;EACzB;AACF","ignoreList":[]}
@@ -39,7 +39,10 @@ function LiveControls({
39
39
  onChange
40
40
  }) {
41
41
  return /*#__PURE__*/_react().default.createElement("ul", {
42
- className: (0, _classnames().default)(_liveControlPanelModule().default.container)
42
+ className: (0, _classnames().default)(_liveControlPanelModule().default.container),
43
+ style: {
44
+ paddingBottom: '20em' /* temp walkaround for cutting popups */
45
+ }
43
46
  }, defs.map(field => {
44
47
  const key = field.id;
45
48
  const InputComponent = (0, _liveControlInput().getInputComponent)(field.input || 'text');
@@ -1 +1 @@
1
- {"version":3,"names":["_react","data","_interopRequireDefault","require","_classnames","_liveControlPanelModule","_liveControlInput","e","__esModule","default","LiveControls","defs","values","onChange","createElement","className","classNames","styles","container","map","field","key","id","InputComponent","getInputComponent","input","item","label","htmlFor","value","v","meta"],"sources":["live-control-panel.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { type Control } from '@teambit/compositions.ui.composition-live-controls';\n\nimport styles from './live-control-panel.module.scss';\nimport { getInputComponent } from './live-control-input';\n\nexport function LiveControls({\n defs,\n values,\n onChange,\n}: {\n defs: Array<Control>;\n values: Record<string, any>;\n onChange: (key: string, value: any) => void;\n}) {\n return (\n <ul className={classNames(styles.container)}>\n {defs.map((field) => {\n const key = field.id;\n const InputComponent = getInputComponent(field.input || 'text');\n return (\n <li key={key} className={classNames(styles.item)}>\n <div className={classNames(styles.label)}>\n <label htmlFor={`control-${key}`}>{field.label || field.id}</label>\n </div>\n <div>\n <InputCompon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S,EAAE,IAAAC,qBAAU,EAACC,iCAAM,CAACS,IAAI;IAAE,gBAC/C1B,MAAA,GAAAS,OAAA,CAAAK,aAAA;MAAKC,SAAS,EAAE,IAAAC,qBAAU,EAACC,iCAAM,CAACU,KAAK;IAAE,gBACvC3B,MAAA,GAAAS,OAAA,CAAAK,aAAA;MAAOc,OAAO,EAAE,WAAWP,GAAG;IAAG,GAAED,KAAK,CAACO,KAAK,IAAIP,KAAK,CAACE,EAAU,CAC/D,CAAC,eACNtB,MAAA,GAAAS,OAAA,CAAAK,aAAA,2BACEd,MAAA,GAAAS,OAAA,CAAAK,aAAA,CAACS,cAAc;MACbD,EAAE,EAAE,WAAWD,GAAG,EAAG;MACrBQ,KAAK,EAAEjB,MAAM,CAACS,GAAG,CAAE;MACnBR,QAAQ,EAAGiB,CAAM,IAAKjB,QAAQ,CAACQ,GAAG,EAAES,CAAC,CAAE;MACvCC,IAAI,EAAEX;IAAM,CACb,CACE,CACH,CAAC;EAET,CAAC,CACC,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["_react","data","_interopRequireDefault","require","_classnames","_liveControlPanelModule","_liveControlInput","e","__esModule","default","LiveControls","defs","values","onChange","createElement","className","classNames","styles","container","style","paddingBottom","map","field","key","id","InputComponent","getInputComponent","input","item","label","htmlFor","value","v","meta"],"sources":["live-control-panel.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { type Control } from '@teambit/compositions.ui.composition-live-controls';\n\nimport styles from './live-control-panel.module.scss';\nimport { getInputComponent } from './live-control-input';\n\nexport function LiveControls({\n defs,\n values,\n onChange,\n}: {\n defs: Array<Control>;\n values: Record<string, any>;\n onChange: (key: string, value: any) => void;\n}) {\n return (\n <ul\n className={classNames(styles.container)}\n style={{ paddingBottom: '20em' /* temp walkaround for cutting popups */ }}\n >\n {defs.map((field) => {\n const key = field.id;\n const InputComponent = getInputComponent(field.input || 'text');\n return (\n <li key={key} className={classNames(styles.item)}>\n <div className={classNames(styles.label)}>\n <label htmlFor={`control-${key}`}>{field.label || field.id}</label>\n </div>\n <div>\n <InputComponent\n id={`control-${key}`}\n value={values[key]}\n onChange={(v: any) => onChange(key, v)}\n meta={field}\n />\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,wBAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,uBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyD,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElD,SAASG,YAAYA,CAAC;EAC3BC,IAAI;EACJC,MAAM;EACNC;AAKF,CAAC,EAAE;EACD,oBACEb,MAAA,GAAAS,OAAA,CAAAK,aAAA;IACEC,SAAS,EAAE,IAAAC,qBAAU,EAACC,iCAAM,CAACC,SAAS,CAAE;IACxCC,KAAK,EAAE;MAAEC,aAAa,EAAE,MAAM,CAAC;IAAyC;EAAE,GAEzET,IAAI,CAACU,GAAG,CAAEC,KAAK,IAAK;IACnB,MAAMC,GAAG,GAAGD,KAAK,CAACE,EAAE;IACpB,MAAMC,cAAc,GAAG,IAAAC,qCAAiB,EAACJ,KAAK,CAACK,KAAK,IAAI,MAAM,CAAC;IAC/D,oBACE3B,MAAA,GAAAS,OAAA,CAAAK,aAAA;MAAIS,GAAG,EAAEA,GAAI;MAACR,SAAS,EAAE,IAAAC,qBAAU,EAACC,iCAAM,CAACW,IAAI;IAAE,gBAC/C5B,MAAA,GAAAS,OAAA,CAAAK,aAAA;MAAKC,SAAS,EAAE,IAAAC,qBAAU,EAACC,iCAAM,CAACY,KAAK;IAAE,gBACvC7B,MAAA,GAAAS,OAAA,CAAAK,aAAA;MAAOgB,OAAO,EAAE,WAAWP,GAAG;IAAG,GAAED,KAAK,CAACO,KAAK,IAAIP,KAAK,CAACE,EAAU,CAC/D,CAAC,eACNxB,MAAA,GAAAS,OAAA,CAAAK,aAAA,2BACEd,MAAA,GAAAS,OAAA,CAAAK,aAAA,CAACW,cAAc;MACbD,EAAE,EAAE,WAAWD,GAAG,EAAG;MACrBQ,KAAK,EAAEnB,MAAM,CAACW,GAAG,CAAE;MACnBV,QAAQ,EAAGmB,CAAM,IAAKnB,QAAQ,CAACU,GAAG,EAAES,CAAC,CAAE;MACvCC,IAAI,EAAEX;IAAM,CACb,CACE,CACH,CAAC;EAET,CAAC,CACC,CAAC;AAET","ignoreList":[]}
@@ -11,4 +11,5 @@
11
11
 
12
12
  .label {
13
13
  font-weight: bold;
14
+ color: var(--on-background-color);
14
15
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/compositions",
3
- "version": "1.0.668",
3
+ "version": "1.0.670",
4
4
  "homepage": "https://bit.cloud/teambit/compositions/compositions",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.compositions",
8
8
  "name": "compositions",
9
- "version": "1.0.668"
9
+ "version": "1.0.670"
10
10
  },
11
11
  "dependencies": {
12
12
  "graphql-tag": "2.12.1",
@@ -27,10 +27,9 @@
27
27
  "@teambit/design.ui.input.option-button": "1.0.0",
28
28
  "@teambit/design.ui.separator": "0.0.354",
29
29
  "@teambit/design.ui.surfaces.status-message-card": "0.0.17",
30
- "@teambit/design.ui.tooltip": "0.0.378",
30
+ "@teambit/docs.ui.queries.get-docs": "0.0.510",
31
31
  "@teambit/documenter.theme.theme-context": "4.0.3",
32
32
  "@teambit/documenter.ui.heading": "4.1.1",
33
- "@teambit/ui-foundation.ui.buttons.collapser": "0.0.228",
34
33
  "@teambit/ui-foundation.ui.hooks.use-is-mobile": "0.0.199",
35
34
  "@teambit/documenter.ui.property-table": "4.1.11",
36
35
  "@teambit/mdx.ui.mdx-layout": "1.0.11",
@@ -41,29 +40,30 @@
41
40
  "@teambit/evangelist.elements.icon": "1.0.2",
42
41
  "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.502",
43
42
  "@teambit/ui-foundation.ui.tree.drawer": "0.0.518",
44
- "@teambit/design.inputs.date-picker": "0.0.2",
43
+ "@teambit/design.inputs.date-picker": "0.0.3",
45
44
  "@teambit/design.inputs.dropdown": "1.3.1",
46
45
  "@teambit/design.inputs.input-text": "1.1.3",
47
46
  "@teambit/design.inputs.selectors.menu-item": "1.1.0",
48
47
  "@teambit/design.inputs.text-area": "0.0.19",
49
48
  "@teambit/design.inputs.toggle-switch": "0.0.7",
50
49
  "@teambit/design.ui.input.color-picker": "0.0.56",
51
- "@teambit/component": "1.0.668",
52
- "@teambit/graphql": "1.0.668",
53
- "@teambit/cli": "0.0.1245",
54
- "@teambit/component.sources": "0.0.110",
55
- "@teambit/dev-files": "1.0.668",
56
- "@teambit/envs": "1.0.668",
57
- "@teambit/legacy.consumer-component": "0.0.59",
58
- "@teambit/preview": "1.0.668",
59
- "@teambit/schema": "1.0.668",
60
- "@teambit/scope": "1.0.668",
61
- "@teambit/workspace": "1.0.668",
62
- "@teambit/docs.ui.queries.get-docs": "0.0.510",
63
- "@teambit/panels": "0.0.1247",
64
- "@teambit/preview.ui.component-preview": "1.0.26",
65
- "@teambit/component-compare": "1.0.668",
66
- "@teambit/ui": "1.0.668"
50
+ "@teambit/component": "1.0.670",
51
+ "@teambit/graphql": "1.0.670",
52
+ "@teambit/cli": "0.0.1247",
53
+ "@teambit/component.sources": "0.0.111",
54
+ "@teambit/dev-files": "1.0.670",
55
+ "@teambit/envs": "1.0.670",
56
+ "@teambit/legacy.consumer-component": "0.0.60",
57
+ "@teambit/preview": "1.0.670",
58
+ "@teambit/schema": "1.0.670",
59
+ "@teambit/scope": "1.0.670",
60
+ "@teambit/workspace": "1.0.670",
61
+ "@teambit/design.ui.tooltip": "0.0.379",
62
+ "@teambit/panels": "0.0.1249",
63
+ "@teambit/preview.ui.component-preview": "1.0.27",
64
+ "@teambit/ui-foundation.ui.buttons.collapser": "0.0.229",
65
+ "@teambit/component-compare": "1.0.670",
66
+ "@teambit/ui": "1.0.670"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/lodash": "4.14.165",
@@ -7,6 +7,8 @@
7
7
  }
8
8
 
9
9
  .tab {
10
+ color: var(--on-background-color);
11
+
10
12
  > div:first-child {
11
13
  border: none;
12
14
  border-bottom: 1px solid var(--bit-border-color-lightest, #ededed);
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-console */
2
+
1
3
  import React from 'react';
2
4
  import classNames from 'classnames';
3
5
 
@@ -9,6 +11,8 @@ import { ColorPicker } from '@teambit/design.ui.input.color-picker';
9
11
  import { DatePicker } from '@teambit/design.inputs.date-picker';
10
12
  import { Toggle } from '@teambit/design.inputs.toggle-switch';
11
13
 
14
+ import { type SelectOption } from '@teambit/compositions.ui.composition-live-controls';
15
+
12
16
  import styles from './live-control-input.module.scss';
13
17
 
14
18
  type InputComponentProps = {
@@ -20,110 +24,174 @@ type InputComponentProps = {
20
24
 
21
25
  type InputComponent = React.FC<InputComponentProps>;
22
26
 
23
- function ShortTextInput({ id, value, onChange }: InputComponentProps) {
24
- const [inputValue, setInputValue] = React.useState(value);
27
+ function ShortTextInput({ value, onChange }: InputComponentProps) {
28
+ const [inputValue, setInputValue] = React.useState(value || '');
29
+
30
+ React.useEffect(() => {
31
+ setInputValue(value || '');
32
+ }, [value]);
33
+
25
34
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
26
35
  const newValue = e.target.value;
27
- onChange(newValue);
28
- setInputValue(newValue);
36
+ onChange(newValue || '');
37
+ setInputValue(newValue || '');
29
38
  };
30
- return <InputText id={id} value={inputValue} onChange={handleChange} />;
39
+
40
+ return <InputText value={inputValue} onChange={handleChange} />;
31
41
  }
32
42
 
33
- function LongTextInput({ id, value, onChange }: InputComponentProps) {
34
- const [inputValue, setInputValue] = React.useState(value);
43
+ function LongTextInput({ value, onChange }: InputComponentProps) {
44
+ const [inputValue, setInputValue] = React.useState(value || '');
45
+
46
+ React.useEffect(() => {
47
+ setInputValue(value || '');
48
+ }, [value]);
49
+
35
50
  const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
36
51
  const newValue = e.target.value;
37
- onChange(newValue);
38
- setInputValue(newValue);
52
+ onChange(newValue || '');
53
+ setInputValue(newValue || '');
39
54
  };
40
- return <TextArea id={id} value={inputValue} onChange={handleChange} />;
55
+
56
+ return <TextArea value={inputValue} onChange={handleChange} />;
41
57
  }
42
58
 
43
- function SelectInput({ id, value, onChange, meta }: InputComponentProps) {
44
- const [selectedValue, setSelectedValue] = React.useState(value);
59
+ function SelectInput({ value, onChange, meta }: InputComponentProps) {
60
+ const [selectedValue, setSelectedValue] = React.useState(value || '');
61
+
62
+ React.useEffect(() => {
63
+ setSelectedValue(value || '');
64
+ }, [value]);
65
+
45
66
  const handleChange = (newValue: any) => {
46
- onChange(newValue);
47
- setSelectedValue(newValue);
67
+ onChange(newValue || '');
68
+ setSelectedValue(newValue || '');
48
69
  };
49
- const placeholderContent = meta.options.find((o: any) => o.value === selectedValue)?.label;
70
+
71
+ const options: {
72
+ label: string;
73
+ value: string;
74
+ }[] = React.useMemo(() => {
75
+ if (!meta || !meta.options) return [];
76
+ return meta.options.map((option: SelectOption) => {
77
+ if (typeof option === 'string') {
78
+ return { label: option, value: option };
79
+ }
80
+ return option;
81
+ });
82
+ }, [meta]);
83
+
84
+ const placeholderContent = options.find((o) => o.value === selectedValue)?.label;
85
+
50
86
  return (
51
87
  <p className={classNames(styles.wrapper)}>
52
- <Dropdown id={id} placeholderContent={placeholderContent}>
53
- {meta.options.map((option: any) => (
54
- <MenuItem
55
- active={option.value === selectedValue}
56
- key={option.value}
57
- onClick={() => handleChange(option.value)}
58
- >
59
- {option.label}
60
- </MenuItem>
61
- ))}
88
+ <Dropdown placeholderContent={placeholderContent}>
89
+ {options.map((option) => {
90
+ return (
91
+ <MenuItem
92
+ active={option.value === selectedValue}
93
+ key={option.value}
94
+ onClick={() => handleChange(option.value)}
95
+ >
96
+ {option.label}
97
+ </MenuItem>
98
+ );
99
+ })}
62
100
  </Dropdown>
63
101
  </p>
64
102
  );
65
103
  }
66
104
 
67
- function NumberInput({ id, value, onChange }: InputComponentProps) {
68
- const [inputValue, setInputValue] = React.useState(value);
105
+ function NumberInput({ value, onChange }: InputComponentProps) {
106
+ const [inputValue, setInputValue] = React.useState(value || 0);
107
+
108
+ React.useEffect(() => {
109
+ setInputValue(value || 0);
110
+ }, [value]);
111
+
69
112
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
70
113
  const newValue = e.target.value;
71
114
  if (!isNaN(Number(newValue))) {
72
- onChange(Number(newValue));
73
- setInputValue(Number(newValue));
115
+ onChange(Number(newValue) || 0);
116
+ setInputValue(Number(newValue) || 0);
74
117
  } else {
75
118
  // TODO: render error message
76
119
  // eslint-disable-next-line no-console
77
120
  console.error('Invalid number input', newValue);
78
121
  }
79
122
  };
80
- return <InputText id={id} type="number" value={inputValue} onChange={handleChange} />;
123
+
124
+ return <InputText type="number" value={inputValue} onChange={handleChange} />;
81
125
  }
82
126
 
83
- function ColorInput({ id, value, onChange }: InputComponentProps) {
84
- const [inputValue, setInputValue] = React.useState(value);
127
+ function ColorInput({ value, onChange }: InputComponentProps) {
128
+ const [inputValue, setInputValue] = React.useState(value || '');
129
+
130
+ React.useEffect(() => {
131
+ setInputValue(value || '');
132
+ }, [value]);
133
+
85
134
  const handleChange = (newValue: string) => {
86
- onChange(newValue);
87
- setInputValue(newValue);
135
+ onChange(newValue || '');
136
+ setInputValue(newValue || '');
88
137
  };
138
+
89
139
  return (
90
140
  <p className={classNames(styles.wrapper)}>
91
- <ColorPicker id={id} value={inputValue} onColorSelect={handleChange} allowCustomColor />
141
+ <ColorPicker value={inputValue} onColorSelect={handleChange} allowCustomColor />
92
142
  </p>
93
143
  );
94
144
  }
95
145
 
96
- function DateInput({ id, value, onChange }: InputComponentProps) {
146
+ function DateInput({ value, onChange }: InputComponentProps) {
97
147
  const [inputValue, setInputValue] = React.useState<Date | null>(new Date(value));
148
+
149
+ React.useEffect(() => {
150
+ setInputValue(new Date(value));
151
+ }, [value]);
152
+
98
153
  const handleChange = (newValue: Date | null) => {
99
154
  if (newValue) {
100
155
  onChange(newValue.toISOString().split('T')[0]);
101
156
  }
102
157
  setInputValue(newValue);
103
158
  };
159
+
104
160
  return (
105
161
  <p className={classNames(styles.wrapper)}>
106
- <DatePicker id={id} date={inputValue} onChange={handleChange} />
162
+ <DatePicker date={inputValue} onChange={handleChange} />
107
163
  </p>
108
164
  );
109
165
  }
110
166
 
111
- function ToggleInput({ id, value, onChange }: InputComponentProps) {
112
- const [isChecked, setIsChecked] = React.useState(value);
167
+ function ToggleInput({ value, onChange }: InputComponentProps) {
168
+ const [isChecked, setIsChecked] = React.useState(!!value);
169
+
170
+ React.useEffect(() => {
171
+ setIsChecked(!!value);
172
+ }, [value]);
173
+
113
174
  const handleChange = () => {
114
175
  setIsChecked(!isChecked);
115
176
  onChange(!isChecked);
116
177
  };
178
+
117
179
  return (
118
180
  <p className={classNames(styles.wrapper)}>
119
- <Toggle id={id} defaultChecked={isChecked} onChange={handleChange} />
181
+ <Toggle defaultChecked={isChecked} onChange={handleChange} />
120
182
  </p>
121
183
  );
122
184
  }
123
185
 
124
- function JsonInput({ id, value, onChange }: InputComponentProps) {
186
+ function JsonInput({ value, onChange }: InputComponentProps) {
125
187
  const [inputValue, setInputValue] = React.useState(JSON.stringify(value, null, 2));
188
+
189
+ React.useEffect(() => {
190
+ setInputValue(JSON.stringify(value, null, 2));
191
+ }, [value]);
192
+
126
193
  const [message, setMessage] = React.useState('');
194
+
127
195
  const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
128
196
  const newValue = e.target.value;
129
197
  try {
@@ -135,9 +203,10 @@ function JsonInput({ id, value, onChange }: InputComponentProps) {
135
203
  }
136
204
  setInputValue(newValue);
137
205
  };
206
+
138
207
  return (
139
208
  <div>
140
- <TextArea id={id} value={inputValue} onChange={handleChange} />
209
+ <TextArea value={inputValue} onChange={handleChange} />
141
210
  {message && <div style={{ color: 'red' }}>{message}</div>}
142
211
  </div>
143
212
  );
@@ -11,4 +11,5 @@
11
11
 
12
12
  .label {
13
13
  font-weight: bold;
14
+ color: var(--on-background-color);
14
15
  }
@@ -15,7 +15,10 @@ export function LiveControls({
15
15
  onChange: (key: string, value: any) => void;
16
16
  }) {
17
17
  return (
18
- <ul className={classNames(styles.container)}>
18
+ <ul
19
+ className={classNames(styles.container)}
20
+ style={{ paddingBottom: '20em' /* temp walkaround for cutting popups */ }}
21
+ >
19
22
  {defs.map((field) => {
20
23
  const key = field.id;
21
24
  const InputComponent = getInputComponent(field.input || 'text');