@remotion/cli 4.0.0-alpha7 → 4.0.0-alpha9

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 (106) hide show
  1. package/dist/codemods/update-default-props.d.ts +1 -1
  2. package/dist/codemods/update-default-props.js +0 -1
  3. package/dist/editor/components/CheckboardToggle.js +2 -1
  4. package/dist/editor/components/InlineAction.d.ts +1 -1
  5. package/dist/editor/components/InlineAction.js +6 -3
  6. package/dist/editor/components/LoopToggle.js +2 -1
  7. package/dist/editor/components/Menu/MenuItem.js +1 -1
  8. package/dist/editor/components/Menu/SubMenu.js +1 -1
  9. package/dist/editor/components/MenuBuildIndicator.js +20 -1
  10. package/dist/editor/components/Modals.js +1 -1
  11. package/dist/editor/components/NewComposition/ComboBox.js +19 -4
  12. package/dist/editor/components/NewComposition/InputDragger.js +3 -2
  13. package/dist/editor/components/NewComposition/MenuContent.d.ts +1 -0
  14. package/dist/editor/components/NewComposition/MenuContent.js +11 -3
  15. package/dist/editor/components/OpenEditorButton.d.ts +2 -0
  16. package/dist/editor/components/OpenEditorButton.js +52 -0
  17. package/dist/editor/components/RenderButton.js +5 -1
  18. package/dist/editor/components/RenderModal/CliCopyButton.js +7 -6
  19. package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +3 -2
  20. package/dist/editor/components/RenderModal/MutedSetting.js +3 -2
  21. package/dist/editor/components/RenderModal/OptionExplainer.js +1 -0
  22. package/dist/editor/components/RenderModal/RenderModal.d.ts +3 -1
  23. package/dist/editor/components/RenderModal/RenderModal.js +9 -7
  24. package/dist/editor/components/RenderModal/RenderModalAdvanced.js +0 -2
  25. package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
  26. package/dist/editor/components/RenderModal/RenderModalBasic.js +3 -2
  27. package/dist/editor/components/RenderModal/RenderModalData.d.ts +3 -3
  28. package/dist/editor/components/RenderModal/RenderModalData.js +50 -25
  29. package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
  30. package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +5 -4
  31. package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -4
  32. package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +3 -0
  33. package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +6 -2
  34. package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +4 -0
  35. package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +5 -4
  36. package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +1 -1
  37. package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +4 -4
  38. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -0
  39. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +38 -26
  40. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +4 -2
  41. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +4 -4
  42. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -1
  43. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +7 -7
  44. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -1
  45. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +17 -60
  46. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -1
  47. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +10 -18
  48. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +3 -2
  49. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +6 -19
  50. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -26
  51. package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +1 -1
  52. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +4 -2
  53. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
  54. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -1
  55. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +15 -34
  56. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +6 -4
  57. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +17 -10
  58. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +4 -2
  59. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
  60. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +4 -2
  61. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +6 -6
  62. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -0
  63. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +11 -25
  64. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -1
  65. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +12 -23
  66. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +3 -2
  67. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +12 -12
  68. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +4 -2
  69. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +2 -2
  70. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +2 -0
  71. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +11 -1
  72. package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +16 -0
  73. package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +44 -0
  74. package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +4 -1
  75. package/dist/editor/components/RenderModal/get-render-modal-warnings.js +21 -2
  76. package/dist/editor/components/RenderModal/out-name-checker.js +1 -11
  77. package/dist/editor/components/RenderQueue/actions.d.ts +3 -3
  78. package/dist/editor/components/RightPanel.js +3 -3
  79. package/dist/editor/components/SidebarRenderButton.js +2 -0
  80. package/dist/editor/components/Spinner.d.ts +4 -0
  81. package/dist/editor/components/Spinner.js +42 -0
  82. package/dist/editor/components/Tabs/index.js +12 -14
  83. package/dist/editor/components/Timeline/TimelineSequence.js +2 -2
  84. package/dist/editor/components/TimelineInOutToggle.js +2 -1
  85. package/dist/editor/components/UpdateCheck.js +2 -1
  86. package/dist/editor/helpers/colors.d.ts +2 -0
  87. package/dist/editor/helpers/colors.js +3 -1
  88. package/dist/editor/icons/media-volume.js +2 -1
  89. package/dist/editor/state/modals.d.ts +3 -1
  90. package/dist/get-cli-options.d.ts +1 -1
  91. package/dist/get-input-props.d.ts +1 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/list-of-remotion-packages.js +1 -0
  94. package/dist/preview-server/api-types.d.ts +2 -2
  95. package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +2 -1
  96. package/dist/preview-server/render-queue/job.d.ts +9 -2
  97. package/dist/preview-server/render-queue/make-retry-payload.js +5 -1
  98. package/dist/preview-server/render-queue/queue.js +0 -1
  99. package/dist/preview-server/routes/update-default-props.d.ts +2 -2
  100. package/dist/preview-server/routes/update-default-props.js +23 -13
  101. package/dist/preview-server/routes.d.ts +2 -1
  102. package/dist/preview-server/start-server.js +1 -1
  103. package/dist/render-flows/render.d.ts +1 -1
  104. package/dist/render-flows/still.d.ts +1 -1
  105. package/package.json +13 -11
  106. package/styles/styles.css +4 -5
