@noya-app/noya-designsystem 0.1.30 → 0.1.32

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.
Files changed (64) hide show
  1. package/.turbo/turbo-build.log +20 -12
  2. package/.turbo/turbo-lint.log +15 -1
  3. package/CHANGELOG.md +17 -0
  4. package/README.md +13 -1
  5. package/dist/index.css +1 -0
  6. package/dist/index.d.ts +238 -627
  7. package/dist/index.js +4259 -2862
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4159 -2764
  10. package/dist/index.mjs.map +1 -1
  11. package/package.json +17 -7
  12. package/src/components/ActivityIndicator.tsx +4 -36
  13. package/src/components/Avatar.tsx +63 -62
  14. package/src/components/Button.tsx +53 -170
  15. package/src/components/Chip.tsx +117 -150
  16. package/src/components/ContextMenu.tsx +13 -35
  17. package/src/components/Dialog.tsx +66 -54
  18. package/src/components/Divider.tsx +31 -41
  19. package/src/components/DraggableMenuButton.tsx +29 -30
  20. package/src/components/DropdownMenu.tsx +30 -40
  21. package/src/components/FillInputField.tsx +16 -26
  22. package/src/components/FillPreviewBackground.tsx +18 -22
  23. package/src/components/FloatingWindow.tsx +4 -7
  24. package/src/components/GridView.tsx +70 -200
  25. package/src/components/IconButton.tsx +1 -5
  26. package/src/components/InputField.tsx +258 -234
  27. package/src/components/InputFieldWithCompletions.tsx +20 -27
  28. package/src/components/InspectorContainer.tsx +4 -9
  29. package/src/components/InspectorPrimitives.tsx +135 -109
  30. package/src/components/Label.tsx +5 -36
  31. package/src/components/LabeledElementView.tsx +5 -26
  32. package/src/components/ListView.tsx +239 -167
  33. package/src/components/Popover.tsx +15 -39
  34. package/src/components/Progress.tsx +21 -44
  35. package/src/components/RadioGroup.tsx +6 -71
  36. package/src/components/ScrollArea.tsx +11 -39
  37. package/src/components/SelectMenu.tsx +72 -32
  38. package/src/components/Slider.tsx +7 -43
  39. package/src/components/Spacer.tsx +6 -18
  40. package/src/components/Switch.tsx +4 -42
  41. package/src/components/Text.tsx +31 -66
  42. package/src/components/TextArea.tsx +5 -31
  43. package/src/components/Toast.tsx +15 -57
  44. package/src/components/Tooltip.tsx +4 -13
  45. package/src/components/WorkspaceLayout.tsx +27 -17
  46. package/src/components/internal/Menu.tsx +37 -83
  47. package/src/contexts/DesignSystemConfiguration.tsx +1 -47
  48. package/src/contexts/DialogContext.tsx +2 -10
  49. package/src/hooks/useDarkMode.ts +14 -0
  50. package/src/index.css +108 -0
  51. package/src/index.tsx +4 -5
  52. package/src/theme/index.ts +4 -16
  53. package/src/utils/tailwind.ts +17 -0
  54. package/tailwind.config.ts +223 -0
  55. package/tailwind.d.ts +11 -0
  56. package/tsconfig.json +4 -1
  57. package/tsup.config.ts +16 -0
  58. package/dist/index.d.mts +0 -1455
  59. package/src/components/Grid.tsx +0 -54
  60. package/src/components/Select.tsx +0 -183
  61. package/src/components/Stack.tsx +0 -155
  62. package/src/theme/dark.ts +0 -45
  63. package/src/theme/light.ts +0 -226
  64. package/src/utils/breakpoints.ts +0 -45
@@ -13,18 +13,16 @@ import React, {
13
13
  useRef,
14
14
  useState,
15
15
  } from "react";
16
- import styled from "styled-components";
17
16
  import {
18
17
  CompletionItem,
19
18
  CompletionListItem,
20
19
  CompletionSectionHeader,
21
20
  } from "../utils/completions";
