@noya-app/noya-designsystem 0.1.8 → 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 183.55 KB
9
- ESM dist/index.mjs.map 407.50 KB
10
- ESM ⚡️ Build success in 103ms
11
- CJS dist/index.js 199.76 KB
12
- CJS dist/index.js.map 407.69 KB
13
- CJS ⚡️ Build success in 103ms
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 5984ms
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,19 @@
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
+
11
+ ## 0.1.9
12
+
13
+ ### Patch Changes
14
+
15
+ - @noya-app/noya-colorpicker@0.1.7
16
+
3
17
  ## 0.1.8
4
18
 
5
19
  ### 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();
@@ -791,6 +803,85 @@ var import_react22 = require("react");
791
803
  var import_noya_utils4 = require("@noya-app/noya-utils");
792
804
  var import_react23 = require("react");
793
805
 
806
+ // ../emitter/src/index.ts
807
+ var Emitter = class {
808
+ constructor(options = {}) {
809
+ this.bufferEventsIfNoListeners = options.bufferEventsIfNoListeners ?? false;
810
+ }
811
+ bufferEventsIfNoListeners;
812
+ listeners = [];
813
+ addListener = (f, options = {}) => {
814
+ if (options.once) {
815
+ const handler = (...args) => {
816
+ this.removeListener(handler);
817
+ return f(...args);
818
+ };
819
+ this.listeners.push(handler);
820
+ } else {
821
+ this.listeners.push(f);
822
+ }
823
+ if (this.bufferedEvents.length > 0) {
824
+ const eventsToEmit = this.bufferedEvents;
825
+ this.bufferedEvents = [];
826
+ eventsToEmit.forEach((event) => {
827
+ this.emit(...event);
828
+ });
829
+ }
830
+ return () => this.removeListener(f);
831
+ };
832
+ removeListener = (f) => {
833
+ const index = this.listeners.indexOf(f);
834
+ if (index === -1)
835
+ return;
836
+ this.listeners.splice(index, 1);
837
+ };
838
+ emit = (...args) => {
839
+ if (this.bufferEventsIfNoListeners && this.listeners.length === 0) {
840
+ this.bufferedEvents.push(args);
841
+ return;
842
+ }
843
+ this.listeners.forEach((l) => l(...args));
844
+ };
845
+ bufferedEvents = [];
846
+ };
847
+
848
+ // ../noya-react-utils/src/utils/ClientStorage.ts
849
+ var ClientStorage = class {
850
+ getItem(storageKey) {
851
+ if (typeof localStorage === "undefined") {
852
+ return null;
853
+ }
854
+ return localStorage.getItem(storageKey);
855
+ }
856
+ setItem(storageKey, value) {
857
+ if (typeof localStorage === "undefined") {
858
+ return;
859
+ }
860
+ if (value === null) {
861
+ localStorage.removeItem(storageKey);
862
+ } else {
863
+ localStorage.setItem(storageKey, value);
864
+ }
865
+ this.emitter.emit(storageKey, value);
866
+ }
867
+ emitter = new Emitter();
868
+ _isListening = false;
869
+ addListener(storageKey, listener) {
870
+ if (!this._isListening && typeof window !== "undefined") {
871
+ this._isListening = true;
872
+ window.addEventListener("storage", (event) => {
873
+ this.emitter.emit(event.key, event.newValue);
874
+ });
875
+ }
876
+ return this.emitter.addListener((key, value) => {
877
+ if (key === storageKey) {
878
+ listener(value);
879
+ }
880
+ });
881
+ }
882
+ };
883
+ var clientStorage = new ClientStorage();
884
+
794
885
  // ../noya-react-utils/src/utils/assignRef.ts
795
886
  function assignRef(ref, value) {
796
887
  if (typeof ref === "function") {
@@ -867,7 +958,7 @@ var styles = {
867
958
  separatorStyle: ({ theme }) => ({
868
959
  height: "1px",
869
960
  backgroundColor: theme.colors.divider,
870
- margin: "4px 8px"
961
+ margin: "4px -4px"
871
962
  }),
872
963
  itemStyle: ({
873
964
  theme,
@@ -880,7 +971,7 @@ var styles = {
880
971
  userSelect: "none",
881
972
  cursor: "pointer",
882
973
  borderRadius: "3px",
883
- padding: "4px 8px",
974
+ padding: "6px 8px",
884
975
  ...disabled && {
885
976
  color: theme.colors.textDisabled
886
977
  },
@@ -1011,7 +1102,16 @@ var DropdownMenuItem = (0, import_react26.memo)(function ContextMenuItem({
1011
1102
  }
1012
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)));
1013
1104
  if (items && items.length > 0) {
1014
- 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
+ );
1015
1115
  } else {
1016
1116
  return element;
1017
1117
  }
@@ -1026,7 +1126,12 @@ var DropdownMenuRoot = (0, import_react26.forwardRef)(function DropdownMenuRoot2
1026
1126
  shouldBindKeyboardShortcuts,
1027
1127
  onOpenChange,
1028
1128
  open,
1029
- onCloseAutoFocus
1129
+ onCloseAutoFocus,
1130
+ side,
1131
+ sideOffset = 4,
1132
+ align,
1133
+ alignOffset,
1134
+ collisionPadding = 8
1030
1135
  }, forwardedRef) {
1031
1136
  const hasCheckedItem = items.some(
1032
1137
  (item) => item !== SEPARATOR_ITEM && item.checked
@@ -1043,9 +1148,12 @@ var DropdownMenuRoot = (0, import_react26.forwardRef)(function DropdownMenuRoot2
1043
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(
1044
1149
  ContentComponent,
1045
1150
  {
1046
- sideOffset: 4,
1151
+ side,
1152
+ sideOffset,
1153
+ align,
1154
+ alignOffset,
1047
1155
  style: contentStyle,
1048
- collisionPadding: 8,
1156
+ collisionPadding,
1049
1157
  ...{ onCloseAutoFocus }
1050
1158
  },
1051
1159
  items.map(