@hai3/studio 0.1.0-alpha.1 → 0.2.0-alpha.0
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/index.cjs +117 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var React4 = require('react');
|
|
4
|
+
var react = require('@hai3/react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var uikit = require('@hai3/uikit');
|
|
7
7
|
var lodash = require('lodash');
|
|
8
|
-
var uikitContracts = require('@hai3/uikit-contracts');
|
|
9
8
|
|
|
10
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
10
|
|
|
12
|
-
var
|
|
11
|
+
var React4__default = /*#__PURE__*/_interopDefault(React4);
|
|
13
12
|
|
|
14
13
|
var __create = Object.create;
|
|
15
14
|
var __defProp = Object.defineProperty;
|
|
@@ -841,19 +840,19 @@ var StudioEvents = {
|
|
|
841
840
|
|
|
842
841
|
// src/effects/persistenceEffects.ts
|
|
843
842
|
var initPersistenceEffects = () => {
|
|
844
|
-
const positionSubscription =
|
|
843
|
+
const positionSubscription = react.eventBus.on(
|
|
845
844
|
StudioEvents.PositionChanged,
|
|
846
845
|
({ position }) => {
|
|
847
846
|
saveStudioState(STORAGE_KEYS.POSITION, position);
|
|
848
847
|
}
|
|
849
848
|
);
|
|
850
|
-
const sizeSubscription =
|
|
849
|
+
const sizeSubscription = react.eventBus.on(
|
|
851
850
|
StudioEvents.SizeChanged,
|
|
852
851
|
({ size }) => {
|
|
853
852
|
saveStudioState(STORAGE_KEYS.SIZE, size);
|
|
854
853
|
}
|
|
855
854
|
);
|
|
856
|
-
const buttonPositionSubscription =
|
|
855
|
+
const buttonPositionSubscription = react.eventBus.on(
|
|
857
856
|
StudioEvents.ButtonPositionChanged,
|
|
858
857
|
({ position }) => {
|
|
859
858
|
saveStudioState(STORAGE_KEYS.BUTTON_POSITION, position);
|
|
@@ -865,63 +864,63 @@ var initPersistenceEffects = () => {
|
|
|
865
864
|
buttonPositionSubscription.unsubscribe();
|
|
866
865
|
};
|
|
867
866
|
};
|
|
868
|
-
var studioTranslations =
|
|
869
|
-
[
|
|
870
|
-
[
|
|
871
|
-
[
|
|
872
|
-
[
|
|
873
|
-
[
|
|
874
|
-
[
|
|
875
|
-
[
|
|
876
|
-
[
|
|
877
|
-
[
|
|
878
|
-
[
|
|
879
|
-
[
|
|
880
|
-
[
|
|
881
|
-
[
|
|
882
|
-
[
|
|
883
|
-
[
|
|
884
|
-
[
|
|
885
|
-
[
|
|
886
|
-
[
|
|
887
|
-
[
|
|
888
|
-
[
|
|
889
|
-
[
|
|
890
|
-
[
|
|
891
|
-
[
|
|
892
|
-
[
|
|
893
|
-
[
|
|
894
|
-
[
|
|
895
|
-
[
|
|
896
|
-
[
|
|
897
|
-
[
|
|
898
|
-
[
|
|
899
|
-
[
|
|
900
|
-
[
|
|
901
|
-
[
|
|
902
|
-
[
|
|
903
|
-
[
|
|
904
|
-
[
|
|
867
|
+
var studioTranslations = react.I18nRegistry.createLoader({
|
|
868
|
+
[react.Language.English]: () => Promise.resolve().then(() => __toESM(require_en())),
|
|
869
|
+
[react.Language.Arabic]: () => Promise.resolve().then(() => __toESM(require_ar())),
|
|
870
|
+
[react.Language.Bengali]: () => Promise.resolve().then(() => __toESM(require_bn())),
|
|
871
|
+
[react.Language.Czech]: () => Promise.resolve().then(() => __toESM(require_cs())),
|
|
872
|
+
[react.Language.Danish]: () => Promise.resolve().then(() => __toESM(require_da())),
|
|
873
|
+
[react.Language.German]: () => Promise.resolve().then(() => __toESM(require_de())),
|
|
874
|
+
[react.Language.Greek]: () => Promise.resolve().then(() => __toESM(require_el())),
|
|
875
|
+
[react.Language.Spanish]: () => Promise.resolve().then(() => __toESM(require_es())),
|
|
876
|
+
[react.Language.Persian]: () => Promise.resolve().then(() => __toESM(require_fa())),
|
|
877
|
+
[react.Language.Finnish]: () => Promise.resolve().then(() => __toESM(require_fi())),
|
|
878
|
+
[react.Language.French]: () => Promise.resolve().then(() => __toESM(require_fr())),
|
|
879
|
+
[react.Language.Hebrew]: () => Promise.resolve().then(() => __toESM(require_he())),
|
|
880
|
+
[react.Language.Hindi]: () => Promise.resolve().then(() => __toESM(require_hi())),
|
|
881
|
+
[react.Language.Hungarian]: () => Promise.resolve().then(() => __toESM(require_hu())),
|
|
882
|
+
[react.Language.Indonesian]: () => Promise.resolve().then(() => __toESM(require_id())),
|
|
883
|
+
[react.Language.Italian]: () => Promise.resolve().then(() => __toESM(require_it())),
|
|
884
|
+
[react.Language.Japanese]: () => Promise.resolve().then(() => __toESM(require_ja())),
|
|
885
|
+
[react.Language.Korean]: () => Promise.resolve().then(() => __toESM(require_ko())),
|
|
886
|
+
[react.Language.Malay]: () => Promise.resolve().then(() => __toESM(require_ms())),
|
|
887
|
+
[react.Language.Dutch]: () => Promise.resolve().then(() => __toESM(require_nl())),
|
|
888
|
+
[react.Language.Norwegian]: () => Promise.resolve().then(() => __toESM(require_no())),
|
|
889
|
+
[react.Language.Polish]: () => Promise.resolve().then(() => __toESM(require_pl())),
|
|
890
|
+
[react.Language.Portuguese]: () => Promise.resolve().then(() => __toESM(require_pt())),
|
|
891
|
+
[react.Language.Romanian]: () => Promise.resolve().then(() => __toESM(require_ro())),
|
|
892
|
+
[react.Language.Russian]: () => Promise.resolve().then(() => __toESM(require_ru())),
|
|
893
|
+
[react.Language.Swedish]: () => Promise.resolve().then(() => __toESM(require_sv())),
|
|
894
|
+
[react.Language.Swahili]: () => Promise.resolve().then(() => __toESM(require_sw())),
|
|
895
|
+
[react.Language.Tamil]: () => Promise.resolve().then(() => __toESM(require_ta())),
|
|
896
|
+
[react.Language.Thai]: () => Promise.resolve().then(() => __toESM(require_th())),
|
|
897
|
+
[react.Language.Tagalog]: () => Promise.resolve().then(() => __toESM(require_tl())),
|
|
898
|
+
[react.Language.Turkish]: () => Promise.resolve().then(() => __toESM(require_tr())),
|
|
899
|
+
[react.Language.Ukrainian]: () => Promise.resolve().then(() => __toESM(require_uk())),
|
|
900
|
+
[react.Language.Urdu]: () => Promise.resolve().then(() => __toESM(require_ur())),
|
|
901
|
+
[react.Language.Vietnamese]: () => Promise.resolve().then(() => __toESM(require_vi())),
|
|
902
|
+
[react.Language.ChineseTraditional]: () => Promise.resolve().then(() => __toESM(require_zh_TW())),
|
|
903
|
+
[react.Language.ChineseSimplified]: () => Promise.resolve().then(() => __toESM(require_zh()))
|
|
905
904
|
});
|
|
906
|
-
|
|
907
|
-
var StudioContext =
|
|
905
|
+
react.i18nRegistry.registerLoader("studio", studioTranslations);
|
|
906
|
+
var StudioContext = React4.createContext(void 0);
|
|
908
907
|
var useStudioContext = () => {
|
|
909
|
-
const context =
|
|
908
|
+
const context = React4.useContext(StudioContext);
|
|
910
909
|
if (!context) {
|
|
911
910
|
throw new Error("useStudioContext must be used within StudioProvider");
|
|
912
911
|
}
|
|
913
912
|
return context;
|
|
914
913
|
};
|
|
915
914
|
var StudioProvider = ({ children }) => {
|
|
916
|
-
const [collapsed, setCollapsed] =
|
|
915
|
+
const [collapsed, setCollapsed] = React4.useState(
|
|
917
916
|
() => loadStudioState(STORAGE_KEYS.COLLAPSED, false)
|
|
918
917
|
);
|
|
919
|
-
const [portalContainer, setPortalContainer] =
|
|
920
|
-
|
|
918
|
+
const [portalContainer, setPortalContainer] = React4.useState(null);
|
|
919
|
+
React4.useEffect(() => {
|
|
921
920
|
const cleanup = initPersistenceEffects();
|
|
922
921
|
return cleanup;
|
|
923
922
|
}, []);
|
|
924
|
-
const toggleCollapsed =
|
|
923
|
+
const toggleCollapsed = React4.useCallback(() => {
|
|
925
924
|
setCollapsed((prev) => {
|
|
926
925
|
const newValue = !prev;
|
|
927
926
|
saveStudioState(STORAGE_KEYS.COLLAPSED, newValue);
|
|
@@ -947,19 +946,19 @@ var useDraggable = ({ panelSize, storageKey = STORAGE_KEYS.POSITION }) => {
|
|
|
947
946
|
x: window.innerWidth - panelSize.width - 20,
|
|
948
947
|
y: window.innerHeight - panelSize.height - 20
|
|
949
948
|
});
|
|
950
|
-
const [position, setPosition] =
|
|
949
|
+
const [position, setPosition] = React4.useState(
|
|
951
950
|
() => loadStudioState(storageKey, getDefaultPosition())
|
|
952
951
|
);
|
|
953
|
-
const [isDragging, setIsDragging] =
|
|
954
|
-
const dragStartPos =
|
|
955
|
-
const handleMouseDown =
|
|
952
|
+
const [isDragging, setIsDragging] = React4.useState(false);
|
|
953
|
+
const dragStartPos = React4.useRef({ x: 0, y: 0 });
|
|
954
|
+
const handleMouseDown = React4.useCallback((e) => {
|
|
956
955
|
setIsDragging(true);
|
|
957
956
|
dragStartPos.current = {
|
|
958
957
|
x: e.clientX - position.x,
|
|
959
958
|
y: e.clientY - position.y
|
|
960
959
|
};
|
|
961
960
|
}, [position]);
|
|
962
|
-
|
|
961
|
+
React4.useEffect(() => {
|
|
963
962
|
if (!isDragging) return;
|
|
964
963
|
const handleMouseMove = (e) => {
|
|
965
964
|
const newX = lodash.clamp(
|
|
@@ -975,7 +974,7 @@ var useDraggable = ({ panelSize, storageKey = STORAGE_KEYS.POSITION }) => {
|
|
|
975
974
|
const newPosition = { x: newX, y: newY };
|
|
976
975
|
setPosition(newPosition);
|
|
977
976
|
const eventName = storageKey === STORAGE_KEYS.BUTTON_POSITION ? StudioEvents.ButtonPositionChanged : StudioEvents.PositionChanged;
|
|
978
|
-
|
|
977
|
+
react.eventBus.emit(eventName, { position: newPosition });
|
|
979
978
|
};
|
|
980
979
|
const handleMouseUp = () => {
|
|
981
980
|
setIsDragging(false);
|
|
@@ -994,15 +993,15 @@ var useDraggable = ({ panelSize, storageKey = STORAGE_KEYS.POSITION }) => {
|
|
|
994
993
|
};
|
|
995
994
|
};
|
|
996
995
|
var useResizable = () => {
|
|
997
|
-
const [size, setSize] =
|
|
996
|
+
const [size, setSize] = React4.useState(
|
|
998
997
|
() => loadStudioState(STORAGE_KEYS.SIZE, {
|
|
999
998
|
width: PANEL_CONSTRAINTS.DEFAULT_WIDTH,
|
|
1000
999
|
height: PANEL_CONSTRAINTS.DEFAULT_HEIGHT
|
|
1001
1000
|
})
|
|
1002
1001
|
);
|
|
1003
|
-
const [isResizing, setIsResizing] =
|
|
1004
|
-
const resizeStartRef =
|
|
1005
|
-
const handleMouseDown =
|
|
1002
|
+
const [isResizing, setIsResizing] = React4.useState(false);
|
|
1003
|
+
const resizeStartRef = React4.useRef(null);
|
|
1004
|
+
const handleMouseDown = React4.useCallback((e) => {
|
|
1006
1005
|
e.stopPropagation();
|
|
1007
1006
|
resizeStartRef.current = {
|
|
1008
1007
|
mouseX: e.clientX,
|
|
@@ -1012,7 +1011,7 @@ var useResizable = () => {
|
|
|
1012
1011
|
};
|
|
1013
1012
|
setIsResizing(true);
|
|
1014
1013
|
}, [size.width, size.height]);
|
|
1015
|
-
|
|
1014
|
+
React4.useEffect(() => {
|
|
1016
1015
|
if (!isResizing || !resizeStartRef.current) return;
|
|
1017
1016
|
const startState = resizeStartRef.current;
|
|
1018
1017
|
document.body.style.userSelect = "none";
|
|
@@ -1032,7 +1031,7 @@ var useResizable = () => {
|
|
|
1032
1031
|
);
|
|
1033
1032
|
const newSize = { width: newWidth, height: newHeight };
|
|
1034
1033
|
setSize(newSize);
|
|
1035
|
-
|
|
1034
|
+
react.eventBus.emit(StudioEvents.SizeChanged, { size: newSize });
|
|
1036
1035
|
};
|
|
1037
1036
|
const handleMouseUp = () => {
|
|
1038
1037
|
setIsResizing(false);
|
|
@@ -1058,25 +1057,23 @@ var useResizable = () => {
|
|
|
1058
1057
|
var ThemeSelector = ({
|
|
1059
1058
|
className = ""
|
|
1060
1059
|
}) => {
|
|
1061
|
-
const
|
|
1062
|
-
const currentTheme = uicore.useAppSelector((state) => state.uicore.layout.theme);
|
|
1060
|
+
const { currentTheme, themes, setTheme } = react.useTheme();
|
|
1063
1061
|
const { portalContainer } = useStudioContext();
|
|
1064
|
-
const { t } =
|
|
1062
|
+
const { t } = react.useTranslation();
|
|
1065
1063
|
const formatThemeName = (themeName) => {
|
|
1066
1064
|
return themeName.split("-").map((word) => lodash.upperFirst(word)).join(" ");
|
|
1067
1065
|
};
|
|
1068
|
-
const availableThemes = uicore.themeRegistry.getThemeNames();
|
|
1069
1066
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center justify-between ${className}`, children: [
|
|
1070
1067
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm text-muted-foreground whitespace-nowrap", children: t("studio:controls.theme") }),
|
|
1071
1068
|
/* @__PURE__ */ jsxRuntime.jsxs(uikit.DropdownMenu, { children: [
|
|
1072
|
-
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownButton, { variant:
|
|
1073
|
-
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuContent, { align: "end", container: portalContainer, className: "z-[99999] pointer-events-auto", children:
|
|
1069
|
+
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownButton, { variant: uikit.ButtonVariant.Outline, children: formatThemeName(currentTheme || "") }) }),
|
|
1070
|
+
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuContent, { align: "end", container: portalContainer, className: "z-[99999] pointer-events-auto", children: themes.map((theme) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1074
1071
|
uikit.DropdownMenuItem,
|
|
1075
1072
|
{
|
|
1076
|
-
onClick: () =>
|
|
1077
|
-
children: formatThemeName(
|
|
1073
|
+
onClick: () => setTheme(theme.id),
|
|
1074
|
+
children: formatThemeName(theme.name || theme.id)
|
|
1078
1075
|
},
|
|
1079
|
-
|
|
1076
|
+
theme.id
|
|
1080
1077
|
)) })
|
|
1081
1078
|
] })
|
|
1082
1079
|
] });
|
|
@@ -1089,7 +1086,7 @@ var ScreensetSelector = ({
|
|
|
1089
1086
|
className = ""
|
|
1090
1087
|
}) => {
|
|
1091
1088
|
const { portalContainer } = useStudioContext();
|
|
1092
|
-
const { t,
|
|
1089
|
+
const { t, isRTL } = react.useTranslation();
|
|
1093
1090
|
const formatName = (name) => {
|
|
1094
1091
|
return name.split(/[-_]/).map((word) => lodash.upperFirst(word)).join(" ");
|
|
1095
1092
|
};
|
|
@@ -1105,8 +1102,8 @@ var ScreensetSelector = ({
|
|
|
1105
1102
|
};
|
|
1106
1103
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center justify-between ${className}`, children: [
|
|
1107
1104
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm text-muted-foreground whitespace-nowrap", children: t("studio:controls.screenset") }),
|
|
1108
|
-
/* @__PURE__ */ jsxRuntime.jsxs(uikit.DropdownMenu, { dir:
|
|
1109
|
-
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownButton, { variant:
|
|
1105
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uikit.DropdownMenu, { dir: isRTL ? "rtl" : "ltr", children: [
|
|
1106
|
+
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownButton, { variant: uikit.ButtonVariant.Outline, children: formatName(getCurrentDisplay()) }) }),
|
|
1110
1107
|
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuContent, { align: "end", container: portalContainer, className: "z-[99999] pointer-events-auto", children: options.map((categoryGroup) => /* @__PURE__ */ jsxRuntime.jsxs(uikit.DropdownMenuSub, { children: [
|
|
1111
1108
|
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuSubTrigger, { disabled: categoryGroup.screensets.length === 0, children: formatName(categoryGroup.category) }),
|
|
1112
1109
|
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuSubContent, { container: portalContainer, className: "z-[99999] pointer-events-auto", children: categoryGroup.screensets.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1125,23 +1122,22 @@ ScreensetSelector.displayName = "ScreensetSelector";
|
|
|
1125
1122
|
var FALLBACK_SELECT_LANGUAGE_TEXT = "Select language";
|
|
1126
1123
|
var RTL_INDICATOR_SUFFIX = " (RTL)";
|
|
1127
1124
|
function LanguageSelector({
|
|
1128
|
-
displayMode =
|
|
1125
|
+
displayMode = react.LanguageDisplayMode.Native
|
|
1129
1126
|
} = {}) {
|
|
1130
|
-
const { t, language,
|
|
1127
|
+
const { t, language, setLanguage } = react.useTranslation();
|
|
1131
1128
|
const { portalContainer } = useStudioContext();
|
|
1132
|
-
const
|
|
1133
|
-
const currentLanguage = languages.find((lang) => lang.code === language);
|
|
1129
|
+
const currentLanguage = language ? react.getLanguageMetadata(language) : null;
|
|
1134
1130
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1135
1131
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm text-muted-foreground whitespace-nowrap", children: t("studio:controls.language") }),
|
|
1136
1132
|
/* @__PURE__ */ jsxRuntime.jsxs(uikit.DropdownMenu, { children: [
|
|
1137
|
-
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(uikit.Button, { variant:
|
|
1138
|
-
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuContent, { align: "end", container: portalContainer, className: "z-[99999] pointer-events-auto", children:
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(uikit.Button, { variant: uikit.ButtonVariant.Outline, children: currentLanguage ? displayMode === react.LanguageDisplayMode.Native ? currentLanguage.name : currentLanguage.englishName : FALLBACK_SELECT_LANGUAGE_TEXT }) }),
|
|
1134
|
+
/* @__PURE__ */ jsxRuntime.jsx(uikit.DropdownMenuContent, { align: "end", container: portalContainer, className: "z-[99999] pointer-events-auto", children: react.SUPPORTED_LANGUAGES.map((lang) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1139
1135
|
uikit.DropdownMenuItem,
|
|
1140
1136
|
{
|
|
1141
|
-
onClick: () =>
|
|
1137
|
+
onClick: () => setLanguage(lang.code),
|
|
1142
1138
|
children: [
|
|
1143
|
-
displayMode ===
|
|
1144
|
-
lang.direction ===
|
|
1139
|
+
displayMode === react.LanguageDisplayMode.Native ? lang.name : lang.englishName,
|
|
1140
|
+
lang.direction === react.TextDirection.RightToLeft && RTL_INDICATOR_SUFFIX
|
|
1145
1141
|
]
|
|
1146
1142
|
},
|
|
1147
1143
|
lang.code
|
|
@@ -1150,8 +1146,12 @@ function LanguageSelector({
|
|
|
1150
1146
|
] });
|
|
1151
1147
|
}
|
|
1152
1148
|
var ApiModeToggle = ({ className }) => {
|
|
1153
|
-
const useMockApi =
|
|
1154
|
-
const { t } =
|
|
1149
|
+
const [useMockApi, setUseMockApi] = React4.useState(true);
|
|
1150
|
+
const { t } = react.useTranslation();
|
|
1151
|
+
const handleToggle = (checked) => {
|
|
1152
|
+
setUseMockApi(checked);
|
|
1153
|
+
react.apiRegistry.setMockMode(checked);
|
|
1154
|
+
};
|
|
1155
1155
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center justify-between h-9 ${className}`, children: [
|
|
1156
1156
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1157
1157
|
"label",
|
|
@@ -1166,28 +1166,43 @@ var ApiModeToggle = ({ className }) => {
|
|
|
1166
1166
|
{
|
|
1167
1167
|
id: "api-mode-toggle",
|
|
1168
1168
|
checked: useMockApi,
|
|
1169
|
-
onCheckedChange:
|
|
1169
|
+
onCheckedChange: handleToggle
|
|
1170
1170
|
}
|
|
1171
1171
|
)
|
|
1172
1172
|
] });
|
|
1173
1173
|
};
|
|
1174
1174
|
ApiModeToggle.displayName = "ApiModeToggle";
|
|
1175
|
-
var ALL_CATEGORIES = [
|
|
1175
|
+
var ALL_CATEGORIES = [react.ScreensetCategory.Drafts, react.ScreensetCategory.Mockups, react.ScreensetCategory.Production];
|
|
1176
1176
|
var buildScreensetOptions = () => {
|
|
1177
|
+
const allScreensets = react.screensetRegistry.getAll();
|
|
1177
1178
|
return ALL_CATEGORIES.map((category) => ({
|
|
1178
1179
|
category,
|
|
1179
|
-
screensets:
|
|
1180
|
+
screensets: allScreensets.filter((s) => s.category === category).map((s) => ({
|
|
1181
|
+
id: s.id,
|
|
1182
|
+
name: s.name
|
|
1183
|
+
}))
|
|
1180
1184
|
}));
|
|
1181
1185
|
};
|
|
1182
1186
|
var ControlPanel = () => {
|
|
1183
|
-
const
|
|
1184
|
-
const
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1187
|
-
React3.useEffect(() => {
|
|
1187
|
+
const { currentScreenset, navigateToScreenset } = react.useNavigation();
|
|
1188
|
+
const [screensetOptions, setScreensetOptions] = React4.useState([]);
|
|
1189
|
+
const { t } = react.useTranslation();
|
|
1190
|
+
React4.useEffect(() => {
|
|
1188
1191
|
const options = buildScreensetOptions();
|
|
1189
1192
|
setScreensetOptions(options);
|
|
1190
1193
|
}, []);
|
|
1194
|
+
const getCurrentValue = () => {
|
|
1195
|
+
if (!currentScreenset) return "";
|
|
1196
|
+
const screenset = react.screensetRegistry.get(currentScreenset);
|
|
1197
|
+
if (!screenset) return "";
|
|
1198
|
+
return `${screenset.category}:${screenset.id}`;
|
|
1199
|
+
};
|
|
1200
|
+
const handleScreensetChange = (value) => {
|
|
1201
|
+
const [, screensetId] = value.split(":");
|
|
1202
|
+
if (screensetId) {
|
|
1203
|
+
navigateToScreenset(screensetId);
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1191
1206
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
1192
1207
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wider", children: t("studio:controls.heading") }),
|
|
1193
1208
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
@@ -1195,8 +1210,8 @@ var ControlPanel = () => {
|
|
|
1195
1210
|
ScreensetSelector,
|
|
1196
1211
|
{
|
|
1197
1212
|
options: screensetOptions,
|
|
1198
|
-
currentValue:
|
|
1199
|
-
onChange:
|
|
1213
|
+
currentValue: getCurrentValue(),
|
|
1214
|
+
onChange: handleScreensetChange
|
|
1200
1215
|
}
|
|
1201
1216
|
),
|
|
1202
1217
|
/* @__PURE__ */ jsxRuntime.jsx(ApiModeToggle, {}),
|
|
@@ -1208,14 +1223,14 @@ var ControlPanel = () => {
|
|
|
1208
1223
|
ControlPanel.displayName = "ControlPanel";
|
|
1209
1224
|
var StudioPanel = () => {
|
|
1210
1225
|
const { toggleCollapsed, setPortalContainer } = useStudioContext();
|
|
1211
|
-
const { t } =
|
|
1212
|
-
const portalRef =
|
|
1226
|
+
const { t } = react.useTranslation();
|
|
1227
|
+
const portalRef = React4__default.default.useRef(null);
|
|
1213
1228
|
const { size, handleMouseDown: handleResizeMouseDown } = useResizable();
|
|
1214
1229
|
const { position, isDragging, handleMouseDown: handleDragMouseDown } = useDraggable({
|
|
1215
1230
|
panelSize: size,
|
|
1216
1231
|
storageKey: STORAGE_KEYS.POSITION
|
|
1217
1232
|
});
|
|
1218
|
-
|
|
1233
|
+
React4__default.default.useEffect(() => {
|
|
1219
1234
|
setPortalContainer(portalRef.current);
|
|
1220
1235
|
return () => setPortalContainer(null);
|
|
1221
1236
|
}, [setPortalContainer]);
|
|
@@ -1306,7 +1321,7 @@ var StudioPanel = () => {
|
|
|
1306
1321
|
};
|
|
1307
1322
|
StudioPanel.displayName = "StudioPanel";
|
|
1308
1323
|
var useKeyboardShortcut = (handler) => {
|
|
1309
|
-
|
|
1324
|
+
React4.useEffect(() => {
|
|
1310
1325
|
const handleKeyDown = (e) => {
|
|
1311
1326
|
if (e.shiftKey && e.code === "Backquote") {
|
|
1312
1327
|
e.preventDefault();
|
|
@@ -1361,12 +1376,12 @@ var StudioIcon = ({ className = "" }) => {
|
|
|
1361
1376
|
);
|
|
1362
1377
|
};
|
|
1363
1378
|
var CollapsedButton = ({ toggleCollapsed }) => {
|
|
1364
|
-
const { t } =
|
|
1379
|
+
const { t } = react.useTranslation();
|
|
1365
1380
|
const { position, isDragging, handleMouseDown } = useDraggable({
|
|
1366
1381
|
panelSize: BUTTON_SIZE,
|
|
1367
1382
|
storageKey: STORAGE_KEYS.BUTTON_POSITION
|
|
1368
1383
|
});
|
|
1369
|
-
const dragStartPosition =
|
|
1384
|
+
const dragStartPosition = React4.useRef(null);
|
|
1370
1385
|
const handleButtonMouseDown = (e) => {
|
|
1371
1386
|
dragStartPosition.current = { x: e.clientX, y: e.clientY };
|
|
1372
1387
|
handleMouseDown(e);
|