@noya-app/noya-designsystem 0.1.9 → 0.1.10

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.
@@ -5,13 +5,13 @@
5
5
  CLI Target: esnext
6
6
  CJS Build start
7
7
  ESM Build start
8
- ESM dist/index.mjs 185.59 KB
9
- ESM dist/index.mjs.map 411.74 KB
10
- ESM ⚡️ Build success in 79ms
11
- CJS dist/index.js 201.80 KB
12
- CJS dist/index.js.map 411.93 KB
13
- CJS ⚡️ Build success in 80ms
8
+ ESM dist/index.mjs 186.07 KB
9
+ ESM dist/index.mjs.map 412.81 KB
10
+ ESM ⚡️ Build success in 109ms
11
+ CJS dist/index.js 202.28 KB
12
+ CJS dist/index.js.map 413.01 KB
13
+ CJS ⚡️ Build success in 112ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 6041ms
16
- DTS dist/index.d.ts 54.34 KB
17
- DTS dist/index.d.mts 54.34 KB
15
+ DTS ⚡️ Build success in 6370ms
16
+ DTS dist/index.d.ts 54.64 KB
17
+ DTS dist/index.d.mts 54.64 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @noya-app/noya-designsystem
2
2
 
3
+ ## 0.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - c93caa1: Improve menu style
8
+ - Updated dependencies [c93caa1]
9
+ - @noya-app/noya-keymap@0.1.1
10
+
3
11
  ## 0.1.9
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@ import React__default, { CSSProperties, ReactNode, ReactElement, ComponentProps,
3
3
  import * as styled_components from 'styled-components';
4
4
  import { CSSObject, CSSProperties as CSSProperties$1 } from 'styled-components';
5
5
  import * as DialogPrimitive from '@radix-ui/react-dialog';
6
+ import * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';
6
7
  import { Sketch } from '@noya-app/noya-file-format';
7
8
  import * as csstype from 'csstype';
8
9
  import { Property } from 'csstype';
@@ -40,6 +41,7 @@ declare const ButtonElement: styled_components.StyledComponent<"button", styled_
40
41
  variant: ButtonVariant;
41
42
  size: ButtonSize;
42
43
  flex?: CSSProperties["flex"];
44
+ defaultBackground?: string | undefined;
43
45
  }, never>;
