@noya-app/noya-designsystem 0.1.46 → 0.1.47

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.46",
3
+ "version": "0.1.47",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -70,20 +70,6 @@ const StyledDescription = forwardRef<
70
70
  />
71
71
  ));
72
72
 
73
- const CloseButtonContainer = forwardRef<
74
- HTMLDivElement,
75
- React.HTMLAttributes<HTMLDivElement>
76
- >(({ className, ...props }, ref) => (
77
- <div
78
- ref={ref}
79
- className={cx(
80
- `absolute top-dialog-padding right-dialog-padding z-[1] bg-popover-background p-[4px_6px] rounded-[2px] border border-[rgba(128,128,128,0.2)] `,
81
- className
82
- )}
83
- {...props}
84
- />
85
- ));
86
-
87
73
  export interface IDialog {
88
74
  containsElement: (element: HTMLElement) => boolean;
89
75
  }
@@ -141,11 +127,17 @@ export const Dialog = forwardRef(function Dialog(
141
127
  })}
142
128
  >
143
129
  {showCloseButton && (
144
- <CloseButtonContainer>
145
- <DialogPrimitive.Close asChild>
146
- <IconButton iconName="Cross1Icon" />
147
- </DialogPrimitive.Close>
148
- </CloseButtonContainer>
130
+ <DialogPrimitive.Close asChild>
131
+ <IconButton
132
+ iconName="Cross1Icon"
133
+ className="z-[1]"
134
+ style={{
135
+ position: "absolute",
136
+ top: "var(--dialog-padding)",
137
+ right: "var(--dialog-padding)",
138
+ }}
139
+ />
140
+ </DialogPrimitive.Close>
149
141
  )}
