@noya-app/noya-designsystem 0.1.53 → 0.1.54
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 +10 -10
- package/CHANGELOG.md +8 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +109 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/ColorSwatch.tsx +5 -2
- package/src/components/SegmentedControl.tsx +13 -42
- package/src/components/Slider.tsx +1 -1
- package/src/components/Toolbar.tsx +60 -43
- package/src/components/connected-users-menu/ConnectedUsersMenuLayout.tsx +2 -2
- package/src/components/internal/Menu.tsx +1 -1
- package/src/components/internal/SelectItem.tsx +24 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-designsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@dnd-kit/core": "6.3.1",
|
|
24
24
|
"@dnd-kit/sortable": "10.0.0",
|
|
25
|
-
"@noya-app/noya-colorpicker": "0.1.
|
|
25
|
+
"@noya-app/noya-colorpicker": "0.1.21",
|
|
26
26
|
"@noya-app/noya-utils": "0.1.5",
|
|
27
27
|
"@noya-app/noya-geometry": "0.1.11",
|
|
28
28
|
"@noya-app/noya-icons": "0.1.8",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
|
+
import { cssVars } from "../theme";
|
|
2
3
|
|
|
3
4
|
export type ColorSwatchSize = "xsmall" | "small" | "medium" | "large";
|
|
4
5
|
|
|
@@ -31,10 +32,12 @@ export const ColorSwatch = forwardRef(function ColorSwatch(
|
|
|
31
32
|
height: sizePx,
|
|
32
33
|
borderRadius: "4px",
|
|
33
34
|
outline: checked
|
|
34
|
-
?
|
|
35
|
+
? `2px solid ${cssVars.colors.primary}`
|
|
35
36
|
: "1px solid rgba(0,0,0,0.1)",
|
|
36
37
|
outlineOffset: -1,
|
|
37
|
-
boxShadow: checked
|
|
38
|
+
boxShadow: checked
|
|
39
|
+
? `inset 0 0 0 2px ${cssVars.colors.background}`
|
|
40
|
+
: undefined,
|
|
38
41
|
...style,
|
|
39
42
|
}}
|
|
40
43
|
/>
|
|
@@ -32,7 +32,6 @@ export interface SegmentedControlProps<T extends string> {
|
|
|
32
32
|
/** @default primary */
|
|
33
33
|
colorScheme?: SegmentedControlColorScheme;
|
|
34
34
|
allowEmpty?: boolean;
|
|
35
|
-
separator?: boolean;
|
|
36
35
|
items: SegmentedControlItemProps<T>[];
|
|
37
36
|
className?: string;
|
|
38
37
|
style?: React.CSSProperties;
|
|
@@ -70,7 +69,7 @@ const SegmentedControlItem = forwardRef(function SegmentedControlItem<
|
|
|
70
69
|
value={(value ?? "").toString()}
|
|
71
70
|
disabled={disabled}
|
|
72
71
|
className={cx(
|
|
73
|
-
"font-sans text-
|
|
72
|
+
"font-sans text-button font-normal relative flex-1 appearance-none text-segmented-control-item rounded inline-flex gap-1.5 items-center justify-center align-middle text-center focus:outline-none transition-colors",
|
|
74
73
|
colorScheme === "secondary"
|
|
75
74
|
? "focus:ring-2 focus:ring-secondary focus:ring-offset-1"
|
|
76
75
|
: "focus:ring-2 focus:ring-primary focus:ring-offset-1",
|
|
@@ -81,7 +80,10 @@ const SegmentedControlItem = forwardRef(function SegmentedControlItem<
|
|
|
81
80
|
: "aria-checked:bg-background aria-checked:text-text",
|
|
82
81
|
"focus:z-interactable",
|
|
83
82
|
"aria-checked:shadow-segment",
|
|
84
|
-
"whitespace-pre",
|
|
83
|
+
"whitespace-pre px-1",
|
|
84
|
+
"border-r border-divider last:border-r-0",
|
|
85
|
+
"aria-checked:border-r-transparent",
|
|
86
|
+
"[&:has(+[aria-checked=true])]:border-r-transparent",
|
|
85
87
|
className
|
|
86
88
|
)}
|
|
87
89
|
{...props}
|
|
@@ -98,15 +100,6 @@ const SegmentedControlItem = forwardRef(function SegmentedControlItem<
|
|
|
98
100
|
);
|
|
99
101
|
});
|
|
100
102
|
|
|
101
|
-
const Separator = ({ transparent }: { transparent: boolean }) => (
|
|
102
|
-
<div
|
|
103
|
-
className={cx(
|
|
104
|
-
"w-[1px] my-1 self-stretch bg-divider",
|
|
105
|
-
transparent && "bg-transparent"
|
|
106
|
-
)}
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
|
|
110
103
|
export const SegmentedControl = memoGeneric(function SegmentedControl<
|
|
111
104
|
T extends string,
|
|
112
105
|
>({
|
|
@@ -116,7 +109,6 @@ export const SegmentedControl = memoGeneric(function SegmentedControl<
|
|
|
116
109
|
colorScheme,
|
|
117
110
|
allowEmpty,
|
|
118
111
|
items,
|
|
119
|
-
separator = true,
|
|
120
112
|
className,
|
|
121
113
|
style,
|
|
122
114
|
}: SegmentedControlProps<T>) {
|
|
@@ -131,8 +123,6 @@ export const SegmentedControl = memoGeneric(function SegmentedControl<
|
|
|
131
123
|
[allowEmpty, onValueChange]
|
|
132
124
|
);
|
|
133
125
|
|
|
134
|
-
const selectedIndex = items.findIndex((item) => item?.value === value);
|
|
135
|
-
|
|
136
126
|
return (
|
|
137
127
|
<SegmentedControlContext.Provider value={contextValue}>
|
|
138
128
|
<ToggleGroupPrimitive.Root
|
|
@@ -141,36 +131,17 @@ export const SegmentedControl = memoGeneric(function SegmentedControl<
|
|
|
141
131
|
value={value}
|
|
142
132
|
onValueChange={handleValueChange}
|
|
143
133
|
className={cx(
|
|
144
|
-
`
|
|
134
|
+
`grid appearance-none relative outline-none min-h-input-height rounded bg-input-background py-0.5 px-0.5`,
|
|
145
135
|
className
|
|
146
136
|
)}
|
|
147
|
-
style={
|
|
137
|
+
style={{
|
|
138
|
+
...style,
|
|
139
|
+
gridTemplateColumns: `repeat(${items.length}, 1fr)`,
|
|
140
|
+
}}
|
|
148
141
|
>
|
|
149
|
-
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const currentValue = item?.value;
|
|
153
|
-
|
|
154
|
-
// Show separator if:
|
|
155
|
-
// 1. Current item is not selected AND
|
|
156
|
-
// 2. Current item is not immediately before the selected item (except when selected is 0)
|
|
157
|
-
// 3. Current item is not immediately after the selected item
|
|
158
|
-
const showSeparator =
|
|
159
|
-
currentValue !== value &&
|
|
160
|
-
(selectedIndex === 0 && selectedIndex !== index
|
|
161
|
-
? true
|
|
162
|
-
: index !== selectedIndex - 1);
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<React.Fragment key={index}>
|
|
166
|
-
<SegmentedControlItem key={index} {...item} />
|
|
167
|
-
{!isLastItem && <Separator transparent={!showSeparator} />}
|
|
168
|
-
</React.Fragment>
|
|
169
|
-
);
|
|
170
|
-
})
|
|
171
|
-
: items.map((item, index) => (
|
|
172
|
-
<SegmentedControlItem key={index} {...item} />
|
|
173
|
-
))}
|
|
142
|
+
{items.map((item, index) => (
|
|
143
|
+
<SegmentedControlItem key={index} {...item} />
|
|
144
|
+
))}
|
|
174
145
|
</ToggleGroupPrimitive.Root>
|
|
175
146
|
</SegmentedControlContext.Provider>
|
|
176
147
|
);
|
|
@@ -117,7 +117,7 @@ export const Slider = memo(function Slider({
|
|
|
117
117
|
<div
|
|
118
118
|
style={trackFillStyle}
|
|
119
119
|
className={cx(
|
|
120
|
-
"absolute inset-0 w-full h-full rounded overflow-hidden",
|
|
120
|
+
"absolute inset-0 w-full h-full rounded overflow-hidden bg-primary-pastel",
|
|
121
121
|
colorScheme === "primary" && "bg-primary",
|
|
122
122
|
colorScheme === "secondary" && "bg-secondary"
|
|
123
123
|
)}
|
|
@@ -18,6 +18,12 @@ import {
|
|
|
18
18
|
import { Spacer } from "./Spacer";
|
|
19
19
|
import { Tooltip } from "./Tooltip";
|
|
20
20
|
|
|
21
|
+
const iconButtonStyle = {
|
|
22
|
+
height: 27,
|
|
23
|
+
width: 27,
|
|
24
|
+
minWidth: 27,
|
|
25
|
+
};
|
|
26
|
+
|
|
21
27
|
export const ToolbarMenuDropdown = memoGeneric(function ToolbarMenuDropdown<
|
|
22
28
|
T extends string,
|
|
23
29
|
>({
|
|
@@ -41,10 +47,10 @@ export const ToolbarMenuDropdown = memoGeneric(function ToolbarMenuDropdown<
|
|
|
41
47
|
}}
|
|
42
48
|
>
|
|
43
49
|
<Button disabled={item.disabled} active={item.checked || open}>
|
|
44
|
-
{item.title}
|
|
45
|
-
{item.title && item.icon && <Spacer.Horizontal inline size={6} />}
|
|
46
50
|
{item.icon && renderIcon(item.icon)}
|
|
47
|
-
<Spacer.Horizontal size={6} />
|
|
51
|
+
{item.title && item.icon && <Spacer.Horizontal inline size={6} />}
|
|
52
|
+
{item.title}
|
|
53
|
+
<Spacer.Horizontal inline size={6} />
|
|
48
54
|
<DropdownChevronIcon />
|
|
49
55
|
</Button>
|
|
50
56
|
</DropdownMenu>
|
|
@@ -64,15 +70,16 @@ export const ToolbarMenuButton = memoGeneric(function ToolbarMenuButton<
|
|
|
64
70
|
<Button
|
|
65
71
|
disabled={item.disabled}
|
|
66
72
|
active={item.checked}
|
|
73
|
+
style={item.icon && !item.title ? iconButtonStyle : undefined}
|
|
67
74
|
onClick={() => {
|
|
68
75
|
if (onSelectMenuItem && item.value) {
|
|
69
76
|
onSelectMenuItem(item.value);
|
|
70
77
|
}
|
|
71
78
|
}}
|
|
72
79
|
>
|
|
73
|
-
{item.title}
|
|
74
|
-
{item.title && item.icon && <Spacer.Horizontal inline size={6} />}
|
|
75
80
|
{item.icon && renderIcon(item.icon)}
|
|
81
|
+
{item.title && item.icon && <Spacer.Horizontal inline size={6} />}
|
|
82
|
+
{item.title}
|
|
76
83
|
</Button>
|
|
77
84
|
);
|
|
78
85
|
|
|
@@ -85,6 +92,54 @@ export const ToolbarMenuButton = memoGeneric(function ToolbarMenuButton<
|
|
|
85
92
|
);
|
|
86
93
|
});
|
|
87
94
|
|
|
95
|
+
export const ToolbarMenuItem = memoGeneric(function ToolbarMenuItem<
|
|
96
|
+
T extends string,
|
|
97
|
+
>({
|
|
98
|
+
item,
|
|
99
|
+
onSelectMenuItem,
|
|
100
|
+
}: {
|
|
101
|
+
item: MenuItem<T>;
|
|
102
|
+
onSelectMenuItem?: (value: T) => void;
|
|
103
|
+
}) {
|
|
104
|
+
if (item.type === "sectionHeader") return null;
|
|
105
|
+
|
|
106
|
+
if (item.type === "separator") {
|
|
107
|
+
return <DividerVertical overflow={4} />;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (isSelectableMenuItem(item)) {
|
|
111
|
+
return (
|
|
112
|
+
<ToolbarMenuButton item={item} onSelectMenuItem={onSelectMenuItem} />
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<ToolbarMenuDropdown item={item} onSelectMenuItem={onSelectMenuItem} />
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
export const ToolbarMenu = memoGeneric(function ToolbarMenu<T extends string>({
|
|
122
|
+
items,
|
|
123
|
+
onSelectMenuItem,
|
|
124
|
+
}: {
|
|
125
|
+
items: MenuItem<T>[];
|
|
126
|
+
onSelectMenuItem?: (value: T) => void;
|
|
127
|
+
}) {
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
{items.map((item, i) => {
|
|
131
|
+
return (
|
|
132
|
+
<ToolbarMenuItem
|
|
133
|
+
key={i}
|
|
134
|
+
item={item}
|
|
135
|
+
onSelectMenuItem={onSelectMenuItem}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
})}
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
88
143
|
export interface ToolbarProps<T extends string = string> {
|
|
89
144
|
children?: React.ReactNode;
|
|
90
145
|
logo?: React.ReactNode;
|
|
@@ -147,41 +202,3 @@ export function Toolbar<T extends string = string>({
|
|
|
147
202
|
</BaseToolbar>
|
|
148
203
|
);
|
|
149
204
|
}
|
|
150
|
-
|
|
151
|
-
export const ToolbarMenu = memoGeneric(function ToolbarMenu<T extends string>({
|
|
152
|
-
items,
|
|
153
|
-
onSelectMenuItem,
|
|
154
|
-
}: {
|
|
155
|
-
items: MenuItem<T>[];
|
|
156
|
-
onSelectMenuItem?: (value: T) => void;
|
|
157
|
-
}) {
|
|
158
|
-
return (
|
|
159
|
-
<>
|
|
160
|
-
{items.map((item, i) => {
|
|
161
|
-
if (item.type === "sectionHeader") return null;
|
|
162
|
-
|
|
163
|
-
if (item.type === "separator") {
|
|
164
|
-
return <DividerVertical key={i} overflow={4} />;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (isSelectableMenuItem(item)) {
|
|
168
|
-
return (
|
|
169
|
-
<ToolbarMenuButton
|
|
170
|
-
key={i}
|
|
171
|
-
item={item}
|
|
172
|
-
onSelectMenuItem={onSelectMenuItem}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<ToolbarMenuDropdown
|
|
179
|
-
key={i}
|
|
180
|
-
item={item}
|
|
181
|
-
onSelectMenuItem={onSelectMenuItem}
|
|
182
|
-
/>
|
|
183
|
-
);
|
|
184
|
-
})}
|
|
185
|
-
</>
|
|
186
|
-
);
|
|
187
|
-
});
|
|
@@ -60,11 +60,11 @@ export const ConnectedUsersMenuLayout = ({
|
|
|
60
60
|
: undefined,
|
|
61
61
|
}}
|
|
62
62
|
>
|
|
63
|
-
AI
|
|
64
|
-
<Spacer.Horizontal size={8} />
|
|
65
63
|
<ChatBubbleWithDotsIcon
|
|
66
64
|
color={isAssistantOpen ? undefined : cssVars.colors.icon}
|
|
67
65
|
/>
|
|
66
|
+
<Spacer.Horizontal inline size={6} />
|
|
67
|
+
AI
|
|
68
68
|
</Button>
|
|
69
69
|
</Tooltip>
|
|
70
70
|
)}
|
|
@@ -159,7 +159,7 @@ export const getMenuItemKey = <T extends string>(
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
export const CHECKBOX_WIDTH = 15;
|
|
162
|
-
export const CHECKBOX_RIGHT_INSET =
|
|
162
|
+
export const CHECKBOX_RIGHT_INSET = 6;
|
|
163
163
|
export const CHECKBOX_INDENT_WIDTH = 6;
|
|
164
164
|
|
|
165
165
|
export const styles = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { renderIcon } from "../Icons";
|
|
2
2
|
|
|
3
|
-
import { CheckIcon } from "@noya-app/noya-icons";
|
|
4
3
|
import * as Select from "@radix-ui/react-select";
|
|
5
4
|
import React, { useCallback } from "react";
|
|
6
5
|
import { cx } from "../../utils/classNames";
|
|
@@ -68,7 +67,7 @@ export const SelectItem = React.forwardRef(
|
|
|
68
67
|
<Spacer.Horizontal size={CHECKBOX_INDENT_WIDTH} />
|
|
69
68
|
{Components.ItemIndicator && (
|
|
70
69
|
<Components.ItemIndicator {...styles.itemIndicator}>
|
|
71
|
-
<
|
|
70
|
+
<Checkmark />
|
|
72
71
|
</Components.ItemIndicator>
|
|
73
72
|
)}
|
|
74
73
|
{icon && (
|
|
@@ -109,7 +108,7 @@ export const SelectItem = React.forwardRef(
|
|
|
109
108
|
{indented && <Spacer.Horizontal size={CHECKBOX_INDENT_WIDTH} />}
|
|
110
109
|
{checked ? (
|
|
111
110
|
<div {...styles.itemIndicator}>
|
|
112
|
-
<
|
|
111
|
+
<Checkmark />
|
|
113
112
|
</div>
|
|
114
113
|
) : indented ? (
|
|
115
114
|
<Spacer.Horizontal size={CHECKBOX_WIDTH - CHECKBOX_RIGHT_INSET} />
|
|
@@ -134,3 +133,25 @@ export const SelectItem = React.forwardRef(
|
|
|
134
133
|
);
|
|
135
134
|
}
|
|
136
135
|
);
|
|
136
|
+
|
|
137
|
+
function Checkmark() {
|
|
138
|
+
return (
|
|
139
|
+
<svg
|
|
140
|
+
viewBox="0 0 15 15"
|
|
141
|
+
fill="none"
|
|
142
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
width={15}
|
|
145
|
+
height={15}
|
|
146
|
+
>
|
|
147
|
+
<path
|
|
148
|
+
className="scale-90 origin-center"
|
|
149
|
+
d="M3 8L6 11L12 5"
|
|
150
|
+
strokeWidth="1.1"
|
|
151
|
+
strokeLinecap="round"
|
|
152
|
+
strokeLinejoin="round"
|
|
153
|
+
stroke="currentColor"
|
|
154
|
+
/>
|
|
155
|
+
</svg>
|
|
156
|
+
);
|
|
157
|
+
}
|