@rebasepro/ui 0.17.3 → 0.18.0

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 (127) hide show
  1. package/README.md +4 -0
  2. package/dist/components/MultiSelect.d.ts +10 -0
  3. package/dist/index.es.js +2 -1
  4. package/dist/index.es.js.map +1 -1
  5. package/package.json +32 -23
  6. package/src/components/Alert.tsx +0 -118
  7. package/src/components/Autocomplete.tsx +0 -93
  8. package/src/components/Avatar.tsx +0 -73
  9. package/src/components/Badge.tsx +0 -44
  10. package/src/components/BooleanSwitch.tsx +0 -116
  11. package/src/components/BooleanSwitchWithLabel.tsx +0 -120
  12. package/src/components/Button.tsx +0 -110
  13. package/src/components/Card.tsx +0 -43
  14. package/src/components/CenteredView.tsx +0 -35
  15. package/src/components/Checkbox.tsx +0 -129
  16. package/src/components/Chip.tsx +0 -131
  17. package/src/components/CircularProgress.tsx +0 -53
  18. package/src/components/CircularProgressCenter.tsx +0 -27
  19. package/src/components/Collapse.tsx +0 -66
  20. package/src/components/ColorPicker.tsx +0 -140
  21. package/src/components/Container.tsx +0 -51
  22. package/src/components/DateTimeField.tsx +0 -363
  23. package/src/components/DebouncedTextField.tsx +0 -76
  24. package/src/components/Dialog.tsx +0 -159
  25. package/src/components/DialogActions.tsx +0 -29
  26. package/src/components/DialogContent.tsx +0 -27
  27. package/src/components/DialogTitle.tsx +0 -41
  28. package/src/components/ErrorBoundary.tsx +0 -236
  29. package/src/components/ExpandablePanel.tsx +0 -130
  30. package/src/components/FileUpload.tsx +0 -103
  31. package/src/components/FilterChip.tsx +0 -89
  32. package/src/components/IconButton.tsx +0 -101
  33. package/src/components/InfoLabel.tsx +0 -23
  34. package/src/components/InputLabel.tsx +0 -40
  35. package/src/components/Label.tsx +0 -32
  36. package/src/components/LoadingButton.tsx +0 -32
  37. package/src/components/Markdown.tsx +0 -55
  38. package/src/components/Menu.tsx +0 -114
  39. package/src/components/Menubar.tsx +0 -355
  40. package/src/components/MultiSelect.tsx +0 -433
  41. package/src/components/Paper.tsx +0 -23
  42. package/src/components/Popover.tsx +0 -162
  43. package/src/components/RadioGroup.tsx +0 -74
  44. package/src/components/ResizablePanels.tsx +0 -189
  45. package/src/components/SearchBar.tsx +0 -136
  46. package/src/components/Select.tsx +0 -326
  47. package/src/components/Separator.tsx +0 -28
  48. package/src/components/Sheet.tsx +0 -135
  49. package/src/components/Skeleton.tsx +0 -54
  50. package/src/components/Slider.tsx +0 -110
  51. package/src/components/Table.tsx +0 -178
  52. package/src/components/Tabs.tsx +0 -185
  53. package/src/components/TextField.tsx +0 -270
  54. package/src/components/TextareaAutosize.tsx +0 -368
  55. package/src/components/ToggleButtonGroup.tsx +0 -69
  56. package/src/components/Tooltip.tsx +0 -153
  57. package/src/components/Typography.tsx +0 -132
  58. package/src/components/VirtualTable/VirtualTable.performance.test.tsx +0 -90
  59. package/src/components/VirtualTable/VirtualTable.tsx +0 -700
  60. package/src/components/VirtualTable/VirtualTableCell.tsx +0 -59
  61. package/src/components/VirtualTable/VirtualTableHeader.tsx +0 -327
  62. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +0 -250
  63. package/src/components/VirtualTable/VirtualTableProps.tsx +0 -339
  64. package/src/components/VirtualTable/VirtualTableRow.tsx +0 -51
  65. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +0 -44
  66. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +0 -89
  67. package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +0 -71
  68. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +0 -107
  69. package/src/components/VirtualTable/fields/VirtualTableSwitch.tsx +0 -28
  70. package/src/components/VirtualTable/index.tsx +0 -10
  71. package/src/components/VirtualTable/selection/SelectionContext.tsx +0 -36
  72. package/src/components/VirtualTable/selection/SelectionStore.ts +0 -54
  73. package/src/components/VirtualTable/types.tsx +0 -47
  74. package/src/components/common/SelectInputLabel.tsx +0 -23
  75. package/src/components/index.tsx +0 -62
  76. package/src/hooks/PortalContainerContext.tsx +0 -50
  77. package/src/hooks/index.ts +0 -7
  78. package/src/hooks/useDebounceCallback.tsx +0 -21
  79. package/src/hooks/useDebounceValue.tsx +0 -20
  80. package/src/hooks/useDebouncedCallback.ts +0 -39
  81. package/src/hooks/useInjectStyles.tsx +0 -31
  82. package/src/hooks/useOutsideAlerter.tsx +0 -46
  83. package/src/icons/GitHubIcon.tsx +0 -21
  84. package/src/icons/HandleIcon.tsx +0 -23
  85. package/src/icons/Icon.tsx +0 -33
  86. package/src/icons/LucideIconByName.tsx +0 -117
  87. package/src/icons/cool_icon_keys.ts +0 -12
  88. package/src/icons/icon_keys.ts +0 -1936
  89. package/src/icons/index.ts +0 -179
  90. package/src/index.css +0 -169
  91. package/src/index.ts +0 -47
  92. package/src/scripts/fixIconSizes.cjs +0 -92
  93. package/src/scripts/fixIconSizesToConst.cjs +0 -106
  94. package/src/scripts/generateIconKeys.ts +0 -41
  95. package/src/scripts/generateIcons.ts +0 -4
  96. package/src/scripts/saveIconFiles.ts +0 -89
  97. package/src/styles.ts +0 -141
  98. package/src/theme.css +0 -168
  99. package/src/util/chip_colors.ts +0 -242
  100. package/src/util/cls.ts +0 -8
  101. package/src/util/debounce.ts +0 -28
  102. package/src/util/hash.ts +0 -11
  103. package/src/util/index.ts +0 -4
  104. package/src/util/key_to_icon_component.ts +0 -11
  105. package/src/util/lazy_chunk.ts +0 -101
  106. package/src/views/CardView.tsx +0 -281
  107. package/src/views/CollectionView/CollectionCardView.tsx +0 -265
  108. package/src/views/CollectionView/CollectionKanbanView.tsx +0 -246
  109. package/src/views/CollectionView/CollectionListView.tsx +0 -240
  110. package/src/views/CollectionView/CollectionTableView.tsx +0 -229
  111. package/src/views/CollectionView/CollectionView.tsx +0 -450
  112. package/src/views/CollectionView/CollectionViewToolbar.tsx +0 -242
  113. package/src/views/CollectionView/CollectionViewTypes.ts +0 -181
  114. package/src/views/CollectionView/DefaultCellRenderer.tsx +0 -404
  115. package/src/views/CollectionView/index.ts +0 -39
  116. package/src/views/CollectionView/resolveTitleProperty.ts +0 -52
  117. package/src/views/CollectionView/utils.ts +0 -14
  118. package/src/views/Kanban/Board.tsx +0 -384
  119. package/src/views/Kanban/BoardColumn.tsx +0 -138
  120. package/src/views/Kanban/BoardColumnTitle.tsx +0 -47
  121. package/src/views/Kanban/BoardSortableList.tsx +0 -182
  122. package/src/views/Kanban/board_types.ts +0 -80
  123. package/src/views/Kanban/index.tsx +0 -5
  124. package/src/views/Kanban/placement.ts +0 -62
  125. package/src/views/KanbanView.tsx +0 -32
  126. package/src/views/ListView.tsx +0 -296
  127. package/src/views/index.ts +0 -5
