@remotion/cli 4.0.0-alpha.217 → 4.0.0-alpha10

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.
Files changed (273) hide show
  1. package/dist/benchmark.js +11 -6
  2. package/dist/better-opn/index.js +3 -3
  3. package/dist/chalk/index.d.ts +45 -54
  4. package/dist/chalk/index.js +2 -135
  5. package/dist/codemods/stringify-with-path.d.ts +5 -0
  6. package/dist/codemods/stringify-with-path.js +44 -0
  7. package/dist/codemods/update-default-props.d.ts +4 -2
  8. package/dist/codemods/update-default-props.js +3 -18
  9. package/dist/color-math.d.ts +2 -2
  10. package/dist/color-math.js +5 -3
  11. package/dist/compositions.js +1 -0
  12. package/dist/config/image-format.d.ts +1 -1
  13. package/dist/config/index.d.ts +2 -2
  14. package/dist/config/log.d.ts +1 -3
  15. package/dist/config/log.js +2 -9
  16. package/dist/convert-entry-point-to-serve-url.js +2 -2
  17. package/dist/download-progress.d.ts +1 -1
  18. package/dist/download-progress.js +1 -4
  19. package/dist/editor/components/CanvasOrLoading.d.ts +5 -0
  20. package/dist/editor/components/CanvasOrLoading.js +66 -0
  21. package/dist/editor/components/CheckboardToggle.js +2 -1
  22. package/dist/editor/components/CompositionSelectorItem.js +2 -2
  23. package/dist/editor/components/CurrentCompositionSideEffects.js +3 -3
  24. package/dist/editor/components/InitialCompositionLoader.js +1 -1
  25. package/dist/editor/components/InlineAction.d.ts +6 -4
  26. package/dist/editor/components/InlineAction.js +7 -8
  27. package/dist/editor/components/LoopToggle.js +2 -1
  28. package/dist/editor/components/Menu/MenuItem.js +1 -1
  29. package/dist/editor/components/Menu/SubMenu.js +1 -1
  30. package/dist/editor/components/Menu/styles.d.ts +1 -0
  31. package/dist/editor/components/Menu/styles.js +6 -1
  32. package/dist/editor/components/MenuBuildIndicator.js +20 -1
  33. package/dist/editor/components/MenuToolbar.js +15 -3
  34. package/dist/editor/components/Modals.js +2 -2
  35. package/dist/editor/components/NewComposition/ComboBox.js +20 -5
  36. package/dist/editor/components/NewComposition/InputDragger.js +3 -2
  37. package/dist/editor/components/NewComposition/MenuContent.d.ts +1 -0
  38. package/dist/editor/components/NewComposition/MenuContent.js +12 -4
  39. package/dist/editor/components/Notifications/ServerDisconnected.js +2 -2
  40. package/dist/editor/components/OpenEditorButton.d.ts +2 -0
  41. package/dist/editor/components/OpenEditorButton.js +52 -0
  42. package/dist/editor/components/PlayPause.js +4 -2
  43. package/dist/editor/components/PreviewToolbar.js +2 -2
  44. package/dist/editor/components/QuickSwitcher/algolia-search.js +1 -1
  45. package/dist/editor/components/RenderButton.d.ts +1 -5
  46. package/dist/editor/components/RenderButton.js +48 -21
  47. package/dist/editor/components/RenderModal/CliCopyButton.js +51 -14
  48. package/dist/editor/components/RenderModal/CrfSetting.d.ts +0 -1
  49. package/dist/editor/components/RenderModal/CrfSetting.js +0 -1
  50. package/dist/editor/components/RenderModal/DataEditor.d.ts +21 -0
  51. package/dist/editor/components/RenderModal/DataEditor.js +287 -0
  52. package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +3 -2
  53. package/dist/editor/components/RenderModal/InfoBubble.js +2 -1
  54. package/dist/editor/components/RenderModal/InfoTooltip.d.ts +1 -0
  55. package/dist/editor/components/RenderModal/InfoTooltip.js +6 -5
  56. package/dist/editor/components/RenderModal/InlineEyeIcon.js +6 -3
  57. package/dist/editor/components/RenderModal/InlineRemoveButton.js +6 -1
  58. package/dist/editor/components/RenderModal/MutedSetting.js +3 -2
  59. package/dist/editor/components/RenderModal/OptionExplainer.js +14 -3
  60. package/dist/editor/components/RenderModal/RenderModal.d.ts +7 -3
  61. package/dist/editor/components/RenderModal/RenderModal.js +108 -49
  62. package/dist/editor/components/RenderModal/RenderModalAdvanced.js +0 -2
  63. package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
  64. package/dist/editor/components/RenderModal/RenderModalBasic.d.ts +3 -2
  65. package/dist/editor/components/RenderModal/RenderModalBasic.js +4 -3
  66. package/dist/editor/components/RenderModal/RenderModalData.d.ts +16 -4
  67. package/dist/editor/components/RenderModal/RenderModalData.js +109 -42
  68. package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +14 -0
  69. package/dist/editor/components/RenderModal/{RenderModalJSONInputPropsEditor.js → RenderModalJSONPropsEditor.js} +51 -30
  70. package/dist/editor/components/RenderModal/RenderModalPicture.d.ts +2 -2
  71. package/dist/editor/components/RenderModal/RenderModalPicture.js +2 -4
  72. package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +6 -4
  73. package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -4
  74. package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +4 -0
  75. package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +15 -6
  76. package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +5 -0
  77. package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +5 -4
  78. package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.js +6 -1
  79. package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +1 -0
  80. package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +7 -2
  81. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +5 -2
  82. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +19 -29
  83. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +5 -2
  84. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +4 -4
  85. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +5 -2
  86. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +7 -7
  87. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +5 -2
  88. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +23 -66
  89. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +5 -2
  90. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +13 -21
  91. package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +17 -0
  92. package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +10 -0
  93. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +4 -2
  94. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +20 -19
  95. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +4 -2
  96. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -26
  97. package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +1 -0
  98. package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +2 -2
  99. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +5 -2
  100. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
  101. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +5 -2
  102. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +16 -32
  103. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +7 -4
  104. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +18 -11
  105. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +5 -2
  106. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
  107. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +5 -2
  108. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +44 -11
  109. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +17 -0
  110. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +59 -0
  111. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +5 -2
  112. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +12 -23
  113. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +5 -2
  114. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +32 -21
  115. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +5 -2
  116. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
  117. package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -2
  118. package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.js +22 -22
  119. package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.d.ts +1 -0
  120. package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.js +27 -0
  121. package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +3 -0
  122. package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.js +126 -0
  123. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +14 -0
  124. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +42 -0
  125. package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +16 -0
  126. package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +38 -0
  127. package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +9 -1
  128. package/dist/editor/components/RenderModal/get-render-modal-warnings.js +42 -8
  129. package/dist/editor/components/RenderModal/human-readable-codec.d.ts +1 -1
  130. package/dist/editor/components/RenderModal/layout.js +3 -0
  131. package/dist/editor/components/RenderModal/out-name-checker.js +1 -11
  132. package/dist/editor/components/RenderQueue/RenderQueueItemCancelButton.js +5 -1
  133. package/dist/editor/components/RenderQueue/RenderQueueOpenInFolder.js +5 -1
  134. package/dist/editor/components/RenderQueue/RenderQueueRemoveItem.js +5 -1
  135. package/dist/editor/components/RenderQueue/RenderQueueRepeat.js +5 -1
  136. package/dist/editor/components/RenderQueue/actions.d.ts +4 -3
  137. package/dist/editor/components/RenderQueue/actions.js +8 -3
  138. package/dist/editor/components/RenderQueue/index.js +9 -2
  139. package/dist/editor/components/RightPanel.js +8 -5
  140. package/dist/editor/components/SidebarCollapserControls.js +22 -9
  141. package/dist/editor/components/SidebarRenderButton.d.ts +6 -0
  142. package/dist/editor/components/{RenderToolbarIcon.js → SidebarRenderButton.js} +27 -41
  143. package/dist/editor/components/Spinner.d.ts +5 -0
  144. package/dist/editor/components/Spinner.js +41 -0
  145. package/dist/editor/components/Tabs/index.js +12 -14
  146. package/dist/editor/components/Timeline/Timeline.js +3 -1
  147. package/dist/editor/components/Timeline/TimelinePlayCursorSyncer.js +4 -3
  148. package/dist/editor/components/Timeline/TimelineSequence.js +8 -6
  149. package/dist/editor/components/TimelineInOutToggle.js +2 -4
  150. package/dist/editor/components/TopPanel.js +2 -2
  151. package/dist/editor/components/UpdateCheck.js +2 -1
  152. package/dist/editor/components/get-zod-if-possible.d.ts +3 -3
  153. package/dist/editor/components/get-zod-if-possible.js +11 -11
  154. package/dist/editor/helpers/calculate-timeline.js +1 -1
  155. package/dist/editor/helpers/client-id.d.ts +2 -2
  156. package/dist/editor/helpers/client-id.js +5 -5
  157. package/dist/editor/helpers/colors.d.ts +4 -2
  158. package/dist/editor/helpers/colors.js +4 -2
  159. package/dist/editor/helpers/get-timeline-sequence-layout.d.ts +2 -2
  160. package/dist/editor/helpers/is-composition-still.d.ts +3 -2
  161. package/dist/editor/helpers/is-current-selected-still.js +3 -4
  162. package/dist/editor/helpers/use-file-existence.js +1 -1
  163. package/dist/editor/helpers/use-menu-structure.js +1 -1
  164. package/dist/editor/icons/media-volume.js +2 -1
  165. package/dist/editor/icons/render.d.ts +1 -0
  166. package/dist/editor/icons/render.js +1 -1
  167. package/dist/editor/state/modals.d.ts +3 -1
  168. package/dist/entry-point.js +17 -17
  169. package/dist/event-source-events.d.ts +2 -0
  170. package/dist/event-source.js +2 -2
  171. package/dist/ffmpeg.js +14 -5
  172. package/dist/file-watcher.js +5 -5
  173. package/dist/get-cli-options.d.ts +3 -3
  174. package/dist/get-cli-options.js +4 -4
  175. package/dist/get-composition-id.d.ts +14 -2
  176. package/dist/get-composition-id.js +32 -8
  177. package/dist/get-composition-with-dimension-override.d.ts +13 -2
  178. package/dist/get-composition-with-dimension-override.js +12 -2
  179. package/dist/get-config-file-name.js +6 -6
  180. package/dist/get-env.js +10 -10
  181. package/dist/get-filename.js +1 -0
  182. package/dist/get-input-props.d.ts +1 -1
  183. package/dist/get-input-props.js +9 -9
  184. package/dist/get-network-address.js +2 -2
  185. package/dist/handle-common-errors.d.ts +2 -1
  186. package/dist/handle-common-errors.js +2 -2
  187. package/dist/index.d.ts +41 -19
  188. package/dist/index.js +9 -6
  189. package/dist/list-of-remotion-packages.js +2 -1
  190. package/dist/load-config.js +8 -8
  191. package/dist/log.d.ts +5 -5
  192. package/dist/log.js +3 -42
  193. package/dist/parse-command-line.d.ts +1 -0
  194. package/dist/preview-server/api-types.d.ts +3 -3
  195. package/dist/preview-server/dev-middleware/compatible-api.d.ts +2 -2
  196. package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
  197. package/dist/preview-server/dev-middleware/middleware.js +7 -7
  198. package/dist/preview-server/dev-middleware/range-parser.d.ts +1 -1
  199. package/dist/preview-server/dev-middleware/setup-hooks.js +2 -2
  200. package/dist/preview-server/error-overlay/react-overlay/utils/get-file-source.js +5 -5
  201. package/dist/preview-server/error-overlay/react-overlay/utils/open-in-editor.js +17 -17
  202. package/dist/preview-server/error-overlay/remotion-overlay/CalculateMetadataErrorExplainer.d.ts +2 -0
  203. package/dist/preview-server/error-overlay/remotion-overlay/CalculateMetadataErrorExplainer.js +18 -0
  204. package/dist/preview-server/error-overlay/remotion-overlay/CodeFrame.js +30 -12
  205. package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.d.ts +4 -0
  206. package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.js +5 -2
  207. package/dist/preview-server/error-overlay/remotion-overlay/ErrorLoader.d.ts +4 -0
  208. package/dist/preview-server/error-overlay/remotion-overlay/ErrorLoader.js +5 -5
  209. package/dist/preview-server/error-overlay/remotion-overlay/ErrorTitle.d.ts +1 -0
  210. package/dist/preview-server/error-overlay/remotion-overlay/ErrorTitle.js +4 -3
  211. package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +2 -1
  212. package/dist/preview-server/error-overlay/remotion-overlay/Overlay.js +1 -1
  213. package/dist/preview-server/error-overlay/remotion-overlay/Retry.d.ts +4 -0
  214. package/dist/preview-server/error-overlay/remotion-overlay/Retry.js +9 -0
  215. package/dist/preview-server/file-existence-watchers.js +3 -3
  216. package/dist/preview-server/get-absolute-public-dir.js +3 -3
  217. package/dist/preview-server/get-package-manager.js +3 -3
  218. package/dist/preview-server/handler.d.ts +1 -1
  219. package/dist/preview-server/hot-middleware/index.d.ts +1 -1
  220. package/dist/preview-server/hot-middleware/index.js +2 -2
  221. package/dist/preview-server/live-events.d.ts +1 -1
  222. package/dist/preview-server/parse-body.d.ts +1 -1
  223. package/dist/preview-server/project-info.js +5 -5
  224. package/dist/preview-server/public-folder.js +8 -8
  225. package/dist/preview-server/render-queue/job.d.ts +11 -2
  226. package/dist/preview-server/render-queue/make-retry-payload.js +5 -1
  227. package/dist/preview-server/render-queue/open-directory-in-finder.js +8 -8
  228. package/dist/preview-server/render-queue/process-still.js +1 -0
  229. package/dist/preview-server/render-queue/queue.js +4 -4
  230. package/dist/preview-server/routes/can-update-default-props.js +3 -2
  231. package/dist/preview-server/routes/update-default-props.d.ts +2 -2
  232. package/dist/preview-server/routes/update-default-props.js +26 -15
  233. package/dist/preview-server/routes.d.ts +3 -2
  234. package/dist/preview-server/routes.js +10 -10
  235. package/dist/preview-server/serve-static.d.ts +1 -1
  236. package/dist/preview-server/serve-static.js +7 -7
  237. package/dist/preview-server/start-server.js +3 -3
  238. package/dist/preview.js +6 -4
  239. package/dist/print-error.d.ts +2 -1
  240. package/dist/print-error.js +8 -5
  241. package/dist/print-help.js +1 -1
  242. package/dist/progress-bar.d.ts +5 -4
  243. package/dist/progress-bar.js +42 -29
  244. package/dist/render-flows/render.d.ts +1 -1
  245. package/dist/render-flows/render.js +62 -35
  246. package/dist/render-flows/still.d.ts +3 -2
  247. package/dist/render-flows/still.js +34 -28
  248. package/dist/resolve-from.js +5 -5
  249. package/dist/setup-cache.d.ts +2 -1
  250. package/dist/setup-cache.js +10 -6
  251. package/dist/should-use-non-overlaying-logger.d.ts +4 -0
  252. package/dist/should-use-non-overlaying-logger.js +12 -0
  253. package/dist/show-compositions-picker.d.ts +8 -0
  254. package/dist/show-compositions-picker.js +51 -0
  255. package/dist/still.js +1 -0
  256. package/dist/studio.d.ts +1 -0
  257. package/dist/studio.js +140 -0
  258. package/dist/upgrade.js +2 -2
  259. package/dist/user-passed-output-location.d.ts +3 -2
  260. package/dist/user-passed-output-location.js +10 -5
  261. package/dist/versions.js +2 -2
  262. package/dist/watch-root-file.d.ts +1 -0
  263. package/dist/watch-root-file.js +22 -0
  264. package/package.json +89 -88
  265. package/styles/styles.css +4 -5
  266. package/dist/editor/components/CollapsableOptions.d.ts +0 -6
  267. package/dist/editor/components/CollapsableOptions.js +0 -35
  268. package/dist/editor/components/RenderModal/RenderModalJSONInputPropsEditor.d.ts +0 -10
  269. package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +0 -2
  270. package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +0 -21
  271. package/dist/editor/components/RenderToolbarIcon.d.ts +0 -2
  272. package/dist/editor/icons/RenderStillIcon.d.ts +0 -3
  273. package/dist/editor/icons/RenderStillIcon.js +0 -8
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.RenderModalData = void 0;
26
+ exports.DataEditor = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  const react_1 = __importStar(require("react"));
29
29
  const remotion_1 = require("remotion");
