@noya-app/noya-designsystem 0.0.14 → 0.0.16
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/.eslintrc.js +11 -0
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-lint.log +3 -0
- package/CHANGELOG.md +24 -0
- package/dist/index.d.mts +133 -111
- package/dist/index.d.ts +133 -111
- package/dist/index.js +7832 -646
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7819 -601
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/components/Chip.tsx +101 -82
- package/src/components/Dialog.tsx +51 -26
- package/src/components/DraggableMenuButton.tsx +116 -0
- package/src/components/InputField.tsx +196 -132
- package/src/components/InputFieldWithCompletions.tsx +43 -6
- package/src/components/InspectorPrimitives.tsx +1 -1
- package/src/components/ListView.tsx +77 -38
- package/src/components/Select.tsx +2 -0
- package/src/components/Sortable.tsx +45 -36
- package/src/components/Stack.tsx +63 -62
- package/src/components/Switch.tsx +25 -25
- package/src/components/Text.tsx +3 -0
- package/src/contexts/DialogContext.tsx +3 -0
- package/src/index.tsx +3 -2
- package/src/theme/light.ts +1 -1
- package/src/utils/getGradientBackground.tsx +8 -10
package/src/components/Stack.tsx
CHANGED
|
@@ -6,63 +6,64 @@ import React, {
|
|
|
6
6
|
memo,
|
|
7
7
|
ReactHTML,
|
|
8
8
|
ReactNode,
|
|
9
|
-
} from
|
|
10
|
-
import styled from
|
|
11
|
-
import { BreakpointCollection, mergeBreakpoints } from
|
|
12
|
-
import withSeparatorElements from
|
|
9
|
+
} from "react";
|
|
10
|
+
import styled from "styled-components";
|
|
11
|
+
import { BreakpointCollection, mergeBreakpoints } from "../utils/breakpoints";
|
|
12
|
+
import withSeparatorElements from "../utils/withSeparatorElements";
|
|
13
13
|
|
|
14
14
|
interface StyleProps {
|
|
15
|
-
display?:
|
|
16
|
-
visibility?: CSSProperties[
|
|
17
|
-
position?: CSSProperties[
|
|
18
|
-
zIndex?: CSSProperties[
|
|
19
|
-
gap?: CSSProperties[
|
|
20
|
-
inset?: CSSProperties[
|
|
21
|
-
top?: CSSProperties[
|
|
22
|
-
right?: CSSProperties[
|
|
23
|
-
bottom?: CSSProperties[
|
|
24
|
-
left?: CSSProperties[
|
|
25
|
-
flexDirection?: CSSProperties[
|
|
26
|
-
justifyContent?: CSSProperties[
|
|
27
|
-
alignItems?: CSSProperties[
|
|
28
|
-
alignSelf?: CSSProperties[
|
|
29
|
-
flex?: CSSProperties[
|
|
30
|
-
flexWrap?: CSSProperties[
|
|
31
|
-
height?: CSSProperties[
|
|
32
|
-
minHeight?: CSSProperties[
|
|
33
|
-
maxHeight?: CSSProperties[
|
|
34
|
-
width?: CSSProperties[
|
|
35
|
-
minWidth?: CSSProperties[
|
|
36
|
-
maxWidth?: CSSProperties[
|
|
37
|
-
aspectRatio?: CSSProperties[
|
|
38
|
-
padding?: CSSProperties[
|
|
15
|
+
display?: "flex" | "inline-flex" | "none" | "block";
|
|
16
|
+
visibility?: CSSProperties["visibility"];
|
|
17
|
+
position?: CSSProperties["position"];
|
|
18
|
+
zIndex?: CSSProperties["zIndex"];
|
|
19
|
+
gap?: CSSProperties["gap"];
|
|
20
|
+
inset?: CSSProperties["inset"];
|
|
21
|
+
top?: CSSProperties["top"];
|
|
22
|
+
right?: CSSProperties["right"];
|
|
23
|
+
bottom?: CSSProperties["bottom"];
|
|
24
|
+
left?: CSSProperties["left"];
|
|
25
|
+
flexDirection?: CSSProperties["flexDirection"];
|
|
26
|
+
justifyContent?: CSSProperties["justifyContent"];
|
|
27
|
+
alignItems?: CSSProperties["alignItems"];
|
|
28
|
+
alignSelf?: CSSProperties["alignSelf"];
|
|
29
|
+
flex?: CSSProperties["flex"];
|
|
30
|
+
flexWrap?: CSSProperties["flexWrap"];
|
|
31
|
+
height?: CSSProperties["height"];
|
|
32
|
+
minHeight?: CSSProperties["minHeight"];
|
|
33
|
+
maxHeight?: CSSProperties["maxHeight"];
|
|
34
|
+
width?: CSSProperties["width"];
|
|
35
|
+
minWidth?: CSSProperties["minWidth"];
|
|
36
|
+
maxWidth?: CSSProperties["maxWidth"];
|
|
37
|
+
aspectRatio?: CSSProperties["aspectRatio"];
|
|
38
|
+
padding?: CSSProperties["padding"];
|
|
39
39
|
paddingVertical?: string | number;
|
|
40
40
|
paddingHorizontal?: string | number;
|
|
41
|
-
margin?: CSSProperties[
|
|
42
|
-
background?: CSSProperties[
|
|
43
|
-
backgroundSize?: CSSProperties[
|
|
44
|
-
backgroundPosition?: CSSProperties[
|
|
45
|
-
borderRadius?: CSSProperties[
|
|
46
|
-
overflowX?: CSSProperties[
|
|
47
|
-
overflowY?: CSSProperties[
|
|
48
|
-
overflow?: CSSProperties[
|
|
49
|
-
textOverflow?: CSSProperties[
|
|
50
|
-
boxShadow?: CSSProperties[
|
|
51
|
-
outline?: CSSProperties[
|
|
52
|
-
border?: CSSProperties[
|
|
53
|
-
borderTop?: CSSProperties[
|
|
54
|
-
borderRight?: CSSProperties[
|
|
55
|
-
borderBottom?: CSSProperties[
|
|
56
|
-
borderLeft?: CSSProperties[
|
|
57
|
-
cursor?: CSSProperties[
|
|
58
|
-
userSelect?: CSSProperties[
|
|
59
|
-
transition?: CSSProperties[
|
|
60
|
-
opacity?: CSSProperties[
|
|
61
|
-
filter?: CSSProperties[
|
|
62
|
-
color?: CSSProperties[
|
|
63
|
-
order?: CSSProperties[
|
|
64
|
-
pointerEvents?: CSSProperties[
|
|
65
|
-
lineHeight?: CSSProperties[
|
|
41
|
+
margin?: CSSProperties["margin"];
|
|
42
|
+
background?: CSSProperties["background"];
|
|
43
|
+
backgroundSize?: CSSProperties["backgroundSize"];
|
|
44
|
+
backgroundPosition?: CSSProperties["backgroundPosition"];
|
|
45
|
+
borderRadius?: CSSProperties["borderRadius"];
|
|
46
|
+
overflowX?: CSSProperties["overflowX"];
|
|
47
|
+
overflowY?: CSSProperties["overflowY"];
|
|
48
|
+
overflow?: CSSProperties["overflow"];
|
|
49
|
+
textOverflow?: CSSProperties["textOverflow"];
|
|
50
|
+
boxShadow?: CSSProperties["boxShadow"];
|
|
51
|
+
outline?: CSSProperties["outline"];
|
|
52
|
+
border?: CSSProperties["border"];
|
|
53
|
+
borderTop?: CSSProperties["borderTop"];
|
|
54
|
+
borderRight?: CSSProperties["borderRight"];
|
|
55
|
+
borderBottom?: CSSProperties["borderBottom"];
|
|
56
|
+
borderLeft?: CSSProperties["borderLeft"];
|
|
57
|
+
cursor?: CSSProperties["cursor"];
|
|
58
|
+
userSelect?: CSSProperties["userSelect"];
|
|
59
|
+
transition?: CSSProperties["transition"];
|
|
60
|
+
opacity?: CSSProperties["opacity"];
|
|
61
|
+
filter?: CSSProperties["filter"];
|
|
62
|
+
color?: CSSProperties["color"];
|
|
63
|
+
order?: CSSProperties["order"];
|
|
64
|
+
pointerEvents?: CSSProperties["pointerEvents"];
|
|
65
|
+
lineHeight?: CSSProperties["lineHeight"];
|
|
66
|
+
isolation?: CSSProperties["isolation"];
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export type StackBreakpointList = BreakpointCollection<StyleProps>;
|
|
@@ -88,16 +89,16 @@ const Element = styled.div<{
|
|
|
88
89
|
|
|
89
90
|
const StackBase = forwardRef(function StackBase(
|
|
90
91
|
{ id, as, children, separator, breakpoints, tabIndex, href, ...rest }: Props,
|
|
91
|
-
forwardedRef: ForwardedRef<HTMLElement
|
|
92
|
+
forwardedRef: ForwardedRef<HTMLElement>
|
|
92
93
|
) {
|
|
93
94
|
const elements = separator
|
|
94
95
|
? withSeparatorElements(Children.toArray(children), separator)
|
|
95
96
|
: children;
|
|
96
97
|
|
|
97
98
|
const styleProps: StyleProps = {
|
|
98
|
-
display:
|
|
99
|
-
position:
|
|
100
|
-
alignItems:
|
|
99
|
+
display: "flex",
|
|
100
|
+
position: "relative",
|
|
101
|
+
alignItems: "stretch",
|
|
101
102
|
...rest,
|
|
102
103
|
};
|
|
103
104
|
|
|
@@ -116,24 +117,24 @@ const StackBase = forwardRef(function StackBase(
|
|
|
116
117
|
);
|
|
117
118
|
});
|
|
118
119
|
|
|
119
|
-
type StackProps = Omit<Props,
|
|
120
|
+
type StackProps = Omit<Props, "flexDirection">;
|
|
120
121
|
|
|
121
122
|
const VerticalStack = memo(
|
|
122
123
|
forwardRef(function VStack(
|
|
123
124
|
props: StackProps,
|
|
124
|
-
forwardedRef: ForwardedRef<HTMLElement
|
|
125
|
+
forwardedRef: ForwardedRef<HTMLElement>
|
|
125
126
|
) {
|
|
126
127
|
return <StackBase {...props} flexDirection="column" ref={forwardedRef} />;
|
|
127
|
-
})
|
|
128
|
+
})
|
|
128
129
|
);
|
|
129
130
|
|
|
130
131
|
const HorizontalStack = memo(
|
|
131
132
|
forwardRef(function HStack(
|
|
132
133
|
props: StackProps,
|
|
133
|
-
forwardedRef: ForwardedRef<HTMLElement
|
|
134
|
+
forwardedRef: ForwardedRef<HTMLElement>
|
|
134
135
|
) {
|
|
135
136
|
return <StackBase {...props} flexDirection="row" ref={forwardedRef} />;
|
|
136
|
-
})
|
|
137
|
+
})
|
|
137
138
|
);
|
|
138
139
|
|
|
139
140
|
export const Stack = {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as SwitchPrimitive from
|
|
2
|
-
import React from
|
|
3
|
-
import styled from
|
|
1
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type SwitchColorScheme = "normal" | "primary" | "secondary";
|
|
6
6
|
|
|
7
7
|
const SwitchRoot = styled(SwitchPrimitive.Root)<{
|
|
8
|
-
|
|
9
|
-
}>(({ theme, variant }) => ({
|
|
10
|
-
all:
|
|
8
|
+
colorScheme: SwitchColorScheme;
|
|
9
|
+
}>(({ theme, colorScheme: variant }) => ({
|
|
10
|
+
all: "unset",
|
|
11
11
|
width: 32,
|
|
12
12
|
height: 19,
|
|
13
13
|
backgroundColor: theme.colors.activeBackground,
|
|
14
|
-
borderRadius:
|
|
15
|
-
position:
|
|
16
|
-
WebkitTapHighlightColor:
|
|
17
|
-
cursor:
|
|
14
|
+
borderRadius: "9999px",
|
|
15
|
+
position: "relative",
|
|
16
|
+
WebkitTapHighlightColor: "rgba(0, 0, 0, 0)",
|
|
17
|
+
cursor: "pointer",
|
|
18
18
|
// '&:focus': {
|
|
19
19
|
// boxShadow: `0 0 0 1px ${
|
|
20
20
|
// variant === 'secondary' ? theme.colors.secondary : theme.colors.primary
|
|
@@ -22,40 +22,40 @@ const SwitchRoot = styled(SwitchPrimitive.Root)<{
|
|
|
22
22
|
// },
|
|
23
23
|
'&[data-state="checked"]': {
|
|
24
24
|
backgroundColor:
|
|
25
|
-
variant ===
|
|
25
|
+
variant === "primary"
|
|
26
26
|
? theme.colors.primary
|
|
27
|
-
: variant ===
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
: variant === "secondary"
|
|
28
|
+
? theme.colors.secondary
|
|
29
|
+
: undefined,
|
|
30
30
|
},
|
|
31
31
|
}));
|
|
32
32
|
|
|
33
33
|
const SwitchThumb = styled(SwitchPrimitive.Thumb)({
|
|
34
|
-
display:
|
|
34
|
+
display: "block",
|
|
35
35
|
width: 15,
|
|
36
36
|
height: 15,
|
|
37
|
-
backgroundColor:
|
|
38
|
-
borderRadius:
|
|
39
|
-
transition:
|
|
40
|
-
transform:
|
|
41
|
-
willChange:
|
|
42
|
-
'&[data-state="checked"]': { transform:
|
|
37
|
+
backgroundColor: "white",
|
|
38
|
+
borderRadius: "9999px",
|
|
39
|
+
transition: "transform 100ms",
|
|
40
|
+
transform: "translateX(2px)",
|
|
41
|
+
willChange: "transform",
|
|
42
|
+
'&[data-state="checked"]': { transform: "translateX(15px)" },
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
interface Props {
|
|
46
46
|
value: boolean;
|
|
47
47
|
onChange: (value: boolean) => void;
|
|
48
|
-
|
|
48
|
+
colorScheme?: SwitchColorScheme;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export const Switch = function Switch({
|
|
52
52
|
value,
|
|
53
53
|
onChange,
|
|
54
|
-
|
|
54
|
+
colorScheme = "normal",
|
|
55
55
|
}: Props) {
|
|
56
56
|
return (
|
|
57
57
|
<SwitchRoot
|
|
58
|
-
|
|
58
|
+
colorScheme={colorScheme}
|
|
59
59
|
checked={value}
|
|
60
60
|
onCheckedChange={(newValue) => {
|
|
61
61
|
onChange(newValue);
|
package/src/components/Text.tsx
CHANGED
|
@@ -32,6 +32,8 @@ type StyleProps = {
|
|
|
32
32
|
whiteSpace?: CSSProperties["whiteSpace"];
|
|
33
33
|
height?: CSSProperties["height"];
|
|
34
34
|
width?: CSSProperties["width"];
|
|
35
|
+
minWidth?: CSSProperties["minWidth"];
|
|
36
|
+
maxWidth?: CSSProperties["maxWidth"];
|
|
35
37
|
opacity?: CSSProperties["opacity"];
|
|
36
38
|
position?: CSSProperties["position"];
|
|
37
39
|
overflow?: CSSProperties["overflow"];
|
|
@@ -57,6 +59,7 @@ interface Props extends StyleProps {
|
|
|
57
59
|
color?: ThemeColorName;
|
|
58
60
|
children: ReactNode;
|
|
59
61
|
onClick?: () => void;
|
|
62
|
+
onDoubleClick?: () => void;
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
const StyledElement = styled.span<
|
|
@@ -138,6 +138,9 @@ export const DialogProvider = function DialogProvider({
|
|
|
138
138
|
event.preventDefault();
|
|
139
139
|
|
|
140
140
|
inputRef.current?.focus();
|
|
141
|
+
|
|
142
|
+
// Select the entire input value
|
|
143
|
+
inputRef.current?.setSelectionRange(0, inputRef.current.value.length);
|
|
141
144
|
}, [])}
|
|
142
145
|
>
|
|
143
146
|
<InputField.Root>
|
package/src/index.tsx
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./components/Chip";
|
|
|
21
21
|
export * from "./components/ContextMenu";
|
|
22
22
|
export * from "./components/Dialog";
|
|
23
23
|
export * from "./components/Divider";
|
|
24
|
+
export * from "./components/DraggableMenuButton";
|
|
24
25
|
export * from "./components/DropdownMenu";
|
|
25
26
|
export * from "./components/FillInputField";
|
|
26
27
|
export * from "./components/FillPreviewBackground";
|
|
@@ -78,6 +79,6 @@ export * from "./utils/sketchPattern";
|
|
|
78
79
|
export { default as withSeparatorElements } from "./utils/withSeparatorElements";
|
|
79
80
|
|
|
80
81
|
// Avoid dependency cycles
|
|
81
|
-
export * as InspectorPrimitives from "./components/InspectorPrimitives";
|
|
82
82
|
export * from "./components/ArrayController";
|
|
83
|
-
export * from "./components/DimensionInput";
|
|
83
|
+
export * from "./components/DimensionInput";
|
|
84
|
+
export * as InspectorPrimitives from "./components/InspectorPrimitives";
|
package/src/theme/light.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Sketch } from
|
|
2
|
-
import { sketchColorToRgbaString } from
|
|
1
|
+
import { Sketch } from "@noya-app/noya-file-format";
|
|
2
|
+
import { sketchColorToRgbaString } from "./sketchColor";
|
|
3
3
|
|
|
4
4
|
const getRGBAColor = (value: Sketch.GradientStop[], num: 100 | 360) =>
|
|
5
5
|
[...value]
|
|
@@ -7,15 +7,15 @@ const getRGBAColor = (value: Sketch.GradientStop[], num: 100 | 360) =>
|
|
|
7
7
|
.map(
|
|
8
8
|
(g) =>
|
|
9
9
|
`${sketchColorToRgbaString(g.color)} ${g.position * num}${
|
|
10
|
-
num === 100 ?
|
|
11
|
-
}
|
|
10
|
+
num === 100 ? "%" : "deg"
|
|
11
|
+
}`
|
|
12
12
|
)
|
|
13
|
-
.join(
|
|
13
|
+
.join(", \n");
|
|
14
14
|
|
|
15
15
|
export function getGradientBackground(
|
|
16
16
|
value: Sketch.GradientStop[],
|
|
17
17
|
type: Sketch.GradientType,
|
|
18
|
-
direction?: number
|
|
18
|
+
direction?: number
|
|
19
19
|
) {
|
|
20
20
|
if (type === Sketch.GradientType.Angular) {
|
|
21
21
|
return `conic-gradient(${getRGBAColor(value, 360)})`;
|
|
@@ -24,10 +24,8 @@ export function getGradientBackground(
|
|
|
24
24
|
const color = getRGBAColor(value, 100);
|
|
25
25
|
const position =
|
|
26
26
|
type === Sketch.GradientType.Radial
|
|
27
|
-
?
|
|
28
|
-
: `linear-gradient(${
|
|
29
|
-
typeof direction !== undefined ? direction : 180
|
|
30
|
-
}deg`;
|
|
27
|
+
? "radial-gradient(circle"
|
|
28
|
+
: `linear-gradient(${direction !== undefined ? direction : 180}deg`;
|
|
31
29
|
|
|
32
30
|
return `${position}, ${color})`;
|
|
33
31
|
}
|