@noya-app/noya-designsystem 0.0.14 → 0.0.15

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.0.14",
3
+ "version": "0.0.15",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -12,11 +12,11 @@
12
12
  "@dnd-kit/core": "3.1.1",
13
13
  "@dnd-kit/modifiers": "3.0.0",
14
14
  "@dnd-kit/sortable": "4.0.0",
15
- "@noya-app/noya-colorpicker": "0.0.8",
16
- "@noya-app/noya-utils": "0.0.11",
17
- "@noya-app/noya-geometry": "0.0.12",
18
- "@noya-app/noya-icons": "0.0.5",
19
- "@noya-app/noya-keymap": "0.0.7",
15
+ "@noya-app/noya-colorpicker": "0.0.9",
16
+ "@noya-app/noya-utils": "0.0.12",
17
+ "@noya-app/noya-geometry": "0.0.13",
18
+ "@noya-app/noya-icons": "0.0.6",
19
+ "@noya-app/noya-keymap": "0.0.8",
20
20
  "@radix-ui/primitive": "^1.0.0",
21
21
  "@radix-ui/react-avatar": "^1.0.1",
22
22
  "@radix-ui/react-compose-refs": "^1.0.0",
@@ -1,12 +1,12 @@
1
- import { Cross1Icon, PlusIcon } from '@noya-app/noya-icons';
2
- import React, { memo } from 'react';
3
- import styled from 'styled-components';
4
- import { useDesignSystemTheme } from '../contexts/DesignSystemConfiguration';
5
- import { useHover } from '../hooks/useHover';
1
+ import { Cross1Icon, PlusIcon } from "@noya-app/noya-icons";
2
+ import React, { memo } from "react";
3
+ import styled from "styled-components";
4
+ import { useDesignSystemTheme } from "../contexts/DesignSystemConfiguration";
5
+ import { useHover } from "../hooks/useHover";
6
6
 
7
- type ChipColorScheme = 'primary' | 'secondary' | 'error';
8
- type ChipSize = 'small' | 'medium';
9
- type ChipVariant = 'solid' | 'outlined' | 'ghost';
7
+ type ChipColorScheme = "primary" | "secondary" | "error";
8
+ type ChipSize = "small" | "medium";
9
+ type ChipVariant = "solid" | "outlined" | "ghost";
10
10
 