@@ -11,11 +11,12 @@ const RemInput_1 = require("../../NewComposition/RemInput");
11
11
  const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
12
12
  const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
13
13
  const layout_2 = require("../layout");
14
+ const local_state_1 = require("./local-state");
14
15
  const SchemaLabel_1 = require("./SchemaLabel");
15
16
  const fullWidth = {
16
17
  width: '100%',
17
18
  };
18
- const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
19
+ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
19
20
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
20
21
  if (!z) {
21
22
  throw new Error('expected zod');
@@ -24,55 +25,27 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
24
25
  if (!zodTypes) {
25
26
  throw new Error('expected zod color');
26
27
  }
27
- const [localValue, setLocalValue] = (0, react_1.useState)(() => {
28
- return {
29
- value,
30
- zodValidation: schema.safeParse(value),
31
- };
28
+ const { localValue, onChange: onValueChange } = (0, local_state_1.useLocalState)({
29
+ schema,
30
+ setValue,
31
+ value,
32
32
  });
33
- const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
34
- const safeParse = schema.safeParse(newValue);
35
- const newLocalState = {
36
- value: newValue,
37
- zodValidation: safeParse,
38
- };
39
- setLocalValue(newLocalState);
40
- if (safeParse.success || forceApply) {
41
- setValue(() => newValue);
42
- }
43
- }, [schema, setValue]);
44
33
  const { a, b, g, r } = localValue.zodValidation.success
45
34
  ? zodTypes.ZodZypesInternals.parseColor(localValue.value)
46
35
  : { a: 1, b: 0, g: 0, r: 0 };
47
36
  const onChange = (0, react_1.useCallback)((e) => {
48
37
  const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
49
- const safeParse = schema.safeParse(newColor);
50
- const newLocalState = {
51
- value: newColor,
52
- zodValidation: safeParse,
53
- };
54
- setLocalValue(newLocalState);
55
- if (safeParse.success) {
56
- setValue(() => newColor);
57
- }
58
- }, [a, schema, setValue, zodTypes]);
38
+ onValueChange(() => newColor, false);
39
+ }, [a, onValueChange, zodTypes]);
59
40
  const onTextChange = (0, react_1.useCallback)((e) => {
60
41
  const newValue = e.target.value;
61
- const safeParse = schema.safeParse(newValue);
62
- const newLocalState = {
63
- value: newValue,
64
- zodValidation: safeParse,
65
- };
66
- setLocalValue(newLocalState);
67
- if (safeParse.success) {
68
- setValue(() => newValue);
69
- }
70
- }, [schema, setValue]);
42
+ onValueChange(() => newValue, false);
43
+ }, [onValueChange]);
71
44
  const reset = (0, react_1.useCallback)(() => {
72
- onValueChange(defaultValue, true);
45
+ onValueChange(() => defaultValue, true);
73
46
  }, [defaultValue, onValueChange]);
