@remotion/cli 4.0.0-alpha13 → 4.0.0-alpha16

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 (189) hide show
  1. package/dist/ansi/ansi-diff.d.ts +1 -1
  2. package/dist/benchmark.js +29 -14
  3. package/dist/cleanup-before-quit.js +3 -0
  4. package/dist/composition-prompts.d.ts +2 -2
  5. package/dist/compositions.js +8 -7
  6. package/dist/config/concurrency.d.ts +1 -1
  7. package/dist/config/index.d.ts +2 -2
  8. package/dist/config/jpeg-quality.d.ts +1 -1
  9. package/dist/config/jpeg-quality.js +1 -1
  10. package/dist/config/number-of-gif-loops.d.ts +1 -1
  11. package/dist/config/override-webpack.d.ts +1 -1
  12. package/dist/config/scale.d.ts +1 -1
  13. package/dist/config/user-agent.d.ts +1 -1
  14. package/dist/editor/components/CanvasOrLoading.js +3 -0
  15. package/dist/editor/components/Checkbox.d.ts +1 -0
  16. package/dist/editor/components/Checkbox.js +2 -2
  17. package/dist/editor/components/CompositionSelectorItem.d.ts +1 -1
  18. package/dist/editor/components/InlineAction.d.ts +1 -1
  19. package/dist/editor/components/Menu/MenuItem.d.ts +2 -2
  20. package/dist/editor/components/Menu/MenuSubItem.d.ts +1 -1
  21. package/dist/editor/components/NewComposition/ComboBox.d.ts +4 -4
  22. package/dist/editor/components/NewComposition/CopyHint.js +1 -1
  23. package/dist/editor/components/NewComposition/InputDragger.d.ts +1 -1
  24. package/dist/editor/components/NewComposition/RemInput.d.ts +3 -3
  25. package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +2 -1
  26. package/dist/editor/components/NewComposition/RemInputTypeColor.js +1 -1
  27. package/dist/editor/components/NewComposition/RemTextarea.d.ts +1 -1
  28. package/dist/editor/components/Notifications/NotificationCenter.d.ts +2 -2
  29. package/dist/editor/components/QuickSwitcher/NoResults.d.ts +1 -1
  30. package/dist/editor/components/QuickSwitcher/QuickSwitcherResult.d.ts +2 -2
  31. package/dist/editor/components/RenderModal/DataEditor.d.ts +2 -3
  32. package/dist/editor/components/RenderModal/DataEditor.js +14 -5
  33. package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +1 -1
  34. package/dist/editor/components/RenderModal/MutedSetting.js +1 -1
  35. package/dist/editor/components/RenderModal/RenderModal.d.ts +1 -1
  36. package/dist/editor/components/RenderModal/RenderModal.js +2 -2
  37. package/dist/editor/components/RenderModal/RenderModalAdvanced.d.ts +1 -1
  38. package/dist/editor/components/RenderModal/RenderModalAdvanced.js +1 -1
  39. package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
  40. package/dist/editor/components/RenderModal/RenderModalGif.js +1 -1
  41. package/dist/editor/components/RenderModal/RenderModalInput.d.ts +1 -1
  42. package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
  43. package/dist/editor/components/RenderModal/RenderModalPicture.d.ts +1 -1
  44. package/dist/editor/components/RenderModal/SchemaEditor/Fieldset.d.ts +7 -0
  45. package/dist/editor/components/RenderModal/SchemaEditor/Fieldset.js +26 -0
  46. package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +0 -1
  47. package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +2 -3
  48. package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -3
  49. package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +1 -7
  50. package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +14 -22
  51. package/dist/editor/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +2 -0
  52. package/dist/editor/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +11 -0
  53. package/dist/editor/components/RenderModal/SchemaEditor/SchemaVerticalGuide.d.ts +5 -0
  54. package/dist/editor/components/RenderModal/SchemaEditor/SchemaVerticalGuide.js +13 -0
  55. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -1
  56. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +51 -42
  57. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +1 -1
  58. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +5 -5
  59. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +3 -1
  60. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +14 -13
  61. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +1 -1
  62. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +12 -14
  63. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +1 -1
  64. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +9 -15
  65. package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +1 -1
  66. package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -2
  67. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -1
  68. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +5 -30
  69. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +0 -1
  70. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +8 -11
  71. package/dist/editor/components/RenderModal/SchemaEditor/ZodFieldValidation.d.ts +7 -0
  72. package/dist/editor/components/RenderModal/SchemaEditor/ZodFieldValidation.js +27 -0
  73. package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +1 -1
  74. package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +3 -3
  75. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +1 -1
  76. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
  77. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +1 -1
  78. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +10 -13
  79. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +1 -1
  80. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +39 -45
  81. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +1 -1
  82. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
  83. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +2 -1
  84. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +13 -48
  85. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -1
  86. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +7 -10
  87. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +1 -1
  88. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +8 -11
  89. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -2
  90. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +21 -21
  91. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +1 -1
  92. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
  93. package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.js +3 -0
  94. package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +1 -1
  95. package/dist/editor/components/RenderModal/SchemaEditor/get-schema-label.js +3 -3
  96. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +1 -1
  97. package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +10 -5
  98. package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +56 -15
  99. package/dist/editor/components/RenderModal/SchemaEditor/zod-types.d.ts +1 -1
  100. package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +1 -1
  101. package/dist/editor/components/RenderModal/layout.d.ts +0 -1
  102. package/dist/editor/components/RenderModal/layout.js +1 -7
  103. package/dist/editor/components/RenderQueue/actions.d.ts +2 -1
  104. package/dist/editor/components/RenderQueue/actions.js +7 -2
  105. package/dist/editor/components/RenderQueue/context.d.ts +1 -1
  106. package/dist/editor/components/RightPanel.d.ts +1 -1
  107. package/dist/editor/components/RightPanel.js +1 -1
  108. package/dist/editor/components/SegmentedControl.d.ts +1 -1
  109. package/dist/editor/components/SegmentedControl.js +2 -0
  110. package/dist/editor/components/Splitter/SplitterContext.d.ts +3 -3
  111. package/dist/editor/components/Timeline/LoopedIndicator.js +6 -6
  112. package/dist/editor/components/Timeline/TimelineWidthProvider.d.ts +1 -1
  113. package/dist/editor/components/Timeline/TimelineZoomControls.js +1 -1
  114. package/dist/editor/components/Timeline/timeline-state-reducer.d.ts +2 -2
  115. package/dist/editor/components/UpdateCheck.d.ts +1 -1
  116. package/dist/editor/components/UpdateCheck.js +2 -4
  117. package/dist/editor/components/get-zod-if-possible.d.ts +2 -2
  118. package/dist/editor/helpers/client-id.d.ts +1 -1
  119. package/dist/editor/helpers/colors.d.ts +1 -1
  120. package/dist/editor/helpers/get-timeline-sequence-sort-key.d.ts +3 -3
  121. package/dist/editor/helpers/persist-open-folders.d.ts +1 -1
  122. package/dist/editor/helpers/render-modal-sections.d.ts +1 -1
  123. package/dist/editor/helpers/use-menu-structure.d.ts +1 -1
  124. package/dist/editor/icons/plus.d.ts +3 -1
  125. package/dist/editor/icons/plus.js +2 -2
  126. package/dist/editor/state/checkerboard.d.ts +1 -1
  127. package/dist/editor/state/editor-zoom-gestures.d.ts +1 -1
  128. package/dist/editor/state/folders.d.ts +1 -1
  129. package/dist/editor/state/highest-z-index.d.ts +1 -1
  130. package/dist/editor/state/in-out.d.ts +2 -2
  131. package/dist/editor/state/keybindings.d.ts +4 -4
  132. package/dist/editor/state/modals.d.ts +4 -4
  133. package/dist/editor/state/preview-size.d.ts +1 -1
  134. package/dist/editor/state/sidebar.d.ts +3 -3
  135. package/dist/editor/state/timeline-ref.d.ts +1 -1
  136. package/dist/event-source-events.d.ts +1 -1
  137. package/dist/file-watcher.d.ts +1 -1
  138. package/dist/get-cli-options.d.ts +1 -1
  139. package/dist/get-composition-id.d.ts +10 -11
  140. package/dist/get-composition-id.js +9 -6
  141. package/dist/get-composition-with-dimension-override.d.ts +4 -4
  142. package/dist/get-composition-with-dimension-override.js +2 -2
  143. package/dist/index.d.ts +5 -4
  144. package/dist/log.d.ts +1 -0
  145. package/dist/parse-command-line.d.ts +1 -1
  146. package/dist/preview-server/api-routes.js +2 -0
  147. package/dist/preview-server/api-types.d.ts +5 -4
  148. package/dist/preview-server/dev-middleware/get-paths.d.ts +1 -1
  149. package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
  150. package/dist/preview-server/dev-middleware/range-parser.d.ts +2 -2
  151. package/dist/preview-server/dev-middleware/types.d.ts +1 -1
  152. package/dist/preview-server/error-overlay/react-overlay/effects/map-error-to-react-stack.d.ts +1 -1
  153. package/dist/preview-server/error-overlay/react-overlay/effects/proxy-console.d.ts +3 -3
  154. package/dist/preview-server/error-overlay/react-overlay/effects/unhandled-error.d.ts +1 -1
  155. package/dist/preview-server/error-overlay/react-overlay/effects/unhandled-rejection.d.ts +1 -1
  156. package/dist/preview-server/error-overlay/react-overlay/listen-to-runtime-errors.d.ts +1 -1
  157. package/dist/preview-server/error-overlay/react-overlay/utils/get-source-map.js +1 -0
  158. package/dist/preview-server/error-overlay/react-overlay/utils/open-in-editor.d.ts +2 -2
  159. package/dist/preview-server/error-overlay/react-overlay/utils/stack-frame.d.ts +4 -4
  160. package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.d.ts +1 -1
  161. package/dist/preview-server/error-overlay/remotion-overlay/Overlay.d.ts +2 -2
  162. package/dist/preview-server/error-overlay/remotion-overlay/get-help-link.d.ts +1 -1
  163. package/dist/preview-server/get-package-manager.d.ts +2 -2
  164. package/dist/preview-server/hot-middleware/client.d.ts +1 -1
  165. package/dist/preview-server/hot-middleware/types.d.ts +4 -4
  166. package/dist/preview-server/live-events.d.ts +1 -1
  167. package/dist/preview-server/live-events.js +10 -1
  168. package/dist/preview-server/project-info.d.ts +1 -1
  169. package/dist/preview-server/render-queue/job.d.ts +30 -21
  170. package/dist/preview-server/render-queue/process-still.js +1 -2
  171. package/dist/preview-server/routes/update-available.d.ts +3 -0
  172. package/dist/preview-server/routes/update-available.js +9 -0
  173. package/dist/preview-server/routes.js +1 -11
  174. package/dist/preview-server/update-available.d.ts +2 -10
  175. package/dist/progress-bar.d.ts +4 -4
  176. package/dist/progress-bar.js +3 -2
  177. package/dist/progress-types.d.ts +4 -4
  178. package/dist/render-flows/render.js +35 -28
  179. package/dist/render-flows/still.d.ts +1 -1
  180. package/dist/render-flows/still.js +23 -10
  181. package/dist/required-chromium-options.d.ts +2 -2
  182. package/dist/server-ready-comment.d.ts +1 -1
  183. package/dist/server-ready-comment.js +2 -2
  184. package/dist/setup-cache.js +10 -0
  185. package/dist/show-compositions-picker.d.ts +1 -1
  186. package/dist/step.d.ts +1 -1
  187. package/dist/studio.js +3 -3
  188. package/dist/truthy.d.ts +1 -1
  189. package/package.json +10 -12
