@noya-app/noya-designsystem 0.1.19 → 0.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noya-app/noya-designsystem",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "@radix-ui/react-utils": "^0.0.5",
37
37
  "immer": "9.0.5",
38
38
  "kiwi.js": "^1.1.3",
39
- "react-resizable-panels": "2.0.16",
39
+ "react-resizable-panels": "2.0.22",
40
40
  "react-virtualized": "^9.22.3",
41
41
  "react-window": "^1.8.8",
42
42
  "vscode-fuzzy-scorer": "^0.0.4"
@@ -46,7 +46,8 @@ const ChipElement = styled.span<{
46
46
  userSelect: "none",
47
47
  display: "inline-flex",
48
48
  alignItems: "center",
49
- lineHeight: "1.4",
49
+ // lineHeight: "1.4",
50
+ lineHeight: "15px",
50
51
  whiteSpace: "pre",
51
52
  ...($size === "medium"
52
53
  ? {
@@ -56,7 +57,6 @@ const ChipElement = styled.span<{
56
57
  : {
57
58
  fontSize: "9px",
58
59
  padding: "0px 4px",
59
- lineHeight: "15px",
60
60
  }),
61
61
  ...($monospace && {
62
62
  fontFamily: theme.fonts.monospace,
@@ -322,7 +322,11 @@ export const InputElement = styled(TextInput)<{
322
322
 
323
323
  const InputFieldInput = forwardRef(function InputFieldInput(
324
324
  // onFocusChange should only be passed from the root, never directly
325
- props: TextInputProps & {
325
+ {
326
+ textAlign,
327
+ variant,
328
+ ...rest
329
+ }: TextInputProps & {
326
330
  textAlign?: Property.TextAlign;
327
331
  variant?: "bare";
328
332
  },
@@ -357,8 +361,10 @@ const InputFieldInput = forwardRef(function InputFieldInput(
357
361
  $hasLabel={hasLabel}
358
362
  $hasDropdown={hasDropdown}
359
363
  $size={size}
364
+ $variant={variant}
365
+ $textAlign={textAlign}
360
366
  onFocusChange={handleFocusChange}
361
- {...props}
367
+ {...rest}
362
368
  />
363
369
  );
364
370
  });
@@ -1,4 +1,4 @@
1
- import { Stack, useDesignSystemTheme } from "@noya-app/noya-designsystem";
1
+ import { useDesignSystemTheme } from "@noya-app/noya-designsystem";
2
2
  import { useKeyboardShortcuts } from "@noya-app/noya-keymap";
3
3
  import React, { forwardRef, useImperativeHandle, useRef } from "react";
4
4
  import {
@@ -26,9 +26,24 @@ interface Props {
26
26
  hasRightSidebar?: boolean;
27
27
  hasLeftSidebar?: boolean;
28
28
  onChangeLayoutState?: (layoutState: PanelLayoutState) => void;
29
- leftSidebarInitialSize?: number;
30
- rightSidebarInitialSize?: number;
31
29
  leftSidebarCanResize?: boolean;
30
+ id?: string;
31
+ className?: string;
32
+ style?: React.CSSProperties;
33
+
34
+ /**
35
+ * Accepts a number (px) or % string (e.g. "50%").
36
+ * Use % to avoid flicker server-rendering.
37
+ */
38
+ leftSidebarInitialSize?: number | string;
39
+ leftSidebarMinSize?: number | string;
40
+
41
+ /**
42
+ * Accepts a number (px) or % string (e.g. "50%").
43
+ * Use % to avoid flicker server-rendering.
44
+ */
45
+ rightSidebarInitialSize?: number | string;
46
+ rightSidebarMinSize?: number | string;
32
47
  }
33
48
 
34
49
  export type IWorkspaceLayout = {
@@ -50,15 +65,32 @@ export const WorkspaceLayout = forwardRef(function WorkspaceLayout(
50
65
  onChangeLayoutState,
51
66
  leftSidebarInitialSize = 280,
52
67
  rightSidebarInitialSize = 400,
68
+ leftSidebarMinSize,
69
+ rightSidebarMinSize,
53
70
  leftSidebarCanResize = false,
71
+ id,
72
+ className,
73
+ style,
54
74
  }: Props,
55
75
  forwardedRef: React.ForwardedRef<IWorkspaceLayout>
56
76
  ) {
57
77
  const windowSize = useWindowSize();
58
- const leftSidebarPercentage =
59
- (leftSidebarInitialSize / windowSize.width) * 100;
60
- const rightSidebarPercentage =
61
- (rightSidebarInitialSize / windowSize.width) * 100;
78
+ function getPercentage(size: number | string) {
79
+ return typeof size === "string"
80
+ ? parseFloat(size)
81
+ : (size / windowSize.width) * 100;
82
+ }
83
+ const leftSidebarPercentage = getPercentage(leftSidebarInitialSize);
84
+ const rightSidebarPercentage = getPercentage(rightSidebarInitialSize);
85
+ const leftSidebarMinPercentage =
86
+ leftSidebarMinSize !== undefined
87
+ ? getPercentage(leftSidebarMinSize)
88
+ : undefined;
89
+ const rightSidebarMinPercentage =
90
+ rightSidebarMinSize !== undefined
91
+ ? getPercentage(rightSidebarMinSize)
92
+ : undefined;
93
+
62
94
  const panelGroupRef = useRef<ImperativePanelGroupHandle>(null);
63
95
  const leftSidebarRef = useRef<ImperativePanelHandle>(null);
64
96
  const rightSidebarRef = useRef<ImperativePanelHandle>(null);
@@ -129,8 +161,22 @@ export const WorkspaceLayout = forwardRef(function WorkspaceLayout(
129
161
  },
130
162
  });
131
163
 
164
+ const centerPanelPercentage =
165
+ 100 -
166
+ (leftPanelContent ? leftSidebarPercentage : 0) -
167
+ (rightPanelContent ? rightSidebarPercentage : 0);
168
+
132
169
  return (
133
- <Stack.H flex="1">
170
+ <div
171
+ id={id}
172
+ className={className}
173
+ style={{
174
+ backgroundColor: theme.colors.canvas.background,
175
+ display: "flex",
176
+ flexDirection: "row",
177
+ ...style,
178
+ }}
179
+ >
134
180
  <PanelGroup
135
181
  ref={panelGroupRef}
136
182
  id={EDITOR_PANEL_GROUP_ID}
@@ -149,7 +195,7 @@ export const WorkspaceLayout = forwardRef(function WorkspaceLayout(
149
195
  order={1}
150
196
  ref={leftSidebarRef}
151
197
  defaultSize={leftSidebarPercentage}
152
- minSize={leftSidebarPercentage}
198
+ minSize={leftSidebarMinPercentage ?? leftSidebarPercentage}
153
199
  {...(!leftSidebarCanResize && { maxSize: leftSidebarPercentage })}
154
200
  collapsible
155
201
  style={{
@@ -172,6 +218,7 @@ export const WorkspaceLayout = forwardRef(function WorkspaceLayout(
172
218
  <Panel
173
219
  id={CONTENT_AREA_ID}
174
220
  order={2}
221
+ defaultSize={centerPanelPercentage}
175
222
  minSize={10}
176
223
  style={{
177
224
  display: "flex",
@@ -194,7 +241,7 @@ export const WorkspaceLayout = forwardRef(function WorkspaceLayout(
194
241
  id={RIGHT_SIDEBAR_ID}
195
242
  order={3}
196
243
  ref={rightSidebarRef}
197
- minSize={rightSidebarPercentage}
244
+ minSize={rightSidebarMinPercentage ?? rightSidebarPercentage}
198
245
  defaultSize={rightSidebarPercentage}
199
246
  collapsible
200
247
  style={{
@@ -207,6 +254,6 @@ export const WorkspaceLayout = forwardRef(function WorkspaceLayout(
207
254
  </>
208
255
  )}
209
256
  </PanelGroup>
210
- </Stack.H>
257
+ </div>
211
258
  );
212
259
  });
@@ -162,7 +162,8 @@ export const textStyles = {
162
162
  fontFamily: fonts.normal,
163
163
  fontSize: `${typeScale[6]}rem`,
164
164
  fontWeight: 400,
165
- lineHeight: "1.4",
165
+ lineHeight: "19px",
166
+ // lineHeight: "1.4",
166
167
  } as CSSObject,
167
168
  button: {
168
169
  fontFamily: fonts.normal,