@helpwave/hightide 0.0.8 → 0.0.11
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/README.md +1 -1
- package/dist/coloring/shading.d.ts +2 -0
- package/dist/coloring/shading.js +40 -0
- package/dist/coloring/types.d.ts +11 -0
- package/dist/coloring/types.js +1 -0
- package/dist/components/Avatar.d.ts +14 -0
- package/dist/components/Avatar.js +35 -0
- package/dist/components/AvatarGroup.d.ts +10 -0
- package/dist/components/AvatarGroup.js +13 -0
- package/dist/components/BreadCrumb.d.ts +16 -0
- package/dist/components/BreadCrumb.js +12 -0
- package/dist/components/Button.d.ts +41 -0
- package/dist/components/Button.js +84 -0
- package/dist/components/ChipList.d.ts +21 -0
- package/dist/components/ChipList.js +38 -0
- package/dist/components/Circle.d.ts +6 -0
- package/dist/components/Circle.js +10 -0
- package/dist/components/ErrorComponent.d.ts +13 -0
- package/dist/components/ErrorComponent.js +19 -0
- package/dist/components/Expandable.d.ts +30 -0
- package/dist/components/Expandable.js +16 -0
- package/dist/components/HelpwaveBadge.d.ts +11 -0
- package/dist/components/HelpwaveBadge.js +14 -0
- package/dist/components/HideableContentSection.d.ts +10 -0
- package/dist/components/HideableContentSection.js +15 -0
- package/dist/components/InputGroup.d.ts +13 -0
- package/dist/components/InputGroup.js +33 -0
- package/dist/components/LoadingAndErrorComponent.d.ts +17 -0
- package/dist/components/LoadingAndErrorComponent.js +25 -0
- package/dist/components/LoadingAnimation.d.ts +13 -0
- package/dist/components/LoadingAnimation.js +19 -0
- package/dist/components/LoadingButton.d.ts +6 -0
- package/dist/components/LoadingButton.js +10 -0
- package/dist/components/MarkdownInterpreter.d.ts +25 -0
- package/dist/components/MarkdownInterpreter.js +190 -0
- package/dist/components/Pagination.d.ts +14 -0
- package/dist/components/Pagination.js +25 -0
- package/dist/components/Profile.d.ts +28 -0
- package/dist/components/Profile.js +45 -0
- package/dist/components/ProgressIndicator.d.ts +21 -0
- package/dist/components/ProgressIndicator.js +24 -0
- package/dist/components/Ring.d.ts +31 -0
- package/dist/components/Ring.js +113 -0
- package/dist/components/SearchableList.d.ts +18 -0
- package/dist/components/SearchableList.js +27 -0
- package/dist/components/SortButton.d.ts +10 -0
- package/dist/components/SortButton.js +9 -0
- package/dist/components/Span.js +1 -0
- package/dist/components/StepperBar.d.ts +23 -0
- package/dist/components/StepperBar.js +47 -0
- package/dist/components/Table.d.ts +87 -0
- package/dist/components/Table.js +187 -0
- package/dist/components/TechRadar.d.ts +36 -0
- package/dist/components/TechRadar.js +191 -0
- package/dist/components/TextImage.d.ts +20 -0
- package/dist/components/TextImage.js +31 -0
- package/dist/components/TimeDisplay.d.ts +30 -0
- package/dist/components/TimeDisplay.js +83 -0
- package/dist/components/Tooltip.d.ts +34 -0
- package/dist/components/Tooltip.js +38 -0
- package/dist/components/VerticalDivider.d.ts +11 -0
- package/dist/components/VerticalDivider.js +7 -0
- package/dist/components/date/DatePicker.d.ts +26 -0
- package/dist/components/date/DatePicker.js +58 -0
- package/dist/components/date/DayPicker.d.ts +16 -0
- package/dist/components/date/DayPicker.js +37 -0
- package/dist/components/date/TimePicker.d.ts +12 -0
- package/dist/components/date/TimePicker.js +79 -0
- package/dist/components/date/YearMonthPicker.d.ts +11 -0
- package/dist/components/date/YearMonthPicker.js +59 -0
- package/dist/components/examples/InputGroupExample.d.ts +6 -0
- package/dist/components/examples/InputGroupExample.js +21 -0
- package/dist/components/examples/MultiSelectExample.d.ts +7 -0
- package/dist/components/examples/MultiSelectExample.js +27 -0
- package/dist/components/examples/SearchableSelectExample.d.ts +6 -0
- package/dist/components/examples/SearchableSelectExample.js +17 -0
- package/dist/components/examples/SelectExample.d.ts +4 -0
- package/dist/components/examples/SelectExample.js +15 -0
- package/dist/components/examples/StackingModals.d.ts +4 -0
- package/dist/components/examples/StackingModals.js +15 -0
- package/dist/components/examples/TableExample.d.ts +9 -0
- package/dist/components/examples/TableExample.js +92 -0
- package/dist/components/examples/TextareaExample.d.ts +6 -0
- package/dist/components/examples/TextareaExample.js +10 -0
- package/dist/components/examples/TileExample.d.ts +9 -0
- package/dist/components/examples/TileExample.js +9 -0
- package/dist/components/examples/Title.js +1 -0
- package/dist/components/examples/date/DateTimePickerExample.d.ts +10 -0
- package/dist/components/examples/date/DateTimePickerExample.js +21 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.js +13 -0
- package/dist/components/examples/properties/DatePropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/DatePropertyExample.js +23 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.js +16 -0
- package/dist/components/examples/properties/NumberPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/NumberPropertyExample.js +13 -0
- package/dist/components/examples/properties/SelectPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/SelectPropertyExample.js +18 -0
- package/dist/components/examples/properties/TextPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/TextPropertyExample.js +13 -0
- package/dist/components/icons/Helpwave.d.ts +10 -0
- package/dist/components/icons/Helpwave.js +20 -0
- package/dist/components/icons/Tag.d.ts +10 -0
- package/dist/components/icons/Tag.js +12 -0
- package/dist/components/layout/Carousel.d.ts +22 -0
- package/dist/components/layout/Carousel.js +233 -0
- package/dist/components/layout/DividerInserter.d.ts +11 -0
- package/dist/components/layout/DividerInserter.js +20 -0
- package/dist/components/layout/FAQSection.d.ts +23 -0
- package/dist/components/layout/FAQSection.js +14 -0
- package/dist/components/layout/Tile.d.ts +34 -0
- package/dist/components/layout/Tile.js +18 -0
- package/dist/components/modals/ConfirmDialog.d.ts +34 -0
- package/dist/components/modals/ConfirmDialog.js +31 -0
- package/dist/components/modals/DiscardChangesDialog.d.ts +19 -0
- package/dist/components/modals/DiscardChangesDialog.js +24 -0
- package/dist/components/modals/InputModal.d.ts +9 -0
- package/dist/components/modals/InputModal.js +9 -0
- package/dist/components/modals/LanguageModal.d.ts +17 -0
- package/dist/components/modals/LanguageModal.js +35 -0
- package/dist/components/modals/Modal.d.ts +38 -0
- package/dist/components/modals/Modal.js +57 -0
- package/dist/components/modals/ModalRegister.d.ts +11 -0
- package/dist/components/modals/ModalRegister.js +28 -0
- package/dist/components/properties/CheckboxProperty.d.ts +15 -0
- package/dist/components/properties/CheckboxProperty.js +27 -0
- package/dist/components/properties/DateProperty.d.ts +11 -0
- package/dist/components/properties/DateProperty.js +22 -0
- package/dist/components/properties/MultiSelectProperty.d.ts +12 -0
- package/dist/components/properties/MultiSelectProperty.js +33 -0
- package/dist/components/properties/NumberProperty.d.ts +16 -0
- package/dist/components/properties/NumberProperty.js +42 -0
- package/dist/components/properties/PropertyBase.d.ts +23 -0
- package/dist/components/properties/PropertyBase.js +27 -0
- package/dist/components/properties/SelectProperty.d.ts +12 -0
- package/dist/components/properties/SelectProperty.js +22 -0
- package/dist/components/properties/TextProperty.d.ts +15 -0
- package/dist/components/properties/TextProperty.js +37 -0
- package/dist/components/user-input/Checkbox.d.ts +37 -0
- package/dist/components/user-input/Checkbox.js +63 -0
- package/dist/components/user-input/DateAndTimePicker.d.ts +39 -0
- package/dist/components/user-input/DateAndTimePicker.js +65 -0
- package/dist/components/user-input/Input.d.ts +61 -0
- package/dist/components/user-input/Input.js +61 -0
- package/dist/components/user-input/Label.d.ts +12 -0
- package/dist/components/user-input/Label.js +12 -0
- package/dist/components/user-input/Menu.d.ts +21 -0
- package/dist/components/user-input/Menu.js +26 -0
- package/dist/components/user-input/MultiSelect.d.ts +39 -0
- package/dist/components/user-input/MultiSelect.js +57 -0
- package/dist/components/user-input/ScrollPicker.d.ts +11 -0
- package/dist/components/user-input/ScrollPicker.js +151 -0
- package/dist/components/user-input/SearchableSelect.d.ts +8 -0
- package/dist/components/user-input/SearchableSelect.js +14 -0
- package/dist/components/user-input/Select.d.ts +32 -0
- package/dist/components/user-input/Select.js +48 -0
- package/dist/components/user-input/Textarea.d.ts +20 -0
- package/dist/components/user-input/Textarea.js +33 -0
- package/dist/components/user-input/ToggleableInput.d.ts +32 -0
- package/dist/components/user-input/ToggleableInput.js +40 -0
- package/{globals.css → dist/css/globals.css} +1 -1
- package/dist/hooks/useHoverState.d.ts +40 -0
- package/dist/hooks/useHoverState.js +46 -0
- package/dist/hooks/useLanguage.d.ts +17 -0
- package/dist/hooks/useLanguage.js +51 -0
- package/dist/hooks/useLocalStorage.d.ts +4 -0
- package/dist/hooks/useLocalStorage.js +24 -0
- package/dist/hooks/useOutsideClick.d.ts +2 -0
- package/dist/hooks/useOutsideClick.js +22 -0
- package/dist/hooks/useSaveDelay.d.ts +5 -0
- package/dist/hooks/useSaveDelay.js +41 -0
- package/dist/hooks/useTheme.d.ts +16 -0
- package/dist/hooks/useTheme.js +32 -0
- package/dist/hooks/useTranslation.d.ts +24 -0
- package/dist/hooks/useTranslation.js +11 -0
- package/dist/util/array.d.ts +23 -0
- package/dist/util/array.js +103 -0
- package/{util/builder.ts → dist/util/builder.d.ts} +1 -4
- package/dist/util/builder.js +9 -0
- package/dist/util/date.d.ts +28 -0
- package/dist/util/date.js +133 -0
- package/dist/util/easeFunctions.d.ts +9 -0
- package/dist/util/easeFunctions.js +30 -0
- package/dist/util/emailValidation.d.ts +1 -0
- package/dist/util/emailValidation.js +3 -0
- package/dist/util/loopingArray.d.ts +23 -0
- package/dist/util/loopingArray.js +67 -0
- package/dist/util/math.d.ts +1 -0
- package/dist/util/math.js +3 -0
- package/dist/util/news.d.ts +98 -0
- package/dist/util/news.js +27 -0
- package/dist/util/noop.d.ts +1 -0
- package/dist/util/noop.js +1 -0
- package/{util/simpleSearch.ts → dist/util/simpleSearch.d.ts} +4 -21
- package/dist/util/simpleSearch.js +62 -0
- package/dist/util/storage.d.ts +15 -0
- package/dist/util/storage.js +32 -0
- package/dist/util/types.d.ts +1 -0
- package/dist/util/types.js +1 -0
- package/package.json +7 -8
- package/coloring/shading.ts +0 -46
- package/coloring/types.ts +0 -13
- package/components/Avatar.tsx +0 -58
- package/components/AvatarGroup.tsx +0 -48
- package/components/BreadCrumb.tsx +0 -35
- package/components/Button.tsx +0 -236
- package/components/ChipList.tsx +0 -89
- package/components/Circle.tsx +0 -27
- package/components/ErrorComponent.tsx +0 -40
- package/components/Expandable.tsx +0 -61
- package/components/HelpwaveBadge.tsx +0 -35
- package/components/HideableContentSection.tsx +0 -43
- package/components/InputGroup.tsx +0 -72
- package/components/LoadingAndErrorComponent.tsx +0 -47
- package/components/LoadingAnimation.tsx +0 -40
- package/components/LoadingButton.tsx +0 -27
- package/components/MarkdownInterpreter.tsx +0 -278
- package/components/Pagination.tsx +0 -65
- package/components/Profile.tsx +0 -124
- package/components/ProgressIndicator.tsx +0 -58
- package/components/Ring.tsx +0 -286
- package/components/SearchableList.tsx +0 -69
- package/components/SortButton.tsx +0 -33
- package/components/StepperBar.tsx +0 -124
- package/components/Table.tsx +0 -330
- package/components/TechRadar.tsx +0 -247
- package/components/TextImage.tsx +0 -86
- package/components/TimeDisplay.tsx +0 -121
- package/components/Tooltip.tsx +0 -92
- package/components/VerticalDivider.tsx +0 -51
- package/components/date/DatePicker.tsx +0 -164
- package/components/date/DayPicker.tsx +0 -95
- package/components/date/TimePicker.tsx +0 -167
- package/components/date/YearMonthPicker.tsx +0 -130
- package/components/examples/InputGroupExample.tsx +0 -58
- package/components/examples/MultiSelectExample.tsx +0 -57
- package/components/examples/SearchableSelectExample.tsx +0 -34
- package/components/examples/SelectExample.tsx +0 -28
- package/components/examples/StackingModals.tsx +0 -54
- package/components/examples/TableExample.tsx +0 -159
- package/components/examples/TextareaExample.tsx +0 -23
- package/components/examples/TileExample.tsx +0 -25
- package/components/examples/date/DateTimePickerExample.tsx +0 -53
- package/components/examples/properties/CheckboxPropertyExample.tsx +0 -29
- package/components/examples/properties/DatePropertyExample.tsx +0 -44
- package/components/examples/properties/MultiSelectPropertyExample.tsx +0 -39
- package/components/examples/properties/NumberPropertyExample.tsx +0 -28
- package/components/examples/properties/SelectPropertyExample.tsx +0 -39
- package/components/examples/properties/TextPropertyExample.tsx +0 -30
- package/components/icons/Helpwave.tsx +0 -51
- package/components/icons/Tag.tsx +0 -29
- package/components/layout/Carousel.tsx +0 -396
- package/components/layout/DividerInserter.tsx +0 -37
- package/components/layout/FAQSection.tsx +0 -57
- package/components/layout/Tile.tsx +0 -67
- package/components/modals/ConfirmDialog.tsx +0 -105
- package/components/modals/DiscardChangesDialog.tsx +0 -71
- package/components/modals/InputModal.tsx +0 -26
- package/components/modals/LanguageModal.tsx +0 -76
- package/components/modals/Modal.tsx +0 -149
- package/components/modals/ModalRegister.tsx +0 -45
- package/components/properties/CheckboxProperty.tsx +0 -62
- package/components/properties/DateProperty.tsx +0 -58
- package/components/properties/MultiSelectProperty.tsx +0 -82
- package/components/properties/NumberProperty.tsx +0 -86
- package/components/properties/PropertyBase.tsx +0 -84
- package/components/properties/SelectProperty.tsx +0 -67
- package/components/properties/TextProperty.tsx +0 -81
- package/components/user-input/Checkbox.tsx +0 -139
- package/components/user-input/DateAndTimePicker.tsx +0 -156
- package/components/user-input/Input.tsx +0 -192
- package/components/user-input/Label.tsx +0 -32
- package/components/user-input/Menu.tsx +0 -75
- package/components/user-input/MultiSelect.tsx +0 -158
- package/components/user-input/ScrollPicker.tsx +0 -240
- package/components/user-input/SearchableSelect.tsx +0 -36
- package/components/user-input/Select.tsx +0 -132
- package/components/user-input/Textarea.tsx +0 -86
- package/components/user-input/ToggleableInput.tsx +0 -115
- package/hooks/useHoverState.ts +0 -88
- package/hooks/useLanguage.tsx +0 -78
- package/hooks/useLocalStorage.tsx +0 -33
- package/hooks/useOutsideClick.ts +0 -25
- package/hooks/useSaveDelay.ts +0 -46
- package/hooks/useTheme.tsx +0 -57
- package/hooks/useTranslation.ts +0 -43
- package/index.ts +0 -0
- package/util/array.ts +0 -115
- package/util/date.ts +0 -180
- package/util/easeFunctions.ts +0 -37
- package/util/emailValidation.ts +0 -3
- package/util/loopingArray.ts +0 -94
- package/util/math.ts +0 -3
- package/util/news.ts +0 -43
- package/util/noop.ts +0 -1
- package/util/storage.ts +0 -37
- package/util/types.ts +0 -4
- /package/{components/Span.tsx → dist/components/Span.d.ts} +0 -0
- /package/{components/examples/Title.tsx → dist/components/examples/Title.d.ts} +0 -0
package/hooks/useLanguage.tsx
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'
|
|
2
|
-
import { createContext, useContext, useEffect, useState } from 'react'
|
|
3
|
-
import useLocalStorage from './useLocalStorage'
|
|
4
|
-
|
|
5
|
-
export const languages = ['en', 'de'] as const
|
|
6
|
-
export type Languages = typeof languages[number]
|
|
7
|
-
export const languagesLocalNames: Record<Languages, string> = {
|
|
8
|
-
en: 'English',
|
|
9
|
-
de: 'Deutsch',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const DEFAULT_LANGUAGE = 'en'
|
|
13
|
-
|
|
14
|
-
export type LanguageContextValue = {
|
|
15
|
-
language: Languages,
|
|
16
|
-
setLanguage: Dispatch<SetStateAction<Languages>>,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const LanguageContext = createContext<LanguageContextValue>({ language: DEFAULT_LANGUAGE, setLanguage: (v) => v })
|
|
20
|
-
|
|
21
|
-
export const useLanguage = () => useContext(LanguageContext)
|
|
22
|
-
|
|
23
|
-
export const useLocale = (overWriteLanguage?: Languages) => {
|
|
24
|
-
const { language } = useLanguage()
|
|
25
|
-
const mapping: Record<Languages, string> = {
|
|
26
|
-
en: 'en-US',
|
|
27
|
-
de: 'de-DE'
|
|
28
|
-
}
|
|
29
|
-
return mapping[overWriteLanguage ?? language]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type ProvideLanguageProps = {
|
|
33
|
-
initialLanguage?: Languages,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const ProvideLanguage = ({ initialLanguage, children }: PropsWithChildren<ProvideLanguageProps>) => {
|
|
37
|
-
const [language, setLanguage] = useState<Languages>(initialLanguage ?? DEFAULT_LANGUAGE)
|
|
38
|
-
const [storedLanguage, setStoredLanguage] = useLocalStorage<Languages>('language', initialLanguage ?? DEFAULT_LANGUAGE)
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if(language !== initialLanguage && initialLanguage){
|
|
42
|
-
console.warn('LanguageProvider initial state changed: Prefer using useLanguages\'s setLanguage instead')
|
|
43
|
-
setLanguage(initialLanguage)
|
|
44
|
-
}
|
|
45
|
-
}, [initialLanguage]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
// TODO set locale of html tag here as well
|
|
49
|
-
setStoredLanguage(language)
|
|
50
|
-
}, [language, setStoredLanguage])
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (storedLanguage !== null) {
|
|
54
|
-
setLanguage(storedLanguage)
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const languagesToTestAgainst = Object.values(languages)
|
|
59
|
-
|
|
60
|
-
const matchingBrowserLanguages = window.navigator.languages
|
|
61
|
-
.map(language => languagesToTestAgainst.find((test) => language === test || language.split('-')[0] === test))
|
|
62
|
-
.filter(entry => entry !== undefined)
|
|
63
|
-
|
|
64
|
-
if (matchingBrowserLanguages.length === 0) return
|
|
65
|
-
|
|
66
|
-
const firstMatch = matchingBrowserLanguages[0] as Languages
|
|
67
|
-
setLanguage(firstMatch)
|
|
68
|
-
}, []) // eslint-disable-line react-hooks/exhaustive-deps
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<LanguageContext.Provider value={{
|
|
72
|
-
language,
|
|
73
|
-
setLanguage
|
|
74
|
-
}}>
|
|
75
|
-
{children}
|
|
76
|
-
</LanguageContext.Provider>
|
|
77
|
-
)
|
|
78
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react'
|
|
2
|
-
import { useCallback, useEffect, useState } from 'react'
|
|
3
|
-
import { LocalStorageService } from '../util/storage'
|
|
4
|
-
|
|
5
|
-
type SetValue<T> = Dispatch<SetStateAction<T>>
|
|
6
|
-
const useLocalStorage = <T, >(key: string, initValue: T): [T, SetValue<T>] => {
|
|
7
|
-
const get = useCallback((): T => {
|
|
8
|
-
if (typeof window === 'undefined') {
|
|
9
|
-
return initValue
|
|
10
|
-
}
|
|
11
|
-
const storageService = new LocalStorageService()
|
|
12
|
-
const value = storageService.get<T>(key)
|
|
13
|
-
return value || initValue
|
|
14
|
-
}, [initValue, key])
|
|
15
|
-
|
|
16
|
-
const [storedValue, setStoredValue] = useState<T>(get)
|
|
17
|
-
|
|
18
|
-
const setValue: SetValue<T> = useCallback(value => {
|
|
19
|
-
const newValue = value instanceof Function ? value(storedValue) : value
|
|
20
|
-
const storageService = new LocalStorageService()
|
|
21
|
-
storageService.set(key, value)
|
|
22
|
-
|
|
23
|
-
setStoredValue(newValue)
|
|
24
|
-
}, [storedValue, setStoredValue, key])
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
setStoredValue(get())
|
|
28
|
-
}, []) // eslint-disable-line react-hooks/exhaustive-deps
|
|
29
|
-
|
|
30
|
-
return [storedValue, setValue]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default useLocalStorage
|
package/hooks/useOutsideClick.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
2
|
-
import type { RefObject } from 'react'
|
|
3
|
-
|
|
4
|
-
export const useOutsideClick = <Ts extends RefObject<HTMLElement>[]>(refs: Ts, handler: () => void) => {
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const listener = (event: MouseEvent | TouchEvent) => {
|
|
7
|
-
// returning means not "not clicking outside"
|
|
8
|
-
|
|
9
|
-
// if no target exists, return
|
|
10
|
-
if (event.target === null) return
|
|
11
|
-
// if the target is a ref's element or descendent thereof, return
|
|
12
|
-
if (refs.some((ref) => !ref.current || ref.current.contains(event.target as Node))) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
handler()
|
|
17
|
-
}
|
|
18
|
-
document.addEventListener('mousedown', listener)
|
|
19
|
-
document.addEventListener('touchstart', listener)
|
|
20
|
-
return () => {
|
|
21
|
-
document.removeEventListener('mousedown', listener)
|
|
22
|
-
document.removeEventListener('touchstart', listener)
|
|
23
|
-
}
|
|
24
|
-
}, [refs, handler])
|
|
25
|
-
}
|
package/hooks/useSaveDelay.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
function useSaveDelay(setNotificationStatus: (isShowing: boolean) => void, delay: number) {
|
|
4
|
-
const [updateTimer, setUpdateTimer] = useState<NodeJS.Timeout | undefined>(undefined)
|
|
5
|
-
const [notificationTimer, setNotificationTimer] = useState<NodeJS.Timeout | undefined>(undefined)
|
|
6
|
-
|
|
7
|
-
const restartTimer = (onSave: () => void) => {
|
|
8
|
-
clearTimeout(updateTimer)
|
|
9
|
-
setUpdateTimer(setTimeout(() => {
|
|
10
|
-
onSave()
|
|
11
|
-
setNotificationStatus(true)
|
|
12
|
-
// Show Saved Notification for fade animation duration
|
|
13
|
-
clearTimeout(notificationTimer)
|
|
14
|
-
setNotificationTimer(setTimeout(() => {
|
|
15
|
-
setNotificationStatus(false)
|
|
16
|
-
clearTimeout(notificationTimer)
|
|
17
|
-
}, delay))
|
|
18
|
-
clearTimeout(updateTimer)
|
|
19
|
-
}, delay))
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const clearUpdateTimer = (hasSaved = true) => {
|
|
23
|
-
clearTimeout(updateTimer)
|
|
24
|
-
if (hasSaved) {
|
|
25
|
-
setNotificationStatus(true)
|
|
26
|
-
clearTimeout(notificationTimer)
|
|
27
|
-
setNotificationTimer(setTimeout(() => {
|
|
28
|
-
setNotificationStatus(false)
|
|
29
|
-
clearTimeout(notificationTimer)
|
|
30
|
-
}, delay))
|
|
31
|
-
} else {
|
|
32
|
-
setNotificationStatus(false)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
return () => {
|
|
38
|
-
clearTimeout(updateTimer)
|
|
39
|
-
clearTimeout(notificationTimer)
|
|
40
|
-
}
|
|
41
|
-
}, []) // eslint-disable-line react-hooks/exhaustive-deps
|
|
42
|
-
|
|
43
|
-
return { restartTimer, clearUpdateTimer }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default useSaveDelay
|
package/hooks/useTheme.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react'
|
|
2
|
-
import type { Dispatch, SetStateAction, PropsWithChildren } from 'react'
|
|
3
|
-
import { createContext, useState, useEffect } from 'react'
|
|
4
|
-
import type { Translation } from './useTranslation'
|
|
5
|
-
|
|
6
|
-
export type ThemeType = 'light' | 'dark'
|
|
7
|
-
|
|
8
|
-
export type ThemeTypeTranslation = Record<ThemeType, string>
|
|
9
|
-
export const defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {
|
|
10
|
-
en: {
|
|
11
|
-
dark: 'Dark',
|
|
12
|
-
light: 'Light'
|
|
13
|
-
},
|
|
14
|
-
de: {
|
|
15
|
-
dark: 'Dunkel',
|
|
16
|
-
light: 'Hell'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type ThemeContextType = {
|
|
21
|
-
theme: ThemeType,
|
|
22
|
-
setTheme: Dispatch<SetStateAction<ThemeType>>,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const ThemeContext = createContext<ThemeContextType>({
|
|
26
|
-
theme: 'light',
|
|
27
|
-
setTheme: (_: SetStateAction<ThemeType>) => {
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
type ThemeProviderProps = {
|
|
32
|
-
initialTheme?: ThemeType,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const ThemeProvider = ({ children, initialTheme = 'light' }: PropsWithChildren<ThemeProviderProps>) => {
|
|
36
|
-
const [theme, setTheme] = useState<ThemeType>(initialTheme)
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (theme !== initialTheme) {
|
|
40
|
-
console.warn('ThemeProvider initial state changed: Prefer using useTheme\'s setTheme instead')
|
|
41
|
-
setTheme(initialTheme)
|
|
42
|
-
}
|
|
43
|
-
}, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
document.documentElement.setAttribute('data-theme', theme)
|
|
47
|
-
}, [theme])
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<ThemeContext.Provider value={{ theme, setTheme }}>
|
|
51
|
-
{children}
|
|
52
|
-
</ThemeContext.Provider>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export const useTheme = () => useContext(ThemeContext)
|
package/hooks/useTranslation.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Languages } from './useLanguage'
|
|
2
|
-
import { useLanguage } from './useLanguage'
|
|
3
|
-
|
|
4
|
-
export type Translation<T> = Record<Languages, T>
|
|
5
|
-
|
|
6
|
-
type OverwriteTranslationType<Translation extends Record<string, unknown>> = {
|
|
7
|
-
language?: Languages,
|
|
8
|
-
translation?: Partial<Record<Languages, Partial<Translation>>>,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Adds the `language` prop to the component props.
|
|
13
|
-
*
|
|
14
|
-
* @param Translation the type of the translation object
|
|
15
|
-
*
|
|
16
|
-
* @param Props the type of the component props, defaults to `Record<string, never>`,
|
|
17
|
-
* if you don't expect any other props other than `language` and get an
|
|
18
|
-
* error when using your component (because it uses `forwardRef` etc.)
|
|
19
|
-
* you can try out `Record<string, unknown>`, this might resolve your
|
|
20
|
-
* problem as `SomeType & never` is still `never` but `SomeType & unknown`
|
|
21
|
-
* is `SomeType` which means that adding back props (like `ref` etc.)
|
|
22
|
-
* works properly
|
|
23
|
-
*/
|
|
24
|
-
export type PropsForTranslation<
|
|
25
|
-
Translation extends Record<string, unknown>,
|
|
26
|
-
Props = Record<string, never>
|
|
27
|
-
> = Props & {
|
|
28
|
-
overwriteTranslation?: OverwriteTranslationType<Translation>,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const useTranslation = <Translation extends Record<string, unknown>>(
|
|
32
|
-
defaults: Record<Languages, Translation>,
|
|
33
|
-
translationOverwrite: OverwriteTranslationType<Translation> = {}
|
|
34
|
-
) : Translation => {
|
|
35
|
-
const { language: languageProp, translation: overwrite } = translationOverwrite
|
|
36
|
-
const { language: inferredLanguage } = useLanguage()
|
|
37
|
-
const usedLanguage = languageProp ?? inferredLanguage
|
|
38
|
-
let defaultValues: Translation = defaults[usedLanguage]
|
|
39
|
-
if (overwrite && overwrite[usedLanguage]) {
|
|
40
|
-
defaultValues = { ...defaultValues, ...overwrite[usedLanguage] }
|
|
41
|
-
}
|
|
42
|
-
return defaultValues
|
|
43
|
-
}
|
package/index.ts
DELETED
|
File without changes
|
package/util/array.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
export const equalSizeGroups = <T >(array: T[], groupSize: number): T[][] => {
|
|
2
|
-
if (groupSize <= 0) {
|
|
3
|
-
console.warn(`group size should be greater than 0: groupSize = ${groupSize}`)
|
|
4
|
-
return [[...array]]
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const groups = []
|
|
8
|
-
for (let i = 0; i < array.length; i += groupSize) {
|
|
9
|
-
groups.push(array.slice(i, Math.min(i + groupSize, array.length)))
|
|
10
|
-
}
|
|
11
|
-
return groups
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param start
|
|
16
|
-
* @param end inclusive
|
|
17
|
-
* @param allowEmptyRange Whether the range can be defined empty via end < start
|
|
18
|
-
*/
|
|
19
|
-
export const range = (start: number, end: number, allowEmptyRange: boolean = false): number[] => {
|
|
20
|
-
if (end < start) {
|
|
21
|
-
if (!allowEmptyRange) {
|
|
22
|
-
console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set allowEmptyRange to true`)
|
|
23
|
-
}
|
|
24
|
-
return []
|
|
25
|
-
}
|
|
26
|
-
return Array.from({ length: end - start + 1 }, (_, index) => index + start)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Finds the closest match
|
|
30
|
-
* @param list The list of all possible matches
|
|
31
|
-
* @param firstCloser Return whether item1 is closer than item2
|
|
32
|
-
*/
|
|
33
|
-
export const closestMatch = <T >(list: T[], firstCloser: (item1: T, item2: T) => boolean) => {
|
|
34
|
-
return list.reduce((item1, item2) => {
|
|
35
|
-
return firstCloser(item1, item2) ? item1 : item2
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* returns the item in middle of a list and its neighbours before and after
|
|
41
|
-
* e.g. [1,2,3,4,5,6] for item = 1 would return [5,6,1,2,3]
|
|
42
|
-
*/
|
|
43
|
-
export const getNeighbours = <T >(list: T[], item: T, neighbourDistance: number = 2) => {
|
|
44
|
-
const index = list.indexOf(item)
|
|
45
|
-
const totalItems = neighbourDistance * 2 + 1
|
|
46
|
-
if (list.length < totalItems) {
|
|
47
|
-
console.warn('List is to short')
|
|
48
|
-
return list
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (index === -1) {
|
|
52
|
-
console.error('item not found in list')
|
|
53
|
-
return list.splice(0, totalItems)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let start = index - neighbourDistance
|
|
57
|
-
if (start < 0) {
|
|
58
|
-
start += list.length
|
|
59
|
-
}
|
|
60
|
-
const end = (index + neighbourDistance + 1) % list.length
|
|
61
|
-
|
|
62
|
-
const result: T[] = []
|
|
63
|
-
let ignoreOnce = list.length === totalItems
|
|
64
|
-
for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {
|
|
65
|
-
result.push(list[i]!)
|
|
66
|
-
if (end === i && ignoreOnce) {
|
|
67
|
-
ignoreOnce = false
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const createLoopingListWithIndex = <T >(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {
|
|
74
|
-
if (length < 0) {
|
|
75
|
-
console.warn(`createLoopingList: length must be >= 0, given ${length}`)
|
|
76
|
-
} else if (length === 0) {
|
|
77
|
-
length = list.length
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const returnList: [number, T][] = []
|
|
81
|
-
|
|
82
|
-
if (forwards) {
|
|
83
|
-
for (let i = startIndex; returnList.length < length; i = (i + 1) % list.length) {
|
|
84
|
-
returnList.push([i, list[i]!])
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
for (let i = startIndex; returnList.length < length; i = i === 0 ? i = list.length - 1 : i - 1) {
|
|
88
|
-
returnList.push([i, list[i]!])
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return returnList
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export const createLoopingList = <T >(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {
|
|
96
|
-
return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const ArrayUtil = {
|
|
100
|
-
unique: <T>(list: T[]): T[] => {
|
|
101
|
-
const seen = new Set<T>()
|
|
102
|
-
return list.filter((item) => {
|
|
103
|
-
if (seen.has(item)) {
|
|
104
|
-
return false
|
|
105
|
-
}
|
|
106
|
-
seen.add(item)
|
|
107
|
-
return true
|
|
108
|
-
})
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
difference: <T>(list: T[], removeList: T[]): T[] => {
|
|
112
|
-
const remove = new Set<T>(removeList)
|
|
113
|
-
return list.filter((item) => !remove.has(item))
|
|
114
|
-
}
|
|
115
|
-
}
|
package/util/date.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { equalSizeGroups } from './array'
|
|
2
|
-
|
|
3
|
-
export const monthsList = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as const
|
|
4
|
-
export type Month = typeof monthsList[number]
|
|
5
|
-
|
|
6
|
-
export const weekDayList = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] as const
|
|
7
|
-
export type WeekDay = typeof weekDayList[number]
|
|
8
|
-
|
|
9
|
-
export const formatDate = (date: Date) => {
|
|
10
|
-
const year = date.getFullYear().toString().padStart(4, '0')
|
|
11
|
-
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
|
12
|
-
const day = (date.getDate()).toString().padStart(2, '0')
|
|
13
|
-
return `${year}-${month}-${day}`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const formatDateTime = (date: Date) => {
|
|
17
|
-
const dateString = formatDate(date)
|
|
18
|
-
const hours = date.getHours().toString().padStart(2, '0')
|
|
19
|
-
const minutes = date.getMinutes().toString().padStart(2, '0')
|
|
20
|
-
return `${dateString}T${hours}:${minutes}`
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const getDaysInMonth = (year: number, month: number): number => {
|
|
24
|
-
const lastDayOfMonth = new Date(year, month + 1, 0)
|
|
25
|
-
return lastDayOfMonth.getDate()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type Duration = {
|
|
29
|
-
years?: number,
|
|
30
|
-
months?: number,
|
|
31
|
-
days?: number,
|
|
32
|
-
hours?: number,
|
|
33
|
-
minutes?: number,
|
|
34
|
-
seconds?: number,
|
|
35
|
-
milliseconds?: number,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const changeDuration = (date: Date, duration: Duration, isAdding?: boolean): Date => {
|
|
39
|
-
const {
|
|
40
|
-
years = 0,
|
|
41
|
-
months = 0,
|
|
42
|
-
days = 0,
|
|
43
|
-
hours = 0,
|
|
44
|
-
minutes = 0,
|
|
45
|
-
seconds = 0,
|
|
46
|
-
milliseconds = 0,
|
|
47
|
-
} = duration
|
|
48
|
-
|
|
49
|
-
// Check ranges
|
|
50
|
-
if (years < 0) {
|
|
51
|
-
console.error(`Range error years must be greater than 0: received ${years}`)
|
|
52
|
-
return new Date(date)
|
|
53
|
-
}
|
|
54
|
-
if (months < 0 || months > 11) {
|
|
55
|
-
console.error(`Range error month must be 0 <= month <= 11: received ${months}`)
|
|
56
|
-
return new Date(date)
|
|
57
|
-
}
|
|
58
|
-
if (days < 0) {
|
|
59
|
-
console.error(`Range error days must be greater than 0: received ${days}`)
|
|
60
|
-
return new Date(date)
|
|
61
|
-
}
|
|
62
|
-
if (hours < 0 || hours > 23) {
|
|
63
|
-
console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`)
|
|
64
|
-
return new Date(date)
|
|
65
|
-
}
|
|
66
|
-
if (minutes < 0 || minutes > 59) {
|
|
67
|
-
console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`)
|
|
68
|
-
return new Date(date)
|
|
69
|
-
}
|
|
70
|
-
if (seconds < 0 || seconds > 59) {
|
|
71
|
-
console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`)
|
|
72
|
-
return new Date(date)
|
|
73
|
-
}
|
|
74
|
-
if (milliseconds < 0) {
|
|
75
|
-
console.error(`Range error seconds must be greater than 0: received ${milliseconds}`)
|
|
76
|
-
return new Date(date)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const multiplier = isAdding ? 1 : -1
|
|
80
|
-
|
|
81
|
-
const newDate = new Date(date)
|
|
82
|
-
|
|
83
|
-
newDate.setFullYear(newDate.getFullYear() + multiplier * years)
|
|
84
|
-
|
|
85
|
-
newDate.setMonth(newDate.getMonth() + multiplier * months)
|
|
86
|
-
|
|
87
|
-
newDate.setDate(newDate.getDate() + multiplier * days)
|
|
88
|
-
|
|
89
|
-
newDate.setHours(newDate.getHours() + multiplier * hours)
|
|
90
|
-
|
|
91
|
-
newDate.setMinutes(newDate.getMinutes() + multiplier * minutes)
|
|
92
|
-
|
|
93
|
-
newDate.setSeconds(newDate.getSeconds() + multiplier * seconds)
|
|
94
|
-
|
|
95
|
-
newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds)
|
|
96
|
-
|
|
97
|
-
return newDate
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export const addDuration = (date: Date, duration: Duration): Date => {
|
|
101
|
-
return changeDuration(date, duration, true)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const subtractDuration = (date: Date, duration: Duration): Date => {
|
|
105
|
-
return changeDuration(date, duration, false)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export const getBetweenDuration = (startDate: Date, endDate: Date): Duration => {
|
|
109
|
-
const durationInMilliseconds = endDate.getTime() - startDate.getTime()
|
|
110
|
-
|
|
111
|
-
const millisecondsInSecond = 1000
|
|
112
|
-
const millisecondsInMinute = 60 * millisecondsInSecond
|
|
113
|
-
const millisecondsInHour = 60 * millisecondsInMinute
|
|
114
|
-
const millisecondsInDay = 24 * millisecondsInHour
|
|
115
|
-
const millisecondsInMonth = 30 * millisecondsInDay // Rough estimation, can be adjusted
|
|
116
|
-
|
|
117
|
-
const years = Math.floor(durationInMilliseconds / (365.25 * millisecondsInDay))
|
|
118
|
-
const months = Math.floor(durationInMilliseconds / millisecondsInMonth)
|
|
119
|
-
const days = Math.floor(durationInMilliseconds / millisecondsInDay)
|
|
120
|
-
const hours = Math.floor((durationInMilliseconds % millisecondsInDay) / millisecondsInHour)
|
|
121
|
-
const seconds = Math.floor((durationInMilliseconds % millisecondsInHour) / millisecondsInSecond)
|
|
122
|
-
const milliseconds = durationInMilliseconds % millisecondsInSecond
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
years,
|
|
126
|
-
months,
|
|
127
|
-
days,
|
|
128
|
-
hours,
|
|
129
|
-
seconds,
|
|
130
|
-
milliseconds,
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** Checks if a given date is in the range of two dates
|
|
135
|
-
*
|
|
136
|
-
* An undefined value for startDate or endDate means no bound for the start or end respectively
|
|
137
|
-
*/
|
|
138
|
-
export const isInTimeSpan = (value: Date, startDate?: Date, endDate?: Date): boolean => {
|
|
139
|
-
if(startDate && endDate) {
|
|
140
|
-
console.assert(startDate <= endDate)
|
|
141
|
-
return startDate <= value && value <= endDate
|
|
142
|
-
} else if (startDate) {
|
|
143
|
-
return startDate <= value
|
|
144
|
-
} else if(endDate) {
|
|
145
|
-
return endDate >= value
|
|
146
|
-
} else {
|
|
147
|
-
return true
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/** Compare two dates on the year, month, day */
|
|
152
|
-
export const equalDate = (date1: Date, date2: Date) => {
|
|
153
|
-
return date1.getFullYear() === date2.getFullYear()
|
|
154
|
-
&& date1.getMonth() === date2.getMonth()
|
|
155
|
-
&& date1.getDate() === date2.getDate()
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export const getWeeksForCalenderMonth = (date: Date, weekStart: WeekDay, weeks: number = 6) => {
|
|
159
|
-
const month = date.getMonth()
|
|
160
|
-
const year = date.getFullYear()
|
|
161
|
-
|
|
162
|
-
const dayList: Date[] = []
|
|
163
|
-
let currentDate = new Date(year, month, 1) // Start of month
|
|
164
|
-
const weekStartIndex = weekDayList.indexOf(weekStart)
|
|
165
|
-
|
|
166
|
-
// Move the current day to the week before
|
|
167
|
-
while (currentDate.getDay() !== weekStartIndex) {
|
|
168
|
-
currentDate = subtractDuration(currentDate, { days: 1 })
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
while (dayList.length < 7 * weeks) {
|
|
172
|
-
const date = new Date(currentDate)
|
|
173
|
-
date.setHours(date.getHours(), date.getMinutes()) // To make sure we are not overwriting the time
|
|
174
|
-
dayList.push(date)
|
|
175
|
-
currentDate = addDuration(currentDate, { days: 1 })
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// weeks
|
|
179
|
-
return equalSizeGroups(dayList, 7)
|
|
180
|
-
}
|
package/util/easeFunctions.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { clamp } from './math'
|
|
2
|
-
|
|
3
|
-
export type EaseFunction = (t: number) => number
|
|
4
|
-
|
|
5
|
-
export class EaseFunctions {
|
|
6
|
-
static cubicBezierGeneric(x1: number, y1: number, x2: number, y2: number): { x: EaseFunction, y: EaseFunction } {
|
|
7
|
-
// Calculate the x and y coordinates using the cubic Bézier formula
|
|
8
|
-
const cx = 3 * x1
|
|
9
|
-
const bx = 3 * (x2 - x1) - cx
|
|
10
|
-
const ax = 1 - cx - bx
|
|
11
|
-
|
|
12
|
-
const cy = 3 * y1
|
|
13
|
-
const by = 3 * (y2 - y1) - cy
|
|
14
|
-
const ay = 1 - cy - by
|
|
15
|
-
|
|
16
|
-
// Compute x and y values at parameter t
|
|
17
|
-
const x = (t: number) => ((ax * t + bx) * t + cx) * t
|
|
18
|
-
const y = (t: number) => ((ay * t + by) * t + cy) * t
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
x,
|
|
22
|
-
y
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static cubicBezier(x1: number, y1: number, x2: number, y2: number): EaseFunction {
|
|
27
|
-
const { y } = EaseFunctions.cubicBezierGeneric(x1, y1, x2, y2)
|
|
28
|
-
return (t: number) => {
|
|
29
|
-
t = clamp(t)
|
|
30
|
-
return y(t) // <= equal to x(t) * 0 + y(t) * 1
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static easeInEaseOut(t: number): number {
|
|
35
|
-
return EaseFunctions.cubicBezier(0.65, 0, 0.35, 1)(t)
|
|
36
|
-
};
|
|
37
|
-
}
|
package/util/emailValidation.ts
DELETED