74
47
  const save = (0, react_1.useCallback)(() => {
75
- onSave(() => value);
48
+ onSave(() => value, false);
76
49
  }, [onSave, value]);
77
50
  const rgb = `#${r.toString(16).padStart(2, '0')}${g
78
51
  .toString(16)
@@ -87,29 +60,13 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
87
60
  }, []);
88
61
  const onOpacityChange = (0, react_1.useCallback)((newValue) => {
89
62
  const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
90
- const safeParse = schema.safeParse(newColor);
91
- const newLocalState = {
92
- value: newColor,
93
- zodValidation: safeParse,
94
- };
95
- setLocalValue(newLocalState);
96
- if (safeParse.success) {
97
- setValue(() => newColor);
98
- }
99
- }, [localValue.value, schema, setValue, zodTypes]);
63
+ onValueChange(() => newColor, false);
64
+ }, [localValue.value, onValueChange, zodTypes]);
100
65
  const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
101
66
  const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
102
- const safeParse = schema.safeParse(newColor);
103
- const newLocalState = {
104
- value: String(newColor),
105
- zodValidation: safeParse,
106
- };
107
- setLocalValue(newLocalState);
108
- if (safeParse.success) {
109
- setValue(() => newColor);
110
- }
111
- }, [localValue.value, schema, setValue, zodTypes]);
112
- 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 }), (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
+ onValueChange(() => newColor, false);
68
+ }, [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: {
113
70
  height: 39,
114
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" })] }))] })] }));
115
72
  };
@@ -8,9 +8,10 @@ export declare const ZodDateEditor: React.FC<{
8
8
  value: Date;
9
9
  defaultValue: Date;
10
10
  setValue: UpdaterFunction<Date>;
11
- onSave: (updater: (oldNum: unknown) => Date) => void;
11
+ onSave: UpdaterFunction<Date>;
12
12
  onRemove: null | (() => void);
13
13
  compact: boolean;
14
14
  showSaveButton: boolean;
15
15
  saving: boolean;
16
+ saveDisabledByParent: boolean;
16
17
  }>;
@@ -8,6 +8,7 @@ const layout_1 = require("../../layout");
8
8
  const RemInput_1 = require("../../NewComposition/RemInput");
9
9
  const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
10
10
  const layout_2 = require("../layout");
11
+ const local_state_1 = require("./local-state");
11
12
  const SchemaLabel_1 = require("./SchemaLabel");
12
13
  const fullWidth = {
13
14
  width: '100%',
@@ -43,24 +44,15 @@ const formatDate = (date) => {
43
44
  .padStart(3, '0')}`;
44
45
  return formattedDate;
45
46
  };
46
- const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
47
- const [localValue, setLocalValue] = (0, react_1.useState)(() => {
48
- return {
49
- value,
50
- zodValidation: schema.safeParse(value),
51
- };
47
+ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
48
+ const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
49
+ schema,
50
+ setValue,
51
+ value,
52
52
  });
53
53
  const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
54
- const safeParse = schema.safeParse(newValue);
55
- const newLocalState = {
56
- value: newValue,
57
- zodValidation: safeParse,
58
- };
59
- setLocalValue(newLocalState);
60
- if (safeParse.success || forceApply) {
61
- setValue(() => newValue);
62
- }
63
- }, [schema, setValue]);
54
+ setLocalValue(() => newValue, forceApply);
55
+ }, [setLocalValue]);
64
56
  const onChange = (0, react_1.useCallback)((e) => {
65
57
  // React does not support e.target.valueAsDate :(
66
58
  onValueChange(new Date(e.target.value), false);
@@ -69,8 +61,8 @@ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue
69
61
  onValueChange(defaultValue, true);
70
62
  }, [defaultValue, onValueChange]);
71
63
  const save = (0, react_1.useCallback)(() => {
72
- onSave(() => value);
64
+ onSave(() => value, false);
73
65
  }, [onSave, value]);
74
- 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 }), (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" })] }))] })] }));
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" })] }))] })] }));
75
67
  };