@@ -32,10 +32,13 @@ const colors_1 = require("../../helpers/colors");
32
32
  const get_zod_if_possible_1 = require("../get-zod-if-possible");
33
33
  const layout_1 = require("../layout");
34
34
  const ValidationMessage_1 = require("../NewComposition/ValidationMessage");
35
+ const NotificationCenter_1 = require("../Notifications/NotificationCenter");
35
36
  const actions_1 = require("../RenderQueue/actions");
36
37
  const SegmentedControl_1 = require("../SegmentedControl");
37
38
  const get_render_modal_warnings_1 = require("./get-render-modal-warnings");
38
- const RenderModalJSONInputPropsEditor_1 = require("./RenderModalJSONInputPropsEditor");
39
+ const RenderModalJSONPropsEditor_1 = require("./RenderModalJSONPropsEditor");
40
+ const extract_enum_json_paths_1 = require("./SchemaEditor/extract-enum-json-paths");
41
+ const input_props_serialization_1 = require("./SchemaEditor/input-props-serialization");
39
42
  const SchemaEditor_1 = require("./SchemaEditor/SchemaEditor");
40
43
  const SchemaErrorMessages_1 = require("./SchemaEditor/SchemaErrorMessages");
41
44
  const WarningIndicatorButton_1 = require("./WarningIndicatorButton");
