@codeleap/mobile 5.0.13 → 5.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 (65) hide show
  1. package/dist/components/Calendar/index.d.ts +3 -10
  2. package/dist/components/Calendar/index.js +15 -26
  3. package/dist/components/Calendar/index.js.map +1 -1
  4. package/dist/components/Calendar/styles.d.ts +3 -0
  5. package/dist/components/Calendar/styles.js +2 -0
  6. package/dist/components/Calendar/styles.js.map +1 -0
  7. package/dist/components/Calendar/types.d.ts +7 -93
  8. package/dist/components/CalendarInput/index.d.ts +13 -0
  9. package/dist/components/CalendarInput/index.js +88 -0
  10. package/dist/components/CalendarInput/index.js.map +1 -0
  11. package/dist/components/CalendarInput/styles.d.ts +3 -0
  12. package/dist/components/CalendarInput/styles.js +2 -0
  13. package/dist/components/CalendarInput/styles.js.map +1 -0
  14. package/dist/components/CalendarInput/types.d.ts +24 -0
  15. package/dist/components/CalendarInput/types.js +2 -0
  16. package/dist/components/CalendarInput/types.js.map +1 -0
  17. package/dist/components/InputBase/index.d.ts +1 -0
  18. package/dist/components/InputBase/index.js +1 -0
  19. package/dist/components/InputBase/index.js.map +1 -1
  20. package/dist/components/InputBase/types.d.ts +2 -1
  21. package/dist/components/Tabs/Context.d.ts +11 -0
  22. package/dist/components/Tabs/Context.js +26 -0
  23. package/dist/components/Tabs/Context.js.map +1 -0
  24. package/dist/components/Tabs/Panel.d.ts +11 -0
  25. package/dist/components/Tabs/Panel.js +17 -0
  26. package/dist/components/Tabs/Panel.js.map +1 -0
  27. package/dist/components/Tabs/Tab.d.ts +10 -0
  28. package/dist/components/Tabs/Tab.js +31 -0
  29. package/dist/components/Tabs/Tab.js.map +1 -0
  30. package/dist/components/Tabs/TabList.d.ts +5 -0
  31. package/dist/components/Tabs/TabList.js +7 -0
  32. package/dist/components/Tabs/TabList.js.map +1 -0
  33. package/dist/components/Tabs/index.d.ts +35 -0
  34. package/dist/components/Tabs/index.js +36 -0
  35. package/dist/components/Tabs/index.js.map +1 -0
  36. package/dist/components/Tabs/styles.d.ts +4 -0
  37. package/dist/components/Tabs/styles.js +2 -0
  38. package/dist/components/Tabs/styles.js.map +1 -0
  39. package/dist/components/Tabs/types.d.ts +20 -0
  40. package/dist/components/Tabs/types.js +2 -0
  41. package/dist/components/Tabs/types.js.map +1 -0
  42. package/dist/components/TextInput/index.js +5 -5
  43. package/dist/components/TextInput/index.js.map +1 -1
  44. package/dist/components/components.d.ts +2 -0
  45. package/dist/components/components.js +2 -0
  46. package/dist/components/components.js.map +1 -1
  47. package/package.json +18 -18
  48. package/package.json.bak +2 -2
  49. package/src/components/Calendar/index.tsx +24 -39
  50. package/src/components/Calendar/styles.ts +5 -0
  51. package/src/components/Calendar/types.ts +11 -101
  52. package/src/components/CalendarInput/index.tsx +150 -0
  53. package/src/components/CalendarInput/styles.ts +7 -0
  54. package/src/components/CalendarInput/types.ts +29 -0
  55. package/src/components/InputBase/index.tsx +2 -0
  56. package/src/components/InputBase/types.ts +2 -1
  57. package/src/components/Tabs/Context.tsx +40 -0
  58. package/src/components/Tabs/Panel.tsx +31 -0
  59. package/src/components/Tabs/Tab.tsx +69 -0
  60. package/src/components/Tabs/TabList.tsx +19 -0
  61. package/src/components/Tabs/index.tsx +66 -0
  62. package/src/components/Tabs/styles.ts +11 -0
  63. package/src/components/Tabs/types.ts +27 -0
  64. package/src/components/TextInput/index.tsx +5 -3
  65. package/src/components/components.ts +3 -1