22
- import { IToken, fuzzyFilter, fuzzyTokenize } from "../utils/fuzzyScorer";
21
+ import { fuzzyFilter, fuzzyTokenize } from "../utils/fuzzyScorer";
23
22
  import { ActivityIndicator } from "./ActivityIndicator";
24
23
  import { InputField, InputFieldSize } from "./InputField";
25
24
  import { IVirtualizedList, ListView } from "./ListView";
26
25
  import { Spacer } from "./Spacer";
27
- import { Stack } from "./Stack";
28
26
  import { Small } from "./Text";
29
27
 
30
28
  function filterWithGroupedSections(
@@ -66,13 +64,6 @@ function filterWithGroupedSections(
66
64
  });
67
65
  }
68
66
 
69
- export const CompletionToken = styled.span<{ $type: IToken["type"] }>(
70
- ({ $type }) => ({
71
- fontWeight: $type === "match" ? "bold" : "normal",
72
- whiteSpace: "pre",
73
- })
74
- );
75
-
76
67
  interface CompletionMenuProps {
77
68
  items: CompletionListItem[];
78
69
  selectedIndex: number;
@@ -127,9 +118,12 @@ export const CompletionMenu = memo(
127
118
  }}
128
119
  >
129
120
  {tokens.map((token, j) => (
130
- <CompletionToken key={j} $type={token.type}>
121
+ <span
122
+ key={j}
123
+ className={`${token.type === "match" ? "font-bold" : "font-normal"} whitespace-pre`}
124
+ >
131
125
  {token.text}
132
- </CompletionToken>
126
+ </span>
133
127
  ))}
134
128
  {item.icon && (
135
129
  <>
@@ -145,7 +139,7 @@ export const CompletionMenu = memo(
145
139
  })
146
140
  );
147
141
 