@@ -59,6 +62,7 @@ const outer = {
59
62
  flexDirection: 'column',
60
63
  flex: 1,
61
64
  overflow: 'hidden',
65
+ backgroundColor: colors_1.BACKGROUND,
62
66
  };
63
67
  const controlContainer = {
64
68
  flexDirection: 'column',
@@ -83,29 +87,40 @@ const getPersistedShowWarningState = () => {
83
87
  const setPersistedShowWarningState = (val) => {
84
88
  localStorage.setItem(persistanceKey, String(Boolean(val)));
85
89
  };
86
- const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayShowSaveButton }) => {
90
+ const DataEditor = ({ unresolvedComposition, inputProps, setInputProps, compact, mayShowSaveButton, propsEditType, }) => {
87
91
  const [mode, setMode] = (0, react_1.useState)('schema');
88
92
  const [valBeforeSafe, setValBeforeSafe] = (0, react_1.useState)(inputProps);
93
+ const [saving, setSaving] = (0, react_1.useState)(false);
89
94
  const [showWarning, setShowWarningWithoutPersistance] = (0, react_1.useState)(() => getPersistedShowWarningState());
95
+ const inJSONEditor = mode === 'json';
96
+ const serializedJSON = (0, react_1.useMemo)(() => {
97
+ if (!inJSONEditor) {
98
+ return null;
99
+ }
100
+ const value = inputProps;
101
+ return (0, input_props_serialization_1.serializeJSONWithDate)({
102
+ data: value,
103
+ indent: 2,
104
+ staticBase: window.remotion_staticBase,
105
+ });
106
+ }, [inJSONEditor, inputProps]);
90
107
  const cliProps = (0, remotion_1.getInputProps)();
91
- const [canSaveDefaultProps, setCanSaveDefaultProps] = (0, react_1.useState)({
92
- canUpdate: false,
93
- reason: 'Loading...',
94
- determined: false,
108
+ const [canSaveDefaultPropsObjectState, setCanSaveDefaultProps] = (0, react_1.useState)({
109
+ [unresolvedComposition.id]: get_render_modal_warnings_1.defaultTypeCanSaveState,
95
110
  });
96
111
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
97
112
  const schema = (0, react_1.useMemo)(() => {
98
113
  if (!z) {
99
114
  return 'no-zod';
100
115
  }
101
- if (!composition.schema) {
102
- return z.any();
116
+ if (!unresolvedComposition.schema) {
117
+ return z.object({});
103
118
  }
104
- if (!(typeof composition.schema.safeParse === 'function')) {
119
+ if (!(typeof unresolvedComposition.schema.safeParse === 'function')) {
105
120
  throw new Error('A value which is not a Zod schema was passed to `schema`');
106
121
  }
107
- return composition.schema;
108
- }, [composition.schema, z]);
122
+ return unresolvedComposition.schema;
123
+ }, [unresolvedComposition.schema, z]);
109
124
  const zodValidationResult = (0, react_1.useMemo)(() => {
110
125
  if (schema === 'no-zod') {
111
126
  return 'no-zod';
@@ -122,30 +137,46 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
122
137
  return val(prevVal);
123
138
  });
124
139
  }, []);
140
+ const canSaveDefaultProps = (0, react_1.useMemo)(() => {
141
+ return canSaveDefaultPropsObjectState[unresolvedComposition.id]
142
+ ? canSaveDefaultPropsObjectState[unresolvedComposition.id]
143
+ : get_render_modal_warnings_1.defaultTypeCanSaveState;
144
+ }, [canSaveDefaultPropsObjectState, unresolvedComposition.id]);
145
+ const showSaveButton = mayShowSaveButton && canSaveDefaultProps.canUpdate;
146
+ const { fastRefreshes } = (0, react_1.useContext)(remotion_1.Internals.NonceContext);
125
147
  (0, react_1.useEffect)(() => {
126
- (0, actions_1.canUpdateDefaultProps)(composition.id)
148
+ (0, actions_1.canUpdateDefaultProps)(unresolvedComposition.id)
127
149
  .then((can) => {
128
150
  if (can.canUpdate) {
129
- setCanSaveDefaultProps({
130
- canUpdate: true,
131
- });
151
+ setCanSaveDefaultProps((prevState) => ({
152
+ ...prevState,
153
+ [unresolvedComposition.id]: {
154
+ canUpdate: true,
155
+ },
156
+ }));
132
157
  }
133
158
  else {
134
- setCanSaveDefaultProps({
135
- canUpdate: false,
136
- reason: can.reason,
137
- determined: true,
138
- });
159
+ setCanSaveDefaultProps((prevState) => ({
160
+ ...prevState,
161
+ [unresolvedComposition.id]: {
162
+ canUpdate: false,
163
+ reason: can.reason,
164
+ determined: true,
165
+ },
166
+ }));
139
167
  }
140
168
  })
141
169
  .catch((err) => {
142
- setCanSaveDefaultProps({
143
- canUpdate: false,
144
- reason: err.message,
145
- determined: true,
146
- });
170
+ setCanSaveDefaultProps((prevState) => ({
171
+ ...prevState,
172
+ [unresolvedComposition.id]: {
173
+ canUpdate: false,
174
+ reason: err.message,
175
+ determined: true,
176
+ },
177
+ }));
147
178
  });
148
- }, [composition.id]);
179
+ }, [unresolvedComposition.id]);
149
180
  const modeItems = (0, react_1.useMemo)(() => {
150
181
  return [
151
182
  {
@@ -166,26 +197,63 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
166
197
  },
167
198
  ];
168
199
  }, [mode]);
169
- const switchToSchema = (0, react_1.useCallback)(() => {
170
- setMode('schema');
171
- }, []);
172
200
  const onUpdate = (0, react_1.useCallback)(() => {
201
+ if (schema === 'no-zod' || z === null) {
202
+ (0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
203
+ return;
204
+ }
173
205
  setValBeforeSafe(inputProps);
174
- (0, actions_1.updateDefaultProps)(composition.id, inputProps);
175
- }, [composition.id, inputProps]);
206
+ (0, actions_1.updateDefaultProps)(unresolvedComposition.id, inputProps, (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, [])).then((response) => {
207
+ if (!response.success) {
208
+ (0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: ' + response.reason);
209
+ }
210
+ });
211
+ }, [unresolvedComposition.id, inputProps, schema, z]);
212
+ (0, react_1.useEffect)(() => {
213
+ setSaving(false);
214
+ }, [fastRefreshes]);
176
215
  const onSave = (0, react_1.useCallback)((updater) => {
177
- (0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps));
178
- }, [composition.defaultProps, composition.id]);
216
+ if (schema === 'no-zod' || z === null) {
217
+ (0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
218
+ return;
219
+ }
220
+ setSaving(true);
221
+ (0, actions_1.updateDefaultProps)(unresolvedComposition.id, updater(unresolvedComposition.defaultProps), (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, []))
222
+ .then((response) => {
223
+ if (!response.success) {
224
+ console.log(response.stack);
225
+ (0, NotificationCenter_1.sendErrorNotification)(`Cannot update default props: ${response.reason}. See console for more information.`);
226
+ }
227
+ })
228
+ .catch((err) => {
229
+ (0, NotificationCenter_1.sendErrorNotification)(`Cannot update default props: ${err.message}`);
230
+ setSaving(false);
231
+ });
232
+ }, [unresolvedComposition.defaultProps, unresolvedComposition.id, schema, z]);
179
233
  const connectionStatus = (0, react_1.useContext)(client_id_1.PreviewServerConnectionCtx).type;
