aidos-ui 4.0.2 → 4.0.4
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/dist/BaseButton.js +1 -1
- package/dist/BaseButton.js.map +1 -1
- package/dist/BaseView.js +4 -4
- package/dist/BaseView.js.map +1 -1
- package/dist/Calendar.js +22 -22
- package/dist/Calendar.js.map +1 -1
- package/dist/Card.js +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/DateInput.d.ts +1 -1
- package/dist/DatePicker.js +2 -2
- package/dist/DatePicker.js.map +1 -1
- package/dist/DatetimeInput.js +2 -2
- package/dist/DatetimeInput.js.map +1 -1
- package/dist/Dialog.js +3 -3
- package/dist/Dialog.js.map +1 -1
- package/dist/Dropdown.d.ts +1 -1
- package/dist/Dropdown.js +8 -7
- package/dist/Dropdown.js.map +1 -1
- package/dist/Icon.js +9 -9
- package/dist/Icon.js.map +1 -1
- package/dist/IconButton.d.ts +2 -0
- package/dist/IconButton.js +7 -4
- package/dist/IconButton.js.map +1 -1
- package/dist/Interactable.js +10 -10
- package/dist/Interactable.js.map +1 -1
- package/dist/JSSComment.d.ts +10 -0
- package/dist/JSSComment.js +52 -0
- package/dist/JSSComment.js.map +1 -0
- package/dist/ListDivider.js +2 -2
- package/dist/ListDivider.js.map +1 -1
- package/dist/ListSpacer.js +2 -2
- package/dist/ListSpacer.js.map +1 -1
- package/dist/NextJSRouter.js +3 -3
- package/dist/NextJSRouter.js.map +1 -1
- package/dist/Popover.js +2 -2
- package/dist/Popover.js.map +1 -1
- package/dist/ProgressBar.js +3 -3
- package/dist/ProgressBar.js.map +1 -1
- package/dist/StaticCheckbox.js +2 -2
- package/dist/StaticCheckbox.js.map +1 -1
- package/dist/Storage.js +1 -3
- package/dist/Storage.js.map +1 -1
- package/dist/Tooltip.js +2 -2
- package/dist/Tooltip.js.map +1 -1
- package/dist/jss.d.ts +1 -1
- package/dist/jss.js +21 -11
- package/dist/jss.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +48 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +1 -0
- package/dist/jsx-runtime.js +3 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/vite-plugin-jss-debug.d.ts +37 -0
- package/dist/vite-plugin-jss-debug.js +76 -0
- package/dist/vite-plugin-jss-debug.js.map +1 -0
- package/jss-debug-loader.mjs +44 -0
- package/next.config.js +12 -1
- package/package.json +19 -1
- package/src/BaseButton.tsx +1 -0
- package/src/BaseView.tsx +4 -4
- package/src/Calendar.tsx +27 -29
- package/src/Card.tsx +1 -1
- package/src/DateInput.tsx +1 -1
- package/src/DatePicker.tsx +2 -2
- package/src/DatetimeInput.tsx +3 -3
- package/src/Dialog.tsx +5 -5
- package/src/Dropdown.tsx +9 -8
- package/src/Icon.tsx +9 -9
- package/src/IconButton.tsx +25 -2
- package/src/Interactable.tsx +10 -10
- package/src/JSSComment.tsx +56 -0
- package/src/ListDivider.tsx +2 -2
- package/src/ListSpacer.tsx +2 -2
- package/src/NextJSRouter.tsx +8 -10
- package/src/Popover.tsx +2 -2
- package/src/ProgressBar.tsx +3 -3
- package/src/StaticCheckbox.tsx +3 -3
- package/src/Storage.tsx +1 -3
- package/src/Tooltip.tsx +2 -2
- package/src/jss.tsx +27 -14
- package/src/jsx-dev-runtime.ts +74 -0
- package/src/jsx-runtime.ts +2 -0
- package/src/vite-plugin-jss-debug.ts +77 -0
- package/tsconfig.json +6 -0
- package/.claude/settings.local.json +0 -21
package/package.json
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aidos-ui",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "A simple UI framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./jsx-runtime": {
|
|
13
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
14
|
+
"default": "./dist/jsx-runtime.js"
|
|
15
|
+
},
|
|
16
|
+
"./jsx-dev-runtime": {
|
|
17
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
18
|
+
"default": "./dist/jsx-dev-runtime.js"
|
|
19
|
+
},
|
|
20
|
+
"./vite-plugin-jss-debug": {
|
|
21
|
+
"types": "./dist/vite-plugin-jss-debug.d.ts",
|
|
22
|
+
"default": "./dist/vite-plugin-jss-debug.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
7
25
|
"scripts": {
|
|
8
26
|
"embeddings": "node ./scripts/embeddings.js",
|
|
9
27
|
"dev": "next dev",
|
package/src/BaseButton.tsx
CHANGED
package/src/BaseView.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { JSS, toClassnames } from "./jss";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const styles: { [key: string]: JSS } = {
|
|
5
5
|
relative: {
|
|
6
6
|
position: "relative",
|
|
7
7
|
},
|
|
@@ -44,9 +44,9 @@ export const BaseView = React.forwardRef(
|
|
|
44
44
|
ref={ref}
|
|
45
45
|
className={toClassnames([
|
|
46
46
|
jss,
|
|
47
|
-
grow &&
|
|
48
|
-
shrink &&
|
|
49
|
-
relative &&
|
|
47
|
+
grow && styles.grow,
|
|
48
|
+
shrink && styles.shrink,
|
|
49
|
+
relative && styles.relative,
|
|
50
50
|
])}
|
|
51
51
|
{...otherProps}
|
|
52
52
|
>
|
package/src/Calendar.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
1
|
+
import React, { cloneElement, useMemo } from "react";
|
|
2
2
|
import { BaseView } from "./BaseView";
|
|
3
3
|
import { JSS } from "./jss";
|
|
4
4
|
|
|
@@ -78,18 +78,17 @@ export const Calendar = React.forwardRef(
|
|
|
78
78
|
index + 1 - offset
|
|
79
79
|
);
|
|
80
80
|
|
|
81
|
-
return (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
</React.Fragment>
|
|
81
|
+
return cloneElement(
|
|
82
|
+
cell({
|
|
83
|
+
date: dayDate,
|
|
84
|
+
today: false,
|
|
85
|
+
top: true,
|
|
86
|
+
left: index % 7 === 0,
|
|
87
|
+
outOfMonth: true,
|
|
88
|
+
right: false,
|
|
89
|
+
bottom: false,
|
|
90
|
+
}),
|
|
91
|
+
{ key: dayDate.toISOString() }
|
|
93
92
|
);
|
|
94
93
|
})}
|
|
95
94
|
|
|
@@ -101,22 +100,21 @@ export const Calendar = React.forwardRef(
|
|
|
101
100
|
12 // If we do not add this the ISO string would be from the day before at midnight
|
|
102
101
|
);
|
|
103
102
|
|
|
104
|
-
return (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</React.Fragment>
|
|
103
|
+
return cloneElement(
|
|
104
|
+
cell({
|
|
105
|
+
date: dayDate,
|
|
106
|
+
top: index + offset < 7,
|
|
107
|
+
left: (index + offset) % 7 === 0,
|
|
108
|
+
right:
|
|
109
|
+
(index + offset) % 7 === 7 - 1 || index === daysInMonth - 1,
|
|
110
|
+
bottom: index > daysInMonth - 7 - 1,
|
|
111
|
+
outOfMonth: false,
|
|
112
|
+
today:
|
|
113
|
+
dayDate.getDate() == new Date().getDate() &&
|
|
114
|
+
dayDate.getMonth() == new Date().getMonth() &&
|
|
115
|
+
dayDate.getFullYear() == new Date().getFullYear(),
|
|
116
|
+
}),
|
|
117
|
+
{ key: dayDate.toISOString() }
|
|
120
118
|
);
|
|
121
119
|
})}
|
|
122
120
|
</BaseView>
|
package/src/Card.tsx
CHANGED
package/src/DateInput.tsx
CHANGED
package/src/DatePicker.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useRef } from "react";
|
|
|
2
2
|
import { Text } from "./Text";
|
|
3
3
|
import { TextColor, toClassnames } from "./jss";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const styles = {
|
|
6
6
|
dateInput: {
|
|
7
7
|
border: "1px solid var(--divider)",
|
|
8
8
|
backgroundColor: "var(--primary-background)",
|
|
@@ -47,7 +47,7 @@ export function DatePicker({
|
|
|
47
47
|
<input
|
|
48
48
|
min={min}
|
|
49
49
|
max={max}
|
|
50
|
-
className={toClassnames(
|
|
50
|
+
className={toClassnames(styles.dateInput)}
|
|
51
51
|
type="date"
|
|
52
52
|
id={id}
|
|
53
53
|
value={date.toISOString().substring(0, 10)}
|
package/src/DatetimeInput.tsx
CHANGED
|
@@ -15,7 +15,7 @@ export interface DatetimeInputProps extends BaseInputProps {
|
|
|
15
15
|
jss?: JSS;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const styles = {
|
|
19
19
|
root: {
|
|
20
20
|
backgroundColor: "var(--primary-background)",
|
|
21
21
|
},
|
|
@@ -43,7 +43,7 @@ export const DatetimeInput = React.forwardRef(
|
|
|
43
43
|
ref?: React.Ref<HTMLInputElement>
|
|
44
44
|
) => {
|
|
45
45
|
return (
|
|
46
|
-
<Row jss={
|
|
46
|
+
<Row jss={styles.root}>
|
|
47
47
|
{icon && (
|
|
48
48
|
<Box padding="medium">
|
|
49
49
|
<Icon size="medium" color="secondary" icon={icon} />
|
|
@@ -55,7 +55,7 @@ export const DatetimeInput = React.forwardRef(
|
|
|
55
55
|
ref={ref}
|
|
56
56
|
value={date.toISOString().substring(0, 16)}
|
|
57
57
|
onChange={(e) => onDateChange(new Date(e.target.value))}
|
|
58
|
-
jss={[
|
|
58
|
+
jss={[styles.input, jss]}
|
|
59
59
|
/>
|
|
60
60
|
{addOn}
|
|
61
61
|
</Row>
|
package/src/Dialog.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { Row } from "./Row";
|
|
|
8
8
|
import { IconButton } from "./IconButton";
|
|
9
9
|
import { toClassnames } from "./jss";
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const styles = {
|
|
12
12
|
dialog: {
|
|
13
13
|
border: "1px solid var(--divider)",
|
|
14
14
|
borderRadius: "var(--border-radius-l)",
|
|
@@ -50,8 +50,8 @@ export const Dialog = ({
|
|
|
50
50
|
close: () => void;
|
|
51
51
|
}) => {
|
|
52
52
|
return (
|
|
53
|
-
<BaseView jss={
|
|
54
|
-
<Column jss={
|
|
53
|
+
<BaseView jss={styles.root}>
|
|
54
|
+
<Column jss={styles.header}>
|
|
55
55
|
<Row padding="medium" justify="space-between" align="center">
|
|
56
56
|
<Text size="medium" color="secondary">
|
|
57
57
|
{label}
|
|
@@ -67,7 +67,7 @@ export const Dialog = ({
|
|
|
67
67
|
</Row>
|
|
68
68
|
<ListDivider />
|
|
69
69
|
</Column>
|
|
70
|
-
<BaseView jss={
|
|
70
|
+
<BaseView jss={styles.content}>{children}</BaseView>
|
|
71
71
|
</BaseView>
|
|
72
72
|
);
|
|
73
73
|
};
|
|
@@ -113,7 +113,7 @@ export function useDialog<Input>(
|
|
|
113
113
|
dialogRef.current = ref;
|
|
114
114
|
ref && ref.showModal();
|
|
115
115
|
}}
|
|
116
|
-
className={toClassnames(
|
|
116
|
+
className={toClassnames(styles.dialog)}
|
|
117
117
|
onClose={() => {
|
|
118
118
|
closeRef.current();
|
|
119
119
|
}}
|
package/src/Dropdown.tsx
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useEffect, useId, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { BaseView } from "./BaseView";
|
|
4
|
-
import { guid } from "./guid";
|
|
5
4
|
import { Button } from "./Button";
|
|
6
5
|
import { Column } from "./Column";
|
|
7
6
|
import { useNavigation } from "./useNavigation";
|
|
8
7
|
import { useRefEffect } from "./useRefEffect";
|
|
9
8
|
import { Gap, JSS, Padding, Size, getBackground } from "./jss";
|
|
10
9
|
|
|
11
|
-
const
|
|
10
|
+
const styles: { [key: string]: JSS } = {
|
|
12
11
|
root: {
|
|
13
12
|
position: "relative",
|
|
14
13
|
display: "flex",
|
|
@@ -25,12 +24,12 @@ const jsss: { [key: string]: JSS } = {
|
|
|
25
24
|
left: 0,
|
|
26
25
|
right: 0,
|
|
27
26
|
borderRadius: "var(--border-radius-m)",
|
|
28
|
-
boxShadow: "
|
|
27
|
+
boxShadow: "var(--shadow-sm)",
|
|
29
28
|
zIndex: 1,
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
31
|
export function Dropdown<T extends string | number>({
|
|
33
|
-
id
|
|
32
|
+
id: propId,
|
|
34
33
|
label,
|
|
35
34
|
options,
|
|
36
35
|
selection,
|
|
@@ -54,6 +53,8 @@ export function Dropdown<T extends string | number>({
|
|
|
54
53
|
gap?: Gap;
|
|
55
54
|
size?: Size;
|
|
56
55
|
}) {
|
|
56
|
+
const hookId = useId();
|
|
57
|
+
const id = propId ?? hookId;
|
|
57
58
|
const triggerRef = useRef(null);
|
|
58
59
|
const [expanded, setExpanded] = useState(false);
|
|
59
60
|
const dropdownRef = useNavigation({ autofocus: true });
|
|
@@ -75,7 +76,7 @@ export function Dropdown<T extends string | number>({
|
|
|
75
76
|
}, [expanded]);
|
|
76
77
|
|
|
77
78
|
return (
|
|
78
|
-
<BaseView ref={rootRef} jss={[
|
|
79
|
+
<BaseView ref={rootRef} jss={[styles.root, jss]}>
|
|
79
80
|
<Button
|
|
80
81
|
size={size}
|
|
81
82
|
padding={padding}
|
|
@@ -86,7 +87,7 @@ export function Dropdown<T extends string | number>({
|
|
|
86
87
|
role="combobox"
|
|
87
88
|
justify="space-between"
|
|
88
89
|
tabIndex={0}
|
|
89
|
-
jss={[
|
|
90
|
+
jss={[styles.button, jssButton]}
|
|
90
91
|
color="positive"
|
|
91
92
|
icon="fa-chevron-down"
|
|
92
93
|
iconPosition="right"
|
|
@@ -100,7 +101,7 @@ export function Dropdown<T extends string | number>({
|
|
|
100
101
|
{expanded && (
|
|
101
102
|
<Column
|
|
102
103
|
gap={gap}
|
|
103
|
-
jss={[
|
|
104
|
+
jss={[styles.dropdown, getBackground("secondary-background")]}
|
|
104
105
|
id={id}
|
|
105
106
|
role="listbox"
|
|
106
107
|
aria-label={label}
|
package/src/Icon.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { BaseView } from "./BaseView";
|
|
|
4
4
|
import { IconType } from "./IconType";
|
|
5
5
|
import { Size, TextColor, getTextColor } from "./jss";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const styles = {
|
|
8
8
|
root: {
|
|
9
9
|
display: "flex",
|
|
10
10
|
justifyContent: "center",
|
|
@@ -63,14 +63,14 @@ export function Icon({
|
|
|
63
63
|
<BaseView
|
|
64
64
|
aria-label={ariaLabel}
|
|
65
65
|
jss={[
|
|
66
|
-
|
|
67
|
-
size === "xsmall" &&
|
|
68
|
-
size === "small" &&
|
|
69
|
-
size === "medium" &&
|
|
70
|
-
size === "large" &&
|
|
71
|
-
size === "xlarge" &&
|
|
72
|
-
size === "xxlarge" &&
|
|
73
|
-
size === "xxxlarge" &&
|
|
66
|
+
styles.root,
|
|
67
|
+
size === "xsmall" && styles.xsmall,
|
|
68
|
+
size === "small" && styles.small,
|
|
69
|
+
size === "medium" && styles.medium,
|
|
70
|
+
size === "large" && styles.large,
|
|
71
|
+
size === "xlarge" && styles.xlarge,
|
|
72
|
+
size === "xxlarge" && styles.xxlarge,
|
|
73
|
+
size === "xxxlarge" && styles.xxxlarge,
|
|
74
74
|
getTextColor(color),
|
|
75
75
|
]}
|
|
76
76
|
>
|
package/src/IconButton.tsx
CHANGED
|
@@ -4,28 +4,46 @@ import { Icon } from "./Icon";
|
|
|
4
4
|
import { IconType } from "./IconType";
|
|
5
5
|
import { getGlyphColor } from "./Interactable";
|
|
6
6
|
import { Size } from "./jss";
|
|
7
|
+
import { Span } from "./Text";
|
|
7
8
|
|
|
8
|
-
const sizes
|
|
9
|
+
const sizes: {
|
|
10
|
+
[key in Size]: number;
|
|
11
|
+
} = {
|
|
9
12
|
xsmall: 20,
|
|
10
13
|
small: 24,
|
|
11
14
|
medium: 32,
|
|
12
15
|
large: 40,
|
|
13
16
|
xlarge: 48,
|
|
17
|
+
xxlarge: 56,
|
|
18
|
+
xxxlarge: 64,
|
|
14
19
|
};
|
|
15
20
|
|
|
16
21
|
export interface IconButtonProps extends BaseButtonProps {
|
|
17
22
|
icon: IconType;
|
|
18
23
|
size: Size;
|
|
24
|
+
label?: string;
|
|
25
|
+
labelSize?: Size;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
export const IconButton = React.forwardRef(
|
|
22
29
|
(
|
|
23
|
-
{
|
|
30
|
+
{
|
|
31
|
+
icon,
|
|
32
|
+
size,
|
|
33
|
+
color,
|
|
34
|
+
bare,
|
|
35
|
+
disabled,
|
|
36
|
+
jss,
|
|
37
|
+
label,
|
|
38
|
+
labelSize = "medium",
|
|
39
|
+
...buttonProps
|
|
40
|
+
}: IconButtonProps,
|
|
24
41
|
ref?: React.Ref<HTMLButtonElement>
|
|
25
42
|
) => {
|
|
26
43
|
return (
|
|
27
44
|
<BaseButton
|
|
28
45
|
{...buttonProps}
|
|
46
|
+
aria-label={buttonProps["aria-label"] ?? label}
|
|
29
47
|
bare={bare}
|
|
30
48
|
jss={[
|
|
31
49
|
{
|
|
@@ -52,6 +70,11 @@ export const IconButton = React.forwardRef(
|
|
|
52
70
|
icon={icon}
|
|
53
71
|
color={getGlyphColor(color, disabled, bare)}
|
|
54
72
|
/>
|
|
73
|
+
{label && (
|
|
74
|
+
<Span size={labelSize} color={getGlyphColor(color, disabled, bare)}>
|
|
75
|
+
{label}
|
|
76
|
+
</Span>
|
|
77
|
+
)}
|
|
55
78
|
</BaseButton>
|
|
56
79
|
);
|
|
57
80
|
}
|
package/src/Interactable.tsx
CHANGED
|
@@ -7,7 +7,7 @@ export type InteractableColor =
|
|
|
7
7
|
| "dark"
|
|
8
8
|
| "light";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const styles = {
|
|
11
11
|
root: {
|
|
12
12
|
cursor: "pointer",
|
|
13
13
|
display: "inline-flex",
|
|
@@ -94,18 +94,18 @@ export function getInteractableJSS({
|
|
|
94
94
|
border: boolean;
|
|
95
95
|
}): Array<JSS> {
|
|
96
96
|
return [
|
|
97
|
-
|
|
98
|
-
color === "dark" &&
|
|
99
|
-
color === "light" &&
|
|
100
|
-
color === "positive" &&
|
|
101
|
-
color === "primary" &&
|
|
102
|
-
color === "negative" &&
|
|
97
|
+
styles.root,
|
|
98
|
+
color === "dark" && styles.dark,
|
|
99
|
+
color === "light" && styles.light,
|
|
100
|
+
color === "positive" && styles.positive,
|
|
101
|
+
color === "primary" && styles.primary,
|
|
102
|
+
color === "negative" && styles.negative,
|
|
103
103
|
border && {
|
|
104
104
|
border: `1px solid ${getCSSColor(color, disabled, bare)}`,
|
|
105
105
|
},
|
|
106
|
-
bare &&
|
|
107
|
-
disabled &&
|
|
108
|
-
!bare &&
|
|
106
|
+
bare && styles.bare,
|
|
107
|
+
disabled && styles.disabled,
|
|
108
|
+
!bare && styles.opacityHover,
|
|
109
109
|
animateInteraction &&
|
|
110
110
|
!disabled && {
|
|
111
111
|
position: "relative",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Injects a real HTML comment node (<!-- ComponentName -->) into the DOM.
|
|
5
|
+
*
|
|
6
|
+
* Renders nothing (null). Uses the React fiber tree to locate the sibling
|
|
7
|
+
* component's first DOM node, then inserts a comment before it.
|
|
8
|
+
* Client-only — no SSR output, no hydration mismatch.
|
|
9
|
+
*/
|
|
10
|
+
export function JSSComment({ name }: { name: string }) {
|
|
11
|
+
const fiberRef = useRef<any>(null);
|
|
12
|
+
|
|
13
|
+
// Capture our fiber during render
|
|
14
|
+
try {
|
|
15
|
+
const internals = (React as any)
|
|
16
|
+
.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
17
|
+
fiberRef.current = internals?.ReactCurrentOwner?.current;
|
|
18
|
+
} catch {}
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const fiber = fiberRef.current;
|
|
22
|
+
if (!fiber) return;
|
|
23
|
+
|
|
24
|
+
// Our sibling in the Fragment is the actual component
|
|
25
|
+
const sibling = fiber.sibling;
|
|
26
|
+
if (!sibling) return;
|
|
27
|
+
|
|
28
|
+
// Walk down the sibling's fiber tree to find its first DOM node
|
|
29
|
+
const hostNode = findFirstDOMNode(sibling);
|
|
30
|
+
if (!hostNode?.parentNode) return;
|
|
31
|
+
|
|
32
|
+
const comment = document.createComment(` ${name} `);
|
|
33
|
+
hostNode.parentNode.insertBefore(comment, hostNode);
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
comment.remove();
|
|
37
|
+
};
|
|
38
|
+
}, [name]);
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function findFirstDOMNode(fiber: any): Node | null {
|
|
44
|
+
let current = fiber;
|
|
45
|
+
while (current) {
|
|
46
|
+
if (current.stateNode instanceof Node) {
|
|
47
|
+
return current.stateNode;
|
|
48
|
+
}
|
|
49
|
+
if (current.child) {
|
|
50
|
+
current = current.child;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
package/src/ListDivider.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BaseView } from "./BaseView";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const styles = {
|
|
5
5
|
root: {
|
|
6
6
|
width: "100%",
|
|
7
7
|
borderBottom: "1px solid var(--divider)",
|
|
@@ -9,5 +9,5 @@ const jsss = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export function ListDivider() {
|
|
12
|
-
return <BaseView jss={
|
|
12
|
+
return <BaseView jss={styles.root} />;
|
|
13
13
|
}
|
package/src/ListSpacer.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BaseView } from "./BaseView";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const styles = {
|
|
5
5
|
root: {
|
|
6
6
|
height: "var(--spacing-xl)",
|
|
7
7
|
backgroundColor: "var(--secondary-background)",
|
|
@@ -10,5 +10,5 @@ const jsss = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export function ListSpacer() {
|
|
13
|
-
return <BaseView jss={
|
|
13
|
+
return <BaseView jss={styles.root} />;
|
|
14
14
|
}
|
package/src/NextJSRouter.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { BaseView } from "./BaseView";
|
|
|
7
7
|
import { useRouterState } from "./NextJSRouterState";
|
|
8
8
|
import { JSS } from "./jss";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const styles: { [key: string]: JSS } = {
|
|
11
11
|
root: {
|
|
12
12
|
display: "flex",
|
|
13
13
|
flexDirection: "column",
|
|
@@ -36,25 +36,23 @@ export function Router() {
|
|
|
36
36
|
} = useRouterState();
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
|
-
<BaseView jss={
|
|
39
|
+
<BaseView jss={styles.root}>
|
|
40
40
|
{navigationStack.map(({ route, routeProps }, index, list) => {
|
|
41
41
|
const isTopOfStack = index === list.length - 1;
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
|
-
<
|
|
44
|
+
<Column
|
|
45
45
|
key={route.title(routeProps)}
|
|
46
|
-
|
|
46
|
+
jss={[styles.route, !isTopOfStack && styles.hidden]}
|
|
47
|
+
aria-hidden={!isTopOfStack}
|
|
47
48
|
>
|
|
48
|
-
<
|
|
49
|
-
jss={[jsss.route, !isTopOfStack && jsss.hidden]}
|
|
50
|
-
aria-hidden={!isTopOfStack}
|
|
51
|
-
>
|
|
49
|
+
<StackContextProvider isTopOfStack={isTopOfStack}>
|
|
52
50
|
<ListDivider />
|
|
53
51
|
<Suspense fallback={null}>
|
|
54
52
|
<route.root {...routeProps} />
|
|
55
53
|
</Suspense>
|
|
56
|
-
</
|
|
57
|
-
</
|
|
54
|
+
</StackContextProvider>
|
|
55
|
+
</Column>
|
|
58
56
|
);
|
|
59
57
|
})}
|
|
60
58
|
</BaseView>
|
package/src/Popover.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseView } from "./BaseView";
|
|
|
5
5
|
import { useRefEffect } from "./useRefEffect";
|
|
6
6
|
import { JSS, toClassnames } from "./jss";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const styles: { [key: string]: JSS } = {
|
|
9
9
|
popover: {
|
|
10
10
|
padding: 0,
|
|
11
11
|
zIndex: 1,
|
|
@@ -129,7 +129,7 @@ export function PopoverTrigger<Input>({
|
|
|
129
129
|
ref={(ref: null | HTMLDialogElement) => {
|
|
130
130
|
dialogRef.current = ref;
|
|
131
131
|
}}
|
|
132
|
-
className={toClassnames([
|
|
132
|
+
className={toClassnames([styles.popover, jssDialog])}
|
|
133
133
|
onClose={() => {
|
|
134
134
|
setPopover(null);
|
|
135
135
|
}}
|
package/src/ProgressBar.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { BaseView } from "./BaseView";
|
|
3
3
|
import { Color, Size, JSS, getBackground } from "./jss";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const styles: { [key: string]: JSS } = {
|
|
6
6
|
root: {
|
|
7
7
|
width: "100%",
|
|
8
8
|
display: "flex",
|
|
@@ -45,7 +45,7 @@ export function ProgressBar({
|
|
|
45
45
|
return (
|
|
46
46
|
<BaseView
|
|
47
47
|
jss={[
|
|
48
|
-
|
|
48
|
+
styles.root,
|
|
49
49
|
{
|
|
50
50
|
height: sizes[size],
|
|
51
51
|
},
|
|
@@ -53,7 +53,7 @@ export function ProgressBar({
|
|
|
53
53
|
]}
|
|
54
54
|
>
|
|
55
55
|
<BaseView
|
|
56
|
-
jss={[
|
|
56
|
+
jss={[styles.fill, getBackground(color)]}
|
|
57
57
|
style={{
|
|
58
58
|
transform: `scaleX(${progress > 1 ? 1 : progress})`,
|
|
59
59
|
}}
|
package/src/StaticCheckbox.tsx
CHANGED
|
@@ -10,7 +10,7 @@ type StaticCheckboxProps = {
|
|
|
10
10
|
icon?: IconType;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const styles: { [key: string]: JSS } = {
|
|
14
14
|
border: {
|
|
15
15
|
position: "absolute",
|
|
16
16
|
top: "var(--spacing-xs)",
|
|
@@ -61,9 +61,9 @@ export function StaticCheckbox({
|
|
|
61
61
|
width: sizes[size],
|
|
62
62
|
}}
|
|
63
63
|
>
|
|
64
|
-
<BaseView jss={[
|
|
64
|
+
<BaseView jss={[styles.border, checked && styles.borderChecked]} />
|
|
65
65
|
{checked && (
|
|
66
|
-
<BaseView jss={
|
|
66
|
+
<BaseView jss={styles.icon}>
|
|
67
67
|
<Icon size={size} color="light" icon={icon} />
|
|
68
68
|
</BaseView>
|
|
69
69
|
)}
|
package/src/Storage.tsx
CHANGED
|
@@ -99,9 +99,7 @@ export function createStorage<State>({
|
|
|
99
99
|
useEffect(() => {
|
|
100
100
|
return subscribe((newState) => {
|
|
101
101
|
const newLocalState = selector(newState);
|
|
102
|
-
|
|
103
|
-
setLocalState(selector(newState));
|
|
104
|
-
}
|
|
102
|
+
setLocalState((prev) => (newLocalState != prev ? newLocalState : prev));
|
|
105
103
|
});
|
|
106
104
|
}, []);
|
|
107
105
|
|
package/src/Tooltip.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { useRefEffect } from "./useRefEffect";
|
|
|
5
5
|
import { Text } from "./Text";
|
|
6
6
|
import { JSS, cssVar, toClassnames } from "./jss";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const styles: { [key: string]: JSS } = {
|
|
9
9
|
tooltip: {
|
|
10
10
|
top: "-100%",
|
|
11
11
|
transform: "translateY(50%)",
|
|
@@ -67,7 +67,7 @@ export function Tooltip({ content, jss, tag, children }: TooltipProps) {
|
|
|
67
67
|
dialogRef.current = ref;
|
|
68
68
|
focusTrapRoot(ref);
|
|
69
69
|
}}
|
|
70
|
-
className={toClassnames(
|
|
70
|
+
className={toClassnames(styles.tooltip)}
|
|
71
71
|
onClose={() => {
|
|
72
72
|
setTooltip(null);
|
|
73
73
|
}}
|