@noya-app/noya-designsystem 0.1.62 → 0.1.64

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 (118) hide show
  1. package/.eslintrc.js +1 -5
  2. package/.turbo/turbo-build.log +10 -10
  3. package/.turbo/turbo-lint.log +0 -1
  4. package/CHANGELOG.md +23 -0
  5. package/dist/index.css +1 -1
  6. package/dist/index.d.mts +299 -179
  7. package/dist/index.d.ts +299 -179
  8. package/dist/index.js +3772 -2999
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +3485 -2720
  11. package/dist/index.mjs.map +1 -1
  12. package/package.json +10 -22
  13. package/src/__tests__/validateDropIndicator.test.ts +26 -41
  14. package/src/__tests__/workspaceLayout.test.ts +281 -0
  15. package/src/components/ActionMenu.tsx +2 -0
  16. package/src/components/ActivityIndicator.tsx +5 -3
  17. package/src/components/AnimatePresence.tsx +6 -4
  18. package/src/components/Avatar.tsx +4 -2
  19. package/src/components/BaseToolbar.tsx +45 -34
  20. package/src/components/Breadcrumbs.tsx +2 -0
  21. package/src/components/Button.tsx +35 -21
  22. package/src/components/Chip.tsx +2 -0
  23. package/src/components/Collection.tsx +4 -1
  24. package/src/components/ColorSwatch.tsx +42 -22
  25. package/src/components/ColorSwatchControl.tsx +5 -3
  26. package/src/components/Combobox.tsx +2 -0
  27. package/src/components/CommandPalette.tsx +2 -0
  28. package/src/components/ContextMenu.tsx +3 -1
  29. package/src/components/Dialog.tsx +3 -1
  30. package/src/components/DimensionInput.tsx +3 -1
  31. package/src/components/Divider.tsx +10 -6
  32. package/src/components/DraggableMenuButton.tsx +22 -4
  33. package/src/components/Drawer.tsx +11 -3
  34. package/src/components/DropdownMenu.tsx +34 -6
  35. package/src/components/EditableText.tsx +2 -0
  36. package/src/components/FileUploadIndicator.tsx +108 -0
  37. package/src/components/FillPreviewBackground.tsx +2 -0
  38. package/src/components/FloatingWindow.tsx +2 -0
  39. package/src/components/GradientPicker.tsx +2 -0
  40. package/src/components/Grid.tsx +47 -38
  41. package/src/components/GridView.tsx +33 -11
  42. package/src/components/IconButton.tsx +4 -2
  43. package/src/components/Icons.tsx +1 -1
  44. package/src/components/InputField.tsx +7 -5
  45. package/src/components/Label.tsx +1 -3
  46. package/src/components/LabeledElementView.tsx +6 -2
  47. package/src/components/LabeledField.tsx +38 -34
  48. package/src/components/List.tsx +10 -2
  49. package/src/components/ListView.tsx +27 -14
  50. package/src/components/MediaThumbnail.tsx +31 -2
  51. package/src/components/Message.tsx +8 -9
  52. package/src/components/Popover.tsx +15 -4
  53. package/src/components/Progress.tsx +20 -7
  54. package/src/components/ScrollArea.tsx +3 -1
  55. package/src/components/SearchCompletionMenu.tsx +2 -0
  56. package/src/components/Section.tsx +2 -0
  57. package/src/components/SegmentedControl.tsx +43 -17
  58. package/src/components/SelectMenu.tsx +6 -4
  59. package/src/components/SelectionToolbar.tsx +31 -8
  60. package/src/components/Slider.tsx +4 -2
  61. package/src/components/Spacer.tsx +0 -1
  62. package/src/components/Switch.tsx +3 -1
  63. package/src/components/Tabs.tsx +48 -0
  64. package/src/components/Text.tsx +6 -5
  65. package/src/components/TextArea.tsx +2 -0
  66. package/src/components/Toast.tsx +1 -1
  67. package/src/components/Toolbar.tsx +113 -12
  68. package/src/components/ToolbarDrawer.tsx +29 -0
  69. package/src/components/Tooltip.tsx +9 -9
  70. package/src/components/TreeView.tsx +2 -0
  71. package/src/components/UserPointer.tsx +2 -0
  72. package/src/components/ai-assistant/AIAssistantLayout.tsx +2 -0
  73. package/src/components/blocks/ImageBlockComponent.tsx +156 -0
  74. package/src/components/connected-users-menu/ConnectedUsersMenuLayout.tsx +2 -0
  75. package/src/components/file-explorer/FileExplorerLayout.tsx +14 -6
  76. package/src/components/internal/Checkmark.tsx +24 -0
  77. package/src/components/internal/Menu.tsx +21 -3
  78. package/src/components/internal/MenuViewport.tsx +8 -5
  79. package/src/components/internal/SelectItem.tsx +4 -23
  80. package/src/components/internal/TextInput.tsx +2 -0
  81. package/src/components/sorting/DragRegistration.tsx +8 -4
  82. package/src/components/sorting/SharedDragProvider.tsx +43 -18
  83. package/src/components/sorting/Sortable.tsx +19 -10
  84. package/src/components/sorting/createSharedDrag.tsx +7 -6
  85. package/src/components/sorting/sorting.ts +6 -9
  86. package/src/components/workspace/DrawerWorkspaceLayout.tsx +113 -28
  87. package/src/components/workspace/PanelWorkspaceLayout.tsx +149 -16
  88. package/src/components/workspace/VerticalTabMenu.tsx +36 -0
  89. package/src/components/workspace/WorkspaceLayout.tsx +132 -47
  90. package/src/components/workspace/constants.ts +4 -0
  91. package/src/components/workspace/panelStorage.ts +216 -0
  92. package/src/components/workspace/renderPanelChildren.tsx +12 -0
  93. package/src/components/workspace/types.ts +30 -7
  94. package/src/contexts/DesignSystemConfiguration.tsx +12 -5
  95. package/src/contexts/DialogContext.tsx +2 -0
  96. package/src/contexts/FloatingWindowContext.tsx +2 -0
  97. package/src/contexts/GlobalInputBlurContext.tsx +2 -0
  98. package/src/contexts/ImageDataContext.tsx +2 -0
  99. package/src/contexts/LinkComponentContext.tsx +17 -0
  100. package/src/contexts/OpenPortalsContext.tsx +2 -0
  101. package/src/contexts/PortalScopeContext.tsx +2 -0
  102. package/src/hooks/mergeEventHandlers.ts +1 -1
  103. package/src/hooks/useHover.ts +30 -17
  104. package/src/hooks/useIndent.ts +2 -0
  105. package/src/hooks/useLabel.ts +12 -10
  106. package/src/hooks/useObjectURL.ts +5 -3
  107. package/src/hooks/usePlatform.ts +5 -3
  108. package/src/hooks/useTheme.ts +3 -1
  109. package/src/index.css +25 -4
  110. package/src/index.tsx +7 -2
  111. package/src/utils/classNames.ts +4 -3
  112. package/src/utils/combobox.ts +2 -0
  113. package/src/utils/editableBlockStyles.ts +10 -0
  114. package/src/utils/formatByteSize.ts +8 -0
  115. package/src/utils/withSeparatorElements.ts +1 -1
  116. package/src/hooks/usePreservePanelSize.tsx +0 -183
  117. package/src/hooks/useWindowSize.tsx +0 -26
  118. package/src/mediaQuery.ts +0 -13