180
234
  const warnings = (0, react_1.useMemo)(() => {
181
- return (0, get_render_modal_warnings_1.getRenderModalWarnings)({ canSaveDefaultProps, cliProps });
182
- }, [canSaveDefaultProps, cliProps]);
235
+ return (0, get_render_modal_warnings_1.getRenderModalWarnings)({
236
+ canSaveDefaultProps,
237
+ cliProps,
238
+ isCustomDateUsed: serializedJSON ? serializedJSON.customDateUsed : false,
239
+ customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,
240
+ inJSONEditor,
241
+ propsEditType,
242
+ jsMapUsed: serializedJSON ? serializedJSON.mapUsed : false,
243
+ jsSetUsed: serializedJSON ? serializedJSON.setUsed : false,
244
+ });
245
+ }, [
246
+ cliProps,
247
+ canSaveDefaultProps,
248
+ inJSONEditor,
249
+ propsEditType,
250
+ serializedJSON,
251
+ ]);
183
252
  if (connectionStatus === 'disconnected') {
184
253
  return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 5 }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The preview server has disconnected. Reconnect to edit the schema." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true })] }));
185
254
  }
186
255
  if (schema === 'no-zod') {
187
- // TODO: Make nicer modal for Zod
188
- return (0, jsx_runtime_1.jsx)("div", { children: "Install zod" });
256
+ return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.ZodNotInstalled, {});
189
257
  }
