@noya-app/noya-designsystem 0.1.29 → 0.1.31
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/.turbo/turbo-lint.log +13 -0
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +172 -200
- package/dist/index.d.ts +172 -200
- package/dist/index.js +304 -467
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -468
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/src/components/Button.tsx +5 -3
- package/src/components/GridView.tsx +37 -35
- package/src/components/InputField.tsx +118 -88
- package/src/components/ListView.tsx +1 -0
- package/src/components/RadioGroup.tsx +2 -0
- package/src/components/SelectMenu.tsx +69 -12
- package/src/components/Stack.tsx +10 -1
- package/src/components/Switch.tsx +1 -0
- package/src/components/WorkspaceLayout.tsx +29 -6
- package/src/index.tsx +1 -2
- package/tailwind.config.ts +283 -0
- package/tailwind.d.ts +11 -0
- package/tsconfig.json +4 -1
- package/src/components/ArrayController.tsx +0 -168
- package/src/components/Select.tsx +0 -183
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.31",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@dnd-kit/sortable": "4.0.0",
|
|
16
16
|
"@noya-app/noya-colorpicker": "0.1.11",
|
|
17
17
|
"@noya-app/noya-utils": "0.1.2",
|
|
18
|
-
"@noya-app/noya-geometry": "0.1.
|
|
18
|
+
"@noya-app/noya-geometry": "0.1.5",
|
|
19
19
|
"@noya-app/noya-icons": "0.1.4",
|
|
20
20
|
"@noya-app/noya-keymap": "0.1.2",
|
|
21
21
|
"@radix-ui/primitive": "^1.0.0",
|
|
@@ -46,8 +46,9 @@
|
|
|
46
46
|
"@types/react-dom": "*",
|
|
47
47
|
"@types/react-virtualized": "^9.21.21",
|
|
48
48
|
"@types/react-window": "^1.8.5",
|
|
49
|
+
"esbuild-plugin-react-virtualized": "1.0.4",
|
|
49
50
|
"react-virtualized": "9.22.5",
|
|
50
|
-
"
|
|
51
|
+
"tailwindcss": "^3.4.14"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"react": "*",
|
|
@@ -19,7 +19,7 @@ type ButtonVariant =
|
|
|
19
19
|
| "floating"
|
|
20
20
|
| "none";
|
|
21
21
|
|
|
22
|
-
type ButtonSize = "normal" | "large";
|
|
22
|
+
type ButtonSize = "small" | "normal" | "large";
|
|
23
23
|
|
|
24
24
|
/* ----------------------------------------------------------------------------
|
|
25
25
|
* Element
|
|
@@ -135,8 +135,8 @@ export const ButtonElement = styled.button<{
|
|
|
135
135
|
background: "white",
|
|
136
136
|
color: theme.colors.text,
|
|
137
137
|
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)",
|
|
138
|
-
fontSize: "12px",
|
|
139
|
-
padding: "0px 4px",
|
|
138
|
+
fontSize: $size === "small" ? "10px" : "12px",
|
|
139
|
+
padding: $size === "small" ? "0px 2px" : "0px 4px",
|
|
140
140
|
"&:hover": {
|
|
141
141
|
opacity: 0.8,
|
|
142
142
|
},
|
|
@@ -184,7 +184,9 @@ export interface ButtonRootProps {
|
|
|
184
184
|
children: ReactNode;
|
|
185
185
|
active?: boolean;
|
|
186
186
|
disabled?: boolean;
|
|
187
|
+
/** @default normal */
|
|
187
188
|
variant?: ButtonVariant;
|
|
189
|
+
/** @default normal */
|
|
188
190
|
size?: ButtonSize;
|
|
189
191
|
tooltip?: ReactNode;
|
|
190
192
|
onClick?: (event: React.MouseEvent) => void;
|
|
@@ -64,39 +64,39 @@ const sizes: Record<
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const Grid = styled.div<{
|
|
67
|
-
size: GridViewSize;
|
|
68
|
-
padding: CSSProperties["padding"];
|
|
69
|
-
}>(({ theme, size, padding }) => {
|
|
67
|
+
$size: GridViewSize;
|
|
68
|
+
$padding: CSSProperties["padding"];
|
|
69
|
+
}>(({ theme, $size, $padding }) => {
|
|
70
70
|
return {
|
|
71
71
|
color: theme.colors.text,
|
|
72
72
|
display: "grid",
|
|
73
|
-
gridTemplateColumns: `repeat(auto-fill, minmax(${sizes[size].itemWidth}px, 1fr))`,
|
|
73
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${sizes[$size].itemWidth}px, 1fr))`,
|
|
74
74
|
// gridAutoRows: `${sizes[size].itemHeight}px`,
|
|
75
|
-
gap: `${sizes[size].gap}px`,
|
|
75
|
+
gap: `${sizes[$size].gap}px`,
|
|
76
76
|
// gridTemplateColumns: `repeat(auto-fill, minmax(
|
|
77
77
|
// ${size === 'large' ? '280px' : size === 'small' ? '160px' : '116px'}
|
|
78
78
|
// , 1fr))`,
|
|
79
79
|
// gridAutoRows:
|
|
80
80
|
// size === 'large' ? '280px' : size === 'small' ? '170px' : '116px',
|
|
81
81
|
// gap: size === 'large' || size === 'small' ? `20px` : `12px`,
|
|
82
|
-
padding,
|
|
82
|
+
padding: $padding,
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
const Container = styled.div<{ scrollable: boolean }>(
|
|
87
|
-
({ theme, scrollable }) => ({
|
|
88
|
-
flex: scrollable ? "1" : "0 0 auto",
|
|
86
|
+
const Container = styled.div<{ $scrollable: boolean }>(
|
|
87
|
+
({ theme, $scrollable }) => ({
|
|
88
|
+
flex: $scrollable ? "1" : "0 0 auto",
|
|
89
89
|
display: "flex",
|
|
90
90
|
flexDirection: "column",
|
|
91
91
|
})
|
|
92
92
|
);
|
|
93
93
|
|
|
94
94
|
const ContentContainer = styled.div<{
|
|
95
|
-
selected?: boolean;
|
|
96
|
-
hovered?: boolean;
|
|
97
|
-
bordered: boolean;
|
|
98
|
-
disabled: boolean;
|
|
99
|
-
}>(({ theme, selected, hovered, bordered, disabled }) => ({
|
|
95
|
+
$selected?: boolean;
|
|
96
|
+
$hovered?: boolean;
|
|
97
|
+
$bordered: boolean;
|
|
98
|
+
$disabled: boolean;
|
|
99
|
+
}>(({ theme, $selected, $hovered, $bordered, $disabled }) => ({
|
|
100
100
|
display: "flex",
|
|
101
101
|
flex: "1",
|
|
102
102
|
backgroundColor: theme.colors.sidebar.background,
|
|
@@ -104,18 +104,18 @@ const ContentContainer = styled.div<{
|
|
|
104
104
|
justifyContent: "center",
|
|
105
105
|
borderRadius: "2px",
|
|
106
106
|
border: `1px solid ${
|
|
107
|
-
selected
|
|
107
|
+
$selected
|
|
108
108
|
? theme.colors.primary
|
|
109
109
|
: // : hovered
|
|
110
110
|
// ? `rgb(132, 63, 255, 0.5)`
|
|
111
|
-
bordered
|
|
111
|
+
$bordered
|
|
112
112
|
? theme.colors.divider
|
|
113
113
|
: "transparent"
|
|
114
114
|
}`,
|
|
115
115
|
overflow: "hidden",
|
|
116
116
|
|
|
117
117
|
cursor: "pointer",
|
|
118
|
-
...(disabled
|
|
118
|
+
...($disabled
|
|
119
119
|
? { opacity: 0.5 }
|
|
120
120
|
: {
|
|
121
121
|
"&:hover": { opacity: 0.85 },
|
|
@@ -134,8 +134,8 @@ const ItemContainer = styled.div(({ theme }) => ({
|
|
|
134
134
|
},
|
|
135
135
|
}));
|
|
136
136
|
|
|
137
|
-
const ItemTitle = styled.span<{ showBackground: boolean }>(
|
|
138
|
-
({ theme, showBackground }) => ({
|
|
137
|
+
const ItemTitle = styled.span<{ $showBackground: boolean }>(
|
|
138
|
+
({ theme, $showBackground }) => ({
|
|
139
139
|
...theme.textStyles.small,
|
|
140
140
|
lineHeight: "1",
|
|
141
141
|
color: theme.colors.text,
|
|
@@ -145,7 +145,7 @@ const ItemTitle = styled.span<{ showBackground: boolean }>(
|
|
|
145
145
|
overflow: "hidden",
|
|
146
146
|
textOverflow: "ellipsis",
|
|
147
147
|
|
|
148
|
-
...(showBackground && {
|
|
148
|
+
...($showBackground && {
|
|
149
149
|
background: theme.colors.sidebar.background,
|
|
150
150
|
// border: `1px solid ${theme.colors.dividerSubtle}`,
|
|
151
151
|
padding: "2px 4px",
|
|
@@ -155,8 +155,8 @@ const ItemTitle = styled.span<{ showBackground: boolean }>(
|
|
|
155
155
|
})
|
|
156
156
|
);
|
|
157
157
|
|
|
158
|
-
const ItemDescription = styled.span<{ showBackground: boolean }>(
|
|
159
|
-
({ theme, showBackground }) => ({
|
|
158
|
+
const ItemDescription = styled.span<{ $showBackground: boolean }>(
|
|
159
|
+
({ theme, $showBackground }) => ({
|
|
160
160
|
...theme.textStyles.small,
|
|
161
161
|
fontSize: "0.7rem",
|
|
162
162
|
lineHeight: "1",
|
|
@@ -166,7 +166,7 @@ const ItemDescription = styled.span<{ showBackground: boolean }>(
|
|
|
166
166
|
overflow: "hidden",
|
|
167
167
|
textOverflow: "ellipsis",
|
|
168
168
|
|
|
169
|
-
...(showBackground && {
|
|
169
|
+
...($showBackground && {
|
|
170
170
|
background: theme.colors.sidebar.background,
|
|
171
171
|
// border: `1px solid ${theme.colors.dividerSubtle}`,
|
|
172
172
|
padding: "2px 4px",
|
|
@@ -319,10 +319,10 @@ const GridViewItem = forwardRef(function GridViewItem<
|
|
|
319
319
|
onKeyDown={handleKeyDown}
|
|
320
320
|
>
|
|
321
321
|
<ContentContainer
|
|
322
|
-
disabled={disabled}
|
|
323
|
-
bordered={bordered}
|
|
324
|
-
selected={selected}
|
|
325
|
-
hovered={!disabled && hovered}
|
|
322
|
+
$disabled={disabled}
|
|
323
|
+
$bordered={bordered}
|
|
324
|
+
$selected={selected}
|
|
325
|
+
$hovered={!disabled && hovered}
|
|
326
326
|
onClick={handleClick}
|
|
327
327
|
onDoubleClick={onDoubleClick}
|
|
328
328
|
onContextMenu={onContextMenu}
|
|
@@ -333,17 +333,17 @@ const GridViewItem = forwardRef(function GridViewItem<
|
|
|
333
333
|
{textPosition === "below" && (
|
|
334
334
|
<>
|
|
335
335
|
<Spacer.Vertical size={8} />
|
|
336
|
-
<ItemTitle showBackground={false}>{title || " "}</ItemTitle>
|
|
337
|
-
<ItemDescription showBackground={false}>
|
|
336
|
+
<ItemTitle $showBackground={false}>{title || " "}</ItemTitle>
|
|
337
|
+
<ItemDescription $showBackground={false}>
|
|
338
338
|
{subtitle || " "}
|
|
339
339
|
</ItemDescription>
|
|
340
340
|
</>
|
|
341
341
|
)}
|
|
342
342
|
{textPosition === "overlay" && hovered && (title || subtitle) && (
|
|
343
343
|
<TextOverlay>
|
|
344
|
-
{title && <ItemTitle showBackground>{title}</ItemTitle>}
|
|
344
|
+
{title && <ItemTitle $showBackground>{title}</ItemTitle>}
|
|
345
345
|
{subtitle && (
|
|
346
|
-
<ItemDescription showBackground>{subtitle}</ItemDescription>
|
|
346
|
+
<ItemDescription $showBackground>{subtitle}</ItemDescription>
|
|
347
347
|
)}
|
|
348
348
|
</TextOverlay>
|
|
349
349
|
)}
|
|
@@ -368,8 +368,10 @@ const GridViewItem = forwardRef(function GridViewItem<
|
|
|
368
368
|
<Tooltip
|
|
369
369
|
content={
|
|
370
370
|
<Stack.V gap={2}>
|
|
371
|
-
<ItemTitle showBackground={false}>{title}</ItemTitle>
|
|
372
|
-
<ItemDescription showBackground={false}>
|
|
371
|
+
<ItemTitle $showBackground={false}>{title}</ItemTitle>
|
|
372
|
+
<ItemDescription $showBackground={false}>
|
|
373
|
+
{subtitle}
|
|
374
|
+
</ItemDescription>
|
|
373
375
|
</Stack.V>
|
|
374
376
|
}
|
|
375
377
|
>
|
|
@@ -432,7 +434,7 @@ function GridViewRoot({
|
|
|
432
434
|
|
|
433
435
|
return (
|
|
434
436
|
<GridViewContext.Provider value={contextValue}>
|
|
435
|
-
<Container onClick={handleClick} scrollable={scrollable}>
|
|
437
|
+
<Container onClick={handleClick} $scrollable={scrollable}>
|
|
436
438
|
{scrollable ? <ScrollArea>{children}</ScrollArea> : children}
|
|
437
439
|
</Container>
|
|
438
440
|
</GridViewContext.Provider>
|
|
@@ -449,7 +451,7 @@ function GridViewSection({
|
|
|
449
451
|
const { size } = useContext(GridViewContext);
|
|
450
452
|
|
|
451
453
|
return (
|
|
452
|
-
<Grid size={size} padding={padding}>
|
|
454
|
+
<Grid $size={size} $padding={padding}>
|
|
453
455
|
{children}
|
|
454
456
|
</Grid>
|
|
455
457
|
);
|
|
@@ -32,21 +32,23 @@ export type InputFieldSize = "small" | "medium" | "large";
|
|
|
32
32
|
|
|
33
33
|
type InputFieldContextValue = {
|
|
34
34
|
labelPosition: LabelPosition;
|
|
35
|
-
labelSize
|
|
36
|
-
|
|
35
|
+
labelSize?: number;
|
|
36
|
+
buttonSize?: number;
|
|
37
37
|
hasDropdown: boolean;
|
|
38
|
+
/** @default medium */
|
|
38
39
|
size: InputFieldSize;
|
|
39
40
|
isFocused: boolean;
|
|
40
41
|
onFocusChange: (isFocused: boolean) => void;
|
|
41
42
|
inputRef?: ForwardedRef<HTMLInputElement>;
|
|
42
43
|
setInputRef?: (ref: ForwardedRef<HTMLInputElement>) => void;
|
|
43
44
|
setLabelWidth?: (width: number) => void;
|
|
45
|
+
setButtonWidth?: (width: number) => void;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const InputFieldContext = createContext<InputFieldContextValue>({
|
|
47
49
|
labelPosition: "end",
|
|
48
|
-
labelSize:
|
|
49
|
-
|
|
50
|
+
labelSize: undefined,
|
|
51
|
+
buttonSize: undefined,
|
|
50
52
|
hasDropdown: false,
|
|
51
53
|
size: "medium",
|
|
52
54
|
isFocused: false,
|
|
@@ -61,26 +63,31 @@ const LabelContainer = styled.label<{
|
|
|
61
63
|
pointerEvents: Property.PointerEvents;
|
|
62
64
|
$labelPosition: LabelPosition;
|
|
63
65
|
$hasDropdown: boolean;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
66
|
+
$size: InputFieldSize;
|
|
67
|
+
}>(({ theme, $labelPosition, $hasDropdown, pointerEvents, $size }) => {
|
|
68
|
+
const offsetRelativeToSize =
|
|
69
|
+
$size === "large" ? 6 : $size === "medium" ? 2 : 0;
|
|
70
|
+
return {
|
|
71
|
+
...theme.textStyles.label,
|
|
72
|
+
fontWeight: "bold",
|
|
73
|
+
color: theme.colors.textDisabled,
|
|
74
|
+
position: "absolute",
|
|
75
|
+
top: 0,
|
|
76
|
+
bottom: 0,
|
|
77
|
+
right: $labelPosition === "end" ? offsetRelativeToSize : undefined,
|
|
78
|
+
left: $labelPosition === "start" ? offsetRelativeToSize : undefined,
|
|
79
|
+
display: "flex",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
pointerEvents,
|
|
82
|
+
userSelect: "none",
|
|
83
|
+
...($labelPosition === "start"
|
|
84
|
+
? { justifyContent: "flex-start", paddingLeft: "6px" }
|
|
85
|
+
: {
|
|
86
|
+
justifyContent: "flex-end",
|
|
87
|
+
paddingRight: $hasDropdown ? "16px" : "6px",
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
84
91
|
|
|
85
92
|
interface InputFieldLabelProps {
|
|
86
93
|
children?: ReactNode;
|
|
@@ -88,12 +95,13 @@ interface InputFieldLabelProps {
|
|
|
88
95
|
style?: React.CSSProperties;
|
|
89
96
|
}
|
|
90
97
|
|
|
98
|
+
/** Inserts a Label at the start or end of the input given a `labelPosition`on InputField.Root. Should not be used with an InputField.Button */
|
|
91
99
|
const InputFieldLabel = memo(
|
|
92
100
|
forwardRef(function InputFieldLabel(
|
|
93
101
|
{ children = false, pointerEvents = "none", style }: InputFieldLabelProps,
|
|
94
102
|
forwardedRef: ForwardedRef<HTMLLabelElement>
|
|
95
103
|
) {
|
|
96
|
-
const { labelPosition, hasDropdown, setLabelWidth } =
|
|
104
|
+
const { labelPosition, hasDropdown, setLabelWidth, size } =
|
|
97
105
|
useContext(InputFieldContext);
|
|
98
106
|
|
|
99
107
|
const ref = useRef<HTMLLabelElement | null>(null);
|
|
@@ -110,6 +118,7 @@ const InputFieldLabel = memo(
|
|
|
110
118
|
|
|
111
119
|
return (
|
|
112
120
|
<LabelContainer
|
|
121
|
+
$size={size}
|
|
113
122
|
ref={(element) => {
|
|
114
123
|
ref.current = element;
|
|
115
124
|
assignRef(forwardedRef, element);
|
|
@@ -179,51 +188,74 @@ const ButtonContainer = styled.span<{ $size: InputFieldSize }>(
|
|
|
179
188
|
({ theme, $size }) => ({
|
|
180
189
|
position: "absolute",
|
|
181
190
|
right: $size === "large" ? "9px" : $size === "medium" ? "4px" : "2px",
|
|
182
|
-
top: $size === "large" ? "
|
|
191
|
+
top: $size === "large" ? "10px" : $size === "medium" ? "4px" : "2px",
|
|
183
192
|
})
|
|
184
193
|
);
|
|
185
194
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
/** Inserts a Button at the end of the input. Should not be used with an InputField.Label */
|
|
196
|
+
const InputFieldButton = memo(
|
|
197
|
+
forwardRef(function InputFieldButton(
|
|
198
|
+
{
|
|
199
|
+
children,
|
|
200
|
+
onClick,
|
|
201
|
+
}: {
|
|
202
|
+
children?: ReactNode;
|
|
203
|
+
onClick?: () => void;
|
|
204
|
+
},
|
|
205
|
+
forwardedRef: ForwardedRef<HTMLButtonElement>
|
|
206
|
+
) {
|
|
207
|
+
const { size, inputRef, setButtonWidth } = useContext(InputFieldContext);
|
|
208
|
+
|
|
209
|
+
const ref = useRef<HTMLButtonElement | null>(null);
|
|
210
|
+
|
|
211
|
+
useLayoutEffect(() => {
|
|
212
|
+
if (!setButtonWidth) return;
|
|
213
|
+
|
|
214
|
+
const width = ref.current?.getBoundingClientRect().width;
|
|
215
|
+
|
|
216
|
+
if (!width) return;
|
|
202
217
|
|
|
218
|
+
setButtonWidth(width);
|
|
219
|
+
}, [setButtonWidth]);
|
|
220
|
+
|
|
221
|
+
const defaultHandleClick = useCallback(
|
|
222
|
+
(event: React.MouseEvent) => {
|
|
223
|
+
if (inputRef && typeof inputRef !== "function") {
|
|
224
|
+
inputRef.current?.focus();
|
|
225
|
+
// Select all text
|
|
226
|
+
inputRef.current?.setSelectionRange(0, inputRef.current.value.length);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
event.stopPropagation();
|
|
231
|
+
},
|
|
232
|
+
[inputRef]
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const handlePointerDown = useCallback((event: React.PointerEvent) => {
|
|
203
236
|
event.preventDefault();
|
|
204
237
|
event.stopPropagation();
|
|
205
|
-
},
|
|
206
|
-
[inputRef]
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
const handlePointerDown = useCallback((event: React.PointerEvent) => {
|
|
210
|
-
event.preventDefault();
|
|
211
|
-
event.stopPropagation();
|
|
212
|
-
}, []);
|
|
238
|
+
}, []);
|
|
213
239
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
240
|
+
return (
|
|
241
|
+
<ButtonContainer $size={size}>
|
|
242
|
+
<Button
|
|
243
|
+
ref={(element) => {
|
|
244
|
+
ref.current = element;
|
|
245
|
+
assignRef(forwardedRef, element);
|
|
246
|
+
}}
|
|
247
|
+
variant="floating"
|
|
248
|
+
onClick={onClick ?? defaultHandleClick}
|
|
249
|
+
onPointerDown={handlePointerDown}
|
|
250
|
+
tabIndex={-1}
|
|
251
|
+
size={size === "medium" ? "normal" : size}
|
|
252
|
+
>
|
|
253
|
+
{children}
|
|
254
|
+
</Button>
|
|
255
|
+
</ButtonContainer>
|
|
256
|
+
);
|
|
257
|
+
})
|
|
258
|
+
);
|
|
227
259
|
|
|
228
260
|
/* ----------------------------------------------------------------------------
|
|
229
261
|
* Input
|
|
@@ -242,8 +274,7 @@ export const InputElement = styled(TextInput)<{
|
|
|
242
274
|
disabled?: boolean;
|
|
243
275
|
readOnly?: boolean;
|
|
244
276
|
$labelPosition: LabelPosition;
|
|
245
|
-
$labelSize
|
|
246
|
-
$hasLabel: boolean;
|
|
277
|
+
$labelSize?: number;
|
|
247
278
|
$hasDropdown: boolean;
|
|
248
279
|
$textAlign?: Property.TextAlign;
|
|
249
280
|
$variant?: InputFieldVariant;
|
|
@@ -255,7 +286,6 @@ export const InputElement = styled(TextInput)<{
|
|
|
255
286
|
$hasDropdown,
|
|
256
287
|
$textAlign,
|
|
257
288
|
disabled,
|
|
258
|
-
$hasLabel,
|
|
259
289
|
readOnly,
|
|
260
290
|
$variant = "normal",
|
|
261
291
|
$size,
|
|
@@ -288,11 +318,11 @@ export const InputElement = styled(TextInput)<{
|
|
|
288
318
|
$size === "large" ? "10px" : $size === "medium" ? "4px" : "1px",
|
|
289
319
|
paddingLeft:
|
|
290
320
|
($size === "large" ? 10 : $size === "medium" ? 6 : 4) +
|
|
291
|
-
($
|
|
321
|
+
($labelSize && $labelPosition === "start" ? 6 + $labelSize : 0) +
|
|
292
322
|
"px",
|
|
293
323
|
paddingRight:
|
|
294
324
|
($size === "large" ? 10 : $size === "medium" ? 6 : 4) +
|
|
295
|
-
($
|
|
325
|
+
($labelSize && $labelPosition === "end" ? 6 + $labelSize : 0) +
|
|
296
326
|
($hasDropdown ? 11 : 0) +
|
|
297
327
|
"px",
|
|
298
328
|
background: theme.colors.inputBackground,
|
|
@@ -321,6 +351,7 @@ export const InputElement = styled(TextInput)<{
|
|
|
321
351
|
};
|
|
322
352
|
});
|
|
323
353
|
|
|
354
|
+
/** Should always be wrapped in InputField.Root */
|
|
324
355
|
const InputFieldInput = forwardRef(function InputFieldInput(
|
|
325
356
|
// onFocusChange should only be passed from the root, never directly
|
|
326
357
|
{
|
|
@@ -337,7 +368,7 @@ const InputFieldInput = forwardRef(function InputFieldInput(
|
|
|
337
368
|
labelPosition,
|
|
338
369
|
labelSize,
|
|
339
370
|
hasDropdown,
|
|
340
|
-
|
|
371
|
+
buttonSize,
|
|
341
372
|
size,
|
|
342
373
|
onFocusChange,
|
|
343
374
|
setInputRef,
|
|
@@ -358,8 +389,7 @@ const InputFieldInput = forwardRef(function InputFieldInput(
|
|
|
358
389
|
<InputElement
|
|
359
390
|
ref={forwardedRef}
|
|
360
391
|
$labelPosition={labelPosition}
|
|
361
|
-
$labelSize={labelSize}
|
|
362
|
-
$hasLabel={hasLabel}
|
|
392
|
+
$labelSize={labelSize || buttonSize}
|
|
363
393
|
$hasDropdown={hasDropdown}
|
|
364
394
|
$size={size}
|
|
365
395
|
$variant={variant}
|
|
@@ -375,7 +405,6 @@ const InputFieldTypeahead = (props: { prefix: string; value: string }) => {
|
|
|
375
405
|
labelPosition,
|
|
376
406
|
labelSize,
|
|
377
407
|
hasDropdown,
|
|
378
|
-
hasLabel,
|
|
379
408
|
size,
|
|
380
409
|
// onFocusChange,
|
|
381
410
|
} = useContext(InputFieldContext);
|
|
@@ -385,7 +414,6 @@ const InputFieldTypeahead = (props: { prefix: string; value: string }) => {
|
|
|
385
414
|
as="span"
|
|
386
415
|
$labelPosition={labelPosition}
|
|
387
416
|
$labelSize={labelSize}
|
|
388
|
-
$hasLabel={hasLabel}
|
|
389
417
|
$hasDropdown={hasDropdown}
|
|
390
418
|
$size={size}
|
|
391
419
|
// onFocusChange={onFocusChange}
|
|
@@ -528,24 +556,27 @@ function InputFieldNumberInput(props: InputFieldNumberInputProps) {
|
|
|
528
556
|
* Root
|
|
529
557
|
* ------------------------------------------------------------------------- */
|
|
530
558
|
|
|
531
|
-
const RootContainer = styled.div<{
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
559
|
+
const RootContainer = styled.div<{
|
|
560
|
+
$width?: number;
|
|
561
|
+
$flex?: string;
|
|
562
|
+
}>(({ theme, $flex, $width }) => ({
|
|
563
|
+
flex: $flex ?? "1",
|
|
564
|
+
display: "flex",
|
|
565
|
+
flexDirection: "row",
|
|
566
|
+
position: "relative",
|
|
567
|
+
maxWidth: typeof $width === "number" ? `${$width}px` : undefined,
|
|
568
|
+
}));
|
|
540
569
|
|
|
541
570
|
interface InputFieldRootProps {
|
|
542
571
|
id?: string;
|
|
543
572
|
flex?: string;
|
|
544
573
|
children?: ReactNode;
|
|
545
574
|
width?: number;
|
|
575
|
+
/** @default end */
|
|
546
576
|
labelPosition?: LabelPosition;
|
|
547
577
|
labelSize?: number;
|
|
548
578
|
hasDropdown?: boolean;
|
|
579
|
+
/** @default medium */
|
|
549
580
|
size?: InputFieldSize;
|
|
550
581
|
renderPopoverContent?: (options: { width: number }) => ReactNode;
|
|
551
582
|
onFocusChange?: (isFocused: boolean) => void;
|
|
@@ -571,13 +602,11 @@ function InputFieldRoot({
|
|
|
571
602
|
const hasDropdown = childrenArray.some(
|
|
572
603
|
(child) => isValidElement(child) && child.type === InputFieldDropdownMenu
|
|
573
604
|
);
|
|
574
|
-
const hasLabel = childrenArray.some(
|
|
575
|
-
(child) => isValidElement(child) && child.type === InputFieldLabel
|
|
576
|
-
);
|
|
577
605
|
|
|
578
606
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
579
607
|
|
|
580
608
|
const [measuredLabelSize, setMeasuredLabelSize] = React.useState<number>();
|
|
609
|
+
const [measuredButtonSize, setMeasuredButtonSize] = React.useState<number>();
|
|
581
610
|
const [measuredWidth, setMeasuredWidth] = React.useState<number>();
|
|
582
611
|
|
|
583
612
|
const handleFocusChange = useCallback(
|
|
@@ -603,22 +632,23 @@ function InputFieldRoot({
|
|
|
603
632
|
const contextValue = useMemo(
|
|
604
633
|
(): InputFieldContextValue => ({
|
|
605
634
|
labelPosition,
|
|
606
|
-
labelSize: measuredLabelSize ?? labelSize
|
|
635
|
+
labelSize: measuredLabelSize ?? labelSize,
|
|
636
|
+
buttonSize: measuredButtonSize,
|
|
607
637
|
hasDropdown,
|
|
608
|
-
hasLabel,
|
|
609
638
|
size,
|
|
610
639
|
isFocused,
|
|
611
640
|
onFocusChange: handleFocusChange,
|
|
612
641
|
inputRef,
|
|
613
642
|
setInputRef,
|
|
614
643
|
setLabelWidth: setMeasuredLabelSize,
|
|
644
|
+
setButtonWidth: setMeasuredButtonSize,
|
|
615
645
|
}),
|
|
616
646
|
[
|
|
617
647
|
labelPosition,
|
|
618
648
|
measuredLabelSize,
|
|
619
649
|
labelSize,
|
|
650
|
+
measuredButtonSize,
|
|
620
651
|
hasDropdown,
|
|
621
|
-
hasLabel,
|
|
622
652
|
size,
|
|
623
653
|
isFocused,
|
|
624
654
|
handleFocusChange,
|
|
@@ -108,6 +108,7 @@ const ToggleGroupItem = forwardRef(function ToggleGroupItem(
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
type RadioGroupContextValue = {
|
|
111
|
+
/** @default primary */
|
|
111
112
|
colorScheme?: RadioGroupColorScheme;
|
|
112
113
|
};
|
|
113
114
|
|
|
@@ -119,6 +120,7 @@ interface Props {
|
|
|
119
120
|
id?: string;
|
|
120
121
|
value?: string;
|
|
121
122
|
onValueChange?: (value: string) => void;
|
|
123
|
+
/** @default primary */
|
|
122
124
|
colorScheme?: RadioGroupColorScheme;
|
|
123
125
|
allowEmpty?: boolean;
|
|
124
126
|
children: ReactNode;
|