@noya-app/noya-designsystem 0.1.31 → 0.1.33
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/.turbo/turbo-build.log +20 -12
- package/.turbo/turbo-lint.log +2 -1
- package/CHANGELOG.md +14 -0
- package/README.md +13 -1
- package/dist/index.css +1 -0
- package/dist/index.d.ts +132 -509
- package/dist/index.js +4167 -2716
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4097 -2643
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -6
- package/src/components/ActivityIndicator.tsx +4 -36
- package/src/components/Avatar.tsx +63 -62
- package/src/components/Button.tsx +53 -172
- package/src/components/Chip.tsx +117 -150
- package/src/components/ContextMenu.tsx +13 -35
- package/src/components/Dialog.tsx +66 -54
- package/src/components/Divider.tsx +31 -41
- package/src/components/DraggableMenuButton.tsx +29 -30
- package/src/components/DropdownMenu.tsx +30 -40
- package/src/components/FillInputField.tsx +16 -26
- package/src/components/FillPreviewBackground.tsx +18 -22
- package/src/components/FloatingWindow.tsx +4 -7
- package/src/components/GridView.tsx +70 -200
- package/src/components/IconButton.tsx +1 -5
- package/src/components/InputField.tsx +191 -194
- package/src/components/InputFieldWithCompletions.tsx +20 -27
- package/src/components/InspectorContainer.tsx +4 -9
- package/src/components/InspectorPrimitives.tsx +135 -109
- package/src/components/Label.tsx +5 -36
- package/src/components/LabeledElementView.tsx +5 -26
- package/src/components/ListView.tsx +239 -167
- package/src/components/Popover.tsx +15 -39
- package/src/components/Progress.tsx +21 -44
- package/src/components/RadioGroup.tsx +6 -71
- package/src/components/ScrollArea.tsx +11 -39
- package/src/components/SelectMenu.tsx +31 -48
- package/src/components/Slider.tsx +7 -43
- package/src/components/Spacer.tsx +6 -18
- package/src/components/Switch.tsx +4 -42
- package/src/components/Text.tsx +31 -66
- package/src/components/TextArea.tsx +5 -31
- package/src/components/Toast.tsx +15 -57
- package/src/components/Tooltip.tsx +4 -13
- package/src/components/WorkspaceLayout.tsx +4 -14
- package/src/components/internal/Menu.tsx +37 -83
- package/src/contexts/DesignSystemConfiguration.tsx +1 -47
- package/src/contexts/DialogContext.tsx +2 -10
- package/src/hooks/useDarkMode.ts +14 -0
- package/src/index.css +108 -0
- package/src/index.tsx +3 -4
- package/src/theme/index.ts +4 -16
- package/src/utils/tailwind.ts +17 -0
- package/tailwind.config.ts +106 -166
- package/tsup.config.ts +16 -0
- package/dist/index.d.mts +0 -1443
- package/src/components/Grid.tsx +0 -54
- package/src/components/Stack.tsx +0 -164
- package/src/theme/dark.ts +0 -45
- package/src/theme/light.ts +0 -226
- package/src/utils/breakpoints.ts +0 -45
package/src/components/Chip.tsx
CHANGED
|
@@ -1,149 +1,113 @@
|
|
|
1
1
|
import { Cross1Icon, PlusIcon } from "@noya-app/noya-icons";
|
|
2
2
|
import React, { forwardRef, memo } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import { useDesignSystemTheme } from "../contexts/DesignSystemConfiguration";
|
|
5
3
|
import { useHover } from "../hooks/useHover";
|
|
6
4
|
|
|
7
5
|
type ChipColorScheme = "primary" | "secondary" | "error";
|
|
8
6
|
type ChipSize = "small" | "medium" | "large";
|
|
9
7
|
type ChipVariant = "solid" | "outlined" | "ghost";
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
function getChipStyles({
|
|
10
|
+
$colorScheme,
|
|
11
|
+
$size,
|
|
12
|
+
$variant,
|
|
13
|
+
$monospace,
|
|
14
|
+
$isInteractive,
|
|
15
|
+
}: {
|
|
12
16
|
$colorScheme?: ChipColorScheme;
|
|
13
17
|
$size: ChipSize;
|
|
14
|
-
$monospace: boolean;
|
|
15
18
|
$variant: ChipVariant;
|
|
19
|
+
$monospace: boolean;
|
|
16
20
|
$isInteractive: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
? {
|
|
59
|
-
fontSize: "10px",
|
|
60
|
-
padding: "2px 6px",
|
|
61
|
-
}
|
|
62
|
-
: {
|
|
63
|
-
fontSize: "9px",
|
|
64
|
-
padding: "0px 4px",
|
|
65
|
-
}),
|
|
66
|
-
...($monospace && {
|
|
67
|
-
fontFamily: theme.fonts.monospace,
|
|
68
|
-
}),
|
|
69
|
-
...($variant === "solid"
|
|
70
|
-
? {
|
|
71
|
-
color,
|
|
72
|
-
backgroundColor,
|
|
73
|
-
}
|
|
74
|
-
: $variant === "outlined"
|
|
75
|
-
? {
|
|
76
|
-
color,
|
|
77
|
-
backgroundColor: "transparent",
|
|
78
|
-
boxShadow: `0 0 0 1px ${subtleColor} inset`,
|
|
79
|
-
}
|
|
80
|
-
: {}),
|
|
81
|
-
"&:hover": {
|
|
82
|
-
...($variant === "outlined" && {
|
|
83
|
-
backgroundColor: subtleColor,
|
|
84
|
-
boxShadow: "none",
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
87
|
-
...($isInteractive && {
|
|
88
|
-
cursor: "pointer",
|
|
89
|
-
"&:hover": {
|
|
90
|
-
opacity: 0.85,
|
|
21
|
+
}) {
|
|
22
|
+
// Base styles
|
|
23
|
+
const baseStyles = `
|
|
24
|
+
inline-flex items-center
|
|
25
|
+
whitespace-pre rounded
|
|
26
|
+
select-none
|
|
27
|
+
leading-[15px]
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
// Size styles
|
|
31
|
+
const sizeStyles = {
|
|
32
|
+
large: "text-[11px] p-[4px_8px]",
|
|
33
|
+
medium: "text-[10px] p-[2px_6px]",
|
|
34
|
+
small: "text-[9px] p-[0px_4px]",
|
|
35
|
+
}[$size];
|
|
36
|
+
|
|
37
|
+
// Font family
|
|
38
|
+
const fontStyles = $monospace ? "font-mono" : "";
|
|
39
|
+
|
|
40
|
+
// Color and background based on scheme and variant
|
|
41
|
+
const variantStyles = (() => {
|
|
42
|
+
const colors = {
|
|
43
|
+
primary: {
|
|
44
|
+
text: "text-primary",
|
|
45
|
+
bg: "bg-primary-pastel",
|
|
46
|
+
subtle: "bg-[rgba(238,229,255,0.2)]",
|
|
47
|
+
},
|
|
48
|
+
secondary: {
|
|
49
|
+
text: "text-secondary",
|
|
50
|
+
bg: "bg-secondary-pastel",
|
|
51
|
+
subtle: "bg-[rgba(205,238,231,0.2)]",
|
|
52
|
+
},
|
|
53
|
+
error: {
|
|
54
|
+
text: "text-text",
|
|
55
|
+
bg: "bg-[rgb(255,219,219)]",
|
|
56
|
+
subtle: "bg-[rgba(255,219,219,0.2)]",
|
|
57
|
+
},
|
|
58
|
+
default: {
|
|
59
|
+
text: "text-text",
|
|
60
|
+
bg: "bg-input-background",
|
|
61
|
+
subtle: "bg-[rgba(0,0,0,0.1)]",
|
|
91
62
|
},
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
transform: "scale(0.6)",
|
|
141
|
-
}),
|
|
142
|
-
|
|
143
|
-
"&:hover": {
|
|
144
|
-
opacity: 0.85,
|
|
145
|
-
},
|
|
146
|
-
}));
|
|
63
|
+
}[$colorScheme ?? "default"];
|
|
64
|
+
|
|
65
|
+
if ($variant === "solid") {
|
|
66
|
+
return `${colors.text} ${colors.bg}`;
|
|
67
|
+
}
|
|
68
|
+
if ($variant === "outlined") {
|
|
69
|
+
return `
|
|
70
|
+
${colors.text} bg-transparent
|
|
71
|
+
shadow-[0_0_0_1px_${colors.subtle.slice(3, -1)}_inset]
|
|
72
|
+
hover:${colors.subtle} hover:shadow-none
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
return "";
|
|
76
|
+
})();
|
|
77
|
+
|
|
78
|
+
// Interactive states
|
|
79
|
+
const interactiveStyles = $isInteractive
|
|
80
|
+
? "cursor-pointer hover:opacity-85"
|
|
81
|
+
: "";
|
|
82
|
+
|
|
83
|
+
return `
|
|
84
|
+
${baseStyles}
|
|
85
|
+
${sizeStyles}
|
|
86
|
+
${fontStyles}
|
|
87
|
+
${variantStyles}
|
|
88
|
+
${interactiveStyles}
|
|
89
|
+
`
|
|
90
|
+
.replace(/\s+/g, " ")
|
|
91
|
+
.trim();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getIconStyles(size: ChipSize, isAdd: boolean) {
|
|
95
|
+
const baseStyles = "relative opacity-50 cursor-pointer hover:opacity-85";
|
|
96
|
+
|
|
97
|
+
if (size === "large") {
|
|
98
|
+
return `
|
|
99
|
+
${baseStyles}
|
|
100
|
+
${isAdd ? "ml-[-2px] mr-[2px] -top-[1px]" : "mr-[-2px] ml-[2px]"}
|
|
101
|
+
scale-75
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return `
|
|
106
|
+
${baseStyles}
|
|
107
|
+
${isAdd ? "ml-[-2px] mr-[-2px]" : "mr-[-2px]"}
|
|
108
|
+
scale-60
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
147
111
|
|
|
148
112
|
export interface ChipProps {
|
|
149
113
|
id?: string;
|
|
@@ -181,12 +145,11 @@ export const Chip = memo(
|
|
|
181
145
|
onClick,
|
|
182
146
|
onAdd,
|
|
183
147
|
onHoverDeleteChange,
|
|
148
|
+
className,
|
|
184
149
|
...rest
|
|
185
150
|
}: ChipProps,
|
|
186
151
|
forwardedRef: React.ForwardedRef<HTMLSpanElement>
|
|
187
152
|
) {
|
|
188
|
-
const theme = useDesignSystemTheme();
|
|
189
|
-
|
|
190
153
|
const { hoverProps: hoverDeleteProps } = useHover({
|
|
191
154
|
onHoverChange: onHoverDeleteChange,
|
|
192
155
|
});
|
|
@@ -195,28 +158,32 @@ export const Chip = memo(
|
|
|
195
158
|
|
|
196
159
|
const color =
|
|
197
160
|
colorScheme === "primary"
|
|
198
|
-
?
|
|
161
|
+
? "var(--primary)"
|
|
199
162
|
: colorScheme === "secondary"
|
|
200
|
-
?
|
|
201
|
-
:
|
|
163
|
+
? "var(--secondary)"
|
|
164
|
+
: "var(--text)";
|
|
202
165
|
|
|
203
166
|
return (
|
|
204
|
-
<
|
|
167
|
+
<span
|
|
205
168
|
ref={forwardedRef}
|
|
206
|
-
|
|
207
|
-
|
|
169
|
+
className={`
|
|
170
|
+
${getChipStyles({
|
|
171
|
+
$colorScheme: colorScheme,
|
|
172
|
+
$size: size,
|
|
173
|
+
$variant: variant,
|
|
174
|
+
$monospace: monospace,
|
|
175
|
+
$isInteractive: !!handleClick || clickable === true,
|
|
176
|
+
})}
|
|
177
|
+
${className ?? ""}
|
|
178
|
+
`}
|
|
208
179
|
style={style}
|
|
209
180
|
onClick={handleClick}
|
|
210
|
-
$size={size}
|
|
211
|
-
$monospace={monospace}
|
|
212
|
-
$isInteractive={!!handleClick || clickable === true}
|
|
213
181
|
tabIndex={tabIndex}
|
|
214
182
|
{...rest}
|
|
215
183
|
>
|
|
216
184
|
{addable && (
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
isOnlyChild={!children && !deletable}
|
|
185
|
+
<PlusIcon
|
|
186
|
+
className={getIconStyles(size, true)}
|
|
220
187
|
onClick={
|
|
221
188
|
onAdd
|
|
222
189
|
? (event) => {
|
|
@@ -230,8 +197,8 @@ export const Chip = memo(
|
|
|
230
197
|
)}
|
|
231
198
|
{children}
|
|
232
199
|
{deletable && (
|
|
233
|
-
<
|
|
234
|
-
|
|
200
|
+
<Cross1Icon
|
|
201
|
+
className={getIconStyles(size, false)}
|
|
235
202
|
{...(hoverDeleteProps as any)}
|
|
236
203
|
onClick={
|
|
237
204
|
onDelete
|
|
@@ -244,7 +211,7 @@ export const Chip = memo(
|
|
|
244
211
|
color={color}
|
|
245
212
|
/>
|
|
246
213
|
)}
|
|
247
|
-
</
|
|
214
|
+
</span>
|
|
248
215
|
);
|
|
249
216
|
})
|
|
250
217
|
);
|
|
@@ -2,7 +2,6 @@ import { CheckIcon, ChevronRightIcon } from "@noya-app/noya-icons";
|
|
|
2
2
|
import { useKeyboardShortcuts } from "@noya-app/noya-keymap";
|
|
3
3
|
import * as RadixContextMenu from "@radix-ui/react-context-menu";
|
|
4
4
|
import React, { ReactNode, memo, useCallback, useMemo } from "react";
|
|
5
|
-
import styled from "styled-components";
|
|
6
5
|
import { renderIcon } from "./Icons";
|
|
7
6
|
import { Spacer } from "./Spacer";
|
|
8
7
|
import {
|
|
@@ -15,28 +14,6 @@ import {
|
|
|
15
14
|
styles,
|
|
16
15
|
} from "./internal/Menu";
|
|
17
16
|
|
|
18
|
-
/* ----------------------------------------------------------------------------
|
|
19
|
-
* Separator
|
|
20
|
-
* ------------------------------------------------------------------------- */
|
|
21
|
-
|
|
22
|
-
const SeparatorElement = styled(RadixContextMenu.Separator)(
|
|
23
|
-
styles.separatorStyle
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
/* ----------------------------------------------------------------------------
|
|
27
|
-
* Item
|
|
28
|
-
* ------------------------------------------------------------------------- */
|
|
29
|
-
|
|
30
|
-
const ItemElement = styled(RadixContextMenu.Item)(styles.itemStyle);
|
|
31
|
-
|
|
32
|
-
const CheckboxItemElement = styled(RadixContextMenu.CheckboxItem)(
|
|
33
|
-
styles.itemStyle
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const StyledItemIndicator = styled(RadixContextMenu.ItemIndicator)(
|
|
37
|
-
styles.itemIndicatorStyle
|
|
38
|
-
);
|
|
39
|
-
|
|
40
17
|
export interface MenuItemProps<T extends string> {
|
|
41
18
|
value?: T;
|
|
42
19
|
children: ReactNode;
|
|
@@ -75,21 +52,23 @@ const ContextMenuItem = memo(function ContextMenuItem<T extends string>({
|
|
|
75
52
|
|
|
76
53
|
if (checked) {
|
|
77
54
|
return (
|
|
78
|
-
<
|
|
55
|
+
<RadixContextMenu.CheckboxItem
|
|
79
56
|
checked={checked}
|
|
80
57
|
disabled={disabled}
|
|
81
58
|
onSelect={handleSelectItem}
|
|
59
|
+
className={styles.itemStyle({ disabled })}
|
|
82
60
|
>
|
|
83
|
-
<
|
|
61
|
+
<RadixContextMenu.ItemIndicator className={styles.itemIndicatorStyle}>
|
|
84
62
|
<CheckIcon />
|
|
85
|
-
</
|
|
63
|
+
</RadixContextMenu.ItemIndicator>
|
|
86
64
|
{children}
|
|
87
|
-
</
|
|
65
|
+
</RadixContextMenu.CheckboxItem>
|
|
88
66
|
);
|
|
89
67
|
}
|
|
90
68
|
|
|
91
69
|
const element = (
|
|
92
|
-
<
|
|
70
|
+
<RadixContextMenu.Item
|
|
71
|
+
className={styles.itemStyle({ disabled })}
|
|
93
72
|
disabled={disabled}
|
|
94
73
|
onSelect={handleSelectItem}
|
|
95
74
|
onPointerDown={handlePointerDown}
|
|
@@ -118,7 +97,7 @@ const ContextMenuItem = memo(function ContextMenuItem<T extends string>({
|
|
|
118
97
|
<ChevronRightIcon />
|
|
119
98
|
</>
|
|
120
99
|
)}
|
|
121
|
-
</
|
|
100
|
+
</RadixContextMenu.Item>
|
|
122
101
|
);
|
|
123
102
|
|
|
124
103
|
if (items && items.length > 0) {
|
|
@@ -136,9 +115,6 @@ const ContextMenuItem = memo(function ContextMenuItem<T extends string>({
|
|
|
136
115
|
* Root
|
|
137
116
|
* ------------------------------------------------------------------------- */
|
|
138
117
|
|
|
139
|
-
const Content = styled(RadixContextMenu.Content)(styles.contentStyle);
|
|
140
|
-
const SubContent = styled(RadixContextMenu.SubContent)(styles.contentStyle);
|
|
141
|
-
|
|
142
118
|
export interface MenuProps<T extends string> {
|
|
143
119
|
children: ReactNode;
|
|
144
120
|
items: MenuItem<T>[];
|
|
@@ -182,7 +158,9 @@ function ContextMenuRoot<T extends string>({
|
|
|
182
158
|
const TriggerComponent = isNested
|
|
183
159
|
? RadixContextMenu.SubTrigger
|
|
184
160
|
: RadixContextMenu.Trigger;
|
|
185
|
-
const ContentComponent: typeof Content = isNested
|
|
161
|
+
const ContentComponent: typeof RadixContextMenu.Content = isNested
|
|
162
|
+
? RadixContextMenu.SubContent
|
|
163
|
+
: RadixContextMenu.Content;
|
|
186
164
|
|
|
187
165
|
return (
|
|
188
166
|
<RootComponent onOpenChange={onOpenChange}>
|
|
@@ -190,10 +168,10 @@ function ContextMenuRoot<T extends string>({
|
|
|
190
168
|
{children}
|
|
191
169
|
</TriggerComponent>
|
|
192
170
|
<RadixContextMenu.Portal>
|
|
193
|
-
<ContentComponent>
|
|
171
|
+
<ContentComponent className={styles.contentStyle}>
|
|
194
172
|
{items.map((item, index) =>
|
|
195
173
|
item === SEPARATOR_ITEM ? (
|
|
196
|
-
<
|
|
174
|
+
<RadixContextMenu.Separator key={index} className={styles.separatorStyle} />
|
|
197
175
|
) : (
|
|
198
176
|
<ContextMenuItem
|
|
199
177
|
key={item.value ?? index}
|
|
@@ -7,60 +7,77 @@ import React, {
|
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useRef,
|
|
9
9
|
} from "react";
|
|
10
|
-
import styled from "styled-components";
|
|
11
10
|
import { IconButton } from "./IconButton";
|
|
12
11
|
import { Spacer } from "./Spacer";
|
|
12
|
+
import { cn } from "../utils/tailwind";
|
|
13
13
|
|
|
14
|
-
const StyledOverlay =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const StyledOverlay = forwardRef<
|
|
15
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<DialogPrimitive.Overlay
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn("fixed inset-0 bg-[rgba(0,0,0,0.5)]", className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
19
24
|
|
|
20
|
-
const StyledContent =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
pointerEvents: "all",
|
|
38
|
-
zIndex: 1000,
|
|
39
|
-
}));
|
|
25
|
+
const StyledContent = forwardRef<
|
|
26
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
27
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
28
|
+
>(({ className, ...props }, ref) => (
|
|
29
|
+
<DialogPrimitive.Content
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={`
|
|
32
|
+
fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2
|
|
33
|
+
w-[90vw] max-w-[450px] max-h-[85vh] p-dialog-padding rounded-[2px]
|
|
34
|
+
font-sans text-heading5 font-normal leading-[19px] text-text-muted
|
|
35
|
+
bg-popover-background overflow-y-auto pointer-events-all z-[1000] focus:outline-none
|
|
36
|
+
shadow-[0_10px_38px_-10px_hsla(206,22%,7%,.35),0_10px_20px_-15px_hsla(206,22%,7%,.2)]
|
|
37
|
+
${className}
|
|
38
|
+
`}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
));
|
|
40
42
|
|
|
41
|
-
const StyledTitle =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const StyledTitle = forwardRef<
|
|
44
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
45
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
46
|
+
>(({ className, ...props }, ref) => (
|
|
47
|
+
<DialogPrimitive.Title
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn(
|
|
50
|
+
"m-0 font-sans text-base font-normal leading-[1.4] text-text",
|
|
51
|
+
className
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
));
|
|
46
56
|
|
|
47
|
-
const StyledDescription =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
const StyledDescription = forwardRef<
|
|
58
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
59
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
60
|
+
>(({ className, ...props }, ref) => (
|
|
61
|
+
<DialogPrimitive.Description
|
|
62
|
+
ref={ref}
|
|
63
|
+
className={cn(
|
|
64
|
+
"m-0 font-sans text-heading5 font-normal leading-[19px] text-text-muted",
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
));
|
|
52
70
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}));
|
|
71
|
+
const CloseButtonContainer = forwardRef<
|
|
72
|
+
HTMLDivElement,
|
|
73
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
74
|
+
>(({ className, ...props }, ref) => (
|
|
75
|
+
<div
|
|
76
|
+
ref={ref}
|
|
77
|
+
className={`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)] ${className}`}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
));
|
|
64
81
|
|
|
65
82
|
export interface IDialog {
|
|
66
83
|
containsElement: (element: HTMLElement) => boolean;
|
|
@@ -97,7 +114,6 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
97
114
|
useImperativeHandle(forwardedRef, () => ({
|
|
98
115
|
containsElement(element) {
|
|
99
116
|
if (!contentRef.current) return false;
|
|
100
|
-
|
|
101
117
|
return contentRef.current.contains(element);
|
|
102
118
|
},
|
|
103
119
|
}));
|
|
@@ -110,12 +126,8 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
110
126
|
onOpenAutoFocus={onOpenAutoFocus}
|
|
111
127
|
style={style}
|
|
112
128
|
{...(closeOnInteractOutside === false && {
|
|
113
|
-
onPointerDownOutside: (event) =>
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
onInteractOutside: (event) => {
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
},
|
|
129
|
+
onPointerDownOutside: (event) => event.preventDefault(),
|
|
130
|
+
onInteractOutside: (event) => event.preventDefault(),
|
|
119
131
|
})}
|
|
120
132
|
>
|
|
121
133
|
<CloseButtonContainer>
|
|
@@ -1,64 +1,54 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
* Divider
|
|
6
|
-
* ------------------------------------------------------------------------- */
|
|
7
|
-
|
|
8
|
-
type DividerVariant = "normal" | "strong" | "subtle";
|
|
9
|
-
|
|
10
|
-
const DividerContainer = styled.div<
|
|
11
|
-
DividerProps_ & {
|
|
12
|
-
$orientation: "horizontal" | "vertical";
|
|
13
|
-
}
|
|
14
|
-
>(({ theme, $variant = "normal", $orientation, $overflow = 0 }) => ({
|
|
15
|
-
...($orientation === "horizontal"
|
|
16
|
-
? { height: "1px", minHeight: "1px", margin: `0px -${$overflow}px` }
|
|
17
|
-
: { width: "1px", minWidth: "1px", margin: `-${$overflow}px 0px` }),
|
|
18
|
-
background:
|
|
19
|
-
$variant === "strong"
|
|
20
|
-
? theme.colors.dividerStrong
|
|
21
|
-
: $variant === "subtle"
|
|
22
|
-
? theme.colors.dividerSubtle
|
|
23
|
-
: theme.colors.divider,
|
|
24
|
-
alignSelf: "stretch",
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
interface DividerProps_ {
|
|
28
|
-
$variant?: DividerVariant;
|
|
29
|
-
$overflow?: number;
|
|
30
|
-
}
|
|
3
|
+
type DividerVariant = "normal" | "subtle" | "strong";
|
|
31
4
|
|
|
32
5
|
interface DividerProps {
|
|
33
6
|
variant?: DividerVariant;
|
|
34
|
-
overflow?: number;
|
|
7
|
+
overflow?: number | string;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
35
10
|
}
|
|
36
11
|
|
|
37
12
|
export const Divider = memo(function Divider({
|
|
38
|
-
variant,
|
|
39
|
-
overflow,
|
|
13
|
+
variant = "normal",
|
|
14
|
+
overflow = 0,
|
|
15
|
+
className,
|
|
16
|
+
style,
|
|
40
17
|
...props
|
|
41
18
|
}: DividerProps) {
|
|
42
19
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
<div
|
|
21
|
+
className={`
|
|
22
|
+
h-px min-h-px
|
|
23
|
+
${variant === "strong" ? "bg-divider-strong" : variant === "subtle" ? "bg-divider-subtle" : "bg-divider"}
|
|
24
|
+
self-stretch
|
|
25
|
+
${className ?? ""}
|
|
26
|
+
`}
|
|
27
|
+
style={{
|
|
28
|
+
marginLeft: `-${overflow}px`,
|
|
29
|
+
marginRight: `-${overflow}px`,
|
|
30
|
+
...style,
|
|
31
|
+
}}
|
|
47
32
|
{...props}
|
|
48
33
|
/>
|
|
49
34
|
);
|
|
50
35
|
});
|
|
51
36
|
|
|
52
37
|
export const DividerVertical = memo(function DividerVertical({
|
|
53
|
-
variant,
|
|
54
|
-
overflow,
|
|
38
|
+
variant = "normal",
|
|
39
|
+
overflow = 0,
|
|
40
|
+
className,
|
|
55
41
|
...props
|
|
56
42
|
}: DividerProps) {
|
|
57
43
|
return (
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
<div
|
|
45
|
+
className={`
|
|
46
|
+
w-px min-w-px
|
|
47
|
+
my-[-${overflow}px]
|
|
48
|
+
${variant === "strong" ? "bg-divider-strong" : variant === "subtle" ? "bg-divider-subtle" : "bg-divider"}
|
|
49
|
+
self-stretch
|
|
50
|
+
${className ?? ""}
|
|
51
|
+
`}
|
|
62
52
|
{...props}
|
|
63
53
|
/>
|
|
64
54
|
);
|