@noya-app/noya-designsystem 0.1.77 → 0.1.79

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 (83) hide show
  1. package/.turbo/turbo-build.log +20 -12
  2. package/CHANGELOG.md +15 -0
  3. package/dist/chunk-D57E6H3M.mjs +36 -0
  4. package/dist/chunk-D57E6H3M.mjs.map +1 -0
  5. package/dist/chunk-FJ6ZGZIA.mjs +43 -0
  6. package/dist/chunk-FJ6ZGZIA.mjs.map +1 -0
  7. package/dist/emojis.d.mts +1 -0
  8. package/dist/emojis.d.ts +1 -0
  9. package/dist/emojis.js +31 -0
  10. package/dist/emojis.js.map +1 -0
  11. package/dist/emojis.mjs +8 -0
  12. package/dist/emojis.mjs.map +1 -0
  13. package/dist/index.css +1 -1
  14. package/dist/index.d.mts +142 -90
  15. package/dist/index.d.ts +142 -90
  16. package/dist/index.js +30559 -6412
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +35081 -10928
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +13 -17
  21. package/src/__tests__/__snapshots__/fuzzyScorer.test.ts.snap +1 -1
  22. package/src/components/Avatar.tsx +10 -10
  23. package/src/components/Banner.tsx +1 -1
  24. package/src/components/BaseToolbar.tsx +1 -1
  25. package/src/components/Button.tsx +2 -1
  26. package/src/components/Chip.tsx +1 -1
  27. package/src/components/ColorSwatchControl.tsx +22 -14
  28. package/src/components/CommandPalette.tsx +10 -6
  29. package/src/components/ContextMenu.tsx +249 -38
  30. package/src/components/Dialog.tsx +70 -67
  31. package/src/components/Drawer.tsx +56 -17
  32. package/src/components/DropdownMenu.tsx +305 -46
  33. package/src/components/EditableText.tsx +1 -1
  34. package/src/components/EmojiPicker.tsx +645 -0
  35. package/src/components/GridView.tsx +5 -1
  36. package/src/components/IVirtualizedList.tsx +21 -1
  37. package/src/components/InputField.tsx +2 -10
  38. package/src/components/InspectorContainer.tsx +4 -2
  39. package/src/components/Message.tsx +5 -16
  40. package/src/components/Popover.tsx +73 -107
  41. package/src/components/Progress.tsx +18 -18
  42. package/src/components/ScrollArea.tsx +66 -31
  43. package/src/components/ScrollableSidebar.tsx +1 -1
  44. package/src/components/SegmentedControl.tsx +166 -38
  45. package/src/components/SelectMenu.tsx +193 -101
  46. package/src/components/Slider.tsx +40 -38
  47. package/src/components/Switch.tsx +4 -4
  48. package/src/components/TextArea.tsx +1 -1
  49. package/src/components/Toast.tsx +99 -26
  50. package/src/components/Toolbar.tsx +114 -16
  51. package/src/components/Tooltip.tsx +18 -8
  52. package/src/components/Virtualized.tsx +193 -14
  53. package/src/components/VisuallyHidden.tsx +20 -0
  54. package/src/components/__tests__/Virtualized.math.test.ts +426 -1
  55. package/src/components/__tests__/Virtualized.test.tsx +129 -1
  56. package/src/components/ai-assistant/AIAssistantLayout.tsx +11 -6
  57. package/src/components/internal/Menu.tsx +4 -0
  58. package/src/components/listView/ListViewEditableRowTitle.tsx +1 -1
  59. package/src/components/listView/ListViewRoot.tsx +5 -1
  60. package/src/components/resizablePanels/Panel.tsx +94 -0
  61. package/src/components/resizablePanels/PanelGroup.tsx +498 -0
  62. package/src/components/resizablePanels/PanelGroupContext.tsx +14 -0
  63. package/src/components/resizablePanels/PanelResizeHandle.tsx +61 -0
  64. package/src/components/resizablePanels/index.ts +7 -0
  65. package/src/components/resizablePanels/types.ts +65 -0
  66. package/src/components/workspace/DrawerWorkspaceLayout.tsx +22 -7
  67. package/src/components/workspace/PanelWorkspaceLayout.tsx +30 -84
  68. package/src/components/workspace/WorkspaceLayout.tsx +28 -58
  69. package/src/components/workspace/types.ts +6 -4
  70. package/src/contexts/DialogContext.tsx +15 -24
  71. package/src/emojis.ts +1 -0
  72. package/src/hooks/useTriggerToggle.ts +95 -0
  73. package/src/index.css +2 -0
  74. package/src/index.tsx +1 -2
  75. package/src/theme/proseTheme.ts +2 -0
  76. package/src/utils/mergeProps.ts +57 -0
  77. package/src/utils/skinTone.ts +90 -0
  78. package/tsup.config.ts +3 -1
  79. package/src/__tests__/workspaceLayout.test.ts +0 -281
  80. package/src/components/ScrollArea2.tsx +0 -76
  81. package/src/components/internal/MenuViewport.tsx +0 -178
  82. package/src/components/internal/SelectItem.tsx +0 -138
  83. package/src/components/workspace/panelStorage.ts +0 -216
