aidos-ui 3.0.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/.prettierrc +4 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/Badge.d.ts +7 -0
- package/dist/Badge.js +22 -0
- package/dist/Badge.js.map +1 -0
- package/dist/BaseButton.d.ts +13 -0
- package/dist/BaseButton.js +22 -0
- package/dist/BaseButton.js.map +1 -0
- package/dist/BaseInput.d.ts +15 -0
- package/dist/BaseInput.js +14 -0
- package/dist/BaseInput.js.map +1 -0
- package/dist/BaseLink.d.ts +17 -0
- package/dist/BaseLink.js +28 -0
- package/dist/BaseLink.js.map +1 -0
- package/dist/BaseList.d.ts +6 -0
- package/dist/BaseList.js +14 -0
- package/dist/BaseList.js.map +1 -0
- package/dist/BaseListAddOn.d.ts +5 -0
- package/dist/BaseListAddOn.js +7 -0
- package/dist/BaseListAddOn.js.map +1 -0
- package/dist/BaseListItem.d.ts +27 -0
- package/dist/BaseListItem.js +26 -0
- package/dist/BaseListItem.js.map +1 -0
- package/dist/BaseView.d.ts +12 -0
- package/dist/BaseView.js +26 -0
- package/dist/BaseView.js.map +1 -0
- package/dist/Box.d.ts +5 -0
- package/dist/Box.js +6 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +20 -0
- package/dist/Button.js +20 -0
- package/dist/Button.js.map +1 -0
- package/dist/Calendar.d.ts +18 -0
- package/dist/Calendar.js +57 -0
- package/dist/Calendar.js.map +1 -0
- package/dist/Card.d.ts +4 -0
- package/dist/Card.js +12 -0
- package/dist/Card.js.map +1 -0
- package/dist/Checkbox.d.ts +12 -0
- package/dist/Checkbox.js +32 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Circle.d.ts +6 -0
- package/dist/Circle.js +12 -0
- package/dist/Circle.js.map +1 -0
- package/dist/Column.d.ts +6 -0
- package/dist/Column.js +7 -0
- package/dist/Column.js.map +1 -0
- package/dist/DarkMode.d.ts +13 -0
- package/dist/DarkMode.js +61 -0
- package/dist/DarkMode.js.map +1 -0
- package/dist/DateInput.d.ts +13 -0
- package/dist/DateInput.js +29 -0
- package/dist/DateInput.js.map +1 -0
- package/dist/DatePicker.d.ts +12 -0
- package/dist/DatePicker.js +34 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatetimeInput.d.ts +13 -0
- package/dist/DatetimeInput.js +31 -0
- package/dist/DatetimeInput.js.map +1 -0
- package/dist/DesignBook.d.ts +2 -0
- package/dist/DesignBook.js +55 -0
- package/dist/DesignBook.js.map +1 -0
- package/dist/Dialog.d.ts +17 -0
- package/dist/Dialog.js +86 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dropdown.d.ts +10 -0
- package/dist/Dropdown.js +64 -0
- package/dist/Dropdown.js.map +1 -0
- package/dist/Emitter.d.ts +6 -0
- package/dist/Emitter.js +19 -0
- package/dist/Emitter.js.map +1 -0
- package/dist/FlexLayout.d.ts +11 -0
- package/dist/FlexLayout.js +18 -0
- package/dist/FlexLayout.js.map +1 -0
- package/dist/Icon.d.ts +12 -0
- package/dist/Icon.js +69 -0
- package/dist/Icon.js.map +1 -0
- package/dist/IconButton.d.ts +9 -0
- package/dist/IconButton.js +31 -0
- package/dist/IconButton.js.map +1 -0
- package/dist/IconLink.d.ts +9 -0
- package/dist/IconLink.js +31 -0
- package/dist/IconLink.js.map +1 -0
- package/dist/IconType.d.ts +1 -0
- package/dist/IconType.js +2 -0
- package/dist/IconType.js.map +1 -0
- package/dist/Interactable.d.ts +48 -0
- package/dist/Interactable.js +131 -0
- package/dist/Interactable.js.map +1 -0
- package/dist/Link.d.ts +20 -0
- package/dist/Link.js +22 -0
- package/dist/Link.js.map +1 -0
- package/dist/List.d.ts +11 -0
- package/dist/List.js +17 -0
- package/dist/List.js.map +1 -0
- package/dist/ListButtonItem.d.ts +15 -0
- package/dist/ListButtonItem.js +9 -0
- package/dist/ListButtonItem.js.map +1 -0
- package/dist/ListDivider.d.ts +2 -0
- package/dist/ListDivider.js +12 -0
- package/dist/ListDivider.js.map +1 -0
- package/dist/ListHeaderItem.d.ts +11 -0
- package/dist/ListHeaderItem.js +13 -0
- package/dist/ListHeaderItem.js.map +1 -0
- package/dist/ListItem.d.ts +10 -0
- package/dist/ListItem.js +7 -0
- package/dist/ListItem.js.map +1 -0
- package/dist/ListLinkItem.d.ts +17 -0
- package/dist/ListLinkItem.js +9 -0
- package/dist/ListLinkItem.js.map +1 -0
- package/dist/ListSpacer.d.ts +2 -0
- package/dist/ListSpacer.js +13 -0
- package/dist/ListSpacer.js.map +1 -0
- package/dist/OnVisible.d.ts +5 -0
- package/dist/OnVisible.js +28 -0
- package/dist/OnVisible.js.map +1 -0
- package/dist/Popover.d.ts +21 -0
- package/dist/Popover.js +88 -0
- package/dist/Popover.js.map +1 -0
- package/dist/ProgressBar.d.ts +8 -0
- package/dist/ProgressBar.js +42 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ProgressCircle.d.ts +6 -0
- package/dist/ProgressCircle.js +12 -0
- package/dist/ProgressCircle.js.map +1 -0
- package/dist/Providers.d.ts +9 -0
- package/dist/Providers.js +16 -0
- package/dist/Providers.js.map +1 -0
- package/dist/RangeInput.d.ts +14 -0
- package/dist/RangeInput.js +32 -0
- package/dist/RangeInput.js.map +1 -0
- package/dist/ResultOrError.d.ts +13 -0
- package/dist/ResultOrError.js +7 -0
- package/dist/ResultOrError.js.map +1 -0
- package/dist/RootView.d.ts +5 -0
- package/dist/RootView.js +35 -0
- package/dist/RootView.js.map +1 -0
- package/dist/Router.d.ts +2 -0
- package/dist/Router.js +37 -0
- package/dist/Router.js.map +1 -0
- package/dist/RouterState.d.ts +38 -0
- package/dist/RouterState.js +111 -0
- package/dist/RouterState.js.map +1 -0
- package/dist/Row.d.ts +6 -0
- package/dist/Row.js +7 -0
- package/dist/Row.js.map +1 -0
- package/dist/StackContext.d.ts +8 -0
- package/dist/StackContext.js +25 -0
- package/dist/StackContext.js.map +1 -0
- package/dist/StaticCheckbox.d.ts +17 -0
- package/dist/StaticCheckbox.js +48 -0
- package/dist/StaticCheckbox.js.map +1 -0
- package/dist/Storage.d.ts +12 -0
- package/dist/Storage.js +148 -0
- package/dist/Storage.js.map +1 -0
- package/dist/Stream.d.ts +9 -0
- package/dist/Stream.js +36 -0
- package/dist/Stream.js.map +1 -0
- package/dist/Sublist.d.ts +12 -0
- package/dist/Sublist.js +18 -0
- package/dist/Sublist.js.map +1 -0
- package/dist/SubmitIconInput.d.ts +9 -0
- package/dist/SubmitIconInput.js +25 -0
- package/dist/SubmitIconInput.js.map +1 -0
- package/dist/Tabs.d.ts +20 -0
- package/dist/Tabs.js +35 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Text.d.ts +25 -0
- package/dist/Text.js +50 -0
- package/dist/Text.js.map +1 -0
- package/dist/TextArea.d.ts +10 -0
- package/dist/TextArea.js +22 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextInput.d.ts +14 -0
- package/dist/TextInput.js +52 -0
- package/dist/TextInput.js.map +1 -0
- package/dist/TextInputWithState.d.ts +10 -0
- package/dist/TextInputWithState.js +14 -0
- package/dist/TextInputWithState.js.map +1 -0
- package/dist/TextPairing.d.ts +21 -0
- package/dist/TextPairing.js +26 -0
- package/dist/TextPairing.js.map +1 -0
- package/dist/TimeInput.d.ts +15 -0
- package/dist/TimeInput.js +58 -0
- package/dist/TimeInput.js.map +1 -0
- package/dist/Tooltip.d.ts +11 -0
- package/dist/Tooltip.js +72 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/aria.d.ts +8 -0
- package/dist/aria.js +42 -0
- package/dist/aria.js.map +1 -0
- package/dist/guid.d.ts +1 -0
- package/dist/guid.js +7 -0
- package/dist/guid.js.map +1 -0
- package/dist/hash.d.ts +1 -0
- package/dist/hash.js +20 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/jss.d.ts +110 -0
- package/dist/jss.js +438 -0
- package/dist/jss.js.map +1 -0
- package/dist/numberToBase.d.ts +1 -0
- package/dist/numberToBase.js +44 -0
- package/dist/numberToBase.js.map +1 -0
- package/dist/stateMachineContextFactory.d.ts +36 -0
- package/dist/stateMachineContextFactory.js +48 -0
- package/dist/stateMachineContextFactory.js.map +1 -0
- package/dist/useCookie.d.ts +9 -0
- package/dist/useCookie.js +65 -0
- package/dist/useCookie.js.map +1 -0
- package/dist/useKeyboard.d.ts +8 -0
- package/dist/useKeyboard.js +26 -0
- package/dist/useKeyboard.js.map +1 -0
- package/dist/useNavigation.d.ts +5 -0
- package/dist/useNavigation.js +79 -0
- package/dist/useNavigation.js.map +1 -0
- package/dist/usePromise.d.ts +1 -0
- package/dist/usePromise.js +12 -0
- package/dist/usePromise.js.map +1 -0
- package/dist/useRefEffect.d.ts +1 -0
- package/dist/useRefEffect.js +15 -0
- package/dist/useRefEffect.js.map +1 -0
- package/next-env.d.ts +5 -0
- package/next.config.js +21 -0
- package/package.json +40 -0
- package/scripts/publish.js +27 -0
- package/src/Badge.tsx +36 -0
- package/src/BaseButton.tsx +58 -0
- package/src/BaseInput.tsx +57 -0
- package/src/BaseLink.tsx +77 -0
- package/src/BaseList.tsx +29 -0
- package/src/BaseListAddOn.tsx +10 -0
- package/src/BaseListItem.tsx +117 -0
- package/src/BaseView.tsx +57 -0
- package/src/Box.tsx +20 -0
- package/src/Button.tsx +84 -0
- package/src/Calendar.tsx +125 -0
- package/src/Card.tsx +17 -0
- package/src/Checkbox.tsx +63 -0
- package/src/Circle.tsx +24 -0
- package/src/Column.tsx +12 -0
- package/src/DarkMode.tsx +99 -0
- package/src/DateInput.tsx +63 -0
- package/src/DatePicker.tsx +67 -0
- package/src/DatetimeInput.tsx +71 -0
- package/src/DesignBook.tsx +697 -0
- package/src/Dialog.tsx +144 -0
- package/src/Dropdown.tsx +129 -0
- package/src/Emitter.ts +26 -0
- package/src/FlexLayout.tsx +53 -0
- package/src/Icon.tsx +96 -0
- package/src/IconButton.tsx +66 -0
- package/src/IconLink.tsx +58 -0
- package/src/IconType.ts +787 -0
- package/src/Interactable.tsx +159 -0
- package/src/Link.tsx +86 -0
- package/src/List.tsx +41 -0
- package/src/ListButtonItem.tsx +69 -0
- package/src/ListDivider.tsx +13 -0
- package/src/ListHeaderItem.tsx +45 -0
- package/src/ListItem.tsx +27 -0
- package/src/ListLinkItem.tsx +76 -0
- package/src/ListSpacer.tsx +14 -0
- package/src/OnVisible.tsx +42 -0
- package/src/Popover.tsx +141 -0
- package/src/ProgressBar.tsx +63 -0
- package/src/ProgressCircle.tsx +38 -0
- package/src/Providers.tsx +33 -0
- package/src/RangeInput.tsx +82 -0
- package/src/ResultOrError.ts +15 -0
- package/src/RootView.tsx +55 -0
- package/src/Router.tsx +62 -0
- package/src/RouterState.tsx +154 -0
- package/src/Row.tsx +12 -0
- package/src/StackContext.tsx +52 -0
- package/src/StaticCheckbox.tsx +74 -0
- package/src/Storage.tsx +200 -0
- package/src/Stream.tsx +50 -0
- package/src/Sublist.tsx +62 -0
- package/src/SubmitIconInput.tsx +45 -0
- package/src/Tabs.tsx +103 -0
- package/src/Text.tsx +102 -0
- package/src/TextArea.tsx +45 -0
- package/src/TextInput.tsx +111 -0
- package/src/TextInputWithState.tsx +35 -0
- package/src/TextPairing.tsx +115 -0
- package/src/TimeInput.tsx +109 -0
- package/src/Tooltip.tsx +108 -0
- package/src/aria.ts +72 -0
- package/src/examples/ExampleDialog.tsx +28 -0
- package/src/guid.ts +7 -0
- package/src/hash.ts +21 -0
- package/src/index.ts +65 -0
- package/src/jss.tsx +607 -0
- package/src/numberToBase.ts +52 -0
- package/src/pages/Badge.mdx +30 -0
- package/src/pages/Button.mdx +57 -0
- package/src/pages/Calendar.mdx +60 -0
- package/src/pages/Checkbox.mdx +56 -0
- package/src/pages/Dialog.mdx +32 -0
- package/src/pages/FlexLayout.mdx +77 -0
- package/src/pages/Hashing.mdx +20 -0
- package/src/pages/Icon.mdx +63 -0
- package/src/pages/IconButton.mdx +144 -0
- package/src/pages/Link.mdx +57 -0
- package/src/pages/List.mdx +292 -0
- package/src/pages/ListHeader.mdx +94 -0
- package/src/pages/Popover.mdx +101 -0
- package/src/pages/ProgressBar.mdx +20 -0
- package/src/pages/ProgressCircle.mdx +35 -0
- package/src/pages/RangeInput.mdx +109 -0
- package/src/pages/Tabs.mdx +168 -0
- package/src/pages/Text.mdx +133 -0
- package/src/pages/TextInput.mdx +110 -0
- package/src/pages/TextPairing.mdx +155 -0
- package/src/pages/TimeInput.mdx +73 -0
- package/src/pages/Tooltip.mdx +28 -0
- package/src/pages/_app.tsx +561 -0
- package/src/pages/_document.tsx +30 -0
- package/src/pages/css-in-js.mdx +127 -0
- package/src/pages/index.mdx +58 -0
- package/src/pages/navigation.mdx +56 -0
- package/src/pages/prism.css +3 -0
- package/src/pages/useCookie.mdx +15 -0
- package/src/pages/useKeyboard.mdx +20 -0
- package/src/pages/useNavigation.mdx +30 -0
- package/src/pages/usePromise.mdx +15 -0
- package/src/pages/useRefEffect.mdx +49 -0
- package/src/stateMachineContextFactory.tsx +111 -0
- package/src/useCookie.tsx +89 -0
- package/src/useKeyboard.tsx +43 -0
- package/src/useNavigation.tsx +89 -0
- package/src/usePromise.tsx +18 -0
- package/src/useRefEffect.tsx +18 -0
- package/tsconfig.build.json +23 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Aidos UI
|
|
2
|
+
|
|
3
|
+
This is a React design system library with many utilities and zero dependencies. It was built with the aim to be simple, lightweight and beautiful.
|
|
4
|
+
|
|
5
|
+
- [Why](/#why)
|
|
6
|
+
- [Who is this for](/#who-is-this-for)
|
|
7
|
+
- [Design philosophy](/#design-philosophy)
|
|
8
|
+
- [Installation](/#installation)
|
|
9
|
+
- [How to use](/#how-to-use)
|
|
10
|
+
|
|
11
|
+
## Why?
|
|
12
|
+
|
|
13
|
+
Over the years I have always have many side projects, and many of them needed a UI. I disliked every available library because they had so much code to support many cases I did not care about. Back in 2019 I thought, maybe I could make my own design system, with just enough javascript to do things exactly how I wanted them to be, and so I did. Since then it has changed quite a bit and it is now something I am more or less proud of. It has everything I have ever needed and it is done in the way I find simplest and least convoluted. This is all ultimately very subjective, and that is fine, because the first design decision of this library was that it would be extremely opinionated. With that said, although this library does not lend it self to modification, it does tend to be fairly easy to extend and compose with it. I am now making this documentation with the vague weak conviction that someone out there may benefit from it. I still dislike other design libraries not because they are not capable but becuse they are too general purpose. I wanted this library to be not-general purpose, but if this happens to fit your needs, it should be the lightest and simplest option available. This will not try to solve all your problems but it will solve a few problems really well.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Who is this for?
|
|
18
|
+
|
|
19
|
+
I initially only planned to use this myself so its features and design have so far reflected the things I have been working on. However I keep extending this library, and I think that with more users it may be possible to add more ideas and usecases so that this becomes a really complete system.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Design philosophy
|
|
24
|
+
|
|
25
|
+
1. <b>Opinionated</b>
|
|
26
|
+
|
|
27
|
+
First and foremost, this library is extremely opinionated. This is so because I believe HTML is too low level and error prone, CSS defaults are not beautiful enough, and the web in general too big a toolkit to make simple things work in the way you expect. So, for the sake of simplicity, this library imposes opinions at every step. These opinions will not fit everyone's needs, and that is a sacrifice that can be made for the sake of simplicity.
|
|
28
|
+
|
|
29
|
+
3. <b>Modular</b>
|
|
30
|
+
|
|
31
|
+
There is no limit to the number of features and components that can be added, as long as every piece remains modular, or at most, composed out of its simpler parts. This is important to keep bundle sizes under control and also to keep the API sane. Modular components imply abstractions that do not depend on each other. This helps keep overall complexity low, so that it is simpler to extend the system.
|
|
32
|
+
|
|
33
|
+
3. <b>Accessible</b>
|
|
34
|
+
|
|
35
|
+
By design every component should be accessible, paying attention to keyboard navigation, focusable elements, adding helpful aria properties and following wcag specificaitons as faithfully as possible.
|
|
36
|
+
|
|
37
|
+
4. <b>Dependency free</b>
|
|
38
|
+
|
|
39
|
+
As few dependencies as possible, to keep things light and under control. The only dependency right now is [iconify](https://github.com/iconify/iconify) because I am not able to re-create all icons myself.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
This library can be installed through npm
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install --save simple-ui-core
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## How to use
|
|
54
|
+
|
|
55
|
+
- The `Providers` component somewhere in the application.
|
|
56
|
+
- If the application is running in nextjs, the `JSServerStyles` component has to be used in the \_document `<Head />`, this enables jss to work also server side.
|
|
57
|
+
|
|
58
|
+
---
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { List } from "../List";
|
|
2
|
+
import { ListButtonItem } from "../ListButtonItem";
|
|
3
|
+
|
|
4
|
+
## List navigation
|
|
5
|
+
|
|
6
|
+
Lists support keyboard navigation by default via the `useNavigation` hook. It can be disabled by passing the prop `navigation` and tries to emulate the [grid layout spec](https://www.w3.org/WAI/ARIA/apg/patterns/grid/examples/layout-grids/):
|
|
7
|
+
|
|
8
|
+
<List ariaLabel="example" navigation={true}>
|
|
9
|
+
<ListButtonItem color="secondary" headline="Headline 1" onClick={() => {}} />
|
|
10
|
+
<ListButtonItem color="secondary" headline="Headline 2" onClick={() => {}} />
|
|
11
|
+
<ListButtonItem
|
|
12
|
+
withDivider={false}
|
|
13
|
+
color="secondary"
|
|
14
|
+
headline="Headline 3"
|
|
15
|
+
onClick={() => {}}
|
|
16
|
+
/>
|
|
17
|
+
</List>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<List ariaLabel="example" navigation={false}>
|
|
22
|
+
<ListButtonItem color="secondary" headline="Headline 1" onClick={() => {}} />
|
|
23
|
+
<ListButtonItem color="secondary" headline="Headline 2" onClick={() => {}} />
|
|
24
|
+
<ListButtonItem
|
|
25
|
+
withDivider={false}
|
|
26
|
+
color="secondary"
|
|
27
|
+
headline="Headline 3"
|
|
28
|
+
onClick={() => {}}
|
|
29
|
+
/>
|
|
30
|
+
</List>
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
<List ariaLabel="example" navigation={true}>
|
|
34
|
+
<ListButtonItem color="secondary" headline="Headline 1" onClick={() => {}} />
|
|
35
|
+
<ListButtonItem color="secondary" headline="Headline 2" onClick={() => {}} />
|
|
36
|
+
<ListButtonItem
|
|
37
|
+
withDivider={false}
|
|
38
|
+
color="secondary"
|
|
39
|
+
headline="Headline 3"
|
|
40
|
+
onClick={() => {}}
|
|
41
|
+
/>
|
|
42
|
+
</List>
|
|
43
|
+
|
|
44
|
+
<List ariaLabel="example" navigation={false}>
|
|
45
|
+
<ListButtonItem color="secondary" headline="Headline 1" onClick={() => {}} />
|
|
46
|
+
<ListButtonItem color="secondary" headline="Headline 2" onClick={() => {}} />
|
|
47
|
+
<ListButtonItem
|
|
48
|
+
withDivider={false}
|
|
49
|
+
color="secondary"
|
|
50
|
+
headline="Headline 3"
|
|
51
|
+
onClick={() => {}}
|
|
52
|
+
/>
|
|
53
|
+
</List>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* PrismJS 1.29.0
|
|
2
|
+
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+jsx+tsx+typescript */
|
|
3
|
+
code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# useCookie
|
|
2
|
+
|
|
3
|
+
`useCookie` is a hook that can be used to get acceess to cookies by name, and use them as if they were React component state.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const [darkModeEnabled, setDarkModeEnabled] = useCookie("dark-mode", {
|
|
7
|
+
initialValue: false,
|
|
8
|
+
// loadingValue could be different to initial value for example if we are server rendering,
|
|
9
|
+
// in which case we do not have access to cookies and you may decide to assign another
|
|
10
|
+
// value, like "pending".
|
|
11
|
+
loadingValue: false,
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# useKeyboard
|
|
2
|
+
|
|
3
|
+
This hook can be used to create keyboard shortcuts to make using a website easier and more accessible.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const ref = useKeyboard([
|
|
7
|
+
{
|
|
8
|
+
key: "K",
|
|
9
|
+
metaKey: true,
|
|
10
|
+
action: (root) => root.focus(),
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
key: "Escape",
|
|
14
|
+
onlyWhenFocused: true,
|
|
15
|
+
action: () => {
|
|
16
|
+
setQuery("");
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# useNavigation
|
|
2
|
+
|
|
3
|
+
The `useNavigation` hook is easy to use but complicated under the hood, so I expect there will be situations in which it will break, especially if the HTML markup is not perfectly correct. The gist of it is that it enables keyboard navigation by manipulating the `tabInde` property for all the elements under a certain element (the root). To the 'active' element we assign the `tabIndex` 0, while every other elements gets assigned `tabIndex` -1. This means that the whole area will be a single tab stop. Then, when we detect the arrow down or right we push change the active element by changing the `tabInde` and calling `element.focus()`.
|
|
4
|
+
|
|
5
|
+
This is following the [grid layout pattern](https://www.w3.org/WAI/ARIA/apg/patterns/grid/examples/layout-grids/).
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
export function List() {
|
|
9
|
+
const rootRef = useNavigation();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ul aria-label={ariaLabel} ref={rootRef}>
|
|
13
|
+
<li>
|
|
14
|
+
<button>Button 1</button>
|
|
15
|
+
</li>
|
|
16
|
+
<li>
|
|
17
|
+
<button>Button 2</button>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<button>Button 3</button>
|
|
21
|
+
</li>
|
|
22
|
+
<li>
|
|
23
|
+
<button>Button 4</button>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# usePromise
|
|
2
|
+
|
|
3
|
+
This hook can be used to unwrap a promsie value, with an initial value that can be assigned while the promise has not resolved.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
function Foo() {
|
|
7
|
+
const [result, error] = usePromise(Promise.resolve(10));
|
|
8
|
+
|
|
9
|
+
if (error != null) {
|
|
10
|
+
return <p>{error}</p>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return <span>{result}</span>;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# useRefEffect
|
|
2
|
+
|
|
3
|
+
This effect is useful when you want to run an effect for a component once only (`useEffect` does not reliably do this). This implies that this component cannot have dependencies in the way other hooks do. Other hooks in this library are implemented using this.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { useRefEffect } from "./useRefEffect";
|
|
7
|
+
|
|
8
|
+
export type KeyboardShortcut<T> = {
|
|
9
|
+
key: string;
|
|
10
|
+
metaKey?: boolean;
|
|
11
|
+
ctrlKey?: boolean;
|
|
12
|
+
action: (root: T) => void;
|
|
13
|
+
onlyWhenFocused?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function useKeyboard<T extends HTMLElement>(
|
|
17
|
+
shortcuts: Array<KeyboardShortcut<T>>
|
|
18
|
+
) {
|
|
19
|
+
return useRefEffect<T>((root: T) => {
|
|
20
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
21
|
+
for (const {
|
|
22
|
+
metaKey,
|
|
23
|
+
key,
|
|
24
|
+
action,
|
|
25
|
+
ctrlKey,
|
|
26
|
+
onlyWhenFocused,
|
|
27
|
+
} of shortcuts) {
|
|
28
|
+
if (metaKey && e.metaKey !== true) {
|
|
29
|
+
continue;
|
|
30
|
+
} else if (ctrlKey && e.ctrlKey !== true) {
|
|
31
|
+
continue;
|
|
32
|
+
} else if (onlyWhenFocused && document.activeElement !== root) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (e.key.toLowerCase() === key.toLowerCase()) {
|
|
37
|
+
action(root);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
window.addEventListener("keydown", onKeyDown);
|
|
43
|
+
|
|
44
|
+
return () => {
|
|
45
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
ReactNode,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
} from "react";
|
|
8
|
+
import { Subscribe, createEmitter, Callback } from "./Emitter";
|
|
9
|
+
|
|
10
|
+
export type Reducer<State, Context> = <Data extends any>({
|
|
11
|
+
state,
|
|
12
|
+
context,
|
|
13
|
+
data,
|
|
14
|
+
}: {
|
|
15
|
+
state: State;
|
|
16
|
+
context: Context;
|
|
17
|
+
data: Data;
|
|
18
|
+
}) => { state: State; context: Context };
|
|
19
|
+
|
|
20
|
+
type StateMachineConfig<State, Transition, Context> = {
|
|
21
|
+
states: {
|
|
22
|
+
[state: string]: {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
on: { [transition: Transition]: Reducer<State, Context> };
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
context: Context;
|
|
28
|
+
state: State;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type Send = <Transition, Data>(transition: Transition, data: Data) => void;
|
|
32
|
+
|
|
33
|
+
type StateMachineContextType<State, Context> = {
|
|
34
|
+
subscribe: Subscribe<{ state: State; context: Context }>;
|
|
35
|
+
send: Send;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function stateMachineContextFactory<State, Transition, Context>(
|
|
39
|
+
stateMachineConfig: StateMachineConfig<State, Transition, Context>
|
|
40
|
+
) {
|
|
41
|
+
const StateMachineContext = React.createContext<
|
|
42
|
+
StateMachineContextType<State, Context>
|
|
43
|
+
>({
|
|
44
|
+
subscribe: () => {
|
|
45
|
+
throw new Error("Not implemented");
|
|
46
|
+
},
|
|
47
|
+
send: (_) => {
|
|
48
|
+
throw new Error("Not implemented");
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
type StateMachineState = {
|
|
53
|
+
state: State;
|
|
54
|
+
context: Context;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function Provider({ children }: { children: ReactNode }) {
|
|
58
|
+
const stateMachineRef = useRef<StateMachineState>({
|
|
59
|
+
state: stateMachineConfig.state,
|
|
60
|
+
context: stateMachineConfig.context,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const emitterRef = useRef(
|
|
64
|
+
createEmitter<{ state: State; context: Context }>()
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const subscribe = useCallback((callback: Callback<StateMachineState>) => {
|
|
68
|
+
const unsbuscribe = emitterRef.current.subscribe(callback);
|
|
69
|
+
callback(stateMachineRef.current);
|
|
70
|
+
|
|
71
|
+
return unsbuscribe;
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
const send = useCallback(
|
|
75
|
+
<Transition, Data extends any>(transition: Transition, data: Data) => {
|
|
76
|
+
const state = stateMachineRef.current.state;
|
|
77
|
+
// @ts-ignore I don't know how to fix this
|
|
78
|
+
const transitions = stateMachineConfig.states[state].on;
|
|
79
|
+
const reducer: Reducer<State, Context> = transitions[transition];
|
|
80
|
+
|
|
81
|
+
if (!reducer) {
|
|
82
|
+
// No transition available in the current state, so no update needed
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const newState = reducer({
|
|
87
|
+
...stateMachineRef.current,
|
|
88
|
+
data,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
stateMachineRef.current = newState;
|
|
92
|
+
emitterRef.current.emit(newState);
|
|
93
|
+
},
|
|
94
|
+
[]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const value = useMemo(() => ({ subscribe, send }), [subscribe, send]);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<StateMachineContext.Provider value={value}>
|
|
101
|
+
{children}
|
|
102
|
+
</StateMachineContext.Provider>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function useStateMachine() {
|
|
107
|
+
return useContext(StateMachineContext);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { Provider, useStateMachine };
|
|
111
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
export function hasCookie(key: string): boolean {
|
|
4
|
+
return (
|
|
5
|
+
document.cookie
|
|
6
|
+
.split(";")
|
|
7
|
+
.map((c) => c.trim())
|
|
8
|
+
.filter((c) => c.startsWith(`${key}=`)).length > 0
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getCookie<T>(
|
|
13
|
+
key: string,
|
|
14
|
+
deserialize: (s: string) => T = JSON.parse
|
|
15
|
+
): T {
|
|
16
|
+
return document.cookie
|
|
17
|
+
.split(";")
|
|
18
|
+
.map((c) => c.trim())
|
|
19
|
+
.filter((c) => c.startsWith(`${key}=`))
|
|
20
|
+
.map((s) => s.split("=")[1])
|
|
21
|
+
.map((s) => deserialize(s))
|
|
22
|
+
.pop();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useCookie<T, L>(
|
|
26
|
+
key: string,
|
|
27
|
+
{
|
|
28
|
+
initialValue = null,
|
|
29
|
+
loadingValue,
|
|
30
|
+
serialize = JSON.stringify,
|
|
31
|
+
deserialize = JSON.parse,
|
|
32
|
+
maxAge = 60 * 60 * 24 * 365,
|
|
33
|
+
}: {
|
|
34
|
+
initialValue: T;
|
|
35
|
+
loadingValue: L;
|
|
36
|
+
serialize?: (t: T) => string;
|
|
37
|
+
deserialize?: (s: string) => T;
|
|
38
|
+
maxAge?: number;
|
|
39
|
+
}
|
|
40
|
+
): [T | L, (t: T | ((prevValue: T | L) => T)) => void] {
|
|
41
|
+
const initializationRef = useRef(false);
|
|
42
|
+
const [cookie, setCookie] = useState<T | L>(() => {
|
|
43
|
+
if (typeof window !== "undefined") {
|
|
44
|
+
const hasPersistedCookie = hasCookie(key);
|
|
45
|
+
if (hasPersistedCookie) {
|
|
46
|
+
return getCookie(key, deserialize);
|
|
47
|
+
} else {
|
|
48
|
+
return loadingValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return loadingValue;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (initializationRef.current === true) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const hasPersistedCookie = hasCookie(key);
|
|
61
|
+
|
|
62
|
+
if (hasPersistedCookie) {
|
|
63
|
+
const persistedCookie = getCookie(key, deserialize);
|
|
64
|
+
setCookie(persistedCookie);
|
|
65
|
+
} else {
|
|
66
|
+
document.cookie = `${key}=${serialize(initialValue)}; max-age=${maxAge};`;
|
|
67
|
+
setCookie(initialValue);
|
|
68
|
+
}
|
|
69
|
+
initializationRef.current = true;
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
return [
|
|
73
|
+
cookie,
|
|
74
|
+
useCallback((t: T | ((prevValue: T | L) => T)) => {
|
|
75
|
+
if (typeof t === "function") {
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
const callback: (prevValue: T | L) => T = t;
|
|
78
|
+
setCookie((oldCookie) => {
|
|
79
|
+
const newValue = callback(oldCookie);
|
|
80
|
+
document.cookie = `${key}=${serialize(newValue)}; max-age=${maxAge};`;
|
|
81
|
+
return newValue;
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
setCookie(t);
|
|
85
|
+
document.cookie = `${key}=${serialize(t)}; max-age=${maxAge};`;
|
|
86
|
+
}
|
|
87
|
+
}, []),
|
|
88
|
+
];
|
|
89
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRefEffect } from "./useRefEffect";
|
|
2
|
+
|
|
3
|
+
export type KeyboardShortcut<T> = {
|
|
4
|
+
key: string;
|
|
5
|
+
metaKey?: boolean;
|
|
6
|
+
ctrlKey?: boolean;
|
|
7
|
+
action: (root: T) => void;
|
|
8
|
+
onlyWhenFocused?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function useKeyboard<T extends HTMLElement>(
|
|
12
|
+
shortcuts: Array<KeyboardShortcut<T>>
|
|
13
|
+
) {
|
|
14
|
+
return useRefEffect<T>((root: T) => {
|
|
15
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
16
|
+
for (const {
|
|
17
|
+
metaKey,
|
|
18
|
+
key,
|
|
19
|
+
action,
|
|
20
|
+
ctrlKey,
|
|
21
|
+
onlyWhenFocused,
|
|
22
|
+
} of shortcuts) {
|
|
23
|
+
if (metaKey && e.metaKey !== true) {
|
|
24
|
+
continue;
|
|
25
|
+
} else if (ctrlKey && e.ctrlKey !== true) {
|
|
26
|
+
continue;
|
|
27
|
+
} else if (onlyWhenFocused && document.activeElement !== root) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (e.key.toLowerCase() === key.toLowerCase()) {
|
|
32
|
+
action(root);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
window.addEventListener("keydown", onKeyDown);
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useRef, useCallback, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { queryFocusables, focusElement, normalizeElements } from "./aria";
|
|
4
|
+
import { useRefEffect } from "./useRefEffect";
|
|
5
|
+
|
|
6
|
+
export function useNavigation({
|
|
7
|
+
autofocus = false,
|
|
8
|
+
rowLength = 1,
|
|
9
|
+
enabled = true,
|
|
10
|
+
} = {}) {
|
|
11
|
+
return useRefEffect((root: HTMLElement) => {
|
|
12
|
+
if (!enabled) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let index = 0;
|
|
17
|
+
|
|
18
|
+
const elements = queryFocusables(root);
|
|
19
|
+
|
|
20
|
+
if (elements.length === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (elements.length !== 0 && autofocus) {
|
|
25
|
+
focusElement(elements, index);
|
|
26
|
+
} else {
|
|
27
|
+
normalizeElements(elements, index);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
31
|
+
const elements = queryFocusables(root);
|
|
32
|
+
|
|
33
|
+
if (elements.length === 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let newIndex: number = -1;
|
|
38
|
+
|
|
39
|
+
if (e.code === "ArrowUp") {
|
|
40
|
+
if (index - rowLength < 0) {
|
|
41
|
+
newIndex = elements.length - (elements.length % rowLength) + index;
|
|
42
|
+
} else {
|
|
43
|
+
newIndex = index - rowLength;
|
|
44
|
+
}
|
|
45
|
+
} else if (e.code === "ArrowLeft") {
|
|
46
|
+
if (index <= 0) {
|
|
47
|
+
newIndex = elements.length - 1;
|
|
48
|
+
} else {
|
|
49
|
+
newIndex = index - 1;
|
|
50
|
+
}
|
|
51
|
+
} else if (e.code === "ArrowRight") {
|
|
52
|
+
if (index >= elements.length - 1) {
|
|
53
|
+
newIndex = 0;
|
|
54
|
+
} else {
|
|
55
|
+
newIndex = index + 1;
|
|
56
|
+
}
|
|
57
|
+
} else if (e.code === "ArrowDown") {
|
|
58
|
+
if (index + rowLength > elements.length - 1) {
|
|
59
|
+
newIndex = (index + rowLength) % rowLength;
|
|
60
|
+
} else {
|
|
61
|
+
newIndex = index + rowLength;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (newIndex !== -1 && index !== newIndex) {
|
|
66
|
+
index = newIndex;
|
|
67
|
+
focusElement(elements, index);
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
root.addEventListener("keydown", onKeyDown);
|
|
74
|
+
|
|
75
|
+
const observer = new MutationObserver((mutationList) => {
|
|
76
|
+
if (mutationList.filter((m) => m.type === "childList").length > 0) {
|
|
77
|
+
const elements = queryFocusables(root);
|
|
78
|
+
if (elements.length > 0) {
|
|
79
|
+
normalizeElements(elements, index);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
observer.observe(root, { childList: true });
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
root.removeEventListener("keydown", onKeyDown);
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export function usePromise<T>(
|
|
4
|
+
promiseFactory: () => Promise<T>,
|
|
5
|
+
inputs: Array<any>,
|
|
6
|
+
initialValue: T
|
|
7
|
+
): [T | null, any] {
|
|
8
|
+
const [value, setValue] = useState(initialValue);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
promiseFactory()
|
|
13
|
+
.then((value) => setValue(value))
|
|
14
|
+
.catch((error) => setError(error));
|
|
15
|
+
}, inputs);
|
|
16
|
+
|
|
17
|
+
return [value, error];
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRef, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
export function useRefEffect<T>(
|
|
4
|
+
callback: (root: T) => (() => void) | void
|
|
5
|
+
): (root: T) => void {
|
|
6
|
+
const unsubscribeRef = useRef<(() => void) | void>(null);
|
|
7
|
+
|
|
8
|
+
const refCallback = useCallback((root: T | null) => {
|
|
9
|
+
if (root === null) {
|
|
10
|
+
unsubscribeRef.current && unsubscribeRef.current();
|
|
11
|
+
} else {
|
|
12
|
+
const unsubscribe = callback(root);
|
|
13
|
+
unsubscribeRef.current = unsubscribe;
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
return refCallback;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["dom", "dom.iterable", "es2020", "es2020.string"],
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist/",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"strict": false,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"noEmit": false,
|
|
17
|
+
"incremental": false,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["src/*"],
|
|
22
|
+
"exclude": ["node_modules"]
|
|
23
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["dom", "dom.iterable", "es2020", "es2020.string"],
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist/",
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"strict": false,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"noEmit": false,
|
|
17
|
+
"incremental": false,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["src/*"],
|
|
22
|
+
"exclude": ["node_modules"]
|
|
23
|
+
}
|