@@ -0,0 +1,216 @@
1
+ import { clientStorage, IClientStorage } from "@noya-app/react-utils";
2
+ import { PanelGroupStorage } from "react-resizable-panels";
3
+ import {
4
+ CONTENT_AREA_ID,
5
+ LEFT_SIDEBAR_ID,
6
+ RIGHT_SIDEBAR_ID,
7
+ } from "./constants";
8
+ import {
9
+ PercentageSidebarOptions,
10
+ WorkspaceLayoutGroup,
11
+ WorkspaceLayoutState,
12
+ } from "./types";
13
+
14
+ // Workspace sizes are stored as percentages (e.g. layout: [78.7224911972, 21.2775088028])
15
+ // we need to convert them to pixels relative to the window width before storing
16
+ // and convert them back to percentages when getting the item
17
+ export const panelStorage: PanelGroupStorage = {
18
+ getItem: (name) => {
19
+ const item = clientStorage.getItem(name);
20
+
21
+ if (item) {
22
+ const parsed = JSON.parse(item);
23
+ const percentageSize = mapWorkspaceLayoutState(parsed, (size) =>
24
+ toPercentageSize(size)
25
+ );
26
+ const stringified = JSON.stringify(percentageSize);
27
+ // console.log("getItem", name, stringified);
28
+ return stringified;
29
+ }
30
+
31
+ return item;
32
+ },
33
+
34
+ setItem: (name, value) => {
35
+ const parsed = JSON.parse(value);
36
+ const pixelSize = mapWorkspaceLayoutState(parsed, (size) =>
37
+ toPixelSize(size)
38
+ );
39
+ // console.log("setItem", name, pixelSize);
40
+ clientStorage.setItem(name, JSON.stringify(pixelSize));
41
+ },
42
+ };
43
+
44
+ export const toPixelSize = (size: number, windowWidth = window.innerWidth) =>
45
+ Math.round((size * windowWidth) / 100);
46
+ export const toPercentageSize = (
47
+ size: number,
48
+ windowWidth = window.innerWidth
49
+ ) => (size * 100) / windowWidth;
50
+
51
+ export function mapWorkspaceLayoutState(
52
+ layout: WorkspaceLayoutState,
53
+ f: (size: number) => number
54
+ ): WorkspaceLayoutState {
55
+ return Object.fromEntries(
56
+ Object.entries(layout).map(
57
+ ([key, value]): [string, WorkspaceLayoutGroup] => {
58
+ const expandToSizes = Object.fromEntries(
59
+ Object.entries(value.expandToSizes).map(([key, value]) => [
60
+ key,
61
+ f(value),
62
+ ])
63
+ );
64
+
65
+ return [
66
+ key,
67
+ {
68
+ expandToSizes,
69
+ layout: value.layout.map(f),
70
+ },
71
+ ];
72
+ }
73
+ )
74
+ );
75
+ }
76
+
77
+ export function getLayoutIds({
78
+ hasLeftPanel,
79
+ hasRightPanel,
80
+ hasCenterPanel,
81
+ }: {
82
+ hasLeftPanel: boolean;
83
+ hasRightPanel: boolean;
84
+ hasCenterPanel: boolean;
85
+ }) {
86
+ return [
87
+ hasLeftPanel && LEFT_SIDEBAR_ID,
88
+ hasCenterPanel && CONTENT_AREA_ID,
89
+ hasRightPanel && RIGHT_SIDEBAR_ID,
90
+ ].flatMap((id) => (id ? [id] : []));
91
+ }
92
+
93
+ export function getPropertyKey(layoutIds: string[]) {
94
+ return layoutIds.sort().join(",");
95
+ }
96
+
97
+ export function getStorageKey(autoSaveId: string) {
98
+ return `react-resizable-panels:${autoSaveId}`;
99
+ }
100
+
101
+ export function getInitialLayout({
102
+ layoutIds,
103
+ leftSidebarOptions,
104
+ rightSidebarOptions,
105
+ centerPanelPercentage,
106
+ hasLeftPanel,
107
+ hasRightPanel,
108
+ hasCenterPanel,
109
+ windowWidth = window.innerWidth,
110
+ }: {
111
+ layoutIds: string[];
112
+ leftSidebarOptions: PercentageSidebarOptions;
113
+ rightSidebarOptions: PercentageSidebarOptions;
114
+ centerPanelPercentage: number;
115
+ hasLeftPanel: boolean;
116
+ hasRightPanel: boolean;
117
+ hasCenterPanel: boolean;
118
+ windowWidth?: number;
119
+ }) {
120
+ return layoutIds.map((id) => {
121
+ if (id === LEFT_SIDEBAR_ID && hasLeftPanel) {
122
+ return leftSidebarOptions.defaultCollapsed
123
+ ? 0
124
+ : toPixelSize(leftSidebarOptions.initialSize ?? 0, windowWidth);
125
+ } else if (id === RIGHT_SIDEBAR_ID && hasRightPanel) {
126
+ return rightSidebarOptions.defaultCollapsed
127
+ ? 0
128
+ : toPixelSize(rightSidebarOptions.initialSize ?? 0, windowWidth);
129
+ } else if (id === CONTENT_AREA_ID && hasCenterPanel) {
130
+ const shouldShowLeftSidebar =
131
+ hasLeftPanel && !leftSidebarOptions.defaultCollapsed;
132
+ const shouldShowRightSidebar =
133
+ hasRightPanel && !rightSidebarOptions.defaultCollapsed;
134
+
135
+ if (!shouldShowLeftSidebar && !shouldShowRightSidebar) {
136
+ return toPixelSize(100, windowWidth);
137
+ }
138
+
139
+ return toPixelSize(centerPanelPercentage, windowWidth);
140
+ }
141
+ return 0;
142
+ });
143
+ }
144
+
145
+ export function setInitialLayout({
146
+ storageKey,
147
+ propertyKey,
148
+ calculateLayout,
149
+ storage = clientStorage,
150
+ }: {
151
+ storageKey: string;
152
+ propertyKey: string;
153
+ calculateLayout: () => number[];
154
+ storage?: IClientStorage;
155
+ }) {
156
+ const savedLayout = storage.getItem(storageKey);
157
+
158
+ if (!savedLayout) {
159
+ const layoutObject: WorkspaceLayoutState = {
160
+ [propertyKey]: {
161
+ layout: calculateLayout(),
162
+ expandToSizes: {},
163
+ },
164
+ };
165
+
166
+ storage.setItem(storageKey, JSON.stringify(layoutObject));
167
+ } else {
168
+ let parsedLayout: WorkspaceLayoutState;
169
+
170
+ try {
171
+ parsedLayout = JSON.parse(savedLayout);
172
+ } catch (error) {
173
+ console.error(error);
174
+ return;
175
+ }
176
+
177
+ if (!(propertyKey in parsedLayout)) {
178
+ const layoutObject: WorkspaceLayoutState = {
179
+ ...parsedLayout,
180
+ [propertyKey]: {
181
+ layout: calculateLayout(),
182
+ expandToSizes: {},
183
+ },
184
+ };
185
+
186
+ storage.setItem(storageKey, JSON.stringify(layoutObject));
187
+ }
188
+ }
189
+ }
190
+
191
+ export function getLayoutCollapsedState({
192
+ layoutGroup,
193
+ layoutIds,
194
+ hasLeftPanel,
195
+ hasRightPanel,
196
+ }: {
197
+ layoutGroup: WorkspaceLayoutGroup;
198
+ propertyKey: string;
199
+ layoutIds: string[];
200
+ hasLeftPanel: boolean;
201
+ hasRightPanel: boolean;
202
+ }) {
203
+ const propertySize = Object.fromEntries(
204
+ layoutIds.map((id, index) => [id, layoutGroup.layout?.[index]])
205
+ );
206
+
207
+ const leftSize = propertySize?.[LEFT_SIDEBAR_ID];
208
+ const leftSidebarCollapsed = hasLeftPanel && leftSize === 0 ? true : false;
209
+ const rightSize = propertySize?.[RIGHT_SIDEBAR_ID];
210
+ const rightSidebarCollapsed = hasRightPanel && rightSize === 0 ? true : false;
211
+
212
+ return {
213
+ leftSidebarCollapsed,
214
+ rightSidebarCollapsed,
215
+ };
216
+ }
@@ -0,0 +1,12 @@
1
+ import { RenderPanel } from "./types";
2
+
3
+ export function renderPanelChildren<TabValue extends string>(
4
+ fn: RenderPanel<TabValue>,
5
+ activeTabValue: TabValue
6
+ ) {
7
+ if (typeof fn === "function") {
8
+ return fn({ activeTabValue });
9
+ }
10
+
11
+ return fn;
12
+ }
@@ -1,3 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ import { MenuItem } from "../internal/Menu";
3
+
1
4
  export type SidebarRef = {
2
5
  expand: () => void;
3
6
  collapse: () => void;
@@ -9,6 +12,8 @@ export type PercentageSidebarOptions = {
9
12
  maxSize?: number;
10
13
  initialSize?: number;
11
14
  resizable?: boolean;
15
+ defaultCollapsed?: boolean;
16
+ showTabs?: boolean;
12
17
  };
13
18
 
14
19
  export type PanelLayoutState = {
@@ -16,16 +21,34 @@ export type PanelLayoutState = {
16
21
  rightSidebarCollapsed: boolean;
17
22
  };
18
23
 
19
- export type LayoutProps = {
20
- leftPanel: React.ReactNode;
21
- rightPanel: React.ReactNode;
24
+ export type RenderPanel<TabValue extends string> =
25
+ | ReactNode
26
+ | ((props: { activeTabValue: TabValue }) => ReactNode);
27
+
28
+ export type LayoutProps<
29
+ LeftTab extends string = string,
30
+ RightTab extends string = string,
31
+ > = {
32
+ leftPanel: ReactNode;
33
+ leftTabItems?: MenuItem<LeftTab>[];
34
+ leftTabValue?: LeftTab;
35
+ onChangeLeftTab?: (value: LeftTab) => void;
36
+ rightPanel: ReactNode;
37
+ rightTabItems?: MenuItem<RightTab>[];
38
+ rightTabValue?: RightTab;
39
+ onChangeRightTab?: (value: RightTab) => void;
22
40
  centerPanel: React.ReactNode;
23
41
  leftSidebarOptions: PercentageSidebarOptions;
24
42
  rightSidebarOptions: PercentageSidebarOptions;
25
43
  centerPanelPercentage: number;
26
44
  autoSavePrefix?: string;
27
- internalLayoutState: PanelLayoutState | null;
28
- leftSidebarRef: React.RefObject<SidebarRef>;
29
- rightSidebarRef: React.RefObject<SidebarRef>;
30
- handleChangeLayoutState: (state: PanelLayoutState) => void;
45
+ leftSidebarRef: React.RefObject<SidebarRef | null>;
46
+ rightSidebarRef: React.RefObject<SidebarRef | null>;
31
47
  };
48
+
49
+ export type WorkspaceLayoutGroup = {
50
+ expandToSizes: Record<string, number>;
51
+ layout: number[];
52
+ };
53
+
54
+ export type WorkspaceLayoutState = Record<string, WorkspaceLayoutGroup>;
@@ -1,8 +1,11 @@
1
+ "use client";
2
+
1
3
  import { getCurrentPlatform, PlatformName } from "@noya-app/noya-keymap";
2
4
  import * as React from "react";
3
5
  import { ToastProvider } from "../components/Toast";
4
6
  import { DialogProvider } from "./DialogContext";
5
7
  import { FloatingWindowProvider } from "./FloatingWindowContext";
8
+ import { LinkComponent, LinkComponentProvider } from "./LinkComponentContext";
6
9
  import { OpenPortalsProvider } from "./OpenPortalsContext";
7
10
 
8
11
  export type DesignSystemConfigurationContextValue = {
@@ -18,9 +21,11 @@ export const DesignSystemConfigurationProvider = React.memo(
18
21
  function DesignSystemConfigurationProvider({
19
22
  children,
20
23
  platform,
24
+ LinkComponent,
21
25
  }: {
22
26
  children: React.ReactNode;
23
27
  platform?: PlatformName;
28
+ LinkComponent?: LinkComponent;
24
29
  }) {
25
30
  const [internalPlatform, setInternalPlatform] =
26
31
  React.useState<PlatformName>(platform ?? "key");
@@ -41,11 +46,13 @@ export const DesignSystemConfigurationProvider = React.memo(
41
46
  return (
42
47
  <DesignSystemConfigurationContext.Provider value={contextValue}>
43
48
  <OpenPortalsProvider>
44
- <DialogProvider>
45
- <ToastProvider>
46
- <FloatingWindowProvider>{children}</FloatingWindowProvider>
47
- </ToastProvider>
48
- </DialogProvider>
49
+ <LinkComponentProvider value={LinkComponent}>
50
+ <DialogProvider>
51
+ <ToastProvider>
52
+ <FloatingWindowProvider>{children}</FloatingWindowProvider>
53
+ </ToastProvider>
54
+ </DialogProvider>
55
+ </LinkComponentProvider>
49
56
  </OpenPortalsProvider>
50
57
  </DesignSystemConfigurationContext.Provider>
51
58
  );
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import React, {
2
4
  createContext,
3
5
  ReactNode,
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import { uuid } from "@noya-app/noya-utils";
2
4
  import React, { createContext, useContext, useMemo, useState } from "react";
3
5
  import { createPortal } from "react-dom";
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import { createContext, useContext, useEffect } from 'react';
2
4
 
3
5
  export type GlobalInputBlurContextValue = {
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
 
3
5
  export type ImageDataContextValue = {
@@ -0,0 +1,17 @@
1
+ "use client";
2
+
3
+ import React, { createContext, useContext } from "react";
4
+
5
+ export type LinkComponent = React.ComponentType<React.ComponentProps<"a">>;
6
+
7
+ const LinkComponentContext = createContext<LinkComponent | undefined>(
8
+ undefined
9
+ );
10
+
11
+ export const LinkComponentProvider = LinkComponentContext.Provider;
12
+
13
+ export const useLinkComponent = () => {
14
+ const Link = useContext(LinkComponentContext);
15
+
16
+ return Link ?? "a";
17
+ };
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
 
3
5
  export type OpenPortalsContextValue = {
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
 
3
5
  export type PortalScopeContextValue = string;
@@ -1,7 +1,7 @@
1
1
  import { unique } from "@noya-app/noya-utils";
2
2
  import { composeEventHandlers } from "@radix-ui/primitive";
3
3
 
4
- function composeAllEventHandlers<E>(...handlers: ((e: E) => void)[]) {
4
+ function composeAllEventHandlers<E extends { defaultPrevented: boolean }>(...handlers: ((e: E) => void)[]) {
5
5
  const [first, ...rest] = handlers;
6
6
 
7
7
  return rest.reduce(
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  // From: https://github.com/radix-ui/primitives/blob/main/packages/react/scroll-area/src/useHover.ts
2
4
  // MIT License
3
5
 
@@ -8,13 +10,13 @@
8
10
  // @see https://github.com/adobe/react-spectrum/tree/452d1cb6a49f9f493757737edaf2b64014108de6/packages/%40react-aria
9
11
  // @see https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
10
12
 
11
- import * as React from 'react';
13
+ import * as React from "react";
12
14
 
13
15
  export interface HoverEvent {
14
16
  /** The type of hover event being fired. */
15
- type: 'hoverstart' | 'hoverend';
17
+ type: "hoverstart" | "hoverend";
16
18
  /** The pointer type that triggered the hover event. */
17
- pointerType: 'mouse' | 'pen';
19
+ pointerType: "mouse" | "pen";
18
20
  /** The target element of the hover event. */
19
21
  target: HTMLElement;
20
22
  }
@@ -58,17 +60,17 @@ function setGlobalIgnoreEmulatedMouseEvents() {
58
60
  }
59
61
 
60
62
  function handleGlobalPointerEvent(event: PointerEvent) {
61
- if (event.pointerType === 'touch') {
63
+ if (event.pointerType === "touch") {
62
64
  setGlobalIgnoreEmulatedMouseEvents();
63
65
  }
64
66
  }
65
67
 
66
68
  function setupGlobalTouchEvents() {
67
- if (typeof document === 'undefined') {
69
+ if (typeof document === "undefined") {
68
70
  return;
69
71
  }
70
72
 
71
- document.addEventListener('pointerup', handleGlobalPointerEvent);
73
+ document.addEventListener("pointerup", handleGlobalPointerEvent);
72
74
 
73
75
  hoverCount++;
74
76
  return function teardownGlobalTouchEvents() {
@@ -76,7 +78,7 @@ function setupGlobalTouchEvents() {
76
78
  if (hoverCount > 0) {
77
79
  return;
78
80
  }
79
- document.removeEventListener('pointerup', handleGlobalPointerEvent);
81
+ document.removeEventListener("pointerup", handleGlobalPointerEvent);
80
82
  };
81
83
  }
82
84
 
@@ -98,10 +100,14 @@ export function useHover(props: HoverProps = {}): HoverResult {
98
100
  const hoverProps = React.useMemo(
99
101
  function getHoverProps() {
100
102
  function triggerHoverStart(
101
- event: PointerEvent | React.PointerEvent | MouseEvent | React.MouseEvent,
102
- pointerType: 'mouse' | 'pen' | 'touch'
103
+ event:
104
+ | PointerEvent
105
+ | React.PointerEvent
106
+ | MouseEvent
107
+ | React.MouseEvent,
108
+ pointerType: "mouse" | "pen" | "touch"
103
109
  ) {
104
- if (isDisabled || pointerType === 'touch' || state.isHovered) {
110
+ if (isDisabled || pointerType === "touch" || state.isHovered) {
105
111
  return;
106
112
  }
107
113
 
@@ -110,7 +116,7 @@ export function useHover(props: HoverProps = {}): HoverResult {
110
116
 
111
117
  if (onHoverStart) {
112
118
  onHoverStart({
113
- type: 'hoverstart',
119
+ type: "hoverstart",
114
120
  target,
115
121
  pointerType,
116
122
  });
@@ -124,10 +130,14 @@ export function useHover(props: HoverProps = {}): HoverResult {
124
130
  }
125
131
 
126
132
  function triggerHoverEnd(
127
- event: PointerEvent | React.PointerEvent | MouseEvent | React.MouseEvent,
128
- pointerType: 'mouse' | 'pen' | 'touch'
133
+ event:
134
+ | PointerEvent
135
+ | React.PointerEvent
136
+ | MouseEvent
137
+ | React.MouseEvent,
138
+ pointerType: "mouse" | "pen" | "touch"
129
139
  ) {
130
- if (isDisabled || pointerType === 'touch' || !state.isHovered) {
140
+ if (isDisabled || pointerType === "touch" || !state.isHovered) {
131
141
  return;
132
142
  }
133
143
 
@@ -136,7 +146,7 @@ export function useHover(props: HoverProps = {}): HoverResult {
136
146
 
137
147
  if (onHoverEnd) {
138
148
  onHoverEnd({
139
- type: 'hoverend',
149
+ type: "hoverend",
140
150
  target,
141
151
  pointerType,
142
152
  });
@@ -151,7 +161,10 @@ export function useHover(props: HoverProps = {}): HoverResult {
151
161
 
152
162
  const hoverProps: React.HTMLAttributes<HTMLElement> = {
153
163
  onPointerEnter(event: React.PointerEvent<HTMLElement>) {
154
- if (globalIgnoreEmulatedMouseEvents && event.pointerType === 'mouse') {
164
+ if (
165
+ globalIgnoreEmulatedMouseEvents &&
166
+ event.pointerType === "mouse"
167
+ ) {
155
168
  return;
156
169
  }
157
170
  triggerHoverStart(event, event.pointerType);
@@ -170,4 +183,4 @@ export function useHover(props: HoverProps = {}): HoverResult {
170
183
  hoverProps,
171
184
  isHovered,
172
185
  };
173
- }
186
+ }
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import React from "react";
2
4
 
3
5
  export const IndentContext = React.createContext<{
@@ -1,5 +1,8 @@
1
+ "use client";
2
+
1
3
  import React, { ReactNode } from "react";
2
- import { LabelPosition } from "../components/Label";
4
+
5
+ export type LabelType = "inset" | "start" | "end" | "above" | "none";
3
6
 
4
7
  export const LabelContext = React.createContext<{
5
8
  fieldId?: string;
@@ -24,18 +27,17 @@ export const useLabel = ({ label, fieldId }: UseLabelParams) => {
24
27
  };
25
28
  };
26
29
 
27
- export const LabelPositionContext =
28
- React.createContext<LabelPositionContextValue>({
29
- position: "start",
30
- });
30
+ export const LabelTypeContext = React.createContext<LabelTypeContextValue>({
31
+ type: "start",
32
+ });
31
33
 
32
- export const useLabelPosition = () => {
33
- const { position } = React.useContext(LabelPositionContext);
34
- return position;
34
+ export const useLabelType = () => {
35
+ const { type } = React.useContext(LabelTypeContext);
36
+ return type;
35
37
  };
36
38
 
37
- export type LabelPositionContextValue = {
38
- position: LabelPosition;
39
+ export type LabelTypeContextValue = {
40
+ type: LabelType;
39
41
  };
40
42
 
41
43
  export type LabelWidthContextValue = {
@@ -1,4 +1,6 @@
1
- import { useLayoutEffect, useMemo } from 'react';
1
+ "use client";
2
+
3
+ import { useLayoutEffect, useMemo } from "react";
2
4
 
3
5
  export function useObjectURL(object?: ArrayBuffer | Uint8Array | Blob) {
4
6
  const objectURL = useMemo(() => {
@@ -8,8 +10,8 @@ export function useObjectURL(object?: ArrayBuffer | Uint8Array | Blob) {
8
10
  object instanceof Uint8Array
9
11
  ? object
10
12
  : object !== undefined
11
- ? new Uint8Array(object)
12
- : new Uint8Array();
13
+ ? new Uint8Array(object)
14
+ : new Uint8Array();
13
15
 
14
16
  return URL.createObjectURL(new Blob([bytes]));
15
17
  }, [object]);
@@ -1,4 +1,6 @@
1
- import { useDesignSystemConfiguration } from '../contexts/DesignSystemConfiguration';
1
+ "use client";
2
+
3
+ import { useDesignSystemConfiguration } from "../contexts/DesignSystemConfiguration";
2
4
 
3
5
  export function usePlatform() {
4
6
  return useDesignSystemConfiguration().platform;
@@ -7,7 +9,7 @@ export function usePlatform() {
7
9
  /**
8
10
  * Either ctrl or meta, depending on the platform
9
11
  */
10
- export function usePlatformModKey(): 'ctrlKey' | 'metaKey' {
12
+ export function usePlatformModKey(): "ctrlKey" | "metaKey" {
11
13
  const platform = useDesignSystemConfiguration().platform;
12
- return platform === 'mac' ? 'metaKey' : 'ctrlKey';
14
+ return platform === "mac" ? "metaKey" : "ctrlKey";
13
15
  }
@@ -1,4 +1,6 @@
1
- import { useState, useEffect } from "react";
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
2
4
 
3
5
  /** @default light */
4
6
  export type UseThemeReturnType = "dark" | "light";
package/src/index.css CHANGED
@@ -11,6 +11,7 @@
11
11
  --n-primary-150: rgb(225, 219, 255);
12
12
  --n-primary-100: rgb(234, 230, 255); /* --n-primary-pastel */
13
13
  --n-primary-50: rgb(243, 242, 255);
14
+ --n-primary-25: rgb(250, 248, 255);
14
15
 
15
16
  --n-indigo-950: rgb(18, 26, 37);
16
17
  --n-indigo-900: rgb(30, 40, 60);
@@ -58,6 +59,13 @@
58
59
  --n-button-background-active-hover: var(--n-primary-50);
59
60
  --n-button-text: var(--n-text);
60
61
  --n-button-text-active: var(--n-primary);
62
+ --n-toolbar-drawer-background: var(--n-primary-25);
63
+ --n-toolbar-drawer-border: color-mix(
64
+ in srgb,
65
+ var(--n-primary) 30%,
66
+ transparent
67
+ );
68
+ --n-toolbar-drawer-shadow: rgba(153, 153, 153, 0.25);
61
69
  --n-canvas-background: var(--n-indigo-25);
62
70
  --n-canvas-grid: rgba(0, 0, 0, 0.05);
63
71
  --n-sidebar-background: rgb(255, 255, 255);
@@ -69,6 +77,7 @@
69
77
  --n-list-view-thumbnail-background: var(--n-input-background);
70
78
  --n-slider-thumb-background: white;
71
79
  --n-slider-border: #9698ac;
80
+ --n-slider-active-background: var(--n-primary-600);
72
81
  --n-mask: rgb(12, 193, 67);
73
82
  --n-transparent-checker: rgba(255, 255, 255, 0.8);
74
83
  --n-scrollbar: rgba(199, 199, 199, 0.8);
@@ -150,17 +159,28 @@
150
159
  --n-primary: var(--n-primary-500);
151
160
  --n-primary-light: var(--n-primary-300);
152
161
  --n-icon: var(--n-text-muted);
153
- --n-selected-list-item-background: var(--n-primary-900);
162
+ --n-selected-list-item-background: var(--n-primary-700);
154
163
  --n-selected-list-item-text: var(--n-primary-100);
155
- --n-selected-list-item-icon-background: var(--n-primary-900);
164
+ --n-selected-list-item-icon-background: var(--n-primary-800);
156
165
  --n-button-background: var(--n-input-background);
157
166
  --n-button-background-hover: var(--n-input-background-light);
158
- --n-button-background-active: var(--n-primary-900);
159
- --n-button-background-active-hover: var(--n-primary-800);
167
+ --n-button-background-active: var(--n-primary-700);
168
+ --n-button-background-active-hover: var(--n-primary-600);
160
169
  --n-button-text: var(--n-text);
161
170
  --n-button-text-active: var(--n-primary-100);
162
171
  --n-secondary-bright: #36fe91;
163
172
  --n-code-background: rgb(20, 19, 23);
173
+ --n-toolbar-drawer-background: color-mix(
174
+ in srgb,
175
+ var(--n-primary-900) 50%,
176
+ var(--n-background)
177
+ );
178
+ --n-toolbar-drawer-border: color-mix(
179
+ in srgb,
180
+ var(--n-primary-700) 30%,
181
+ transparent
182
+ );
183
+ --n-toolbar-drawer-shadow: rgba(255, 255, 255, 0.1);
164
184
  --n-canvas-background: rgb(20, 19, 23);
165
185
  --n-canvas-grid: rgba(0, 0, 0, 0.1);
166
186
  --n-sidebar-background: rgb(34, 33, 39);
@@ -172,6 +192,7 @@
172
192
  --n-list-view-thumbnail-background: var(--n-input-background);
173
193
  --n-slider-thumb-background: var(--n-input-background-light);
174
194
  --n-slider-border: var(--n-divider);
195
+ --n-slider-active-background: var(--n-primary-700);
175
196
  --n-segmented-control-item-active-text: var(--n-text);
176
197
  --n-segmented-control-item-active-background: var(--n-input-background-light);
177
198
  --n-mask: rgb(102, 187, 106);