150
142
  {title && (
151
143
  <>
@@ -6,6 +6,7 @@ import {
6
6
  ListView,
7
7
  SelectableMenuItem,
8
8
  Small,
9
+ cssVars,
9
10
  fuzzyFilter,
10
11
  getNextIndex,
11
12
  isSelectableMenuItem,
@@ -155,32 +156,11 @@ export const SearchCompletionMenu = forwardRef(function SearchCompletionMenu(
155
156
  borderRadius: 0,
156
157
  outline: "none",
157
158
  boxShadow: "none",
158
- backgroundColor: "white",
159
+ backgroundColor: cssVars.colors.inputBackground,
159
160
  padding: "4px 12px",
160
161
  }}
161
162
  onChange={setSearch}
162
163
  onKeyDown={handleKeyDown}
163
- // onBlur={(event) => {
164
- // const isWithinPopover =
165
- // event.relatedTarget &&
166
- // event.relatedTarget instanceof HTMLElement &&
167
- // event.relatedTarget.role === 'dialog';
168
-
169
- // if (isWithinPopover) {
170
- // inputRef.current?.focus();
171
-
172
- // event.stopPropagation();
173
- // event.preventDefault();
174
- // }
175
- // }}
176
- // onPointerDown={(event) => {
177
- // event.stopPropagation();
178
- // event.preventDefault();
179
- // }}
180
- // onFocusCapture={(event) => {
181
- // event.stopPropagation();
182
- // event.preventDefault();
183
- // }}
184
164
  />
185
165
  </InputField.Root>
186
166
  <Divider />
@@ -38,7 +38,7 @@ export const Switch = function Switch({
38
38
  onChange(newValue);
39
39
  }}
40
40
  className={cx(
41
- "all-unset w-8 h-[19px] bg-active-background rounded-full relative cursor-pointer [webkit-tap-highlight-color:rgba(0,0,0,0)] focus:ring-2 focus:ring-primary focus:ring-offset-[1px] outline-none data-[state=checked]:bg-primary transition-all",
41
+ "all-unset w-8 h-[19px] bg-active-background rounded-full relative cursor-pointer ring-offset-background [webkit-tap-highlight-color:rgba(0,0,0,0)] focus:ring-2 focus:ring-primary focus:ring-offset-[1px] outline-none data-[state=checked]:bg-primary transition-all",
42
42
  colorScheme === "secondary" && "data-[state=checked]:bg-secondary",
43
43
  "focus:z-interactable",
44
44
  className
@@ -25,6 +25,12 @@ function createDeferredPromise<T>() {
25
25
  }
26
26
 
27
27
  export type DialogContextValue = {
28
+ openDialog(options: {
29
+ title: string;
30
+ description?: ReactNode;
31
+ children: ReactNode;
32
+ }): Promise<void>;
33
+
28
34
  openInputDialog(
29
35
  options:
30
36
  | string
@@ -66,7 +72,18 @@ type ConfirmationDialogContents = {
66
72
  resolve: (value: boolean) => void;
67
73
  };
68
74
 
69
- type DialogContents = InputDialogContents | ConfirmationDialogContents;
75
+ type CustomDialogContents = {
76
+ type: "custom";
77
+ title: string;
78
+ description?: ReactNode;
79
+ children: ReactNode;
80
+ resolve: () => void;
81
+ };
82
+
83
+ type DialogContents =
84
+ | InputDialogContents
85
+ | ConfirmationDialogContents
86
+ | CustomDialogContents;
70
87
 
71
88
  export const DialogProvider = function DialogProvider({
72
89
  children,
@@ -136,6 +153,26 @@ export const DialogProvider = function DialogProvider({
136
153
  return promise;
137
154
  }, []);
138
155
 
156
+ const openCustomDialog: DialogContextValue["openDialog"] = useCallback(
157
+ (options) => {
158
+ const { promise, resolve } = createDeferredPromise<void>();
159
+
160
+ setContents({
161
+ type: "custom",
162
+ title: options.title,
163
+ description: options.description,
164
+ children: options.children,
165
+ resolve: () => {
166
+ resolve();
167
+ setContents(undefined);
168
+ },
169
+ });
170
+
171
+ return promise;
172
+ },
173
+ []
174
+ );
175
+
139
176
  const handleKeyDown = useCallback(
140
177
  (event: React.KeyboardEvent<HTMLInputElement>) => {
141
178
  if (event.key !== "Enter") return;
@@ -162,11 +199,12 @@ export const DialogProvider = function DialogProvider({
162
199
  <DialogContext.Provider
163
200
  value={useMemo(
164
201
  () => ({
202
+ openDialog: openCustomDialog,
165
203
  openInputDialog: open,
166
204
  openConfirmationDialog: openConfirmation,
167
205
  containsElement,
168
206
  }),
169
- [containsElement, open, openConfirmation]
207
+ [containsElement, open, openConfirmation, openCustomDialog]
170
208
  )}
171
209
  >
172
210
  {children}
@@ -221,12 +259,16 @@ export const DialogProvider = function DialogProvider({
221
259
  OK
222
260
  </Button>
223
261
  </div>
262
+ ) : contents?.type === "custom" ? (
263
+ <>{contents.children}</>
224
264
  ) : (
225
265
  <>
226
266
  <InputField.Root>
227
267
  <InputField.Input
228
268
  ref={inputRef}
229
- placeholder={contents?.placeholder}
269
+ placeholder={
270
+ contents?.type === "input" ? contents.placeholder : undefined
271
+ }
230
272
  value={contents?.type === "input" ? contents.inputValue : ""}
231
273
  onChange={(value: string) => {
232
274
  setContents((contents) =>
@@ -262,7 +304,7 @@ export const DialogProvider = function DialogProvider({
262
304
  );
263
305
  };
264
306
 
265
- function useDialog(): DialogContextValue {
307
+ export function useDialogContext(): DialogContextValue {
266
308
  const value = useContext(DialogContext);
267
309
 
268
310
  if (!value) {
@@ -273,13 +315,17 @@ function useDialog(): DialogContextValue {
273
315
  }
274
316
 
275
317
  export function useOpenInputDialog() {
276
- return useDialog().openInputDialog;
318
+ return useDialogContext().openInputDialog;
277
319
  }
278
320
 
279
321
  export function useDialogContainsElement() {
280
- return useDialog().containsElement;
322
+ return useDialogContext().containsElement;
281
323
  }
282
324
 
283
325
  export function useOpenConfirmationDialog() {
284
- return useDialog().openConfirmationDialog;
326
+ return useDialogContext().openConfirmationDialog;
327
+ }
328
+
329
+ export function useOpenDialog() {
330
+ return useDialogContext().openDialog;
285
331
  }
package/src/index.css CHANGED
@@ -104,7 +104,8 @@
104
104
  --popover-divider: rgba(255, 255, 255, 0.08);
105
105
  --listview-raised-background: rgba(181, 178, 255, 0.1);
106
106
  --listview-editing-background: #000;
107
- --slider-thumb-background: rgb(248, 248, 250);
107
+ --slider-thumb-background: var(--input-background-light);
108
+ --slider-border: var(--divider);
108
109
  --mask: rgb(102, 187, 106);
109
110
  --transparent-checker: rgba(255, 255, 255, 0.3);
110
111
  --scrollbar: rgba(199, 199, 199, 0.2);