190
258
  if (!z) {
191
259
  throw new Error('expected zod');
@@ -199,12 +267,11 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
199
267
  if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {
200
268
  return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.NoSchemaDefined, {});
201
269
  }
202
- if (!composition.defaultProps) {
270
+ if (!unresolvedComposition.defaultProps) {
203
271
  return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.NoDefaultProps, {});
204
272
  }
205
- const showSaveButton = mayShowSaveButton && canSaveDefaultProps.canUpdate;
206
273
  return ((0, jsx_runtime_1.jsxs)("div", { style: outer, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlContainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: tabWrapper, children: [(0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: modeItems, needsWrapping: false }), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), warnings.length > 0 ? ((0, jsx_runtime_1.jsx)(WarningIndicatorButton_1.WarningIndicatorButton, { setShowWarning: setShowWarning, showWarning: showWarning, warningCount: warnings.length })) : null] }), showWarning && warnings.length > 0
207
274
  ? warnings.map((warning) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { message: warning, align: "flex-start", type: "warning" })] }, warning)))
208
- : null] }), mode === 'schema' ? ((0, jsx_runtime_1.jsx)(SchemaEditor_1.SchemaEditor, { value: inputProps, setValue: setInputProps, schema: schema, zodValidationResult: zodValidationResult, compact: compact, defaultProps: composition.defaultProps, onSave: onSave, showSaveButton: showSaveButton })) : ((0, jsx_runtime_1.jsx)(RenderModalJSONInputPropsEditor_1.RenderModalJSONInputPropsEditor, { value: inputProps !== null && inputProps !== void 0 ? inputProps : {}, setValue: setInputProps, zodValidationResult: zodValidationResult, switchToSchema: switchToSchema, onSave: onUpdate, valBeforeSafe: valBeforeSafe, showSaveButton: showSaveButton }))] }));
275
+ : null] }), mode === 'schema' ? ((0, jsx_runtime_1.jsx)(SchemaEditor_1.SchemaEditor, { value: inputProps, setValue: setInputProps, schema: schema, zodValidationResult: zodValidationResult, compact: compact, defaultProps: unresolvedComposition.defaultProps, onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: !zodValidationResult.success })) : ((0, jsx_runtime_1.jsx)(RenderModalJSONPropsEditor_1.RenderModalJSONPropsEditor, { value: inputProps !== null && inputProps !== void 0 ? inputProps : {}, setValue: setInputProps, onSave: onUpdate, valBeforeSafe: valBeforeSafe, showSaveButton: showSaveButton, serializedJSON: serializedJSON, defaultProps: unresolvedComposition.defaultProps, schema: schema }))] }));
209
276
  };
210
- exports.RenderModalData = RenderModalData;
277
+ exports.DataEditor = DataEditor;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { z } from 'zod';
3
+ import type { SerializedJSONWithCustomFields } from './SchemaEditor/input-props-serialization';
4
+ export declare type EditType = 'inputProps' | 'defaultProps';
5
+ export declare const RenderModalJSONPropsEditor: React.FC<{
6
+ value: unknown;
7
+ setValue: React.Dispatch<React.SetStateAction<Record<string, unknown>>>;
8
+ onSave: () => void;
9
+ valBeforeSafe: unknown;
10
+ showSaveButton: boolean;
11
+ serializedJSON: SerializedJSONWithCustomFields | null;
12
+ defaultProps: Record<string, unknown>;
13
+ schema: z.ZodTypeAny;
14
+ }>;
@@ -23,46 +23,44 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.RenderModalJSONInputPropsEditor = void 0;
26
+ exports.RenderModalJSONPropsEditor = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  const react_1 = __importStar(require("react"));
29
29
  const Button_1 = require("../../../preview-server/error-overlay/remotion-overlay/Button");
30
+ const colors_1 = require("../../helpers/colors");
30
31
  const use_keybinding_1 = require("../../helpers/use-keybinding");
31
32
  const layout_1 = require("../layout");
32
33
  const RemTextarea_1 = require("../NewComposition/RemTextarea");
33
34
  const ValidationMessage_1 = require("../NewComposition/ValidationMessage");
34
- const date_serialization_1 = require("./SchemaEditor/date-serialization");
35
- const parseJSON = (str) => {
36
- try {
37
- const value = (0, date_serialization_1.deserializeJSONWithDate)(str);
38
- return { str, value, validJSON: true };
39
- }
40
- catch (e) {
41
- return { str, validJSON: false, error: e.message };
42
- }
43
- };
35
+ const input_props_serialization_1 = require("./SchemaEditor/input-props-serialization");
36
+ const ZodErrorMessages_1 = require("./SchemaEditor/ZodErrorMessages");
44
37
  const style = {
45
38
  fontFamily: 'monospace',
46
39
  flex: 1,
47
40
  };
48
- const schemaButton = {
49
- border: 'none',
50
- padding: 0,
51
- display: 'inline-block',
52
- cursor: 'pointer',
53
- backgroundColor: 'transparent',
54
- };
55
41
  const scrollable = {
56
42
  padding: '8px 12px',
57
43
  display: 'flex',
58
44
  flexDirection: 'column',
59
45
  flex: 1,
60
46
  };
