@noya-app/noya-designsystem 0.1.77 → 0.1.78

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.
Files changed (81) hide show
  1. package/.turbo/turbo-build.log +20 -12
  2. package/CHANGELOG.md +9 -0
  3. package/dist/chunk-D57E6H3M.mjs +36 -0
  4. package/dist/chunk-D57E6H3M.mjs.map +1 -0
  5. package/dist/emojis.d.mts +1 -0
  6. package/dist/emojis.d.ts +1 -0
  7. package/dist/emojis.js +31 -0
  8. package/dist/emojis.js.map +1 -0
  9. package/dist/emojis.mjs +8 -0
  10. package/dist/emojis.mjs.map +1 -0
  11. package/dist/index.css +1 -1
  12. package/dist/index.d.mts +142 -90
  13. package/dist/index.d.ts +142 -90
  14. package/dist/index.js +3171 -1745
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +3349 -1918
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +11 -7
  19. package/src/__tests__/__snapshots__/fuzzyScorer.test.ts.snap +1 -1
  20. package/src/components/Avatar.tsx +10 -10
  21. package/src/components/Banner.tsx +1 -1
  22. package/src/components/BaseToolbar.tsx +1 -1
  23. package/src/components/Button.tsx +2 -1
  24. package/src/components/Chip.tsx +1 -1
  25. package/src/components/ColorSwatchControl.tsx +22 -14
  26. package/src/components/CommandPalette.tsx +10 -6
  27. package/src/components/ContextMenu.tsx +249 -38
  28. package/src/components/Dialog.tsx +70 -67
  29. package/src/components/Drawer.tsx +56 -17
  30. package/src/components/DropdownMenu.tsx +305 -46
  31. package/src/components/EditableText.tsx +1 -1
  32. package/src/components/EmojiPicker.tsx +645 -0
  33. package/src/components/GridView.tsx +5 -1
  34. package/src/components/IVirtualizedList.tsx +21 -1
  35. package/src/components/InputField.tsx +2 -10
  36. package/src/components/InspectorContainer.tsx +4 -2
  37. package/src/components/Message.tsx +5 -16
  38. package/src/components/Popover.tsx +73 -107
  39. package/src/components/Progress.tsx +18 -18
  40. package/src/components/ScrollArea.tsx +66 -31
  41. package/src/components/ScrollableSidebar.tsx +1 -1
  42. package/src/components/SegmentedControl.tsx +166 -38
  43. package/src/components/SelectMenu.tsx +193 -101
  44. package/src/components/Slider.tsx +40 -38
  45. package/src/components/Switch.tsx +4 -4
  46. package/src/components/TextArea.tsx +1 -1
  47. package/src/components/Toast.tsx +99 -26
  48. package/src/components/Toolbar.tsx +114 -16
  49. package/src/components/Tooltip.tsx +18 -8
  50. package/src/components/Virtualized.tsx +193 -14
  51. package/src/components/VisuallyHidden.tsx +20 -0
  52. package/src/components/__tests__/Virtualized.math.test.ts +426 -1
  53. package/src/components/__tests__/Virtualized.test.tsx +129 -1
  54. package/src/components/ai-assistant/AIAssistantLayout.tsx +11 -6
  55. package/src/components/internal/Menu.tsx +4 -0
  56. package/src/components/listView/ListViewEditableRowTitle.tsx +1 -1
  57. package/src/components/listView/ListViewRoot.tsx +5 -1
  58. package/src/components/resizablePanels/Panel.tsx +94 -0
  59. package/src/components/resizablePanels/PanelGroup.tsx +498 -0
  60. package/src/components/resizablePanels/PanelGroupContext.tsx +14 -0
  61. package/src/components/resizablePanels/PanelResizeHandle.tsx +61 -0
  62. package/src/components/resizablePanels/index.ts +7 -0
  63. package/src/components/resizablePanels/types.ts +65 -0
  64. package/src/components/workspace/DrawerWorkspaceLayout.tsx +22 -7
  65. package/src/components/workspace/PanelWorkspaceLayout.tsx +30 -84
  66. package/src/components/workspace/WorkspaceLayout.tsx +28 -58
  67. package/src/components/workspace/types.ts +6 -4
  68. package/src/contexts/DialogContext.tsx +15 -24
  69. package/src/emojis.ts +1 -0
  70. package/src/hooks/useTriggerToggle.ts +95 -0
  71. package/src/index.css +2 -0
  72. package/src/index.tsx +1 -2
  73. package/src/theme/proseTheme.ts +2 -0
  74. package/src/utils/mergeProps.ts +57 -0
  75. package/src/utils/skinTone.ts +90 -0
  76. package/tsup.config.ts +1 -1
  77. package/src/__tests__/workspaceLayout.test.ts +0 -281
  78. package/src/components/ScrollArea2.tsx +0 -76
  79. package/src/components/internal/MenuViewport.tsx +0 -178
  80. package/src/components/internal/SelectItem.tsx +0 -138
  81. package/src/components/workspace/panelStorage.ts +0 -216
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { Dialog as DialogPrimitive, VisuallyHidden } from "radix-ui";
3
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
4
4
  import React, {
5
- ComponentProps,
6
5
  ForwardedRef,
7
6
  forwardRef,
8
7
  ReactNode,
@@ -12,24 +11,25 @@ import React, {
12
11
  import { cx } from "../utils/classNames";
13
12
  import { IconButton } from "./IconButton";
14
13
  import { Spacer } from "./Spacer";
14
+ import { VisuallyHidden } from "./VisuallyHidden";
15
15
 
16
- const StyledOverlay = forwardRef<
17
- React.ElementRef<typeof DialogPrimitive.Overlay>,
18
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
16
+ const StyledBackdrop = forwardRef<
17
+ HTMLDivElement,
18
+ React.HTMLAttributes<HTMLDivElement>
19
19
  >(({ className, ...props }, ref) => (
20
- <DialogPrimitive.Overlay
20
+ <DialogPrimitive.Backdrop
21
21
  ref={ref}
22
22
  className={cx(`n-fixed n-inset-0 n-bg-[rgba(0,0,0,0.5)]`, className)}
23
23
  {...props}
24
24
  />
25
25
  ));
26
26
 
27
- const StyledContent = forwardRef<
28
- React.ElementRef<typeof DialogPrimitive.Content>,
29
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
27
+ const StyledPopup = forwardRef<
28
+ HTMLDivElement,
29
+ React.HTMLAttributes<HTMLDivElement>
30
30
  >(({ className, children, ...props }, ref) => {
31
31
  return (
32
- <DialogPrimitive.Content
32
+ <DialogPrimitive.Popup
33
33
  ref={ref}
34
34
  className={cx(
35
35
  `n-fixed n-top-1/2 n-left-1/2 -n-translate-x-1/2 -n-translate-y-1/2 n-w-[90vw] n-max-w-[550px] n-max-h-[85vh] n-p-dialog-padding n-rounded-[2px] n-font-sans n-text-heading5 n-font-normal n-leading-[19px] n-text-text-muted n-bg-popover-background n-pointer-events-all n-z-[1000] focus:n-outline-none n-shadow-dialog-shadow n-flex n-flex-col`,
@@ -38,13 +38,13 @@ const StyledContent = forwardRef<
38
38
  {...props}
39
39
  >
40
40
  {children}
41
- </DialogPrimitive.Content>
41
+ </DialogPrimitive.Popup>
42
42
  );
43
43
  });
44
44
 
45
45
  const StyledTitle = forwardRef<
46
- React.ElementRef<typeof DialogPrimitive.Title>,
47
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
46
+ HTMLHeadingElement,
47
+ React.HTMLAttributes<HTMLHeadingElement>
48
48
  >(({ className, ...props }, ref) => (
49
49
  <DialogPrimitive.Title
50
50
  ref={ref}
@@ -57,8 +57,8 @@ const StyledTitle = forwardRef<
57
57
  ));
58
58
 
59
59
  const StyledDescription = forwardRef<
60
- React.ElementRef<typeof DialogPrimitive.Description>,
61
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
60
+ HTMLParagraphElement,
61
+ React.HTMLAttributes<HTMLParagraphElement>
62
62
  >(({ className, ...props }, ref) => (
63
63
  <DialogPrimitive.Description
64
64
  ref={ref}
@@ -78,12 +78,9 @@ interface Props {
78
78
  title?: ReactNode;
79
79
  description?: ReactNode;
80
80
  children?: ReactNode;
81
- style?: ComponentProps<typeof StyledContent>["style"];
82
- open: ComponentProps<typeof DialogPrimitive.Root>["open"];
83
- onOpenChange?: ComponentProps<typeof DialogPrimitive.Root>["onOpenChange"];
84
- onOpenAutoFocus?: ComponentProps<
85
- typeof DialogPrimitive.Content
86
- >["onOpenAutoFocus"];
81
+ style?: React.CSSProperties;
82
+ open: boolean;
83
+ onOpenChange?: (open: boolean) => void;
87
84
  closeOnInteractOutside?: boolean;
88
85
  showCloseButton?: boolean;
89
86
  className?: string;
@@ -97,8 +94,7 @@ export const Dialog = forwardRef(function Dialog(
97
94
  open,
98
95
  style,
99
96
  onOpenChange,
100
- onOpenAutoFocus,
101
- closeOnInteractOutside = true,
97
+ closeOnInteractOutside: _closeOnInteractOutside = true,
102
98
  className,
103
99
  showCloseButton = true,
104
100
  }: Props,
@@ -113,52 +109,59 @@ export const Dialog = forwardRef(function Dialog(
113
109
  },
114
110
  }));
115
111
 
112
+ const handleOpenChange = (newOpen: boolean) => {
113
+ onOpenChange?.(newOpen);
114
+ };
115
+
116
116
  return (
117
- <DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
118
- <StyledOverlay />
119
- <StyledContent
120
- ref={contentRef}
121
- onOpenAutoFocus={onOpenAutoFocus}
122
- style={style}
123
- className={className}
124
- aria-describedby={typeof description === "string" ? description : ""}
125
- {...(closeOnInteractOutside === false && {
126
- onPointerDownOutside: (event) => event.preventDefault(),
127
- onInteractOutside: (event) => event.preventDefault(),
128
- })}
129
- >
130
- {showCloseButton && (
131
- <DialogPrimitive.Close asChild>
132
- <IconButton
133
- iconName="Cross1Icon"
134
- className="n-z-[1]"
135
- style={{
136
- position: "absolute",
137
- top: "var(--n-dialog-padding)",
138
- right: "var(--n-dialog-padding)",
139
- }}
117
+ <DialogPrimitive.Root
118
+ open={open}
119
+ onOpenChange={handleOpenChange}
120
+ modal={true}
121
+ >
122
+ <DialogPrimitive.Portal>
123
+ <StyledBackdrop />
124
+ <StyledPopup
125
+ ref={contentRef}
126
+ style={style}
127
+ className={className}
128
+ aria-describedby={typeof description === "string" ? description : ""}
129
+ >
130
+ {showCloseButton && (
131
+ <DialogPrimitive.Close
132
+ render={
133
+ <IconButton
134
+ iconName="Cross1Icon"
135
+ className="n-z-[1]"
136
+ style={{
137
+ position: "absolute",
138
+ top: "var(--n-dialog-padding)",
139
+ right: "var(--n-dialog-padding)",
140
+ }}
141
+ />
142
+ }
140
143
  />
141
- </DialogPrimitive.Close>
142
- )}
143
- {title && (
144
- <>
145
- <StyledTitle>{title}</StyledTitle>
146
- <Spacer.Vertical size={description ? 10 : 20} />
147
- </>
148
- )}
149
- {!title && (
150
- <VisuallyHidden.Root>
151
- <StyledTitle>Dialog</StyledTitle>
152
- </VisuallyHidden.Root>
153
- )}
154
- {description && (
155
- <>
156
- <StyledDescription>{description}</StyledDescription>
157
- <Spacer.Vertical size={20} />
158
- </>
159
- )}
160
- {children}
161
- </StyledContent>
144
+ )}
145
+ {title && (
146
+ <>
147
+ <StyledTitle>{title}</StyledTitle>
148
+ <Spacer.Vertical size={description ? 10 : 20} />
149
+ </>
150
+ )}
151
+ {!title && (
152
+ <VisuallyHidden>
153
+ <StyledTitle>Dialog</StyledTitle>
154
+ </VisuallyHidden>
155
+ )}
156
+ {description && (
157
+ <>
158
+ <StyledDescription>{description}</StyledDescription>
159
+ <Spacer.Vertical size={20} />
160
+ </>
161
+ )}
162
+ {children}
163
+ </StyledPopup>
164
+ </DialogPrimitive.Portal>
162
165
  </DialogPrimitive.Root>
163
166
  );
164
167
  });
@@ -1,10 +1,12 @@
1
1
  "use client";
2
2
 
3
+ import { Dialog } from "@base-ui/react/dialog";
3
4
  import { useControlledOrUncontrolled } from "@noya-app/react-utils";
4
- import { Dialog } from "radix-ui";
5
5
  import * as React from "react";
6
6
  import { useImperativeHandle } from "react";
7
+ import { useTriggerToggle } from "../hooks/useTriggerToggle";
7
8
  import { cx } from "../utils/classNames";
9
+ import { mergePropsWithEventComposition } from "../utils/mergeProps";
8
10
  import { SidebarRef } from "./workspace/types";
9
11
 
10
12
  export type DrawerProps = {
@@ -22,6 +24,7 @@ export type DrawerProps = {
22
24
  side?: "left" | "right";
23
25
  portalled?: boolean;
24
26
  portalContainer?: HTMLElement | null;
27
+ modal?: boolean;
25
28
  };
26
29
 
27
30
  export const Drawer = React.memo(
@@ -41,6 +44,7 @@ export const Drawer = React.memo(
41
44
  portalContainer,
42
45
  overlayClassName,
43
46
  overlayStyle,
47
+ modal = true,
44
48
  }: DrawerProps,
45
49
  forwardedRef: React.ForwardedRef<SidebarRef>
46
50
  ) {
@@ -50,21 +54,30 @@ export const Drawer = React.memo(
50
54
  onChange: onOpenChange,
51
55
  });
52
56
 
53
- useImperativeHandle(forwardedRef, () => ({
54
- expand: () => {
55
- setInternalOpen(true);
56
- },
57
- collapse: () => {
58
- setInternalOpen(false);
59
- },
60
- isExpanded: () => {
61
- return internalOpen;
62
- },
63
- }));
57
+ const { setAnchorElement, popupRef, handleOpenChange } = useTriggerToggle(
58
+ internalOpen,
59
+ setInternalOpen
60
+ );
61
+
62
+ useImperativeHandle(
63
+ forwardedRef,
64
+ () => ({
65
+ expand: () => {
66
+ handleOpenChange(true);
67
+ },
68
+ collapse: () => {
69
+ handleOpenChange(false);
70
+ },
71
+ isExpanded: () => {
72
+ return internalOpen;
73
+ },
74
+ }),
75
+ [internalOpen, handleOpenChange]
76
+ );
64
77
 
65
78
  const inner = (
66
79
  <>
67
- <Dialog.Overlay
80
+ <Dialog.Backdrop
68
81
  className={cx(
69
82
  "n-inset-0 n-bg-black/50",
70
83
  positioning === "absolute" ? "n-absolute" : "n-fixed",
@@ -72,7 +85,8 @@ export const Drawer = React.memo(
72
85
  )}
73
86
  style={overlayStyle}
74
87
  />
75
- <Dialog.Content
88
+ <Dialog.Popup
89
+ ref={popupRef}
76
90
  id={id}
77
91
  style={style}
78
92
  className={cx(
@@ -84,7 +98,7 @@ export const Drawer = React.memo(
84
98
  >
85
99
  {title && <Dialog.Title>{title}</Dialog.Title>}
86
100
  {children}
87
- </Dialog.Content>
101
+ </Dialog.Popup>
88
102
  </>
89
103
  );
90
104
 
@@ -92,9 +106,34 @@ export const Drawer = React.memo(
92
106
  <Dialog.Root
93
107
  key="dialog"
94
108
  open={internalOpen}
95
- onOpenChange={setInternalOpen}
109
+ onOpenChange={handleOpenChange}
110
+ modal={modal}
96
111
  >
97
- <Dialog.Trigger key="trigger">{trigger}</Dialog.Trigger>
112
+ <Dialog.Trigger
113
+ key="trigger"
114
+ render={(triggerProps) => {
115
+ const element = React.isValidElement(trigger) ? (
116
+ trigger
117
+ ) : (
118
+ <span>{trigger}</span>
119
+ );
120
+ const childProps = element.props as Record<string, unknown>;
121
+ const mergedProps = mergePropsWithEventComposition(
122
+ triggerProps as Record<string, unknown>,
123
+ childProps
124
+ );
125
+
126
+ // Track anchor element for click detection
127
+ mergedProps.ref = (node: Element | null) => {
128
+ if (node) setAnchorElement(node);
129
+ };
130
+
131
+ return React.cloneElement(
132
+ element as React.ReactElement<any>,
133
+ mergedProps
134
+ );
135
+ }}
136
+ />
98
137
  {portalled ? (
99
138
  <Dialog.Portal container={portalContainer}>{inner}</Dialog.Portal>
100
139
  ) : (