@mks2508/mks-ui 0.8.0 → 0.8.2

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.
@@ -15,8 +15,12 @@
15
15
  .gbtn-trigger {
16
16
  position: absolute;
17
17
  top: 0;
18
- left: 50%;
19
- transform: translateX(-50%);
18
+ /* Follow the pill's computed X (which honours `pillOffsetX`) instead of
19
+ * centring the hit-area in the host. Centring worked only while
20
+ * `pillOffsetX === 0`; any non-zero offset drifted the visual pill away
21
+ * from the invisible trigger. See `GooeyButton/index.tsx` — the host
22
+ * exposes `--gms-pill-x` identical to the primitive's internal value. */
23
+ left: var(--gms-pill-x);
20
24
  z-index: 3;
21
25
  width: var(--gms-pill-w);
22
26
  height: var(--gms-pill-h);
package/dist/index.css CHANGED
@@ -1520,8 +1520,12 @@
1520
1520
  .gbtn-trigger {
1521
1521
  position: absolute;
1522
1522
  top: 0;
1523
- left: 50%;
1524
- transform: translateX(-50%);
1523
+ /* Follow the pill's computed X (which honours `pillOffsetX`) instead of
1524
+ * centring the hit-area in the host. Centring worked only while
1525
+ * `pillOffsetX === 0`; any non-zero offset drifted the visual pill away
1526
+ * from the invisible trigger. See `GooeyButton/index.tsx` — the host
1527
+ * exposes `--gms-pill-x` identical to the primitive's internal value. */
1528
+ left: var(--gms-pill-x);
1525
1529
  z-index: 3;
1526
1530
  width: var(--gms-pill-w);
1527
1531
  height: var(--gms-pill-h);
@@ -9,7 +9,6 @@
9
9
  * @module components/devenv/terminal/panel/interactive-wterm
10
10
  */
11
11
  import type { ITerminalInteractivePanelProps, ITerminalInteractivePanelRef } from './TerminalInteractivePanel.types';
12
- import '@wterm/react/css';
13
12
  /**
14
13
  * TerminalInteractivePanelWterm Component.
15
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalInteractivePanelWterm.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelWterm.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAeH,OAAO,KAAK,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAWrH,OAAO,kBAAkB,CAAC;AAY1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,6BAA6B,yIAqOzC,CAAC"}
1
+ {"version":3,"file":"TerminalInteractivePanelWterm.d.ts","sourceRoot":"","sources":["../../../../../src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelWterm.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAcH,OAAO,KAAK,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAiDrH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,6BAA6B,yIA2PzC,CAAC"}
@@ -12,8 +12,6 @@ import { TerminalPanelChrome } from "./TerminalPanelChrome.js";
12
12
  import { WtermJsonTransport } from "../wterm/WtermJsonTransport.js";
13
13
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
14
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
- import { Terminal } from "@wterm/react";
16
- import "@wterm/react/css";
17
15
 
18
16
  //#region src/react-ui/blocks/Terminal/panel/TerminalInteractivePanelWterm.tsx
19
17
  /**
@@ -34,6 +32,24 @@ const terminalContainerStyles = "relative bg-[hsl(var(--terminal-bg,var(--backgr
34
32
  const MIN_FONT_SIZE = 10;
35
33
  const MAX_FONT_SIZE = 24;
36
34
  /**
35
+ * Lazy-loaded wterm Terminal component.
36
+ * Only loads if @wterm/react is installed, otherwise returns null.
37
+ */
38
+ let TerminalComponent = null;
39
+ let wtermLoadAttempted = false;
40
+ async function loadWtermTerminal() {
41
+ if (TerminalComponent !== null || wtermLoadAttempted) return TerminalComponent;
42
+ wtermLoadAttempted = true;
43
+ try {
44
+ TerminalComponent = (await import("@wterm/react")).Terminal;
45
+ await import("@wterm/react/css");
46
+ return TerminalComponent;
47
+ } catch {
48
+ TerminalComponent = null;
49
+ return null;
50
+ }
51
+ }
52
+ /**
37
53
  * TerminalInteractivePanelWterm Component.
38
54
  *
39
55
  * Interactive terminal panel combining:
@@ -76,6 +92,14 @@ const TerminalInteractivePanelWterm = forwardRef(({ containerName, wsUrl, sessio
76
92
  rows: 24
77
93
  });
78
94
  const [connectionStatus, setConnectionStatus] = useState("disconnected");
95
+ const [wtermAvailable, setWtermAvailable] = useState(null);
96
+ const [Terminal, setTerminal] = useState(null);
97
+ useEffect(() => {
98
+ loadWtermTerminal().then((term) => {
99
+ setTerminal(() => term);
100
+ setWtermAvailable(term !== null);
101
+ });
102
+ }, []);
79
103
  /**
80
104
  * Connect to MKS terminal server via WtermJsonTransport.
81
105
  */
@@ -223,22 +247,36 @@ const TerminalInteractivePanelWterm = forwardRef(({ containerName, wsUrl, sessio
223
247
  ref: containerRef,
224
248
  className: cn(terminalContainerStyles, "wterm-wrapper"),
225
249
  style: { "--wterm-font-size": `${fontSize}px` },
226
- children: [/* @__PURE__ */ jsx(Terminal, {
227
- ref: terminalRef,
228
- cols: dimensions.cols,
229
- rows: dimensions.rows,
230
- autoResize: false,
231
- cursorBlink: true,
232
- onData: handleData,
233
- onResize: handleResize,
234
- onReady: (wt) => {
235
- wt.focus();
236
- },
237
- className: "w-full h-full"
238
- }), /* @__PURE__ */ jsx(TerminalDisconnectedOverlay, {
239
- onReconnect: reconnect,
240
- visible: connectionStatus === "disconnected"
241
- })]
250
+ children: [
251
+ wtermAvailable === null && /* @__PURE__ */ jsx("div", {
252
+ className: "flex items-center justify-center h-full text-muted-foreground text-sm",
253
+ children: "Loading wterm..."
254
+ }),
255
+ wtermAvailable === false && /* @__PURE__ */ jsxs("div", {
256
+ className: "flex flex-col items-center justify-center h-full text-muted-foreground text-sm gap-2",
257
+ children: [/* @__PURE__ */ jsx("span", { children: "wterm is not installed" }), /* @__PURE__ */ jsx("code", {
258
+ className: "text-xs bg-muted px-2 py-1 rounded",
259
+ children: "bun add @wterm/react"
260
+ })]
261
+ }),
262
+ Terminal && wtermAvailable === true && /* @__PURE__ */ jsx(Terminal, {
263
+ ref: terminalRef,
264
+ cols: dimensions.cols,
265
+ rows: dimensions.rows,
266
+ autoResize: false,
267
+ cursorBlink: true,
268
+ onData: handleData,
269
+ onResize: handleResize,
270
+ onReady: (wt) => {
271
+ wt.focus();
272
+ },
273
+ className: "w-full h-full"
274
+ }),
275
+ /* @__PURE__ */ jsx(TerminalDisconnectedOverlay, {
276
+ onReconnect: reconnect,
277
+ visible: connectionStatus === "disconnected"
278
+ })
279
+ ]
242
280
  })
243
281
  });
244
282
  });