61
- // TODO: Note if custom 'remotion-date:' pattern has been used
62
- const RenderModalJSONInputPropsEditor = ({ setValue, value, zodValidationResult, switchToSchema, onSave, valBeforeSafe, showSaveButton, }) => {
47
+ const parseJSON = (str, schema) => {
48
+ try {
49
+ const value = (0, input_props_serialization_1.deserializeJSONWithCustomFields)(str);
50
+ const zodValidation = schema.safeParse(value);
51
+ return { str, value, validJSON: true, zodValidation };
52
+ }
53
+ catch (e) {
54
+ return { str, validJSON: false, error: e.message };
55
+ }
56
+ };
57
+ const RenderModalJSONPropsEditor = ({ setValue, value, defaultProps, onSave, valBeforeSafe, showSaveButton, serializedJSON, schema, }) => {
58
+ if (serializedJSON === null) {
59
+ throw new Error('expecting serializedJSON to be defined');
60
+ }
63
61
  const keybindings = (0, use_keybinding_1.useKeybinding)();
64
62
  const [localValue, setLocalValue] = react_1.default.useState(() => {
65
- return parseJSON((0, date_serialization_1.serializeJSONWithDate)(value, 2));
63
+ return parseJSON(serializedJSON.serializedString, schema);
66
64
  });
67
65
  const onPretty = (0, react_1.useCallback)(() => {
68
66
  if (!localValue.validJSON) {
@@ -70,15 +68,20 @@ const RenderModalJSONInputPropsEditor = ({ setValue, value, zodValidationResult,
70
68
  }
71
69
  const parsed = JSON.parse(localValue.str);
72
70
  setLocalValue({ ...localValue, str: JSON.stringify(parsed, null, 2) });
73
- }, [localValue]);
71
+ }, [localValue, setLocalValue]);
74
72
  const onChange = (0, react_1.useCallback)((e) => {
75
- const parsed = parseJSON(e.target.value);
73
+ const parsed = parseJSON(e.target.value, schema);
76
74
  if (parsed.validJSON) {
75
+ const validationResult = schema.safeParse(parsed.value);
77
76
  setLocalValue({
78
77
  str: e.target.value,
79
78
  value: parsed.value,
80
79
  validJSON: parsed.validJSON,
80
+ zodValidation: validationResult,
81
81
  });
82
+ if (validationResult.success) {
83
+ setValue(parsed.value);
84
+ }
82
85
  }
83
86
  else {
84
87
  setLocalValue({
@@ -87,10 +90,7 @@ const RenderModalJSONInputPropsEditor = ({ setValue, value, zodValidationResult,
87
90
  error: parsed.error,
88
91
  });
89
92
  }
90
- if (parsed.validJSON) {
91
- setValue(parsed.value);
92
- }
93
- }, [setValue]);
93
+ }, [schema, setValue]);
94
94
  const hasChanged = (0, react_1.useMemo)(() => {
95
95
  return value && JSON.stringify(value) !== JSON.stringify(valBeforeSafe);
96
96
  }, [valBeforeSafe, value]);
@@ -99,6 +99,10 @@ const RenderModalJSONInputPropsEditor = ({ setValue, value, zodValidationResult,
99
99
  onSave();
100
100
  }
101
101
  }, [hasChanged, onSave]);
102
+ // If schema is changed in code
103
+ (0, react_1.useEffect)(() => {
104
+ setLocalValue(parseJSON(localValue.str, schema));
105
+ }, [localValue.str, schema]);
102
106
  (0, react_1.useEffect)(() => {
103
107
  const save = keybindings.registerKeybinding({
104
108
  event: 'keydown',
@@ -112,7 +116,24 @@ const RenderModalJSONInputPropsEditor = ({ setValue, value, zodValidationResult,
112
116
  save.unregister();
113
117
  };
114
118
  }, [keybindings, onQuickSave, onSave]);
115
- // TODO: Indicate saving progress
116
- return ((0, jsx_runtime_1.jsxs)("div", { style: scrollable, children: [(0, jsx_runtime_1.jsx)(RemTextarea_1.RemTextarea, { onChange: onChange, value: localValue.str, status: localValue.validJSON ? 'ok' : 'error', style: style }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), localValue.validJSON === false ? ((0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.error, type: "error" })) : zodValidationResult.success === false ? ((0, jsx_runtime_1.jsx)("button", { type: "button", style: schemaButton, onClick: switchToSchema, children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: "Does not match schema", type: "warning" }) })) : null, (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { disabled: !localValue.validJSON, onClick: onPretty, children: "Format JSON" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onSave, disabled: !zodValidationResult.success || !hasChanged || !showSaveButton, children: "Save" })] })] }));
119
+ const reset = (0, react_1.useCallback)(() => {
120
+ setLocalValue(parseJSON(serializedJSON.serializedString, schema));
121
+ setValue(defaultProps);
122
+ }, [defaultProps, schema, serializedJSON.serializedString, setValue]);
123
+ const textAreaStyle = (0, react_1.useMemo)(() => {
124
+ const fail = !localValue.validJSON || !localValue.zodValidation.success;
125
+ if (!fail) {
126
+ return style;
127
+ }
128
+ return {
129
+ ...style,
130
+ borderColor: colors_1.FAIL_COLOR,
131
+ };
132
+ }, [localValue]);
133
+ return ((0, jsx_runtime_1.jsxs)("div", { style: scrollable, children: [(0, jsx_runtime_1.jsx)(RemTextarea_1.RemTextarea, { onChange: onChange, value: localValue.str, status: localValue.validJSON ? 'ok' : 'error', style: textAreaStyle }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), localValue.validJSON === false ? ((0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.error, type: "error" })) : localValue.zodValidation.success === false ? ((0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: localValue.zodValidation })) : null, (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { disabled: !localValue.validJSON ||
134
+ !(localValue.validJSON && !localValue.zodValidation.success), onClick: reset, children: "Reset" }), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), (0, jsx_runtime_1.jsx)(Button_1.Button, { disabled: !localValue.validJSON, onClick: onPretty, children: "Format" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onSave, disabled: !(localValue.validJSON && localValue.zodValidation.success) ||
135
+ !localValue.validJSON ||
136
+ !hasChanged ||
137
+ !showSaveButton, children: "Save" })] })] }));
117
138
  };
