@noya-app/noya-designsystem 0.1.22 → 0.1.24
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 +9 -9
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +632 -602
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +295 -265
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Button.tsx +2 -2
- package/src/components/ContextMenu.tsx +2 -1
- package/src/components/DropdownMenu.tsx +3 -2
- package/src/components/IconButton.tsx +2 -2
- package/src/components/Icons.tsx +18 -0
- package/src/components/InputField.tsx +11 -1
- package/src/components/ListView.tsx +18 -1
- package/src/components/Select.tsx +1 -1
- package/src/components/SelectMenu.tsx +3 -2
- package/src/components/TreeView.tsx +3 -2
- package/src/components/internal/Menu.tsx +2 -1
package/package.json
CHANGED
|
@@ -57,10 +57,10 @@ export const ButtonElement = styled.button<{
|
|
|
57
57
|
borderRadius: "4px",
|
|
58
58
|
paddingTop: $variant === "none" ? "0px" : "4px",
|
|
59
59
|
paddingRight:
|
|
60
|
-
$variant === "none" ? "0px" : $variant === "thin" ? "1px" : "
|
|
60
|
+
$variant === "none" ? "0px" : $variant === "thin" ? "1px" : "6px",
|
|
61
61
|
paddingBottom: $variant === "none" ? "0px" : "4px",
|
|
62
62
|
paddingLeft:
|
|
63
|
-
$variant === "none" ? "0px" : $variant === "thin" ? "1px" : "
|
|
63
|
+
$variant === "none" ? "0px" : $variant === "thin" ? "1px" : "6px",
|
|
64
64
|
...($size === "large" && {
|
|
65
65
|
paddingTop: "12px",
|
|
66
66
|
paddingRight: "16px",
|
|
@@ -3,6 +3,7 @@ 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
5
|
import styled from "styled-components";
|
|
6
|
+
import { renderIcon } from "./Icons";
|
|
6
7
|
import { Spacer } from "./Spacer";
|
|
7
8
|
import {
|
|
8
9
|
CHECKBOX_RIGHT_INSET,
|
|
@@ -98,7 +99,7 @@ const ContextMenuItem = memo(function ContextMenuItem<T extends string>({
|
|
|
98
99
|
)}
|
|
99
100
|
{icon && (
|
|
100
101
|
<>
|
|
101
|
-
{icon}
|
|
102
|
+
{renderIcon(icon)}
|
|
102
103
|
<Spacer.Horizontal size={8} />
|
|
103
104
|
</>
|
|
104
105
|
)}
|
|
@@ -12,6 +12,7 @@ import React, {
|
|
|
12
12
|
} from "react";
|
|
13
13
|
import styled from "styled-components";
|
|
14
14
|
import { MenuItemProps, MenuProps } from "./ContextMenu";
|
|
15
|
+
import { renderIcon } from "./Icons";
|
|
15
16
|
import { Spacer } from "./Spacer";
|
|
16
17
|
import {
|
|
17
18
|
CHECKBOX_RIGHT_INSET,
|
|
@@ -73,7 +74,7 @@ const DropdownMenuItem = memo(function ContextMenuItem<T extends string>({
|
|
|
73
74
|
</StyledItemIndicator>
|
|
74
75
|
{icon && (
|
|
75
76
|
<>
|
|
76
|
-
{icon}
|
|
77
|
+
{renderIcon(icon)}
|
|
77
78
|
<Spacer.Horizontal size={8} />
|
|
78
79
|
</>
|
|
79
80
|
)}
|
|
@@ -89,7 +90,7 @@ const DropdownMenuItem = memo(function ContextMenuItem<T extends string>({
|
|
|
89
90
|
)}
|
|
90
91
|
{icon && (
|
|
91
92
|
<>
|
|
92
|
-
{icon}
|
|
93
|
+
{renderIcon(icon)}
|
|
93
94
|
<Spacer.Horizontal size={8} />
|
|
94
95
|
</>
|
|
95
96
|
)}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Icons from "@noya-app/noya-icons";
|
|
2
1
|
import React, {
|
|
3
2
|
CSSProperties,
|
|
4
3
|
ForwardedRef,
|
|
@@ -8,9 +7,10 @@ import React, {
|
|
|
8
7
|
} from "react";
|
|
9
8
|
import { useTheme } from "styled-components";
|
|
10
9
|
import { Button, ButtonRootProps } from "./Button";
|
|
10
|
+
import { IconName, Icons } from "./Icons";
|
|
11
11
|
|
|
12
12
|
type Props = Omit<ButtonRootProps, "children" | "variant" | "flex" | "size"> & {
|
|
13
|
-
iconName:
|
|
13
|
+
iconName: IconName;
|
|
14
14
|
className?: string;
|
|
15
15
|
style?: CSSProperties;
|
|
16
16
|
selected?: boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as Icons from "@noya-app/noya-icons";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
export type IconName = keyof typeof Icons;
|
|
5
|
+
|
|
6
|
+
export { Icons };
|
|
7
|
+
|
|
8
|
+
export function renderIcon(
|
|
9
|
+
iconName: Exclude<ReactNode, string> | IconName
|
|
10
|
+
): ReactNode {
|
|
11
|
+
if (typeof iconName === "string") {
|
|
12
|
+
const Icon = Icons[iconName as IconName];
|
|
13
|
+
|
|
14
|
+
return <Icon />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return iconName;
|
|
18
|
+
}
|
|
@@ -543,6 +543,8 @@ interface InputFieldRootProps {
|
|
|
543
543
|
size?: InputFieldSize;
|
|
544
544
|
renderPopoverContent?: (options: { width: number }) => ReactNode;
|
|
545
545
|
onFocusChange?: (isFocused: boolean) => void;
|
|
546
|
+
style?: React.CSSProperties;
|
|
547
|
+
className?: string;
|
|
546
548
|
}
|
|
547
549
|
|
|
548
550
|
function InputFieldRoot({
|
|
@@ -555,6 +557,8 @@ function InputFieldRoot({
|
|
|
555
557
|
size = "medium",
|
|
556
558
|
renderPopoverContent,
|
|
557
559
|
onFocusChange,
|
|
560
|
+
style,
|
|
561
|
+
className,
|
|
558
562
|
}: InputFieldRootProps) {
|
|
559
563
|
const childrenArray = Children.toArray(children);
|
|
560
564
|
|
|
@@ -617,7 +621,13 @@ function InputFieldRoot({
|
|
|
617
621
|
);
|
|
618
622
|
|
|
619
623
|
const rootElement = (
|
|
620
|
-
<RootContainer
|
|
624
|
+
<RootContainer
|
|
625
|
+
id={id}
|
|
626
|
+
$width={width}
|
|
627
|
+
$flex={flex}
|
|
628
|
+
style={style}
|
|
629
|
+
className={className}
|
|
630
|
+
>
|
|
621
631
|
{children}
|
|
622
632
|
</RootContainer>
|
|
623
633
|
);
|
|
@@ -333,6 +333,13 @@ interface ListViewRowProps<MenuItemType extends string = string> {
|
|
|
333
333
|
onMenuOpenChange?: (isOpen: boolean) => void;
|
|
334
334
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
335
335
|
style?: CSSProperties;
|
|
336
|
+
dragIndicatorStyle?:
|
|
337
|
+
| CSSProperties
|
|
338
|
+
| ((props: {
|
|
339
|
+
depth: number;
|
|
340
|
+
indentation: number;
|
|
341
|
+
position: RelativeDropPosition;
|
|
342
|
+
}) => CSSProperties);
|
|
336
343
|
}
|
|
337
344
|
|
|
338
345
|
const ListViewRow = forwardRef(function ListViewRow<
|
|
@@ -359,6 +366,7 @@ const ListViewRow = forwardRef(function ListViewRow<
|
|
|
359
366
|
onMenuOpenChange,
|
|
360
367
|
onKeyDown,
|
|
361
368
|
style,
|
|
369
|
+
dragIndicatorStyle,
|
|
362
370
|
}: ListViewRowProps<MenuItemType>,
|
|
363
371
|
forwardedRef: ForwardedRef<HTMLElement>
|
|
364
372
|
) {
|
|
@@ -461,7 +469,16 @@ const ListViewRow = forwardRef(function ListViewRow<
|
|
|
461
469
|
$colorScheme={colorScheme}
|
|
462
470
|
$relativeDropPosition={relativeDropPosition}
|
|
463
471
|
$offsetLeft={33 + depth * indentation}
|
|
464
|
-
$gap={listGap}
|
|
472
|
+
$gap={listGap + (divider ? 1 : 0)}
|
|
473
|
+
style={
|
|
474
|
+
typeof dragIndicatorStyle === "function"
|
|
475
|
+
? dragIndicatorStyle({
|
|
476
|
+
depth,
|
|
477
|
+
indentation,
|
|
478
|
+
position: relativeDropPosition,
|
|
479
|
+
})
|
|
480
|
+
: dragIndicatorStyle
|
|
481
|
+
}
|
|
465
482
|
/>
|
|
466
483
|
)}
|
|
467
484
|
{depth > 0 && <Spacer.Horizontal size={depth * indentation} />}
|
|
@@ -77,7 +77,7 @@ const SelectElement = styled.select<{ $flex: CSSProperties["flex"] }>(
|
|
|
77
77
|
borderRadius: "4px",
|
|
78
78
|
paddingTop: "4px",
|
|
79
79
|
paddingBottom: "4px",
|
|
80
|
-
paddingLeft: "
|
|
80
|
+
paddingLeft: "6px",
|
|
81
81
|
paddingRight: "23px",
|
|
82
82
|
background: [
|
|
83
83
|
`calc(100% - 6px) / 15px url("data:image/svg+xml;utf8,${createChevronSVGString(
|
|
@@ -3,6 +3,7 @@ import * as Select from "@radix-ui/react-select";
|
|
|
3
3
|
import React, { memo } from "react";
|
|
4
4
|
import { styled } from "styled-components";
|
|
5
5
|
import { Button } from "./Button";
|
|
6
|
+
import { renderIcon } from "./Icons";
|
|
6
7
|
import { Spacer } from "./Spacer";
|
|
7
8
|
import { MenuItem, RegularMenuItem, styles } from "./internal/Menu";
|
|
8
9
|
|
|
@@ -37,7 +38,7 @@ export const SelectMenu = memo(function SelectMenu<T extends string = string>({
|
|
|
37
38
|
<Button id={id} style={style} className={className}>
|
|
38
39
|
{icon && (
|
|
39
40
|
<>
|
|
40
|
-
{icon}
|
|
41
|
+
{renderIcon(icon)}
|
|
41
42
|
<Spacer.Horizontal size={8} />
|
|
42
43
|
</>
|
|
43
44
|
)}
|
|
@@ -86,7 +87,7 @@ const SelectItem = React.forwardRef(
|
|
|
86
87
|
<StyledItem {...props} ref={forwardedRef}>
|
|
87
88
|
{icon && (
|
|
88
89
|
<>
|
|
89
|
-
{icon}
|
|
90
|
+
{renderIcon(icon)}
|
|
90
91
|
<Spacer.Horizontal size={8} />
|
|
91
92
|
</>
|
|
92
93
|
)}
|
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
useContext,
|
|
8
8
|
} from "react";
|
|
9
9
|
import { IconButton } from "./IconButton";
|
|
10
|
+
import { IconName, renderIcon } from "./Icons";
|
|
10
11
|
import { ListView } from "./ListView";
|
|
11
12
|
import { Spacer } from "./Spacer";
|
|
12
13
|
|
|
@@ -15,7 +16,7 @@ import { Spacer } from "./Spacer";
|
|
|
15
16
|
* ------------------------------------------------------------------------- */
|
|
16
17
|
|
|
17
18
|
type TreeRowBaseProps = {
|
|
18
|
-
icon?: ReactNode;
|
|
19
|
+
icon?: Exclude<ReactNode, string> | IconName;
|
|
19
20
|
expanded?: boolean;
|
|
20
21
|
onClickChevron?: ({ altKey }: { altKey: boolean }) => void;
|
|
21
22
|
};
|
|
@@ -61,7 +62,7 @@ const TreeRow = forwardRef(function TreeRow<MenuItemType extends string>(
|
|
|
61
62
|
)}
|
|
62
63
|
{icon && (
|
|
63
64
|
<>
|
|
64
|
-
{icon}
|
|
65
|
+
{renderIcon(icon)}
|
|
65
66
|
<Spacer.Horizontal size={10} />
|
|
66
67
|
</>
|
|
67
68
|
)}
|
|
@@ -4,6 +4,7 @@ import styled, { CSSObject } from "styled-components";
|
|
|
4
4
|
import { useDesignSystemConfiguration } from "../../contexts/DesignSystemConfiguration";
|
|
5
5
|
import { Theme } from "../../theme";
|
|
6
6
|
import withSeparatorElements from "../../utils/withSeparatorElements";
|
|
7
|
+
import { IconName } from "../Icons";
|
|
7
8
|
|
|
8
9
|
export const SEPARATOR_ITEM = "separator";
|
|
9
10
|
|
|
@@ -63,7 +64,7 @@ export type RegularMenuItem<T extends string> = {
|
|
|
63
64
|
shortcut?: string;
|
|
64
65
|
checked?: boolean;
|
|
65
66
|
disabled?: boolean;
|
|
66
|
-
icon?: ReactNode;
|
|
67
|
+
icon?: Exclude<ReactNode, string> | IconName;
|
|
67
68
|
items?: MenuItem<T>[];
|
|
68
69
|
role?: MenuItemRole;
|
|
69
70
|
};
|