@remotion/studio 4.0.493 → 4.0.495

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 (111) hide show
  1. package/dist/api/get-static-files.d.ts +1 -1
  2. package/dist/components/AssetFileIcon.d.ts +7 -0
  3. package/dist/components/AssetFileIcon.js +24 -0
  4. package/dist/components/AssetSelectorItem.js +13 -7
  5. package/dist/components/Canvas.js +194 -36
  6. package/dist/components/CompositionSelectorItem.js +15 -8
  7. package/dist/components/CurrentAsset.d.ts +1 -0
  8. package/dist/components/CurrentAsset.js +17 -1
  9. package/dist/components/Editor.js +2 -4
  10. package/dist/components/InitialCompositionLoader.d.ts +1 -1
  11. package/dist/components/InitialCompositionLoader.js +6 -1
  12. package/dist/components/InspectorPanel/AssetInspector.d.ts +4 -0
  13. package/dist/components/InspectorPanel/AssetInspector.js +11 -0
  14. package/dist/components/InspectorPanel/{DefaultInspector.d.ts → CompositionInspector.d.ts} +2 -2
  15. package/dist/components/InspectorPanel/CompositionInspector.js +114 -0
  16. package/dist/components/InspectorPanel/CompositionInspectorHeader.d.ts +1 -0
  17. package/dist/components/{CurrentComposition.js → InspectorPanel/CompositionInspectorHeader.js} +16 -16
  18. package/dist/components/InspectorPanel/{CompositionDimensions.d.ts → CompositionMetadata.d.ts} +1 -1
  19. package/dist/components/InspectorPanel/{CompositionDimensions.js → CompositionMetadata.js} +17 -8
  20. package/dist/components/InspectorPanel/ConnectedCompositionsSection.js +2 -2
  21. package/dist/components/InspectorPanel/EasingInspector.js +3 -5
  22. package/dist/components/InspectorPanel/KeyframeInspector.js +2 -2
  23. package/dist/components/InspectorPanel/SequenceSelectionInspector.js +34 -1
  24. package/dist/components/InspectorPanel/common.d.ts +8 -0
  25. package/dist/components/InspectorPanel/common.js +31 -8
  26. package/dist/components/InspectorPanel/styles.d.ts +5 -3
  27. package/dist/components/InspectorPanel/styles.js +13 -4
  28. package/dist/components/InspectorPanel/use-composition-actions.d.ts +8 -0
  29. package/dist/components/InspectorPanel/use-composition-actions.js +114 -0
  30. package/dist/components/InspectorPanel.js +11 -2
  31. package/dist/components/InspectorSequenceSection.d.ts +0 -1
  32. package/dist/components/InspectorSequenceSection.js +9 -48
  33. package/dist/components/Modals.js +2 -1
  34. package/dist/components/NewComposition/InputDragger.d.ts +6 -0
  35. package/dist/components/NewComposition/InputDragger.js +26 -13
  36. package/dist/components/NewComposition/NewComposition.js +8 -1
  37. package/dist/components/NewComposition/ValidationMessage.d.ts +1 -1
  38. package/dist/components/Preview.js +15 -7
  39. package/dist/components/RenderModal/RenderModalOutputName.js +34 -1
  40. package/dist/components/SelectedOutlineOverlay.js +1 -0
  41. package/dist/components/SvgImportDialog.d.ts +7 -0
  42. package/dist/components/SvgImportDialog.js +103 -0
  43. package/dist/components/Timeline/Timeline.js +2 -0
  44. package/dist/components/Timeline/TimelineClipboardKeybindings.js +11 -1
  45. package/dist/components/Timeline/TimelineDeleteKeybindings.js +2 -0
  46. package/dist/components/Timeline/TimelineKeyframeControls.js +1 -0
  47. package/dist/components/Timeline/TimelineList.js +9 -4
  48. package/dist/components/Timeline/TimelineSequence.d.ts +1 -0
  49. package/dist/components/Timeline/TimelineSequence.js +42 -6
  50. package/dist/components/Timeline/TimelineSequenceItem.d.ts +2 -1
  51. package/dist/components/Timeline/TimelineSequenceItem.js +33 -13
  52. package/dist/components/Timeline/TimelineTrack.js +2 -1
  53. package/dist/components/Timeline/call-delete-keyframe.d.ts +1 -0
  54. package/dist/components/Timeline/call-delete-keyframe.js +4 -0
  55. package/dist/components/Timeline/delete-selected-keyframe.d.ts +4 -2
  56. package/dist/components/Timeline/delete-selected-keyframe.js +48 -5
  57. package/dist/components/Timeline/delete-selected-timeline-item.d.ts +3 -1
  58. package/dist/components/Timeline/delete-selected-timeline-item.js +3 -1
  59. package/dist/components/Timeline/nest-timeline-tracks.d.ts +8 -0
  60. package/dist/components/Timeline/nest-timeline-tracks.js +25 -0
  61. package/dist/components/Timeline/timeline-scroll-logic.d.ts +8 -4
  62. package/dist/components/Timeline/timeline-scroll-logic.js +29 -15
  63. package/dist/components/import-assets.d.ts +41 -3
  64. package/dist/components/import-assets.js +148 -24
  65. package/dist/components/layout.d.ts +1 -0
  66. package/dist/components/layout.js +2 -1
  67. package/dist/components/selected-outline-measurement.d.ts +2 -1
  68. package/dist/components/selected-outline-measurement.js +3 -1
  69. package/dist/esm/{chunk-mndqr3zx.js → chunk-784jbkzs.js} +8604 -7249
  70. package/dist/esm/internals.mjs +8604 -7249
  71. package/dist/esm/previewEntry.mjs +8704 -7349
  72. package/dist/esm/renderEntry.mjs +1 -1
  73. package/dist/helpers/client-id.js +2 -1
  74. package/dist/helpers/clipboard-figma.d.ts +4 -0
  75. package/dist/helpers/clipboard-figma.js +41 -0
  76. package/dist/helpers/clipboard-images.d.ts +10 -0
  77. package/dist/helpers/clipboard-images.js +77 -0
  78. package/dist/helpers/clipboard-svg.d.ts +3 -0
  79. package/dist/helpers/clipboard-svg.js +47 -0
  80. package/dist/helpers/get-effective-translation.d.ts +2 -1
  81. package/dist/helpers/get-effective-translation.js +15 -7
  82. package/dist/helpers/get-preview-file-type.d.ts +1 -1
  83. package/dist/helpers/get-preview-file-type.js +5 -1
  84. package/dist/helpers/get-sequence-double-click-action.d.ts +6 -0
  85. package/dist/helpers/get-sequence-double-click-action.js +10 -1
  86. package/dist/helpers/inject-css.js +9 -2
  87. package/dist/helpers/studio-fit-padding.d.ts +41 -0
  88. package/dist/helpers/studio-fit-padding.js +64 -0
  89. package/dist/helpers/use-image-metadata.d.ts +8 -0
  90. package/dist/helpers/use-image-metadata.js +82 -0
  91. package/dist/helpers/use-studio-canvas-dimensions.js +2 -2
  92. package/dist/icons/audio.d.ts +3 -0
  93. package/dist/icons/audio.js +3 -1
  94. package/dist/icons/font.d.ts +4 -0
  95. package/dist/icons/font.js +8 -0
  96. package/dist/icons/frame.d.ts +3 -1
  97. package/dist/icons/frame.js +1 -1
  98. package/dist/icons/json.d.ts +4 -0
  99. package/dist/icons/json.js +8 -0
  100. package/dist/icons/magnet.js +1 -1
  101. package/dist/icons/scissors.d.ts +5 -0
  102. package/dist/icons/scissors.js +8 -0
  103. package/dist/icons/solid.d.ts +5 -0
  104. package/dist/icons/solid.js +8 -0
  105. package/dist/icons/video.d.ts +3 -0
  106. package/dist/icons/video.js +5 -1
  107. package/dist/state/modals.d.ts +8 -1
  108. package/dist/state/timeline-zoom.js +12 -11
  109. package/package.json +11 -11
  110. package/dist/components/CurrentComposition.d.ts +0 -2
  111. package/dist/components/InspectorPanel/DefaultInspector.js +0 -97
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MagnetIcon = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const MagnetIcon = (props) => {
6
- return (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { transform: "rotate(180 256 256)", d: "M32 176v112c0 123.7 100.3 224 224 224s224-100.3 224-224V176H352v112c0 53-43 96-96 96s-96-43-96-96V176H32zm0-48h128V64c0-17.7-14.3-32-32-32H64C46.3 32 32 46.3 32 64v64zm320 0h128V64c0-17.7-14.3-32-32-32h-64c-17.7 0-32 14.3-32 32v64z" }) }));
6
+ return (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { transform: "rotate(180 256 256)", d: "M32 176v112c0 123.7 100.3 224 224 224s224-100.3 224-224V176H352v112c0 53-43 96-96 96s-96-43-96-96V176H32zm0-48h128V32c0-17.7-14.3-32-32-32H64C46.3 0 32 14.3 32 32v96zm320 0h128V32c0-17.7-14.3-32-32-32h-64c-17.7 0-32 14.3-32 32v96z" }) }));
7
7
  };
