@noya-app/noya-designsystem 0.1.47 → 0.1.48

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 (41) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/CHANGELOG.md +10 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.d.mts +205 -106
  5. package/dist/index.d.ts +205 -106
  6. package/dist/index.js +2108 -1589
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +2078 -1566
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +6 -7
  11. package/src/__tests__/validateDropIndicator.test.ts +263 -0
  12. package/src/components/ActionMenu.tsx +40 -0
  13. package/src/components/ActivityIndicator.tsx +7 -1
  14. package/src/components/Collection.tsx +12 -2
  15. package/src/components/Combobox.tsx +14 -1
  16. package/src/components/ComboboxMenu.tsx +14 -5
  17. package/src/components/Dialog.tsx +17 -12
  18. package/src/components/Drawer.tsx +98 -0
  19. package/src/components/Grid.tsx +57 -27
  20. package/src/components/GridView.tsx +39 -25
  21. package/src/components/InputField.tsx +87 -92
  22. package/src/components/Label.tsx +7 -7
  23. package/src/components/List.tsx +42 -16
  24. package/src/components/ListView.tsx +21 -17
  25. package/src/components/MediaThumbnail.tsx +117 -0
  26. package/src/components/SearchCompletionMenu.tsx +30 -16
  27. package/src/components/SelectMenu.tsx +19 -17
  28. package/src/components/Sortable.tsx +70 -44
  29. package/src/components/internal/Menu.tsx +38 -23
  30. package/src/components/internal/MenuViewport.tsx +7 -1
  31. package/src/components/internal/SelectItem.tsx +51 -27
  32. package/src/components/internal/__tests__/Menu.test.tsx +12 -0
  33. package/src/components/workspace/DrawerWorkspaceLayout.tsx +86 -0
  34. package/src/components/workspace/PanelWorkspaceLayout.tsx +102 -0
  35. package/src/components/{WorkspaceLayout.tsx → workspace/WorkspaceLayout.tsx} +109 -106
  36. package/src/components/workspace/types.ts +31 -0
  37. package/src/contexts/DialogContext.tsx +49 -34
  38. package/src/hooks/usePreservePanelSize.tsx +1 -5
  39. package/src/index.css +1 -0
  40. package/src/index.tsx +4 -1
  41. package/tailwind.config.ts +1 -0
@@ -24,31 +24,26 @@ function createDeferredPromise<T>() {
24
24
  return { promise, resolve, reject };
25
25
  }
26
26
 