@@ -9,14 +9,14 @@ const layout_1 = require("../../layout");
9
9
  const InputDragger_1 = require("../../NewComposition/InputDragger");
10
10
  const RemInput_1 = require("../../NewComposition/RemInput");
11
11
  const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
12
- const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
13
- const layout_2 = require("../layout");
14
12
  const local_state_1 = require("./local-state");
15
13
  const SchemaLabel_1 = require("./SchemaLabel");
14
+ const Fieldset_1 = require("./Fieldset");
15
+ const ZodFieldValidation_1 = require("./ZodFieldValidation");
16
16
  const fullWidth = {
17
17
  width: '100%',
18
18
  };
19
- const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
19
+ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, onSave, onRemove, saving, saveDisabledByParent, mayPad, }) => {
20
20
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
21
21
  if (!z) {
22
22
  throw new Error('expected zod');
@@ -25,27 +25,25 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
25
25
  if (!zodTypes) {
26
26
  throw new Error('expected zod color');
27
27
  }
28
- const { localValue, onChange: onValueChange } = (0, local_state_1.useLocalState)({
28
+ const { localValue, onChange: onValueChange, reset, } = (0, local_state_1.useLocalState)({
29
29
  schema,
30
30
  setValue,
31
31
  value,
32
+ defaultValue,
32
33
  });
33
34
  const { a, b, g, r } = localValue.zodValidation.success
34
35
  ? zodTypes.ZodZypesInternals.parseColor(localValue.value)
35
36
  : { a: 1, b: 0, g: 0, r: 0 };
36
37
  const onChange = (0, react_1.useCallback)((e) => {
37
38
  const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
38
- onValueChange(() => newColor, false);
39
+ onValueChange(() => newColor, false, false);
39
40
  }, [a, onValueChange, zodTypes]);
40
41
  const onTextChange = (0, react_1.useCallback)((e) => {
41
42
  const newValue = e.target.value;
42
- onValueChange(() => newValue, false);
43
+ onValueChange(() => newValue, false, false);
43
44
  }, [onValueChange]);
44
- const reset = (0, react_1.useCallback)(() => {
45
- onValueChange(() => defaultValue, true);
46
- }, [defaultValue, onValueChange]);
47
45
  const save = (0, react_1.useCallback)(() => {
48
- onSave(() => value, false);
46
+ onSave(() => value, false, false);
49
47
  }, [onSave, value]);
50
48
  const rgb = `#${r.toString(16).padStart(2, '0')}${g
51
49
  .toString(16)
@@ -60,14 +58,14 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
60
58
  }, []);
61
59
  const onOpacityChange = (0, react_1.useCallback)((newValue) => {
62
60
  const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
63
- onValueChange(() => newColor, false);
61
+ onValueChange(() => newColor, false, false);
64
62
  }, [localValue.value, onValueChange, zodTypes]);
65
63
  const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
66
64
  const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
67
- onValueChange(() => newColor, false);
65
+ onValueChange(() => newColor, false, false);
68
66
  }, [localValue.value, onValueChange, zodTypes]);
69
- return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
67
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: localValue.value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
70
68
  height: 39,
71
- }, value: rgb, onChange: onChange, className: "__remotion_color_picker", status: status }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1, block: true }), (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}%`, rightAlign: false })] }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
69
+ }, value: rgb, onChange: onChange, className: "__remotion_color_picker", status: status, name: jsonPath.join('.') }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1, block: true }), (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}%`, rightAlign: false })] }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] })] }));
72
70
  };
73
71
  exports.ZodColorEditor = ZodColorEditor;
@@ -10,8 +10,8 @@ export declare const ZodDateEditor: React.FC<{
10
10
  setValue: UpdaterFunction<Date>;
11
11
  onSave: UpdaterFunction<Date>;
12
12
  onRemove: null | (() => void);
13
- compact: boolean;
14
13
  showSaveButton: boolean;
15
14
  saving: boolean;
16
15
  saveDisabledByParent: boolean;
16
+ mayPad: boolean;
17
17
  }>;
@@ -6,10 +6,10 @@ const react_1 = require("react");
6
6
  const colors_1 = require("../../../helpers/colors");
7
7
  const layout_1 = require("../../layout");
8
8
  const RemInput_1 = require("../../NewComposition/RemInput");
9
- const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
10
- const layout_2 = require("../layout");
11
9
  const local_state_1 = require("./local-state");
12
10
  const SchemaLabel_1 = require("./SchemaLabel");
11
+ const Fieldset_1 = require("./Fieldset");
12
+ const ZodFieldValidation_1 = require("./ZodFieldValidation");
13
13
  const fullWidth = {
14
14
  width: '100%',
15
15
  };
@@ -17,7 +17,6 @@ const explainer = {
17
17
  fontFamily: 'sans-serif',
18
18
  fontSize: 12,
19
19
  color: colors_1.VERY_LIGHT_TEXT,
20
- marginBottom: layout_1.SPACING_UNIT,
21
20
  };
22
21
  // This will do 2 things:
23
22
  // - Make the calendar icon white
@@ -44,25 +43,20 @@ const formatDate = (date) => {
44
43
  .padStart(3, '0')}`;