@@ -1,110 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import { cls } from "../util";
4
- import { type ButtonSize, controlHeightMixin, controlPaddingMixin } from "../styles";
5
-
6
- export type ButtonProps<C extends React.ElementType = "button"> = {
7
- children?: React.ReactNode;
8
- variant?: "filled" | "outlined" | "text";
9
- disabled?: boolean;
10
- color?: "primary" | "secondary" | "text" | "error" | "neutral";
11
- size?: ButtonSize;
12
- startIcon?: React.ReactNode;
13
- fullWidth?: boolean;
14
- className?: string;
15
- component?: C;
16
- onClick?: React.MouseEventHandler<HTMLElement>;
17
- } & React.ComponentPropsWithoutRef<C>;
18
-
19
- const ButtonInner = React.memo(React.forwardRef<
20
- HTMLButtonElement,
21
- ButtonProps<React.ElementType>
22
- >(({
23
- children,
24
- className,
25
- variant = "filled",
26
- disabled = false,
27
- size = "medium",
28
- startIcon = null,
29
- fullWidth = false,
30
- component: Component,
31
- color = "neutral",
32
- ...props
33
- }: ButtonProps<React.ElementType>, ref) => {
34
-
35
- const baseClasses =
36
- "typography-button h-fit rounded-lg whitespace-nowrap inline-flex items-center justify-center p-2 px-4 focus:outline-none transition-colors ease-in-out duration-150 gap-2";
37
-
38
- const buttonClasses = cls({
39
- "w-full": fullWidth,
40
- "w-fit": !fullWidth,
41
-
42
- // Filled Variants
43
- "border border-primary bg-primary focus:ring-primary text-white hover:text-white hover:brightness-105": variant === "filled" && color === "primary" && !disabled,
44
- "border border-secondary bg-secondary focus:ring-secondary text-white hover:text-white hover:brightness-105": variant === "filled" && color === "secondary" && !disabled,
45
- "border border-red-600 bg-red-600 hover:bg-red-700 focus:ring-red-600 text-white hover:text-white": variant === "filled" && color === "error" && !disabled,
46
- "border border-surface-accent-200 bg-surface-accent-200 hover:bg-surface-accent-300 focus:ring-surface-accent-400 text-text-primary hover:text-text-primary dark:border-surface-accent-700 dark:bg-surface-accent-700 dark:hover:bg-surface-accent-600 dark:text-text-primary-dark hover:dark:text-text-primary-dark": variant === "filled" && color === "text" && !disabled,
47
- "border border-transparent bg-surface-100 hover:bg-surface-accent-200 text-text-primary dark:bg-surface-700 dark:hover:bg-surface-accent-700 dark:text-text-primary-dark hover:text-text-primary dark:text-text-primary-dark hover:dark:text-text-primary-dark": variant === "filled" && color === "neutral" && !disabled,
48
-
49
- // Text Variants
50
- "border border-transparent text-primary hover:text-primary hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:hover:bg-surface-accent-800": variant === "text" && color === "primary" && !disabled,
51
- "border border-transparent text-secondary hover:text-secondary hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:hover:bg-surface-accent-800": variant === "text" && color === "secondary" && !disabled,
52
- "border border-transparent text-red-600 hover:text-red-600 hover:bg-red-600 hover:bg-opacity-10 hover:bg-red-600/10": variant === "text" && color === "error" && !disabled,
53
- "border border-transparent text-text-primary hover:text-text-primary dark:text-text-primary-dark hover:dark:text-text-primary-dark hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:hover:bg-surface-accent-800": variant === "text" && color === "text" && !disabled,
54
- "border border-transparent text-text-primary hover:text-text-primary hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:text-text-primary-dark dark:hover:text-text-primary-dark dark:hover:bg-surface-accent-800": variant === "text" && color === "neutral" && !disabled,
55
-
56
- // Outlined Variants
57
- "border border-primary text-primary hover:text-primary hover:bg-primary-bg hover:bg-primary/10": variant === "outlined" && color === "primary" && !disabled,
58
- "border border-secondary text-secondary hover:text-secondary hover:bg-secondary-bg": variant === "outlined" && color === "secondary" && !disabled,
59
- "border border-red-500 text-red-600 hover:text-white hover:bg-red-600": variant === "outlined" && color === "error" && !disabled,
60
- "border border-surface-accent-400 text-text-primary hover:text-text-primary dark:text-text-primary-dark dark:border-surface-accent-600 hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:hover:bg-surface-accent-800": variant === "outlined" && color === "text" && !disabled,
61
- "border border-surface-300 text-text-primary hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:border-surface-600 dark:text-text-primary-dark dark:hover:bg-surface-accent-800": variant === "outlined" && color === "neutral" && !disabled,
62
-
63
- // Disabled states for all variants
64
- "text-text-disabled dark:text-text-disabled-dark": disabled,
65
- "border border-transparent opacity-50": variant === "text" && disabled,
66
- "border border-surface-500 opacity-50": variant === "outlined" && disabled,
67
- "border border-transparent bg-surface-300 dark:bg-surface-500 opacity-40 bg-surface-300/40 dark:bg-surface-500/40": variant === "filled" && disabled
68
- });
69
-
70
- // Height comes from the shared control scale (see styles.ts) so a Button
71
- // and a TextField at the same `size` line up. Vertical padding is dropped:
72
- // the button is an inline-flex box centring its content inside min-height.
73
- const sizeClasses = cls("py-0", controlHeightMixin[size], controlPaddingMixin[size]);
74
-
75
- const iconColorClass = (color === "neutral" || color === "text") && !disabled
76
- ? "[&>svg]:text-surface-accent-500 dark:[&>svg]:text-surface-accent-300"
77
- : "";
78
-
79
- if (Component) {
80
- return (
81
- <Component
82
- ref={ref}
83
- onClick={props.onClick}
84
- className={cls(startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, iconColorClass, className)}
85
- {...props}>
86
- {startIcon}
87
- {children}
88
- </Component>
89
- );
90
- }
91
-
92
- return (
93
- <button ref={ref as React.Ref<HTMLButtonElement>}
94
- type={props.type ?? "button"}
95
- onClick={props.onClick}
96
- className={cls(startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, iconColorClass, className)}
97
- disabled={disabled}
98
- data-variant={variant}
99
- data-size={size}
100
- {...props as React.ButtonHTMLAttributes<HTMLButtonElement>}>
101
- {startIcon}
102
- {children}
103
- </button>
104
- );
105
-
106
- }));
107
-
108
- ButtonInner.displayName = "Button"
109
-
110
- export const Button = ButtonInner as React.FC<ButtonProps<React.ElementType>>;
@@ -1,43 +0,0 @@
1
- "use client";
2
- import React, { useCallback } from "react";
3
- import { cardClickableMixin, cardMixin } from "../styles";
4
- import { cls } from "../util";
5
-
6
- type CardProps = {
7
- children: React.ReactNode;
8
- style?: React.CSSProperties;
9
- onClick?: (e?: React.MouseEvent) => void;
10
- className?: string;
11
- } & React.HTMLAttributes<HTMLDivElement>;
12
-
13
- const Card = React.forwardRef<HTMLDivElement, CardProps>(({
14
- children,
15
- className,
16
- onClick,
17
- style,
18
- ...props
19
- }, ref) => {
20
- const onKeyPress = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
21
- if (e.key === "Enter" || e.key === " ") {
22
- onClick?.();
23
- }
24
- }, [onClick]);
25
-
26
- return (
27
- <div
28
- ref={ref}
29
- onKeyPress={onKeyPress}
30
- role={onClick ? "button" : undefined}
31
- tabIndex={onClick ? 0 : undefined}
32
- onClick={onClick}
33
- className={cls(cardMixin, onClick && cardClickableMixin, className)}
34
- style={style}
35
- {...props}>
36
- {children}
37
- </div>
38
- );
39
- });
40
-
41
- Card.displayName = "Card";
42
-
43
- export { Card };
@@ -1,35 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import { Container } from "./Container";
4
- import { cls } from "../util";
5
-
6
- export type CenteredViewProps = {
7
- children: React.ReactNode;
8
- maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl";
9
- outerClassName?: string;
10
- className?: string;
11
- fullScreen?: boolean;
12
- };
13
-
14
- export const CenteredView = React.forwardRef<HTMLDivElement, CenteredViewProps>(({
15
- children,
16
- maxWidth,
17
- outerClassName,
18
- className,
19
- fullScreen,
20
- ...rest
21
- }, ref) => { // Notice how the ref is now received as the second argument
22
-
23
- return (
24
- <div ref={ref}
25
- className={cls("flex flex-col grow", fullScreen ? "h-screen" : "h-full", outerClassName)}
26
- {...rest}>
27
- <Container className={cls("m-auto", className)} maxWidth={maxWidth}>
28
- {children}
29
- </Container>
30
- </div>
31
- );
32
-
33
- });
34
-
35
- CenteredView.displayName = "CenteredView";
@@ -1,129 +0,0 @@
1
-
2
- import React from "react";
3
- import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4
-
5
- import { CheckIcon, MinusIcon } from "lucide-react";
6
- import { cls } from "../util";
7
-
8
- export interface CheckboxProps {
9
- checked: boolean;
10
- id?: string;
11
- disabled?: boolean;
12
- indeterminate?: boolean;
13
- onCheckedChange?: (checked: boolean) => void;
14
- padding?: boolean;
15
- size?: "smallest" | "small" | "medium" | "large";
16
- color?: "primary" | "secondary";
17
- "aria-label"?: string;
18
- }
19
-
20
- // Radius steps down with the box. `rounded-md` is 6px — on a 16-20px box that
21
- // is most of the edge, so the control reads as a squircle rather than a
22
- // checkbox. Box sizes match the icon glyph scale (16/16/20/24) so a Checkbox
23
- // sitting beside IconButtons in a table row is the same visual size.
24
- const sizeClasses = {
25
- large: "w-6 h-6 rounded flex items-center justify-center",
26
- medium: "w-5 h-5 rounded flex items-center justify-center",
27
- small: "w-4 h-4 rounded-sm flex items-center justify-center",
28
- smallest: "w-4 h-4 rounded-sm flex items-center justify-center"
29
- };
30
-
31
- // Outer box is the hit area and sets the control's rendered height, so it
32
- // tracks the shared 28/32/40/48 scale. `smallest` used to reuse `small`'s
33
- // 32px box, which made the two sizes identical.
34
- //
35
- // A checkbox with no `onCheckedChange` is not a hit area — it is a tick mark
36
- // standing in for a value, as in `BooleanPreview`. There the box was 10px of
37
- // dead space on each side of a `medium` tick: on top of a read-only field's
38
- // own padding, it started the tick 10px further in than the text of the field
39
- // beside it. `padding={false}` reads as the request to drop it, and until now
40
- // did nothing at all, because it only removed `p-2` from a box whose size was
41
- // fixed regardless. Kept for anything clickable — the same box is the click
42
- // target for table row selection and for editor task items.
43
- const outerSizeClasses = {
44
- medium: "w-10 h-10",
45
- small: "w-8 h-8",
46
- large: "w-12 h-12 ",
47
- smallest: "w-7 h-7"
48
- }
49
- // Flat p-2, as it always was. `shrink-0` on the box below is what stops it
50
- // being squashed; changing the padding here only shifts the control's optical
51
- // weight relative to the icons beside it.
52
- const paddingClasses = {
53
- medium: "p-2",
54
- small: "p-2",
55
- large: "p-2",
56
- smallest: "p-2"
57
- }
58
-
59
- const colorClasses = {
60
- primary: "bg-primary",
61
- secondary: "bg-secondary"
62
- }
63
-
64
- export const Checkbox = React.memo(({
65
- id,
66
- checked,
67
- indeterminate = false,
68
- padding = true,
69
- disabled,
70
- size = "medium",
71
- onCheckedChange,
72
- color = "primary",
73
- "aria-label": ariaLabel
74
- }: CheckboxProps) => {
75
-
76
- const isChecked = indeterminate ? false : checked;
77
-
78
- const iconSize = size === "medium"
79
- ? 20
80
- : size === "small"
81
- ? 16
82
- : size === "smallest"
83
- ? 14
84
- : 24;
85
- return (
86
- <CheckboxPrimitive.Root
87
- id={id}
88
- checked={indeterminate || isChecked}
89
- disabled={disabled}
90
- aria-label={ariaLabel}
91
- aria-checked={indeterminate ? "mixed" : isChecked}
92
- className="rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"
93
- onCheckedChange={disabled ? undefined : onCheckedChange}>
94
-
95
- <div className={cls(
96
- padding ? paddingClasses[size] : "",
97
- padding || onCheckedChange ? outerSizeClasses[size] : "",
98
- "inline-flex items-center justify-center text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150",
99
- onCheckedChange ? "rounded-full hover:bg-surface-accent-200 hover:bg-opacity-75 hover:bg-surface-accent-200/75 dark:hover:bg-surface-accent-700 dark:hover:bg-opacity-75 dark:hover:bg-surface-accent-700/75" : "",
100
- onCheckedChange ? "cursor-pointer" : "cursor-default"
101
- )}>
102
- <div
103
- className={cls(
104
- "border-2 shrink-0 relative transition-colors ease-in-out duration-150",
105
- sizeClasses[size],
106
- disabled
107
- ? (indeterminate || isChecked ? "bg-surface-accent-400 dark:bg-surface-accent-600" : "bg-surface-accent-400 dark:bg-surface-accent-600")
108
- : (indeterminate || isChecked ? colorClasses[color] : "bg-white dark:bg-surface-900"),
109
- (indeterminate || isChecked) ? "text-surface-accent-100 dark:text-surface-accent-900" : "",
110
- disabled
111
- ? "border-transparent"
112
- : (indeterminate || isChecked ? "border-transparent" : "border-surface-accent-800 dark:border-surface-accent-500")
113
- )}>
114
- <CheckboxPrimitive.Indicator asChild>
115
- {indeterminate
116
- ? (
117
- <MinusIcon size={iconSize} className={"absolute"}/>
118
- )
119
- : (
120
- <CheckIcon size={iconSize} className={"absolute"}/>
121
- )}
122
- </CheckboxPrimitive.Indicator>
123
- </div>
124
- </div>
125
- </CheckboxPrimitive.Root>
126
- );
127
- });
128
-
129
- Checkbox.displayName = "Checkbox";
@@ -1,131 +0,0 @@
1
- import React from "react";
2
- import { CHIP_COLORS, cls, getColorSchemeForKey } from "../util";
3
- import type { ChipColorKey, ChipColorScheme } from "../util/chip_colors";
4
-
5
- export type { ChipColorKey, ChipColorScheme };
6
-
7
- export interface ChipProps {
8
- className?: string;
9
- children: React.ReactNode;
10
- size?: "smallest" | "small" | "medium" | "large";
11
- colorScheme?: ChipColorScheme | ChipColorKey;
12
- error?: boolean;
13
- outlined?: boolean;
14
- onClick?: () => void;
15
- icon?: React.ReactNode;
16
- style?: React.CSSProperties;
17
- }
18
-
19
- // `small` and `medium` used to differ only in horizontal padding, so both
20
- // rendered at the same height and the step was invisible. Vertical rhythm now
21
- // increases across the whole scale.
22
- const sizeClassNames = {
23
- smallest: "px-1.5 py-px text-[10px]",
24
- small: "px-2 py-0.5 text-xs",
25
- medium: "px-2.5 py-1 text-xs",
26
- large: "px-3 py-1.5 text-sm"
27
- }
28
-
29
- /**
30
- * Detect if the app is currently in dark mode by checking the
31
- * Tailwind `dark` class on the document root.
32
- */
33
- function isDarkMode(): boolean {
34
- return typeof document !== "undefined" &&
35
- document.documentElement.classList.contains("dark");
36
- }
37
-
38
- /**
39
- * Helper to generate rgba from hex or standard colors.
40
- */
41
- function getRgba(hex: string, alpha: number): string {
42
- if (!hex || !hex.startsWith("#")) return hex;
43
- let color = hex.slice(1);
44
- if (color.length === 3) {
45
- color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];
46
- }
47
- const r = parseInt(color.slice(0, 2), 16);
48
- const g = parseInt(color.slice(2, 4), 16);
49
- const b = parseInt(color.slice(4, 6), 16);
50
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
51
- }
52
-
53
- /**
54
- * @group Preview components
55
- */
56
- export function Chip({
57
- children,
58
- colorScheme,
59
- error,
60
- outlined,
61
- onClick,
62
- icon,
63
- size = "medium",
64
- className,
65
- style
66
- }: ChipProps) {
67
-
68
- const usedColorScheme = typeof colorScheme === "string" ? getColorSchemeForKey(colorScheme) : colorScheme;
69
- const dark = isDarkMode();
70
-
71
- const hasScheme = error || usedColorScheme;
72
-
73
- let textColor = "";
74
- let bgColor = "";
75
- let border = "";
76
-
77
- if (error) {
78
- textColor = dark ? "#f87171" : "#dc2626";
79
- } else if (usedColorScheme) {
80
- textColor = dark && usedColorScheme.darkText ? usedColorScheme.darkText : usedColorScheme.text;
81
- }
82
-
83
- if (hasScheme) {
84
- if (outlined) {
85
- // An outlined chip has no fill, so it needs the ink meant for the
86
- // PAGE, not the ink meant for the fill it just dropped. Those are
87
- // different colours for most hues — a bright `solid` chip carries
88
- // dark ink, which on a near-black page would be invisible.
89
- if (!error && usedColorScheme) {
90
- const outlineInk = dark
91
- ? usedColorScheme.darkOutlineText ?? usedColorScheme.darkText
92
- : usedColorScheme.outlineText;
93
- if (outlineInk) textColor = outlineInk;
94
- }
95
- bgColor = getRgba(textColor, dark ? 0.1 : 0.06);
96
- border = `1px solid ${getRgba(textColor, dark ? 0.2 : 0.14)}`;
97
- } else if (error) {
98
- bgColor = dark ? "rgba(220, 38, 38, 0.15)" : "rgba(239, 68, 68, 0.1)";
99
- border = `1px solid ${dark ? "rgba(220, 38, 38, 0.3)" : "rgba(239, 68, 68, 0.2)"}`;
100
- } else if (usedColorScheme) {
101
- bgColor = dark && usedColorScheme.darkColor ? usedColorScheme.darkColor : usedColorScheme.color;
102
- }
103
- }
104
-
105
- return (
106
- <div
107
- className={cls("rounded-lg max-w-full w-max h-fit font-medium inline-flex gap-1",
108
- "text-ellipsis",
109
- "items-center",
110
- "transition-colors duration-150",
111
- !hasScheme && "bg-surface-100 dark:bg-surface-800 text-text-secondary dark:text-text-secondary-dark border border-surface-200 dark:border-surface-700",
112
- !hasScheme && outlined && "bg-transparent dark:bg-transparent",
113
- onClick ? "cursor-pointer hover:bg-primary/5 dark:hover:bg-primary/5" : "",
114
- sizeClassNames[size],
115
- className)}
116
- onClick={onClick}
117
- style={{
118
- ...(hasScheme ? {
119
- backgroundColor: bgColor,
120
- color: textColor,
121
- border: border || undefined,
122
- } : {}),
123
- overflow: "hidden",
124
- ...style
125
- }}
126
- >
127
- {icon}
128
- {children}
129
- </div>
130
- );
131
- }
@@ -1,53 +0,0 @@
1
- import React from "react";
2
- import { cls } from "../util";
3
-
4
- export type CircularProgressProps = {
5
- size?: "smallest" | "small" | "medium" | "large",
6
- className?: string
7
- }
8
-
9
- export function CircularProgress({
10
- size = "medium",
11
- className
12
- }: CircularProgressProps) {
13
-
14
- let sizeClasses = "";
15
- if (size === "smallest") {
16
- sizeClasses = "w-4 h-4";
17
- } else if (size === "small") {
18
- sizeClasses = "w-6 h-6";
19
- } else if (size === "medium") {
20
- sizeClasses = "w-8 h-8 m-1";
21
- } else {
22
- sizeClasses = "w-10 h-10 m-1";
23
- }
24
-
25
- let borderClasses = "";
26
- if (size === "smallest") {
27
- borderClasses = "border-2";
28
- } else if (size === "small") {
29
- borderClasses = "border-2";
30
- } else if (size === "medium") {
31
- borderClasses = "border-[3px]";
32
- } else {
33
- borderClasses = "border-4";
34
- }
35
-
36
- return (
37
- <div
38
- className={cls(
39
- sizeClasses,
40
- borderClasses,
41
- "inline-block shrink-0 rounded-full border-solid align-[-0.125em]",
42
- "animate-[spin_0.7s_linear_infinite] motion-reduce:animate-[spin_1.5s_linear_infinite]",
43
- "border-surface-200 dark:border-surface-700 border-t-primary dark:border-t-primary",
44
- className)}
45
- role="status">
46
- <span
47
- className="absolute! -m-px! h-px! w-px! overflow-hidden! whitespace-nowrap! border-0! p-0! [clip:rect(0,0,0,0)]!"
48
- >
49
- Loading...
50
- </span>
51
- </div>
52
- );
53
- }
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- import { CircularProgress, CircularProgressProps } from "./CircularProgress";
3
- import { Typography } from "./Typography";
4
-
5
- /**
6
- *
7
- * @param text
8
- * @param props
9
-
10
- * @ignore
11
- */
12
- export function CircularProgressCenter({ text, ...props }: CircularProgressProps & {
13
- text?: string
14
- }) {
15
- return (
16
- <div
17
- className="flex w-full h-screen max-h-full max-w-full gap-4">
18
- <div className="m-auto flex flex-col gap-2 items-center">
19
- <CircularProgress {...props}/>
20
- {text && <Typography
21
- color={"secondary"}
22
- variant={"caption"}
23
- className="text-center">{text}</Typography>}
24
- </div>
25
- </div>
26
- );
27
- }
@@ -1,66 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import * as Collapsible from "@radix-ui/react-collapsible";
4
-
5
- import { cls } from "../util";
6
- import { useInjectStyles } from "../hooks";
7
-
8
- interface CollapseProps {
9
- children?: React.ReactNode;
10
- className?: string;
11
- in?: boolean;
12
- duration?: number;
13
- }
14
-
15
- export const Collapse = React.memo(({
16
- children,
17
- className,
18
- in: isOpen = false,
19
- duration = 220
20
- }: CollapseProps) => {
21
-
22
- useInjectStyles(`Collapse-${duration}`, `
23
- .CollapseContent-${duration} {
24
- overflow: hidden;
25
- }
26
- .CollapseContent-${duration}[data-state='open'] {
27
- animation: slideDown ${duration}ms ease-out;
28
- }
29
- .CollapseContent-${duration}[data-state='closed'] {
30
- animation: slideUp ${duration}ms ease-in;
31
- }
32
-
33
- @keyframes slideDown {
34
- from {
35
- height: 0;
36
- }
37
- to {
38
- height: var(--radix-collapsible-content-height);
39
- }
40
- }
41
-
42
- @keyframes slideUp {
43
- from {
44
- height: var(--radix-collapsible-content-height);
45
- }
46
- to {
47
- height: 0;
48
- }
49
- }
50
- `);
51
-
52
- return (
53
- <Collapsible.Root
54
- open={isOpen}
55
- className={className}>
56
-
57
- <Collapsible.Content
58
- className={cls(`CollapseContent-${duration}`)}
59
- >
60
- {children}
61
- </Collapsible.Content>
62
- </Collapsible.Root>
63
- )
64
- });
65
-
66
- Collapse.displayName = "Collapse";