11
11
  const ChipElement = styled.span<{
12
12
  colorScheme?: ChipColorScheme;
@@ -16,69 +16,70 @@ const ChipElement = styled.span<{
16
16
  isInteractive: boolean;
17
17
  }>(({ theme, colorScheme, size, variant, monospace, isInteractive }) => {
18
18
  const color =
19
- colorScheme === 'primary'
19
+ colorScheme === "primary"
20
20
  ? theme.colors.primary
21
- : colorScheme === 'secondary'
22
- ? theme.colors.secondary
23
- : theme.colors.text;
21
+ : colorScheme === "secondary"
22
+ ? theme.colors.secondary
23
+ : theme.colors.text;
24
24
 
25
25
  const backgroundColor =
26
- colorScheme === 'primary'
27
- ? 'rgb(238, 229, 255)'
28
- : colorScheme === 'secondary'
29
- ? 'rgb(205, 238, 231)'
30
- : colorScheme === 'error'
31
- ? 'rgb(255, 219, 219)'
32
- : theme.colors.inputBackground;
26
+ colorScheme === "primary"
27
+ ? "rgb(238, 229, 255)"
28
+ : colorScheme === "secondary"
29
+ ? "rgb(205, 238, 231)"
30
+ : colorScheme === "error"
31
+ ? "rgb(255, 219, 219)"
32
+ : theme.colors.inputBackground;
33
33
 
34
34
  const subtleColor =
35
- colorScheme === 'primary'
36
- ? 'rgba(238, 229, 255, 0.2)'
37
- : colorScheme === 'secondary'
38
- ? 'rgba(205, 238, 231, 0.2)'
39
- : colorScheme === 'error'
40
- ? 'rgba(255, 219, 219, 0.2)'
41
- : 'rgba(0, 0, 0, 0.1)';
35
+ colorScheme === "primary"
36
+ ? "rgba(238, 229, 255, 0.2)"
37
+ : colorScheme === "secondary"
38
+ ? "rgba(205, 238, 231, 0.2)"
39
+ : colorScheme === "error"
40
+ ? "rgba(255, 219, 219, 0.2)"
41
+ : "rgba(0, 0, 0, 0.1)";
42
42
 
43
43
  return {
44
- textTransform: 'initial',
44
+ textTransform: "initial",
45
45
  borderRadius: 4,
46
- userSelect: 'none',
47
- display: 'inline-flex',
48
- alignItems: 'center',
49
- lineHeight: '1.4',
50
- ...(size === 'medium'
46
+ userSelect: "none",
47
+ display: "inline-flex",
48
+ alignItems: "center",
49
+ lineHeight: "1.4",
50
+ whiteSpace: "pre",
51
+ ...(size === "medium"
51
52
  ? {
52
- fontSize: '11px',
53
- padding: '4px 8px',
53
+ fontSize: "11px",
54
+ padding: "4px 8px",
54
55
  }
55
56
  : {
56
- fontSize: '9px',
57
- padding: '0px 4px',
57
+ fontSize: "9px",
58
+ padding: "0px 4px",
58
59
  }),
59
60
  ...(monospace && {
60
61
  fontFamily: theme.fonts.monospace,
61
62
  }),
62
- ...(variant === 'solid'
63
+ ...(variant === "solid"
63
64
  ? {
64
65
  color,
65
66
  backgroundColor,
66
67
  }
67
- : variant === 'outlined'
68
- ? {
69
- color,
70
- backgroundColor: 'transparent',
71
- boxShadow: `0 0 0 1px ${subtleColor} inset`,
72
- }
73
- : {}),
74
- '&:hover': {
75
- ...(variant === 'outlined' && {
68
+ : variant === "outlined"
69
+ ? {
70
+ color,
71
+ backgroundColor: "transparent",
72
+ boxShadow: `0 0 0 1px ${subtleColor} inset`,
73
+ }
74
+ : {}),
75
+ "&:hover": {
76
+ ...(variant === "outlined" && {
76
77
  backgroundColor: subtleColor,
77
- boxShadow: 'none',
78
+ boxShadow: "none",
78
79
  }),
79
80
  },
80
81
  ...(isInteractive && {
81
- cursor: 'pointer',
82
+ cursor: "pointer",
82
83
  }),
83
84
  };
84
85
  });
@@ -86,27 +87,27 @@ const ChipElement = styled.span<{
86
87
  const DeleteElement = styled(Cross1Icon)<{
87
88
  size: ChipSize;
88
89
  }>(({ size }) => ({
89
- position: 'relative',
90
- marginRight: '-2px',
91
- cursor: 'pointer',
90
+ position: "relative",
91
+ marginRight: "-2px",
92
+ cursor: "pointer",
92
93
  opacity: 0.5,
93
94
 
94
- ...(size === 'medium'
95
+ ...(size === "medium"
95
96
  ? {
96
- marginLeft: '2px',
97
+ marginLeft: "2px",
97
98
  // top: '-1px',
98
- transform: 'scale(0.75)',
99
+ transform: "scale(0.75)",
99
100
  }
100
101
  : {
101
- transform: 'scale(0.6)',
102
+ transform: "scale(0.6)",
102
103
  }),
103
104
 
104
- '&:hover': {
105
+ "&:hover": {
105
106
  opacity: 0.85,
106
107
  },
107
108
  }));
108
109
 
109
- const ignoredProps = new Set(['size', 'isOnlyChild']);
110
+ const ignoredProps = new Set(["size", "isOnlyChild"]);
110
111
 
111
112
  const AddElement = styled(PlusIcon).withConfig({
112
113
  shouldForwardProp: (prop) => !ignoredProps.has(prop),
@@ -114,23 +115,23 @@ const AddElement = styled(PlusIcon).withConfig({
114
115
  size: ChipSize;
115
116
  isOnlyChild: boolean;
116
117
  }>(({ size, isOnlyChild }) => ({
117
- position: 'relative',
118
- marginRight: '-2px',
119
- cursor: 'pointer',
118
+ position: "relative",
119
+ marginRight: "-2px",
120
+ cursor: "pointer",
120
121
  opacity: 0.5,
121
122
 
122
- ...(size === 'medium'
123
+ ...(size === "medium"
123
124
  ? {
124
- marginLeft: '2px',
125
- top: '-1px',
126
- transform: 'scale(0.75)',
125
+ marginLeft: "2px",
126
+ top: "-1px",
127
+ transform: "scale(0.75)",
127
128
  }
128
129
  : {
129
- transform: 'scale(0.6)',
130
- ...(isOnlyChild && { marginLeft: '-2px' }),
130
+ transform: "scale(0.6)",
131
+ ...(isOnlyChild && { marginLeft: "-2px" }),
131
132
  }),
132
133
 
133
- '&:hover': {
134
+ "&:hover": {
134
135
  opacity: 0.85,
135
136
  },
136
137
  }));
@@ -157,8 +158,8 @@ export const Chip = memo(function Chip({
157
158
  deletable,
158
159
  addable,
159
160
  style,
160
- size = 'medium',
161
- variant = 'solid',
161
+ size = "medium",
162
+ variant = "solid",
162
163
  monospace = false,
163
164
  tabIndex,
164
165
  onDelete,
@@ -175,11 +176,11 @@ export const Chip = memo(function Chip({
175
176
  const handleClick = !children && !deletable && addable ? onAdd : onClick;
176
177
 
177
178
  const color =
178
- colorScheme === 'primary'
179
+ colorScheme === "primary"
179
180
  ? theme.colors.primary
180
- : colorScheme === 'secondary'
181
- ? theme.colors.secondary
182
- : theme.colors.text;
181
+ : colorScheme === "secondary"
182
+ ? theme.colors.secondary
183
+ : theme.colors.text;
183
184
 
184
185
  return (
185
186
  <ChipElement
@@ -1,4 +1,4 @@
1
- import * as DialogPrimitive from '@radix-ui/react-dialog';
1
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
2
2
  import React, {
3
3
  ComponentProps,
4
4
  ForwardedRef,
@@ -6,35 +6,35 @@ import React, {
6
6
  ReactNode,
7
7
  useImperativeHandle,
8
8
  useRef,
9
- } from 'react';
10
- import styled from 'styled-components';
11
- import { IconButton } from './IconButton';
12
- import { Spacer } from './Spacer';
9
+ } from "react";
10
+ import styled from "styled-components";
11
+ import { IconButton } from "./IconButton";
12
+ import { Spacer } from "./Spacer";
13
13
 
14
14
  const StyledOverlay = styled(DialogPrimitive.Overlay)({
15
- backgroundColor: 'rgba(0,0,0,0.5)',
16
- position: 'fixed',
15
+ backgroundColor: "rgba(0,0,0,0.5)",
16
+ position: "fixed",
17
17
  inset: 0,
18
18
  });
19
19
 
20
20
  const StyledContent = styled(DialogPrimitive.Content)(({ theme }) => ({
21
21
  boxShadow:
22
- 'hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px',
23
- position: 'fixed',
24
- top: '50%',
25
- left: '50%',
26
- transform: 'translate(-50%, -50%)',
27
- width: '90vw',
28
- maxWidth: '450px',
29
- maxHeight: '85vh',
22
+ "hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
23
+ position: "fixed",
24
+ top: "50%",
25
+ left: "50%",
26
+ transform: "translate(-50%, -50%)",
27
+ width: "90vw",
28
+ maxWidth: "450px",
29
+ maxHeight: "85vh",
30
30
  padding: theme.sizes.dialog.padding,
31
31
  borderRadius: 2,
32
32
  ...theme.textStyles.small,
33
33
  backgroundColor: theme.colors.popover.background,
34
- overflowY: 'auto',
34
+ overflowY: "auto",
35
35
  color: theme.colors.textMuted,
36
- '&:focus': { outline: 'none' },
37
- pointerEvents: 'all',
36
+ "&:focus": { outline: "none" },
37
+ pointerEvents: "all",
38
38
  zIndex: 1000,
39
39
  }));
40
40
 
@@ -51,13 +51,13 @@ const StyledDescription = styled(DialogPrimitive.Description)(({ theme }) => ({
51
51
  }));
52
52
 
53
53
  export const CloseButtonContainer = styled.div(({ theme }) => ({
54
- position: 'absolute',
54
+ position: "absolute",
55
55
  top: theme.sizes.dialog.padding,
56
56
  right: theme.sizes.dialog.padding,
57
57
  zIndex: 1,
58
58
  backgroundColor: theme.colors.popover.background,
59
- padding: '4px 6px',
60
- borderRadius: '2px',
59
+ padding: "4px 6px",
60
+ borderRadius: "2px",
61
61
  // boxShadow: `0 0 2px rgba(0, 0, 0, 0.2)`,
62
62
  border: `1px solid rgba(128,128,128,0.2)`,
63
63
  }));
@@ -70,12 +70,12 @@ interface Props {
70
70
  title?: ReactNode;
71
71
  description?: ReactNode;
72
72
  children?: ReactNode;
73
- style?: ComponentProps<typeof StyledContent>['style'];
74
- open: ComponentProps<typeof DialogPrimitive.Root>['open'];
75
- onOpenChange?: ComponentProps<typeof DialogPrimitive.Root>['onOpenChange'];
73
+ style?: ComponentProps<typeof StyledContent>["style"];
74
+ open: ComponentProps<typeof DialogPrimitive.Root>["open"];
75
+ onOpenChange?: ComponentProps<typeof DialogPrimitive.Root>["onOpenChange"];
76
76
  onOpenAutoFocus?: ComponentProps<
77
77
  typeof DialogPrimitive.Content
78
- >['onOpenAutoFocus'];
78
+ >["onOpenAutoFocus"];
79
79
  closeOnInteractOutside?: boolean;
80
80
  }
81
81
 
@@ -90,7 +90,7 @@ export const Dialog = forwardRef(function Dialog(
90
90
  onOpenAutoFocus,
91
91
  closeOnInteractOutside = true,
92
92
  }: Props,
93
- forwardedRef: ForwardedRef<IDialog>,
93
+ forwardedRef: ForwardedRef<IDialog>
94
94
  ) {
95
95
  const contentRef = useRef<HTMLDivElement>(null);
96
96
 
@@ -141,3 +141,28 @@ export const Dialog = forwardRef(function Dialog(
141
141
  </DialogPrimitive.Root>
142
142
  );
143
143
  });
144
+
145
+ export const FullscreenDialog = forwardRef(function FullscreenDialog(
146
+ { style, ...rest }: Props,
147
+ forwardedRef: ForwardedRef<IDialog>
148
+ ) {
149
+ return (
150
+ <Dialog
151
+ ref={forwardedRef}
152
+ style={{
153
+ width: "100%",
154
+ height: "100%",
155
+ maxWidth: "100%",
156
+ maxHeight: "100%",
157
+ top: "0",
158
+ left: "0",
159
+ transform: "none",
160
+ display: "flex",
161
+ flexDirection: "column",
162
+ padding: 0,
163
+ ...style,
164
+ }}
165
+ {...rest}
166
+ />
167
+ );
168
+ });
@@ -1,20 +1,20 @@
1
- import * as SwitchPrimitive from '@radix-ui/react-switch';
2
- import React from 'react';
3
- import styled from 'styled-components';
1
+ import * as SwitchPrimitive from "@radix-ui/react-switch";
2
+ import React from "react";
3
+ import styled from "styled-components";
4
4
 
5
- type SwitchVariant = 'normal' | 'primary' | 'secondary';
5
+ type SwitchColorScheme = "normal" | "primary" | "secondary";
6
6
 
7
7
  const SwitchRoot = styled(SwitchPrimitive.Root)<{
8
- variant: SwitchVariant;
9
- }>(({ theme, variant }) => ({
10
- all: 'unset',
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: '9999px',
15
- position: 'relative',
16
- WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
17
- cursor: 'pointer',
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 === 'primary'
25
+ variant === "primary"
26
26
  ? theme.colors.primary
27
- : variant === 'secondary'
28
- ? theme.colors.secondary
29
- : undefined,
27
+ : variant === "secondary"
28
+ ? theme.colors.secondary
29
+ : undefined,
30
30
  },
31
31
  }));
32
32
 
33
33
  const SwitchThumb = styled(SwitchPrimitive.Thumb)({
34
- display: 'block',
34
+ display: "block",
35
35
  width: 15,
36
36
  height: 15,
37
- backgroundColor: 'white',
38
- borderRadius: '9999px',
39
- transition: 'transform 100ms',
40
- transform: 'translateX(2px)',
41
- willChange: 'transform',
42
- '&[data-state="checked"]': { transform: 'translateX(15px)' },
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
- variant?: SwitchVariant;
48
+ colorScheme?: SwitchColorScheme;
49
49
  }
50
50
 
51
51
  export const Switch = function Switch({
52
52
  value,
53
53
  onChange,
54
- variant = 'normal',
54
+ colorScheme = "normal",
55
55
  }: Props) {
56
56
  return (
57
57
  <SwitchRoot
58
- variant={variant}
58
+ colorScheme={colorScheme}
59
59
  checked={value}
60
60
  onCheckedChange={(newValue) => {
61
61
  onChange(newValue);
@@ -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<