45
44
  return formattedDate;
46
45
  };
47
- const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
48
- const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
46
+ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, onSave, onRemove, saving, saveDisabledByParent, mayPad, }) => {
47
+ const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
49
48
  schema,
50
49
  setValue,
51
50
  value,
51
+ defaultValue,
52
52
  });
53
- const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
54
- setLocalValue(() => newValue, forceApply);
55
- }, [setLocalValue]);
56
53
  const onChange = (0, react_1.useCallback)((e) => {
57
54
  // React does not support e.target.valueAsDate :(
58
- onValueChange(new Date(e.target.value), false);
59
- }, [onValueChange]);
60
- const reset = (0, react_1.useCallback)(() => {
61
- onValueChange(defaultValue, true);
62
- }, [defaultValue, onValueChange]);
55
+ setLocalValue(() => new Date(e.target.value), false, false);
56
+ }, [setLocalValue]);
63
57
  const save = (0, react_1.useCallback)(() => {
64
- onSave(() => value, false);
58
+ onSave(() => value, false, false);
65
59
  }, [onSave, value]);
66
- return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
60
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: localValue.value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] })] }));
67
61
  };
68
62
  exports.ZodDateEditor = ZodDateEditor;
@@ -5,7 +5,6 @@ import type { UpdaterFunction } from './ZodSwitch';
5
5
  export declare const ZodDefaultEditor: React.FC<{
6
6
  showSaveButton: boolean;
7
7
  jsonPath: JSONPath;
8
- compact: boolean;
9
8
  value: unknown;
10
9
  defaultValue: unknown;
11
10
  schema: z.ZodTypeAny;
@@ -14,4 +13,5 @@ export declare const ZodDefaultEditor: React.FC<{
14
13
  onRemove: null | (() => void);
15
14
  saving: boolean;
16
15
  saveDisabledByParent: boolean;
16
+ mayPad: boolean;
17
17
  }>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZodDefaultEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const ZodSwitch_1 = require("./ZodSwitch");
6
- const ZodDefaultEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
6
+ const ZodDefaultEditor = ({ jsonPath, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
7
7
  const { innerType } = schema._def;
8
- return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, saving: saving, saveDisabledByParent: saveDisabledByParent }));
8
+ return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }));
9
9
  };