@@ -0,0 +1,36 @@
1
+ import { View } from '../View';
2
+ import { TabsProvider } from './Context';
3
+ import { Panel } from './Panel';
4
+ import { Tab } from './Tab';
5
+ import { TabList } from './TabList';
6
+ import { MobileStyleRegistry } from '../../Registry';
7
+ import { useStylesFor } from '../../hooks';
8
+ export { useTabContext } from './Context';
9
+ export * from './types';
10
+ export * from './styles';
11
+ export const Tabs = (props) => {
12
+ const { style, value, onValueChange, defaultValue, keepMounted, children, ...rest } = {
13
+ ...Tabs.defaultProps,
14
+ ...props,
15
+ };
16
+ const styles = useStylesFor(Tabs.styleRegistryName, style);
17
+ return <View {...rest} style={styles?.wrapper}>
18
+ <TabsProvider value={value} onValueChange={onValueChange} defaultValue={defaultValue} styles={styles} keepMounted={keepMounted}>
19
+ {children}
20
+ </TabsProvider>
21
+ </View>;
22
+ };
23
+ Tabs.Tab = Tab;
24
+ Tabs.TabList = TabList;
25
+ Tabs.Panel = Panel;
26
+ Tabs.styleRegistryName = 'Tabs';
27
+ Tabs.elements = ['wrapper', 'tab', 'panel'];
28
+ Tabs.rootElement = 'wrapper';
29
+ Tabs.withVariantTypes = (styles) => {
30
+ return Tabs;
31
+ };
32
+ Tabs.defaultProps = {
33
+ keepMounted: true,
34
+ };
35
+ MobileStyleRegistry.registerComponent(Tabs);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tabs/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AAExB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAgB,EAAE,EAAE;IACvC,MAAM,EACJ,KAAK,EACL,KAAK,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,GAAG,IAAI,EACR,GAAG;QACF,GAAG,IAAI,CAAC,YAAY;QACpB,GAAG,KAAK;KACT,CAAA;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAE1D,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAC5C;IAAA,CAAC,YAAY,CACX,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,WAAW,CAAC,CAAC,WAAW,CAAC,CAEzB;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,YAAY,CAChB;EAAA,EAAE,IAAI,CAAC,CAAA;AACT,CAAC,CAAA;AAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;AACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;AACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;AAElB,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAA;AAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAC3C,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;AAE5B,IAAI,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACzD,OAAO,IAIN,CAAA;AACH,CAAC,CAAA;AAED,IAAI,CAAC,YAAY,GAAG;IAClB,WAAW,EAAE,IAAI;CACI,CAAA;AAEvB,mBAAmB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ type TabStates = 'active' | 'disabled';
2
+ type TabComposition = 'wrapper' | 'icon' | 'text';
3
+ export type TabsComposition = 'wrapper' | 'panel' | 'tabList' | 'tabListContainer' | `tab${Capitalize<TabComposition>}` | `tab${Capitalize<TabComposition>}:${TabStates}`;
4
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/Tabs/styles.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { ICSS, StyledProp } from '@codeleap/styles';
2
+ import { ReactNode } from 'react';
3
+ import { TabsComposition } from './styles';
4
+ import { ViewProps } from '../View';
5
+ export type TabsContextProps = {
6
+ defaultValue: string;
7
+ value?: string;
8
+ onValueChange?: (newValue: string) => void;
9
+ children?: ReactNode;
10
+ keepMounted?: boolean;
11
+ };
12
+ export type TabsProps = TabsContextProps & Omit<ViewProps, 'style'> & {
13
+ style?: StyledProp<TabsComposition>;
14
+ };
15
+ export type TabsStyles = Record<TabsComposition, ICSS>;
16
+ export type TabPropsWithCtx<P> = P & {
17
+ active?: boolean;
18
+ setValue?: (value: string) => void;
19
+ styles: TabsStyles;
20
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Tabs/types.ts"],"names":[],"mappings":""}
@@ -17,7 +17,7 @@ export const TextInput = forwardRef((props, inputRef) => {
17
17
  ...props,
18
18
  };
19
19
  const { inputBaseProps, others, } = selectInputBaseProps(allProps);
20
- const { debugName, visibilityToggle, masking, secure, field, onChangeMask, onPress, visibleIcon, hiddenIcon, style, autoAdjustSelection, selectionStart, forceError, multiline, ...textInputProps } = others;
20
+ const { debugName, visibilityToggle, masking, secure, field, onChangeMask, onPress, visibleIcon, hiddenIcon, style, autoAdjustSelection, selectionStart, forceError, multiline, onLayout, ...textInputProps } = others;
21
21
  const styles = useStylesFor(TextInput.styleRegistryName, style);
22
22
  const { validation, inputValue, onInputValueChange, innerInputRef, wrapperRef, isFocused, secureTextEntry, currentSelection, hasMultipleLines, hasValue, hasError, toggleSecureTextEntry, handleMaskChange, handleBlur, handleFocus, } = useTextInput(allProps);
23
23
  const InputElement = masking ? MaskedTextInput : NativeTextInput;
@@ -26,7 +26,7 @@ export const TextInput = forwardRef((props, inputRef) => {
26
26
  const partialStyles = useInputBasePartialStyles(styles, ['placeholder', 'selection'], {
27
27
  disabled: isDisabled,
28
28
  error: !!hasError,
29
- focus: isFocused,
29
+ focus: isFocused || textInputProps?.focused,
30
30
  });
31
31
  const visibilityToggleProps = visibilityToggle ? {
32
32
  onPress: toggleSecureTextEntry,
@@ -49,7 +49,7 @@ export const TextInput = forwardRef((props, inputRef) => {
49
49
  editable: false,
50
50
  caretHidden: true,
51
51
  } : {};
52
- return <InputBase {...inputBaseProps} ref={wrapperRef} innerWrapper={isPressable ? Touchable : undefined} debugName={debugName} error={hasError ? validation?.message || forceError : null} style={{
52
+ return <InputBase {...inputBaseProps} onLayout={onLayout} ref={wrapperRef} innerWrapper={isPressable ? Touchable : undefined} debugName={debugName} error={hasError ? validation?.message || forceError : null} style={{
53
53
  ...styles,
54
54
  innerWrapper: [
55
55
  styles?.innerWrapper,
@@ -61,11 +61,11 @@ export const TextInput = forwardRef((props, inputRef) => {
61
61
  onPress,
62
62
  debugName,
63
63
  dismissKeyboard: false,
64
- }} rightIcon={rightIcon} focused={isFocused} hasValue={hasValue}>
64
+ }} rightIcon={rightIcon} focused={isFocused || textInputProps?.focused} hasValue={hasValue}>
65
65
  <InputElement allowFontScaling={false} editable={!isPressable && !isDisabled} {...buttonModeProps} selection={autoAdjustSelection ? currentSelection : undefined} placeholderTextColor={partialStyles?.placeholder?.color} selectionColor={partialStyles?.selection?.color} secureTextEntry={secure && secureTextEntry} textAlignVertical={multiline ? 'top' : undefined} multiline={multiline} {...textInputProps} value={inputValue} onChangeText={onInputValueChange} onBlur={handleBlur} onFocus={handleFocus} style={[
66
66
  styles?.input,
67
67
  multiline && styles['input:multiline'],
68
- isFocused && styles['input:focused'],
68
+ (isFocused || textInputProps?.focused) && styles['input:focused'],
69
69
  hasError && styles['input:error'],
70
70
  isDisabled && styles['input:disabled'],
71
71
  hasMultipleLines && styles['input:hasMultipleLines'],
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAA;AAElF,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAkC,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IACvF,MAAM,QAAQ,GAAG;QACf,GAAG,SAAS,CAAC,YAAY;QACzB,GAAG,KAAK;KACT,CAAA;IAED,MAAM,EACJ,cAAc,EACd,MAAM,GACP,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAElC,MAAM,EACJ,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,MAAM,EACN,KAAK,EACL,YAAY,EACZ,OAAO,EACP,WAAW,EACX,UAAU,EACV,KAAK,EACL,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,SAAS,EACT,GAAG,cAAc,EAClB,GAAG,MAAM,CAAA;IAEV,MAAM,MAAM,G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AC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAChD,IAAI,iBAAiB,CAAC,EAE1B;EAAA,EAAE,SAAS,CAAC,CAAA;AACd,CAAC,CAA6C,CAAA;AAE9C,SAAS,CAAC,iBAAiB,GAAG,WAAW,CAAA;AACzC,SAAS,CAAC,QAAQ,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;AACjF,SAAS,CAAC,WAAW,GAAG,SAAS,CAAA;AAEjC,SAAS,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC9D,OAAO,SAAiF,CAAA;AAC1F,CAAC,CAAA;AAED,SAAS,CAAC,YAAY,GAAG;IACvB,UAAU,EAAE,wBAAmC;IAC/C,WAAW,EAAE,yBAAoC;IACjD,gBAAgB,EAAE,KAAK;IACvB,mBAAmB,EAAE,KAAK;IAC1B,cAAc,EAAE,CAAC;IACjB,MAAM,EAAE,KAAK;CACa,CAAA;AAE5B,mBAAmB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA"}
@@ -39,3 +39,5 @@ export * from './PaginationIndicator';
39
39
  export * from './PlacesAutocomplete';
40
40
  export * from './SortablePhotos';
41
41
  export * from './SectionFilters';
42
+ export * from './Tabs';
43
+ export * from './CalendarInput';
@@ -39,4 +39,6 @@ export * from './PaginationIndicator';
39
39
  export * from './PlacesAutocomplete';
40
40
  export * from './SortablePhotos';
41
41
  export * from './SectionFilters';
42
+ export * from './Tabs';
43
+ export * from './CalendarInput';
42
44
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC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xB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "5.0.13",
3
+ "version": "5.1.0",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,28 +9,28 @@
9
9
  "directory": "packages/mobile"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/types": "5.0.13",
13
- "@codeleap/utils": "5.0.13",
14
- "@codeleap/hooks": "5.0.13",
15
- "@codeleap/form": "5.0.13",
16
- "@codeleap/query": "5.0.13",
17
- "@codeleap/logger": "5.0.13",
18
- "@codeleap/config": "5.0.13",
19
- "@codeleap/modals": "5.0.13"
12
+ "@codeleap/types": "5.1.0",
13
+ "@codeleap/utils": "5.1.0",
14
+ "@codeleap/hooks": "5.1.0",
15
+ "@codeleap/form": "5.1.0",
16
+ "@codeleap/query": "5.1.0",
17
+ "@codeleap/logger": "5.1.0",
18
+ "@codeleap/config": "5.1.0",
19
+ "@codeleap/modals": "5.1.0"
20
20
  },
21
21
  "scripts": {
22
22
  "build": "tsc --build",
23
23
  "lint": "eslint -c .eslintrc.js --fix \"./src/**/*.{ts,tsx,js,jsx}\""
24
24
  },
25
25
  "peerDependencies": {
26
- "@codeleap/types": "5.0.13",
27
- "@codeleap/utils": "5.0.13",
28
- "@codeleap/hooks": "5.0.13",
29
- "@codeleap/form": "5.0.13",
30
- "@codeleap/query": "5.0.13",
31
- "@codeleap/logger": "5.0.13",
32
- "@codeleap/styles": "5.0.13",
33
- "@codeleap/modals": "5.0.13",
26
+ "@codeleap/types": "5.1.0",
27
+ "@codeleap/utils": "5.1.0",
28
+ "@codeleap/hooks": "5.1.0",
29
+ "@codeleap/form": "5.1.0",
30
+ "@codeleap/query": "5.1.0",
31
+ "@codeleap/logger": "5.1.0",
32
+ "@codeleap/styles": "5.1.0",
33
+ "@codeleap/modals": "5.1.0",
34
34
  "@d11/react-native-fast-image": "8.9.2",
35
35
  "@react-native-firebase/messaging": "21.12.0",
36
36
  "@react-navigation/bottom-tabs": "7.3.1",
@@ -38,7 +38,7 @@
38
38
  "@react-navigation/native-stack": "7.3.1",
39
39
  "react": "18.2.0",
40
40
  "react-native": "0.77.1",
41
- "react-native-calendars": "1.1307.0",
41
+ "react-native-calendars": "1.1310.0",
42
42
  "react-native-date-picker": "5.0.10",
43
43
  "react-native-device-info": "14.0.4",
44
44
  "react-native-gesture-handler": "2.24.0",
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "5.0.13",
3
+ "version": "5.1.0",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "@react-navigation/native-stack": "7.3.1",
39
39
  "react": "18.2.0",
40
40
  "react-native": "0.77.1",
41
- "react-native-calendars": "1.1307.0",
41
+ "react-native-calendars": "1.1310.0",
42
42
  "react-native-date-picker": "5.0.10",
43
43
  "react-native-device-info": "14.0.4",
44
44
  "react-native-gesture-handler": "2.24.0",
@@ -1,67 +1,52 @@
1
- import React from 'react'
1
+ import React, { useCallback } from 'react'
2
2
  import { TypeGuards } from '@codeleap/types'
3
- import dayjs from 'dayjs'
4
- // @ts-ignore
5
- import { Calendar as RNCalendar, CalendarProps as RNCalendarProps, DateData } from 'react-native-calendars'
6
- import { View, ViewProps } from '../View'
7
- import { CalendarComposition } from './types'
8
- import { AnyRecord, IJSX, StyledComponentProps, StyledProp } from '@codeleap/styles'
3
+ import { Calendar as RNCalendar, DateData } from 'react-native-calendars'
4
+ import { AnyRecord, IJSX, StyledComponentProps } from '@codeleap/styles'
9
5
  import { MobileStyleRegistry } from '../../Registry'
10
6
  import { useStylesFor } from '../../hooks'
7
+ import { CalendarProps } from './types'
8
+ import dayjs from 'dayjs'
11
9
 
12
- export type CalendarProps =
13
- Omit<ViewProps, 'style'> &
14
- {
15
- onValueChange?: (date: Date | string) => any
16
- value?: Date | string
17
- calendarProps?: RNCalendarProps
18
- style?: StyledProp<CalendarComposition>
19
- }
20
-
10
+ export * from './styles'
21
11
  export * from './types'
22
12
 
23
13
  export const Calendar = (props: CalendarProps) => {
24
14
  const {
25
15
  style,
26
- calendarProps,
27
16
  value,
28
17
  onValueChange,
29
- ...viewProps
18
+ ...calendarProps
30
19
  } = props
31
20
 
32
21
  const styles = useStylesFor(Calendar.styleRegistryName, style)
33
22
 
34
- const isDateObject = TypeGuards.isInstance(value, Date)
35
- const stringValue: string = isDateObject ? dayjs(value).format('YYYY/MM/DD') : value
23
+ const isDateValue = TypeGuards.isInstance(value, Date)
24
+ const stringValue = isDateValue ? dayjs(value).format('YYYY-MM-DD') : value ?? ''
36
25
 
37
- function handleChange(date: DateData) {
38
- if (!onValueChange) return
39
- if (isDateObject) {
40
- onValueChange(new Date(date.timestamp))
41
- } else {
42
- onValueChange(date.dateString)
43
- }
44
- }
26
+ const onChange = useCallback((date: DateData) => {
27
+ const newValue = isDateValue ? dayjs(date.dateString).toDate() : date.dateString
28
+ onValueChange?.(newValue)
29
+ }, [onValueChange])
45
30
 
46
- return <View style={styles?.wrapper} {...viewProps}>
31
+ return (
47
32
  <RNCalendar
48
- onDayPress={handleChange}
49
- current={new Date(value).toISOString()}
33
+ onDayPress={onChange}
34
+ current={stringValue}
50
35
  monthFormat={'MMMM yyyy'}
51
- markedDates={{
52
- [stringValue]: { selected: true },
53
- }}
36
+ {...calendarProps}
37
+ markedDates={{ [stringValue]: { selected: true }, ...calendarProps?.markedDates }}
38
+ style={styles?.wrapper}
39
+ headerStyle={styles?.header}
54
40
  theme={{
55
- ...styles?.theme,
56
- stylesheet: styles,
41
+ ...styles?.calendar,
42
+ ...calendarProps?.theme,
57
43
  }}
58
- {...calendarProps}
59
44
  />
60
- </View>
45
+ )
61
46
  }
62
47
 
63
48
  Calendar.styleRegistryName = 'Calendar'
64
- Calendar.elements = ['wrapper', 'theme', 'calendar', 'day', 'agenda', 'expandable', 'event', 'timeLabel', 'textDayStyle', 'dotStyle', 'arrowStyle', 'contentStyle', 'timelineContainer', 'line', 'verticalLine', 'nowIndicator']
49
+ Calendar.elements = ['wrapper', 'header', 'calendar']
65
50
  Calendar.rootElement = 'wrapper'
66
51
 
67
52
  Calendar.withVariantTypes = <S extends AnyRecord>(styles: S) => {
@@ -0,0 +1,5 @@
1
+ import { Theme } from 'react-native-calendars/src/types'
2
+
3
+ export type CalendarComposition = 'wrapper' | 'header' | 'calendar'
4
+
5
+ export type CalendarThemeConfig = Theme
@@ -1,101 +1,11 @@
1
- import { FilterKeys, Paths } from '@codeleap/types'
2
- import { TextStyle, ViewStyle } from 'react-native'
3
-
4
- type CalendarTheme = {
5
- timelineContainer?: object
6
- contentStyle?: ViewStyle
7
- event?: object
8
- eventTitle?: object
9
- eventSummary?: object
10
- eventTimes?: object
11
- line?: object
12
- verticalLine?: object
13
- nowIndicatorLine?: object
14
- nowIndicatorKnob?: object
15
- timeLabel?: object
16
- todayTextColor?: string
17
- calendarBackground?: string
18
- indicatorColor?: string
19
- textSectionTitleColor?: string
20
- textSectionTitleDisabledColor?: string
21
- dayTextColor?: string
22
- selectedDayTextColor?: string
23
- monthTextColor?: string
24
- selectedDayBackgroundColor?: string
25
- arrowColor?: string
26
- textDisabledColor?: string
27
- textInactiveColor?: string
28
- backgroundColor?: string //TODO: remove in V2
29
- dotColor?: string
30
- selectedDotColor?: string
31
- disabledArrowColor?: string
32
- textDayFontFamily?: TextStyle['fontFamily']
33
- textMonthFontFamily?: TextStyle['fontFamily']
34
- textDayHeaderFontFamily?: TextStyle['fontFamily']
35
- textDayFontWeight?: TextStyle['fontWeight']
36
- textMonthFontWeight?: TextStyle['fontWeight']
37
- textDayHeaderFontWeight?: TextStyle['fontWeight']
38
- textDayFontSize?: number
39
- textMonthFontSize?: number
40
- textDayHeaderFontSize?: number
41
- agendaDayTextColor?: string
42
- agendaDayNumColor?: string
43
- agendaTodayColor?: string
44
- agendaKnobColor?: string
45
- todayButtonFontFamily?: TextStyle['fontFamily']
46
- todayButtonFontWeight?: TextStyle['fontWeight']
47
- todayButtonFontSize?: number
48
- textDayStyle?: TextStyle
49
- dotStyle?: object
50
- arrowStyle?: ViewStyle
51
- todayBackgroundColor?: string
52
- disabledDotColor?: string
53
- inactiveDotColor?: string
54
- todayDotColor?: string
55
- todayButtonTextColor?: string
56
- todayButtonPosition?: string
57
- arrowHeight?: number
58
- arrowWidth?: number
59
- weekVerticalMargin?: number
60
- stylesheet?: {
61
- calendar?: {
62
- main?: object
63
- header?: object
64
- }
65
- day?: {
66
- basic?: object
67
- period?: object
68
- }
69
- dot?: object
70
- marking?: object
71
- 'calendar-list'?: {
72
- main?: object
73
- }
74
- agenda?: {
75
- main?: object
76
- list?: object
77
- }
78
- expandable?: {
79
- main?: object
80
- }
81
- }
82
- }
83
-
84
- type FlatStyleKeys = 'dot' | 'marking'
85
-
86
- type StyleSheetKeys = Exclude<keyof CalendarTheme['stylesheet'], FlatStyleKeys>
87
-
88
- type ThemeObjPrimitiveKeys = FilterKeys<CalendarTheme, string|number>
89
-
90
- type ThemeObjCompositionKeys = Exclude<keyof CalendarTheme, ThemeObjPrimitiveKeys | 'stylesheet'>
91
-
92
- type StyleSheetObjKeys = Exclude<Paths<CalendarTheme['stylesheet']>, StyleSheetKeys>
93
-
94
- export type CalendarStyleGen<TCSS = any> = {
95
- theme?: Partial<{
96
- [P in ThemeObjPrimitiveKeys]: CalendarTheme[P]
97
- }>
98
- } & Partial<Record<StyleSheetObjKeys | 'wrapper' | ThemeObjCompositionKeys, TCSS>>
99
-
100
- export type CalendarComposition = keyof CalendarStyleGen
101
- export type TCalendarStyles = CalendarStyleGen<any>
1
+ import { StyledProp } from '@codeleap/styles'
2
+ import { CalendarProps as RNCalendarProps } from 'react-native-calendars'
3
+ import { CalendarComposition } from './styles'
4
+
5
+ export type CalendarProps =
6
+ Omit<RNCalendarProps, 'style'> &
7
+ {
8
+ onValueChange: (date: Date | string) => void
9
+ value: Date | string
10
+ style?: StyledProp<CalendarComposition>
11
+ }
@@ -0,0 +1,150 @@
1
+ import React, { useCallback, useState } from 'react'
2
+ import { AnyRecord, IJSX, StyledComponentProps, useCompositionStyles } from '@codeleap/styles'
3
+ import { MobileStyleRegistry } from '../../Registry'
4
+ import { useStylesFor } from '../../hooks'
5
+ import { CalendarInputProps } from './types'
6
+ import { View } from '../View'
7
+ import { Calendar } from '../Calendar'
8
+ import { TextInput } from '../TextInput'
9
+ import dayjs from 'dayjs'
10
+ import Animated, { FadeOut, FadeIn } from 'react-native-reanimated'
11
+ import { globalState } from '@codeleap/store'
12
+ import { useBooleanToggle, useId } from '@codeleap/hooks'
13
+ import { useInputBase } from '../InputBase'
14
+ import { fields } from '@codeleap/form'
15
+
16
+ export * from './styles'
17
+ export * from './types'
18
+
19
+ const calendarStore = globalState({})
20
+
21
+ const useCalendar = (id: string, autoClosePeersCalendars: boolean) => {
22
+ if (!autoClosePeersCalendars) return useBooleanToggle(false)
23
+
24
+ const isOpen = calendarStore.use(state => state[id])
25
+
26
+ const toggle = useCallback(() => {
27
+ const isCurrentlyOpen = calendarStore.value[id]
28
+ const isAnyOtherOpen = Object.entries(calendarStore.value).some(
29
+ ([key, isOpen]) => key !== id && isOpen
30
+ )
31
+
32
+ const newValues = Object.keys(calendarStore.value).reduce((acc, key) => {
33
+ acc[key] = false
34
+ return acc
35
+ }, {} as Record<string, boolean>)
36
+
37
+ if (isAnyOtherOpen && !isCurrentlyOpen) {
38
+ calendarStore.set(newValues)
39
+
40
+ setTimeout(() => {
41
+ calendarStore.set({ [id]: true })
42
+ }, 100)
43
+ } else {
44
+ calendarStore.set({ ...newValues, [id]: !isCurrentlyOpen })
45
+ }
46
+ }, [])
47
+
48
+ return [isOpen, toggle]
49
+ }
50
+
51
+ export const CalendarInput = (props: CalendarInputProps) => {
52
+ const {
53
+ style,
54
+ value,
55
+ onValueChange,
56
+ disabled,
57
+ gap,
58
+ calendarPosition,
59
+ rightIcon,
60
+ leftIcon,
61
+ autoClosePeersCalendars,
62
+ field,
63
+ format,
64
+ overlay,
65
+ ...textInputProps
66
+ } = {
67
+ ...CalendarInput.defaultProps,
68
+ ...props
69
+ }
70
+
71
+ const id = useId()
72
+
73
+ const styles = useStylesFor(CalendarInput.styleRegistryName, style)
74
+
75
+ const compositionStyles = useCompositionStyles(['calendar', 'input'], styles)
76
+
77
+ const {
78
+ inputValue,
79
+ onInputValueChange,
80
+ } = useInputBase<Date | string>(field, fields.date as any, { value, onValueChange })
81
+
82
+ const [inputHeight, setInputHeight] = useState(0)
83
+
84
+ const [isOpen, toggle] = useCalendar(id, autoClosePeersCalendars)
85
+
86
+ return (
87
+ <View style={[styles.wrapper, { position: 'relative' }]}>
88
+ <TextInput
89
+ placeholder='Select Date'
90
+ disabled={disabled}
91
+ {...textInputProps}
92
+ leftIcon={!leftIcon ? null : {
93
+ ...leftIcon,
94
+ onPress: toggle,
95
+ }}
96
+ rightIcon={!rightIcon ? null : {
97
+ ...rightIcon,
98
+ onPress: toggle,
99
+ }}
100
+ value={!inputValue ? '' : dayjs(inputValue).format(format)}
101
+ onValueChange={() => inputValue}
102
+ onPress={disabled ? null : toggle}
103
+ innerWrapperProps={{
104
+ rippleDisabled: true,
105
+ }}
106
+ focused={isOpen}
107
+ onLayout={(e) => setInputHeight(e.nativeEvent.layout.height)}
108
+ />
109
+
110
+ {!isOpen || disabled ? null : (
111
+ <Animated.View
112
+ exiting={FadeOut.duration(150)}
113
+ entering={FadeIn.duration(150)}
114
+ style={overlay ? {
115
+ position: 'absolute',
116
+ zIndex: 1,
117
+ [calendarPosition]: 0,
118
+ top: inputHeight + gap,
119
+ } : {
120
+ marginTop: gap,
121
+ }}
122
+ >
123
+ <Calendar
124
+ style={compositionStyles.calendar}
125
+ value={inputValue}
126
+ onValueChange={onInputValueChange}
127
+ />
128
+ </Animated.View>
129
+ )}
130
+ </View>
131
+ )
132
+ }
133
+
134
+ CalendarInput.styleRegistryName = 'CalendarInput'
135
+ CalendarInput.elements = ['wrapper', 'calendar', 'input']
136
+ CalendarInput.rootElement = 'wrapper'
137
+
138
+ CalendarInput.withVariantTypes = <S extends AnyRecord>(styles: S) => {
139
+ return CalendarInput as (props: StyledComponentProps<CalendarInputProps, typeof styles>) => IJSX
140
+ }
141
+
142
+ CalendarInput.defaultProps = {
143
+ gap: 8,
144
+ calendarPosition: 'left',
145
+ autoClosePeersCalendars: false,
146
+ format: 'DD/MM/YYYY',
147
+ overlay: true,
148
+ } as Partial<CalendarInputProps>
149
+
150
+ MobileStyleRegistry.registerComponent(CalendarInput)
@@ -0,0 +1,7 @@
1
+ import { TextInputComposition } from '../TextInput'
2
+ import { CalendarComposition } from '../Calendar'
3
+
4
+ export type CalendarInputComposition =
5
+ 'wrapper' |
6
+ `input${Capitalize<TextInputComposition>}` |
7
+ `calendar${Capitalize<CalendarComposition>}`
@@ -0,0 +1,29 @@
1
+ import { StyledProp } from '@codeleap/styles'
2
+ import { CalendarInputComposition } from './styles'
3
+ import { CalendarProps } from '../Calendar'
4
+ import { TextInputProps } from '../TextInput'
5
+ import { DateField } from '@codeleap/form'
6
+
7
+ export type CalendarInputProps =
8
+ Omit<TextInputProps, 'value' | 'onValueChange' | 'field' | 'style'> &
9
+ {
10
+ value?: CalendarProps['value']
11
+ onValueChange?: CalendarProps['onValueChange']
12
+ style?: StyledProp<CalendarInputComposition>
13
+ disabled?: boolean
14
+ gap?: number
15
+ field?: DateField<any>
16
+ format?: string
17
+ overlay?: boolean
18
+
19
+ /**
20
+ * Defines the position where the calendar will be anchored relative to the input.
21
+ */
22
+ calendarPosition?: 'left' | 'right'
23
+
24
+ /**
25
+ * If `true`, this calendar is part of a globally managed group.
26
+ * When one calendar in this group opens, all others with `autoClosePeersCalendars: true` will close.
27
+ */
28
+ autoClosePeersCalendars?: boolean
29
+ }