118
- exports.RenderModalJSONInputPropsEditor = RenderModalJSONInputPropsEditor;
139
+ exports.RenderModalJSONPropsEditor = RenderModalJSONPropsEditor;
@@ -12,7 +12,7 @@ export declare const RenderModalPicture: React.FC<{
12
12
  setPixelFormat: React.Dispatch<React.SetStateAction<PixelFormat>>;
13
13
  imageFormatOptions: SegmentedControlItem[];
14
14
  setQualityControl: React.Dispatch<React.SetStateAction<QualityControl>>;
15
- qualityControlType: QualityControl;
15
+ qualityControlType: QualityControl | null;
16
16
  videoImageFormat: VideoImageFormat;
17
17
  stillImageFormat: StillImageFormat;
18
18
  setJpegQuality: React.Dispatch<React.SetStateAction<number>>;
@@ -20,9 +20,9 @@ export declare const RenderModalPicture: React.FC<{
20
20
  maxCrf: number;
21
21
  minCrf: number;
22
22
  setCrf: React.Dispatch<React.SetStateAction<number>>;
23
- shouldDisplayCrfOption: boolean;
24
23
  setCustomTargetVideoBitrateValue: React.Dispatch<React.SetStateAction<string>>;
25
24
  crf: number;
26
25
  customTargetVideoBitrate: string;
26
+ shouldDisplayQualityControlPicker: boolean;
27
27
  }>;
28
28
  export {};
@@ -19,7 +19,7 @@ const qualityControlModes = ['crf', 'bitrate'];
19
19
  const container = {
20
20
  flex: 1,
21
21
  };
22
- const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixelFormat, imageFormatOptions, setQualityControl, qualityControlType, videoImageFormat, setJpegQuality, jpegQuality, maxCrf, minCrf, setCrf, shouldDisplayCrfOption, setCustomTargetVideoBitrateValue, crf, customTargetVideoBitrate, stillImageFormat, }) => {
22
+ const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixelFormat, imageFormatOptions, setQualityControl, qualityControlType, videoImageFormat, setJpegQuality, jpegQuality, maxCrf, minCrf, setCrf, shouldDisplayQualityControlPicker, setCustomTargetVideoBitrateValue, crf, customTargetVideoBitrate, stillImageFormat, }) => {
23
23
  const pixelFormatOptions = (0, react_1.useMemo)(() => {
24
24
  return client_1.BrowserSafeApis.validPixelFormats.map((option) => {
25
25
  return {
@@ -49,8 +49,6 @@ const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixel
49
49
  const onTargetVideoBitrateChanged = (0, react_1.useCallback)((e) => {
50
50
  setCustomTargetVideoBitrateValue(e.target.value);
51
51
  }, [setCustomTargetVideoBitrateValue]);
52
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, shouldDisplayCrfOption &&
53
- qualityControlType === 'crf' &&
54
- renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Target video bitrate" }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok", rightAlign: true }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
52
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' && qualityControlType !== null ? ((0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {})) : null, shouldDisplayQualityControlPicker && renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, qualityControlType === 'crf' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: layout_1.label, children: ["Target video bitrate", (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) })] }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok", rightAlign: true }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
55
53
  };
56
54
  exports.RenderModalPicture = RenderModalPicture;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
- import type { z } from 'zod';
2
+ import type { AnyZodObject, z } from 'zod';
3
3
  export declare const SchemaEditor: React.FC<{
4
- schema: z.ZodTypeAny;
4
+ schema: AnyZodObject;
5
5
  value: unknown;
6
- setValue: React.Dispatch<React.SetStateAction<unknown>>;
6
+ setValue: React.Dispatch<React.SetStateAction<Record<string, unknown>>>;
7
7
  zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
8
8
  compact: boolean;
9
- defaultProps: unknown;
9
+ defaultProps: Record<string, unknown>;
10
10
  onSave: (updater: (oldState: unknown) => unknown) => void;
11
11
  showSaveButton: boolean;
12
+ saving: boolean;
13
+ saveDisabledByParent: boolean;
12
14
  }>;
@@ -13,7 +13,7 @@ const scrollable = {
13
13
  flexDirection: 'column',
14
14
  overflowY: 'auto',
15
15
  };
16
- const SchemaEditor = ({ schema, value, setValue, zodValidationResult, compact, defaultProps, onSave, showSaveButton, }) => {
16
+ const SchemaEditor = ({ schema, value, setValue, zodValidationResult, compact, defaultProps, onSave, showSaveButton, saving, saveDisabledByParent, }) => {
17
17
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
18
18
  if (!z) {
19
19
  throw new Error('expected zod');
@@ -31,9 +31,9 @@ const SchemaEditor = ({ schema, value, setValue, zodValidationResult, compact, d
31
31
  }
32
32
  return ((0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.InvalidSchema, { reset: reset, zodValidationResult: zodValidationResult }));
33
33
  }
34
- if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
35
- return ((0, jsx_runtime_1.jsx)("div", { style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: (0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { value: value, setValue: setValue, jsonPath: [], schema: schema, compact: compact, defaultValue: defaultProps, onSave: onSave, showSaveButton: showSaveButton, onRemove: null }) }));
34
+ if (typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
35
+ return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.TopLevelZodValue, { typeReceived: typeName });
36
36
  }
37
- return null;
37
+ return ((0, jsx_runtime_1.jsx)("div", { style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: (0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { value: value, setValue: setValue, jsonPath: [], schema: schema, compact: compact, defaultValue: defaultProps, onSave: onSave, showSaveButton: showSaveButton, onRemove: null, saving: saving, saveDisabledByParent: saveDisabledByParent }) }));
38
38
  };
39
39
  exports.SchemaEditor = SchemaEditor;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { z } from 'zod';
3
+ export declare const ZodNotInstalled: () => JSX.Element;
3
4
  export declare const NoSchemaDefined: () => JSX.Element;
4
5
  export declare const NoDefaultProps: () => JSX.Element;
5
6
  export declare const InvalidDefaultProps: React.FC<{
@@ -9,3 +10,6 @@ export declare const InvalidSchema: React.FC<{
9
10
  zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
10
11
  reset: () => void;
11
12
  }>;
13
+ export declare const TopLevelZodValue: React.FC<{
14
+ typeReceived: string;
15
+ }>;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidSchema = exports.InvalidDefaultProps = exports.NoDefaultProps = exports.NoSchemaDefined = void 0;
3
+ exports.TopLevelZodValue = exports.InvalidSchema = exports.InvalidDefaultProps = exports.NoDefaultProps = exports.NoSchemaDefined = exports.ZodNotInstalled = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const Button_1 = require("../../../../preview-server/error-overlay/remotion-overlay/Button");
6
6
  const colors_1 = require("../../../helpers/colors");
7
7
  const layout_1 = require("../../layout");
8
+ const styles_1 = require("../../Menu/styles");
8
9
  const SchemaEmptyStateGraphic_1 = require("./SchemaEmptyStateGraphic");
9
10
  const ZodErrorMessages_1 = require("./ZodErrorMessages");
10
11
  const explainer = {
@@ -24,7 +25,7 @@ const errorExplanation = {
24
25
  };
25
26
  const codeSnippet = {
26
27
  fontSize: 14,
27
- color: 'var(--blue)',
28
+ color: colors_1.BLUE,
28
29
  fontFamily: 'monospace',
29
30
  };
30
31
  const errorContainer = {
@@ -36,20 +37,28 @@ const openDocs = () => {
36
37
  // TODO: Make sure to update this link when we release v4
37
38
  'https://v4.remotion.dev/docs/parametrized-rendering#define-a-schema-');
38
39
  };
40
+ const ZodNotInstalled = () => {
41
+ return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Install ", (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "zod" }), " as a dependency to interactively control the props of the composition."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn how" })] }));
42
+ };
43
+ exports.ZodNotInstalled = ZodNotInstalled;
39
44
  const NoSchemaDefined = () => {
40
- return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsx)(SchemaEmptyStateGraphic_1.SchemaEmptyStateGraphic, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 5 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Make the props of this composition interactively editable by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "schema" }), " prop to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " component."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn how" })] }));
45
+ return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsx)(SchemaEmptyStateGraphic_1.SchemaEmptyStateGraphic, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 5 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Make the props of this composition interactively editable by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "schema" }), " prop to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: '<Composition>' }), " component."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn how" })] }));
41
46
  };