10
10
  exports.ZodDefaultEditor = ZodDefaultEditor;
@@ -7,10 +7,10 @@ export declare const ZodEffectEditor: React.FC<{
7
7
  jsonPath: JSONPath;
8
8
  value: unknown;
9
9
  setValue: UpdaterFunction<unknown>;
10
- compact: boolean;
11
10
  defaultValue: unknown;
12
11
  onSave: UpdaterFunction<unknown>;
13
12
  showSaveButton: boolean;
14
13
  onRemove: null | (() => void);
15
14
  saving: boolean;
15
+ mayPad: boolean;
16
16
  }>;
@@ -2,27 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZodEffectEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const colors_1 = require("../../../helpers/colors");
7
5
  const get_zod_if_possible_1 = require("../../get-zod-if-possible");
8
- const layout_1 = require("../../layout");
9
- const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
10
- const InfoBubble_1 = require("../InfoBubble");
11
6
  const local_state_1 = require("./local-state");
12
7
  const ZodSwitch_1 = require("./ZodSwitch");
8
+ const Fieldset_1 = require("./Fieldset");
9
+ const ZodFieldValidation_1 = require("./ZodFieldValidation");
13
10
  const fullWidth = {
14
11
  width: '100%',
15
12
  };
16
- const stackTrace = {
17
- padding: 10,
18
- };
19
- const stackTraceLabel = {
20
- fontSize: 14,
21
- };
22
- const legend = {
23
- display: 'flex',
24
- };
25
- const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compact, defaultValue, onSave, onRemove, showSaveButton, saving, }) => {
13
+ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, defaultValue, onSave, onRemove, showSaveButton, saving, mayPad, }) => {
26
14
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
27
15
  if (!z) {
28
16
  throw new Error('expected zod');
@@ -31,26 +19,13 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
31
19
  value,
32
20
  schema,
33
21
  setValue: updateValue,
22
+ defaultValue,
34
23
  });
