react-native-molecules 0.5.0-beta.0 → 0.5.0-beta.1

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.
@@ -2,13 +2,14 @@ import {
2
2
  createContext,
3
3
  forwardRef,
4
4
  memo,
5
- ReactElement,
6
- ReactNode,
5
+ type ReactElement,
6
+ type ReactNode,
7
7
  useContext,
8
8
  useEffect,
9
9
  useMemo,
10
10
  } from 'react';
11
11
  import { View, type ViewProps } from 'react-native';
12
+
12
13
  import { useControlledValue, useSubcomponents } from '../../hooks';
13
14
  import type { WithElements } from '../../types';
14
15
  import { AccordionContext } from './Accordion';
@@ -1,5 +1,6 @@
1
1
  import { memo } from 'react';
2
2
  import { View, type ViewProps } from 'react-native';
3
+
3
4
  import { accordionItemContentStyles } from './utils';
4
5
 
5
6
  export type Props = ViewProps & {};
@@ -1,12 +1,13 @@
1
- import { forwardRef, memo, ReactNode, useCallback, useContext, useMemo } from 'react';
1
+ import { forwardRef, memo, type ReactNode, useCallback, useContext, useMemo } from 'react';
2
+ import { type GestureResponderEvent, type TextStyle, View, type ViewStyle } from 'react-native';
3
+
4
+ import { useActionState } from '../../hooks';
2
5
  import type { WithElements } from '../../types';
6
+ import { resolveStateVariant } from '../../utils';
7
+ import { Text } from '../Text';
3
8
  import { TouchableRipple, type TouchableRippleProps } from '../TouchableRipple';
4
9
  import { AccordionItemContext } from './AccordionItem';
5
- import { View, type GestureResponderEvent, type TextStyle, type ViewStyle } from 'react-native';
6
- import { Text } from '../Text';
7
10
  import { accordionItemHeaderStyles } from './utils';
8
- import { resolveStateVariant } from '../../utils';
9
- import { useActionState } from '../../hooks';
10
11
 
