@remotion/studio 4.0.438 → 4.0.440
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Studio.js +2 -2
- package/dist/api/helpers/calc-new-props.js +5 -8
- package/dist/api/update-default-props.d.ts +7 -3
- package/dist/api/update-default-props.js +7 -21
- package/dist/api/visual-control.js +6 -0
- package/dist/components/DefaultPropsEditor.d.ts +8 -0
- package/dist/components/DefaultPropsEditor.js +15 -0
- package/dist/components/Editor.js +0 -14
- package/dist/components/EditorContexts.js +6 -3
- package/dist/components/KeyboardShortcutsExplainer.js +6 -2
- package/dist/components/MenuBuildIndicator.js +1 -0
- package/dist/components/MenuToolbar.js +3 -1
- package/dist/components/NewComposition/InputDragger.js +2 -2
- package/dist/components/NewComposition/RemTextarea.js +4 -0
- package/dist/components/ObserveDefaultPropsContext.d.ts +11 -0
- package/dist/components/ObserveDefaultPropsContext.js +120 -0
- package/dist/components/OptionsPanel.js +90 -28
- package/dist/components/RenderModal/CrfSetting.d.ts +1 -1
- package/dist/components/RenderModal/DataEditor.d.ts +4 -5
- package/dist/components/RenderModal/DataEditor.js +9 -111
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +52 -48
- package/dist/components/RenderModal/SchemaEditor/Fieldset.d.ts +0 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +4 -9
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +2 -61
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +0 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +2 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +0 -6
- package/dist/components/RenderModal/SchemaEditor/SchemaLabel.js +2 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +3 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +1 -1
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +15 -26
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +7 -12
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +0 -7
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +5 -15
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.js +30 -28
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.js +13 -17
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +13 -28
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -5
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +11 -12
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +1 -5
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -16
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.js +1 -2
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.js +20 -30
- package/dist/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +0 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +16 -21
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +2 -7
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +27 -49
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +8 -15
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +10 -15
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.js +13 -17
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +27 -27
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.js +45 -17
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +15 -26
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.js +4 -11
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
- package/dist/components/RenderModal/ServerRenderModal.js +9 -3
- package/dist/components/RenderModal/WebRenderModal.js +9 -3
- package/dist/components/RenderModal/get-default-codecs.d.ts +5 -5
- package/dist/components/RenderModal/get-render-modal-warnings.d.ts +1 -2
- package/dist/components/RenderModal/get-render-modal-warnings.js +4 -6
- package/dist/components/RenderModal/human-readable-codec.d.ts +1 -1
- package/dist/components/RenderModal/human-readable-codec.js +3 -0
- package/dist/components/RenderModal/out-name-checker.d.ts +1 -1
- package/dist/components/RenderQueue/actions.d.ts +2 -3
- package/dist/components/RenderQueue/actions.js +1 -13
- package/dist/components/Timeline/Timeline.js +1 -1
- package/dist/components/Timeline/TimelineExpandedSection.js +7 -1
- package/dist/components/Timeline/TimelineFieldRow.d.ts +1 -0
- package/dist/components/Timeline/TimelineFieldRow.js +25 -3
- package/dist/components/Timeline/TimelineImageInfo.d.ts +5 -0
- package/dist/components/Timeline/TimelineImageInfo.js +61 -0
- package/dist/components/Timeline/TimelineListItem.js +1 -2
- package/dist/components/Timeline/TimelineNumberField.js +4 -6
- package/dist/components/Timeline/TimelineRotationField.js +4 -6
- package/dist/components/Timeline/TimelineSequence.js +9 -4
- package/dist/components/Timeline/TimelineStack/index.js +3 -1
- package/dist/components/Timeline/TimelineTracks.js +1 -1
- package/dist/components/Timeline/TimelineTranslateField.js +28 -13
- package/dist/components/TopPanel.js +10 -5
- package/dist/components/UndoRedoButtons.d.ts +2 -0
- package/dist/components/UndoRedoButtons.js +116 -0
- package/dist/components/VisualControls/VisualControlHandle.js +18 -18
- package/dist/components/VisualControls/VisualControlsUndoSync.d.ts +2 -0
- package/dist/components/VisualControls/VisualControlsUndoSync.js +23 -0
- package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +0 -1
- package/dist/esm/{chunk-ba0scebn.js → chunk-1x2ychmc.js} +4466 -5252
- package/dist/esm/index.mjs +25 -28
- package/dist/esm/internals.mjs +4466 -5252
- package/dist/esm/previewEntry.mjs +4652 -5497
- package/dist/esm/renderEntry.mjs +6 -6
- package/dist/helpers/client-id.js +13 -1
- package/dist/helpers/document-title.d.ts +0 -1
- package/dist/helpers/document-title.js +1 -17
- package/dist/helpers/render-modal-sections.d.ts +1 -1
- package/dist/helpers/timeline-layout.d.ts +1 -1
- package/dist/helpers/timeline-layout.js +1 -1
- package/dist/hot-middleware-client/client.d.ts +1 -6
- package/dist/hot-middleware-client/client.js +22 -73
- package/dist/hot-middleware-client/process-update.d.ts +0 -2
- package/dist/hot-middleware-client/process-update.js +6 -14
- package/dist/icons/redo.d.ts +3 -0
- package/dist/icons/redo.js +8 -0
- package/dist/icons/undo.d.ts +3 -0
- package/dist/icons/undo.js +8 -0
- package/dist/renderEntry.js +7 -6
- package/dist/visual-controls/VisualControls.js +9 -5
- package/dist/visual-controls/get-current-edited-value.js +5 -4
- package/dist/visual-controls/visual-control-store.d.ts +7 -0
- package/dist/visual-controls/visual-control-store.js +22 -0
- package/package.json +9 -9
- package/dist/components/GlobalPropsEditorUpdateButton.d.ts +0 -5
- package/dist/components/GlobalPropsEditorUpdateButton.js +0 -78
- package/dist/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaSaveButton.js +0 -18
- package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +0 -25
- package/dist/components/RenderModal/SchemaEditor/local-state.js +0 -107
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GlobalPropsEditorUpdateButton = void 0;
|
|
37
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const react_1 = __importStar(require("react"));
|
|
39
|
-
const remotion_1 = require("remotion");
|
|
40
|
-
const save_default_props_1 = require("../api/save-default-props");
|
|
41
|
-
const fast_refresh_context_1 = require("../fast-refresh-context");
|
|
42
|
-
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
43
|
-
const SchemaResetButton_1 = require("./RenderModal/SchemaEditor/SchemaResetButton");
|
|
44
|
-
const SchemaSaveButton_1 = require("./RenderModal/SchemaEditor/SchemaSaveButton");
|
|
45
|
-
const container = {
|
|
46
|
-
display: 'inline-block',
|
|
47
|
-
flexDirection: 'row',
|
|
48
|
-
};
|
|
49
|
-
const GlobalPropsEditorUpdateButton = ({ compositionId, currentDefaultProps }) => {
|
|
50
|
-
const { fastRefreshes } = (0, react_1.useContext)(fast_refresh_context_1.FastRefreshContext);
|
|
51
|
-
const [disabled, setDisabled] = react_1.default.useState(false);
|
|
52
|
-
const onClicked = (0, react_1.useCallback)(() => {
|
|
53
|
-
setDisabled(true);
|
|
54
|
-
window.remotion_ignoreFastRefreshUpdate = fastRefreshes + 1;
|
|
55
|
-
(0, save_default_props_1.saveDefaultProps)({
|
|
56
|
-
compositionId,
|
|
57
|
-
defaultProps: () => currentDefaultProps,
|
|
58
|
-
})
|
|
59
|
-
.catch((err) => {
|
|
60
|
-
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${err.stack}`, 2000);
|
|
61
|
-
})
|
|
62
|
-
.finally(() => {
|
|
63
|
-
setDisabled(true);
|
|
64
|
-
});
|
|
65
|
-
}, [compositionId, currentDefaultProps, fastRefreshes]);
|
|
66
|
-
const onReset = (0, react_1.useCallback)(() => {
|
|
67
|
-
window.remotion_ignoreFastRefreshUpdate = null;
|
|
68
|
-
window.dispatchEvent(new CustomEvent(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, {
|
|
69
|
-
detail: {
|
|
70
|
-
resetUnsaved: compositionId,
|
|
71
|
-
},
|
|
72
|
-
}));
|
|
73
|
-
}, [compositionId]);
|
|
74
|
-
return (jsx_runtime_1.jsxs("div", { style: container, children: [
|
|
75
|
-
jsx_runtime_1.jsx(SchemaResetButton_1.SchemaResetButton, { onClick: onReset }), jsx_runtime_1.jsx(SchemaSaveButton_1.SchemaSaveButton, { disabled: disabled, onClick: onClicked })
|
|
76
|
-
] }));
|
|
77
|
-
};
|
|
78
|
-
exports.GlobalPropsEditorUpdateButton = GlobalPropsEditorUpdateButton;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SchemaSaveButton = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const colors_1 = require("../../../helpers/colors");
|
|
7
|
-
const InlineAction_1 = require("../../InlineAction");
|
|
8
|
-
const icon = {
|
|
9
|
-
height: 14,
|
|
10
|
-
color: 'currentColor',
|
|
11
|
-
};
|
|
12
|
-
const SchemaSaveButton = ({ onClick, disabled }) => {
|
|
13
|
-
const renderAction = (0, react_1.useCallback)((color) => {
|
|
14
|
-
return (jsx_runtime_1.jsx("svg", { style: icon, viewBox: "0 0 448 512", children: jsx_runtime_1.jsx("path", { fill: disabled ? colors_1.LIGHT_TEXT : color, d: "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V173.3c0-17-6.7-33.3-18.7-45.3L352 50.7C340 38.7 323.7 32 306.7 32H64zm0 96c0-17.7 14.3-32 32-32H288c17.7 0 32 14.3 32 32v64c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V128zM224 288a64 64 0 1 1 0 128 64 64 0 1 1 0-128z" }) }));
|
|
15
|
-
}, [disabled]);
|
|
16
|
-
return (jsx_runtime_1.jsx(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick, disabled: disabled }));
|
|
17
|
-
};
|
|
18
|
-
exports.SchemaSaveButton = SchemaSaveButton;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { AnyZodSchema, ZodSafeParseResult } from './zod-schema-type';
|
|
3
|
-
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
|
-
export type LocalState<T> = {
|
|
5
|
-
value: T;
|
|
6
|
-
zodValidation: ZodSafeParseResult;
|
|
7
|
-
keyStabilityRevision: number;
|
|
8
|
-
};
|
|
9
|
-
export type RevisionContextType = {
|
|
10
|
-
childResetRevision: number;
|
|
11
|
-
};
|
|
12
|
-
export declare const RevisionContext: React.Context<RevisionContextType>;
|
|
13
|
-
export declare const useLocalState: <T>({ unsavedValue, schema, setValue, savedValue, }: {
|
|
14
|
-
unsavedValue: T;
|
|
15
|
-
schema: AnyZodSchema;
|
|
16
|
-
setValue: UpdaterFunction<T>;
|
|
17
|
-
savedValue: T;
|
|
18
|
-
}) => {
|
|
19
|
-
localValue: LocalState<T>;
|
|
20
|
-
onChange: (updater: (oldV: T) => T, forceApply: boolean, increment: boolean) => void;
|
|
21
|
-
reset: () => void;
|
|
22
|
-
RevisionContextProvider: ({ children }: {
|
|
23
|
-
children: React.ReactNode;
|
|
24
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocalState = exports.RevisionContext = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
|
-
const deep_equal_1 = require("./deep-equal");
|
|
8
|
-
const zod_schema_type_1 = require("./zod-schema-type");
|
|
9
|
-
exports.RevisionContext = (0, react_1.createContext)({
|
|
10
|
-
childResetRevision: 0,
|
|
11
|
-
});
|
|
12
|
-
const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
13
|
-
const parentRevision = (0, react_1.useContext)(exports.RevisionContext).childResetRevision;
|
|
14
|
-
const [resetRevision, setResetRevision] = (0, react_1.useState)(0);
|
|
15
|
-
const [localValueOrNull, setLocalValue] = (0, react_1.useState)(() => {
|
|
16
|
-
return {
|
|
17
|
-
[parentRevision]: {
|
|
18
|
-
value: unsavedValue,
|
|
19
|
-
keyStabilityRevision: 0,
|
|
20
|
-
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, unsavedValue),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
const localUnsavedValue = (0, react_1.useMemo)(() => {
|
|
25
|
-
var _a;
|
|
26
|
-
if (((_a = localValueOrNull[parentRevision]) !== null && _a !== void 0 ? _a : null) === null) {
|
|
27
|
-
return {
|
|
28
|
-
value: unsavedValue,
|
|
29
|
-
keyStabilityRevision: 0,
|
|
30
|
-
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, unsavedValue),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return localValueOrNull[parentRevision];
|
|
34
|
-
}, [localValueOrNull, parentRevision, schema, unsavedValue]);
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
const checkFile = () => {
|
|
37
|
-
setResetRevision((old) => old + 1);
|
|
38
|
-
setLocalValue({});
|
|
39
|
-
};
|
|
40
|
-
window.addEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
41
|
-
return () => {
|
|
42
|
-
window.removeEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
45
|
-
const currentLocalValue = (0, react_1.useMemo)(() => {
|
|
46
|
-
return (localUnsavedValue !== null && localUnsavedValue !== void 0 ? localUnsavedValue : {
|
|
47
|
-
value: savedValue,
|
|
48
|
-
keyStabilityRevision: 0,
|
|
49
|
-
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, savedValue),
|
|
50
|
-
});
|
|
51
|
-
}, [localUnsavedValue, savedValue, schema]);
|
|
52
|
-
const stateRef = (0, react_1.useRef)(currentLocalValue);
|
|
53
|
-
stateRef.current = currentLocalValue;
|
|
54
|
-
const onChange = (0, react_1.useCallback)(
|
|
55
|
-
// Increment is to regenerate `key` attributes in array items,
|
|
56
|
-
// so should increment when changing array items
|
|
57
|
-
(updater, forceApply, increment) => {
|
|
58
|
-
const newValue = updater(stateRef.current.value);
|
|
59
|
-
const isSame = (0, deep_equal_1.deepEqual)(newValue, stateRef.current.value);
|
|
60
|
-
if (isSame) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const safeParse = (0, zod_schema_type_1.zodSafeParse)(schema, newValue);
|
|
64
|
-
if (safeParse.success || forceApply) {
|
|
65
|
-
setValue(updater, forceApply, increment);
|
|
66
|
-
}
|
|
67
|
-
setLocalValue(() => {
|
|
68
|
-
const newState = {
|
|
69
|
-
keyStabilityRevision: currentLocalValue.keyStabilityRevision + (increment ? 1 : 0),
|
|
70
|
-
value: newValue,
|
|
71
|
-
zodValidation: safeParse,
|
|
72
|
-
};
|
|
73
|
-
stateRef.current = newState;
|
|
74
|
-
return {
|
|
75
|
-
...localUnsavedValue,
|
|
76
|
-
[parentRevision]: newState,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
}, [
|
|
80
|
-
currentLocalValue.keyStabilityRevision,
|
|
81
|
-
localUnsavedValue,
|
|
82
|
-
parentRevision,
|
|
83
|
-
schema,
|
|
84
|
-
setValue,
|
|
85
|
-
]);
|
|
86
|
-
const contextValue = (0, react_1.useMemo)(() => {
|
|
87
|
-
return {
|
|
88
|
-
childResetRevision: resetRevision,
|
|
89
|
-
};
|
|
90
|
-
}, [resetRevision]);
|
|
91
|
-
const reset = (0, react_1.useCallback)(() => {
|
|
92
|
-
// Only need to do key stability for arrays, but
|
|
93
|
-
// since user is not editing right now, should be fine
|
|
94
|
-
onChange(() => savedValue, true, true);
|
|
95
|
-
setResetRevision((old) => old + 1);
|
|
96
|
-
}, [savedValue, onChange]);
|
|
97
|
-
const RevisionContextProvider = (0, react_1.useCallback)(({ children }) => {
|
|
98
|
-
return (jsx_runtime_1.jsx(exports.RevisionContext.Provider, { value: contextValue, children: children }));
|
|
99
|
-
}, [contextValue]);
|
|
100
|
-
return (0, react_1.useMemo)(() => ({
|
|
101
|
-
localValue: currentLocalValue,
|
|
102
|
-
onChange,
|
|
103
|
-
reset,
|
|
104
|
-
RevisionContextProvider,
|
|
105
|
-
}), [RevisionContextProvider, currentLocalValue, onChange, reset]);
|
|
106
|
-
};
|
|
107
|
-
exports.useLocalState = useLocalState;
|