35
24
  const def = schema._def;
36
25
  const typeName = def.typeName;
37
26
  if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
38
27
  throw new Error('expected effect');
39
28
  }
40
- const container = (0, react_1.useMemo)(() => {
41
- if (!localValue.zodValidation.success) {
42
- return {
43
- border: `1px solid ${colors_1.FAIL_COLOR}`,
44
- borderRadius: 4,
45
- };
46
- }
47
- return {
48
- border: 'none',
49
- padding: 0,
50
- };
51
- }, [localValue.zodValidation.success]);
52
- return ((0, jsx_runtime_1.jsxs)("fieldset", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: !localValue.zodValidation.success }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)("legend", { style: legend, children: [(0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Zod validation failure", children: (0, jsx_runtime_1.jsxs)("div", { style: stackTrace, children: [(0, jsx_runtime_1.jsx)("div", { style: stackTraceLabel, children: "Zod Validation has failed:" }), localValue.zodValidation.error.errors.map((error, index) => (
53
- // eslint-disable-next-line react/no-array-index-key
54
- (0, jsx_runtime_1.jsxs)("div", { style: stackTraceLabel, children: ["Type: ", error.code, " ", (0, jsx_runtime_1.jsx)("br", {}), "Message: ", error.message] }, index)))] }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 })] }))] }));
29
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: !localValue.zodValidation.success, mayPad: false }) }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
55
30
  };
56
31
  exports.ZodEffectEditor = ZodEffectEditor;
@@ -9,7 +9,6 @@ export declare const ZodEnumEditor: React.FC<{
9
9
  defaultValue: string;
10
10
  setValue: UpdaterFunction<string>;
11
11
  onSave: UpdaterFunction<string>;
12
- compact: boolean;
13
12
  showSaveButton: boolean;
14
13
  onRemove: null | (() => void);
15
14
  saving: boolean;
@@ -5,24 +5,24 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const Checkmark_1 = require("../../../icons/Checkmark");
7
7
  const get_zod_if_possible_1 = require("../../get-zod-if-possible");
8
- const layout_1 = require("../../layout");
9
8
  const ComboBox_1 = require("../../NewComposition/ComboBox");
10
- const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
11
- const layout_2 = require("../layout");
12
9
  const local_state_1 = require("./local-state");
13
10
  const SchemaLabel_1 = require("./SchemaLabel");
11
+ const Fieldset_1 = require("./Fieldset");
12
+ const ZodFieldValidation_1 = require("./ZodFieldValidation");
14
13
  const container = {
15
14
  width: '100%',
16
15
  };
17
- const ZodEnumEditor = ({ schema, jsonPath, compact, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
16
+ const ZodEnumEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
18
17
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
19
18
  if (!z) {
20
19
  throw new Error('expected zod');
21
20
  }
22
- const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
21
+ const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
23
22
  schema,
24
23
  setValue,
25
24
  value,
25
+ defaultValue,
26
26
  });
27
27
  const def = schema._def;
28
28
  const typeName = def.typeName;
@@ -30,9 +30,6 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue, defaultValue, valu
30
30
  throw new Error('expected enum');
31
31
  }
32
32
  const isRoot = jsonPath.length === 0;