76
68
  exports.ZodDateEditor = ZodDateEditor;
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import type { z } from 'zod';
3
3
  import type { JSONPath } from './zod-types';
4
+ import type { UpdaterFunction } from './ZodSwitch';
4
5
  export declare const ZodEffectEditor: React.FC<{
5
6
  schema: z.ZodTypeAny;
6
7
  jsonPath: JSONPath;
7
8
  value: unknown;
8
- setValue: (updater: (oldState: unknown) => unknown) => void;
9
+ setValue: UpdaterFunction<unknown>;
9
10
  compact: boolean;
10
11
  defaultValue: unknown;
11
- onSave: (updater: (oldState: unknown) => unknown) => void;
12
+ onSave: UpdaterFunction<unknown>;
12
13
  showSaveButton: boolean;
13
14
  onRemove: null | (() => void);
14
15
  saving: boolean;
@@ -6,6 +6,7 @@ const react_1 = require("react");
6
6
  const colors_1 = require("../../../helpers/colors");
7
7
  const get_zod_if_possible_1 = require("../../get-zod-if-possible");
8
8
  const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
9
+ const local_state_1 = require("./local-state");
9
10
  const ZodSwitch_1 = require("./ZodSwitch");
10
11
  const fullWidth = {
11
12
  width: '100%',
@@ -15,30 +16,16 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
15
16
  if (!z) {
16
17
  throw new Error('expected zod');
17
18
  }
18
- const [localValue, setLocalValue] = (0, react_1.useState)(() => {
19
- return {
20
- value,
21
- zodValidation: schema.safeParse(value),
22
- };
19
+ const { localValue, onChange } = (0, local_state_1.useLocalState)({
20
+ value,
21
+ schema,
22
+ setValue: updateValue,
23
23
  });
24
24
  const def = schema._def;
25
25
  const typeName = def.typeName;
26
26
  if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
27
27
  throw new Error('expected effect');
28
28
  }
29
- const onChange = (0, react_1.useCallback)((updater) => {
30
- setLocalValue((oldLocalState) => {
31
- const newValue = updater(oldLocalState.value);
32
- const safeParse = schema.safeParse(newValue);
33
- if (safeParse.success) {
34
- updateValue(() => newValue);
35
- }
36
- return {
37
- value: newValue,
38
- zodValidation: safeParse,
39
- };
40
- });
41
- }, [schema, updateValue]);
42
29
  const container = (0, react_1.useMemo)(() => {
43
30
  if (!localValue.zodValidation.success) {
44
31
  return {
@@ -51,6 +38,6 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
51
38
  padding: 0,
52
39
  };
53
40
  }, [localValue.zodValidation.success]);
54
- 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 }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }) }))] }));
41
+ 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.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }) }))] }));
55
42
  };
56
43
  exports.ZodEffectEditor = ZodEffectEditor;
@@ -9,21 +9,20 @@ const layout_1 = require("../../layout");
9
9
  const ComboBox_1 = require("../../NewComposition/ComboBox");
10
10
  const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
11
11
  const layout_2 = require("../layout");
12
+ const local_state_1 = require("./local-state");
12
13
  const SchemaLabel_1 = require("./SchemaLabel");
13
14
  const container = {
14
15
  width: '100%',
15
16
  };
16
- const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
17
+ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
17
18
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
18
19
  if (!z) {
19
20
  throw new Error('expected zod');
20
21
  }
21
- const [localValue, setLocalValue] = (0, react_1.useState)(() => {
22
- return {
23
- value,
24
- zodValidation: schema.safeParse(value),
25
- revision: 0,
26
- };
22
+ const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
23
+ schema,
24
+ setValue,
25
+ value,
27
26
  });
28
27
  const def = schema._def;
29
28
  const typeName = def.typeName;
@@ -31,22 +30,9 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
31
30
  throw new Error('expected enum');
32
31
  }
33
32
  const isRoot = jsonPath.length === 0;