8
8
  exports.MagnetIcon = MagnetIcon;
@@ -0,0 +1,5 @@
1
+ import type { SVGProps } from 'react';
2
+ import React from 'react';
3
+ export declare const ScissorsIcon: React.FC<SVGProps<SVGSVGElement> & {
4
+ readonly color: string;
5
+ }>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScissorsIcon = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ScissorsIcon = ({ color, ...props }) => {
6
+ return (jsx_runtime_1.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", ...props, children: jsx_runtime_1.jsx("path", { fill: color, d: "M112 32a80 80 0 1 0 0 160 80 80 0 1 0 0-160zm0-32c61.9 0 112 50.1 112 112 0 12.4-2 24.4-5.8 35.6L256 185.4 383.9 57.5c31-31 81.2-31 112.2 0 12.4 12.4 12.4 32.6 0 45L221.6 377c1.6 7.4 2.4 15.1 2.4 23 0 61.9-50.1 112-112 112S0 461.9 0 400s50.1-112 112-112c12.4 0 24.4 2 35.6 5.8L177.4 264 135 221.6c-7.4 1.6-15.1 2.4-23 2.4-61.9 0-112-50.1-112-112S50.1 0 112 0zm55.8 209.1l32.2 32.2 33.4-33.4-30.5-30.5c-9.3 12.9-21.3 23.7-35.1 31.7zm238.7-129-229 229c12.9 9.3 23.7 21.3 31.7 35.1L473.4 80c-18.5-18.4-48.4-18.3-66.9.1zM192 400a80 80 0 1 0-160 0 80 80 0 1 0 160 0zm206.5 39.9c18.5 18.5 48.4 18.5 66.9.1L346 320.6l22.6-22.6 119.5 119.5c12.4 12.4 12.4 32.6 0 45-31 31-81.2 31-112.2 0L290 376.6l22.6-22.6 85.9 85.9z" }) }));
7
+ };
8
+ exports.ScissorsIcon = ScissorsIcon;
@@ -0,0 +1,5 @@
1
+ import type { SVGProps } from 'react';
2
+ import React from 'react';
3
+ export declare const SolidIcon: React.FC<SVGProps<SVGSVGElement> & {
4
+ readonly color: string;
5
+ }>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolidIcon = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const SolidIcon = ({ color, ...props }) => {
6
+ return (jsx_runtime_1.jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", children: jsx_runtime_1.jsx("rect", { x: 16, y: 48, width: 480, height: 416, rx: 48, fill: "none", stroke: color, strokeWidth: 32 }) }));
7
+ };
8
+ exports.SolidIcon = SolidIcon;
@@ -3,3 +3,6 @@ import React from 'react';
3
3
  export declare const FilmIcon: React.FC<SVGProps<SVGSVGElement> & {
4
4
  readonly color: string;
5
5
  }>;
6
+ export declare const VideoFileIcon: React.FC<SVGProps<SVGSVGElement> & {
7
+ readonly color: string;
8
+ }>;
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilmIcon = void 0;
3
+ exports.VideoFileIcon = exports.FilmIcon = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const FilmIcon = ({ color, ...props }) => {
6
6
  return (jsx_runtime_1.jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", children: jsx_runtime_1.jsx("path", { fill: color, d: "M448 32H64C28.65 32 0 60.65 0 96v320c0 35.35 28.65 64 64 64h384c35.35 0 64-28.65 64-64V96C512 60.65 483.3 32 448 32zM384 64v176H128V64H384zM32 96c0-17.64 14.36-32 32-32h32v80H32V96zM32 176h64v64H32V176zM32 272h64v64H32V272zM64 448c-17.64 0-32-14.36-32-32v-48h64V448H64zM128 448V272h256V448H128zM480 416c0 17.64-14.36 32-32 32h-32v-80h64V416zM480 336h-64v-64h64V336zM480 240h-64v-64h64V240zM480 144h-64V64h32c17.64 0 32 14.36 32 32V144z" }) }));
7
7
  };
8
8
  exports.FilmIcon = FilmIcon;
9
+ const VideoFileIcon = ({ color, ...props }) => {
10
+ return (jsx_runtime_1.jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512", children: jsx_runtime_1.jsx("path", { fill: color, d: "M96 96c-17.7 0-32 14.3-32 32l0 256c0 17.7 14.3 32 32 32l256 0c17.7 0 32-14.3 32-32l0-256c0-17.7-14.3-32-32-32L96 96zM32 128c0-35.3 28.7-64 64-64l256 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L96 448c-35.3 0-64-28.7-64-64l0-256zm432 84l0-40 73.6-55.2c4.2-3.1 9.2-4.8 14.4-4.8 13.3 0 24 10.7 24 24l0 240c0 13.3-10.7 24-24 24-5.2 0-10.2-1.7-14.4-4.8l-73.6-55.2 0-40 80 60 0-208-80 60z" }) }));
11
+ };
12
+ exports.VideoFileIcon = VideoFileIcon;
@@ -96,6 +96,13 @@ export type ConfirmationDialogState = {
96
96
  onConfirm: () => void;
97
97
  onCancel: () => void;
98
98
  };
99
+ export type SvgImportDialogState = {
100
+ type: 'svg-import-dialog';
101
+ id: string;
102
+ onImage: () => void;
103
+ onInline: () => void;
104
+ onDismiss: () => void;
105
+ };
99
106
  export type AddEffectModalState = {
100
107
  type: 'add-effect';
101
108
  fileName: string;
@@ -150,7 +157,7 @@ export type ModalState = {
150
157
  type: 'quick-switcher';
151
158
  mode: QuickSwitcherMode;
152
159
  invocationTimestamp: number;
153
- } | AddEffectModalState | ConfirmationDialogState;
160
+ } | AddEffectModalState | ConfirmationDialogState | SvgImportDialogState;
154
161
  export type ModalContextType = {
155
162
  selectedModal: ModalState | null;
156
163
  setSelectedModal: React.Dispatch<React.SetStateAction<ModalState | null>>;
@@ -18,24 +18,25 @@ exports.TimelineZoomCtx = (0, react_1.createContext)({
18
18
  const TimelineZoomContext = ({ children }) => {
19
19
  const [zoom, setZoomState] = (0, react_1.useState)(() => (0, ZoomPersistor_1.getZoomFromLocalStorage)());
20
20
  const setZoom = (0, react_1.useCallback)((compositionId, callback, options) => {
21
+ var _a, _b;
22
+ // Capture the old geometry before committing the new timeline width.
23
+ const preserveTimelineCursor = (0, timeline_scroll_logic_1.prepareToPreserveTimelineCursor)({
24
+ currentDurationInFrames: (0, imperative_state_1.getCurrentDuration)(),
25
+ currentFrame: (0, imperative_state_1.getCurrentFrame)(),
26
+ anchorFrame: (_a = options === null || options === void 0 ? void 0 : options.anchorFrame) !== null && _a !== void 0 ? _a : null,
27
+ anchorContentX: (_b = options === null || options === void 0 ? void 0 : options.anchorContentX) !== null && _b !== void 0 ? _b : null,
28
+ });
21
29
  (0, react_dom_1.flushSync)(() => {
22
30
  setZoomState((prevZoomMap) => {
23
- var _a, _b, _c, _d;
31
+ var _a;
24
32
  const newZoomWithFloatingPointErrors = Math.min(exports.TIMELINE_MAX_ZOOM, Math.max(exports.TIMELINE_MIN_ZOOM, callback((_a = prevZoomMap[compositionId]) !== null && _a !== void 0 ? _a : exports.TIMELINE_MIN_ZOOM)));
25
33
  const newZoom = Math.round(newZoomWithFloatingPointErrors * 10) / 10;
26
- const anchorFrame = (_b = options === null || options === void 0 ? void 0 : options.anchorFrame) !== null && _b !== void 0 ? _b : null;
27
- const anchorContentX = (_c = options === null || options === void 0 ? void 0 : options.anchorContentX) !== null && _c !== void 0 ? _c : null;
28
- (0, timeline_scroll_logic_1.zoomAndPreserveCursor)({
29
- oldZoom: (_d = prevZoomMap[compositionId]) !== null && _d !== void 0 ? _d : exports.TIMELINE_MIN_ZOOM,
30
- newZoom,
31
- currentDurationInFrames: (0, imperative_state_1.getCurrentDuration)(),
32
- currentFrame: (0, imperative_state_1.getCurrentFrame)(),
33
- anchorFrame,
34
- anchorContentX,
35
- });
36
34
  return { ...prevZoomMap, [compositionId]: newZoom };
37
35
  });
38
36
  });
37
+ // The new scroll range exists now, so the browser will not clamp the offset
38
+ // against the previous width.
39
+ preserveTimelineCursor();
39
40
  }, []);
40
41
  const value = (0, react_1.useMemo)(() => {
41
42
  return {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.493",
6
+ "version": "4.0.495",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "scripts": {
@@ -25,15 +25,15 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "semver": "7.5.3",
28
- "remotion": "4.0.493",
29
- "@remotion/canvas-capture": "4.0.493",
30
- "@remotion/player": "4.0.493",
31
- "@remotion/media-utils": "4.0.493",
32
- "@remotion/renderer": "4.0.493",
33
- "@remotion/web-renderer": "4.0.493",
34
- "@remotion/studio-shared": "4.0.493",
35
- "@remotion/timeline-utils": "4.0.493",
36
- "@remotion/zod-types": "4.0.493",
28
+ "remotion": "4.0.495",
29
+ "@remotion/canvas-capture": "4.0.495",
30
+ "@remotion/player": "4.0.495",
31
+ "@remotion/media-utils": "4.0.495",
32
+ "@remotion/renderer": "4.0.495",
33
+ "@remotion/web-renderer": "4.0.495",
34
+ "@remotion/studio-shared": "4.0.495",
35
+ "@remotion/timeline-utils": "4.0.495",
36
+ "@remotion/zod-types": "4.0.495",
37
37
  "@jridgewell/trace-mapping": "0.3.31",
38
38
  "mediabunny": "1.50.8",
39
39
  "memfs": "3.4.3",
@@ -44,7 +44,7 @@
44
44
  "react": "19.2.3",
45
45
  "react-dom": "19.2.3",
46
46
  "@types/semver": "7.5.3",
47
- "@remotion/eslint-config-internal": "4.0.493",
47
+ "@remotion/eslint-config-internal": "4.0.495",
48
48
  "eslint": "9.19.0",
49
49
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
50
50
  },
@@ -1,2 +0,0 @@
1
- export declare const CURRENT_COMPOSITION_HEIGHT = 66;
2
- export declare const CurrentComposition: () => import("react/jsx-runtime").JSX.Element;
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultInspector = 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 interactivity_enabled_1 = require("../../helpers/interactivity-enabled");
8
- const VisualControls_1 = require("../../visual-controls/VisualControls");
9
- const CurrentAsset_1 = require("../CurrentAsset");
10
- const CurrentComposition_1 = require("../CurrentComposition");
11
- const DefaultPropsEditor_1 = require("../DefaultPropsEditor");
12
- const get_zod_if_possible_1 = require("../get-zod-if-possible");
13
- const is_menu_item_1 = require("../Menu/is-menu-item");
14
- const ObserveDefaultPropsContext_1 = require("../ObserveDefaultPropsContext");
15
- const DataEditor_1 = require("../RenderModal/DataEditor");
16
- const zod_schema_type_1 = require("../RenderModal/SchemaEditor/zod-schema-type");
17
- const WarningIndicatorButton_1 = require("../RenderModal/WarningIndicatorButton");
18
- const SegmentedControl_1 = require("../SegmentedControl");
19
- const VisualControlsContent_1 = require("../VisualControls/VisualControlsContent");
20
- const common_1 = require("./common");
21
- const CompositionDimensions_1 = require("./CompositionDimensions");
22
- const styles_1 = require("./styles");
23
- const DefaultInspector = ({ composition, currentDefaultProps, readOnlyStudio, setDefaultProps }) => {
24
- var _a, _b;
25
- const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
26
- const hasSelectedAsset = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'asset';
27
- const z = (0, get_zod_if_possible_1.useZodIfPossible)();
28
- const canSaveDefaultProps = (0, react_1.useContext)(ObserveDefaultPropsContext_1.ObserveDefaultPropsContext);
29
- const { handles: visualControlHandles } = (0, react_1.useContext)(VisualControls_1.VisualControlsContext);
30
- const [defaultPropsMode, setDefaultPropsMode] = (0, react_1.useState)('schema');
31
- const compositionId = (_a = composition === null || composition === void 0 ? void 0 : composition.id) !== null && _a !== void 0 ? _a : null;
32
- const hasVisualControls = interactivity_enabled_1.studioInteractivityEnabled && Object.keys(visualControlHandles).length > 0;
33
- (0, react_1.useEffect)(() => {
34
- setDefaultPropsMode('schema');
35
- }, [compositionId]);
36
- const defaultPropsModeItems = (0, react_1.useMemo)(() => {
37
- return [
38
- {
39
- key: 'schema',
40
- label: 'Schema',
41
- onClick: () => {
42
- setDefaultPropsMode('schema');
43
- },
44
- selected: defaultPropsMode === 'schema',
45
- },
46
- {
47
- key: 'json',
48
- label: 'JSON',
49
- onClick: () => {
50
- setDefaultPropsMode('json');
51
- },
52
- selected: defaultPropsMode === 'json',
53
- },
54
- ];
55
- }, [defaultPropsMode]);
56
- const canShowDefaultPropsSection = (0, react_1.useMemo)(() => {
57
- if (!z || !(composition === null || composition === void 0 ? void 0 : composition.schema) || !composition.defaultProps) {
58
- return false;
59
- }
60
- if (!(typeof composition.schema.safeParse ===
61
- 'function')) {
62
- return false;
63
- }
64
- return (0, zod_schema_type_1.getZodSchemaType)(composition.schema) !== 'any';
65
- }, [composition === null || composition === void 0 ? void 0 : composition.defaultProps, composition === null || composition === void 0 ? void 0 : composition.schema, z]);
66
- const { setShowWarning, showWarning } = (0, DataEditor_1.useDataEditorWarningVisibility)();
67
- const { warnings: defaultPropsWarnings } = (0, DataEditor_1.useDataEditorWarnings)({
68
- canSaveDefaultProps: (_b = canSaveDefaultProps === null || canSaveDefaultProps === void 0 ? void 0 : canSaveDefaultProps.canSaveDefaultProps) !== null && _b !== void 0 ? _b : null,
69
- defaultProps: currentDefaultProps,
70
- mode: defaultPropsMode,
71
- propsEditType: 'default-props',
72
- showCannotSaveDefaultPropsWarning: canShowDefaultPropsSection,
73
- });
74
- if (hasSelectedAsset) {
75
- return (jsx_runtime_1.jsx("div", { style: styles_1.scrollableContainer, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx("div", { style: styles_1.compositionSection, children: jsx_runtime_1.jsx(CurrentAsset_1.CurrentAsset, { readOnlyStudio: readOnlyStudio }) }) }));
76
- }
77
- if (composition === null) {
78
- return jsx_runtime_1.jsx("div", { style: styles_1.container });
79
- }
80
- return (jsx_runtime_1.jsxs("div", { style: styles_1.scrollableContainer, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: [
81
- jsx_runtime_1.jsxs("div", { style: styles_1.compositionSection, children: [
82
- jsx_runtime_1.jsx(CurrentComposition_1.CurrentComposition, {}), jsx_runtime_1.jsx(common_1.InspectorSectionDivider, {}), jsx_runtime_1.jsx(CompositionDimensions_1.CompositionDimensions, { compositionId: composition.id, disabled: readOnlyStudio, stack: composition.stack })
83
- ] }), canShowDefaultPropsSection ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
84
- jsx_runtime_1.jsx(common_1.InspectorSectionDivider, {}), jsx_runtime_1.jsxs("div", { style: styles_1.defaultPropsSection, children: [
85
- jsx_runtime_1.jsx(common_1.InspectorSectionHeader, { children: jsx_runtime_1.jsxs("div", { style: styles_1.sectionHeaderRow, children: [
86
- jsx_runtime_1.jsxs("div", { style: styles_1.sectionHeaderStart, children: [
87
- jsx_runtime_1.jsx("span", { style: styles_1.sectionHeaderTitle, children: "Default Props" }), jsx_runtime_1.jsx(SegmentedControl_1.SegmentedControl, { items: defaultPropsModeItems, needsWrapping: false, size: "compact" })
88
- ] }), jsx_runtime_1.jsx("div", { style: styles_1.sectionHeaderEnd, children: defaultPropsWarnings.length > 0 ? (jsx_runtime_1.jsx(WarningIndicatorButton_1.WarningIndicatorButton, { setShowWarning: setShowWarning, showWarning: showWarning, warningCount: defaultPropsWarnings.length, size: "compact" })) : null })
89
- ] }) }), defaultPropsWarnings.length > 0 && showWarning ? (jsx_runtime_1.jsx("div", { style: styles_1.defaultPropsWarningContainer, children: jsx_runtime_1.jsx(common_1.InspectorDefaultPropsWarnings, { warnings: defaultPropsWarnings }) })) : null, jsx_runtime_1.jsx(DefaultPropsEditor_1.DefaultPropsEditor, { unresolvedComposition: composition, defaultProps: currentDefaultProps, setDefaultProps: setDefaultProps, propsEditType: "default-props", schemaErrorMode: "compact", layout: "inspector", mode: defaultPropsMode, onModeChange: setDefaultPropsMode, hideModeControls: canShowDefaultPropsSection, warnings: defaultPropsWarnings, showWarning: false, setShowWarning: setShowWarning, hideWarningButton: true }, composition.id)
90
- ] })
91
- ] })) : null, hasVisualControls ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
92
- jsx_runtime_1.jsx(common_1.InspectorSectionDivider, {}), jsx_runtime_1.jsxs("div", { style: styles_1.visualControlsSection, children: [
93
- jsx_runtime_1.jsx(common_1.InspectorSectionHeader, { children: "Visual Controls" }), jsx_runtime_1.jsx(VisualControlsContent_1.VisualControlsContent, {})
94
- ] })
95
- ] })) : null] }));
96
- };
97
- exports.DefaultInspector = DefaultInspector;