33
- const reset = (0, react_1.useCallback)(() => {
34
- setLocalValue(() => defaultValue, true);
35
- }, [defaultValue, setLocalValue]);
36
33
  const comboBoxValues = (0, react_1.useMemo)(() => {
37
34
  return def.values.map((option) => {
38
35
  return {
@@ -42,7 +39,7 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue, defaultValue, valu
42
39
  keyHint: null,
43
40
  leftItem: option === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
44
41
  onClick: (id) => {
45
- setLocalValue(() => id, false);
42
+ setLocalValue(() => id, false, false);
46
43
  },
47
44
  quickSwitcherLabel: null,
48
45
  subMenu: null,
@@ -51,8 +48,8 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue, defaultValue, valu
51
48
  });
52
49
  }, [def.values, setLocalValue, value]);
53
50
  const save = (0, react_1.useCallback)(() => {
54
- onSave(() => value, false);
51
+ onSave(() => value, false, false);
55
52
  }, [onSave, value]);
56
- return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: !localValue.zodValidation.success }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), !localValue.zodValidation.success && ((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)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] }));
53
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: true, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: localValue.value === defaultValue, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: !localValue.zodValidation.success, suffix: null }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
57
54
  };
58
55
  exports.ZodEnumEditor = ZodEnumEditor;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { LocalState } from './local-state';
3
+ import type { JSONPath } from './zod-types';
4
+ export declare const ZodFieldValidation: React.FC<{
5
+ localValue: LocalState<unknown>;
6
+ path: JSONPath;
7
+ }>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZodFieldValidation = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
6
+ const layout_1 = require("../../layout");
7
+ const InfoBubble_1 = require("../InfoBubble");
8
+ const legend = {
9
+ display: 'flex',
10
+ flexDirection: 'row',
11
+ alignItems: 'center',
12
+ };
13
+ const stackTrace = {
14
+ padding: 10,
15
+ };
16
+ const stackTraceLabel = {
17
+ fontSize: 14,
18
+ };
19
+ const ZodFieldValidation = ({ localValue, path }) => {
20
+ if (localValue.zodValidation.success) {
21
+ return null;
22
+ }
23
+ return ((0, jsx_runtime_1.jsxs)("div", { style: legend, children: [(0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Zod validation failure", children: (0, jsx_runtime_1.jsxs)("div", { style: stackTrace, children: [(0, jsx_runtime_1.jsx)("div", { style: stackTraceLabel, children: "Zod Validation has failed:" }), localValue.zodValidation.error.errors.map((error, index) => (
24
+ // eslint-disable-next-line react/no-array-index-key
25
+ (0, jsx_runtime_1.jsxs)("div", { style: stackTraceLabel, children: ["Type: ", error.code, " ", (0, jsx_runtime_1.jsx)("br", {}), "Message: ", error.message, (0, jsx_runtime_1.jsx)("br", {}), "Path: ", path.join('.')] }, index)))] }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 })] }));
26
+ };
27
+ exports.ZodFieldValidation = ZodFieldValidation;
@@ -3,7 +3,7 @@ import type { JSONPath } from './zod-types';
3
3
  export declare const ZonNonEditableValue: React.FC<{
4
4
  jsonPath: JSONPath;
5
5
  label: string;
6
- compact: boolean;
7
6
  showSaveButton: boolean;
8
7
  saving: boolean;
8
+ mayPad: boolean;
9
9
  }>;
@@ -4,8 +4,8 @@ exports.ZonNonEditableValue = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const colors_1 = require("../../../helpers/colors");
7
- const layout_1 = require("../layout");
8
7
  const SchemaLabel_1 = require("./SchemaLabel");
8
+ const Fieldset_1 = require("./Fieldset");
9
9
  const fullWidth = {
10
10
  width: '100%',
11
11
  };
@@ -19,9 +19,9 @@ const wideEmptyLabel = {
19
19
  ...emptyLabel,
20
20
  lineHeight: '37px',
21
21
  };
22
- const ZonNonEditableValue = ({ jsonPath, label, compact, showSaveButton, saving }) => {
22
+ const ZonNonEditableValue = ({ jsonPath, label, showSaveButton, saving, mayPad }) => {
23
23
  const save = (0, react_1.useCallback)(() => undefined, []);
24
24
  const reset = (0, react_1.useCallback)(() => undefined, []);
25
- return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: true, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: null, saving: saving, valid: true, saveDisabledByParent: true }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)("em", { style: compact ? emptyLabel : wideEmptyLabel, children: label }) })] }));
25
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: true, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: true, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: null, saving: saving, valid: true, saveDisabledByParent: true, suffix: null }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)("em", { style: wideEmptyLabel, children: label }) })] }));
26
26
  };
27
27
  exports.ZonNonEditableValue = ZonNonEditableValue;
@@ -5,7 +5,6 @@ import type { UpdaterFunction } from './ZodSwitch';
5
5
  export declare const ZodNullableEditor: React.FC<{
6
6
  showSaveButton: boolean;
7
7
  jsonPath: JSONPath;
8
- compact: boolean;
9
8
  value: unknown;
10
9
  defaultValue: unknown;
11
10
  schema: z.ZodTypeAny;
@@ -14,4 +13,5 @@ export declare const ZodNullableEditor: React.FC<{
14
13
  onRemove: null | (() => void);
15
14
  saving: boolean;
16
15
  saveDisabledByParent: boolean;
16
+ mayPad: boolean;
17
17
  }>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZodNullableEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
6
- const ZodNullableEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
6
+ const ZodNullableEditor = ({ jsonPath, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
7
7
  const { innerType } = schema._def;
8
- return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: null, saving: saving, saveDisabledByParent: saveDisabledByParent }));
8
+ return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: schema, innerSchema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: null, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }));
9
9
  };