44
46
  interface ButtonRootProps {
45
47
  id?: string;
@@ -56,6 +58,7 @@ interface ButtonRootProps {
56
58
  onClick?: (event: React__default.MouseEvent) => void;
57
59
  onPointerDown?: (event: React__default.PointerEvent) => void;
58
60
  contentStyle?: CSSProperties;
61
+ defaultBackground?: string;
59
62
  as?: React__default.ElementType;
60
63
  href?: string;
61
64
  target?: string;
@@ -291,7 +294,7 @@ declare const DraggableMenuButton: <T extends string>(props: {
291
294
  declare const DropdownMenu: <T extends string>(props: MenuProps<T> & {
292
295
  open?: boolean | undefined;
293
296
  onCloseAutoFocus?: ((event: React__default.SyntheticEvent<unknown, Event>) => void) | undefined;
294
- } & React__default.RefAttributes<HTMLElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
297
+ } & Pick<RadixDropdownMenu.DropdownMenuContentProps & React__default.RefAttributes<HTMLDivElement>, "side" | "sideOffset" | "align" | "alignOffset" | "collisionPadding"> & React__default.RefAttributes<HTMLElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
295
298
 
296
299
  declare const SUPPORTED_IMAGE_UPLOAD_TYPES: ("image/png" | "image/jpeg" | "image/webp" | "image/svg+xml" | "application/pdf")[];
297
300
  declare const SUPPORTED_CANVAS_UPLOAD_TYPES: ("" | "image/png" | "image/jpeg" | "image/webp" | "image/svg+xml" | "application/pdf")[];
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import React__default, { CSSProperties, ReactNode, ReactElement, ComponentProps,
3
3
  import * as styled_components from 'styled-components';
4
4
  import { CSSObject, CSSProperties as CSSProperties$1 } from 'styled-components';
5
5
  import * as DialogPrimitive from '@radix-ui/react-dialog';
6
+ import * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';
6
7
  import { Sketch } from '@noya-app/noya-file-format';
7
8
  import * as csstype from 'csstype';
8
9
  import { Property } from 'csstype';
@@ -40,6 +41,7 @@ declare const ButtonElement: styled_components.StyledComponent<"button", styled_
40
41
  variant: ButtonVariant;
41
42
  size: ButtonSize;
42
43
  flex?: CSSProperties["flex"];
44
+ defaultBackground?: string | undefined;
43
45
  }, never>;
44
46
  interface ButtonRootProps {
45
47
  id?: string;
@@ -56,6 +58,7 @@ interface ButtonRootProps {
56
58
  onClick?: (event: React__default.MouseEvent) => void;
57
59
  onPointerDown?: (event: React__default.PointerEvent) => void;
58
60
  contentStyle?: CSSProperties;
61
+ defaultBackground?: string;
59
62
  as?: React__default.ElementType;
60
63
  href?: string;
61
64
  target?: string;
@@ -291,7 +294,7 @@ declare const DraggableMenuButton: <T extends string>(props: {
291
294
  declare const DropdownMenu: <T extends string>(props: MenuProps<T> & {
292
295
  open?: boolean | undefined;
293
296
  onCloseAutoFocus?: ((event: React__default.SyntheticEvent<unknown, Event>) => void) | undefined;
294
- } & React__default.RefAttributes<HTMLElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
297
+ } & Pick<RadixDropdownMenu.DropdownMenuContentProps & React__default.RefAttributes<HTMLDivElement>, "side" | "sideOffset" | "align" | "alignOffset" | "collisionPadding"> & React__default.RefAttributes<HTMLElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
295
298
 
296
299
  declare const SUPPORTED_IMAGE_UPLOAD_TYPES: ("image/png" | "image/jpeg" | "image/webp" | "image/svg+xml" | "application/pdf")[];
297
300
  declare const SUPPORTED_CANVAS_UPLOAD_TYPES: ("" | "image/png" | "image/jpeg" | "image/webp" | "image/svg+xml" | "application/pdf")[];
package/dist/index.js CHANGED
@@ -230,94 +230,104 @@ var Tooltip = (0, import_react3.memo)(function Tooltip2({ children, content }) {
230
230
  });
231
231
 
232
232
  // src/components/Button.tsx
233
- var ButtonElement = import_styled_components4.default.button(({ theme, active, disabled, variant, size: size2, flex }) => ({
234
- ...size2 === "large" ? theme.textStyles.heading4 : theme.textStyles.small,
235
- textDecoration: "none",
236
- lineHeight: "1",
237
- flex: flex ?? "0 0 auto",
238
- position: "relative",
239
- border: "0",
240
- outline: "none",
241
- WebkitAppRegion: "no-drag",
242
- userSelect: "none",
243
- minWidth: variant === "normal" ? "31px" : void 0,
244
- textAlign: "left",
245
- borderRadius: "4px",
246
- paddingTop: variant === "none" ? "0px" : "4px",
247
- paddingRight: variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
248
- paddingBottom: variant === "none" ? "0px" : "4px",
249
- paddingLeft: variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
250
- ...size2 === "large" && {
251
- paddingTop: "12px",
252
- paddingRight: "16px",
253
- paddingBottom: "12px",
254
- paddingLeft: "16px"
255
- },
256
- background: active ? theme.colors.primary : variant === "primaryGradient" ? `linear-gradient(90deg, ${theme.colors.primary}, ${theme.colors.primaryLight})` : variant === "none" || variant === "thin" ? "transparent" : theme.colors.inputBackground,
257
- color: active ? "white" : theme.colors.text,
258
- opacity: disabled ? 0.25 : 1,
259
- "&:focus": {
260
- boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${theme.colors.primary}`
261
- },
262
- "&:hover": {
263
- background: variant === "primaryGradient" || active ? theme.colors.primaryLight : theme.colors.inputBackgroundLight
264
- },
265
- "&:active": {
266
- background: variant === "primaryGradient" ? theme.colors.primary : theme.colors.activeBackground
267
- },
268
- ...variant === "primary" && {
269
- background: theme.colors.primary,
270
- color: "white",
271
- "&:hover": {
272
- background: theme.colors.primaryLight
233
+ var ButtonElement = import_styled_components4.default.button(
234
+ ({
235
+ theme,
236
+ active,
237
+ disabled,
238
+ variant,
239
+ size: size2,
240
+ flex,
241
+ defaultBackground = theme.colors.inputBackground
242
+ }) => ({
243
+ ...size2 === "large" ? theme.textStyles.heading4 : theme.textStyles.small,
244
+ textDecoration: "none",
245
+ lineHeight: "1",
246
+ flex: flex ?? "0 0 auto",
247
+ position: "relative",
248
+ border: "0",
249
+ outline: "none",
250
+ WebkitAppRegion: "no-drag",
251
+ userSelect: "none",
252
+ minWidth: variant === "normal" ? "31px" : void 0,
253
+ textAlign: "left",
254
+ borderRadius: "4px",
255
+ paddingTop: variant === "none" ? "0px" : "4px",
256
+ paddingRight: variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
257
+ paddingBottom: variant === "none" ? "0px" : "4px",
258
+ paddingLeft: variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
259
+ ...size2 === "large" && {
260
+ paddingTop: "12px",
261
+ paddingRight: "16px",
262
+ paddingBottom: "12px",
263
+ paddingLeft: "16px"
273
264
  },
274
- "&:active": {
275
- background: theme.colors.primary
276
- }
277
- },
278
- ...variant === "secondary" && {
279
- background: theme.colors.secondary,
280
- color: "white",
281
- "&:hover": {
282
- background: theme.colors.secondaryLight
265
+ background: active ? theme.colors.primary : variant === "primaryGradient" ? `linear-gradient(90deg, ${theme.colors.primary}, ${theme.colors.primaryLight})` : variant === "none" || variant === "thin" ? "transparent" : defaultBackground,
266
+ color: active ? "white" : theme.colors.text,
267
+ opacity: disabled ? 0.25 : 1,
268
+ "&:focus": {
269
+ boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${theme.colors.primary}`
283
270
  },
284
- "&:active": {
285
- background: theme.colors.secondary
286
- }
287
- },
288
- ...variant === "secondaryBright" && {
289
- background: "#0ab557",
290
- color: "white",
291
271
  "&:hover": {
292
- opacity: 0.8
272
+ background: variant === "primaryGradient" || active ? theme.colors.primaryLight : theme.colors.inputBackgroundLight
293
273
  },
294
274
  "&:active": {
295
- opacity: 0.9
296
- }
297
- },
298
- ...variant === "white" && {
299
- background: "white",
300
- "&:hover": {
301
- opacity: 0.8
275
+ background: variant === "primaryGradient" || active ? theme.colors.primary : theme.colors.activeBackground
302
276
  },
303
- "&:active": {
304
- opacity: 0.9
277
+ ...variant === "primary" && {
278
+ background: theme.colors.primary,
279
+ color: "white",
280
+ "&:hover": {
281
+ background: theme.colors.primaryLight
282
+ },
283
+ "&:active": {
284
+ background: theme.colors.primary
285
+ }
286
+ },
287
+ ...variant === "secondary" && {
288
+ background: theme.colors.secondary,
289
+ color: "white",
290
+ "&:hover": {
291
+ background: theme.colors.secondaryLight
292
+ },
293
+ "&:active": {
294
+ background: theme.colors.secondary
295
+ }
296
+ },
297
+ ...variant === "secondaryBright" && {
298
+ background: "#0ab557",
299
+ color: "white",
300
+ "&:hover": {
301
+ opacity: 0.8
302
+ },
303
+ "&:active": {
304
+ opacity: 0.9
305
+ }
306
+ },
307
+ ...variant === "white" && {
308
+ background: "white",
309
+ "&:hover": {
310
+ opacity: 0.8
311
+ },
312
+ "&:active": {
313
+ opacity: 0.9
314
+ }
315
+ },
316
+ ...variant === "floating" && {
317
+ background: "white",
318
+ color: theme.colors.text,
319
+ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)",
320
+ fontSize: "12px",
321
+ padding: "0px 4px"
322
+ },
323
+ display: "flex",
324
+ alignItems: "center",
325
+ justifyContent: "center",
326
+ "& *": {
327
+ pointerEvents: "none"
305
328
  }
306
- },
307
- ...variant === "floating" && {
308
- background: "white",
309
- color: theme.colors.text,
310
- boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)",
311
- fontSize: "12px",
312
- padding: "0px 4px"
313
- },
314
- display: "flex",
315
- alignItems: "center",
316
- justifyContent: "center",
317
- "& *": {
318
- pointerEvents: "none"
319
- }
320
- }));
329
+ })
330
+ );
321
331
  var ButtonContent = import_styled_components4.default.span(({ theme }) => ({
322
332
  // Line height of small text - maybe figure out better way to ensure
323
333
  // icons don't have a smaller height
@@ -341,6 +351,7 @@ var Button = (0, import_react4.forwardRef)(function Button2({
341
351
  variant = "normal",
342
352
  size: size2 = "normal",
343
353
  contentStyle,
354
+ defaultBackground,
344
355
  onClick,
345
356
  children,
346
357
  ...rest
@@ -359,6 +370,7 @@ var Button = (0, import_react4.forwardRef)(function Button2({
359
370
  disabled,
360
371
  variant,
361
372
  size: size2,
373
+ defaultBackground,
362
374
  onClick,
363
375
  onDoubleClick: (0, import_react4.useCallback)((event) => {
364
376
  event.stopPropagation();
@@ -946,7 +958,7 @@ var styles = {
946
958
  separatorStyle: ({ theme }) => ({
947
959
  height: "1px",
948
960
  backgroundColor: theme.colors.divider,
949
- margin: "4px 8px"
961
+ margin: "4px -4px"
950
962
  }),
951
963
  itemStyle: ({
952
964
  theme,
@@ -959,7 +971,7 @@ var styles = {
959
971
  userSelect: "none",
960
972
  cursor: "pointer",
961
973
  borderRadius: "3px",
962
- padding: "4px 8px",
974
+ padding: "6px 8px",
963
975
  ...disabled && {
964
976
  color: theme.colors.textDisabled
965
977
  },
@@ -1090,7 +1102,16 @@ var DropdownMenuItem = (0, import_react26.memo)(function ContextMenuItem({
1090
1102
  }
1091
1103
  const element = /* @__PURE__ */ import_react26.default.createElement(ItemElement, { disabled, onSelect: handleSelectItem }, indented && /* @__PURE__ */ import_react26.default.createElement(Spacer.Horizontal, { size: CHECKBOX_WIDTH - CHECKBOX_RIGHT_INSET }), icon && /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, icon, /* @__PURE__ */ import_react26.default.createElement(Spacer.Horizontal, { size: 8 })), children, shortcut && /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, /* @__PURE__ */ import_react26.default.createElement(Spacer.Horizontal, null), /* @__PURE__ */ import_react26.default.createElement(Spacer.Horizontal, { size: 24 }), /* @__PURE__ */ import_react26.default.createElement(KeyboardShortcut, { shortcut })), items && items.length > 0 && /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, /* @__PURE__ */ import_react26.default.createElement(Spacer.Horizontal, null), /* @__PURE__ */ import_react26.default.createElement(Spacer.Horizontal, { size: 16 }), /* @__PURE__ */ import_react26.default.createElement(import_noya_icons.ChevronRightIcon, null)));
1092
1104
  if (items && items.length > 0) {
1093
- return /* @__PURE__ */ import_react26.default.createElement(DropdownMenuRoot, { isNested: true, items, onSelect }, element);
1105
+ return /* @__PURE__ */ import_react26.default.createElement(
1106
+ DropdownMenuRoot,
1107
+ {
1108
+ isNested: true,
1109
+ items,
1110
+ onSelect,
1111
+ alignOffset: -5
1112
+ },
1113
+ element
1114
+ );
1094
1115
  } else {
1095
1116
  return element;
1096
1117
  }
@@ -1105,7 +1126,12 @@ var DropdownMenuRoot = (0, import_react26.forwardRef)(function DropdownMenuRoot2
1105
1126
  shouldBindKeyboardShortcuts,
1106
1127
  onOpenChange,
1107
1128
  open,
1108
- onCloseAutoFocus
1129
+ onCloseAutoFocus,
1130
+ side,
1131
+ sideOffset = 4,
1132
+ align,
1133
+ alignOffset,
1134
+ collisionPadding = 8
1109
1135
  }, forwardedRef) {
1110
1136
  const hasCheckedItem = items.some(
1111
1137
  (item) => item !== SEPARATOR_ITEM && item.checked
@@ -1122,9 +1148,12 @@ var DropdownMenuRoot = (0, import_react26.forwardRef)(function DropdownMenuRoot2
1122
1148
  return /* @__PURE__ */ import_react26.default.createElement(RootComponent, { onOpenChange, open }, /* @__PURE__ */ import_react26.default.createElement(TriggerComponent, { ref: forwardedRef, asChild: true }, children), /* @__PURE__ */ import_react26.default.createElement(RadixDropdownMenu.Portal, null, /* @__PURE__ */ import_react26.default.createElement(
1123
1149
  ContentComponent,
1124
1150
  {
1125
- sideOffset: 4,
1151
+ side,
1152
+ sideOffset,
1153
+ align,
1154
+ alignOffset,
1126
1155
  style: contentStyle,
1127
- collisionPadding: 8,
1156
+ collisionPadding,
1128
1157
  ...{ onCloseAutoFocus }
1129
1158
  },
1130
1159
  items.map(