34
- const onChange = (0, react_1.useCallback)((updater, forceApply) => {
35
- setLocalValue((oldLocalState) => {
36
- const newValue = updater(oldLocalState.value);
37
- const safeParse = schema.safeParse(newValue);
38
- if (safeParse.success || forceApply) {
39
- updateValue(updater);
40
- }
41
- return {
42
- value: newValue,
43
- zodValidation: safeParse,
44
- };
45
- });
46
- }, [schema, updateValue]);
47
33
  const reset = (0, react_1.useCallback)(() => {
48
- onChange(() => defaultValue, true);
49
- }, [defaultValue, onChange]);
34
+ setLocalValue(() => defaultValue, true);
35
+ }, [defaultValue, setLocalValue]);
50
36
  const comboBoxValues = (0, react_1.useMemo)(() => {
51
37
  return def.values.map((option) => {
52
38
  return {
@@ -56,17 +42,17 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
56
42
  keyHint: null,
57
43
  leftItem: option === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
58
44
  onClick: (id) => {
59
- onChange(() => id, false);
45
+ setLocalValue(() => id, false);
60
46
  },
61
47
  quickSwitcherLabel: null,
62
48
  subMenu: null,
63
49
  type: 'item',
64
50
  };
65
51
  });
66
- }, [def.values, onChange, value]);
52
+ }, [def.values, setLocalValue, value]);
67
53
  const save = (0, react_1.useCallback)(() => {
68
- onSave(() => value);
54
+ onSave(() => value, false);
69
55
  }, [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, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving }), (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" })] }))] }));
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" })] }))] }));
71
57
  };
72
58
  exports.ZodEnumEditor = ZodEnumEditor;
@@ -22,6 +22,6 @@ const wideEmptyLabel = {
22
22
  const ZonNonEditableValue = ({ jsonPath, label, compact, showSaveButton, saving }) => {
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 }), (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)("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 }) })] }));
26
26
  };
27
27
  exports.ZonNonEditableValue = ZonNonEditableValue;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { z } from 'zod';
3
3
  import type { JSONPath } from './zod-types';
4
+ import type { UpdaterFunction } from './ZodSwitch';
4
5
  export declare const ZodNullableEditor: React.FC<{
5
6
  showSaveButton: boolean;
6
7
  jsonPath: JSONPath;
@@ -8,8 +9,9 @@ export declare const ZodNullableEditor: React.FC<{
8
9
  value: unknown;
9
10
  defaultValue: unknown;
10
11
  schema: z.ZodTypeAny;
11
- setValue: (updater: (oldNum: unknown) => unknown) => void;
12
- onSave: (updater: (oldNum: unknown) => unknown) => void;
12
+ setValue: UpdaterFunction<unknown>;
13
+ onSave: UpdaterFunction<unknown>;
13
14
  onRemove: null | (() => void);
14
15
  saving: boolean;
16
+ saveDisabledByParent: boolean;
15
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, }) => {
6
+ const ZodNullableEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
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 }));
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 }));
9
9
  };
10
10
  exports.ZodNullableEditor = ZodNullableEditor;
@@ -9,8 +9,9 @@ export declare const ZodNumberEditor: React.FC<{
9
9
  setValue: UpdaterFunction<number>;
10
10
  compact: boolean;
11
11
  defaultValue: number;
12
- onSave: (updater: (oldNum: unknown) => number) => void;
12
+ onSave: UpdaterFunction<number>;
13
13
  onRemove: null | (() => void);
14
14
  showSaveButton: boolean;
15
15
  saving: boolean;
16
+ saveDisabledByParent: boolean;
16
17
  }>;
@@ -7,6 +7,7 @@ const layout_1 = require("../../layout");
7
7
  const InputDragger_1 = require("../../NewComposition/InputDragger");
8
8
  const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
9
9
  const layout_2 = require("../layout");
10
+ const local_state_1 = require("./local-state");
10
11
  const SchemaLabel_1 = require("./SchemaLabel");
11
12
  const fullWidth = {
12
13
  width: '100%',
@@ -47,45 +48,25 @@ const getStep = (schema) => {
47
48
  }
48
49
  return multipleStep.value;
49
50
  };
