@sublime-ui/library 0.1.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.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/components/AppBar/AppBar.d.ts +6 -0
- package/dist/components/AppBar/AppBar.js +55 -0
- package/dist/components/AppBar/AppBar.types.d.ts +11 -0
- package/dist/components/AppBar/AppBar.types.js +0 -0
- package/dist/components/AppBar/index.d.ts +3 -0
- package/dist/components/AppBar/index.js +4 -0
- package/dist/components/Avatar/Avatar.d.ts +7 -0
- package/dist/components/Avatar/Avatar.js +30 -0
- package/dist/components/Avatar/Avatar.types.d.ts +12 -0
- package/dist/components/Avatar/Avatar.types.js +0 -0
- package/dist/components/Avatar/index.d.ts +4 -0
- package/dist/components/Avatar/index.js +4 -0
- package/dist/components/Badge/Badge.d.ts +7 -0
- package/dist/components/Badge/Badge.js +75 -0
- package/dist/components/Badge/Badge.types.d.ts +12 -0
- package/dist/components/Badge/Badge.types.js +0 -0
- package/dist/components/Badge/index.d.ts +4 -0
- package/dist/components/Badge/index.js +4 -0
- package/dist/components/Banner/Banner.d.ts +7 -0
- package/dist/components/Banner/Banner.js +68 -0
- package/dist/components/Banner/Banner.types.d.ts +13 -0
- package/dist/components/Banner/Banner.types.js +0 -0
- package/dist/components/Banner/index.d.ts +4 -0
- package/dist/components/Banner/index.js +4 -0
- package/dist/components/BottomNav/BottomNav.d.ts +7 -0
- package/dist/components/BottomNav/BottomNav.js +9 -0
- package/dist/components/BottomNav/BottomNav.types.d.ts +10 -0
- package/dist/components/BottomNav/BottomNav.types.js +0 -0
- package/dist/components/BottomNav/index.d.ts +3 -0
- package/dist/components/BottomNav/index.js +4 -0
- package/dist/components/Button/Button.d.ts +7 -0
- package/dist/components/Button/Button.js +42 -0
- package/dist/components/Button/Button.types.d.ts +17 -0
- package/dist/components/Button/Button.types.js +0 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.js +4 -0
- package/dist/components/Card/Card.d.ts +6 -0
- package/dist/components/Card/Card.js +26 -0
- package/dist/components/Card/Card.types.d.ts +10 -0
- package/dist/components/Card/Card.types.js +0 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Card/index.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +7 -0
- package/dist/components/Checkbox/Checkbox.js +34 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +17 -0
- package/dist/components/Checkbox/Checkbox.types.js +0 -0
- package/dist/components/Checkbox/index.d.ts +4 -0
- package/dist/components/Checkbox/index.js +4 -0
- package/dist/components/Dialog/Dialog.d.ts +6 -0
- package/dist/components/Dialog/Dialog.js +51 -0
- package/dist/components/Dialog/Dialog.types.d.ts +12 -0
- package/dist/components/Dialog/Dialog.types.js +0 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.js +4 -0
- package/dist/components/Divider/Divider.d.ts +6 -0
- package/dist/components/Divider/Divider.js +19 -0
- package/dist/components/Divider/Divider.types.d.ts +7 -0
- package/dist/components/Divider/Divider.types.js +0 -0
- package/dist/components/Divider/index.d.ts +3 -0
- package/dist/components/Divider/index.js +4 -0
- package/dist/components/Drawer/Drawer.d.ts +8 -0
- package/dist/components/Drawer/Drawer.js +9 -0
- package/dist/components/Drawer/Drawer.types.d.ts +13 -0
- package/dist/components/Drawer/Drawer.types.js +0 -0
- package/dist/components/Drawer/index.d.ts +4 -0
- package/dist/components/Drawer/index.js +4 -0
- package/dist/components/Fab/Fab.d.ts +7 -0
- package/dist/components/Fab/Fab.js +33 -0
- package/dist/components/Fab/Fab.types.d.ts +11 -0
- package/dist/components/Fab/Fab.types.js +0 -0
- package/dist/components/Fab/index.d.ts +4 -0
- package/dist/components/Fab/index.js +4 -0
- package/dist/components/GlassAppBar/GlassAppBar.d.ts +6 -0
- package/dist/components/GlassAppBar/GlassAppBar.js +57 -0
- package/dist/components/GlassAppBar/GlassAppBar.types.d.ts +12 -0
- package/dist/components/GlassAppBar/GlassAppBar.types.js +0 -0
- package/dist/components/GlassAppBar/index.d.ts +3 -0
- package/dist/components/GlassAppBar/index.js +4 -0
- package/dist/components/Icon/Icon.d.ts +8 -0
- package/dist/components/Icon/Icon.js +46 -0
- package/dist/components/Icon/Icon.types.d.ts +14 -0
- package/dist/components/Icon/Icon.types.js +0 -0
- package/dist/components/Icon/index.d.ts +5 -0
- package/dist/components/Icon/index.js +4 -0
- package/dist/components/Input/Input.d.ts +6 -0
- package/dist/components/Input/Input.js +43 -0
- package/dist/components/Input/Input.types.d.ts +13 -0
- package/dist/components/Input/Input.types.js +0 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.js +4 -0
- package/dist/components/Select/Select.d.ts +6 -0
- package/dist/components/Select/Select.js +50 -0
- package/dist/components/Select/Select.types.d.ts +15 -0
- package/dist/components/Select/Select.types.js +0 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/Select/index.js +4 -0
- package/dist/components/Spinner/Spinner.d.ts +7 -0
- package/dist/components/Spinner/Spinner.js +35 -0
- package/dist/components/Spinner/Spinner.types.d.ts +9 -0
- package/dist/components/Spinner/Spinner.types.js +0 -0
- package/dist/components/Spinner/index.d.ts +4 -0
- package/dist/components/Spinner/index.js +4 -0
- package/dist/components/Surface/Surface.d.ts +6 -0
- package/dist/components/Surface/Surface.js +29 -0
- package/dist/components/Surface/Surface.types.d.ts +11 -0
- package/dist/components/Surface/Surface.types.js +0 -0
- package/dist/components/Surface/index.d.ts +3 -0
- package/dist/components/Surface/index.js +4 -0
- package/dist/components/Switch/Switch.d.ts +7 -0
- package/dist/components/Switch/Switch.js +34 -0
- package/dist/components/Switch/Switch.types.d.ts +17 -0
- package/dist/components/Switch/Switch.types.js +0 -0
- package/dist/components/Switch/index.d.ts +4 -0
- package/dist/components/Switch/index.js +4 -0
- package/dist/components/Text/Text.d.ts +7 -0
- package/dist/components/Text/Text.js +34 -0
- package/dist/components/Text/Text.types.d.ts +13 -0
- package/dist/components/Text/Text.types.js +0 -0
- package/dist/components/Text/index.d.ts +4 -0
- package/dist/components/Text/index.js +4 -0
- package/dist/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/components/Tooltip/Tooltip.js +8 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +11 -0
- package/dist/components/Tooltip/Tooltip.types.js +0 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/index.js +4 -0
- package/dist/components/common.d.ts +11 -0
- package/dist/components/common.js +0 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +54 -0
- package/dist/notifications/NotificationContext.d.ts +33 -0
- package/dist/notifications/NotificationContext.js +34 -0
- package/dist/notifications/NotificationHost.d.ts +5 -0
- package/dist/notifications/NotificationHost.js +22 -0
- package/dist/notifications/useNotify.d.ts +13 -0
- package/dist/notifications/useNotify.js +19 -0
- package/dist/provider/SublimeProvider.d.ts +12 -0
- package/dist/provider/SublimeProvider.js +23 -0
- package/dist/provider/TokenContext.d.ts +14 -0
- package/dist/provider/TokenContext.js +5 -0
- package/dist/provider/resolveTokens.d.ts +7 -0
- package/dist/provider/resolveTokens.js +13 -0
- package/dist/provider/useTokens.d.ts +7 -0
- package/dist/provider/useTokens.js +12 -0
- package/dist/tokens/generateThemes.d.ts +10 -0
- package/dist/tokens/generateThemes.js +44 -0
- package/dist/tokens/tokens.d.ts +74 -0
- package/dist/tokens/tokens.js +78 -0
- package/package.json +53 -0
- package/src/components/AppBar/AppBar.native.tsx +28 -0
- package/src/components/AppBar/AppBar.tsx +51 -0
- package/src/components/AppBar/AppBar.types.ts +9 -0
- package/src/components/AppBar/index.ts +2 -0
- package/src/components/Avatar/Avatar.native.tsx +38 -0
- package/src/components/Avatar/Avatar.tsx +38 -0
- package/src/components/Avatar/Avatar.types.ts +10 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Badge/Badge.native.tsx +97 -0
- package/src/components/Badge/Badge.tsx +89 -0
- package/src/components/Badge/Badge.types.ts +11 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Banner/Banner.native.tsx +89 -0
- package/src/components/Banner/Banner.tsx +78 -0
- package/src/components/Banner/Banner.types.ts +11 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/BottomNav/BottomNav.native.tsx +87 -0
- package/src/components/BottomNav/BottomNav.tsx +9 -0
- package/src/components/BottomNav/BottomNav.types.ts +8 -0
- package/src/components/BottomNav/index.ts +2 -0
- package/src/components/Button/Button.native.tsx +27 -0
- package/src/components/Button/Button.tsx +37 -0
- package/src/components/Button/Button.types.ts +17 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Card/Card.native.tsx +24 -0
- package/src/components/Card/Card.tsx +30 -0
- package/src/components/Card/Card.types.ts +8 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.native.tsx +58 -0
- package/src/components/Checkbox/Checkbox.tsx +35 -0
- package/src/components/Checkbox/Checkbox.types.ts +15 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Dialog/Dialog.native.tsx +28 -0
- package/src/components/Dialog/Dialog.tsx +49 -0
- package/src/components/Dialog/Dialog.types.ts +10 -0
- package/src/components/Dialog/index.ts +2 -0
- package/src/components/Divider/Divider.native.tsx +30 -0
- package/src/components/Divider/Divider.tsx +16 -0
- package/src/components/Divider/Divider.types.ts +5 -0
- package/src/components/Divider/index.ts +2 -0
- package/src/components/Drawer/Drawer.native.tsx +113 -0
- package/src/components/Drawer/Drawer.tsx +9 -0
- package/src/components/Drawer/Drawer.types.ts +11 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Fab/Fab.native.tsx +41 -0
- package/src/components/Fab/Fab.tsx +36 -0
- package/src/components/Fab/Fab.types.ts +9 -0
- package/src/components/Fab/index.ts +2 -0
- package/src/components/GlassAppBar/GlassAppBar.native.tsx +29 -0
- package/src/components/GlassAppBar/GlassAppBar.tsx +53 -0
- package/src/components/GlassAppBar/GlassAppBar.types.ts +10 -0
- package/src/components/GlassAppBar/index.ts +2 -0
- package/src/components/Icon/Icon.native.tsx +39 -0
- package/src/components/Icon/Icon.tsx +57 -0
- package/src/components/Icon/Icon.types.ts +13 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.native.tsx +34 -0
- package/src/components/Input/Input.tsx +33 -0
- package/src/components/Input/Input.types.ts +11 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Select/Select.native.tsx +63 -0
- package/src/components/Select/Select.tsx +48 -0
- package/src/components/Select/Select.types.ts +14 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Spinner/Spinner.native.tsx +38 -0
- package/src/components/Spinner/Spinner.tsx +37 -0
- package/src/components/Spinner/Spinner.types.ts +7 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Surface/Surface.native.tsx +32 -0
- package/src/components/Surface/Surface.tsx +31 -0
- package/src/components/Surface/Surface.types.ts +10 -0
- package/src/components/Surface/index.ts +2 -0
- package/src/components/Switch/Switch.native.tsx +58 -0
- package/src/components/Switch/Switch.tsx +35 -0
- package/src/components/Switch/Switch.types.ts +15 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Text/Text.native.tsx +31 -0
- package/src/components/Text/Text.tsx +34 -0
- package/src/components/Text/Text.types.ts +12 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.native.tsx +6 -0
- package/src/components/Tooltip/Tooltip.tsx +10 -0
- package/src/components/Tooltip/Tooltip.types.ts +9 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/common.ts +10 -0
- package/src/index.ts +33 -0
- package/src/notifications/NotificationContext.tsx +57 -0
- package/src/notifications/NotificationHost.native.tsx +20 -0
- package/src/notifications/NotificationHost.tsx +27 -0
- package/src/notifications/useNotify.ts +18 -0
- package/src/provider/SublimeProvider.native.tsx +29 -0
- package/src/provider/SublimeProvider.tsx +30 -0
- package/src/provider/TokenContext.ts +13 -0
- package/src/provider/resolveTokens.ts +16 -0
- package/src/provider/useTokens.ts +10 -0
- package/src/test-utils/renderWeb.tsx +8 -0
- package/src/tokens/generateThemes.ts +49 -0
- package/src/tokens/tokens.ts +71 -0
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CircularProgress } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const sizePx = (size) => size === "sm" ? 16 : size === "lg" ? 40 : 24;
|
|
5
|
+
const toneColor = (c, tone) => {
|
|
6
|
+
switch (tone) {
|
|
7
|
+
case "primary":
|
|
8
|
+
return c.primary;
|
|
9
|
+
case "success":
|
|
10
|
+
return c.success;
|
|
11
|
+
case "danger":
|
|
12
|
+
return c.danger;
|
|
13
|
+
case "warning":
|
|
14
|
+
return c.warning;
|
|
15
|
+
case "info":
|
|
16
|
+
return c.info;
|
|
17
|
+
case "neutral":
|
|
18
|
+
default:
|
|
19
|
+
return c.mutedFg;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function Spinner({ size = "md", tone = "primary", testID }) {
|
|
23
|
+
const tokens = useTokens();
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
CircularProgress,
|
|
26
|
+
{
|
|
27
|
+
size: sizePx(size),
|
|
28
|
+
"data-testid": testID,
|
|
29
|
+
sx: { color: toneColor(tokens.color, tone) }
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
Spinner
|
|
35
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const boxShadow = (e, shadows) => e === "none" ? "none" : shadows[e];
|
|
5
|
+
function Surface({
|
|
6
|
+
children,
|
|
7
|
+
elevation = "sm",
|
|
8
|
+
padded = true,
|
|
9
|
+
testID
|
|
10
|
+
}) {
|
|
11
|
+
const tokens = useTokens();
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Box,
|
|
14
|
+
{
|
|
15
|
+
"data-testid": testID,
|
|
16
|
+
sx: {
|
|
17
|
+
backgroundColor: tokens.color.surface,
|
|
18
|
+
border: `1px solid ${tokens.color.surfaceBorder}`,
|
|
19
|
+
borderRadius: `${tokens.radii.lg}px`,
|
|
20
|
+
boxShadow: boxShadow(elevation, tokens.shadows),
|
|
21
|
+
padding: padded ? `${tokens.spacing.lg}px` : 0
|
|
22
|
+
},
|
|
23
|
+
children
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Surface
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type SurfaceElevation = 'none' | 'sm' | 'md' | 'lg';
|
|
4
|
+
interface SurfaceProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
elevation?: SurfaceElevation;
|
|
7
|
+
padded?: boolean;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { SurfaceElevation, SurfaceProps };
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as MuiSwitch, FormControlLabel } from "@mui/material";
|
|
3
|
+
const muiColor = (t) => t === "danger" ? "error" : t === "neutral" ? "default" : t;
|
|
4
|
+
function Switch({
|
|
5
|
+
value,
|
|
6
|
+
onValueChange,
|
|
7
|
+
label,
|
|
8
|
+
disabled,
|
|
9
|
+
tone = "primary",
|
|
10
|
+
testID
|
|
11
|
+
}) {
|
|
12
|
+
const control = /* @__PURE__ */ jsx(
|
|
13
|
+
MuiSwitch,
|
|
14
|
+
{
|
|
15
|
+
checked: value,
|
|
16
|
+
onChange: (e) => onValueChange(e.target.checked),
|
|
17
|
+
color: muiColor(tone),
|
|
18
|
+
"data-testid": testID,
|
|
19
|
+
...disabled === void 0 ? {} : { disabled }
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
if (label === void 0) return control;
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
FormControlLabel,
|
|
25
|
+
{
|
|
26
|
+
control,
|
|
27
|
+
label,
|
|
28
|
+
...disabled === void 0 ? {} : { disabled }
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
Switch
|
|
34
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Tone } from '../common.js';
|
|
2
|
+
|
|
3
|
+
interface SwitchProps {
|
|
4
|
+
/** Whether the switch is on. */
|
|
5
|
+
value: boolean;
|
|
6
|
+
/** Called with the new value when toggled. */
|
|
7
|
+
onValueChange: (value: boolean) => void;
|
|
8
|
+
/** Optional label rendered beside the switch. */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Disables interaction. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Color tone applied to the on state. */
|
|
13
|
+
tone?: Tone;
|
|
14
|
+
testID?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { SwitchProps };
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const muiVariant = (v) => v === "title" ? "h6" : v === "subtitle" ? "subtitle1" : v === "caption" ? "caption" : "body1";
|
|
5
|
+
function Text({
|
|
6
|
+
children,
|
|
7
|
+
variant = "body",
|
|
8
|
+
numberOfLines,
|
|
9
|
+
testID
|
|
10
|
+
}) {
|
|
11
|
+
const tokens = useTokens();
|
|
12
|
+
const muted = variant === "caption" || variant === "subtitle";
|
|
13
|
+
const clamp = numberOfLines !== void 0 ? {
|
|
14
|
+
display: "-webkit-box",
|
|
15
|
+
WebkitLineClamp: numberOfLines,
|
|
16
|
+
WebkitBoxOrient: "vertical",
|
|
17
|
+
overflow: "hidden"
|
|
18
|
+
} : {};
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
Typography,
|
|
21
|
+
{
|
|
22
|
+
variant: muiVariant(variant),
|
|
23
|
+
"data-testid": testID,
|
|
24
|
+
sx: {
|
|
25
|
+
color: muted ? tokens.color.mutedFg : tokens.color.foreground,
|
|
26
|
+
...clamp
|
|
27
|
+
},
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
Text
|
|
34
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Tone } from '../common.js';
|
|
3
|
+
|
|
4
|
+
type TextVariant = 'title' | 'subtitle' | 'body' | 'caption';
|
|
5
|
+
interface TextProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
variant?: TextVariant;
|
|
8
|
+
tone?: Tone;
|
|
9
|
+
numberOfLines?: number;
|
|
10
|
+
testID?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type { TextProps, TextVariant };
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as MuiTooltip } from "@mui/material";
|
|
3
|
+
function Tooltip({ label, children, testID }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(MuiTooltip, { title: label, "data-testid": testID, children });
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
Tooltip
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
/** The tooltip text shown on hover/long-press. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The single element the tooltip wraps. */
|
|
7
|
+
children: ReactElement;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { TooltipProps };
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Variant = 'solid' | 'soft' | 'outline' | 'ghost';
|
|
2
|
+
type Tone = 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'neutral';
|
|
3
|
+
type Size = 'sm' | 'md' | 'lg';
|
|
4
|
+
interface NavItem {
|
|
5
|
+
key: string;
|
|
6
|
+
label: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
badge?: string | number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type { NavItem, Size, Tone, Variant };
|
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export { SublimeProvider, SublimeProviderProps } from './provider/SublimeProvider.js';
|
|
2
|
+
export { useTokens } from './provider/useTokens.js';
|
|
3
|
+
export { generateThemes } from './tokens/generateThemes.js';
|
|
4
|
+
export { ColorTokens, SublimeTokens, defaultTokens } from './tokens/tokens.js';
|
|
5
|
+
export { useNotify } from './notifications/useNotify.js';
|
|
6
|
+
export { Button } from './components/Button/Button.js';
|
|
7
|
+
export { ButtonProps } from './components/Button/Button.types.js';
|
|
8
|
+
export { Text } from './components/Text/Text.js';
|
|
9
|
+
export { NavItem } from './components/common.js';
|
|
10
|
+
export { Input } from './components/Input/Input.js';
|
|
11
|
+
export { Card } from './components/Card/Card.js';
|
|
12
|
+
export { Badge } from './components/Badge/Badge.js';
|
|
13
|
+
export { Icon } from './components/Icon/Icon.js';
|
|
14
|
+
export { Surface } from './components/Surface/Surface.js';
|
|
15
|
+
export { Divider } from './components/Divider/Divider.js';
|
|
16
|
+
export { Spinner } from './components/Spinner/Spinner.js';
|
|
17
|
+
export { Dialog } from './components/Dialog/Dialog.js';
|
|
18
|
+
export { Banner } from './components/Banner/Banner.js';
|
|
19
|
+
export { Fab } from './components/Fab/Fab.js';
|
|
20
|
+
export { AppBar } from './components/AppBar/AppBar.js';
|
|
21
|
+
export { Select } from './components/Select/Select.js';
|
|
22
|
+
export { Avatar } from './components/Avatar/Avatar.js';
|
|
23
|
+
export { Tooltip } from './components/Tooltip/Tooltip.js';
|
|
24
|
+
export { Checkbox } from './components/Checkbox/Checkbox.js';
|
|
25
|
+
export { Switch } from './components/Switch/Switch.js';
|
|
26
|
+
export { GlassAppBar } from './components/GlassAppBar/GlassAppBar.js';
|
|
27
|
+
export { BottomNav } from './components/BottomNav/BottomNav.js';
|
|
28
|
+
export { Drawer } from './components/Drawer/Drawer.js';
|
|
29
|
+
import 'react';
|
|
30
|
+
import './provider/TokenContext.js';
|
|
31
|
+
import 'react-native-paper';
|
|
32
|
+
import '@mui/material';
|
|
33
|
+
import './notifications/NotificationContext.js';
|
|
34
|
+
import './components/Text/Text.types.js';
|
|
35
|
+
import './components/Input/Input.types.js';
|
|
36
|
+
import './components/Card/Card.types.js';
|
|
37
|
+
import './components/Badge/Badge.types.js';
|
|
38
|
+
import './components/Icon/Icon.types.js';
|
|
39
|
+
import './components/Surface/Surface.types.js';
|
|
40
|
+
import './components/Divider/Divider.types.js';
|
|
41
|
+
import './components/Spinner/Spinner.types.js';
|
|
42
|
+
import './components/Dialog/Dialog.types.js';
|
|
43
|
+
import './components/Banner/Banner.types.js';
|
|
44
|
+
import './components/Fab/Fab.types.js';
|
|
45
|
+
import './components/AppBar/AppBar.types.js';
|
|
46
|
+
import './components/Select/Select.types.js';
|
|
47
|
+
import './components/Avatar/Avatar.types.js';
|
|
48
|
+
import './components/Tooltip/Tooltip.types.js';
|
|
49
|
+
import './components/Checkbox/Checkbox.types.js';
|
|
50
|
+
import './components/Switch/Switch.types.js';
|
|
51
|
+
import './components/GlassAppBar/GlassAppBar.types.js';
|
|
52
|
+
import './components/BottomNav/BottomNav.types.js';
|
|
53
|
+
import './components/Drawer/Drawer.types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SublimeProvider } from "./provider/SublimeProvider.js";
|
|
2
|
+
import { useTokens } from "./provider/useTokens.js";
|
|
3
|
+
import { generateThemes } from "./tokens/generateThemes.js";
|
|
4
|
+
import { defaultTokens } from "./tokens/tokens.js";
|
|
5
|
+
import { useNotify } from "./notifications/useNotify.js";
|
|
6
|
+
import { Button } from "./components/Button/index.js";
|
|
7
|
+
import { Text } from "./components/Text/index.js";
|
|
8
|
+
import { Input } from "./components/Input/index.js";
|
|
9
|
+
import { Card } from "./components/Card/index.js";
|
|
10
|
+
import { Badge } from "./components/Badge/index.js";
|
|
11
|
+
import { Icon } from "./components/Icon/index.js";
|
|
12
|
+
import { Surface } from "./components/Surface/index.js";
|
|
13
|
+
import { Divider } from "./components/Divider/index.js";
|
|
14
|
+
import { Spinner } from "./components/Spinner/index.js";
|
|
15
|
+
import { Dialog } from "./components/Dialog/index.js";
|
|
16
|
+
import { Banner } from "./components/Banner/index.js";
|
|
17
|
+
import { Fab } from "./components/Fab/index.js";
|
|
18
|
+
import { AppBar } from "./components/AppBar/index.js";
|
|
19
|
+
import { Select } from "./components/Select/index.js";
|
|
20
|
+
import { Avatar } from "./components/Avatar/index.js";
|
|
21
|
+
import { Tooltip } from "./components/Tooltip/index.js";
|
|
22
|
+
import { Checkbox } from "./components/Checkbox/index.js";
|
|
23
|
+
import { Switch } from "./components/Switch/index.js";
|
|
24
|
+
import { GlassAppBar } from "./components/GlassAppBar/index.js";
|
|
25
|
+
import { BottomNav } from "./components/BottomNav/index.js";
|
|
26
|
+
import { Drawer } from "./components/Drawer/index.js";
|
|
27
|
+
export {
|
|
28
|
+
AppBar,
|
|
29
|
+
Avatar,
|
|
30
|
+
Badge,
|
|
31
|
+
Banner,
|
|
32
|
+
BottomNav,
|
|
33
|
+
Button,
|
|
34
|
+
Card,
|
|
35
|
+
Checkbox,
|
|
36
|
+
Dialog,
|
|
37
|
+
Divider,
|
|
38
|
+
Drawer,
|
|
39
|
+
Fab,
|
|
40
|
+
GlassAppBar,
|
|
41
|
+
Icon,
|
|
42
|
+
Input,
|
|
43
|
+
Select,
|
|
44
|
+
Spinner,
|
|
45
|
+
SublimeProvider,
|
|
46
|
+
Surface,
|
|
47
|
+
Switch,
|
|
48
|
+
Text,
|
|
49
|
+
Tooltip,
|
|
50
|
+
defaultTokens,
|
|
51
|
+
generateThemes,
|
|
52
|
+
useNotify,
|
|
53
|
+
useTokens
|
|
54
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type Tone = 'success' | 'error' | 'warning' | 'info' | 'neutral';
|
|
5
|
+
interface Notification {
|
|
6
|
+
id: string;
|
|
7
|
+
message: string;
|
|
8
|
+
tone: Tone;
|
|
9
|
+
duration: number;
|
|
10
|
+
action?: {
|
|
11
|
+
label: string;
|
|
12
|
+
onPress: () => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface NotifyOptions {
|
|
16
|
+
tone?: Tone;
|
|
17
|
+
duration?: number;
|
|
18
|
+
action?: {
|
|
19
|
+
label: string;
|
|
20
|
+
onPress: () => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface QueueApi {
|
|
24
|
+
queue: Notification[];
|
|
25
|
+
notify: (message: string, opts?: NotifyOptions) => string;
|
|
26
|
+
dismiss: (id: string) => void;
|
|
27
|
+
}
|
|
28
|
+
declare function NotificationProvider({ children }: {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): react.JSX.Element;
|
|
31
|
+
declare function useNotificationQueue(): QueueApi;
|
|
32
|
+
|
|
33
|
+
export { type Notification, NotificationProvider, type NotifyOptions, type Tone, useNotificationQueue };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
3
|
+
const Ctx = createContext(null);
|
|
4
|
+
function NotificationProvider({ children }) {
|
|
5
|
+
const [queue, setQueue] = useState([]);
|
|
6
|
+
const counter = useRef(0);
|
|
7
|
+
const dismiss = useCallback((id) => {
|
|
8
|
+
setQueue((q) => q.filter((n) => n.id !== id));
|
|
9
|
+
}, []);
|
|
10
|
+
const notify = useCallback((message, opts = {}) => {
|
|
11
|
+
counter.current += 1;
|
|
12
|
+
const id = `n${counter.current}`;
|
|
13
|
+
const n = {
|
|
14
|
+
id,
|
|
15
|
+
message,
|
|
16
|
+
tone: opts.tone ?? "neutral",
|
|
17
|
+
duration: opts.duration ?? 4e3,
|
|
18
|
+
...opts.action ? { action: opts.action } : {}
|
|
19
|
+
};
|
|
20
|
+
setQueue((q) => [...q, n]);
|
|
21
|
+
return id;
|
|
22
|
+
}, []);
|
|
23
|
+
const value = useMemo(() => ({ queue, notify, dismiss }), [queue, notify, dismiss]);
|
|
24
|
+
return /* @__PURE__ */ jsx(Ctx.Provider, { value, children });
|
|
25
|
+
}
|
|
26
|
+
function useNotificationQueue() {
|
|
27
|
+
const api = useContext(Ctx);
|
|
28
|
+
if (api === null) throw new Error("Notifications require a <SublimeProvider>.");
|
|
29
|
+
return api;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
NotificationProvider,
|
|
33
|
+
useNotificationQueue
|
|
34
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Snackbar, Alert } from "@mui/material";
|
|
3
|
+
import { useNotificationQueue } from "./NotificationContext.js";
|
|
4
|
+
const severityOf = (tone) => tone === "neutral" ? "info" : tone;
|
|
5
|
+
function NotificationHost() {
|
|
6
|
+
const { queue, dismiss } = useNotificationQueue();
|
|
7
|
+
return /* @__PURE__ */ jsx(Fragment, { children: queue.map((n, i) => /* @__PURE__ */ jsx(
|
|
8
|
+
Snackbar,
|
|
9
|
+
{
|
|
10
|
+
open: true,
|
|
11
|
+
autoHideDuration: n.duration,
|
|
12
|
+
onClose: () => dismiss(n.id),
|
|
13
|
+
anchorOrigin: { vertical: "bottom", horizontal: "center" },
|
|
14
|
+
style: { bottom: 16 + i * 64 },
|
|
15
|
+
children: /* @__PURE__ */ jsx(Alert, { severity: severityOf(n.tone), onClose: () => dismiss(n.id), variant: "filled", children: n.message })
|
|
16
|
+
},
|
|
17
|
+
n.id
|
|
18
|
+
)) });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
NotificationHost
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NotifyOptions } from './NotificationContext.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
declare function useNotify(): {
|
|
5
|
+
notify: (message: string, opts?: NotifyOptions) => string;
|
|
6
|
+
dismiss: (id: string) => void;
|
|
7
|
+
success: (message: string, opts?: NotifyOptions) => string;
|
|
8
|
+
error: (message: string, opts?: NotifyOptions) => string;
|
|
9
|
+
warning: (message: string, opts?: NotifyOptions) => string;
|
|
10
|
+
info: (message: string, opts?: NotifyOptions) => string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { useNotify };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useNotificationQueue } from "./NotificationContext.js";
|
|
3
|
+
function useNotify() {
|
|
4
|
+
const { notify, dismiss } = useNotificationQueue();
|
|
5
|
+
return useMemo(() => {
|
|
6
|
+
const toned = (tone) => (message, opts) => notify(message, { ...opts, tone });
|
|
7
|
+
return {
|
|
8
|
+
notify,
|
|
9
|
+
dismiss,
|
|
10
|
+
success: toned("success"),
|
|
11
|
+
error: toned("error"),
|
|
12
|
+
warning: toned("warning"),
|
|
13
|
+
info: toned("info")
|
|
14
|
+
};
|
|
15
|
+
}, [notify, dismiss]);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useNotify
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SublimeTokens } from '../tokens/tokens.js';
|
|
4
|
+
|
|
5
|
+
interface SublimeProviderProps {
|
|
6
|
+
mode?: 'light' | 'dark';
|
|
7
|
+
tokens?: SublimeTokens;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare function SublimeProvider({ mode, tokens, children }: SublimeProviderProps): react.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { SublimeProvider, type SublimeProviderProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { ThemeProvider, CssBaseline } from "@mui/material";
|
|
4
|
+
import { generateThemes } from "../tokens/generateThemes.js";
|
|
5
|
+
import { defaultTokens } from "../tokens/tokens.js";
|
|
6
|
+
import { TokenContext } from "./TokenContext.js";
|
|
7
|
+
import { resolveTokens } from "./resolveTokens.js";
|
|
8
|
+
import { NotificationProvider } from "../notifications/NotificationContext.js";
|
|
9
|
+
import { NotificationHost } from "../notifications/NotificationHost.js";
|
|
10
|
+
function SublimeProvider({ mode = "light", tokens = defaultTokens, children }) {
|
|
11
|
+
const { muiTheme } = useMemo(() => generateThemes(tokens, mode), [tokens, mode]);
|
|
12
|
+
const resolved = useMemo(() => resolveTokens(tokens, mode), [tokens, mode]);
|
|
13
|
+
return /* @__PURE__ */ jsxs(ThemeProvider, { theme: muiTheme, children: [
|
|
14
|
+
/* @__PURE__ */ jsx(CssBaseline, {}),
|
|
15
|
+
/* @__PURE__ */ jsx(TokenContext.Provider, { value: resolved, children: /* @__PURE__ */ jsxs(NotificationProvider, { children: [
|
|
16
|
+
children,
|
|
17
|
+
/* @__PURE__ */ jsx(NotificationHost, {})
|
|
18
|
+
] }) })
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
SublimeProvider
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ColorTokens, SublimeTokens } from '../tokens/tokens.js';
|
|
3
|
+
|
|
4
|
+
interface ResolvedTokens {
|
|
5
|
+
color: ColorTokens;
|
|
6
|
+
radii: SublimeTokens['radii'];
|
|
7
|
+
shadows: SublimeTokens['shadows'];
|
|
8
|
+
spacing: SublimeTokens['spacing'];
|
|
9
|
+
typography: SublimeTokens['typography'];
|
|
10
|
+
mode: 'light' | 'dark';
|
|
11
|
+
}
|
|
12
|
+
declare const TokenContext: react.Context<ResolvedTokens | null>;
|
|
13
|
+
|
|
14
|
+
export { type ResolvedTokens, TokenContext };
|