@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.
Files changed (137) hide show
  1. package/dist/abstractions/KeyboardAvoidingView.js +1 -0
  2. package/dist/abstractions/KeyboardAvoidingView.native.js +1 -0
  3. package/dist/components/actions/ActionsDrawer.js +1 -0
  4. package/dist/components/actions/Button.js +1 -1
  5. package/dist/components/actions/FloatingMenu.js +1 -0
  6. package/dist/components/actions/index.js +1 -1
  7. package/dist/components/animations/AnimatedTopBar.js +1 -0
  8. package/dist/components/animations/AnimatedTopBar.native.js +1 -0
  9. package/dist/components/animations/AnimatedTopBar.web.js +1 -0
  10. package/dist/components/animations/ParallaxHeader.js +1 -0
  11. package/dist/components/animations/ParallaxHeader.native.js +1 -0
  12. package/dist/components/animations/ParallaxHeader.web.js +1 -0
  13. package/dist/components/animations/ReanimatedScrollHandler.js +1 -0
  14. package/dist/components/animations/ReanimatedScrollHandler.native.js +1 -0
  15. package/dist/components/animations/ReanimatedScrollHandler.web.js +1 -0
  16. package/dist/components/animations/index.js +1 -1
  17. package/dist/components/form/FormItem.js +1 -1
  18. package/dist/components/form/FormList.js +1 -1
  19. package/dist/components/form/SubmitButton.js +1 -1
  20. package/dist/components/form/index.js +1 -1
  21. package/dist/components/form/useNewForm.js +1 -1
  22. package/dist/components/form/validation/defaultMessages.js +1 -0
  23. package/dist/components/form/validation/index.js +1 -0
  24. package/dist/components/form/validation/normalizeRules.js +1 -0
  25. package/dist/components/form/validation/shouldValidateOn.js +1 -0
  26. package/dist/components/form/validation/validateRules.js +1 -0
  27. package/dist/components/form/validation/validators.js +1 -0
  28. package/dist/components/index.js +1 -1
  29. package/dist/components/inputs/InputWrapper.js +1 -1
  30. package/dist/components/inputs/NumberInput.js +1 -1
  31. package/dist/components/inputs/Picker.js +1 -1
  32. package/dist/components/inputs/Select.js +1 -1
  33. package/dist/components/presentation/Avatar.js +1 -1
  34. package/dist/components/presentation/AvatarLabel.js +1 -1
  35. package/dist/components/presentation/LabelValue.js +1 -1
  36. package/dist/components/presentation/Result.js +1 -1
  37. package/dist/components/presentation/Tooltip.js +1 -1
  38. package/dist/components/sections/Section.js +1 -0
  39. package/dist/components/sections/SectionItem.js +1 -0
  40. package/dist/components/sections/SectionItemLink.js +1 -0
  41. package/dist/components/sections/index.js +1 -0
  42. package/dist/components/state/StatePresenter.js +1 -0
  43. package/dist/components/state/index.js +1 -1
  44. package/dist/components/structure/BlurView.js +1 -1
  45. package/dist/components/structure/KeyboardAvoidingView.js +1 -0
  46. package/dist/components/structure/TopBar.js +1 -0
  47. package/dist/components/structure/bottomDrawer/index.js +1 -1
  48. package/dist/components/structure/bottomDrawer/index.native.js +1 -1
  49. package/dist/components/structure/bottomDrawer/index.web.js +1 -1
  50. package/dist/components/structure/bottomDrawer/native/BottomDrawer.js +1 -1
  51. package/dist/components/structure/bottomDrawer/native/DrawerScrollView.js +1 -1
  52. package/dist/components/structure/bottomDrawer/native/createDrawerScrollComponent.js +1 -0
  53. package/dist/components/structure/index.js +1 -1
  54. package/dist/components/text/DateText.js +1 -0
  55. package/dist/components/text/index.js +1 -1
  56. package/dist/components/theme/ThemePicker.js +1 -1
  57. package/dist/helpers/index.js +1 -1
  58. package/dist/helpers/storage.js +1 -1
  59. package/dist/responsive/responsiveHooks.js +1 -1
  60. package/dist/theme/ThemeHandler.js +1 -1
  61. package/dist/theme/default/base.js +1 -1
  62. package/dist/theme/default/blackTheme.js +1 -1
  63. package/dist/theme/default/cyberpunkTheme.js +1 -1
  64. package/dist/theme/default/darkTheme.js +1 -1
  65. package/dist/theme/default/hackerTheme.js +1 -1
  66. package/dist/theme/default/lightTheme.js +1 -1
  67. package/dist/theme/default/msdosTheme.js +1 -1
  68. package/dist/theme/default/paperTheme.js +1 -1
  69. package/package.json +1 -1
  70. package/src/abstractions/KeyboardAvoidingView.js +3 -0
  71. package/src/abstractions/KeyboardAvoidingView.native.js +3 -0
  72. package/src/components/actions/ActionsDrawer.js +68 -0
  73. package/src/components/actions/Button.js +2 -1
  74. package/src/components/actions/FloatingMenu.js +39 -0
  75. package/src/components/actions/index.js +2 -0
  76. package/src/components/animations/AnimatedTopBar.js +10 -0
  77. package/src/components/animations/AnimatedTopBar.native.js +34 -0
  78. package/src/components/animations/AnimatedTopBar.web.js +1 -0
  79. package/src/components/animations/ParallaxHeader.js +9 -0
  80. package/src/components/animations/ParallaxHeader.native.js +32 -0
  81. package/src/components/animations/ParallaxHeader.web.js +32 -0
  82. package/src/components/animations/ReanimatedScrollHandler.js +8 -0
  83. package/src/components/animations/ReanimatedScrollHandler.native.js +24 -0
  84. package/src/components/animations/ReanimatedScrollHandler.web.js +1 -0
  85. package/src/components/animations/index.js +3 -0
  86. package/src/components/form/FormItem.js +42 -5
  87. package/src/components/form/FormList.js +23 -4
  88. package/src/components/form/SubmitButton.js +4 -2
  89. package/src/components/form/index.js +1 -0
  90. package/src/components/form/useNewForm.js +108 -15
  91. package/src/components/form/validation/defaultMessages.js +20 -0
  92. package/src/components/form/validation/index.js +5 -0
  93. package/src/components/form/validation/normalizeRules.js +22 -0
  94. package/src/components/form/validation/shouldValidateOn.js +21 -0
  95. package/src/components/form/validation/validateRules.js +83 -0
  96. package/src/components/form/validation/validators.js +82 -0
  97. package/src/components/index.js +1 -0
  98. package/src/components/inputs/InputWrapper.js +1 -1
  99. package/src/components/inputs/NumberInput.js +6 -5
  100. package/src/components/inputs/Picker.js +3 -2
  101. package/src/components/inputs/Select.js +31 -15
  102. package/src/components/presentation/Avatar.js +2 -2
  103. package/src/components/presentation/AvatarLabel.js +2 -0
  104. package/src/components/presentation/LabelValue.js +7 -5
  105. package/src/components/presentation/Result.js +2 -2
  106. package/src/components/presentation/Tooltip.js +1 -1
  107. package/src/components/sections/Section.js +50 -0
  108. package/src/components/sections/SectionItem.js +24 -0
  109. package/src/components/sections/SectionItemLink.js +33 -0
  110. package/src/components/sections/index.js +3 -0
  111. package/src/components/state/StatePresenter.js +41 -0
  112. package/src/components/state/index.js +1 -0
  113. package/src/components/structure/BlurView.js +1 -0
  114. package/src/components/structure/KeyboardAvoidingView.js +52 -0
  115. package/src/components/structure/TopBar.js +45 -0
  116. package/src/components/structure/bottomDrawer/index.js +2 -0
  117. package/src/components/structure/bottomDrawer/index.native.js +2 -1
  118. package/src/components/structure/bottomDrawer/index.web.js +2 -1
  119. package/src/components/structure/bottomDrawer/native/BottomDrawer.js +14 -20
  120. package/src/components/structure/bottomDrawer/native/DrawerScrollView.js +4 -82
  121. package/src/components/structure/bottomDrawer/native/createDrawerScrollComponent.js +131 -0
  122. package/src/components/structure/index.js +2 -0
  123. package/src/components/text/DateText.js +11 -0
  124. package/src/components/text/index.js +1 -0
  125. package/src/components/theme/ThemePicker.js +1 -2
  126. package/src/helpers/index.js +1 -0
  127. package/src/helpers/storage.js +32 -9
  128. package/src/responsive/responsiveHooks.js +6 -0
  129. package/src/theme/ThemeHandler.js +6 -3
  130. package/src/theme/default/base.js +16 -4
  131. package/src/theme/default/blackTheme.js +1 -0
  132. package/src/theme/default/cyberpunkTheme.js +10 -0
  133. package/src/theme/default/darkTheme.js +1 -0
  134. package/src/theme/default/hackerTheme.js +17 -3
  135. package/src/theme/default/lightTheme.js +1 -0
  136. package/src/theme/default/msdosTheme.js +9 -10
  137. package/src/theme/default/paperTheme.js +10 -0