50
- const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, }) => {
51
- const [localValue, setLocalValue] = (0, react_1.useState)(() => {
52
- return {
53
- value: String(value),
54
- zodValidation: schema.safeParse(value),
55
- };
51
+ const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, }) => {
52
+ const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
53
+ value,
54
+ schema,
55
+ setValue,
56
56
  });
57
- const onChange = (0, react_1.useCallback)((newValue) => {
58
- const safeParse = schema.safeParse(Number(newValue));
59
- const newLocalState = {
60
- value: newValue,
61
- zodValidation: safeParse,
62
- };
63
- setLocalValue(newLocalState);
64
- if (safeParse.success) {
65
- setValue(() => Number(newValue));
66
- }
67
- }, [schema, setValue]);
68
- const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
69
- const safeParse = schema.safeParse(newValue);
70
- const newLocalState = {
71
- value: String(newValue),
72
- zodValidation: safeParse,
73
- };
74
- setLocalValue(newLocalState);
75
- if (safeParse.success || forceApply) {
76
- setValue(() => newValue);
77
- }
78
- }, [schema, setValue]);
79
57
  const onNumberChange = (0, react_1.useCallback)((newValue) => {
80
- onValueChange(newValue, false);
81
- }, [onValueChange]);
58
+ setLocalValue(() => newValue, false);
59
+ }, [setLocalValue]);
82
60
  const isDefault = value === defaultValue;
83
61
  const reset = (0, react_1.useCallback)(() => {
84
- onValueChange(defaultValue, true);
85
- }, [defaultValue, onValueChange]);
62
+ setLocalValue(() => defaultValue, true);
63
+ }, [defaultValue, setLocalValue]);
64
+ const onTextChange = (0, react_1.useCallback)((newValue) => {
65
+ setLocalValue(() => Number(newValue), false);
66
+ }, [setLocalValue]);
86
67
  const save = (0, react_1.useCallback)(() => {
87
- onSave(() => value);
68
+ onSave(() => value, false);
88
69
  }, [onSave, value]);
89
- 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 }), (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: onChange, 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" })] }))] })] }));
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" })] }))] })] }));
90
71
  };
91
72
  exports.ZodNumberEditor = ZodNumberEditor;
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import type { z } from 'zod';
3
3
  import type { JSONPath } from './zod-types';
4
+ import type { UpdaterFunction } from './ZodSwitch';
4
5
  export declare const ZodObjectEditor: React.FC<{
5
6
  schema: z.ZodTypeAny;
6
7
  jsonPath: JSONPath;
7
- value: unknown;
8
- defaultValue: unknown;
9
- setValue: (updater: (oldState: Record<string, unknown>) => Record<string, unknown>) => void;
8
+ value: Record<string, unknown>;
9
+ defaultValue: Record<string, unknown>;
10
+ setValue: UpdaterFunction<Record<string, unknown>>;
10
11
  compact: boolean;
11
- onSave: (updater: (oldVal: Record<string, unknown>) => Record<string, unknown>) => void;
12
+ onSave: UpdaterFunction<Record<string, unknown>>;
12
13
  showSaveButton: boolean;
13
14
  onRemove: null | (() => void);
14
15
  saving: boolean;
16
+ saveDisabledByParent: boolean;
15
17
  }>;
@@ -6,6 +6,7 @@ const react_1 = require("react");
6
6
  const colors_1 = require("../../../helpers/colors");
7
7
  const get_zod_if_possible_1 = require("../../get-zod-if-possible");
8
8
  const layout_1 = require("../layout");
9
+ const local_state_1 = require("./local-state");
9
10
  const SchemaLabel_1 = require("./SchemaLabel");
10
11
  const ZodSwitch_1 = require("./ZodSwitch");