10
10
  exports.ZodNullableEditor = ZodNullableEditor;
@@ -7,11 +7,11 @@ export declare const ZodNumberEditor: React.FC<{
7
7
  jsonPath: JSONPath;
8
8
  value: number;
9
9
  setValue: UpdaterFunction<number>;
10
- compact: boolean;
11
10
  defaultValue: number;
12
11
  onSave: UpdaterFunction<number>;
13
12
  onRemove: null | (() => void);
14
13
  showSaveButton: boolean;
15
14
  saving: boolean;
16
15
  saveDisabledByParent: boolean;
16
+ mayPad: boolean;
17
17
  }>;
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZodNumberEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const layout_1 = require("../../layout");
7
6
  const InputDragger_1 = require("../../NewComposition/InputDragger");
8
- const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
9
- const layout_2 = require("../layout");
10
7
  const local_state_1 = require("./local-state");
11
8
  const SchemaLabel_1 = require("./SchemaLabel");
9
+ const Fieldset_1 = require("./Fieldset");
10
+ const ZodFieldValidation_1 = require("./ZodFieldValidation");
12
11
  const fullWidth = {
13
12
  width: '100%',
14
13
  };
@@ -48,25 +47,23 @@ const getStep = (schema) => {
48
47
  }
49
48
  return multipleStep.value;
50
49
  };
51
- const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, }) => {
52
- const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
50
+ const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, mayPad, }) => {
51
+ const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
53
52
  value,
54
53
  schema,
55
54
  setValue,
55
+ defaultValue,
56
56
  });
57
57
  const onNumberChange = (0, react_1.useCallback)((newValue) => {
58
- setLocalValue(() => newValue, false);
58
+ setLocalValue(() => newValue, false, false);
59
59
  }, [setLocalValue]);
60
- const isDefault = value === defaultValue;
61
- const reset = (0, react_1.useCallback)(() => {
62
- setLocalValue(() => defaultValue, true);
63
- }, [defaultValue, setLocalValue]);
60
+ const isDefault = localValue.value === defaultValue;
64
61
  const onTextChange = (0, react_1.useCallback)((newValue) => {
65
- setLocalValue(() => Number(newValue), false);
62
+ setLocalValue(() => Number(newValue), false, false);
66
63
  }, [setLocalValue]);
67
64
  const save = (0, react_1.useCallback)(() => {
68
- onSave(() => value, false);
65
+ onSave(() => value, false, false);
69
66
  }, [onSave, value]);
70
- return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onTextChange, onValueChange: onNumberChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema), rightAlign: false }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
67
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onTextChange, onValueChange: onNumberChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema), rightAlign: false }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] })] }));
71
68
  };
72
69
  exports.ZodNumberEditor = ZodNumberEditor;
@@ -8,10 +8,10 @@ export declare const ZodObjectEditor: React.FC<{
8
8
  value: Record<string, unknown>;
9
9
  defaultValue: Record<string, unknown>;
10
10
  setValue: UpdaterFunction<Record<string, unknown>>;
11
- compact: boolean;
12
11
  onSave: UpdaterFunction<Record<string, unknown>>;
13
12
  showSaveButton: boolean;
14
13
  onRemove: null | (() => void);
15
14
  saving: boolean;
16
15
  saveDisabledByParent: boolean;
16
+ mayPad: boolean;
17
17
  }>;
@@ -1,33 +1,31 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ZodObjectEditor = void 0;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
5
8
  const react_1 = require("react");
6
- const colors_1 = require("../../../helpers/colors");
9
+ const react_2 = __importDefault(require("react"));
7
10
  const get_zod_if_possible_1 = require("../../get-zod-if-possible");
8
- const layout_1 = require("../layout");
9
11
  const local_state_1 = require("./local-state");
10
- const SchemaLabel_1 = require("./SchemaLabel");
11
12
  const ZodSwitch_1 = require("./ZodSwitch");
12
- const container = {
13
- width: '100%',
14
- };
15
- const fullWidth = {
16
- width: '100%',
17
- };
18
- const fieldset = {
19
- borderRadius: 4,
20
- borderColor: colors_1.INPUT_BORDER_COLOR_UNHOVERED,
21
- };
22
- const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
13
+ const Fieldset_1 = require("./Fieldset");
14
+ const SchemaSeparationLine_1 = require("./SchemaSeparationLine");
15
+ const layout_1 = require("../layout");
16
+ const SchemaVerticalGuide_1 = require("./SchemaVerticalGuide");
17
+ const SchemaLabel_1 = require("./SchemaLabel");
18
+ const deep_equal_1 = require("./deep-equal");
19
+ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
23
20
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
24
21
  if (!z) {
25
22
  throw new Error('expected zod');
26
23
  }