@@ -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
- return AbsStorage.set(key, JSON.stringify(value))
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.setAsync(key).then((value) => {
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) || defaultValue)
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 toggleTheme = () => setActiveThemeKey(activeThemeKey === 'light' ? 'dark' : 'light')
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: 20,
43
- sm: 30,
44
- md: 35,
45
- lg: 40,
54
+ xs: 25,
55
+ sm: 35,
56
+ md: 40,
57
+ lg: 45,
46
58
  xl: 50,
47
59
  xxl: 60,
48
60
  xxxl: 70,
@@ -16,6 +16,7 @@ export const DEFAULT_BLACK_THEME = mergeDeepRight(BASE_THEME, {
16
16
  overlayBG: '#000000',
17
17
  backdrop: '#1f1f1f',
18
18
  shadow: 'rgba(216, 210, 203, 0.1)',
19
+ transparent: 'rgba(0, 0, 0, 0)',
19
20
  divider: '#383E44',
20
21
 
21
22
  blue: '#4DA3FF',
@@ -31,4 +31,14 @@ export const CYBERPUNK_DARK_THEME = mergeDeepRight(BASE_THEME, {
31
31
  lylac: '#B388FF',
32
32
  pink: '#FF80AB',
33
33
  },
34
+
35
+ components: {
36
+ Card: {
37
+ border: true,
38
+ },
39
+
40
+ Section: {
41
+ border: true,
42
+ },
43
+ },
34
44
  })
@@ -15,6 +15,7 @@ export const DEFAULT_DARK_THEME = mergeDeepRight(BASE_THEME, {
15
15
  overlayBG: '#272D34',
16
16
  backdrop: '#383E44',
17
17
  shadow: 'rgba(216, 210, 203, 0.1)',
18
+ transparent: 'rgba(0, 0, 0, 0)',
18
19
  divider: '#383E44',
19
20
 
20
21
  blue: '#4DA3FF',
@@ -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: 1,
39
- br: 5,
40
- borderColor: 'divider',
50
+ border: true,
51
+ },
52
+
53
+ Section: {
54
+ border: true,
41
55
  },
42
56
  },
43
57
  })