@@ -15,8 +15,12 @@
15
15
  .gbtn-trigger {
16
16
  position: absolute;
17
17
  top: 0;
18
- left: 50%;
19
- transform: translateX(-50%);
18
+ /* Follow the pill's computed X (which honours `pillOffsetX`) instead of
19
+ * centring the hit-area in the host. Centring worked only while
20
+ * `pillOffsetX === 0`; any non-zero offset drifted the visual pill away
21
+ * from the invisible trigger. See `GooeyButton/index.tsx` — the host
22
+ * exposes `--gms-pill-x` identical to the primitive's internal value. */
23
+ left: var(--gms-pill-x);
20
24
  z-index: 3;
21
25
  width: var(--gms-pill-w);
22
26
  height: var(--gms-pill-h);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/GooeyButton/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,cAAc,qBAAqB,CAAC;AAEpC;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAC3B,IAAI,EAAE,cAAc,EACpB,WAAmB,EACnB,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,aAAoB,EACpB,cAAqB,EACrB,QAAgB,EAChB,SAAS,EACT,KAAK,EACL,YAAY,EAAE,SAAoB,GAClC,EAAE,iBAAiB,2CA6EnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/GooeyButton/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,cAAc,qBAAqB,CAAC;AAEpC;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAC3B,IAAI,EAAE,cAAc,EACpB,WAAmB,EACnB,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,aAAoB,EACpB,cAAqB,EACrB,QAAgB,EAChB,SAAS,EACT,KAAK,EACL,YAAY,EAAE,SAAoB,GAClC,EAAE,iBAAiB,2CAyFnB"}
@@ -38,11 +38,20 @@ function GooeyButton({ open: controlledOpen, defaultOpen = false, onOpenChange,
38
38
  const hostStyle = useMemo(() => {
39
39
  const pillWidth = config?.pillWidth ?? DEFAULT_GOOEY_CONFIG.pillWidth;
40
40
  const pillHeight = config?.pillHeight ?? DEFAULT_GOOEY_CONFIG.pillHeight;
41
+ const cardWidth = config?.cardWidth ?? DEFAULT_GOOEY_CONFIG.cardWidth;
42
+ const pillOffsetX = config?.pillOffsetX ?? DEFAULT_GOOEY_CONFIG.pillOffsetX;
43
+ const pillX = (cardWidth - pillWidth) / 2 + pillOffsetX;
41
44
  return {
42
45
  "--gms-pill-w": `${pillWidth}px`,
43
- "--gms-pill-h": `${pillHeight}px`
46
+ "--gms-pill-h": `${pillHeight}px`,
47
+ "--gms-pill-x": `${pillX}px`
44
48
  };
45
- }, [config?.pillWidth, config?.pillHeight]);
49
+ }, [
50
+ config?.pillWidth,
51
+ config?.pillHeight,
52
+ config?.cardWidth,
53
+ config?.pillOffsetX
54
+ ]);
46
55
  const toggle = useCallback(() => {
47
56
  if (disabled) return;
48
57
  setOpen(!open);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mks2508/mks-ui",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "UI component library - Shadcn/Animate UI based with DevEnv components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -192,4 +192,4 @@
192
192
  "publishConfig": {
193
193
  "access": "public"
194
194
  }
195
- }
195
+ }