@noya-app/noya-designsystem 0.1.15 → 0.1.17

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.
@@ -1,5 +1,4 @@
1
1
  import { CaretDownIcon } from "@noya-app/noya-icons";
2
- import { memoize } from "@noya-app/noya-utils";
3
2
  import { assignRef } from "@noya-app/react-utils";
4
3
  import { Property } from "csstype";
5
4
  import React, {
@@ -59,26 +58,26 @@ const InputFieldContext = createContext<InputFieldContextValue>({
59
58
 
60
59
  const LabelContainer = styled.label<{
61
60
  pointerEvents: Property.PointerEvents;
62
- labelPosition: LabelPosition;
63
- hasDropdown: boolean;
64
- }>(({ theme, labelPosition, hasDropdown, pointerEvents }) => ({
61
+ $labelPosition: LabelPosition;
62
+ $hasDropdown: boolean;
63
+ }>(({ theme, $labelPosition, $hasDropdown, pointerEvents }) => ({
65
64
  ...theme.textStyles.label,
66
65
  fontWeight: "bold",
67
66
  color: theme.colors.textDisabled,
68
67
  position: "absolute",
69
68
  top: 0,
70
- right: labelPosition === "end" ? 0 : undefined,
69
+ right: $labelPosition === "end" ? 0 : undefined,
71
70
  bottom: 0,
72
- left: labelPosition === "start" ? 0 : undefined,
71
+ left: $labelPosition === "start" ? 0 : undefined,
73
72
  display: "flex",
74
73
  alignItems: "center",
75
74
  pointerEvents,
76
75
  userSelect: "none",
77
- ...(labelPosition === "start"
76
+ ...($labelPosition === "start"
78
77
  ? { justifyContent: "flex-start", paddingLeft: "6px" }
79
78
  : {
80
79
  justifyContent: "flex-end",
81
- paddingRight: hasDropdown ? "16px" : "6px",
80
+ paddingRight: $hasDropdown ? "16px" : "6px",
82
81
  }),
83
82
  }));
84
83
 
@@ -115,8 +114,8 @@ const InputFieldLabel = memo(
115
114
  assignRef(forwardedRef, element);
116
115
  }}
117
116
  pointerEvents={pointerEvents}
118
- labelPosition={labelPosition}
119
- hasDropdown={hasDropdown}
117
+ $labelPosition={labelPosition}
118
+ $hasDropdown={hasDropdown}
120
119
  style={style}
121
120
  >
122
121
  {children}
@@ -175,11 +174,11 @@ const InputFieldDropdownMenu = memo(function InputFieldDropdownMenu<
175
174
  * Button
176
175
  * ------------------------------------------------------------------------- */
177
176
 
178
- const ButtonContainer = styled.span<{ size: InputFieldSize }>(
179
- ({ theme, size }) => ({
177
+ const ButtonContainer = styled.span<{ $size: InputFieldSize }>(
178
+ ({ theme, $size }) => ({
180
179
  position: "absolute",
181
- right: size === "large" ? "9px" : size === "medium" ? "4px" : "2px",
182
- top: size === "large" ? "8px" : size === "medium" ? "4px" : "2px",
180
+ right: $size === "large" ? "9px" : $size === "medium" ? "4px" : "2px",
181
+ top: $size === "large" ? "8px" : $size === "medium" ? "4px" : "2px",
183
182
  })
184
183
  );
185
184
 
@@ -212,7 +211,7 @@ const InputFieldButton = memo(function InputFieldButton({
212
211
  }, []);
213
212
 
214
213
  return (
215
- <ButtonContainer size={size}>
214
+ <ButtonContainer $size={size}>
216
215
  <Button
217
216
  variant="floating"
218
217
  onClick={onClick ?? defaultHandleClick}
@@ -229,50 +228,38 @@ const InputFieldButton = memo(function InputFieldButton({
229
228
  * Input
230
229
  * ------------------------------------------------------------------------- */
231
230
 
232
- const createCrossSVGString = memoize(
233
- (color: string) =>
234
- `<svg width='15' height='15' viewBox='0 0 15 15' fill='${color}' xmlns='http://www.w3.org/2000/svg'>
235
- <path d='M0.877075 7.49988C0.877075 3.84219 3.84222 0.877045 7.49991 0.877045C11.1576 0.877045 14.1227 3.84219 14.1227 7.49988C14.1227 11.1575 11.1576 14.1227 7.49991 14.1227C3.84222 14.1227 0.877075 11.1575 0.877075 7.49988ZM7.49991 1.82704C4.36689 1.82704 1.82708 4.36686 1.82708 7.49988C1.82708 10.6329 4.36689 13.1727 7.49991 13.1727C10.6329 13.1727 13.1727 10.6329 13.1727 7.49988C13.1727 4.36686 10.6329 1.82704 7.49991 1.82704ZM9.85358 5.14644C10.0488 5.3417 10.0488 5.65829 9.85358 5.85355L8.20713 7.49999L9.85358 9.14644C10.0488 9.3417 10.0488 9.65829 9.85358 9.85355C9.65832 10.0488 9.34173 10.0488 9.14647 9.85355L7.50002 8.2071L5.85358 9.85355C5.65832 10.0488 5.34173 10.0488 5.14647 9.85355C4.95121 9.65829 4.95121 9.3417 5.14647 9.14644L6.79292 7.49999L5.14647 5.85355C4.95121 5.65829 4.95121 5.3417 5.14647 5.14644C5.34173 4.95118 5.65832 4.95118 5.85358 5.14644L7.50002 6.79289L9.14647 5.14644C9.34173 4.95118 9.65832 4.95118 9.85358 5.14644Z' fill-rule='evenodd' clip-rule='evenodd'></path>
236
- </svg>`
237
- );
231
+ // const createCrossSVGString = memoize(
232
+ // (color: string) =>
233
+ // `<svg width='15' height='15' viewBox='0 0 15 15' fill='${color}' xmlns='http://www.w3.org/2000/svg'>
234
+ // <path d='M0.877075 7.49988C0.877075 3.84219 3.84222 0.877045 7.49991 0.877045C11.1576 0.877045 14.1227 3.84219 14.1227 7.49988C14.1227 11.1575 11.1576 14.1227 7.49991 14.1227C3.84222 14.1227 0.877075 11.1575 0.877075 7.49988ZM7.49991 1.82704C4.36689 1.82704 1.82708 4.36686 1.82708 7.49988C1.82708 10.6329 4.36689 13.1727 7.49991 13.1727C10.6329 13.1727 13.1727 10.6329 13.1727 7.49988C13.1727 4.36686 10.6329 1.82704 7.49991 1.82704ZM9.85358 5.14644C10.0488 5.3417 10.0488 5.65829 9.85358 5.85355L8.20713 7.49999L9.85358 9.14644C10.0488 9.3417 10.0488 9.65829 9.85358 9.85355C9.65832 10.0488 9.34173 10.0488 9.14647 9.85355L7.50002 8.2071L5.85358 9.85355C5.65832 10.0488 5.34173 10.0488 5.14647 9.85355C4.95121 9.65829 4.95121 9.3417 5.14647 9.14644L6.79292 7.49999L5.14647 5.85355C4.95121 5.65829 4.95121 5.3417 5.14647 5.14644C5.34173 4.95118 5.65832 4.95118 5.85358 5.14644L7.50002 6.79289L9.14647 5.14644C9.34173 4.95118 9.65832 4.95118 9.85358 5.14644Z' fill-rule='evenodd' clip-rule='evenodd'></path>
235
+ // </svg>`
236
+ // );
238
237
 
239
238
  type InputFieldVariant = "normal" | "bare";
240
239
 
241
- const ignoredProps = new Set([
242
- "labelPosition",
243
- "labelSize",
244
- "hasLabel",
245
- "hasDropdown",
246
- "textAlign",
247
- "variant",
248
- "onNudge",
249
- ]);
250
-
251
- export const InputElement = styled(TextInput).withConfig({
252
- shouldForwardProp: (prop) => (ignoredProps.has(prop) ? false : true),
253
- })<{
254
- labelPosition: LabelPosition;
255
- labelSize: number;
256
- hasLabel: boolean;
257
- hasDropdown: boolean;
258
- textAlign?: Property.TextAlign;
240
+ export const InputElement = styled(TextInput)<{
259
241
  disabled?: boolean;
260
- variant?: InputFieldVariant;
261
242
  readOnly?: boolean;
262
- size: InputFieldSize;
263
- }>(
264
- ({
265
- theme,
266
- labelPosition,
267
- labelSize,
268
- hasDropdown,
269
- textAlign,
270
- disabled,
271
- hasLabel,
272
- readOnly,
273
- variant = "normal",
274
- size,
275
- }) => ({
243
+ $labelPosition: LabelPosition;
244
+ $labelSize: number;
245
+ $hasLabel: boolean;
246
+ $hasDropdown: boolean;
247
+ $textAlign?: Property.TextAlign;
248
+ $variant?: InputFieldVariant;
249
+ $size: InputFieldSize;
250
+ }>(({
251
+ theme,
252
+ $labelPosition,
253
+ $labelSize,
254
+ $hasDropdown,
255
+ $textAlign,
256
+ disabled,
257
+ $hasLabel,
258
+ readOnly,
259
+ $variant = "normal",
260
+ $size,
261
+ }) => {
262
+ return {
276
263
  // placeholder
277
264
  "&::placeholder": {
278
265
  color: theme.colors.textDisabled,
@@ -283,7 +270,7 @@ export const InputElement = styled(TextInput).withConfig({
283
270
  : disabled
284
271
  ? theme.colors.textDisabled
285
272
  : theme.colors.text,
286
- ...(size === "small" && {
273
+ ...($size === "small" && {
287
274
  fontSize: "11px",
288
275
  }),
289
276
  width: "0px", // Reset intrinsic width
@@ -292,26 +279,26 @@ export const InputElement = styled(TextInput).withConfig({
292
279
  border: "0",
293
280
  outline: "none",
294
281
  minWidth: "0",
295
- textAlign: textAlign ?? "left",
282
+ textAlign: $textAlign ?? "left",
296
283
  alignSelf: "stretch",
297
284
  borderRadius: "4px",
298
- paddingTop: size === "large" ? "10px" : size === "medium" ? "4px" : "1px",
285
+ paddingTop: $size === "large" ? "10px" : $size === "medium" ? "4px" : "1px",
299
286
  paddingBottom:
300
- size === "large" ? "10px" : size === "medium" ? "4px" : "1px",
287
+ $size === "large" ? "10px" : $size === "medium" ? "4px" : "1px",
301
288
  paddingLeft:
302
- (size === "large" ? 10 : size === "medium" ? 6 : 4) +
303
- (hasLabel && labelPosition === "start" ? 6 + labelSize : 0) +
289
+ ($size === "large" ? 10 : $size === "medium" ? 6 : 4) +
290
+ ($hasLabel && $labelPosition === "start" ? 6 + $labelSize : 0) +
304
291
  "px",
305
292
  paddingRight:
306
- (size === "large" ? 10 : size === "medium" ? 6 : 4) +
307
- (hasLabel && labelPosition === "end" ? 6 + labelSize : 0) +
308
- (hasDropdown ? 11 : 0) +
293
+ ($size === "large" ? 10 : $size === "medium" ? 6 : 4) +
294
+ ($hasLabel && $labelPosition === "end" ? 6 + $labelSize : 0) +
295
+ ($hasDropdown ? 11 : 0) +
309
296
  "px",
310
297
  background: theme.colors.inputBackground,
311
298
  "&:focus": {
312
299
  boxShadow: `0 0 0 2px ${theme.colors.primary}`,
313
300
  },
314
- ...(variant === "bare" && {
301
+ ...($variant === "bare" && {
315
302
  paddingTop: "4px",
316
303
  paddingRight: "4px",
317
304
  paddingBottom: "4px",
@@ -322,16 +309,16 @@ export const InputElement = styled(TextInput).withConfig({
322
309
  marginLeft: "-4px",
323
310
  }),
324
311
 
325
- '&[type="search"]::-webkit-search-cancel-button': {
326
- appearance: "none",
327
- height: "15px",
328
- width: "15px",
329
- background: `url("data:image/svg+xml;utf8,${createCrossSVGString(
330
- theme.colors.icon
331
- )}") no-repeat`,
332
- },
333
- })
334
- );
312
+ // '&[type="search"]::-webkit-search-cancel-button': {
313
+ // appearance: "none",
314
+ // height: "15px",
315
+ // width: "15px",
316
+ // background: `url("data:image/svg+xml;utf8,${createCrossSVGString(
317
+ // theme.colors.icon
318
+ // )}") no-repeat`,
319
+ // },
320
+ };
321
+ });
335
322
 
336
323
  const InputFieldInput = forwardRef(function InputFieldInput(
337
324
  // onFocusChange should only be passed from the root, never directly
@@ -365,11 +352,11 @@ const InputFieldInput = forwardRef(function InputFieldInput(
365
352
  return (
366
353
  <InputElement
367
354
  ref={forwardedRef}
368
- labelPosition={labelPosition}
369
- labelSize={labelSize}
370
- hasLabel={hasLabel}
371
- hasDropdown={hasDropdown}
372
- size={size}
355
+ $labelPosition={labelPosition}
356
+ $labelSize={labelSize}
357
+ $hasLabel={hasLabel}
358
+ $hasDropdown={hasDropdown}
359
+ $size={size}
373
360
  onFocusChange={handleFocusChange}
374
361
  {...props}
375
362
  />
@@ -388,11 +375,11 @@ const InputFieldTypeahead = (props: { value: string }) => {
388
375
 
389
376
  return (
390
377
  <InputElement
391
- labelPosition={labelPosition}
392
- labelSize={labelSize}
393
- hasLabel={hasLabel}
394
- hasDropdown={hasDropdown}
395
- size={size}
378
+ $labelPosition={labelPosition}
379
+ $labelSize={labelSize}
380
+ $hasLabel={hasLabel}
381
+ $hasDropdown={hasDropdown}
382
+ $size={size}
396
383
  onFocusChange={onFocusChange}
397
384
  readOnly
398
385
  placeholder={props.value}
@@ -438,7 +425,7 @@ function parseNumber(value: string) {
438
425
  }
439
426
 
440
427
  function InputFieldNumberInput(props: InputFieldNumberInputProps) {
441
- const { value, placeholder, onNudge } = props;
428
+ const { value, placeholder, onNudge, ...rest } = props;
442
429
  const onSubmit = "onSubmit" in props ? props.onSubmit : undefined;
443
430
  const onChange = "onChange" in props ? props.onChange : undefined;
444
431
 
@@ -476,7 +463,7 @@ function InputFieldNumberInput(props: InputFieldNumberInputProps) {
476
463
 
477
464
  return (
478
465
  <InputFieldInput
479
- {...props}
466
+ {...rest}
480
467
  value={value === undefined ? "" : String(value)}
481
468
  placeholder={placeholder}
482
469
  onKeyDown={handleKeyDown}
@@ -491,13 +478,13 @@ function InputFieldNumberInput(props: InputFieldNumberInputProps) {
491
478
  * Root
492
479
  * ------------------------------------------------------------------------- */
493
480
 
494
- const RootContainer = styled.div<{ width?: number; flex?: string }>(
495
- ({ theme, flex, width }) => ({
496
- flex: flex ?? "1",
481
+ const RootContainer = styled.div<{ $width?: number; $flex?: string }>(
482
+ ({ theme, $flex, $width }) => ({
483
+ flex: $flex ?? "1",
497
484
  display: "flex",
498
485
  flexDirection: "row",
499
486
  position: "relative",
500
- maxWidth: typeof width === "number" ? `${width}px` : undefined,
487
+ maxWidth: typeof $width === "number" ? `${$width}px` : undefined,
501
488
  })
502
489
  );
503
490
 
@@ -586,7 +573,7 @@ function InputFieldRoot({
586
573
  );
587
574
 
588
575
  const rootElement = (
589
- <RootContainer id={id} width={width} flex={flex}>
576
+ <RootContainer id={id} $width={width} $flex={flex}>
590
577
  {children}
591
578
  </RootContainer>
592
579
  );
@@ -66,9 +66,9 @@ function filterWithGroupedSections(
66
66
  });
67
67
  }
68
68
 
69
- export const CompletionToken = styled.span<{ type: IToken["type"] }>(
70
- ({ type }) => ({
71
- fontWeight: type === "match" ? "bold" : "normal",
69
+ export const CompletionToken = styled.span<{ $type: IToken["type"] }>(
70
+ ({ $type }) => ({
71
+ fontWeight: $type === "match" ? "bold" : "normal",
72
72
  whiteSpace: "pre",
73
73
  })
74
74
  );
@@ -127,7 +127,7 @@ export const CompletionMenu = memo(
127
127
  }}
128
128
  >
129
129
  {tokens.map((token, j) => (
130
- <CompletionToken key={j} type={token.type}>
130
+ <CompletionToken key={j} $type={token.type}>
131
131
  {token.text}
132
132
  </CompletionToken>
133
133
  ))}
@@ -3,14 +3,14 @@ import styled, { useTheme } from "styled-components";
3
3
  import { Spacer } from "./Spacer";
4
4
 
5
5
  export const Section = styled.div<{
6
- padding?: CSSProperties["padding"];
7
- gap?: CSSProperties["gap"];
8
- }>(({ theme, padding = "10px", gap }) => ({
6
+ $padding?: CSSProperties["padding"];
7
+ $gap?: CSSProperties["gap"];
8
+ }>(({ theme, $padding = "10px", $gap }) => ({
9
9
  flex: "0 0 auto",
10
10
  display: "flex",
11
11
  flexDirection: "column",
12
- padding,
13
- gap,
12
+ padding: $padding,
13
+ gap: $gap,
14
14
  }));
15
15
 
16
16
  export const SectionHeader = styled.div(({ theme }) => ({
@@ -19,14 +19,14 @@ export const SectionHeader = styled.div(({ theme }) => ({
19
19
  }));
20
20
 
21
21
  export const Title = styled.div<{
22
- textStyle?: "small" | "heading5" | "heading4" | "heading3";
23
- }>(({ theme, textStyle }) => ({
22
+ $textStyle?: "small" | "heading5" | "heading4" | "heading3";
23
+ }>(({ theme, $textStyle }) => ({
24
24
  display: "flex",
25
25
  flexDirection: "row",
26
26
  userSelect: "none",
27
- ...(textStyle
27
+ ...($textStyle
28
28
  ? {
29
- ...theme.textStyles[textStyle],
29
+ ...theme.textStyles[$textStyle],
30
30
  color: theme.colors.text,
31
31
  }
32
32
  : {
@@ -36,13 +36,13 @@ export const Title = styled.div<{
36
36
  }),
37
37
  }));
38
38
 
39
- export const Row = styled.div<{ gap?: CSSProperties["gap"] }>(
40
- ({ theme, gap }) => ({
39
+ export const Row = styled.div<{ $gap?: CSSProperties["gap"] }>(
40
+ ({ theme, $gap }) => ({
41
41
  flex: "1",
42
42
  display: "flex",
43
43
  flexDirection: "row",
44
44
  alignItems: "center",
45
- gap,
45
+ gap: $gap,
46
46
  })
47
47
  );
48
48
 
@@ -76,13 +76,13 @@ const SliderRowLabel = styled.span(({ theme }) => ({
76
76
  }));
77
77
 
78
78
  export const RowLabel = styled.span<{
79
- textStyle?: "small" | "heading5" | "heading4" | "heading3";
80
- }>(({ theme, textStyle }) => ({
79
+ $textStyle?: "small" | "heading5" | "heading4" | "heading3";
80
+ }>(({ theme, $textStyle }) => ({
81
81
  // marginBottom: '6px',
82
82
  display: "flex",
83
- ...(textStyle
83
+ ...($textStyle
84
84
  ? {
85
- ...theme.textStyles[textStyle],
85
+ ...theme.textStyles[$textStyle],
86
86
  }
87
87
  : {
88
88
  ...theme.textStyles.label,
@@ -111,12 +111,12 @@ export const LabeledRow = memo(function LabeledRow({
111
111
  return (
112
112
  <Row id={id}>
113
113
  <Column>
114
- <RowLabel textStyle={labelTextStyle}>
114
+ <RowLabel $textStyle={labelTextStyle}>
115
115
  {label}
116
116
  {right && <Spacer.Horizontal />}
117
117
  {right}
118
118
  </RowLabel>
119
- <Row gap={gap}>{children}</Row>
119
+ <Row $gap={gap}>{children}</Row>
120
120
  </Column>
121
121
  </Row>
122
122
  );
@@ -1,24 +1,24 @@
1
- import React, { memo, ReactNode } from 'react';
2
- import styled from 'styled-components';
3
- import { Spacer } from './Spacer';
1
+ import React, { memo, ReactNode } from "react";
2
+ import styled from "styled-components";
3
+ import { Spacer } from "./Spacer";
4
4
 
5
5
  /* ----------------------------------------------------------------------------
6
6
  * Label
7
7
  * ------------------------------------------------------------------------- */
8
8
 
9
- const LabelLabel = styled.label<{ selected?: boolean }>(
10
- ({ theme, selected }) => ({
9
+ const LabelLabel = styled.label<{ $selected?: boolean }>(
10
+ ({ theme, $selected }) => ({
11
11
  ...theme.textStyles.small,
12
12
  color: theme.colors.textMuted,
13
- ...(selected && {
13
+ ...($selected && {
14
14
  color: theme.colors.text,
15
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
- }),
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
22
  );
23
23
 
24
24
  /* ----------------------------------------------------------------------------
@@ -26,15 +26,15 @@ const LabelLabel = styled.label<{ selected?: boolean }>(
26
26
  * ------------------------------------------------------------------------- */
27
27
 
28
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',
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
38
  }));
39
39
 
40
40
  interface LabelRootProps {