aidos-ui 4.0.3 → 4.0.5
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 +1 -1
- package/README.md +23 -3
- package/dist/index.d.ts +797 -68
- package/dist/index.js +3868 -68
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +6 -2
- package/dist/jsx-dev-runtime.js +87 -42
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +2 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/vite-plugin-jss-debug.d.ts +12 -6
- package/dist/vite-plugin-jss-debug.js +57 -72
- package/dist/vite-plugin-jss-debug.js.map +1 -1
- package/package.json +58 -27
- package/.claude/settings.local.json +0 -22
- package/.prettierrc +0 -4
- package/CLAUDE.md +0 -72
- package/dist/Badge.d.ts +0 -6
- package/dist/Badge.js +0 -22
- package/dist/Badge.js.map +0 -1
- package/dist/BaseButton.d.ts +0 -14
- package/dist/BaseButton.js +0 -23
- package/dist/BaseButton.js.map +0 -1
- package/dist/BaseInput.d.ts +0 -14
- package/dist/BaseInput.js +0 -15
- package/dist/BaseInput.js.map +0 -1
- package/dist/BaseLink.d.ts +0 -18
- package/dist/BaseLink.js +0 -29
- package/dist/BaseLink.js.map +0 -1
- package/dist/BaseList.d.ts +0 -6
- package/dist/BaseList.js +0 -14
- package/dist/BaseList.js.map +0 -1
- package/dist/BaseListAddOn.d.ts +0 -5
- package/dist/BaseListAddOn.js +0 -7
- package/dist/BaseListAddOn.js.map +0 -1
- package/dist/BaseListItem.d.ts +0 -26
- package/dist/BaseListItem.js +0 -29
- package/dist/BaseListItem.js.map +0 -1
- package/dist/BaseView.d.ts +0 -12
- package/dist/BaseView.js +0 -26
- package/dist/BaseView.js.map +0 -1
- package/dist/Box.d.ts +0 -4
- package/dist/Box.js +0 -6
- package/dist/Box.js.map +0 -1
- package/dist/Button.d.ts +0 -20
- package/dist/Button.js +0 -19
- package/dist/Button.js.map +0 -1
- package/dist/Calendar.d.ts +0 -18
- package/dist/Calendar.js +0 -57
- package/dist/Calendar.js.map +0 -1
- package/dist/Card.d.ts +0 -4
- package/dist/Card.js +0 -14
- package/dist/Card.js.map +0 -1
- package/dist/Checkbox.d.ts +0 -11
- package/dist/Checkbox.js +0 -32
- package/dist/Checkbox.js.map +0 -1
- package/dist/Circle.d.ts +0 -5
- package/dist/Circle.js +0 -12
- package/dist/Circle.js.map +0 -1
- package/dist/Column.d.ts +0 -6
- package/dist/Column.js +0 -7
- package/dist/Column.js.map +0 -1
- package/dist/DarkMode.d.ts +0 -13
- package/dist/DarkMode.js +0 -62
- package/dist/DarkMode.js.map +0 -1
- package/dist/DateInput.d.ts +0 -13
- package/dist/DateInput.js +0 -29
- package/dist/DateInput.js.map +0 -1
- package/dist/DatePicker.d.ts +0 -11
- package/dist/DatePicker.js +0 -34
- package/dist/DatePicker.js.map +0 -1
- package/dist/DatetimeInput.d.ts +0 -13
- package/dist/DatetimeInput.js +0 -31
- package/dist/DatetimeInput.js.map +0 -1
- package/dist/DesignBook.d.ts +0 -1
- package/dist/DesignBook.js +0 -55
- package/dist/DesignBook.js.map +0 -1
- package/dist/Dialog.d.ts +0 -17
- package/dist/Dialog.js +0 -92
- package/dist/Dialog.js.map +0 -1
- package/dist/Dropdown.d.ts +0 -14
- package/dist/Dropdown.js +0 -65
- package/dist/Dropdown.js.map +0 -1
- package/dist/Emitter.d.ts +0 -6
- package/dist/Emitter.js +0 -19
- package/dist/Emitter.js.map +0 -1
- package/dist/FlexLayout.d.ts +0 -11
- package/dist/FlexLayout.js +0 -18
- package/dist/FlexLayout.js.map +0 -1
- package/dist/Icon.d.ts +0 -12
- package/dist/Icon.js +0 -60
- package/dist/Icon.js.map +0 -1
- package/dist/IconButton.d.ts +0 -9
- package/dist/IconButton.js +0 -31
- package/dist/IconButton.js.map +0 -1
- package/dist/IconLink.d.ts +0 -9
- package/dist/IconLink.js +0 -32
- package/dist/IconLink.js.map +0 -1
- package/dist/IconType.d.ts +0 -1
- package/dist/IconType.js +0 -2
- package/dist/IconType.js.map +0 -1
- package/dist/Interactable.d.ts +0 -50
- package/dist/Interactable.js +0 -169
- package/dist/Interactable.js.map +0 -1
- package/dist/JSSComment.d.ts +0 -10
- package/dist/JSSComment.js +0 -52
- package/dist/JSSComment.js.map +0 -1
- package/dist/Link.d.ts +0 -22
- package/dist/Link.js +0 -29
- package/dist/Link.js.map +0 -1
- package/dist/List.d.ts +0 -15
- package/dist/List.js +0 -29
- package/dist/List.js.map +0 -1
- package/dist/ListButtonItem.d.ts +0 -14
- package/dist/ListButtonItem.js +0 -11
- package/dist/ListButtonItem.js.map +0 -1
- package/dist/ListDivider.d.ts +0 -1
- package/dist/ListDivider.js +0 -12
- package/dist/ListDivider.js.map +0 -1
- package/dist/ListHeaderItem.d.ts +0 -10
- package/dist/ListHeaderItem.js +0 -15
- package/dist/ListHeaderItem.js.map +0 -1
- package/dist/ListItem.d.ts +0 -9
- package/dist/ListItem.js +0 -9
- package/dist/ListItem.js.map +0 -1
- package/dist/ListLinkItem.d.ts +0 -16
- package/dist/ListLinkItem.js +0 -11
- package/dist/ListLinkItem.js.map +0 -1
- package/dist/ListSpacer.d.ts +0 -1
- package/dist/ListSpacer.js +0 -13
- package/dist/ListSpacer.js.map +0 -1
- package/dist/MenuIcon.d.ts +0 -5
- package/dist/MenuIcon.js +0 -31
- package/dist/MenuIcon.js.map +0 -1
- package/dist/NextJSRouter.d.ts +0 -1
- package/dist/NextJSRouter.js +0 -37
- package/dist/NextJSRouter.js.map +0 -1
- package/dist/NextJSRouterState.d.ts +0 -38
- package/dist/NextJSRouterState.js +0 -111
- package/dist/NextJSRouterState.js.map +0 -1
- package/dist/OnVisible.d.ts +0 -5
- package/dist/OnVisible.js +0 -28
- package/dist/OnVisible.js.map +0 -1
- package/dist/Popover.d.ts +0 -22
- package/dist/Popover.js +0 -90
- package/dist/Popover.js.map +0 -1
- package/dist/ProgressBar.d.ts +0 -7
- package/dist/ProgressBar.js +0 -42
- package/dist/ProgressBar.js.map +0 -1
- package/dist/ProgressCircle.d.ts +0 -5
- package/dist/ProgressCircle.js +0 -12
- package/dist/ProgressCircle.js.map +0 -1
- package/dist/Providers.d.ts +0 -9
- package/dist/Providers.js +0 -16
- package/dist/Providers.js.map +0 -1
- package/dist/RangeInput.d.ts +0 -14
- package/dist/RangeInput.js +0 -32
- package/dist/RangeInput.js.map +0 -1
- package/dist/ResultOrError.d.ts +0 -13
- package/dist/ResultOrError.js +0 -7
- package/dist/ResultOrError.js.map +0 -1
- package/dist/RootView.d.ts +0 -5
- package/dist/RootView.js +0 -35
- package/dist/RootView.js.map +0 -1
- package/dist/Row.d.ts +0 -6
- package/dist/Row.js +0 -7
- package/dist/Row.js.map +0 -1
- package/dist/Select.d.ts +0 -9
- package/dist/Select.js +0 -17
- package/dist/Select.js.map +0 -1
- package/dist/StackContext.d.ts +0 -8
- package/dist/StackContext.js +0 -25
- package/dist/StackContext.js.map +0 -1
- package/dist/StaticCheckbox.d.ts +0 -16
- package/dist/StaticCheckbox.js +0 -48
- package/dist/StaticCheckbox.js.map +0 -1
- package/dist/Storage.d.ts +0 -13
- package/dist/Storage.js +0 -146
- package/dist/Storage.js.map +0 -1
- package/dist/Stream.d.ts +0 -9
- package/dist/Stream.js +0 -36
- package/dist/Stream.js.map +0 -1
- package/dist/Sublist.d.ts +0 -12
- package/dist/Sublist.js +0 -18
- package/dist/Sublist.js.map +0 -1
- package/dist/SubmitIconInput.d.ts +0 -8
- package/dist/SubmitIconInput.js +0 -25
- package/dist/SubmitIconInput.js.map +0 -1
- package/dist/Tabs.d.ts +0 -23
- package/dist/Tabs.js +0 -39
- package/dist/Tabs.js.map +0 -1
- package/dist/Text.d.ts +0 -25
- package/dist/Text.js +0 -52
- package/dist/Text.js.map +0 -1
- package/dist/TextArea.d.ts +0 -11
- package/dist/TextArea.js +0 -27
- package/dist/TextArea.js.map +0 -1
- package/dist/TextInput.d.ts +0 -15
- package/dist/TextInput.js +0 -61
- package/dist/TextInput.js.map +0 -1
- package/dist/TextInputWithState.d.ts +0 -8
- package/dist/TextInputWithState.js +0 -14
- package/dist/TextInputWithState.js.map +0 -1
- package/dist/TextPairing.d.ts +0 -21
- package/dist/TextPairing.js +0 -26
- package/dist/TextPairing.js.map +0 -1
- package/dist/TimeInput.d.ts +0 -15
- package/dist/TimeInput.js +0 -58
- package/dist/TimeInput.js.map +0 -1
- package/dist/Tooltip.d.ts +0 -11
- package/dist/Tooltip.js +0 -73
- package/dist/Tooltip.js.map +0 -1
- package/dist/aria.d.ts +0 -8
- package/dist/aria.js +0 -42
- package/dist/aria.js.map +0 -1
- package/dist/guid.d.ts +0 -1
- package/dist/guid.js +0 -7
- package/dist/guid.js.map +0 -1
- package/dist/hash.d.ts +0 -1
- package/dist/hash.js +0 -20
- package/dist/hash.js.map +0 -1
- package/dist/isServer.d.ts +0 -1
- package/dist/isServer.js +0 -4
- package/dist/isServer.js.map +0 -1
- package/dist/jss.d.ts +0 -122
- package/dist/jss.js +0 -515
- package/dist/jss.js.map +0 -1
- package/dist/numberToBase.d.ts +0 -1
- package/dist/numberToBase.js +0 -44
- package/dist/numberToBase.js.map +0 -1
- package/dist/stateMachineContextFactory.d.ts +0 -36
- package/dist/stateMachineContextFactory.js +0 -48
- package/dist/stateMachineContextFactory.js.map +0 -1
- package/dist/useCookie.d.ts +0 -9
- package/dist/useCookie.js +0 -67
- package/dist/useCookie.js.map +0 -1
- package/dist/useKeyboard.d.ts +0 -8
- package/dist/useKeyboard.js +0 -26
- package/dist/useKeyboard.js.map +0 -1
- package/dist/useNavigation.d.ts +0 -5
- package/dist/useNavigation.js +0 -79
- package/dist/useNavigation.js.map +0 -1
- package/dist/usePromise.d.ts +0 -1
- package/dist/usePromise.js +0 -12
- package/dist/usePromise.js.map +0 -1
- package/dist/useRefEffect.d.ts +0 -1
- package/dist/useRefEffect.js +0 -15
- package/dist/useRefEffect.js.map +0 -1
- package/jss-debug-loader.mjs +0 -44
- package/next-env.d.ts +0 -6
- package/next.config.js +0 -33
- package/scripts/embeddings.js +0 -93
- package/scripts/openai_embeddings.js +0 -100
- package/scripts/publish.js +0 -28
- package/scripts/test_embeddings.js +0 -47
- package/src/Badge.tsx +0 -36
- package/src/BaseButton.tsx +0 -62
- package/src/BaseInput.tsx +0 -63
- package/src/BaseLink.tsx +0 -80
- package/src/BaseList.tsx +0 -26
- package/src/BaseListAddOn.tsx +0 -10
- package/src/BaseListItem.tsx +0 -119
- package/src/BaseView.tsx +0 -57
- package/src/Box.tsx +0 -20
- package/src/Button.tsx +0 -90
- package/src/Calendar.tsx +0 -125
- package/src/Card.tsx +0 -30
- package/src/Checkbox.tsx +0 -63
- package/src/Circle.tsx +0 -24
- package/src/Column.tsx +0 -12
- package/src/DarkMode.tsx +0 -100
- package/src/DateInput.tsx +0 -63
- package/src/DatePicker.tsx +0 -67
- package/src/DatetimeInput.tsx +0 -64
- package/src/DesignBook.tsx +0 -677
- package/src/Dialog.tsx +0 -150
- package/src/Dropdown.tsx +0 -146
- package/src/Emitter.ts +0 -26
- package/src/FlexLayout.tsx +0 -53
- package/src/Icon.tsx +0 -80
- package/src/IconButton.tsx +0 -58
- package/src/IconLink.tsx +0 -59
- package/src/IconType.ts +0 -787
- package/src/Interactable.tsx +0 -210
- package/src/JSSComment.tsx +0 -56
- package/src/Link.tsx +0 -110
- package/src/List.tsx +0 -58
- package/src/ListButtonItem.tsx +0 -69
- package/src/ListDivider.tsx +0 -13
- package/src/ListHeaderItem.tsx +0 -45
- package/src/ListItem.tsx +0 -24
- package/src/ListLinkItem.tsx +0 -76
- package/src/ListSpacer.tsx +0 -14
- package/src/MenuIcon.tsx +0 -50
- package/src/NextJSRouter.tsx +0 -62
- package/src/NextJSRouterState.tsx +0 -154
- package/src/OnVisible.tsx +0 -42
- package/src/Popover.tsx +0 -145
- package/src/ProgressBar.tsx +0 -63
- package/src/ProgressCircle.tsx +0 -38
- package/src/Providers.tsx +0 -33
- package/src/RangeInput.tsx +0 -82
- package/src/ResultOrError.ts +0 -15
- package/src/RootView.tsx +0 -55
- package/src/Row.tsx +0 -12
- package/src/Select.tsx +0 -39
- package/src/StackContext.tsx +0 -52
- package/src/StaticCheckbox.tsx +0 -72
- package/src/Storage.tsx +0 -198
- package/src/Stream.tsx +0 -50
- package/src/Sublist.tsx +0 -61
- package/src/SubmitIconInput.tsx +0 -45
- package/src/Tabs.tsx +0 -110
- package/src/Text.tsx +0 -111
- package/src/TextArea.tsx +0 -58
- package/src/TextInput.tsx +0 -123
- package/src/TextInputWithState.tsx +0 -32
- package/src/TextPairing.tsx +0 -115
- package/src/TimeInput.tsx +0 -109
- package/src/Tooltip.tsx +0 -109
- package/src/aria.ts +0 -72
- package/src/docs/mdx.tsx +0 -137
- package/src/docs/pages.ts +0 -115
- package/src/docs/searchIndex.ts +0 -1
- package/src/examples/ExampleDialog.tsx +0 -28
- package/src/guid.ts +0 -7
- package/src/hash.ts +0 -21
- package/src/index.ts +0 -68
- package/src/isServer.ts +0 -3
- package/src/jss.tsx +0 -712
- package/src/jsx-dev-runtime.ts +0 -74
- package/src/jsx-runtime.ts +0 -2
- package/src/numberToBase.ts +0 -52
- package/src/pages/Badge.mdx +0 -152
- package/src/pages/Button.mdx +0 -163
- package/src/pages/Calendar.mdx +0 -254
- package/src/pages/Card.mdx +0 -147
- package/src/pages/Checkbox.mdx +0 -131
- package/src/pages/Dialog.mdx +0 -197
- package/src/pages/FlexLayout.mdx +0 -211
- package/src/pages/Hashing.mdx +0 -211
- package/src/pages/Icon.mdx +0 -171
- package/src/pages/IconButton.mdx +0 -155
- package/src/pages/Link.mdx +0 -160
- package/src/pages/List.mdx +0 -262
- package/src/pages/ListHeader.mdx +0 -220
- package/src/pages/Popover.mdx +0 -223
- package/src/pages/ProgressBar.mdx +0 -200
- package/src/pages/ProgressCircle.mdx +0 -218
- package/src/pages/RangeInput.mdx +0 -237
- package/src/pages/Tabs.mdx +0 -281
- package/src/pages/Text.mdx +0 -154
- package/src/pages/TextInput.mdx +0 -235
- package/src/pages/TextPairing.mdx +0 -204
- package/src/pages/TimeInput.mdx +0 -178
- package/src/pages/Tooltip.mdx +0 -115
- package/src/pages/_app.tsx +0 -466
- package/src/pages/_document.tsx +0 -30
- package/src/pages/css-in-js.mdx +0 -240
- package/src/pages/index.mdx +0 -58
- package/src/pages/navigation.mdx +0 -158
- package/src/pages/prism.css +0 -3
- package/src/pages/useCookie.mdx +0 -176
- package/src/pages/useKeyboard.mdx +0 -257
- package/src/pages/useNavigation.mdx +0 -258
- package/src/pages/usePromise.mdx +0 -280
- package/src/pages/useRefEffect.mdx +0 -251
- package/src/stateMachineContextFactory.tsx +0 -111
- package/src/useCookie.tsx +0 -95
- package/src/useKeyboard.tsx +0 -43
- package/src/useNavigation.tsx +0 -89
- package/src/usePromise.tsx +0 -18
- package/src/useRefEffect.tsx +0 -18
- package/src/vite-plugin-jss-debug.ts +0 -75
- package/tsconfig.build.json +0 -23
- package/tsconfig.json +0 -38
package/src/MenuIcon.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { BaseView } from "./BaseView";
|
|
2
|
-
import { Column } from "./Column";
|
|
3
|
-
import { Color, JSS, getBackground } from "./jss";
|
|
4
|
-
|
|
5
|
-
export function MenuIcon({ open, color }: { open: boolean; color: Color }) {
|
|
6
|
-
return (
|
|
7
|
-
<Column gap="small">
|
|
8
|
-
<Bar
|
|
9
|
-
color={color}
|
|
10
|
-
jss={{
|
|
11
|
-
transform: open ? "rotateZ(135deg)" : "",
|
|
12
|
-
transformOrigin: "center",
|
|
13
|
-
top: open ? 8 : 0,
|
|
14
|
-
}}
|
|
15
|
-
/>
|
|
16
|
-
<Bar
|
|
17
|
-
color={color}
|
|
18
|
-
jss={{
|
|
19
|
-
opacity: open ? 0 : 1,
|
|
20
|
-
}}
|
|
21
|
-
/>
|
|
22
|
-
<Bar
|
|
23
|
-
color={color}
|
|
24
|
-
jss={{
|
|
25
|
-
transform: open ? "rotateZ(-135deg)" : "",
|
|
26
|
-
transformOrigin: "center",
|
|
27
|
-
top: open ? -8 : 0,
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
30
|
-
</Column>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function Bar({ jss, color }: { jss: JSS; color: Color }) {
|
|
35
|
-
return (
|
|
36
|
-
<BaseView
|
|
37
|
-
jss={[
|
|
38
|
-
{
|
|
39
|
-
position: "relative",
|
|
40
|
-
width: 24,
|
|
41
|
-
height: 4,
|
|
42
|
-
borderRadius: "1px",
|
|
43
|
-
transition: "all 200ms ease-out",
|
|
44
|
-
},
|
|
45
|
-
getBackground(color),
|
|
46
|
-
jss,
|
|
47
|
-
]}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
}
|
package/src/NextJSRouter.tsx
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { Suspense } from "react";
|
|
2
|
-
|
|
3
|
-
import { StackContextProvider } from "./StackContext";
|
|
4
|
-
import { Column } from "./Column";
|
|
5
|
-
import { ListDivider } from "./ListDivider";
|
|
6
|
-
import { BaseView } from "./BaseView";
|
|
7
|
-
import { useRouterState } from "./NextJSRouterState";
|
|
8
|
-
import { JSS } from "./jss";
|
|
9
|
-
|
|
10
|
-
const jsss: { [key: string]: JSS } = {
|
|
11
|
-
root: {
|
|
12
|
-
display: "flex",
|
|
13
|
-
flexDirection: "column",
|
|
14
|
-
flexGrow: 1,
|
|
15
|
-
minHeight: 0,
|
|
16
|
-
flexShrink: 1,
|
|
17
|
-
flexBasis: "0%",
|
|
18
|
-
position: "relative",
|
|
19
|
-
},
|
|
20
|
-
route: {
|
|
21
|
-
display: "flex",
|
|
22
|
-
flexDirection: "column",
|
|
23
|
-
flexGrow: 1,
|
|
24
|
-
minHeight: 0,
|
|
25
|
-
flexShrink: 1,
|
|
26
|
-
flexBasis: "0%",
|
|
27
|
-
},
|
|
28
|
-
hidden: {
|
|
29
|
-
display: "none",
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function Router() {
|
|
34
|
-
const {
|
|
35
|
-
context: { navigationStack },
|
|
36
|
-
} = useRouterState();
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<BaseView jss={jsss.root}>
|
|
40
|
-
{navigationStack.map(({ route, routeProps }, index, list) => {
|
|
41
|
-
const isTopOfStack = index === list.length - 1;
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<StackContextProvider
|
|
45
|
-
key={route.title(routeProps)}
|
|
46
|
-
isTopOfStack={isTopOfStack}
|
|
47
|
-
>
|
|
48
|
-
<Column
|
|
49
|
-
jss={[jsss.route, !isTopOfStack && jsss.hidden]}
|
|
50
|
-
aria-hidden={!isTopOfStack}
|
|
51
|
-
>
|
|
52
|
-
<ListDivider />
|
|
53
|
-
<Suspense fallback={null}>
|
|
54
|
-
<route.root {...routeProps} />
|
|
55
|
-
</Suspense>
|
|
56
|
-
</Column>
|
|
57
|
-
</StackContextProvider>
|
|
58
|
-
);
|
|
59
|
-
})}
|
|
60
|
-
</BaseView>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState, ComponentType } from "react";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
stateMachineContextFactory,
|
|
5
|
-
Reducer,
|
|
6
|
-
} from "./stateMachineContextFactory";
|
|
7
|
-
|
|
8
|
-
import { DesignBook } from "./DesignBook";
|
|
9
|
-
|
|
10
|
-
export enum RouteState {
|
|
11
|
-
Menu = "Menu",
|
|
12
|
-
DesignBook = "DesignBook",
|
|
13
|
-
Encounter = "Encounter",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export enum RouteTransition {
|
|
17
|
-
Pop = "Pop",
|
|
18
|
-
ToDesignBook = "ToDesignBook",
|
|
19
|
-
ToEncounter = "ToEncounter",
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type Context = {
|
|
23
|
-
navigationStack: Array<StackNode<any>>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type StackNode<Props> = {
|
|
27
|
-
route: Route<Props, any>;
|
|
28
|
-
routeProps: Props;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type Route<Props, State extends RouteState> = {
|
|
32
|
-
state: State;
|
|
33
|
-
title: (props: Props) => string;
|
|
34
|
-
root: ComponentType<Props>;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// const MenuRoute: Route<{}, RouteState.Menu> = {
|
|
38
|
-
// state: RouteState.Menu,
|
|
39
|
-
// title: () => "Menu",
|
|
40
|
-
// root: Menu,
|
|
41
|
-
// };
|
|
42
|
-
|
|
43
|
-
const DesignBookRoute: Route<{}, RouteState.DesignBook> = {
|
|
44
|
-
state: RouteState.DesignBook,
|
|
45
|
-
title: () => "DesignBook",
|
|
46
|
-
root: DesignBook,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const INITIAL_CONTEXT: Context = {
|
|
50
|
-
navigationStack: [{ route: DesignBookRoute, routeProps: {} }],
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const pop: Reducer<RouteState, Context> = ({ state, context }) => {
|
|
54
|
-
if (context.navigationStack.length > 1) {
|
|
55
|
-
const navigationStack = [...context.navigationStack];
|
|
56
|
-
navigationStack.pop();
|
|
57
|
-
const finalState = navigationStack[navigationStack.length - 1].route.state;
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
state: finalState,
|
|
61
|
-
context: {
|
|
62
|
-
...context,
|
|
63
|
-
navigationStack,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return { state, context };
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const pushFactory =
|
|
72
|
-
<Props, State extends RouteState>(
|
|
73
|
-
route: Route<Props, State>
|
|
74
|
-
): Reducer<RouteState, Context> =>
|
|
75
|
-
({ context, data }) => {
|
|
76
|
-
return {
|
|
77
|
-
state: route.state,
|
|
78
|
-
context: {
|
|
79
|
-
...context,
|
|
80
|
-
navigationStack: [
|
|
81
|
-
...context.navigationStack,
|
|
82
|
-
{
|
|
83
|
-
route,
|
|
84
|
-
routeProps: data,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const replaceFactory =
|
|
92
|
-
<Props, State extends RouteState>(
|
|
93
|
-
route: Route<Props, State>
|
|
94
|
-
): Reducer<RouteState, Context> =>
|
|
95
|
-
({ context, data }) => {
|
|
96
|
-
return {
|
|
97
|
-
state: route.state,
|
|
98
|
-
context: {
|
|
99
|
-
...context,
|
|
100
|
-
navigationStack: [
|
|
101
|
-
...context.navigationStack.slice(0, -1),
|
|
102
|
-
{
|
|
103
|
-
route,
|
|
104
|
-
routeProps: data,
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const stateMachine = {
|
|
112
|
-
states: {
|
|
113
|
-
[RouteState.Menu]: {
|
|
114
|
-
on: {
|
|
115
|
-
ToDesignBook: pushFactory(DesignBookRoute),
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
[RouteState.Encounter]: {
|
|
119
|
-
on: {
|
|
120
|
-
Pop: pop,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
[RouteState.DesignBook]: {
|
|
124
|
-
on: {
|
|
125
|
-
Pop: pop,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
state: RouteState.Menu,
|
|
130
|
-
context: INITIAL_CONTEXT,
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const { Provider, useStateMachine } =
|
|
134
|
-
stateMachineContextFactory(stateMachine);
|
|
135
|
-
|
|
136
|
-
export const useRouterState = () => {
|
|
137
|
-
const [state, setState] = useState<{ state: RouteState; context: Context }>({
|
|
138
|
-
state: RouteState.Menu,
|
|
139
|
-
context: INITIAL_CONTEXT,
|
|
140
|
-
});
|
|
141
|
-
const { subscribe } = useStateMachine();
|
|
142
|
-
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
return subscribe(setState);
|
|
145
|
-
}, [subscribe]);
|
|
146
|
-
|
|
147
|
-
return state;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export const useRouterSend = () => {
|
|
151
|
-
const { send } = useStateMachine();
|
|
152
|
-
|
|
153
|
-
return send;
|
|
154
|
-
};
|
package/src/OnVisible.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useCallback, ReactElement } from "react";
|
|
2
|
-
|
|
3
|
-
export function OnVisible({
|
|
4
|
-
children,
|
|
5
|
-
onVisible,
|
|
6
|
-
}: {
|
|
7
|
-
children: (refCallback: React.RefCallback<HTMLElement>) => ReactElement;
|
|
8
|
-
onVisible: () => void;
|
|
9
|
-
}) {
|
|
10
|
-
const intersectionObserverRef = useRef<IntersectionObserver | null>(null);
|
|
11
|
-
|
|
12
|
-
const refCallback = useCallback((element) => {
|
|
13
|
-
if (element == null) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const intersectionObserver = new IntersectionObserver(
|
|
18
|
-
(entries) => {
|
|
19
|
-
entries.forEach((entry) => {
|
|
20
|
-
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
|
21
|
-
onVisible();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
root: null,
|
|
27
|
-
rootMargin: "0px",
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
intersectionObserverRef.current = intersectionObserver;
|
|
32
|
-
intersectionObserver.observe(element);
|
|
33
|
-
|
|
34
|
-
return () => {
|
|
35
|
-
intersectionObserver.unobserve(element);
|
|
36
|
-
intersectionObserverRef.current = null;
|
|
37
|
-
};
|
|
38
|
-
// eslint-disable-next-line
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
return children(refCallback);
|
|
42
|
-
}
|
package/src/Popover.tsx
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
import { queryFocusables } from "./aria";
|
|
3
|
-
|
|
4
|
-
import { BaseView } from "./BaseView";
|
|
5
|
-
import { useRefEffect } from "./useRefEffect";
|
|
6
|
-
import { JSS, toClassnames } from "./jss";
|
|
7
|
-
|
|
8
|
-
const jsss: { [key: string]: JSS } = {
|
|
9
|
-
popover: {
|
|
10
|
-
padding: 0,
|
|
11
|
-
zIndex: 1,
|
|
12
|
-
backgroundColor: "var(--primary-background)",
|
|
13
|
-
borderRadius: "var(--border-radius-l)",
|
|
14
|
-
border: "1px solid var(--divider)",
|
|
15
|
-
overflow: "hidden",
|
|
16
|
-
boxShadow: "var(--shadow-lg)",
|
|
17
|
-
animation: "popoverFadeIn 0.15s ease-out",
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function Popover({ children, close }) {
|
|
22
|
-
const activeElementRef = useRef(null);
|
|
23
|
-
|
|
24
|
-
const focusTrapRoot = useRefEffect((root: HTMLElement) => {
|
|
25
|
-
activeElementRef.current = document.activeElement;
|
|
26
|
-
const [element] = queryFocusables(root);
|
|
27
|
-
element ? element.focus() : root.focus();
|
|
28
|
-
|
|
29
|
-
const keydown = (e) => {
|
|
30
|
-
if (e.key === "Escape") {
|
|
31
|
-
close();
|
|
32
|
-
} else if (e.key === "Tab") {
|
|
33
|
-
const focusables = queryFocusables(root).filter(
|
|
34
|
-
(element) => element.tabIndex !== -1
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (focusables.length === 0) {
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const focusedIndex = focusables.findIndex(
|
|
43
|
-
(x) => x === document.activeElement
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (focusables.length === 0) {
|
|
47
|
-
e.stopPropagation();
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
} else if (focusedIndex === focusables.length - 1) {
|
|
50
|
-
// Cycle back to the first element
|
|
51
|
-
focusables[0].focus();
|
|
52
|
-
e.stopPropagation();
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
} else {
|
|
55
|
-
// Just do the usual thing
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const click = () => {
|
|
61
|
-
close();
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// This is needed so that the trigger click is not captured immediatly, which would close the popover as it opens
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
window.addEventListener("keydown", keydown);
|
|
67
|
-
window.addEventListener("click", click);
|
|
68
|
-
}, 0);
|
|
69
|
-
|
|
70
|
-
return () => {
|
|
71
|
-
activeElementRef.current && activeElementRef.current.focus();
|
|
72
|
-
window.removeEventListener("keydown", keydown);
|
|
73
|
-
window.removeEventListener("click", click);
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return <BaseView ref={focusTrapRoot}>{children}</BaseView>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
interface PopoverTriggerProps<Input> {
|
|
81
|
-
PopoverComponent: (props: { close: () => void } & Input) => React.JSX.Element;
|
|
82
|
-
jss?: JSS;
|
|
83
|
-
jssDialog?: JSS;
|
|
84
|
-
className?: undefined;
|
|
85
|
-
grow?: boolean;
|
|
86
|
-
shrink?: boolean;
|
|
87
|
-
tag?: keyof HTMLElementTagNameMap;
|
|
88
|
-
children: (props: { toggle: (input: Input) => void }) => React.JSX.Element;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function PopoverTrigger<Input>({
|
|
92
|
-
PopoverComponent,
|
|
93
|
-
jss,
|
|
94
|
-
jssDialog,
|
|
95
|
-
grow,
|
|
96
|
-
shrink,
|
|
97
|
-
tag,
|
|
98
|
-
children,
|
|
99
|
-
}: PopoverTriggerProps<Input>) {
|
|
100
|
-
const [popover, setPopover] = useState<React.JSX.Element>(null);
|
|
101
|
-
const dialogRef = useRef<null | HTMLDialogElement>(null);
|
|
102
|
-
|
|
103
|
-
const toggle = (input: Input) => {
|
|
104
|
-
if (popover == null) {
|
|
105
|
-
dialogRef && dialogRef.current.show();
|
|
106
|
-
setPopover(
|
|
107
|
-
<PopoverComponent
|
|
108
|
-
{...input}
|
|
109
|
-
close={() => {
|
|
110
|
-
dialogRef && dialogRef.current.close();
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
);
|
|
114
|
-
} else {
|
|
115
|
-
dialogRef && dialogRef.current.close();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<BaseView
|
|
121
|
-
grow={grow}
|
|
122
|
-
shrink={shrink}
|
|
123
|
-
tag={tag}
|
|
124
|
-
relative={true}
|
|
125
|
-
jss={[jss, { position: "relative", display: "inline-block" }]}
|
|
126
|
-
>
|
|
127
|
-
{children({ toggle })}
|
|
128
|
-
<dialog
|
|
129
|
-
ref={(ref: null | HTMLDialogElement) => {
|
|
130
|
-
dialogRef.current = ref;
|
|
131
|
-
}}
|
|
132
|
-
className={toClassnames([jsss.popover, jssDialog])}
|
|
133
|
-
onClose={() => {
|
|
134
|
-
setPopover(null);
|
|
135
|
-
}}
|
|
136
|
-
onClick={(e) => {
|
|
137
|
-
e.preventDefault();
|
|
138
|
-
e.stopPropagation();
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
{popover}
|
|
142
|
-
</dialog>
|
|
143
|
-
</BaseView>
|
|
144
|
-
);
|
|
145
|
-
}
|
package/src/ProgressBar.tsx
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { BaseView } from "./BaseView";
|
|
3
|
-
import { Color, Size, JSS, getBackground } from "./jss";
|
|
4
|
-
|
|
5
|
-
const jsss: { [key: string]: JSS } = {
|
|
6
|
-
root: {
|
|
7
|
-
width: "100%",
|
|
8
|
-
display: "flex",
|
|
9
|
-
position: "relative",
|
|
10
|
-
backgroundColor: "var(--primary-background)",
|
|
11
|
-
borderRadius: "var(--border-radius-s)",
|
|
12
|
-
border: "1px solid var(--divider)",
|
|
13
|
-
overflow: "hidden",
|
|
14
|
-
},
|
|
15
|
-
fill: {
|
|
16
|
-
borderRadius: "var(--border-radius-s)",
|
|
17
|
-
position: "absolute",
|
|
18
|
-
transformOrigin: "center left",
|
|
19
|
-
top: 0,
|
|
20
|
-
bottom: 0,
|
|
21
|
-
left: 0,
|
|
22
|
-
right: 0,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const sizes = {
|
|
27
|
-
xsmall: 4,
|
|
28
|
-
small: 8,
|
|
29
|
-
medium: 12,
|
|
30
|
-
large: 16,
|
|
31
|
-
xlarge: 20,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export function ProgressBar({
|
|
35
|
-
color,
|
|
36
|
-
progress,
|
|
37
|
-
size,
|
|
38
|
-
jss,
|
|
39
|
-
}: {
|
|
40
|
-
progress: number;
|
|
41
|
-
color: Color;
|
|
42
|
-
size: Size;
|
|
43
|
-
jss?: JSS;
|
|
44
|
-
}) {
|
|
45
|
-
return (
|
|
46
|
-
<BaseView
|
|
47
|
-
jss={[
|
|
48
|
-
jsss.root,
|
|
49
|
-
{
|
|
50
|
-
height: sizes[size],
|
|
51
|
-
},
|
|
52
|
-
jss,
|
|
53
|
-
]}
|
|
54
|
-
>
|
|
55
|
-
<BaseView
|
|
56
|
-
jss={[jsss.fill, getBackground(color)]}
|
|
57
|
-
style={{
|
|
58
|
-
transform: `scaleX(${progress > 1 ? 1 : progress})`,
|
|
59
|
-
}}
|
|
60
|
-
/>
|
|
61
|
-
</BaseView>
|
|
62
|
-
);
|
|
63
|
-
}
|
package/src/ProgressCircle.tsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { cssVar, toClassnames } from "./jss";
|
|
3
|
-
|
|
4
|
-
export function ProgressCircle({
|
|
5
|
-
progress,
|
|
6
|
-
stroke = 4,
|
|
7
|
-
outerRadius,
|
|
8
|
-
}: {
|
|
9
|
-
progress: number;
|
|
10
|
-
stroke?: number;
|
|
11
|
-
outerRadius: number;
|
|
12
|
-
}) {
|
|
13
|
-
const circumference = outerRadius * 2 * Math.PI;
|
|
14
|
-
const strokeDashoffset = circumference - progress * circumference;
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<svg
|
|
18
|
-
className={toClassnames({
|
|
19
|
-
backgroundColor: cssVar("--secondary-background"),
|
|
20
|
-
transform: "rotate(-90deg)",
|
|
21
|
-
borderRadius: "50%",
|
|
22
|
-
})}
|
|
23
|
-
width={(outerRadius + stroke) * 2}
|
|
24
|
-
height={(outerRadius + stroke) * 2}
|
|
25
|
-
>
|
|
26
|
-
<circle
|
|
27
|
-
stroke="var(--highlight)"
|
|
28
|
-
fill="transparent"
|
|
29
|
-
strokeWidth={stroke}
|
|
30
|
-
strokeDasharray={`${circumference} ${circumference}`}
|
|
31
|
-
style={{ strokeDashoffset }}
|
|
32
|
-
r={outerRadius}
|
|
33
|
-
cx={outerRadius + stroke}
|
|
34
|
-
cy={outerRadius + stroke}
|
|
35
|
-
/>
|
|
36
|
-
</svg>
|
|
37
|
-
);
|
|
38
|
-
}
|
package/src/Providers.tsx
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement, useEffect } from "react";
|
|
2
|
-
import { DarkModeProvider } from "./DarkMode";
|
|
3
|
-
import { DialogProvider } from "./Dialog";
|
|
4
|
-
import { IconProvider } from "./Icon";
|
|
5
|
-
import { useCookie } from "./useCookie";
|
|
6
|
-
import { JSSProvider, Theme } from "./jss";
|
|
7
|
-
|
|
8
|
-
export function Providers({
|
|
9
|
-
children,
|
|
10
|
-
themes,
|
|
11
|
-
}: {
|
|
12
|
-
children: React.JSX.Element;
|
|
13
|
-
themes: { light: Theme; dark: Theme };
|
|
14
|
-
}) {
|
|
15
|
-
const [darkModeEnabled, setDarkModeEnabled] = useCookie("dark-mode", {
|
|
16
|
-
initialValue: false,
|
|
17
|
-
loadingValue: false,
|
|
18
|
-
});
|
|
19
|
-
const toggleDarkMode = React.useCallback(
|
|
20
|
-
() => setDarkModeEnabled((x) => !x),
|
|
21
|
-
[]
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<JSSProvider themes={themes}>
|
|
26
|
-
<IconProvider>
|
|
27
|
-
<DarkModeProvider enabled={darkModeEnabled} toggle={toggleDarkMode}>
|
|
28
|
-
<DialogProvider>{children}</DialogProvider>
|
|
29
|
-
</DarkModeProvider>
|
|
30
|
-
</IconProvider>
|
|
31
|
-
</JSSProvider>
|
|
32
|
-
);
|
|
33
|
-
}
|
package/src/RangeInput.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { BaseInput, BaseInputProps } from "./BaseInput";
|
|
3
|
-
import { Row } from "./Row";
|
|
4
|
-
import { Gap, JSS, Padding, cssVar } from "./jss";
|
|
5
|
-
|
|
6
|
-
export interface RangeInputProps extends BaseInputProps {
|
|
7
|
-
onValueChange: (value: number) => void;
|
|
8
|
-
value: number;
|
|
9
|
-
jssRoot?: JSS;
|
|
10
|
-
onChange?: undefined;
|
|
11
|
-
padding?: Padding;
|
|
12
|
-
gap?: Gap;
|
|
13
|
-
addOn?: React.JSX.Element;
|
|
14
|
-
addOnPosition?: "start" | "end";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const RangeInput = React.forwardRef(
|
|
18
|
-
(
|
|
19
|
-
{
|
|
20
|
-
value,
|
|
21
|
-
onValueChange,
|
|
22
|
-
jssRoot,
|
|
23
|
-
jss,
|
|
24
|
-
gap = "medium",
|
|
25
|
-
padding = "none",
|
|
26
|
-
min = 0,
|
|
27
|
-
max = 100,
|
|
28
|
-
step = 1,
|
|
29
|
-
label,
|
|
30
|
-
addOn,
|
|
31
|
-
addOnPosition = "start",
|
|
32
|
-
...inputProps
|
|
33
|
-
}: RangeInputProps,
|
|
34
|
-
ref?: React.Ref<HTMLInputElement>
|
|
35
|
-
) => {
|
|
36
|
-
return (
|
|
37
|
-
<Row
|
|
38
|
-
gap={gap}
|
|
39
|
-
padding={padding}
|
|
40
|
-
align="center"
|
|
41
|
-
jss={[
|
|
42
|
-
{
|
|
43
|
-
":has(:focus-visible)": {
|
|
44
|
-
borderRadius: cssVar("--border-radius-m"),
|
|
45
|
-
backgroundColor: cssVar("--light-highlight"),
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
jssRoot,
|
|
49
|
-
]}
|
|
50
|
-
>
|
|
51
|
-
{addOnPosition === "start" && addOn}
|
|
52
|
-
<BaseInput
|
|
53
|
-
{...inputProps}
|
|
54
|
-
label={label}
|
|
55
|
-
min={min}
|
|
56
|
-
max={max}
|
|
57
|
-
type="range"
|
|
58
|
-
ref={ref}
|
|
59
|
-
value={value}
|
|
60
|
-
onChange={(e) => {
|
|
61
|
-
onValueChange(parseFloat(e.target.value));
|
|
62
|
-
}}
|
|
63
|
-
jss={[
|
|
64
|
-
{
|
|
65
|
-
backgroundColor: cssVar("--primary-background"),
|
|
66
|
-
flexGrow: 1,
|
|
67
|
-
color: cssVar("--primary-text"),
|
|
68
|
-
margin: 0,
|
|
69
|
-
paddingTop: cssVar("--spacing-m"),
|
|
70
|
-
paddingBottom: cssVar("--spacing-m"),
|
|
71
|
-
":disabled": {
|
|
72
|
-
color: cssVar("--subtle-text"),
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
jss,
|
|
76
|
-
]}
|
|
77
|
-
/>
|
|
78
|
-
{addOnPosition === "end" && addOn}
|
|
79
|
-
</Row>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
);
|
package/src/ResultOrError.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type Result<T> = { success: true; value: T };
|
|
2
|
-
export type Error<T> = { success: false; error: T };
|
|
3
|
-
export type ResultOrError<R, E> = Result<R> | Error<E>;
|
|
4
|
-
|
|
5
|
-
export function makeResult<T>(t: void): Result<void>;
|
|
6
|
-
export function makeResult<T>(t: T): Result<T>;
|
|
7
|
-
export function makeResult<T>(t: T): Result<T> {
|
|
8
|
-
return { success: true, value: t };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function makeError<T>(t: void): Error<void>;
|
|
12
|
-
export function makeError<T>(t: T): Error<T>;
|
|
13
|
-
export function makeError<T>(t: T): Error<T> {
|
|
14
|
-
return { success: false, error: t };
|
|
15
|
-
}
|