11
12
  const container = {
@@ -18,12 +19,16 @@ const fieldset = {
18
19
  borderRadius: 4,
19
20
  borderColor: colors_1.INPUT_BORDER_COLOR_UNHOVERED,
20
21
  };
21
- // TODO: First validate locally
22
- const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultValue, onSave, showSaveButton, onRemove, saving, }) => {
22
+ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
23
23
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
24
24
  if (!z) {
25
25
  throw new Error('expected zod');
26
26
  }
27
+ const { localValue, onChange } = (0, local_state_1.useLocalState)({
28
+ schema,
29
+ setValue,
30
+ value,
31
+ });
27
32
  const def = schema._def;
28
33
  const typeName = def.typeName;
29
34
  if (typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
@@ -40,25 +45,27 @@ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultVa
40
45
  }
41
46
  return { paddingTop };
42
47
  }, [isRoot, paddingTop]);
43
- 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, { jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: keys.map((key) => {
44
- var _a;
45
- return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: [...jsonPath, key], schema: shape[key], value: value[key],
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],
46
53
  // In case of null | {a: string, b: string} type, we need to fallback to the default value
47
- defaultValue: ((_a = defaultValue) !== null && _a !== void 0 ? _a : value)[key], setValue: (val) => {
54
+ defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : value)[key], setValue: (val, forceApply) => {
48
55
  setValue((oldVal) => {
49
56
  return {
50
57
  ...oldVal,
51
58
  [key]: typeof val === 'function' ? val(oldVal[key]) : val,
52
59
  };
53
- });
54
- }, onSave: (val) => {
60
+ }, forceApply);
61
+ }, onSave: (val, forceApply) => {
55
62
  onSave((oldVal) => {
56
63
  return {
57
64
  ...oldVal,
58
65
  [key]: typeof val === 'function' ? val(oldVal[key]) : val,
59
66
  };
60
- });
61
- }, onRemove: null, compact: compact, showSaveButton: showSaveButton, saving: saving }, key));
67
+ }, forceApply);
68
+ }, onRemove: null, compact: compact, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent }, key));
62
69
  }) })] }) }) }));
63
70
  };
64
71
  exports.ZodObjectEditor = ZodObjectEditor;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { z } from 'zod';
3
3
  import type { JSONPath } from './zod-types';
4
+ import type { UpdaterFunction } from './ZodSwitch';
4
5
  export declare const ZodOptionalEditor: React.FC<{
5
6
  showSaveButton: boolean;
6
7
  jsonPath: JSONPath;
@@ -8,8 +9,9 @@ export declare const ZodOptionalEditor: React.FC<{
8
9
  value: unknown;
9
10
  defaultValue: unknown;
10
11
  schema: z.ZodTypeAny;
11
- setValue: (updater: (oldNum: unknown) => unknown) => void;
12
- onSave: (updater: (oldNum: unknown) => unknown) => void;
12
+ setValue: UpdaterFunction<unknown>;
13
+ onSave: UpdaterFunction<unknown>;
13
14
  onRemove: null | (() => void);
14
15
  saving: boolean;
16
+ saveDisabledByParent: boolean;
15
17
  }>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZodOptionalEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
6
- const ZodOptionalEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, }) => {
6
+ const ZodOptionalEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
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: undefined, saving: saving }));
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: undefined, saving: saving, saveDisabledByParent: saveDisabledByParent }));
9
9
  };
10
10
  exports.ZodOptionalEditor = ZodOptionalEditor;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { z } from 'zod';
3
3
  import type { JSONPath } from './zod-types';
4
+ import type { UpdaterFunction } from './ZodSwitch';
4
5
  export declare const ZodOrNullishEditor: React.FC<{
5
6
  showSaveButton: boolean;
6
7
  jsonPath: JSONPath;
@@ -8,9 +9,10 @@ export declare const ZodOrNullishEditor: React.FC<{
8
9
  value: unknown;
9
10
  defaultValue: unknown;
10
11
  schema: z.ZodTypeAny;
11
- setValue: (updater: (oldState: unknown) => unknown) => void;
12
- onSave: (updater: (oldNum: unknown) => unknown) => void;
12
+ setValue: UpdaterFunction<unknown>;
13
+ onSave: UpdaterFunction<unknown>;
13
14
  onRemove: null | (() => void);
14
15
  nullishValue: null | undefined;
15
16
  saving: boolean;
17
+ saveDisabledByParent: boolean;
16
18
  }>;