@@ -1,138 +0,0 @@
1
- "use client";
2
-
3
- import { renderIcon } from "../Icons";
4
-
5
- import { Select } from "radix-ui";
6
- import React, { useCallback } from "react";
7
- import { cx } from "../../utils/classNames";
8
- import { Spacer } from "../Spacer";
9
- import { Checkmark } from "./Checkmark";
10
- import {
11
- CHECKBOX_INDENT_WIDTH,
12
- CHECKBOX_RIGHT_INSET,
13
- CHECKBOX_WIDTH,
14
- KeyboardShortcut,
15
- styles,
16
- } from "./Menu";
17
- import { MenuComponents } from "./MenuViewport";
18
-
19
- export const SelectItem = React.forwardRef(
20
- (
21
- {
22
- children,
23
- icon,
24
- disabled,
25
- checked,
26
- Components,
27
- value,
28
- onSelect,
29
- shortcut,
30
- indented,
31
- testSelected,
32
- ...props
33
- }: Select.SelectItemProps & {
34
- icon?: React.ReactNode;
35
- checked?: boolean | "indeterminate";
36
- Components: MenuComponents;
37
- onSelect?: (value: any) => void;
38
- shortcut?: string;
39
- indented?: boolean;
40
- testSelected?: boolean;
41
- },
42
- forwardedRef: React.ForwardedRef<HTMLDivElement>
43
- ) => {
44
- const handleSelectItem = useCallback(() => {
45
- if (!value) return;
46
- onSelect?.(value);
47
- }, [onSelect, value]);
48
-
49
- // Prevent the click from propagating outside the menu
50
- const cancelClickPropagation = useCallback(
51
- (event: React.MouseEvent<HTMLDivElement>) => {
52
- event.stopPropagation();
53
- },
54
- []
55
- );
56
-
57
- if (checked && Components.CheckboxItem) {
58
- return (
59
- <div className="n-px-1">
60
- <Components.CheckboxItem
61
- checked={checked}
62
- disabled={disabled}
63
- onSelect={handleSelectItem}
64
- className={cx(
65
- styles.itemStyle({ disabled }),
66
- styles.selectedItemStyle,
67
- testSelected && styles.testSelectedItemStyle
68
- )}
69
- >
70
- <Spacer.Horizontal size={CHECKBOX_INDENT_WIDTH} />
71
- {Components.ItemIndicator && (
72
- <Components.ItemIndicator {...styles.itemIndicator}>
73
- <Checkmark />
74
- </Components.ItemIndicator>
75
- )}
76
- {icon && (
77
- <>
78
- {renderIcon(icon)}
79
- <Spacer.Horizontal size={8} />
80
- </>
81
- )}
82
- {children}
83
- {shortcut && (
84
- <>
85
- <Spacer.Horizontal />
86
- <Spacer.Horizontal size={24} />
87
- <KeyboardShortcut shortcut={shortcut} />
88
- </>
89
- )}
90
- </Components.CheckboxItem>
91
- </div>
92
- );
93
- }
94
-
95
- return (
96
- <div className="n-px-1">
97
- <Components.Item
98
- className={cx(
99
- styles.itemStyle({ disabled }),
100
- styles.selectedItemStyle,
101
- testSelected && styles.testSelectedItemStyle
102
- )}
103
- disabled={disabled}
104
- value={value}
105
- ref={forwardedRef}
106
- onClick={cancelClickPropagation}
107
- onSelect={handleSelectItem}
108
- {...props}
109
- >
110
- <div className="n-flex n-flex-1 n-items-center">
111
- {indented && <Spacer.Horizontal size={CHECKBOX_INDENT_WIDTH} />}
112
- {checked ? (
113
- <div {...styles.itemIndicator}>
114
- <Checkmark />
115
- </div>
116
- ) : indented ? (
117
- <Spacer.Horizontal size={CHECKBOX_WIDTH - CHECKBOX_RIGHT_INSET} />
118
- ) : null}
119
- {icon && (
120
- <>
121
- {renderIcon(icon)}
122
- <Spacer.Horizontal size={8} />
123
- </>
124
- )}
125
- <Components.ItemText>{children}</Components.ItemText>
126
- {shortcut && (
127
- <>
128
- <Spacer.Horizontal />
129
- <Spacer.Horizontal size={24} />
130
- <KeyboardShortcut shortcut={shortcut} />
131
- </>
132
- )}
133
- </div>
134
- </Components.Item>
135
- </div>
136
- );
137
- }
138
- );
@@ -1,216 +0,0 @@
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
- }