148
- type Props = {
142
+ export type InputFieldWithCompletionsProps = {
149
143
  loading?: boolean;
150
144
  initialValue?: string;
151
145
  placeholder?: string;
@@ -164,7 +158,7 @@ type Props = {
164
158
  hideMenuWhenEmptyValue?: boolean;
165
159
  };
166
160
 
167
- export interface IInputFieldWithCompletions {
161
+ export interface InputFieldWithCompletionsRef {
168
162
  focus(): void;
169
163
  setValue(value: string): void;
170
164
  selectAllInputText(): void;
@@ -189,8 +183,8 @@ export const InputFieldWithCompletions = memo(
189
183
  children,
190
184
  hideChildrenWhenFocused = false,
191
185
  hideMenuWhenEmptyValue = false,
192
- }: Props,
193
- forwardedRef: ForwardedRef<IInputFieldWithCompletions>
186
+ }: InputFieldWithCompletionsProps,
187
+ forwardedRef: ForwardedRef<InputFieldWithCompletionsRef>
194
188
  ) {
195
189
  const ref = useRef<HTMLInputElement>(null);
196
190
 
@@ -416,12 +410,16 @@ export const InputFieldWithCompletions = memo(
416
410
  return (
417
411
  <InputField.Root
418
412
  size={size}
419
- labelSize={16}
420
413
  renderPopoverContent={({ width }) => {
421
414
  const listSize = { width, height };
422
415
 
423
416
  return (
424
- <Stack.V flex={`0 0 ${height}px`} display={display}>
417
+ <div
418
+ className={`flex flex-col ${!filter && hideMenuWhenEmptyValue ? "none" : "flex"}`}
419
+ style={{
420
+ flex: `0 0 ${height}px`
421
+ }}
422
+ >
425
423
  {filteredItems.length > 0 ? (
426
424
  <CompletionMenu
427
425
  ref={listRef}
@@ -432,18 +430,13 @@ export const InputFieldWithCompletions = memo(
432
430
  listSize={listSize}
433
431
  />
434
432
  ) : (
435
- <Stack.V
436
- height="100px"
437
- padding="20px"
438
- alignItems="center"
439
- justifyContent="center"
440
- >
441
- <Small color="textDisabled">
433
+ <div className="flex flex-col h-[100px] p-5 items-center justify-center">
434
+ <Small className="text-text-disabled">
442
435
  {loading ? "Loading" : "No results"}
443
436
  </Small>
444
- </Stack.V>
437
+ </div>
445
438
  )}
446
- </Stack.V>
439
+ </div>
447
440
  );
448
441
  }}
449
442
  >
@@ -1,8 +1,6 @@
1
1
  import {
2
2
  Divider,
3
3
  ScrollArea,
4
- Stack,
5
- useDesignSystemTheme,
6
4
  withSeparatorElements,
7
5
  } from "@noya-app/noya-designsystem";
8
6
  import React, { forwardRef, memo } from "react";
@@ -28,7 +26,6 @@ export const InspectorContainer = memo(
28
26
  },
29
27
  forwardedRef: React.ForwardedRef<HTMLDivElement>
30
28
  ) {
31
- const theme = useDesignSystemTheme();
32
29
 
33
30
  return (
34
31
  <div
@@ -39,23 +36,21 @@ export const InspectorContainer = memo(
39
36
  display: "flex",
40
37
  flexDirection: "column",
41
38
  position: "relative",
42
- background: theme.colors.sidebar.background,
39
+ background: "var(--sidebar-background)",
43
40
  ...style,
44
41
  }}
45
42
  >
46
43
  {header}
47
44
  {children ? (
48
45
  <ScrollArea>
49
- <Stack.V position="relative">
46
+ <div className="flex flex-col relative">
50
47
  {showDividers
51
48
  ? withSeparatorElements(children, <Divider />)
52
49
  : children}
53
- </Stack.V>
50
+ </div>
54
51
  </ScrollArea>
55
52
  ) : fallback ? (
56
- <Stack.V position="relative" height="100%">
57
- {fallback}
58
- </Stack.V>
53
+ <div className="flex flex-col relative h-full">{fallback}</div>
59
54
  ) : null}
60
55
  </div>
61
56
  );
@@ -1,140 +1,166 @@
1
- import React, { CSSProperties, memo, ReactNode } from "react";
2
- import styled, { useTheme } from "styled-components";
1
+ import React, { memo, ReactNode, forwardRef } from "react";
2
+ import { cn } from "../utils/tailwind";
3
3
  import { Spacer } from "./Spacer";
4
+ import { textStyles } from "./Text";
4
5
 
5
- export const Section = styled.div<{
6
- $padding?: CSSProperties["padding"];
7
- $gap?: CSSProperties["gap"];
8
- }>(({ theme, $padding = "10px", $gap }) => ({
9
- flex: "0 0 auto",
10
- display: "flex",
11
- flexDirection: "column",
12
- padding: $padding,
13
- gap: $gap,
14
- }));
15
-
16
- export const SectionHeader = styled.div(({ theme }) => ({
17
- display: "flex",
18
- alignItems: "center",
19
- }));
20
-
21
- export const Title = styled.div<{
22
- $textStyle?: "small" | "heading5" | "heading4" | "heading3";
23
- }>(({ theme, $textStyle }) => ({
24
- display: "flex",
25
- flexDirection: "row",
26
- userSelect: "none",
27
- ...($textStyle
28
- ? {
29
- ...theme.textStyles[$textStyle],
30
- color: theme.colors.text,
31
- }
32
- : {
33
- ...theme.textStyles.label,
34
- color: theme.colors.textMuted,
35
- fontWeight: "bold",
36
- }),
37
- }));
38
-
39
- export const Row = styled.div<{ $gap?: CSSProperties["gap"] }>(
40
- ({ theme, $gap }) => ({
41
- flex: "1",
42
- display: "flex",
43
- flexDirection: "row",
44
- alignItems: "center",
45
- gap: $gap,
46
- })
47
- );
6
+ export const Section = forwardRef<
7
+ HTMLDivElement,
8
+ React.HTMLAttributes<HTMLDivElement>
9
+ >(({ className, ...props }, ref) => (
10
+ <div
11
+ ref={ref}
12
+ className={cn("flex-none flex flex-col", className)}
13
+ {...props}
14
+ />
15
+ ));
16
+
17
+ export const SectionHeader = forwardRef<
18
+ HTMLDivElement,
19
+ React.HTMLAttributes<HTMLDivElement>
20
+ >(({ className, ...props }, ref) => (
21
+ <div ref={ref} className={cn("flex items-center", className)} {...props} />
22
+ ));
23
+
24
+ type TitleTextStyle = "small" | "heading5" | "heading4" | "heading3";
25
+
26
+ export const Title = forwardRef<
27
+ HTMLDivElement,
28
+ React.HTMLAttributes<HTMLDivElement> & {
29
+ $textStyle?: TitleTextStyle;
30
+ }
31
+ >(({ className, $textStyle, ...props }, ref) => (
32
+ <div
33
+ ref={ref}
34
+ className={`flex select-none ${$textStyle ? `${textStyles[$textStyle]} text-text` : "font-sans text-label uppercase text-text-muted font-bold"} ${className ?? ""}`}
35
+ {...props}
36
+ />
37
+ ));
48
38
 
49
- export const Column = styled.div(({ theme }) => ({
50
- flex: "1",
51
- display: "flex",
52
- flexDirection: "column",
53
- gap: "4px",
54
- }));
39
+ export const Row = forwardRef<
40
+ HTMLDivElement,
41
+ React.HTMLAttributes<HTMLDivElement>
42
+ >(({ className, ...props }, ref) => (
43
+ <div
44
+ ref={ref}
45
+ className={cn("flex-1 flex flex-row items-center", className)}
46
+ {...props}
47
+ />
48
+ ));
55
49
 
56
- export const Checkbox = styled.input(({ theme }) => ({
57
- margin: 0,
58
- }));
50
+ export const Column = forwardRef<
51
+ HTMLDivElement,
52
+ React.HTMLAttributes<HTMLDivElement>
53
+ >(({ className, ...props }, ref) => (
54
+ <div
55
+ ref={ref}
56
+ className={cn("flex-1 flex flex-col gap-1", className)}
57
+ {...props}
58
+ />
59
+ ));
59
60
 
60
- export const Text = styled.span(({ theme }) => ({
61
- ...theme.textStyles.small,
62
- }));
61
+ export const Checkbox = forwardRef<
62
+ HTMLInputElement,
63
+ React.InputHTMLAttributes<HTMLInputElement>
64
+ >(({ className, ...props }, ref) => (
65
+ <input
66
+ ref={ref}
67
+ type="checkbox"
68
+ className={cn("m-0", className)}
69
+ {...props}
70
+ />
71
+ ));
72
+
73
+ export const Text = forwardRef<
74
+ HTMLSpanElement,
75
+ React.HTMLAttributes<HTMLSpanElement>
76
+ >(({ className, ...props }, ref) => (
77
+ <span
78
+ ref={ref}
79
+ className={cn("font-sans text-heading5 font-normal", className)}
80
+ {...props}
81
+ />
82
+ ));
63
83
 
64
84
  export const VerticalSeparator = () => (
65
- <Spacer.Vertical size={useTheme().sizes.inspector.verticalSeparator} />
85
+ <Spacer.Vertical size="inspector-v-separator" />
66
86
  );
67
87
 
68
88
  export const HorizontalSeparator = () => (
69
- <Spacer.Horizontal size={useTheme().sizes.inspector.horizontalSeparator} />
89
+ <Spacer.Horizontal size="inspector-h-separator" />
70
90
  );
71
91
 
72
- const SliderRowLabel = styled.span(({ theme }) => ({
73
- ...theme.textStyles.small,
74
- color: theme.colors.textMuted,
75
- marginBottom: "-6px",
76
- }));
77
-
78
- export const RowLabel = styled.span<{
79
- $textStyle?: "small" | "heading5" | "heading4" | "heading3";
80
- }>(({ theme, $textStyle }) => ({
81
- // marginBottom: '6px',
82
- display: "flex",
83
- ...($textStyle
84
- ? {
85
- ...theme.textStyles[$textStyle],
86
- }
87
- : {
88
- ...theme.textStyles.label,
89
- color: theme.colors.textSubtle,
90
- fontWeight: "bold",
91
- }),
92
- lineHeight: "19px", // Button height
93
- alignItems: "center",
94
- }));
92
+ // const SliderRowLabel = forwardRef<
93
+ // HTMLSpanElement,
94
+ // React.HTMLAttributes<HTMLSpanElement>
95
+ // >(({ className, ...props }, ref) => (
96
+ // <span
97
+ // ref={ref}
98
+ // className={`font-sans text-heading5 font-normal text-text-muted -mb-[6px] ${className ?? ""}`}
99
+ // {...props}
100
+ // />
101
+ // ));
102
+
103
+ export const RowLabel = forwardRef<
104
+ HTMLSpanElement,
105
+ React.HTMLAttributes<HTMLSpanElement> & {
106
+ $textStyle?: TitleTextStyle | "label";
107
+ }
108
+ >(function RowLabel({ className, $textStyle, ...props }, ref) {
109
+ return (
110
+ <span
111
+ ref={ref}
112
+ className={`font-sans text-label uppercase flex items-center leading-[19px] font-bold text-text-subtle ${$textStyle && textStyles[$textStyle]} ${className ?? ""}`}
113
+ {...props}
114
+ />
115
+ );
116
+ });
117
+
118
+ interface LabeledRowProps {
119
+ id?: string;
120
+ children: ReactNode;
121
+ label: ReactNode;
122
+ labelTextStyle?: TitleTextStyle;
123
+ right?: ReactNode;
124
+ className?: string;
125
+ }
95
126
 
96
127
  export const LabeledRow = memo(function LabeledRow({
97
128
  id,
98
129
  children,
99
130
  label,
100
131
  labelTextStyle,
101
- gap,
102
132
  right,
103
- }: {
104
- id?: string;
105
- children: ReactNode;
106
- label: ReactNode;
107
- labelTextStyle?: "small" | "heading5" | "heading4" | "heading3";
108
- gap?: CSSProperties["gap"];
109
- right?: ReactNode;
110
- }) {
133
+ className,
134
+ }: LabeledRowProps) {
111
135
  return (
112
- <Row id={id}>
136
+ <Row id={id} className={className ?? ""}>
113
137
  <Column>
114
138
  <RowLabel $textStyle={labelTextStyle}>
115
139
  {label}
116
140
  {right && <Spacer.Horizontal />}
117
141
  {right}
118
142
  </RowLabel>
119
- <Row $gap={gap}>{children}</Row>
120
- </Column>
121
- </Row>
122
- );
123
- });
124
-
125
- export const LabeledSliderRow = memo(function LabeledRow({
126
- children,
127
- label,
128
- }: {
129
- children: ReactNode;
130
- label: string;
131
- }) {
132
- return (
133
- <Row>
134
- <Column>
135
- <SliderRowLabel>{label}</SliderRowLabel>
136
143
  <Row>{children}</Row>
137
144
  </Column>
138
145
  </Row>
139
146
  );
140
147
  });
148
+
149
+ // interface LabeledSliderRowProps {
150
+ // children: ReactNode;
151
+ // label: string;
152
+ // }
153
+
154
+ // export const LabeledSliderRow = memo(function LabeledSliderRow({
155
+ // children,
156
+ // label,
157
+ // }: LabeledSliderRowProps) {
158
+ // return (
159
+ // <Row>
160
+ // <Column>
161
+ // <SliderRowLabel>{label}</SliderRowLabel>
162
+ // <Row>{children}</Row>
163
+ // </Column>
164
+ // </Row>
165
+ // );
166
+ // });
@@ -1,42 +1,11 @@
1
1
  import React, { memo, ReactNode } from "react";
2
- import styled from "styled-components";
3
2
  import { Spacer } from "./Spacer";
4
-
5
- /* ----------------------------------------------------------------------------
6
- * Label
7
- * ------------------------------------------------------------------------- */
8
-
9
- const LabelLabel = styled.label<{ $selected?: boolean }>(
10
- ({ theme, $selected }) => ({
11
- ...theme.textStyles.small,
12
- color: theme.colors.textMuted,
13
- ...($selected && {
14
- color: theme.colors.text,
15
- }),
16
- fontSize: "11px",
17
- flex: "0 0 auto",
18
- minWidth: "0",
19
- letterSpacing: "0.4px",
20
- whiteSpace: "pre", // prevent breaking - may need to make this an option
21
- })
22
- );
3
+ import { textStyles } from "./Text";
23
4
 
24
5
  /* ----------------------------------------------------------------------------
25
6
  * Root
26
7
  * ------------------------------------------------------------------------- */
27
8
 
28
- const LabelContainer = styled.span(({ theme }) => ({
29
- flex: "0 0 auto",
30
- position: "relative",
31
- border: "0",
32
- outline: "none",
33
- minWidth: "0",
34
- textAlign: "left",
35
- display: "flex",
36
- flexDirection: "column",
37
- alignItems: "center",
38
- }));
39
-
40
9
  interface LabelRootProps {
41
10
  label: ReactNode;
42
11
  children: ReactNode;
@@ -44,19 +13,19 @@ interface LabelRootProps {
44
13
 
45
14
  function LabelRoot({ label, children }: LabelRootProps) {
46
15
  return (
47
- <LabelContainer>
16
+ <span className={`flex-none relative outline-none border-0 min-w-0 text-left flex flex-col items-center`}>
48
17
  {children}
49
18
  {label && (
50
19
  <>
51
20
  <Spacer.Vertical size={2} />
52
- <LabelLabel>{label}</LabelLabel>
21
+ <span className={`${textStyles.small} text-text-muted text-xs flex-none min-w-0 tracking-[0.4px] whitespace-pre`}>{label}</span>
22
+
53
23
  </>
54
24
  )}
55
- </LabelContainer>
25
+ </span>
56
26
  );
57
27
  }
58
28
 
59
29
  export namespace Label {
60
- export const Label = memo(LabelLabel);
61
30
  export const Root = memo(LabelRoot);
62
31
  }
@@ -10,27 +10,6 @@ import React, {
10
10
  useMemo,
11
11
  useRef,
12
12
  } from 'react';
13
- import styled from 'styled-components';
14
-
15
- const Container = styled.div(({ theme }) => ({
16
- display: 'flex',
17
- flex: '1',
18
- flexDirection: 'column',
19
- position: 'relative',
20
- }));
21
-
22
- const Tools = styled.div(({ theme }) => ({
23
- display: 'flex',
24
- flex: '1',
25
- alignItems: 'center',
26
- }));
27
-
28
- const Labels = styled.div(({ theme }) => ({
29
- height: 'var(--height)',
30
- position: 'relative',
31
- overflow: 'hidden',
32
- userSelect: 'none',
33
- }));
34
13
 
35
14
  interface ContainerProps {
36
15
  children: ReactNode;
@@ -177,9 +156,9 @@ export const LabeledElementView = memo(function LabeledElementView({
177
156
  }, [refs, labelElements]);
178
157
 
179
158
  return (
180
- <Container ref={containerRef}>
181
- <Tools>{children}</Tools>
182
- <Labels>{labelElements}</Labels>
183
- </Container>
159
+ <div className="flex flex-1 flex-col relative" ref={containerRef}>
160
+ <div className="flex flex-1 items-center">{children}</div>
161
+ <div className="relative overflow-hidden select-none">{labelElements}</div>
162
+ </div>
184
163
  );
185
- });
164
+ });