27
- const { localValue, onChange } = (0, local_state_1.useLocalState)({
24
+ const { localValue, onChange, RevisionContextProvider, reset } = (0, local_state_1.useLocalState)({
28
25
  schema,
29
26
  setValue,
30
27
  value,
28
+ defaultValue,
31
29
  });
32
30
  const def = schema._def;
33
31
  const typeName = def.typeName;
@@ -37,35 +35,31 @@ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultVa
37
35
  const shape = def.shape();
38
36
  const keys = Object.keys(shape);
39
37
  const isRoot = jsonPath.length === 0;
40
- const Element = isRoot ? 'div' : 'fieldset';
41
- const { paddingTop } = layout_1.optionRow;
42
- const style = (0, react_1.useMemo)(() => {
43
- if (isRoot) {
44
- return {};
45
- }
46
- return { paddingTop };
47
- }, [isRoot, paddingTop]);
48
- const onRes = (0, react_1.useCallback)(() => {
49
- onChange(() => defaultValue, true);
50
- }, [defaultValue, onChange]);
51
- return ((0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsxs)(Element, { style: fieldset, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaFieldsetLabel, { isDefaultValue: true, onReset: onRes, jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: keys.map((key) => {
52
- return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: [...jsonPath, key], schema: shape[key], value: localValue.value[key],
53
- // In case of null | {a: string, b: string} type, we need to fallback to the default value
54
- defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : value)[key], setValue: (val, forceApply) => {
55
- onChange((oldVal) => {
56
- return {
57
- ...oldVal,
58
- [key]: typeof val === 'function' ? val(oldVal[key]) : val,
59
- };
60
- }, forceApply);
61
- }, onSave: (val, forceApply) => {
62
- onSave((oldVal) => {
63
- return {
64
- ...oldVal,
65
- [key]: typeof val === 'function' ? val(oldVal[key]) : val,
66
- };
67
- }, forceApply);
68
- }, onRemove: null, compact: compact, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent }, key));
69
- }) })] }) }) }));
38
+ const isDefaultValue = (0, react_1.useMemo)(() => {
39
+ return (0, deep_equal_1.deepEqual)(localValue.value, defaultValue);
40
+ }, [defaultValue, localValue]);
41
+ return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: !isRoot && mayPad, success: localValue.zodValidation.success, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefaultValue, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, suffix: ' {', onSave: () => {
42
+ onSave(() => {
43
+ return localValue.value;
44
+ }, false, false);
45
+ }, saveDisabledByParent: saveDisabledByParent, saving: saving, showSaveButton: showSaveButton, valid: localValue.zodValidation.success })), (0, jsx_runtime_1.jsx)(RevisionContextProvider, { children: (0, jsx_runtime_1.jsx)(SchemaVerticalGuide_1.SchemaVerticalGuide, { isRoot: isRoot, children: keys.map((key, i) => {
46
+ return ((0, jsx_runtime_1.jsxs)(react_2.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { mayPad: true, jsonPath: [...jsonPath, key], schema: shape[key], value: localValue.value[key],
47
+ // In case of null | {a: string, b: string} type, we need to fallback to the default value
48
+ defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : value)[key], setValue: (val, forceApply) => {
49
+ onChange((oldVal) => {
50
+ return {
51
+ ...oldVal,
52
+ [key]: typeof val === 'function' ? val(oldVal[key]) : val,
53
+ };
54
+ }, forceApply, false);
55
+ }, onSave: (val, forceApply) => {
56
+ onSave((oldVal) => {
57
+ return {
58
+ ...oldVal,
59
+ [key]: typeof val === 'function' ? val(oldVal[key]) : val,
60
+ };
61
+ }, forceApply, false);
62
+ }, onRemove: null, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent }), i === keys.length - 1 ? null : (0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaSeparationLine, {})] }, key));
63
+ }) }) }), isRoot ? null : (0, jsx_runtime_1.jsx)("div", { style: layout_1.fieldsetLabel, children: '}' })] }));
70
64
  };
71
65
  exports.ZodObjectEditor = ZodObjectEditor;
@@ -5,7 +5,6 @@ import type { UpdaterFunction } from './ZodSwitch';
5
5
  export declare const ZodOptionalEditor: React.FC<{
6
6
  showSaveButton: boolean;
7
7
  jsonPath: JSONPath;
8
- compact: boolean;
9
8
  value: unknown;
10
9
  defaultValue: unknown;
11
10
  schema: z.ZodTypeAny;
@@ -14,4 +13,5 @@ export declare const ZodOptionalEditor: React.FC<{
14
13
  onRemove: null | (() => void);
15
14
  saving: boolean;
16
15
  saveDisabledByParent: boolean;
16
+ mayPad: boolean;
17
17
  }>;