27
+ type RenderableProps = { close: () => void };
28
+
27
29
  export type DialogContextValue = {
28
- openDialog(options: {
29
- title: string;
30
- description?: ReactNode;
31
- children: ReactNode;
32
- }): Promise<void>;
30
+ openDialog(
31
+ options: BaseDialogContents & {
32
+ children: ReactNode | ((props: RenderableProps) => ReactNode);
33
+ }
34
+ ): Promise<void>;
33
35
 
34
36
  openInputDialog(
35
37
  options:
36
38
  | string
37
- | {
38
- title: string;
39
- description?: ReactNode;
39
+ | (BaseDialogContents & {
40
40
  placeholder?: string;
41
41
  initialValue?: string;
42
- }
42
+ })
43
43
  ): Promise<string | undefined>;
44
44
 
45
45
  openConfirmationDialog(
46
- options:
47
- | string
48
- | {
49
- title: string;
50
- description?: ReactNode;
51
- }
46
+ options: string | BaseDialogContents
52
47
  ): Promise<boolean>;
53
48
 
54
49
  containsElement(element: HTMLElement): boolean;
@@ -56,26 +51,27 @@ export type DialogContextValue = {
56
51
 
57
52
  const DialogContext = createContext<DialogContextValue | undefined>(undefined);
58
53
 
59
- type InputDialogContents = {
60
- type: "input";
54
+ type BaseDialogContents = {
55
+ style?: React.CSSProperties;
56
+ className?: string;
61
57
  title: string;
62
58
  description?: ReactNode;
59
+ };
60
+
61
+ type InputDialogContents = BaseDialogContents & {
62
+ type: "input";
63
63
  placeholder?: string;
64
64
  inputValue: string;
65
65
  resolve: (value: string | undefined) => void;
66
66
  };
67
67
 
68
- type ConfirmationDialogContents = {
68
+ type ConfirmationDialogContents = BaseDialogContents & {
69
69
  type: "confirmation";
70
- title: string;
71
- description?: ReactNode;
72
70
  resolve: (value: boolean) => void;
73
71
  };
74
72
 
75
- type CustomDialogContents = {
73
+ type CustomDialogContents = BaseDialogContents & {
76
74
  type: "custom";
77
- title: string;
78
- description?: ReactNode;
79
75
  children: ReactNode;
80
76
  resolve: () => void;
81
77
  };
@@ -95,16 +91,20 @@ export const DialogProvider = function DialogProvider({
95
91
  const isOpen = !!contents;
96
92
 
97
93
  const close = useCallback(() => {
98
- if (!contents) return;
99
-
100
- if (contents.type === "input") {
101
- contents.resolve(undefined);
102
- } else {
103
- contents.resolve(false);
94
+ if (contents) {
95
+ if (contents.type === "input") {
96
+ contents.resolve(undefined);
97
+ } else {
98
+ contents.resolve(false);
99
+ }
104
100
  }
101
+
105
102
  setContents(undefined);
106
103
  }, [contents]);
107
104
 
105
+ const closeRef = useRef(close);
106
+ closeRef.current = close;
107
+
108
108
  const submit = useCallback(() => {
109
109
  if (!contents || contents.type !== "input") return;
110
110
 
@@ -115,7 +115,7 @@ export const DialogProvider = function DialogProvider({
115
115
  const open: DialogContextValue["openInputDialog"] = useCallback((options) => {
116
116
  const { promise, resolve } = createDeferredPromise<string | undefined>();
117
117
 
118
- const { title, description, initialValue, placeholder } =
118
+ const { title, description, initialValue, placeholder, style, className } =
119
119
  typeof options === "string" ? { title: options } : options;
120
120
 
121
121
  setContents({
@@ -124,6 +124,8 @@ export const DialogProvider = function DialogProvider({
124
124
  description,
125
125
  inputValue: initialValue ?? "",
126
126
  placeholder,
127
+ style,
128
+ className,
127
129
  resolve: (value: string | undefined) => {
128
130
  resolve(value);
129
131
  setContents(undefined);
@@ -137,13 +139,15 @@ export const DialogProvider = function DialogProvider({
137
139
  useCallback((options) => {
138
140
  const { promise, resolve } = createDeferredPromise<boolean>();
139
141
 
140
- const { title, description } =
142
+ const { title, description, style, className } =
141
143
  typeof options === "string" ? { title: options } : options;
142
144
 
143
145
  setContents({
144
146
  type: "confirmation",
145
147
  title,
146
148
  description,
149
+ style,
150
+ className,
147
151
  resolve: (value: boolean) => {
148
152
  resolve(value);
149
153
  setContents(undefined);
@@ -157,11 +161,20 @@ export const DialogProvider = function DialogProvider({
157
161
  (options) => {
158
162
  const { promise, resolve } = createDeferredPromise<void>();
159
163
 
164
+ const { title, description, style, className } = options;
165
+
166
+ const children =
167
+ typeof options.children === "function"
168
+ ? options.children({ close: closeRef.current })
169
+ : options.children;
170
+
160
171
  setContents({
161
172
  type: "custom",
162
- title: options.title,
163
- description: options.description,
164
- children: options.children,
173
+ title,
174
+ description,
175
+ style,
176
+ className,
177
+ children,
165
178
  resolve: () => {
166
179
  resolve();
167
180
  setContents(undefined);
@@ -214,6 +227,8 @@ export const DialogProvider = function DialogProvider({
214
227
  title={contents?.title}
215
228
  description={contents?.description}
216
229
  open={isOpen}
230
+ style={contents?.style}
231
+ className={contents?.className}
217
232
  onOpenChange={useCallback(
218
233
  (isOpen: boolean) => {
219
234
  if (!isOpen) {
@@ -1,5 +1,6 @@
1
1
  import React, { useLayoutEffect, useRef } from "react";
2
2
  import { ImperativePanelGroupHandle } from "react-resizable-panels";
3
+ import { PanelLayoutState } from "../components/workspace/types";
3
4
  import { useWindowSize } from "./useWindowSize";
4
5
 
5
6
  export const EDITOR_PANEL_GROUP_ID = "editor-panel-group";
@@ -7,11 +8,6 @@ export const LEFT_SIDEBAR_ID = "editor-left-sidebar";
7
8
  export const RIGHT_SIDEBAR_ID = "editor-right-sidebar";
8
9
  export const CONTENT_AREA_ID = "editor-content-area";
9
10
 
10
- export type PanelLayoutState = {
11
- leftSidebarCollapsed: boolean;
12
- rightSidebarCollapsed: boolean;
13
- };
14
-
15
11
  export function usePreservePanelSize(
16
12
  panelGroupRef: React.RefObject<ImperativePanelGroupHandle | null>,
17
13
  setPanelLayoutState?: (state: PanelLayoutState) => void
package/src/index.css CHANGED
@@ -58,6 +58,7 @@
58
58
  --inspector-h-separator: 8px;
59
59
  --inspector-v-separator: 10px;
60
60
  --dialog-padding: 16px;
61
+ --input-height: 27px;
61
62
  --icon: rgb(129, 131, 165);
62
63
  --icon-selected: rgb(220, 220, 220);
63
64
  --warning: rgb(251, 211, 0);
package/src/index.tsx CHANGED
@@ -14,6 +14,7 @@ export * from "./components/ContextMenu";
14
14
  export * from "./components/Dialog";
15
15
  export * from "./components/Divider";
16
16
  export * from "./components/DraggableMenuButton";
17
+ export * from "./components/Drawer";
17
18
  export * from "./components/DropdownMenu";
18
19
  export * from "./components/EditableText";
19
20
  export * from "./components/Fade";
@@ -39,6 +40,7 @@ export * from "./components/LabeledElementView";
39
40
  export * from "./components/LabeledField";
40
41
  export * from "./components/List";
41
42
  export * from "./components/ListView";
43
+ export * from "./components/MediaThumbnail";
42
44
  export * from "./components/Message";
43
45
  export * from "./components/Popover";
44
46
  export * from "./components/Progress";
@@ -57,7 +59,8 @@ export * from "./components/Toast";
57
59
  export * from "./components/Tooltip";
58
60
  export * from "./components/TreeView";
59
61
  export * from "./components/UserPointer";
60
- export * from "./components/WorkspaceLayout";
62
+ export * from "./components/workspace/types";
63
+ export * from "./components/workspace/WorkspaceLayout";
61
64
  // Contexts
62
65
  export * from "./contexts/DesignSystemConfiguration";
63
66
  export * from "./contexts/DialogContext";
@@ -189,6 +189,7 @@ const config = {
189
189
  "inspector-h-separator": "var(--inspector-h-separator)",
190
190
  "inspector-v-separator": "var(--inspector-v-separator)",
191
191
  "dialog-padding": "var(--dialog-padding)",
192
+ "input-height": "var(--input-height)",
192
193
  },
193
194
  keyframes: {
194
195
  spin: {