@noya-app/noya-designsystem 0.1.6 → 0.1.7

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.6",
3
+ "version": "0.1.7",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -13,10 +13,10 @@
13
13
  "@dnd-kit/core": "3.1.1",
14
14
  "@dnd-kit/modifiers": "3.0.0",
15
15
  "@dnd-kit/sortable": "4.0.0",
16
- "@noya-app/noya-colorpicker": "0.1.4",
16
+ "@noya-app/noya-colorpicker": "0.1.5",
17
17
  "@noya-app/noya-utils": "0.1.0",
18
- "@noya-app/noya-geometry": "0.1.1",
19
- "@noya-app/noya-icons": "0.1.1",
18
+ "@noya-app/noya-geometry": "0.1.2",
19
+ "@noya-app/noya-icons": "0.1.2",
20
20
  "@noya-app/noya-keymap": "0.1.0",
21
21
  "@radix-ui/primitive": "^1.0.0",
22
22
  "@radix-ui/react-avatar": "^1.0.1",
@@ -35,8 +35,8 @@ export const DraggableMenuButton = memo(function DraggableMenuButton<
35
35
  onSelect,
36
36
  isVisible = true,
37
37
  }: {
38
- items: MenuItem<T>[];
39
- onSelect: (value: T) => void;
38
+ items?: MenuItem<T>[];
39
+ onSelect?: (value: T) => void;
40
40
  isVisible?: boolean;
41
41
  }) {
42
42
  const color = useDesignSystemTheme().colors.icon;
@@ -98,19 +98,25 @@ export const DraggableMenuButton = memo(function DraggableMenuButton<
98
98
  event.preventDefault();
99
99
  }}
100
100
  >
101
- <DropdownMenu
102
- open={open}
103
- onOpenChange={handleOpenChange}
104
- items={items}
105
- onSelect={onSelect}
106
- shouldBindKeyboardShortcuts={false}
107
- >
108
- <TriggerElement>
109
- <DragHandleDots2Icon
110
- color={isVisible || open ? color : "transparent"}
111
- />
112
- </TriggerElement>
113
- </DropdownMenu>
101
+ {items && onSelect ? (
102
+ <DropdownMenu
103
+ open={open}
104
+ onOpenChange={handleOpenChange}
105
+ items={items}
106
+ onSelect={onSelect}
107
+ shouldBindKeyboardShortcuts={false}
108
+ >
109
+ <TriggerElement>
110
+ <DragHandleDots2Icon
111
+ color={isVisible || open ? color : "transparent"}
112
+ />
113
+ </TriggerElement>
114
+ </DropdownMenu>
115
+ ) : (
116
+ <DragHandleDots2Icon
117
+ color={isVisible || open ? color : "transparent"}
118
+ />
119
+ )}
114
120
  </DotButtonElement>
115
121
  );
116
122
  });
@@ -90,6 +90,7 @@ export const RowLabel = styled.span<{
90
90
  fontWeight: "bold",
91
91
  }),
92
92
  lineHeight: "19px", // Button height
93
+ alignItems: "center",
93
94
  }));
94
95
 
95
96
  export const LabeledRow = memo(function LabeledRow({
@@ -332,6 +332,7 @@ interface ListViewRowProps<MenuItemType extends string = string> {
332
332
  onContextMenu?: () => void;
333
333
  onMenuOpenChange?: (isOpen: boolean) => void;
334
334
  onKeyDown?: (event: React.KeyboardEvent) => void;
335
+ style?: CSSProperties;
335
336
  }
336
337
 
337
338
  const ListViewRow = forwardRef(function ListViewRow<
@@ -357,6 +358,7 @@ const ListViewRow = forwardRef(function ListViewRow<
357
358
  onSelectMenuItem,
358
359
  onMenuOpenChange,
359
360
  onKeyDown,
361
+ style,
360
362
  }: ListViewRowProps<MenuItemType>,
361
363
  forwardedRef: ForwardedRef<HTMLElement>
362
364
  ) {
@@ -402,15 +404,16 @@ const ListViewRow = forwardRef(function ListViewRow<
402
404
  [onDoubleClick]
403
405
  );
404
406
 
405
- const isDraggingStyle = useMemo(() => {
407
+ const mergedStyle = useMemo(() => {
406
408
  return isDragging
407
409
  ? {
408
410
  // TODO: Where do these offsets actually come from?
409
411
  transform: `translate3d(-36px, -6px, 0)`,
410
412
  width: `calc(100% + 48px)`,
413
+ ...style,
411
414
  }
412
- : undefined;
413
- }, [isDragging]);
415
+ : style;
416
+ }, [isDragging, style]);
414
417
 
415
418
  const renderContent = (
416
419
  {
@@ -443,7 +446,7 @@ const ListViewRow = forwardRef(function ListViewRow<
443
446
  aria-selected={selected}
444
447
  divider={!isDragging && divider}
445
448
  onKeyDown={onKeyDown}
446
- style={isDraggingStyle}
449
+ style={mergedStyle}
447
450
  {...renderProps}
448
451
  {...mergeEventHandlers(
449
452
  { onPointerDown: renderProps.onPointerDown },
@@ -655,7 +658,9 @@ type RenderProps<T> = {
655
658
  renderItem: (item: T, index: number, info: ListViewItemInfo) => ReactNode;
656
659
  keyExtractor: (item: T, index: number) => string;
657
660
  /**
658
- * Each item must have an `id` in order to be sortable
661
+ * Each item must have an `id` in order to be sortable.
662
+ *
663
+ * Additionally, the key extracted with `keyExtractor` must match the ListItem.Row `id`.
659
664
  */
660
665
  sortable?: boolean;
661
666
  virtualized?: Size;
@@ -87,7 +87,7 @@ type ChildrenProps<T> =
87
87
  children: ReactNode;
88
88
  }
89
89
  | {
90
- options: T[];
90
+ options: readonly T[];
91
91
  getTitle?: (option: T, index: number) => string;
92
92
  onChange: (value: T) => void;
93
93
  };