@@ -15,6 +15,7 @@ export const DEFAULT_LIGHT_THEME = mergeDeepRight(BASE_THEME, {
15
15
  overlayBG: '#FFFFFF',
16
16
  backdrop: '#383E44',
17
17
  shadow: 'rgba(39, 45, 52, 0.15)',
18
+ transparent: 'rgba(255, 255, 255, 0)',
18
19
  divider: '#e0e0e0',
19
20
 
20
21
  blue: '#4DA3FF',
@@ -34,21 +34,20 @@ export const DEFAULT_MSDOS_THEME = mergeDeepRight(BASE_THEME, {
34
34
  },
35
35
 
36
36
  radius: {
37
- xxxs: 1,
38
- xxs: 2,
39
- xs: 3,
40
- sm: 4,
41
- md: 6,
42
- lg: 8,
43
- xl: 10,
44
- xxl: 12,
45
- xxxl: 14,
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
  },
@@ -32,4 +32,14 @@ export const DEFAULT_PAPER_THEME = mergeDeepRight(BASE_THEME, {
32
32
  lylac: '#C7B7D4',
33
33
  pink: '#E4A1B2',
34
34
  },
35
+
36
+ components: {
37
+ Card: {
38
+ border: true,
39
+ },
40
+
41
+ Section: {
42
+ border: true,
43
+ },
44
+ },
35
45
  })