11
12
  export type AccordionHeaderElementProps = {
12
13
  color: string;
@@ -1,8 +1,8 @@
1
+ import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
2
+ import AccordionDefault from './Accordion';
1
3
  import AccordionItemComponent from './AccordionItem';
2
- import AccordionItemHeader from './AccordionItemHeader';
3
4
  import AccordionItemContent from './AccordionItemContent';
4
- import AccordionDefault from './Accordion';
5
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
5
+ import AccordionItemHeader from './AccordionItemHeader';
6
6
 
7
7
  const AccordionItemDefault = Object.assign(AccordionItemComponent, {
8
8
  Header: AccordionItemHeader,
@@ -22,15 +22,14 @@ export const AccordionItem = getRegisteredComponentWithFallback(
22
22
 
23
23
  export type { Props as AccordionProps } from './Accordion';
24
24
  export type { Props as AccordionItemProps } from './AccordionItem';
25
+ export type { Props as AccordionItemContentProps } from './AccordionItemContent';
25
26
  export type {
26
- Props as AccordionItemHeaderProps,
27
27
  AccordionHeaderElementProps,
28
+ Props as AccordionItemHeaderProps,
28
29
  } from './AccordionItemHeader';
29
- export type { Props as AccordionItemContentProps } from './AccordionItemContent';
30
-
31
30
  export {
32
- accordionStyles,
33
- accordionItemStyles,
34
- accordionItemHeaderStyles,
35
31
  accordionItemContentStyles,
32
+ accordionItemHeaderStyles,
33
+ accordionItemStyles,
34
+ accordionStyles,
36
35
  } from './utils';
@@ -13,8 +13,6 @@ export const sizeToIconSizeMap = {
13
13
  const defaultStylesDefault = StyleSheet.create(theme => {
14
14
  return {
15
15
  root: {
16
- flexGrow: 1,
17
-
18
16
  variants: {
19
17
  size: {
20
18
  sm: {
@@ -10,5 +10,5 @@ export const DatePickerInput = getRegisteredComponentWithFallback(
10
10
  DatePickerInputDefault,
11
11
  );
12
12
 
13
- export { DatePickerInputProps } from './types';
13
+ export type { DatePickerInputProps } from './types';
14
14
  export { datePickerInputStyles } from './utils';
@@ -170,7 +170,7 @@ const fabStylesDefault = StyleSheet.create(theme => ({
170
170
  label: {
171
171
  fontSize: theme.typescale.labelSmall.fontSize,
172
172
  lineHeight: theme.typescale.labelSmall.lineHeight,
173
- fontWeight: theme.typescale.labelMedium.labelSmall,
173
+ fontWeight: theme.typescale.labelSmall.fontWeight,
174
174
  marginLeft: theme.spacings['1'],
175
175
  variants: {
176
176
  state: {
@@ -1,6 +1,5 @@
1
1
  import { forwardRef, memo, useMemo } from 'react';
2
2
  import { StyleSheet } from 'react-native-unistyles';
3
- import type { Mappings } from 'react-native-unistyles/lib/typescript/src/core/withUnistyles/types';
4
3
 
5
4
  import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
6
5
  import { tokenStylesParser } from '../../utils/tokenStylesParser';
@@ -10,15 +9,7 @@ import type { IconProps } from './types';
10
9
  /**
11
10
  * Neutral component. Doesn't have platform specific styles
12
11
  */
13
- const Icon = (
14
- {
15
- type = 'material-community',
16
- style,
17
- color,
18
- ...rest
19
- }: IconProps & { uniProps?: Mappings<any> },
20
- ref: any,
21
- ) => {
12
+ const Icon = ({ type = 'material-community', style, color, ...rest }: IconProps, ref: any) => {
22
13
  const IconComponent = iconFactory(type);
23
14
  const componentStyles = useMemo(
24
15
  () => [styles.root, style, tokenStylesParser.getColor(color as string)],
@@ -1,17 +1,16 @@
1
1
  import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
3
  import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
4
- import { getCursorStyle } from '../../utils';
5
4
 
6
5
  // type States = 'disabled' | 'hovered';
7
6
 
8
7
  const linkStylesDefault = StyleSheet.create(theme => ({
9
8
  root: {
10
- ...getCursorStyle('pointer'),
11
9
  color: theme.colors.primary,
12
10
  ...theme.typescale.labelLarge,
13
11
 
14
12
  _web: {
13
+ cursor: 'pointer',
15
14
  _hover: {
16
15
  textDecorationLine: 'underline',
17
16
  },
@@ -22,7 +21,10 @@ const linkStylesDefault = StyleSheet.create(theme => ({
22
21
  disabled: {
23
22
  color: theme.colors.onSurfaceDisabled,
24
23
  opacity: 0.38,
25
- ...getCursorStyle('pointer'),
24
+
25
+ _web: {
26
+ cursor: 'not-allowed',
27
+ },
26
28
  },
27
29
  default: {},
28
30
  },
@@ -128,7 +128,8 @@ const NavigationRailItem = memo(
128
128
  iconContainerStyle: [
129
129
  navigationRailItemStyles.iconContainer,
130
130
  !label && {
131
- height: navigationRailItemStyles.iconContainer.width,
131
+ // TODO - remove this. We cannot do it like this
132
+ height: (navigationRailItemStyles.iconContainer as any).width,
132
133
  },
133
134
  iconContainerProps.style,
134
135
  ],
@@ -20,8 +20,7 @@ registerMoleculesComponents({
20
20
 
21
21
  export const RadioButton = getRegisteredComponentWithFallback('RadioButton', RadioButtonDefault);
22
22
 
23
- export { Props as RadioButtonProps } from './RadioButton';
24
- export { Props as RadioButtonGroupProps } from './RadioButtonGroup';
25
- export { Props as RadioButtonItemProps } from './RadioButtonItem';
26
-
27
- export { radioButtonStyles, radioButtonItemStyles } from './utils';
23
+ export type { Props as RadioButtonProps } from './RadioButton';
24
+ export type { Props as RadioButtonGroupProps } from './RadioButtonGroup';
25
+ export type { Props as RadioButtonItemProps } from './RadioButtonItem';
26
+ export { radioButtonItemStyles, radioButtonStyles } from './utils';
@@ -1,8 +1,9 @@
1
1
  import { forwardRef, memo, useCallback, useMemo } from 'react';
2
2
  import { Pressable, type ViewStyle } from 'react-native';
3
+
4
+ import { resolveStateVariant } from '../../utils';
3
5
  import { Icon, type IconProps, type IconType } from '../Icon';
4
6
  import { Tooltip, type TooltipProps } from '../Tooltip';
5
- import { resolveStateVariant } from '../../utils';
6
7
  import { ratingItemStyles } from './utils';
7
8
 
8
9
  export type Props = Omit<IconProps, 'ref'> & {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Children,
3
3
  cloneElement,
4
- FC,
4
+ type FC,
5
5
  isValidElement,
6
6
  memo,
7
- ReactElement,
7
+ type ReactElement,
8
8
  useCallback,
9
9
  useEffect,
10
10
  useMemo,
@@ -13,20 +13,21 @@ import {
13
13
  } from 'react';
14
14
  import {
15
15
  Animated,
16
- StyleProp,
17
- ViewStyle,
18
- ViewProps,
16
+ type LayoutChangeEvent,
17
+ type NativeScrollEvent,
18
+ type NativeSyntheticEvent,
19
19
  ScrollView as RNScrollView,
20
- LayoutChangeEvent,
21
- NativeSyntheticEvent,
22
- NativeScrollEvent,
23
- View,
24
20
  ScrollView,
21
+ type StyleProp,
22
+ View,
23
+ type ViewProps,
24
+ type ViewStyle,
25
25
  } from 'react-native';
26
- import type { TabItemProps } from './TabItem';
26
+
27
27
  import { useControlledValue } from '../../hooks';
28
28
  import { noop } from '../../utils/lodash';
29
29
  import { HorizontalDivider, type HorizontalDividerProps } from '../HorizontalDivider';
30
+ import type { TabItemProps } from './TabItem';
30
31
  import { tabsStyles } from './utils';
31
32
 
32
33
  export type TabsProps = ViewProps & {
@@ -100,7 +101,7 @@ export const TabBase = ({
100
101
  const nameToIndexMap = useMemo(
101
102
  () =>
102
103
  validChildren.reduce((acc, child, currentIndex) => {
103
- acc[(child as ReactElement).props?.name] = currentIndex;
104
+ acc[(child as ReactElement<TabItemProps>).props?.name] = currentIndex;
104
105
 
105
106
  return acc;
106
107
  }, {} as Record<string, number>),
@@ -110,7 +111,7 @@ export const TabBase = ({
110
111
  const [value, onChange] = useControlledValue({
111
112
  value: valueProp,
112
113
  onChange: onChangeProp,
113
- defaultValue: defaultValue || (validChildren[0] as ReactElement)?.props?.name,
114
+ defaultValue: defaultValue || (validChildren[0] as ReactElement<TabItemProps>)?.props?.name,
114
115
  });
115
116
 
116
117
  const valueIndex = nameToIndexMap[value];
@@ -311,7 +312,7 @@ export const TabBase = ({
311
312
  style={itemsContainerStyle}>
312
313
  {validChildren.map((child, index) => (
313
314
  <ChildItem
314
- key={(child as ReactElement).props?.name}
315
+ key={(child as ReactElement<TabItemProps>).props?.name}
315
316
  testID={testID && `${testID}--tab-item`}
316
317
  index={index}
317
318
  value={value}
@@ -1,7 +1,7 @@
1
1
  import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
2
2
  import TooltipComponent from './Tooltip';
3
- import TooltipTrigger from './TooltipTrigger';
4
3
  import TooltipContent from './TooltipContent';
4
+ import TooltipTrigger from './TooltipTrigger';
5
5
 
6
6
  export const TooltipDefault = Object.assign(TooltipComponent, {
7
7
  Trigger: TooltipTrigger,
@@ -14,7 +14,7 @@ registerMoleculesComponents({
14
14
 
15
15
  export const Tooltip = getRegisteredComponentWithFallback('Tooltip', TooltipDefault);
16
16
 
17
- export { Props as TooltipProps } from './Tooltip';
18
- export { Props as TooltipTriggerProps } from './TooltipTrigger';
19
- export { Props as TooltipContentProps } from './TooltipContent';
17
+ export type { Props as TooltipProps } from './Tooltip';
18
+ export type { Props as TooltipContentProps } from './TooltipContent';
19
+ export type { Props as TooltipTriggerProps } from './TooltipTrigger';
20
20
  export { tooltipStyles } from './utils';
package/hooks/index.tsx CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  export * from './useActionState';
4
4
  export * from './useActive';
5
- export { default as useBreakpoints } from './useBreakpoints';
6
5
  export { default as useColorMode } from './useColorMode';
7
6
  export { useContrastColor } from './useContrastColor';
8
7
  export { default as useControlledValue } from './useControlledValue';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-molecules",
3
- "version": "0.5.0-beta.0",
3
+ "version": "0.5.0-beta.1",
4
4
  "author": "Thet Aung <thetaung.dev@gmail.com>",
5
5
  "license": "MIT",
6
6
  "main": "index.ts",
@@ -1,7 +1,8 @@
1
- import type { Scope, Shortcut } from '../types';
2
- import { createFastContext } from '../../fast-context';
3
1
  import type { ReactNode } from 'react';
4
2
 
3
+ import { createFastContext } from '../../fast-context';
4
+ import type { Scope, Shortcut } from '../types';
5
+
5
6
  export type ShortcutsManagerContextType = {
6
7
  shortcuts: Record<string, Shortcut>;
7
8
  scopes: Record<string, Scope>;
@@ -1,2 +1,2 @@
1
- export { default as useShortcut } from './useShortcut';
2
1
  export * from './types';
2
+ export { default as useShortcut } from './useShortcut';
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect } from 'react';
2
- import useLatest from '../../hooks/useLatest';
3
2
 
3
+ import useLatest from '../../hooks/useLatest';
4
4
  import { useShortcutsManagerStoreRef } from '../ShortcutsManager';
5
5
  import type { ShortcutEventDetail } from '../types';
6
6
  import { calculateShortcutEventName } from '../utils';
@@ -2,6 +2,8 @@ import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
3
  export const tokenStylesParser = StyleSheet.create(theme => ({
4
4
  getColor: (color: string | undefined, propertyName: string = 'color') => ({
5
- ...(color ? { [propertyName]: theme.colors[color] ?? color } : {}),
5
+ ...(color
6
+ ? { [propertyName]: theme.colors[color as keyof typeof theme.colors] ?? color }
7
+ : {}),
6
8
  }),
7
9
  }));
@@ -1,7 +0,0 @@
1
- import { useTheme } from './useTheme';
2
-
3
- const useBreakpoints = () => {
4
- return useTheme().grid.breakpoints;
5
- };
6
-
7
- export default useBreakpoints;