42
47
  exports.NoSchemaDefined = NoSchemaDefined;
43
48
  const NoDefaultProps = () => {
44
- return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " does not exist."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by adding a ", (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), ' ', "prop to your composition."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn more" })] }));
49
+ return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: '<Composition>' }), " does not exist."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "defaultProps" }), " prop to your composition."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn more" })] }));
45
50
  };
46
51
  exports.NoDefaultProps = NoDefaultProps;
47
52
  const InvalidDefaultProps = ({ zodValidationResult }) => {
48
53
  // TODO: Does not react to when schema is updated
49
- return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " is not valid:"] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by changing the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in your composition so it does not give a type error."] })] }));
54
+ return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: '<Composition>' }), " is not valid:"] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by changing the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "defaultProps" }), " prop in your composition so it does not give a type error."] })] }));
50
55
  };
51
56
  exports.InvalidDefaultProps = InvalidDefaultProps;
52
57
  const InvalidSchema = ({ zodValidationResult, reset }) => {
53
- return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the ", (0, jsx_runtime_1.jsx)("code", { children: "defaultProps" }), " that you have defined."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: reset, children: "Reset props" })] }));
58
+ return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "defaultProps" }), " that you have defined."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: reset, children: "Reset props" })] }));
54
59
  };
55
60
  exports.InvalidSchema = InvalidSchema;
61
+ const TopLevelZodValue = ({ typeReceived }) => {
62
+ return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The top-level type of the schema must be a pure", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "z.object" }), ". Instead got a schema of type", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: typeReceived })] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema by changing the top-level Zod type to an object." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn more" })] }));
63
+ };
64
+ exports.TopLevelZodValue = TopLevelZodValue;
@@ -8,8 +8,13 @@ export declare const SchemaLabel: React.FC<{
8
8
  onRemove: null | (() => void);
9
9
  showSaveButton: boolean;
10
10
  compact: boolean;
11
+ saving: boolean;
12
+ valid: boolean;
13
+ saveDisabledByParent: boolean;
11
14
  }>;
12
15
  export declare const SchemaFieldsetLabel: React.FC<{
13
16
  jsonPath: JSONPath;
14
17
  onRemove: null | (() => void);
18
+ isDefaultValue: boolean;
19
+ onReset: () => void;
15
20
  }>;
@@ -30,11 +30,12 @@ const labelStyle = {
30
30
  color: colors_1.LIGHT_TEXT,
31
31
  lineHeight: '40px',
32
32
  };
33
- const SchemaLabel = ({ jsonPath, isDefaultValue, onReset, onSave, showSaveButton, compact, onRemove, }) => {
34
- return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? compactStyles : wideStyles, children: [(0, jsx_runtime_1.jsx)("span", { style: labelStyle, children: (0, get_schema_label_1.getSchemaLabel)(jsonPath) }), compact ? (0, jsx_runtime_1.jsx)(layout_1.Flex, {}) : (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), isDefaultValue ? null : (0, jsx_runtime_1.jsx)(SchemaResetButton_1.SchemaResetButton, { onClick: onReset }), isDefaultValue ? null : showSaveButton ? ((0, jsx_runtime_1.jsx)(SchemaSaveButton_1.SchemaSaveButton, { onClick: onSave })) : null, onRemove ? (0, jsx_runtime_1.jsx)(InlineRemoveButton_1.InlineRemoveButton, { onClick: onRemove }) : null] }));
33
+ const SchemaLabel = ({ jsonPath, isDefaultValue, onReset, onSave, showSaveButton, compact, onRemove, saving, valid, saveDisabledByParent, }) => {
34
+ const disableSave = saving || !valid || saveDisabledByParent;
35
+ return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? compactStyles : wideStyles, children: [(0, jsx_runtime_1.jsx)("span", { style: labelStyle, children: (0, get_schema_label_1.getSchemaLabel)(jsonPath) }), compact ? (0, jsx_runtime_1.jsx)(layout_1.Flex, {}) : (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), isDefaultValue ? null : (0, jsx_runtime_1.jsx)(SchemaResetButton_1.SchemaResetButton, { onClick: onReset }), isDefaultValue ? null : showSaveButton ? ((0, jsx_runtime_1.jsx)(SchemaSaveButton_1.SchemaSaveButton, { onClick: onSave, disabled: disableSave })) : null, onRemove ? (0, jsx_runtime_1.jsx)(InlineRemoveButton_1.InlineRemoveButton, { onClick: onRemove }) : null] }));
35
36
  };
36
37
  exports.SchemaLabel = SchemaLabel;
37
- const SchemaFieldsetLabel = ({ jsonPath, onRemove }) => {
38
- return ((0, jsx_runtime_1.jsxs)("legend", { style: layout_2.fieldsetLabel, children: [(0, get_schema_label_1.getSchemaLabel)(jsonPath), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), onRemove ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), " ", (0, jsx_runtime_1.jsx)(InlineRemoveButton_1.InlineRemoveButton, { onClick: onRemove })] })) : null] }));
38
+ const SchemaFieldsetLabel = ({ jsonPath, onRemove, isDefaultValue, onReset }) => {
39
+ return ((0, jsx_runtime_1.jsxs)("legend", { style: layout_2.fieldsetLabel, children: [(0, get_schema_label_1.getSchemaLabel)(jsonPath), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), isDefaultValue ? null : (0, jsx_runtime_1.jsx)(SchemaResetButton_1.SchemaResetButton, { onClick: onReset }), onRemove ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), " ", (0, jsx_runtime_1.jsx)(InlineRemoveButton_1.InlineRemoveButton, { onClick: onRemove })] })) : null] }));
39
40
  };
40
41
  exports.SchemaFieldsetLabel = SchemaFieldsetLabel;
@@ -2,11 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaResetButton = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const InlineAction_1 = require("../../InlineAction");
6
7
  const icon = {
7
8
  height: 14,
9
+ color: 'currentColor',
8
10
  };
9
11
  const SchemaResetButton = ({ onClick }) => {
10
- return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { onClick: onClick, children: (0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 512 512", children: (0, jsx_runtime_1.jsx)("path", { fill: "currentcolor", d: "M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z" }) }) }));
12
+ const renderAction = (0, react_1.useCallback)((color) => {
13
+ return ((0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 512 512", children: (0, jsx_runtime_1.jsx)("path", { fill: color, d: "M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z" }) }));
14
+ }, []);
15
+ return (0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick });
11
16
  };
12
17
  exports.SchemaResetButton = SchemaResetButton;