@neko-os/ui 0.0.13 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstractions/KeyboardAvoidingView.js +1 -0
- package/dist/abstractions/KeyboardAvoidingView.native.js +1 -0
- package/dist/components/actions/ActionsDrawer.js +1 -0
- package/dist/components/actions/Button.js +1 -1
- package/dist/components/actions/FloatingMenu.js +1 -0
- package/dist/components/actions/index.js +1 -1
- package/dist/components/animations/AnimatedTopBar.js +1 -0
- package/dist/components/animations/AnimatedTopBar.native.js +1 -0
- package/dist/components/animations/AnimatedTopBar.web.js +1 -0
- package/dist/components/animations/ParallaxHeader.js +1 -0
- package/dist/components/animations/ParallaxHeader.native.js +1 -0
- package/dist/components/animations/ParallaxHeader.web.js +1 -0
- package/dist/components/animations/ReanimatedScrollHandler.js +1 -0
- package/dist/components/animations/ReanimatedScrollHandler.native.js +1 -0
- package/dist/components/animations/ReanimatedScrollHandler.web.js +1 -0
- package/dist/components/animations/index.js +1 -1
- package/dist/components/form/FormItem.js +1 -1
- package/dist/components/form/FormList.js +1 -1
- package/dist/components/form/SubmitButton.js +1 -1
- package/dist/components/form/index.js +1 -1
- package/dist/components/form/useNewForm.js +1 -1
- package/dist/components/form/validation/defaultMessages.js +1 -0
- package/dist/components/form/validation/index.js +1 -0
- package/dist/components/form/validation/normalizeRules.js +1 -0
- package/dist/components/form/validation/shouldValidateOn.js +1 -0
- package/dist/components/form/validation/validateRules.js +1 -0
- package/dist/components/form/validation/validators.js +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/inputs/InputWrapper.js +1 -1
- package/dist/components/inputs/NumberInput.js +1 -1
- package/dist/components/inputs/Picker.js +1 -1
- package/dist/components/inputs/Select.js +1 -1
- package/dist/components/presentation/Avatar.js +1 -1
- package/dist/components/presentation/AvatarLabel.js +1 -1
- package/dist/components/presentation/LabelValue.js +1 -1
- package/dist/components/presentation/Result.js +1 -1
- package/dist/components/presentation/Tooltip.js +1 -1
- package/dist/components/sections/Section.js +1 -0
- package/dist/components/sections/SectionItem.js +1 -0
- package/dist/components/sections/SectionItemLink.js +1 -0
- package/dist/components/sections/index.js +1 -0
- package/dist/components/state/StatePresenter.js +1 -0
- package/dist/components/state/index.js +1 -1
- package/dist/components/structure/BlurView.js +1 -1
- package/dist/components/structure/KeyboardAvoidingView.js +1 -0
- package/dist/components/structure/TopBar.js +1 -0
- package/dist/components/structure/bottomDrawer/index.js +1 -1
- package/dist/components/structure/bottomDrawer/index.native.js +1 -1
- package/dist/components/structure/bottomDrawer/index.web.js +1 -1
- package/dist/components/structure/bottomDrawer/native/BottomDrawer.js +1 -1
- package/dist/components/structure/bottomDrawer/native/DrawerScrollView.js +1 -1
- package/dist/components/structure/bottomDrawer/native/createDrawerScrollComponent.js +1 -0
- package/dist/components/structure/index.js +1 -1
- package/dist/components/text/DateText.js +1 -0
- package/dist/components/text/index.js +1 -1
- package/dist/components/theme/ThemePicker.js +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/storage.js +1 -1
- package/dist/responsive/responsiveHooks.js +1 -1
- package/dist/theme/ThemeHandler.js +1 -1
- package/dist/theme/default/base.js +1 -1
- package/dist/theme/default/blackTheme.js +1 -1
- package/dist/theme/default/cyberpunkTheme.js +1 -1
- package/dist/theme/default/darkTheme.js +1 -1
- package/dist/theme/default/hackerTheme.js +1 -1
- package/dist/theme/default/lightTheme.js +1 -1
- package/dist/theme/default/msdosTheme.js +1 -1
- package/dist/theme/default/paperTheme.js +1 -1
- package/package.json +1 -1
- package/src/abstractions/KeyboardAvoidingView.js +3 -0
- package/src/abstractions/KeyboardAvoidingView.native.js +3 -0
- package/src/components/actions/ActionsDrawer.js +68 -0
- package/src/components/actions/Button.js +2 -1
- package/src/components/actions/FloatingMenu.js +39 -0
- package/src/components/actions/index.js +2 -0
- package/src/components/animations/AnimatedTopBar.js +10 -0
- package/src/components/animations/AnimatedTopBar.native.js +34 -0
- package/src/components/animations/AnimatedTopBar.web.js +1 -0
- package/src/components/animations/ParallaxHeader.js +9 -0
- package/src/components/animations/ParallaxHeader.native.js +32 -0
- package/src/components/animations/ParallaxHeader.web.js +32 -0
- package/src/components/animations/ReanimatedScrollHandler.js +8 -0
- package/src/components/animations/ReanimatedScrollHandler.native.js +24 -0
- package/src/components/animations/ReanimatedScrollHandler.web.js +1 -0
- package/src/components/animations/index.js +3 -0
- package/src/components/form/FormItem.js +42 -5
- package/src/components/form/FormList.js +23 -4
- package/src/components/form/SubmitButton.js +4 -2
- package/src/components/form/index.js +1 -0
- package/src/components/form/useNewForm.js +108 -15
- package/src/components/form/validation/defaultMessages.js +20 -0
- package/src/components/form/validation/index.js +5 -0
- package/src/components/form/validation/normalizeRules.js +22 -0
- package/src/components/form/validation/shouldValidateOn.js +21 -0
- package/src/components/form/validation/validateRules.js +83 -0
- package/src/components/form/validation/validators.js +82 -0
- package/src/components/index.js +1 -0
- package/src/components/inputs/InputWrapper.js +1 -1
- package/src/components/inputs/NumberInput.js +6 -5
- package/src/components/inputs/Picker.js +3 -2
- package/src/components/inputs/Select.js +31 -15
- package/src/components/presentation/Avatar.js +2 -2
- package/src/components/presentation/AvatarLabel.js +2 -0
- package/src/components/presentation/LabelValue.js +7 -5
- package/src/components/presentation/Result.js +2 -2
- package/src/components/presentation/Tooltip.js +1 -1
- package/src/components/sections/Section.js +50 -0
- package/src/components/sections/SectionItem.js +24 -0
- package/src/components/sections/SectionItemLink.js +33 -0
- package/src/components/sections/index.js +3 -0
- package/src/components/state/StatePresenter.js +41 -0
- package/src/components/state/index.js +1 -0
- package/src/components/structure/BlurView.js +1 -0
- package/src/components/structure/KeyboardAvoidingView.js +52 -0
- package/src/components/structure/TopBar.js +45 -0
- package/src/components/structure/bottomDrawer/index.js +2 -0
- package/src/components/structure/bottomDrawer/index.native.js +2 -1
- package/src/components/structure/bottomDrawer/index.web.js +2 -1
- package/src/components/structure/bottomDrawer/native/BottomDrawer.js +14 -20
- package/src/components/structure/bottomDrawer/native/DrawerScrollView.js +4 -82
- package/src/components/structure/bottomDrawer/native/createDrawerScrollComponent.js +131 -0
- package/src/components/structure/index.js +2 -0
- package/src/components/text/DateText.js +11 -0
- package/src/components/text/index.js +1 -0
- package/src/components/theme/ThemePicker.js +1 -2
- package/src/helpers/index.js +1 -0
- package/src/helpers/storage.js +32 -9
- package/src/responsive/responsiveHooks.js +6 -0
- package/src/theme/ThemeHandler.js +6 -3
- package/src/theme/default/base.js +16 -4
- package/src/theme/default/blackTheme.js +1 -0
- package/src/theme/default/cyberpunkTheme.js +10 -0
- package/src/theme/default/darkTheme.js +1 -0
- package/src/theme/default/hackerTheme.js +17 -3
- package/src/theme/default/lightTheme.js +1 -0
- package/src/theme/default/msdosTheme.js +9 -10
- package/src/theme/default/paperTheme.js +10 -0
package/src/helpers/storage.js
CHANGED
|
@@ -2,22 +2,42 @@ import React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { AbsStorage } from '../abstractions/helpers/storage'
|
|
4
4
|
|
|
5
|
+
// Pub/Sub listener registry for cross-component sync
|
|
6
|
+
const listeners = {}
|
|
7
|
+
|
|
8
|
+
function notify(key, value) {
|
|
9
|
+
if (listeners[key]) {
|
|
10
|
+
listeners[key].forEach((cb) => cb(value))
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function subscribe(key, cb) {
|
|
15
|
+
if (!listeners[key]) listeners[key] = []
|
|
16
|
+
listeners[key].push(cb)
|
|
17
|
+
return () => {
|
|
18
|
+
listeners[key] = listeners[key].filter((fn) => fn !== cb)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
5
22
|
function set(key, value) {
|
|
6
|
-
|
|
23
|
+
AbsStorage.set(key, JSON.stringify(value))
|
|
24
|
+
notify(key, value)
|
|
7
25
|
}
|
|
8
26
|
|
|
9
27
|
function setAsync(key, value) {
|
|
10
|
-
return AbsStorage.setAsync(key, JSON.stringify(value))
|
|
28
|
+
return AbsStorage.setAsync(key, JSON.stringify(value)).then(() => {
|
|
29
|
+
notify(key, value)
|
|
30
|
+
})
|
|
11
31
|
}
|
|
12
32
|
|
|
13
|
-
function get(key) {
|
|
33
|
+
function get(key, defaultValue) {
|
|
14
34
|
const value = AbsStorage.get(key)
|
|
15
|
-
return formatStoragedValue(value)
|
|
35
|
+
return formatStoragedValue(value) ?? defaultValue
|
|
16
36
|
}
|
|
17
37
|
|
|
18
|
-
function getAsync(key) {
|
|
19
|
-
return AbsStorage.
|
|
20
|
-
return formatStoragedValue(value)
|
|
38
|
+
function getAsync(key, defaultValue) {
|
|
39
|
+
return AbsStorage.getAsync(key).then((value) => {
|
|
40
|
+
return formatStoragedValue(value) ?? defaultValue
|
|
21
41
|
})
|
|
22
42
|
}
|
|
23
43
|
|
|
@@ -34,11 +54,14 @@ function formatStoragedValue(value) {
|
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
function useState(key, defaultValue) {
|
|
37
|
-
const [value, setValue] = React.useState(get(key)
|
|
57
|
+
const [value, setValue] = React.useState(() => get(key) ?? defaultValue)
|
|
58
|
+
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
return subscribe(key, setValue)
|
|
61
|
+
}, [key])
|
|
38
62
|
|
|
39
63
|
const handleChange = (newValue) => {
|
|
40
64
|
set(key, newValue)
|
|
41
|
-
setValue(newValue)
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
return [value, handleChange]
|
|
@@ -17,6 +17,12 @@ export function useGetResponsiveValue() {
|
|
|
17
17
|
const isWeb = value?.web !== undefined && Platform.OS === 'web'
|
|
18
18
|
if (isWeb) return value?.web
|
|
19
19
|
|
|
20
|
+
const isIOS = value?.ios !== undefined && Platform.OS === 'ios'
|
|
21
|
+
if (isIOS) return value?.ios
|
|
22
|
+
|
|
23
|
+
const isAndroid = value?.android !== undefined && Platform.OS === 'android'
|
|
24
|
+
if (isAndroid) return value?.android
|
|
25
|
+
|
|
20
26
|
const isObj = is(Object, value)
|
|
21
27
|
|
|
22
28
|
if (!isObj) return value
|
|
@@ -57,18 +57,21 @@ export function ThemeHandler({ breakpoints, themes, initTheme, onChangeTheme, ch
|
|
|
57
57
|
const [themePickerOpen, setThemePickerOpen] = React.useState(false)
|
|
58
58
|
const openThemePicker = () => setThemePickerOpen(true)
|
|
59
59
|
const [activeThemeKey, setActiveThemeKey] = React.useState(initTheme || 'light')
|
|
60
|
-
const
|
|
60
|
+
const handleChangeTheme = (key) => {
|
|
61
|
+
setActiveThemeKey(key)
|
|
62
|
+
onChangeTheme?.(key)
|
|
63
|
+
}
|
|
64
|
+
const toggleTheme = () => handleChangeTheme(activeThemeKey === 'light' ? 'dark' : 'light')
|
|
61
65
|
const theme = useFormattedTheme(themes, activeThemeKey)
|
|
62
66
|
|
|
63
67
|
const value = {
|
|
64
68
|
theme,
|
|
65
69
|
themes,
|
|
66
70
|
activeThemeKey,
|
|
67
|
-
setActiveThemeKey,
|
|
68
71
|
toggleTheme,
|
|
69
72
|
themePickerOpen,
|
|
70
73
|
setThemePickerOpen,
|
|
71
|
-
onChangeTheme,
|
|
74
|
+
onChangeTheme: handleChangeTheme,
|
|
72
75
|
openThemePicker,
|
|
73
76
|
toggleTheme,
|
|
74
77
|
breakpoints: breakpoints || DEFAULT_BREAKPOINTS,
|
|
@@ -36,13 +36,25 @@ export const BASE_THEME = {
|
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
// Buttons, inputs, etc.
|
|
39
|
+
// elementHeights: {
|
|
40
|
+
// xxxs: 10,
|
|
41
|
+
// xxs: 15,
|
|
42
|
+
// xs: 20,
|
|
43
|
+
// sm: 30,
|
|
44
|
+
// md: 35,
|
|
45
|
+
// lg: 40,
|
|
46
|
+
// xl: 50,
|
|
47
|
+
// xxl: 60,
|
|
48
|
+
// xxxl: 70,
|
|
49
|
+
// },
|
|
50
|
+
|
|
39
51
|
elementHeights: {
|
|
40
52
|
xxxs: 10,
|
|
41
53
|
xxs: 15,
|
|
42
|
-
xs:
|
|
43
|
-
sm:
|
|
44
|
-
md:
|
|
45
|
-
lg:
|
|
54
|
+
xs: 25,
|
|
55
|
+
sm: 35,
|
|
56
|
+
md: 40,
|
|
57
|
+
lg: 45,
|
|
46
58
|
xl: 50,
|
|
47
59
|
xxl: 60,
|
|
48
60
|
xxxl: 70,
|
|
@@ -33,11 +33,25 @@ export const DEFAULT_MATRIX_THEME = mergeDeepRight(BASE_THEME, {
|
|
|
33
33
|
pink: '#C51162',
|
|
34
34
|
},
|
|
35
35
|
|
|
36
|
+
radius: {
|
|
37
|
+
xxxs: 0,
|
|
38
|
+
xxs: 1,
|
|
39
|
+
xs: 2,
|
|
40
|
+
sm: 3,
|
|
41
|
+
md: 4,
|
|
42
|
+
lg: 5,
|
|
43
|
+
xl: 6,
|
|
44
|
+
xxl: 7,
|
|
45
|
+
xxxl: 8,
|
|
46
|
+
},
|
|
47
|
+
|
|
36
48
|
components: {
|
|
37
49
|
Card: {
|
|
38
|
-
border:
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
border: true,
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
Section: {
|
|
54
|
+
border: true,
|
|
41
55
|
},
|
|
42
56
|
},
|
|
43
57
|
})
|
|
@@ -34,21 +34,20 @@ export const DEFAULT_MSDOS_THEME = mergeDeepRight(BASE_THEME, {
|
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
radius: {
|
|
37
|
-
xxxs:
|
|
38
|
-
xxs:
|
|
39
|
-
xs:
|
|
40
|
-
sm:
|
|
41
|
-
md:
|
|
42
|
-
lg:
|
|
43
|
-
xl:
|
|
44
|
-
xxl:
|
|
45
|
-
xxxl:
|
|
37
|
+
xxxs: 0,
|
|
38
|
+
xxs: 1,
|
|
39
|
+
xs: 2,
|
|
40
|
+
sm: 3,
|
|
41
|
+
md: 4,
|
|
42
|
+
lg: 5,
|
|
43
|
+
xl: 6,
|
|
44
|
+
xxl: 7,
|
|
45
|
+
xxxl: 8,
|
|
46
46
|
},
|
|
47
47
|
|
|
48
48
|
components: {
|
|
49
49
|
Card: {
|
|
50
50
|
border: 1,
|
|
51
|
-
br: 5,
|
|
52
51
|
borderColor: 'divider',
|
|
53
52
|
},
|
|
54
53
|
},
|