@tecsinapse/react-core 1.10.2 → 1.11.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/components/atoms/Avatar/styled.js +0 -3
  3. package/dist/components/atoms/Avatar/styled.js.map +1 -1
  4. package/dist/components/atoms/GroupButton/GroupButton.d.ts +1 -0
  5. package/dist/components/atoms/GroupButton/GroupButton.js +4 -1
  6. package/dist/components/atoms/GroupButton/GroupButton.js.map +1 -1
  7. package/dist/components/atoms/Input/hooks/useMask.js +1 -1
  8. package/dist/components/atoms/Input/hooks/useMask.js.map +1 -1
  9. package/dist/components/atoms/Input/masks/index.js +1 -1
  10. package/dist/components/atoms/Input/masks/index.js.map +1 -1
  11. package/dist/components/atoms/Switch/Switch.d.ts +1 -0
  12. package/dist/components/atoms/Switch/Switch.js +13 -5
  13. package/dist/components/atoms/Switch/Switch.js.map +1 -1
  14. package/dist/components/atoms/Switch/animation.js +4 -4
  15. package/dist/components/atoms/Switch/animation.js.map +1 -1
  16. package/dist/components/molecules/DatePicker/DatePicker.js +10 -2
  17. package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
  18. package/dist/components/molecules/DatePicker/Modal.js +4 -2
  19. package/dist/components/molecules/DatePicker/Modal.js.map +1 -1
  20. package/dist/components/molecules/DateTimePicker/DateTimePicker.js +3 -1
  21. package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  22. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +3 -1
  23. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
  24. package/dist/utils/extractNumbersFromString.d.ts +1 -0
  25. package/dist/utils/extractNumbersFromString.js +5 -1
  26. package/dist/utils/extractNumbersFromString.js.map +1 -1
  27. package/dist/utils/index.d.ts +1 -1
  28. package/dist/utils/index.js +6 -0
  29. package/dist/utils/index.js.map +1 -1
  30. package/package.json +2 -2
  31. package/src/components/atoms/Avatar/styled.ts +0 -1
  32. package/src/components/atoms/GroupButton/GroupButton.tsx +3 -1
  33. package/src/components/atoms/Input/hooks/useMask.ts +2 -4
  34. package/src/components/atoms/Input/masks/index.ts +1 -1
  35. package/src/components/atoms/Switch/Switch.stories.tsx +2 -1
  36. package/src/components/atoms/Switch/Switch.tsx +23 -9
  37. package/src/components/atoms/Switch/animation.ts +4 -4
  38. package/src/components/molecules/DatePicker/DatePicker.tsx +5 -3
  39. package/src/components/molecules/DatePicker/Modal.tsx +14 -11
  40. package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +3 -1
  41. package/src/components/molecules/DateTimeSelector/DateTimeSelector.tsx +1 -1
  42. package/src/utils/extractNumbersFromString.ts +6 -0
  43. package/src/utils/index.ts +4 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.11.1](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.11.0...@tecsinapse/react-core@1.11.1) (2021-12-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * complement active on transitionSwitch ([969a047](https://github.com/tecsinapse/design-system/commit/969a04748dc74107e22be6bc103e12c813ee232d))
12
+ * missing some locales on datetime formats ([97ca962](https://github.com/tecsinapse/design-system/commit/97ca9621dd67daf4b4d1f9e58783b3ba721a2e31))
13
+
14
+
15
+
16
+
17
+
18
+ # [1.11.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.4...@tecsinapse/react-core@1.11.0) (2021-12-17)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * [163127] Modais de picker do DS estão em inglês ([a95b0b2](https://github.com/tecsinapse/design-system/commit/a95b0b283f3535af20a23ac6a9a5e5633127d5b0))
24
+
25
+
26
+
27
+
28
+
29
+ ## [1.10.4](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.3...@tecsinapse/react-core@1.10.4) (2021-12-07)
30
+
31
+ **Note:** Version bump only for package @tecsinapse/react-core
32
+
33
+
34
+
35
+
36
+
37
+ ## [1.10.3](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.2...@tecsinapse/react-core@1.10.3) (2021-11-29)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * added method extractDigitsFromString ([76daa94](https://github.com/tecsinapse/design-system/commit/76daa943cc1be981b587830d0024c4a01c4df6e2))
43
+ * remove cursor css prop from avatar ([2f9ed15](https://github.com/tecsinapse/design-system/commit/2f9ed15bafb6697e2aee883b417574b4ee3275d5))
44
+
45
+
46
+
47
+
48
+
6
49
  ## [1.10.2](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.1...@tecsinapse/react-core@1.10.2) (2021-11-16)
7
50
 
8
51
 
@@ -22,9 +22,6 @@ const ContainerButtonAvatar = (0, _native.default)(_PressableSurface.PressableSu
22
22
  theme,
23
23
  size = 'mega'
24
24
  }) => theme.iconSize[size]};
25
- cursor: ${({
26
- onPress
27
- }) => onPress ? 'pointer' : 'default'};
28
25
  `;
29
26
  exports.ContainerButtonAvatar = ContainerButtonAvatar;
30
27
  const StyledAvatar = (0, _native.default)(_reactNative.Image)`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Avatar/styled.ts"],"names":["ContainerButtonAvatar","PressableSurface","theme","size","iconSize","onPress","StyledAvatar","Image","borderRadius","pill","StyledBackground","View","color","secondary","dark","getStyledTextComponent","component"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;;;AAIO,MAAMA,qBAAqB,GAAG,qBAAOC,kCAAP,CAEnC;AACF,WAAW,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,IAAI,GAAG;AAAhB,CAAD,KACPD,KAAK,CAACE,QAAN,CAAeD,IAAf,CAAqB;AACzB,YAAY,CAAC;AAAED,EAAAA,KAAF;AAASC,EAAAA,IAAI,GAAG;AAAhB,CAAD,KACRD,KAAK,CAACE,QAAN,CAAeD,IAAf,CAAqB;AACzB,YAAY,CAAC;AAAEE,EAAAA;AAAF,CAAD,KAAkBA,OAAO,GAAG,SAAH,GAAe,SAAW;AAC/D,CARO;;AAUA,MAAMC,YAAY,GAAG,qBAAOC,kBAAP,CAAmC;AAC/D,mBAAmB,CAAC;AAAEL,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACM,YAAN,CAAmBC,IAAK;AACtE;AACA;AACA;AACA,CALO;;AAOA,MAAMC,gBAAgB,GAAG,qBAAOC,iBAAP,CAAkC;AAClE,mBAAmB,CAAC;AAAET,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACM,YAAN,CAAmBC,IAAK;AACtE,sBAAsB,CAAC;AAAEP,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACU,KAAN,CAAYC,SAAZ,CAAsBC,IAAK;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA,CATO;;;AAWA,MAAMC,sBAAsB,GAAIC,SAAD,IAA8B;AAClE,SAAO,qBAAOA,SAAP,CAAkB;AAC3B;AACA;AACA;AACA;AACA,GALE;AAMD,CAPM","sourcesContent":["import styled from '@emotion/native';\nimport { FC } from 'react';\nimport { Image, View } from 'react-native';\nimport { StyleProps } from '../../../types/defaults';\nimport { PressableSurface } from '../PressableSurface';\nimport { TextProps } from '../Text';\nimport { AvatarProps } from './Avatar';\n\nexport const ContainerButtonAvatar = styled(PressableSurface)<\n Partial<StyleProps & AvatarProps>\n>`\n width: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>\n theme.iconSize[size]};\n height: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>\n theme.iconSize[size]};\n cursor: ${({ onPress }) => (onPress ? 'pointer' : 'default')};\n`;\n\nexport const StyledAvatar = styled(Image)<Partial<StyleProps>>`\n border-radius: ${({ theme }: StyleProps) => theme.borderRadius.pill};\n overflow: hidden;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledBackground = styled(View)<Partial<StyleProps>>`\n border-radius: ${({ theme }: StyleProps) => theme.borderRadius.pill};\n background-color: ${({ theme }: StyleProps) => theme.color.secondary.dark};\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: row;\n`;\n\nexport const getStyledTextComponent = (component: FC<TextProps>) => {\n return styled(component)`\n text-transform: uppercase;\n text-align: center;\n align-self: center;\n flex: 1;\n `;\n};\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Avatar/styled.ts"],"names":["ContainerButtonAvatar","PressableSurface","theme","size","iconSize","StyledAvatar","Image","borderRadius","pill","StyledBackground","View","color","secondary","dark","getStyledTextComponent","component"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;;;AAIO,MAAMA,qBAAqB,GAAG,qBAAOC,kCAAP,CAEnC;AACF,WAAW,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,IAAI,GAAG;AAAhB,CAAD,KACPD,KAAK,CAACE,QAAN,CAAeD,IAAf,CAAqB;AACzB,YAAY,CAAC;AAAED,EAAAA,KAAF;AAASC,EAAAA,IAAI,GAAG;AAAhB,CAAD,KACRD,KAAK,CAACE,QAAN,CAAeD,IAAf,CAAqB;AACzB,CAPO;;AASA,MAAME,YAAY,GAAG,qBAAOC,kBAAP,CAAmC;AAC/D,mBAAmB,CAAC;AAAEJ,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACK,YAAN,CAAmBC,IAAK;AACtE;AACA;AACA;AACA,CALO;;AAOA,MAAMC,gBAAgB,GAAG,qBAAOC,iBAAP,CAAkC;AAClE,mBAAmB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACK,YAAN,CAAmBC,IAAK;AACtE,sBAAsB,CAAC;AAAEN,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACS,KAAN,CAAYC,SAAZ,CAAsBC,IAAK;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA,CATO;;;AAWA,MAAMC,sBAAsB,GAAIC,SAAD,IAA8B;AAClE,SAAO,qBAAOA,SAAP,CAAkB;AAC3B;AACA;AACA;AACA;AACA,GALE;AAMD,CAPM","sourcesContent":["import styled from '@emotion/native';\nimport { FC } from 'react';\nimport { Image, View } from 'react-native';\nimport { StyleProps } from '../../../types/defaults';\nimport { PressableSurface } from '../PressableSurface';\nimport { TextProps } from '../Text';\nimport { AvatarProps } from './Avatar';\n\nexport const ContainerButtonAvatar = styled(PressableSurface)<\n Partial<StyleProps & AvatarProps>\n>`\n width: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>\n theme.iconSize[size]};\n height: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>\n theme.iconSize[size]};\n`;\n\nexport const StyledAvatar = styled(Image)<Partial<StyleProps>>`\n border-radius: ${({ theme }: StyleProps) => theme.borderRadius.pill};\n overflow: hidden;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledBackground = styled(View)<Partial<StyleProps>>`\n border-radius: ${({ theme }: StyleProps) => theme.borderRadius.pill};\n background-color: ${({ theme }: StyleProps) => theme.color.secondary.dark};\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: row;\n`;\n\nexport const getStyledTextComponent = (component: FC<TextProps>) => {\n return styled(component)`\n text-transform: uppercase;\n text-align: center;\n align-self: center;\n flex: 1;\n `;\n};\n"],"file":"styled.js"}
@@ -26,6 +26,7 @@ export interface GroupButtonProps<T> {
26
26
  onChange: (option: T) => void;
27
27
  buttonSize?: ButtonSizeType;
28
28
  style?: StyleProp<ViewStyle>;
29
+ disableAllOptions?: boolean;
29
30
  }
30
31
  declare const GroupButton: <T extends unknown>({ style, ...rest }: GroupButtonProps<T>) => JSX.Element;
31
32
  export default GroupButton;
@@ -30,10 +30,13 @@ const groupOptions = ({
30
30
  renderKey,
31
31
  onChange,
32
32
  value,
33
+ disableAllOptions,
33
34
  ...rest
34
35
  }) => {
35
36
  const theme = (0, _react.useTheme)();
36
37
  return options === null || options === void 0 ? void 0 : options.map((option, idx) => {
38
+ var _option$options;
39
+
37
40
  const {
38
41
  value: optionValue,
39
42
  options: {
@@ -43,7 +46,7 @@ const groupOptions = ({
43
46
  activeBackgroundColorTone,
44
47
  inactiveBackgroundColor,
45
48
  inactiveBackgroundColorTone,
46
- disabled
49
+ disabled = disableAllOptions || ((_option$options = option.options) === null || _option$options === void 0 ? void 0 : _option$options.disabled)
47
50
  } = {}
48
51
  } = option;
49
52
  const key = renderKey === null || renderKey === void 0 ? void 0 : renderKey(optionValue);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/GroupButton/GroupButton.tsx"],"names":["GroupButton","style","rest","groupOptions","options","renderOption","renderKey","onChange","value","theme","map","option","idx","optionValue","activeStyle","inactiveStyle","activeBackgroundColor","activeBackgroundColorTone","inactiveBackgroundColor","inactiveBackgroundColorTone","disabled","key","active","isFirst","isLast","length","colors","miscellaneous","surfaceColor","color"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;;;;;AAoCA,MAAMA,WAAW,GAAG,CAAoB;AACtCC,EAAAA,KADsC;AAEtC,KAAGC;AAFmC,CAApB,KAGO;AACzB,SACE,8BAAC,yBAAD;AAAmB,IAAA,KAAK,EAAED;AAA1B,KAAkCE,YAAY,CAACD,IAAD,CAA9C,CADF;AAGD,CAPD;;AASA,MAAMC,YAAY,GAAG,CAAoB;AACvCC,EAAAA,OADuC;AAEvCC,EAAAA,YAFuC;AAGvCC,EAAAA,SAHuC;AAIvCC,EAAAA,QAJuC;AAKvCC,EAAAA,KALuC;AAMvC,KAAGN;AANoC,CAApB,KAOe;AAClC,QAAMO,KAAK,GAAG,sBAAd;AACA,SAAOL,OAAP,aAAOA,OAAP,uBAAOA,OAAO,CAAEM,GAAT,CAAa,CAACC,MAAD,EAASC,GAAT,KAAiB;AACnC,UAAM;AACJJ,MAAAA,KAAK,EAAEK,WADH;AAEJT,MAAAA,OAAO,EAAE;AACPU,QAAAA,WAD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R,WAAH,GAAiBC;AAThC,QAWGV,YAXH,aAWGA,YAXH,uBAWGA,YAAY,CAAGM,MAAM,CAACH,KAAV,EAAiBc,MAAjB,CAXf,CADF,EAcG,CAACE,MAAD,IAAW,8BAAC,qBAAD,OAdd,CADF;AAkBD,GApDM,CAAP;AAqDD,CA9DD;;eAgEexB,W","sourcesContent":["import { useTheme } from '@emotion/react';\nimport React from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport {\n ColorGradationType,\n ColorType,\n ThemeProp,\n} from '../../../types/defaults';\nimport { ButtonSizeType } from '../Button';\nimport {\n StyledDivider,\n StyledGroupButton,\n StyledOption,\n StyledPressable,\n} from './styled';\n\nexport interface GroupButtonOptions {\n activeBackgroundColor?: ColorType;\n activeBackgroundColorTone?: ColorGradationType;\n activeBorderColor?: ColorType;\n activeBorderColorTone?: ColorGradationType;\n inactiveBackgroundColor?: ColorType;\n inactiveBackgroundColorTone?: ColorGradationType;\n inactiveBorderColor?: ColorType;\n inactiveBorderColorTone?: ColorGradationType;\n activeStyle?: StyleProp<ViewStyle>;\n inactiveStyle?: StyleProp<ViewStyle>;\n disabled?: boolean;\n}\n\nexport interface GroupButtonValue<T> {\n value: T;\n options?: GroupButtonOptions;\n}\n\nexport interface GroupButtonProps<T> {\n value: T;\n options: GroupButtonValue<T>[];\n renderKey: (option?: T) => string | number | undefined;\n renderOption: (option: T, active: boolean) => JSX.Element;\n onChange: (option: T) => void;\n buttonSize?: ButtonSizeType;\n style?: StyleProp<ViewStyle>;\n}\n\nconst GroupButton = <T extends unknown>({\n style,\n ...rest\n}: GroupButtonProps<T>) => {\n return (\n <StyledGroupButton style={style}>{groupOptions(rest)}</StyledGroupButton>\n );\n};\n\nconst groupOptions = <T extends unknown>({\n options,\n renderOption,\n renderKey,\n onChange,\n value,\n ...rest\n}: Partial<GroupButtonProps<T>>) => {\n const theme = useTheme() as ThemeProp;\n return options?.map((option, idx) => {\n const {\n value: optionValue,\n options: {\n activeStyle,\n inactiveStyle,\n activeBackgroundColor,\n activeBackgroundColorTone,\n inactiveBackgroundColor,\n inactiveBackgroundColorTone,\n disabled,\n } = {},\n } = option;\n\n const key = renderKey?.(optionValue);\n const active = key === renderKey?.(value);\n const isFirst = idx === 0;\n const isLast = idx === options.length - 1;\n\n let colors = theme.miscellaneous.surfaceColor;\n if (active) {\n colors =\n theme.color[activeBackgroundColor || 'secondary'][\n activeBackgroundColorTone || 'medium'\n ];\n }\n\n if (!active && (inactiveBackgroundColor || inactiveBackgroundColorTone)) {\n colors =\n theme.color[inactiveBackgroundColor || 'secondary'][\n inactiveBackgroundColorTone || 'medium'\n ];\n }\n\n return (\n <StyledOption key={key}>\n <StyledPressable\n {...rest}\n {...option.options}\n disabled={disabled}\n isActive={active}\n isFirstOption={isFirst}\n isLastOption={isLast}\n onPress={() => onChange?.(optionValue)}\n surfaceColor={colors}\n style={active ? activeStyle : inactiveStyle}\n >\n {renderOption?.(option.value, active)}\n </StyledPressable>\n {!isLast && <StyledDivider />}\n </StyledOption>\n );\n });\n};\n\nexport default GroupButton;\n"],"file":"GroupButton.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/GroupButton/GroupButton.tsx"],"names":["GroupButton","style","rest","groupOptions","options","renderOption","renderKey","onChange","value","disableAllOptions","theme","map","option","idx","optionValue","activeStyle","inactiveStyle","activeBackgroundColor","activeBackgroundColorTone","inactiveBackgroundColor","inactiveBackgroundColorTone","disabled","key","active","isFirst","isLast","length","colors","miscellaneous","surfaceColor","color"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;;;;;AAqCA,MAAMA,WAAW,GAAG,CAAoB;AACtCC,EAAAA,KADsC;AAEtC,KAAGC;AAFmC,CAApB,KAGO;AACzB,SACE,8BAAC,yBAAD;AAAmB,IAAA,KAAK,EAAED;AAA1B,KAAkCE,YAAY,CAACD,IAAD,CAA9C,CADF;AAGD,CAPD;;AASA,MAAMC,YAAY,GAAG,CAAoB;AACvCC,EAAAA,OADuC;AAEvCC,EAAAA,YA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,2BAA2B,IAAI,QADjC,CADF;AAID;;AAED,WACE,8BAAC,oBAAD;AAAc,MAAA,GAAG,EAAEE;AAAnB,OACE,8BAAC,uBAAD,eACMpB,IADN,EAEMU,MAAM,CAACR,OAFb;AAGE,MAAA,QAAQ,EAAEiB,QAHZ;AAIE,MAAA,QAAQ,EAAEE,MAJZ;AAKE,MAAA,aAAa,EAAEC,OALjB;AAME,MAAA,YAAY,EAAEC,MANhB;AAOE,MAAA,OAAO,EAAE,MAAMlB,QAAN,aAAMA,QAAN,uBAAMA,QAAQ,CAAGO,WAAH,CAPzB;AAQE,MAAA,YAAY,EAAEa,MARhB;AASE,MAAA,KAAK,EAAEJ,MAAM,GAAGR,WAAH,GAAiBC;AAThC,QAWGX,YAXH,aAWGA,YAXH,uBAWGA,YAAY,CAAGO,MAAM,CAACJ,KAAV,EAAiBe,MAAjB,CAXf,CADF,EAcG,CAACE,MAAD,IAAW,8BAAC,qBAAD,OAdd,CADF;AAkBD,GApDM,CAAP;AAqDD,CA/DD;;eAiEezB,W","sourcesContent":["import { useTheme } from '@emotion/react';\nimport React from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport {\n ColorGradationType,\n ColorType,\n ThemeProp,\n} from '../../../types/defaults';\nimport { ButtonSizeType } from '../Button';\nimport {\n StyledDivider,\n StyledGroupButton,\n StyledOption,\n StyledPressable,\n} from './styled';\n\nexport interface GroupButtonOptions {\n activeBackgroundColor?: ColorType;\n activeBackgroundColorTone?: ColorGradationType;\n activeBorderColor?: ColorType;\n activeBorderColorTone?: ColorGradationType;\n inactiveBackgroundColor?: ColorType;\n inactiveBackgroundColorTone?: ColorGradationType;\n inactiveBorderColor?: ColorType;\n inactiveBorderColorTone?: ColorGradationType;\n activeStyle?: StyleProp<ViewStyle>;\n inactiveStyle?: StyleProp<ViewStyle>;\n disabled?: boolean;\n}\n\nexport interface GroupButtonValue<T> {\n value: T;\n options?: GroupButtonOptions;\n}\n\nexport interface GroupButtonProps<T> {\n value: T;\n options: GroupButtonValue<T>[];\n renderKey: (option?: T) => string | number | undefined;\n renderOption: (option: T, active: boolean) => JSX.Element;\n onChange: (option: T) => void;\n buttonSize?: ButtonSizeType;\n style?: StyleProp<ViewStyle>;\n disableAllOptions?: boolean;\n}\n\nconst GroupButton = <T extends unknown>({\n style,\n ...rest\n}: GroupButtonProps<T>) => {\n return (\n <StyledGroupButton style={style}>{groupOptions(rest)}</StyledGroupButton>\n );\n};\n\nconst groupOptions = <T extends unknown>({\n options,\n renderOption,\n renderKey,\n onChange,\n value,\n disableAllOptions,\n ...rest\n}: Partial<GroupButtonProps<T>>) => {\n const theme = useTheme() as ThemeProp;\n return options?.map((option, idx) => {\n const {\n value: optionValue,\n options: {\n activeStyle,\n inactiveStyle,\n activeBackgroundColor,\n activeBackgroundColorTone,\n inactiveBackgroundColor,\n inactiveBackgroundColorTone,\n disabled = disableAllOptions || option.options?.disabled,\n } = {},\n } = option;\n\n const key = renderKey?.(optionValue);\n const active = key === renderKey?.(value);\n const isFirst = idx === 0;\n const isLast = idx === options.length - 1;\n\n let colors = theme.miscellaneous.surfaceColor;\n if (active) {\n colors =\n theme.color[activeBackgroundColor || 'secondary'][\n activeBackgroundColorTone || 'medium'\n ];\n }\n\n if (!active && (inactiveBackgroundColor || inactiveBackgroundColorTone)) {\n colors =\n theme.color[inactiveBackgroundColor || 'secondary'][\n inactiveBackgroundColorTone || 'medium'\n ];\n }\n\n return (\n <StyledOption key={key}>\n <StyledPressable\n {...rest}\n {...option.options}\n disabled={disabled}\n isActive={active}\n isFirstOption={isFirst}\n isLastOption={isLast}\n onPress={() => onChange?.(optionValue)}\n surfaceColor={colors}\n style={active ? activeStyle : inactiveStyle}\n >\n {renderOption?.(option.value, active)}\n </StyledPressable>\n {!isLast && <StyledDivider />}\n </StyledOption>\n );\n });\n};\n\nexport default GroupButton;\n"],"file":"GroupButton.js"}
@@ -30,7 +30,7 @@ const getMask = (value = '', mask) => {
30
30
 
31
31
  const useMask = (mask, defaultValue) => {
32
32
  const applyMask = (0, _react.useCallback)((value = '') => {
33
- const onlyNumbers = value ? String((0, _reactCore.extractNumbersFromString)(value)) : value;
33
+ const onlyNumbers = value ? (0, _reactCore.extractDigitsFromString)(value) : value;
34
34
  const selectedMask = getMask(onlyNumbers, mask);
35
35
  const formattedValue = mergeMask(onlyNumbers, selectedMask);
36
36
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/atoms/Input/hooks/useMask.ts"],"names":["mergeMask","value","mask","chars","formattedValue","iMask","iChars","length","charAt","getMask","useMask","defaultValue","applyMask","onlyNumbers","String","selectedMask","raw","formatted","setValue","converter","maskValue","handleChangeValue","oldValue"],"mappings":";;;;;;;AAAA;;AACA;;AAkBA,MAAMA,SAAS,GAAG,CAACC,KAAK,GAAG,EAAT,EAAaC,IAAb,KAA8B;AAC9C,QAAMC,KAAK,GAAG,KAAKF,KAAnB;AACA,MAAIG,cAAc,GAAG,EAArB;;AAEA,OACE,IAAIC,KAAK,GAAG,CAAZ,EAAeC,MAAM,GAAG,CAD1B,EAEED,KAAK,GAAGH,IAAI,CAACK,MAAb,IAAuBD,MAAM,GAAGH,KAAK,CAACI,MAFxC,EAGEF,KAAK,EAHP,EAIE;AACAD,IAAAA,cAAc,IACZF,IAAI,CAACM,MAAL,CAAYH,KAAZ,MAAuB,GAAvB,GAA6BF,KAAK,CAACK,MAAN,CAAaF,MAAM,EAAnB,CAA7B,GAAsDJ,IAAI,CAACM,MAAL,CAAYH,KAAZ,CADxD;AAED;;AACD,SAAOD,cAAP;AACD,CAbD;;AAqBA,MAAMK,OAAO,GAAG,CAACR,KAAK,GAAG,EAAT,EAAaC,IAAb,KAA+D;AAC7E,MAAI,OAAOA,IAAP,KAAgB,UAApB,EAAgC;AAC9B,WAAOA,IAAI,CAACD,KAAD,CAAX;AACD;;AACD,SAAOC,IAAP;AACD,CALD;;AAaO,MAAMQ,OAAO,GAAG,CACrBR,IADqB,EAErBS,YAFqB,KAGe;AACpC,QAAMC,SAAS,GAAG,wBAChB,CAACX,KAAK,GAAG,EAAT,KAA4B;AAC1B,UAAMY,WAAW,GAAGZ,KAAK,GACrBa,MAAM,CAAC,yCAAyBb,KAAzB,CAAD,CADe,GAErBA,KAFJ;AAGA,UAAMc,YAAY,GAAGN,OAAO,CAACI,WAAD,EAAcX,IAAd,CAA5B;AACA,UAAME,cAAc,GAAGJ,SAAS,CAACa,WAAD,EAAcE,YAAd,CAAhC;AAEA,WAAO;AACLC,MAAAA,GAAG,EAAEH,WADA;AAELI,MAAAA,SAAS,EAAEb;AAFN,KAAP;AAID,GAZe,EAahB,CAACF,IAAD,CAbgB,CAAlB;AAgBA,QAAM,CAACD,KAAD,EAAQiB,QAAR,IAAoB,qBAAgB;AACxCC,IAAAA,SAAS,EAAEP,SAD6B;AAExCQ,IAAAA,SAAS,EAAER,SAAS,CAACD,YAAD;AAFoB,GAAhB,CAA1B;AAKA,QAAMU,iBAAiB,GAAG,wBACvBpB,KAAD,IAAmB;AACjB,UAAM;AAAEe,MAAAA,GAAF;AAAOC,MAAAA;AAAP,QAAqBL,SAAS,CAACX,KAAD,CAApC;AACAiB,IAAAA,QAAQ,CAACI,QAAQ,KAAK,EACpB,GAAGA,QADiB;AAEpBF,MAAAA,SAAS,EAAE;AACTJ,QAAAA,GADS;AAETC,QAAAA;AAFS;AAFS,KAAL,CAAT,CAAR;AAOD,GAVuB,EAWxB,CAACL,SAAD,EAAYM,QAAZ,CAXwB,CAA1B;AAcA,SAAO,CAACjB,KAAD,EAAQoB,iBAAR,CAAP;AACD,CAxCM","sourcesContent":["import { useCallback, useState } from 'react';\nimport { extractNumbersFromString } from '@tecsinapse/react-core';\n\nexport interface IMaskValue {\n formatted?: string;\n raw?: any;\n}\n\nexport interface IMask {\n converter?: (raw?: string) => IMaskValue;\n maskValue?: IMaskValue;\n}\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nconst mergeMask = (value = '', mask: string) => {\n const chars = '' + value;\n let formattedValue = '';\n\n for (\n let iMask = 0, iChars = 0;\n iMask < mask.length && iChars < chars.length;\n iMask++\n ) {\n formattedValue +=\n mask.charAt(iMask) === '9' ? chars.charAt(iChars++) : mask.charAt(iMask);\n }\n return formattedValue;\n};\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nconst getMask = (value = '', mask: ((raw: any) => string) | string): string => {\n if (typeof mask === 'function') {\n return mask(value);\n }\n return mask;\n};\n\n/**\n * TODO:\n * @param mask\n * @param defaultValue\n * @returns\n */\nexport const useMask = (\n mask: ((raw: any) => string) | string,\n defaultValue?: string\n): [IMask, (text: string) => void] => {\n const applyMask = useCallback(\n (value = ''): IMaskValue => {\n const onlyNumbers = value\n ? String(extractNumbersFromString(value))\n : value;\n const selectedMask = getMask(onlyNumbers, mask);\n const formattedValue = mergeMask(onlyNumbers, selectedMask);\n\n return {\n raw: onlyNumbers,\n formatted: formattedValue,\n };\n },\n [mask]\n );\n\n const [value, setValue] = useState<IMask>({\n converter: applyMask,\n maskValue: applyMask(defaultValue),\n });\n\n const handleChangeValue = useCallback(\n (value: string) => {\n const { raw, formatted } = applyMask(value);\n setValue(oldValue => ({\n ...oldValue,\n maskValue: {\n raw,\n formatted,\n },\n }));\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"file":"useMask.js"}
1
+ {"version":3,"sources":["../../../../../src/components/atoms/Input/hooks/useMask.ts"],"names":["mergeMask","value","mask","chars","formattedValue","iMask","iChars","length","charAt","getMask","useMask","defaultValue","applyMask","onlyNumbers","selectedMask","raw","formatted","setValue","converter","maskValue","handleChangeValue","oldValue"],"mappings":";;;;;;;AAAA;;AACA;;AAkBA,MAAMA,SAAS,GAAG,CAACC,KAAK,GAAG,EAAT,EAAaC,IAAb,KAA8B;AAC9C,QAAMC,KAAK,GAAG,KAAKF,KAAnB;AACA,MAAIG,cAAc,GAAG,EAArB;;AAEA,OACE,IAAIC,KAAK,GAAG,CAAZ,EAAeC,MAAM,GAAG,CAD1B,EAEED,KAAK,G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KAAD,CAApC;AACAgB,IAAAA,QAAQ,CAACI,QAAQ,KAAK,EACpB,GAAGA,QADiB;AAEpBF,MAAAA,SAAS,EAAE;AACTJ,QAAAA,GADS;AAETC,QAAAA;AAFS;AAFS,KAAL,CAAT,CAAR;AAOD,GAVuB,EAWxB,CAACJ,SAAD,EAAYK,QAAZ,CAXwB,CAA1B;AAcA,SAAO,CAAChB,KAAD,EAAQmB,iBAAR,CAAP;AACD,CAtCM","sourcesContent":["import { useCallback, useState } from 'react';\nimport { extractDigitsFromString } from '@tecsinapse/react-core';\n\nexport interface IMaskValue {\n formatted?: string;\n raw?: any;\n}\n\nexport interface IMask {\n converter?: (raw?: string) => IMaskValue;\n maskValue?: IMaskValue;\n}\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nconst mergeMask = (value = '', mask: string) => {\n const chars = '' + value;\n let formattedValue = '';\n\n for (\n let iMask = 0, iChars = 0;\n iMask < mask.length && iChars < chars.length;\n iMask++\n ) {\n formattedValue +=\n mask.charAt(iMask) === '9' ? chars.charAt(iChars++) : mask.charAt(iMask);\n }\n return formattedValue;\n};\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nconst getMask = (value = '', mask: ((raw: any) => string) | string): string => {\n if (typeof mask === 'function') {\n return mask(value);\n }\n return mask;\n};\n\n/**\n * TODO:\n * @param mask\n * @param defaultValue\n * @returns\n */\nexport const useMask = (\n mask: ((raw: any) => string) | string,\n defaultValue?: string\n): [IMask, (text: string) => void] => {\n const applyMask = useCallback(\n (value = ''): IMaskValue => {\n const onlyNumbers = value ? extractDigitsFromString(value) : value;\n const selectedMask = getMask(onlyNumbers, mask);\n const formattedValue = mergeMask(onlyNumbers, selectedMask);\n\n return {\n raw: onlyNumbers,\n formatted: formattedValue,\n };\n },\n [mask]\n );\n\n const [value, setValue] = useState<IMask>({\n converter: applyMask,\n maskValue: applyMask(defaultValue),\n });\n\n const handleChangeValue = useCallback(\n (value: string) => {\n const { raw, formatted } = applyMask(value);\n setValue(oldValue => ({\n ...oldValue,\n maskValue: {\n raw,\n formatted,\n },\n }));\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"file":"useMask.js"}
@@ -12,7 +12,7 @@ const Masks = {
12
12
  CEP: '99999-999',
13
13
  PHONE: '(99) 9999-9999',
14
14
  PHONE_EXTENDED: '(99) 99999-9999',
15
- COMBINED_PHONE: value => value.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED
15
+ COMBINED_PHONE: value => (value === null || value === void 0 ? void 0 : value.length) <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED
16
16
  };
17
17
  exports.Masks = Masks;
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/atoms/Input/masks/index.ts"],"names":["Masks","CPF","CNPJ","DATE","MONTH_YEAR","CEP","PHONE","PHONE_EXTENDED","COMBINED_PHONE","value","length"],"mappings":";;;;;;AACO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,GAAG,EAAE,gBADc;AAEnBC,EAAAA,IAAI,EAAE,oBAFa;AAGnBC,EAAAA,IAAI,EAAE,YAHa;AAInBC,EAAAA,UAAU,EAAE,SAJO;AAKnBC,EAAAA,GAAG,EAAE,WALc;AAMnBC,EAAAA,KAAK,EAAE,gBANY;AAOnBC,EAAAA,cAAc,EAAE,iBAPG;AAQnBC,EAAAA,cAAc,EAAGC,KAAD,IACdA,KAAK,CAACC,MAAN,IAAgB,EAAhB,GAAqBV,KAAK,CAACM,KAA3B,GAAmCN,KAAK,CAACO;AATxB,CAAd","sourcesContent":["// NOTE: Add here all individually masks, then you can use it on input components everywhere.\nexport const Masks = {\n CPF: '999.999.999-99',\n CNPJ: '99.999.999/9999-99',\n DATE: '99/99/9999',\n MONTH_YEAR: '99/9999',\n CEP: '99999-999',\n PHONE: '(99) 9999-9999',\n PHONE_EXTENDED: '(99) 99999-9999',\n COMBINED_PHONE: (value: string) =>\n value.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../../src/components/atoms/Input/masks/index.ts"],"names":["Masks","CPF","CNPJ","DATE","MONTH_YEAR","CEP","PHONE","PHONE_EXTENDED","COMBINED_PHONE","value","length"],"mappings":";;;;;;AACO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,GAAG,EAAE,gBADc;AAEnBC,EAAAA,IAAI,EAAE,oBAFa;AAGnBC,EAAAA,IAAI,EAAE,YAHa;AAInBC,EAAAA,UAAU,EAAE,SAJO;AAKnBC,EAAAA,GAAG,EAAE,WALc;AAMnBC,EAAAA,KAAK,EAAE,gBANY;AAOnBC,EAAAA,cAAc,EAAE,iBAPG;AAQnBC,EAAAA,cAAc,EAAGC,KAAD,IACd,CAAAA,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEC,MAAP,KAAiB,EAAjB,GAAsBV,KAAK,CAACM,KAA5B,GAAoCN,KAAK,CAACO;AATzB,CAAd","sourcesContent":["// NOTE: Add here all individually masks, then you can use it on input components everywhere.\nexport const Masks = {\n CPF: '999.999.999-99',\n CNPJ: '99.999.999/9999-99',\n DATE: '99/99/9999',\n MONTH_YEAR: '99/9999',\n CEP: '99999-999',\n PHONE: '(99) 9999-9999',\n PHONE_EXTENDED: '(99) 99999-9999',\n COMBINED_PHONE: (value: string) =>\n value?.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED,\n};\n"],"file":"index.js"}
@@ -10,6 +10,7 @@ export interface SwitchProps {
10
10
  inactiveColorTone?: ColorGradationType;
11
11
  style?: StyleProp<ViewStyle>;
12
12
  dotStyle?: StyleProp<ViewStyle>;
13
+ disabled?: boolean;
13
14
  }
14
15
  declare const Switch: FC<SwitchProps>;
15
16
  export default Switch;
@@ -33,6 +33,7 @@ const Switch = ({
33
33
  inactiveColorTone = 'light',
34
34
  active,
35
35
  dotStyle,
36
+ disabled = false,
36
37
  ...rest
37
38
  }) => {
38
39
  const theme = (0, _react.useTheme)();
@@ -41,18 +42,24 @@ const Switch = ({
41
42
 
42
43
  const animatedColor = _react2.default.useRef(new _reactNative.Animated.Value(active ? 1 : 0)).current;
43
44
 
45
+ const getBackgroundColor = (color, variation) => {
46
+ return disabled ? (0, _utils.lightenDarkenColor)(color, variation) : color;
47
+ };
48
+
44
49
  const interpolateColor = animatedColor.interpolate({
45
50
  inputRange: [0, 1],
46
- outputRange: [theme.color[inactiveColor][inactiveColorTone], theme.color[activeColor][activeColorTone]]
51
+ outputRange: [getBackgroundColor(theme.color[inactiveColor][inactiveColorTone], 25), getBackgroundColor(theme.color[activeColor][activeColorTone], 50)]
47
52
  });
48
53
  const animatedStyle = {
49
54
  backgroundColor: interpolateColor
50
55
  };
56
+ (0, _react2.useEffect)(() => {
57
+ (0, _animation.transitionSwitch)(!active, transitionValue, animatedColor);
58
+ }, [active]);
51
59
  const handleChange = (0, _react2.useCallback)(() => {
52
60
  onChange(!active);
53
- (0, _animation.transitionSwitch)(active, transitionValue, animatedColor);
54
61
  }, [active, onChange]);
55
- const stylesDefaut = {
62
+ const stylesDefault = {
56
63
  borderRadius: (0, _utils.extractNumbersFromString)(theme.borderRadius.pill),
57
64
  paddingHorizontal: (0, _utils.extractNumbersFromString)(theme.spacing.micro),
58
65
  paddingVertical: 0,
@@ -62,10 +69,11 @@ const Switch = ({
62
69
  };
63
70
  return _react2.default.createElement(_PressableSurface.PressableSurface, _extends({}, rest, {
64
71
  onPress: handleChange,
65
- effect: "none"
72
+ effect: "none",
73
+ disabled: disabled
66
74
  }), _react2.default.createElement(_reactNative.Animated.View, {
67
75
  style: { ...animatedStyle,
68
- ...stylesDefaut
76
+ ...stylesDefault
69
77
  }
70
78
  }, _react2.default.createElement(_styled.StyledSwitch, {
71
79
  style: [dotStyle, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Switch/Switch.tsx"],"names":["Switch","onChange","activeColor","activeColorTone","inactiveColor","inactiveColorTone","active","dotStyle","rest","theme","transitionValue","React","useRef","Animated","Value","current","animatedColor","interpolateColor","interpolate","inputRange","outputRange","color","animatedStyle","backgroundColor","handleChange","stylesDefaut","borderRadius","pill","paddingHorizontal","spacing","micro","paddingVertical","justifyContent","width","height","transform","translateX"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;;;;;;;AAaA,MAAMA,MAAuB,GAAG,CAAC;AAC/BC,EAAAA,QAD+B;AAE/BC,EAAAA,WAAW,GAAG,SAFiB;AAG/BC,EAAAA,eAAe,GAAG,QAHa;AAI/BC,EAAAA,aAAa,GAAG,WAJe;AAK/BC,EAAAA,iBAAiB,GAAG,OALW;AAM/BC,EAAAA,MAN+B;AAO/BC,EAAAA,QAP+B;AAQ/B,KAAGC;AAR4B,CAAD,KASb;AACjB,QAAMC,KAAK,GAAG,sBAAd;;AAEA,QAAMC,eAAe,GAAGC,gBAAMC,MAAN,CAAa,IAAIC,sBAASC,KAAb,CAAmBR,MAAM,GAAG,IAAH,GAAU,CAAnC,CAAb,EACrBS,OADH;;AAGA,QAAMC,aAAa,GAAGL,gBAAMC,MAAN,CAAa,IAAIC,sBAASC,KAAb,CAAmBR,MAAM,GAAG,CAAH,GAAO,CAAhC,CAAb,EACnBS,OADH;;AAGA,QAAME,gBAAgB,GAAGD,aAAa,CAACE,WAAd,CAA0B;AACjDC,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,CADqC;AAEjDC,IAAAA,WAAW,EAAE,CACXX,KAAK,CAACY,KAAN,CAAYjB,aAAZ,EAA2BC,iBAA3B,CADW,EAEXI,KAAK,CAACY,KAAN,CAAYnB,WAAZ,EAAyBC,eAAzB,CAFW;AAFoC,GAA1B,CAAzB;AAQA,QAAMmB,aAAa,GAAG;AACpBC,IAAAA,eAAe,EAAEN;AADG,GAAtB;AAIA,QAAMO,YAAY,GAAG,yBAAY,MAAM;AACrCvB,IAAAA,QAAQ,CAAC,CAACK,MAAF,CAAR;AACA,qCAAiBA,MAAjB,EAAyBI,eAAzB,EAA0CM,aAA1C;AACD,GAHoB,EAGlB,CAACV,MAAD,EAASL,QAAT,CAHkB,CAArB;AAKA,QAAMwB,YAAuB,GAAG;AAC9BC,IAAAA,YAAY,EAAE,qCAAyBjB,KAAK,CAACiB,YAAN,CAAmBC,IAA5C,CADgB;AAE9BC,IAAAA,iBAAiB,EAAE,qCAAyBnB,KAAK,CAACoB,OAAN,CAAcC,KAAvC,CAFW;AAG9BC,IAAAA,eAAe,EAAE,CAHa;AAI9BC,IAAAA,cAAc,EAAE,QAJc;AAK9BC,IAAAA,KAAK,EAAE,EALuB;AAM9BC,IAAAA,MAAM,EAAE;AANsB,GAAhC;AASA,SACE,8BAAC,kCAAD,eAAsB1B,IAAtB;AAA4B,IAAA,OAAO,EAAEgB,YAArC;AAAmD,IAAA,MAAM,EAAC;AAA1D,MACE,8BAAC,qBAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,EAAE,GAAGF,aAAL;AAAoB,SAAGG;AAAvB;AAAtB,KACE,8BAAC,oBAAD;AACE,IAAA,KAAK,EAAE,CAAClB,QAAD,EAAW;AAAE4B,MAAAA,SAAS,EAAE,CAAC;AAAEC,QAAAA,UAAU,EAAE1B;AAAd,OAAD;AAAb,KAAX;AADT,IADF,CADF,CADF;AASD,CArDD;;eAuDeV,M","sourcesContent":["import { useTheme } from '@emotion/react';\nimport React, { FC, useCallback } from 'react';\nimport { Animated, StyleProp, ViewStyle } from 'react-native';\nimport {\n ColorGradationType,\n ColorType,\n ThemeProp,\n} from '../../../types/defaults';\nimport { PressableSurface } from '../PressableSurface';\nimport { StyledSwitch } from './styled';\nimport { transitionSwitch } from './animation';\nimport { extractNumbersFromString } from '../../../utils';\n\nexport interface SwitchProps {\n onChange: (active: boolean) => void;\n active: boolean;\n activeColor?: ColorType;\n activeColorTone?: ColorGradationType;\n inactiveColor?: ColorType;\n inactiveColorTone?: ColorGradationType;\n style?: StyleProp<ViewStyle>;\n dotStyle?: StyleProp<ViewStyle>;\n}\n\nconst Switch: FC<SwitchProps> = ({\n onChange,\n activeColor = 'primary',\n activeColorTone = 'medium',\n inactiveColor = 'secondary',\n inactiveColorTone = 'light',\n active,\n dotStyle,\n ...rest\n}): JSX.Element => {\n const theme = useTheme() as ThemeProp;\n\n const transitionValue = React.useRef(new Animated.Value(active ? 16.5 : 0))\n .current;\n\n const animatedColor = React.useRef(new Animated.Value(active ? 1 : 0))\n .current;\n\n const interpolateColor = animatedColor.interpolate({\n inputRange: [0, 1],\n outputRange: [\n theme.color[inactiveColor][inactiveColorTone],\n theme.color[activeColor][activeColorTone],\n ],\n });\n\n const animatedStyle = {\n backgroundColor: interpolateColor,\n };\n\n const handleChange = useCallback(() => {\n onChange(!active);\n transitionSwitch(active, transitionValue, animatedColor);\n }, [active, onChange]);\n\n const stylesDefaut: ViewStyle = {\n borderRadius: extractNumbersFromString(theme.borderRadius.pill),\n paddingHorizontal: extractNumbersFromString(theme.spacing.micro),\n paddingVertical: 0,\n justifyContent: 'center',\n width: 40,\n height: 22,\n };\n\n return (\n <PressableSurface {...rest} onPress={handleChange} effect=\"none\">\n <Animated.View style={{ ...animatedStyle, ...stylesDefaut }}>\n <StyledSwitch\n style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}\n />\n </Animated.View>\n </PressableSurface>\n );\n};\n\nexport default Switch;\n"],"file":"Switch.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Switch/Switch.tsx"],"names":["Switch","onChange","activeColor","activeColorTone","inactiveColor","inactiveColorTone","active","dotStyle","disabled","rest","theme","transitionValue","React","useRef","Animated","Value","current","animatedColor","getBackgroundColor","color","variation","interpolateColor","interpolate","inputRange","outputRange","animatedStyle","backgroundColor","handleChange","stylesDefault","borderRadius","pill","paddingHorizontal","spacing","micro","paddingVertical","justifyContent","width","height","transform","translateX"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;;;;;;;AAcA,MAAMA,MAAuB,GAAG,CAAC;AA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ACX,MAAD,CAFH;AAIA,QAAMqB,YAAY,GAAG,yBAAY,MAAM;AACrC1B,IAAAA,QAAQ,CAAC,CAACK,MAAF,CAAR;AACD,GAFoB,EAElB,CAACA,MAAD,EAASL,QAAT,CAFkB,CAArB;AAIA,QAAM2B,aAAwB,GAAG;AAC/BC,IAAAA,YAAY,EAAE,qCAAyBnB,KAAK,CAACmB,YAAN,CAAmBC,IAA5C,CADiB;AAE/BC,IAAAA,iBAAiB,EAAE,qCAAyBrB,KAAK,CAACsB,OAAN,CAAcC,KAAvC,CAFY;AAG/BC,IAAAA,eAAe,EAAE,CAHc;AAI/BC,IAAAA,cAAc,EAAE,QAJe;AAK/BC,IAAAA,KAAK,EAAE,EALwB;AAM/BC,IAAAA,MAAM,EAAE;AANuB,GAAjC;AASA,SACE,8BAAC,kCAAD,eACM5B,IADN;AAEE,IAAA,OAAO,EAAEkB,YAFX;AAGE,IAAA,MAAM,EAAC,MAHT;AAIE,IAAA,QAAQ,EAAEnB;AAJZ,MAME,8BAAC,qBAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,EAAE,GAAGiB,aAAL;AAAoB,SAAGG;AAAvB;AAAtB,KACE,8BAAC,oBAAD;AACE,IAAA,KAAK,EAAE,CAACrB,QAAD,EAAW;AAAE+B,MAAAA,SAAS,EAAE,CAAC;AAAEC,QAAAA,UAAU,EAAE5B;AAAd,OAAD;AAAb,KAAX;AADT,IADF,CANF,CADF;AAcD,CAlED;;eAoEeX,M","sourcesContent":["import { useTheme } from '@emotion/react';\nimport React, { FC, useCallback, useEffect } from 'react';\nimport { Animated, StyleProp, ViewStyle, Text } from 'react-native';\nimport {\n ColorGradationType,\n ColorType,\n ThemeProp,\n} from '../../../types/defaults';\nimport { PressableSurface } from '../PressableSurface';\nimport { StyledSwitch } from './styled';\nimport { transitionSwitch } from './animation';\nimport { extractNumbersFromString, lightenDarkenColor } from '../../../utils';\n\nexport interface SwitchProps {\n onChange: (active: boolean) => void;\n active: boolean;\n activeColor?: ColorType;\n activeColorTone?: ColorGradationType;\n inactiveColor?: ColorType;\n inactiveColorTone?: ColorGradationType;\n style?: StyleProp<ViewStyle>;\n dotStyle?: StyleProp<ViewStyle>;\n disabled?: boolean;\n}\n\nconst Switch: FC<SwitchProps> = ({\n onChange,\n activeColor = 'primary',\n activeColorTone = 'medium',\n inactiveColor = 'secondary',\n inactiveColorTone = 'light',\n active,\n dotStyle,\n disabled = false,\n ...rest\n}): JSX.Element => {\n const theme = useTheme() as ThemeProp;\n\n const transitionValue = React.useRef(new Animated.Value(active ? 16.5 : 0))\n .current;\n\n const animatedColor = React.useRef(new Animated.Value(active ? 1 : 0))\n .current;\n\n const getBackgroundColor = (color: string, variation: number) => {\n return disabled ? lightenDarkenColor(color, variation) : color;\n };\n\n const interpolateColor = animatedColor.interpolate({\n inputRange: [0, 1],\n outputRange: [\n getBackgroundColor(theme.color[inactiveColor][inactiveColorTone], 25),\n getBackgroundColor(theme.color[activeColor][activeColorTone], 50),\n ],\n });\n\n const animatedStyle = {\n backgroundColor: interpolateColor,\n };\n\n useEffect(() => {\n transitionSwitch(!active, transitionValue, animatedColor);\n }, [active]);\n\n const handleChange = useCallback(() => {\n onChange(!active);\n }, [active, onChange]);\n\n const stylesDefault: ViewStyle = {\n borderRadius: extractNumbersFromString(theme.borderRadius.pill),\n paddingHorizontal: extractNumbersFromString(theme.spacing.micro),\n paddingVertical: 0,\n justifyContent: 'center',\n width: 40,\n height: 22,\n };\n\n return (\n <PressableSurface\n {...rest}\n onPress={handleChange}\n effect=\"none\"\n disabled={disabled}\n >\n <Animated.View style={{ ...animatedStyle, ...stylesDefault }}>\n <StyledSwitch\n style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}\n />\n </Animated.View>\n </PressableSurface>\n );\n};\n\nexport default Switch;\n"],"file":"Switch.js"}
@@ -11,25 +11,25 @@ const transitionSwitch = (active, transitionValue, animatedColor) => {
11
11
  if (active) {
12
12
  _reactNative.Animated.timing(transitionValue, {
13
13
  toValue: 0,
14
- duration: 250,
14
+ duration: 150,
15
15
  useNativeDriver: true
16
16
  }).start();
17
17
 
18
18
  _reactNative.Animated.timing(animatedColor, {
19
19
  toValue: 0,
20
- duration: 250,
20
+ duration: 150,
21
21
  useNativeDriver: false
22
22
  }).start();
23
23
  } else {
24
24
  _reactNative.Animated.timing(transitionValue, {
25
25
  toValue: 16.5,
26
- duration: 250,
26
+ duration: 150,
27
27
  useNativeDriver: true
28
28
  }).start();
29
29
 
30
30
  _reactNative.Animated.timing(animatedColor, {
31
31
  toValue: 1,
32
- duration: 250,
32
+ duration: 150,
33
33
  useNativeDriver: false
34
34
  }).start();
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Switch/animation.ts"],"names":["transitionSwitch","active","transitionValue","animatedColor","Animated","timing","toValue","duration","useNativeDriver","start"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,gBAAgB,GAAG,CAC9BC,MAD8B,EAE9BC,eAF8B,EAG9BC,aAH8B,KAIrB;AACT,MAAIF,MAAJ,EAAY;AACVG,0BAASC,MAAT,CAAgBH,eAAhB,EAAiC;AAC/BI,MAAAA,OAAO,EAAE,CADsB;AAE/BC,MAAAA,QAAQ,EAAE,GAFqB;AAG/BC,MAAAA,eAAe,EAAE;AAHc,KAAjC,EAIGC,KAJH;;AAKAL,0BAASC,MAAT,CAAgBF,aAAhB,EAA+B;AAC7BG,MAAAA,OAAO,EAAE,CADoB;AAE7BC,MAAAA,QAAQ,EAAE,GAFmB;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAA/B,EAIGC,KAJH;AAKD,GAXD,MAWO;AACLL,0BAASC,MAAT,CAAgBH,eAAhB,EAAiC;AAC/BI,MAAAA,OAAO,EAAE,IADsB;AAE/BC,MAAAA,QAAQ,EAAE,GAFqB;AAG/BC,MAAAA,eAAe,EAAE;AAHc,KAAjC,EAIGC,KAJH;;AAKAL,0BAASC,MAAT,CAAgBF,aAAhB,EAA+B;AAC7BG,MAAAA,OAAO,EAAE,CADoB;AAE7BC,MAAAA,QAAQ,EAAE,GAFmB;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAA/B,EAIGC,KAJH;AAKD;AACF,CA5BM","sourcesContent":["import { Animated } from 'react-native';\n\nexport const transitionSwitch = (\n active: boolean,\n transitionValue: Animated.Value,\n animatedColor: Animated.Value\n): void => {\n if (active) {\n Animated.timing(transitionValue, {\n toValue: 0,\n duration: 250,\n useNativeDriver: true,\n }).start();\n Animated.timing(animatedColor, {\n toValue: 0,\n duration: 250,\n useNativeDriver: false,\n }).start();\n } else {\n Animated.timing(transitionValue, {\n toValue: 16.5,\n duration: 250,\n useNativeDriver: true,\n }).start();\n Animated.timing(animatedColor, {\n toValue: 1,\n duration: 250,\n useNativeDriver: false,\n }).start();\n }\n};\n"],"file":"animation.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Switch/animation.ts"],"names":["transitionSwitch","active","transitionValue","animatedColor","Animated","timing","toValue","duration","useNativeDriver","start"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,gBAAgB,GAAG,CAC9BC,MAD8B,EAE9BC,eAF8B,EAG9BC,aAH8B,KAIrB;AACT,MAAIF,MAAJ,EAAY;AACVG,0BAASC,MAAT,CAAgBH,eAAhB,EAAiC;AAC/BI,MAAAA,OAAO,EAAE,CADsB;AAE/BC,MAAAA,QAAQ,EAAE,GAFqB;AAG/BC,MAAAA,eAAe,EAAE;AAHc,KAAjC,EAIGC,KAJH;;AAKAL,0BAASC,MAAT,CAAgBF,aAAhB,EAA+B;AAC7BG,MAAAA,OAAO,EAAE,CADoB;AAE7BC,MAAAA,QAAQ,EAAE,GAFmB;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAA/B,EAIGC,KAJH;AAKD,GAXD,MAWO;AACLL,0BAASC,MAAT,CAAgBH,eAAhB,EAAiC;AAC/BI,MAAAA,OAAO,EAAE,IADsB;AAE/BC,MAAAA,QAAQ,EAAE,GAFqB;AAG/BC,MAAAA,eAAe,EAAE;AAHc,KAAjC,EAIGC,KAJH;;AAKAL,0BAASC,MAAT,CAAgBF,aAAhB,EAA+B;AAC7BG,MAAAA,OAAO,EAAE,CADoB;AAE7BC,MAAAA,QAAQ,EAAE,GAFmB;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAA/B,EAIGC,KAJH;AAKD;AACF,CA5BM","sourcesContent":["import { Animated } from 'react-native';\n\nexport const transitionSwitch = (\n active: boolean,\n transitionValue: Animated.Value,\n animatedColor: Animated.Value\n): void => {\n if (active) {\n Animated.timing(transitionValue, {\n toValue: 0,\n duration: 150,\n useNativeDriver: true,\n }).start();\n Animated.timing(animatedColor, {\n toValue: 0,\n duration: 150,\n useNativeDriver: false,\n }).start();\n } else {\n Animated.timing(transitionValue, {\n toValue: 16.5,\n duration: 150,\n useNativeDriver: true,\n }).start();\n Animated.timing(animatedColor, {\n toValue: 1,\n duration: 150,\n useNativeDriver: false,\n }).start();\n }\n};\n"],"file":"animation.js"}
@@ -69,13 +69,21 @@ function DatePicker({
69
69
  if (!value) return placeholder;
70
70
 
71
71
  if (type === 'day') {
72
- return (0, _dateFns.format)(value, format);
72
+ return (0, _dateFns.format)(value, format, {
73
+ locale: locale
74
+ });
73
75
  } else {
74
76
  const {
75
77
  lowest,
76
78
  highest
77
79
  } = value;
78
- if (highest) return `${(0, _dateFns.format)(lowest, format)} - ${(0, _dateFns.format)(highest, format)}`;else return (0, _dateFns.format)(lowest, format);
80
+ if (highest) return `${(0, _dateFns.format)(lowest, format, {
81
+ locale: locale
82
+ })} - ${(0, _dateFns.format)(highest, format, {
83
+ locale: locale
84
+ })}`;else return (0, _dateFns.format)(lowest, format, {
85
+ locale: locale
86
+ });
79
87
  }
80
88
  };
81
89
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DatePicker/DatePicker.tsx"],"names":["DatePicker","month","year","onChange","value","type","format","placeholder","onFocus","onBlur","disabled","controlComponent","hintComponent","hint","variant","TextComponent","Text","CalendarComponent","bottomOffset","rightComponent","animationType","style","locale","closeOnPick","rest","focused","handleBlur","handleFocus","modalVisible","setModalVisible","React","useState","handlePressInput","useCallback","handleCloseModal","getDisplayValue","lowest","highest","StyledText","setTimeout"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;AAoBA,SAASA,UAAT,CAA6C;AAE3CC,EAAAA,KAF2C;AAG3CC,EAAAA,IAH2C;AAI3CC,EAAAA,QAJ2C;AAK3CC,EAAAA,KAL2C;AAM3CC,EAAAA,IAN2C;AAO3CC,EAAAA,MAAM,GAAG,YAPkC;AAS3CC,EAAAA,WAT2C;AAU3CC,EAAAA,OAV2C;AAW3CC,EAAAA,MAX2C;AAY3CC,EAAAA,QAZ2C;AAa3CC,EAAAA,gBAb2C;AAc3CC,EAAAA,aAd2C;AAe3CC,EAAAA,IAf2C;AAgB3CC,EAAAA,OAhB2C;AAiB3CC,EAAAA,aAAa,GAAGC,UAjB2B;AAkB3CC,EAAAA,iBAlB2C;AAmB3CC,EAAAA,YAnB2C;AAoB3CC,EAAAA,cApB2C;AAqB3CC,EAAAA,aAAa,GAAG,MArB2B;AAsB3CC,EAAAA,KAtB2C;AAuB3CC,EAAAA,MAvB2C;AAwB3CC,EAAAA,WAAW,GAAG,KAxB6B;AAyB3C,KAAGC;AAzBwC,CAA7C,EA0BoC;AAClC,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,UAAX;AAAuBC,IAAAA;AAAvB,MAAuC,0BAC3CnB,OAD2C,EAE3CC,MAF2C,EAG3C,CAACC,QAH0C,CAA7C;AAMA,QAAM,CAACkB,YAAD,EAAeC,eAAf,IAAkCC,KAAK,CAACC,QAAN,CAAe,KAAf,CAAxC;AAEA,QAAMC,gBAAgB,GAAGF,KAAK,CAACG,WAAN,CAAkB,MAAM;AAC/CJ,IAAAA,eAAe,CAAC,IAAD,CAAf;AACAF,IAAAA,WAAW;AACZ,GAHwB,EAGtB,CAACA,WAAD,EAAcE,eAA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AAlC,CADD,GAGf,oBAAC,sCAAD;AACE,IAAA,OAAO,EAAEV,OADX;AAEE,IAAA,SAAS,EAAEJ,KAFb;AAGE,IAAA,OAAO,EAAEW,gBAHX;AAIE,IAAA,QAAQ,EAAEtB,QAJZ;AAKE,IAAA,aAAa,EAAEE,aALjB;AAME,IAAA,cAAc,EAAEG,aANlB;AAOE,IAAA,OAAO,EAAED,OAPX;AAQE,IAAA,IAAI,EAAED,IARR;AASE,IAAA,cAAc,EACZ,0CACE,oBAAC,oBAAD;AAAc,MAAA,IAAI,EAAC,gBAAnB;AAAoC,MAAA,IAAI,EAAC,SAAzC;AAAmD,MAAA,IAAI,EAAC;AAAxD,MADF,EAEGM,cAFH;AAVJ,KAeMK,IAfN,GAiBE,oBAAC,UAAD;AAAY,IAAA,UAAU,EAAC,MAAvB;AAA8B,IAAA,QAAQ,EAAEd;AAAxC,KACGyB,eAAe,MAAM,GADxB,CAjBF,CAJJ,EA0BE,oBAAC,YAAD;AACE,IAAA,iBAAiB,EAAElB,iBADrB;AAEE,IAAA,YAAY,EAAEC,YAFhB;AAGE,IAAA,OAAO,EAAEU,YAHX;AAIE,IAAA,cAAc,EAAEM,gBAJlB;AAKE,IAAA,QAAQ,MALV;AAME,IAAA,aAAa,EAAEd,aANjB;AAOE,IAAA,KAAK,EAAEnB,KAPT;AAQE,IAAA,IAAI,EAAEC,IARR;AASE,IAAA,QAAQ,EAAEC,QATZ;AAUE,IAAA,KAAK,EAAEC,KAVT;AAWE,IAAA,IAAI,EAAEC,IAXR;AAYE,IAAA,MAAM,EAAEiB;AAZV,IA1BF,CADF;AA2CD;;eAEctB,U","sourcesContent":["import { format as formatDate } from 'date-fns';\nimport * as React from 'react';\nimport { ModalBaseProps } from 'react-native';\nimport { InputContainerProps, useInputFocus } from '../../atoms/Input';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { CalendarProps, DateRange, SelectionType } from '../Calendar';\nimport { DatePickerModalProps, Modal } from './Modal';\nimport { CalendarIcon, getStyledTextComponent } from './styled';\nimport { HintInputContainer } from '../HintInputContainer';\nimport { useEffect } from 'react';\n\nexport interface DatePickerProps<T extends SelectionType>\n extends InputContainerProps,\n DatePickerModalProps<T>,\n Omit<CalendarProps<T>, 'style'> {\n controlComponent?: (\n onPress: () => void,\n displayValue?: string\n ) => JSX.Element;\n TextComponent?: React.FC<TextProps>;\n animationType?: ModalBaseProps['animationType'];\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n format?: string;\n closeOnPick?: boolean;\n}\n\nfunction DatePicker<T extends SelectionType>({\n /** DatePicker props */\n month,\n year,\n onChange,\n value,\n type,\n format = 'yyyy-MM-dd',\n\n placeholder,\n onFocus,\n onBlur,\n disabled,\n controlComponent,\n hintComponent,\n hint,\n variant,\n TextComponent = Text,\n CalendarComponent,\n bottomOffset,\n rightComponent,\n animationType = 'fade',\n style,\n locale,\n closeOnPick = false,\n ...rest\n}: DatePickerProps<T>): JSX.Element {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [modalVisible, setModalVisible] = React.useState(false);\n\n const handlePressInput = React.useCallback(() => {\n setModalVisible(true);\n handleFocus();\n }, [handleFocus, setModalVisible]);\n\n const handleCloseModal = React.useCallback(() => {\n setModalVisible(false);\n handleBlur();\n }, [handleBlur, setModalVisible]);\n\n const getDisplayValue = () => {\n if (!value) return placeholder;\n if (type === 'day') {\n return formatDate(value as Date, format);\n } else {\n const { lowest, highest } = value as DateRange;\n if (highest)\n return `${formatDate(lowest, format)} - ${formatDate(highest, format)}`;\n else return formatDate(lowest, format);\n }\n };\n\n const StyledText = getStyledTextComponent(TextComponent);\n\n useEffect(() => {\n if (closeOnPick && value && type === 'day') {\n setTimeout(handleCloseModal, 200);\n }\n if (closeOnPick && value && type === 'range') {\n const { lowest, highest } = value as DateRange;\n lowest && highest && setTimeout(handleCloseModal, 200);\n }\n }, [value, closeOnPick, type, handleCloseModal]);\n\n return (\n <>\n {controlComponent ? (\n controlComponent(handlePressInput, getDisplayValue())\n ) : (\n <HintInputContainer\n focused={focused}\n viewStyle={style}\n onPress={handlePressInput}\n disabled={disabled}\n hintComponent={hintComponent}\n LabelComponent={TextComponent}\n variant={variant}\n hint={hint}\n rightComponent={\n <>\n <CalendarIcon name=\"calendar-sharp\" type=\"ionicon\" size=\"centi\" />\n {rightComponent}\n </>\n }\n {...rest}\n >\n <StyledText fontWeight=\"bold\" disabled={disabled}>\n {getDisplayValue() || ' '}\n </StyledText>\n </HintInputContainer>\n )}\n <Modal\n CalendarComponent={CalendarComponent}\n bottomOffset={bottomOffset}\n visible={modalVisible}\n onRequestClose={handleCloseModal}\n animated\n animationType={animationType}\n month={month}\n year={year}\n onChange={onChange}\n value={value}\n type={type}\n locale={locale}\n />\n </>\n );\n}\n\nexport default DatePicker;\n"],"file":"DatePicker.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DatePicker/DatePicker.tsx"],"names":["DatePicker","month","year","onChange","value","type","format","placeholder","onFocus","onBlur","disabled","controlComponent","hintComponent","hint","variant","TextComponent","Text","CalendarComponent","bottomOffset","rightComponent","animationType","style","locale","closeOnPick","rest","focused","handleBlur","handleFocus","modalVisible","setModalVisible","React","useState","handlePressInput","useCallback","handleCloseModal","getDisplayValue","lowest","highest","StyledText","setTimeout"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;AAoBA,SAASA,UAAT,CAA6C;AAE3CC,EAAAA,KAF2C;AAG3CC,EAAAA,IAH2C;AAI3CC,EAAAA,QAJ2C;AAK3CC,EAAAA,KAL2C;AAM3CC,EAAAA,IAN2C;AAO3CC,EAAAA,MAAM,GAAG,YAPkC;AAS3CC,EAAAA,WAT2C;AAU3CC,EAAAA,OAV2C;AAW3CC,EAAAA,MAX2C;AAY3CC,EAAAA,QAZ2C;AAa3CC,EAAAA,gBAb2C;AAc3CC,EAAAA,aAd2C;AAe3CC,EAAAA,IAf2C;AAgB3CC,E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B;AAAoC,MAAA,IAAI,EAAC,SAAzC;AAAmD,MAAA,IAAI,EAAC;AAAxD,MADF,EAEGM,cAFH;AAVJ,KAeMK,IAfN,GAiBE,oBAAC,UAAD;AAAY,IAAA,UAAU,EAAC,MAAvB;AAA8B,IAAA,QAAQ,EAAEd;AAAxC,KACGyB,eAAe,MAAM,GADxB,CAjBF,CAJJ,EA0BE,oBAAC,YAAD;AACE,IAAA,iBAAiB,EAAElB,iBADrB;AAEE,IAAA,YAAY,EAAEC,YAFhB;AAGE,IAAA,OAAO,EAAEU,YAHX;AAIE,IAAA,cAAc,EAAEM,gBAJlB;AAKE,IAAA,QAAQ,MALV;AAME,IAAA,aAAa,EAAEd,aANjB;AAOE,IAAA,KAAK,EAAEnB,KAPT;AAQE,IAAA,IAAI,EAAEC,IARR;AASE,IAAA,QAAQ,EAAEC,QATZ;AAUE,IAAA,KAAK,EAAEC,KAVT;AAWE,IAAA,IAAI,EAAEC,IAXR;AAYE,IAAA,MAAM,EAAEiB;AAZV,IA1BF,CADF;AA2CD;;eAEctB,U","sourcesContent":["import { format as formatDate } from 'date-fns';\nimport * as React from 'react';\nimport { ModalBaseProps } from 'react-native';\nimport { InputContainerProps, useInputFocus } from '../../atoms/Input';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { CalendarProps, DateRange, SelectionType } from '../Calendar';\nimport { DatePickerModalProps, Modal } from './Modal';\nimport { CalendarIcon, getStyledTextComponent } from './styled';\nimport { HintInputContainer } from '../HintInputContainer';\nimport { useEffect } from 'react';\n\nexport interface DatePickerProps<T extends SelectionType>\n extends InputContainerProps,\n DatePickerModalProps<T>,\n Omit<CalendarProps<T>, 'style'> {\n controlComponent?: (\n onPress: () => void,\n displayValue?: string\n ) => JSX.Element;\n TextComponent?: React.FC<TextProps>;\n animationType?: ModalBaseProps['animationType'];\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n format?: string;\n closeOnPick?: boolean;\n}\n\nfunction DatePicker<T extends SelectionType>({\n /** DatePicker props */\n month,\n year,\n onChange,\n value,\n type,\n format = 'yyyy-MM-dd',\n\n placeholder,\n onFocus,\n onBlur,\n disabled,\n controlComponent,\n hintComponent,\n hint,\n variant,\n TextComponent = Text,\n CalendarComponent,\n bottomOffset,\n rightComponent,\n animationType = 'fade',\n style,\n locale,\n closeOnPick = false,\n ...rest\n}: DatePickerProps<T>): JSX.Element {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [modalVisible, setModalVisible] = React.useState(false);\n\n const handlePressInput = React.useCallback(() => {\n setModalVisible(true);\n handleFocus();\n }, [handleFocus, setModalVisible]);\n\n const handleCloseModal = React.useCallback(() => {\n setModalVisible(false);\n handleBlur();\n }, [handleBlur, setModalVisible]);\n\n const getDisplayValue = () => {\n if (!value) return placeholder;\n if (type === 'day') {\n return formatDate(value as Date, format, { locale: locale });\n } else {\n const { lowest, highest } = value as DateRange;\n if (highest)\n return `${formatDate(lowest, format, {\n locale: locale,\n })} - ${formatDate(highest, format, { locale: locale })}`;\n else return formatDate(lowest, format, { locale: locale });\n }\n };\n\n const StyledText = getStyledTextComponent(TextComponent);\n\n useEffect(() => {\n if (closeOnPick && value && type === 'day') {\n setTimeout(handleCloseModal, 200);\n }\n if (closeOnPick && value && type === 'range') {\n const { lowest, highest } = value as DateRange;\n lowest && highest && setTimeout(handleCloseModal, 200);\n }\n }, [value, closeOnPick, type, handleCloseModal]);\n\n return (\n <>\n {controlComponent ? (\n controlComponent(handlePressInput, getDisplayValue())\n ) : (\n <HintInputContainer\n focused={focused}\n viewStyle={style}\n onPress={handlePressInput}\n disabled={disabled}\n hintComponent={hintComponent}\n LabelComponent={TextComponent}\n variant={variant}\n hint={hint}\n rightComponent={\n <>\n <CalendarIcon name=\"calendar-sharp\" type=\"ionicon\" size=\"centi\" />\n {rightComponent}\n </>\n }\n {...rest}\n >\n <StyledText fontWeight=\"bold\" disabled={disabled}>\n {getDisplayValue() || ' '}\n </StyledText>\n </HintInputContainer>\n )}\n <Modal\n CalendarComponent={CalendarComponent}\n bottomOffset={bottomOffset}\n visible={modalVisible}\n onRequestClose={handleCloseModal}\n animated\n animationType={animationType}\n month={month}\n year={year}\n onChange={onChange}\n value={value}\n type={type}\n locale={locale}\n />\n </>\n );\n}\n\nexport default DatePicker;\n"],"file":"DatePicker.js"}
@@ -13,6 +13,8 @@ var _Calendar = require("../Calendar");
13
13
 
14
14
  var _styled = require("./styled");
15
15
 
16
+ var _reactCore = require("@tecsinapse/react-core");
17
+
16
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
19
 
18
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -40,7 +42,7 @@ const Component = ({
40
42
  }), React.createElement(_styled.Backdrop, {
41
43
  onPress: onRequestClose,
42
44
  effect: "none"
43
- }, React.createElement(_styled.ModalContent, {
45
+ }, React.createElement(_reactCore.PressableSurface, null, React.createElement(_styled.ModalContent, {
44
46
  offset: bottomOffset
45
47
  }, React.createElement(CalendarComponent, {
46
48
  pointerEvents: 'box-none',
@@ -50,7 +52,7 @@ const Component = ({
50
52
  year: year,
51
53
  onChange: onChange,
52
54
  locale: locale
53
- }))));
55
+ })))));
54
56
  };
55
57
 
56
58
  const Modal = Component;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DatePicker/Modal.tsx"],"names":["Component","type","value","onRequestClose","month","year","onChange","CalendarComponent","Calendar","bottomOffset","locale","modalProps","Modal"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAOA,MAAMA,SAAS,GAAG,CAA0B;AAC1CC,EAAAA,IAD0C;AAE1CC,EAAAA,KAF0C;AAG1CC,EAAAA,cAH0C;AAI1CC,EAAAA,KAJ0C;AAK1CC,EAAAA,IAL0C;AAM1CC,EAAAA,QAN0C;AAO1CC,EAAAA,iBAAiB,GAAGC,kBAPsB;AAQ1CC,EAAAA,YAAY,GAAG,CAR2B;AAS1CC,EAAAA,MAT0C;AAU1C,KAAGC;AAVuC,CAA1B,KAW0D;AAC1E,SACE,oBAAC,kBAAD;AACE,IAAA,WAAW,MADb;AAEE,IAAA,mBAAmB,MAFrB;AAGE,IAAA,oBAAoB;AAHtB,KAIMA,UAJN;AAKE,IAAA,cAAc,EAAER;AALlB,MAOE,oBAAC,gBAAD;AAAU,IAAA,OAAO,EAAEA,cAAnB;AAAmC,IAAA,MAAM,EAAC;AAA1C,KACE,oBAAC,oBAAD;AAAc,IAAA,MAAM,EAAEM;AAAtB,KACE,oBAAC,iBAAD;AACE,IAAA,aAAa,EAAE,UADjB;AAEE,IAAA,IAAI,EAAER,IAFR;AAGE,IAAA,KAAK,EAAEC,KAHT;AAIE,IAAA,KAAK,EAAEE,KAJT;AAKE,IAAA,IAAI,EAAEC,IALR;AAME,IAAA,QAAQ,EAAEC,QANZ;AAOE,IAAA,MAAM,EAAEI;AAPV,IADF,CADF,CAPF,CADF;AAuBD,CAnCD;;AAqCO,MAAME,KAAK,GAAGZ,SAAd","sourcesContent":["import * as React from 'react';\nimport { Modal as RNModal, ModalProps } from 'react-native';\nimport { Calendar, CalendarProps, SelectionType } from '../Calendar';\nimport { Backdrop, ModalContent } from './styled';\n\nexport interface DatePickerModalProps<T extends SelectionType> {\n CalendarComponent?: React.FC<CalendarProps<T>>;\n bottomOffset?: number;\n}\n\nconst Component = <T extends SelectionType>({\n type,\n value,\n onRequestClose,\n month,\n year,\n onChange,\n CalendarComponent = Calendar,\n bottomOffset = 0,\n locale,\n ...modalProps\n}: CalendarProps<T> & ModalProps & DatePickerModalProps<T>): JSX.Element => {\n return (\n <RNModal\n transparent\n hardwareAccelerated\n statusBarTranslucent\n {...modalProps}\n onRequestClose={onRequestClose}\n >\n <Backdrop onPress={onRequestClose} effect=\"none\">\n <ModalContent offset={bottomOffset}>\n <CalendarComponent\n pointerEvents={'box-none'}\n type={type}\n value={value}\n month={month}\n year={year}\n onChange={onChange}\n locale={locale}\n />\n </ModalContent>\n </Backdrop>\n </RNModal>\n );\n};\n\nexport const Modal = Component;\n"],"file":"Modal.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DatePicker/Modal.tsx"],"names":["Component","type","value","onRequestClose","month","year","onChange","CalendarComponent","Calendar","bottomOffset","locale","modalProps","Modal"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAOA,MAAMA,SAAS,GAAG,CAA0B;AAC1CC,EAAAA,IAD0C;AAE1CC,EAAAA,KAF0C;AAG1CC,EAAAA,cAH0C;AAI1CC,EAAAA,KAJ0C;AAK1CC,EAAAA,IAL0C;AAM1CC,EAAAA,QAN0C;AAO1CC,EAAAA,iBAAiB,GAAGC,kBAPsB;AAQ1CC,EAAAA,YAAY,GAAG,CAR2B;AAS1CC,EAAAA,MAT0C;AAU1C,KAAGC;AAVuC,CAA1B,KAW0D;AAC1E,SACE,oBAAC,kBAAD;AACE,IAAA,WAAW,MADb;AAEE,IAAA,mBAAmB,MAFrB;AAGE,IAAA,oBAAoB;AAHtB,KAIMA,UAJN;AAKE,IAAA,cAAc,EAAER;AALlB,MAOE,oBAAC,gBAAD;AAAU,IAAA,OAAO,EAAEA,cAAnB;AAAmC,IAAA,MAAM,EAAC;AAA1C,KACE,oBAAC,2BAAD,QACE,oBAAC,oBAAD;AAAc,IAAA,MAAM,EAAEM;AAAtB,KACE,oBAAC,iBAAD;AACE,IAAA,aAAa,EAAE,UADjB;AAEE,IAAA,IAAI,EAAER,IAFR;AAGE,IAAA,KAAK,EAAEC,KAHT;AAIE,IAAA,KAAK,EAAEE,KAJT;AAKE,IAAA,IAAI,EAAEC,IALR;AAME,IAAA,QAAQ,EAAEC,QANZ;AAOE,IAAA,MAAM,EAAEI;AAPV,IADF,CADF,CADF,CAPF,CADF;AAyBD,CArCD;;AAuCO,MAAME,KAAK,GAAGZ,SAAd","sourcesContent":["import * as React from 'react';\nimport { Modal as RNModal, ModalProps } from 'react-native';\nimport { Calendar, CalendarProps, SelectionType } from '../Calendar';\nimport { Backdrop, ModalContent } from './styled';\nimport { PressableSurface } from '@tecsinapse/react-core';\n\nexport interface DatePickerModalProps<T extends SelectionType> {\n CalendarComponent?: React.FC<CalendarProps<T>>;\n bottomOffset?: number;\n}\n\nconst Component = <T extends SelectionType>({\n type,\n value,\n onRequestClose,\n month,\n year,\n onChange,\n CalendarComponent = Calendar,\n bottomOffset = 0,\n locale,\n ...modalProps\n}: CalendarProps<T> & ModalProps & DatePickerModalProps<T>): JSX.Element => {\n return (\n <RNModal\n transparent\n hardwareAccelerated\n statusBarTranslucent\n {...modalProps}\n onRequestClose={onRequestClose}\n >\n <Backdrop onPress={onRequestClose} effect=\"none\">\n <PressableSurface>\n <ModalContent offset={bottomOffset}>\n <CalendarComponent\n pointerEvents={'box-none'}\n type={type}\n value={value}\n month={month}\n year={year}\n onChange={onChange}\n locale={locale}\n />\n </ModalContent>\n </PressableSurface>\n </Backdrop>\n </RNModal>\n );\n};\n\nexport const Modal = Component;\n"],"file":"Modal.js"}
@@ -79,7 +79,9 @@ const DateTimePicker = ({
79
79
  };
80
80
 
81
81
  const StyledText = (0, _styled.getStyledTextComponent)(TextComponent);
82
- const displayValue = (value ? (0, _dateFns.format)(value, format) : placeholder) || ' ';
82
+ const displayValue = (value ? (0, _dateFns.format)(value, format, {
83
+ locale: locale
84
+ }) : placeholder) || ' ';
83
85
  return React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, displayValue) : React.createElement(_HintInputContainer.HintInputContainer, _extends({
84
86
  focused: focused,
85
87
  viewStyle: style,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/DateTimePicker.tsx"],"names":["DateTimePicker","onChange","value","mode","format","locale","upperDateThreshold","lowerDateThreshold","offsetThreshold","upperOffsetThreshold","lowerOffsetThreshold","dateModalTitle","timeModalTitle","dateConfirmButtonText","timeConfirmButtonText","dayLabel","monthLabel","yearLabel","hourLabel","minuteLabel","placeholder","onFocus","onBlur","disabled","controlComponent","hintComponent","hint","variant","TextComponent","Text","DateTimeSelectorComponent","bottomOffset","rightComponent","animationType","style","rest","focused","handleBlur","handleFocus","modalVisible","setModalVisible","React","useState","handlePressInput","handleCloseModal","StyledText","displayValue"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;AAiBA,MAAMA,cAA6C,GAAG,CAAC;AACrDC,EAAAA,QADqD;AAErDC,EAAAA,KAFqD;AAGrDC,EAAAA,IAAI,GAAG,MAH8C;AAIrDC,EAAAA,MAAM,GAAG,qBAJ4C;AAKrDC,EAAAA,MALqD;AAMrDC,EAAAA,kBANqD;AAOrDC,EAAAA,kBAPqD;AAQrDC,EAAAA,eARqD;AASrDC,EAAAA,oBATqD;AAUrDC,EAAAA,oBAVqD;AAYrDC,EAAAA,cAZqD;AAarDC,EAAAA,cAbqD;AAcrDC,EAAAA,qBAdqD;AAerDC,EAAAA,qBAfqD;AAgBrDC,EAAAA,QAhBqD;AAiBrDC,EAAAA,UAjBqD;AAkBrDC,EAAAA,SAlBqD;AAmBrDC,EAAAA,SAnBqD;AAoBrDC,EAAAA,WApBqD;AAsB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IAAA,SAAS,EAAEC,SAxBb;AAyBE,IAAA,WAAW,EAAEC;AAzBf,IA1BF,CADF;AAwDD,CAnHD;;eAqHenB,c","sourcesContent":["import { format as formatDate } from 'date-fns';\nimport * as React from 'react';\nimport { ModalBaseProps } from 'react-native';\nimport { InputContainerProps, useInputFocus } from '../../atoms/Input';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { CalendarIcon, getStyledTextComponent } from '../DatePicker/styled';\nimport { DateTimeSelectorProps } from '../DateTimeSelector';\nimport { DateTimePickerModalProps, Modal } from './Modal';\nimport { HintInputContainer } from '../HintInputContainer';\n\nexport interface DateTimePickerProps\n extends InputContainerProps,\n DateTimePickerModalProps,\n Omit<DateTimeSelectorProps, 'style'> {\n controlComponent?: (\n onPress: () => void,\n displayValue?: string\n ) => JSX.Element;\n TextComponent?: React.FC<TextProps>;\n animationType?: ModalBaseProps['animationType'];\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n}\n\nconst DateTimePicker: React.FC<DateTimePickerProps> = ({\n onChange,\n value,\n mode = 'date',\n format = 'yyyy-MM-dd hh:mm:ss',\n locale,\n upperDateThreshold,\n lowerDateThreshold,\n offsetThreshold,\n upperOffsetThreshold,\n lowerOffsetThreshold,\n\n dateModalTitle,\n timeModalTitle,\n dateConfirmButtonText,\n timeConfirmButtonText,\n dayLabel,\n monthLabel,\n yearLabel,\n hourLabel,\n minuteLabel,\n\n placeholder,\n onFocus,\n onBlur,\n disabled,\n controlComponent,\n hintComponent,\n hint,\n variant = 'default',\n TextComponent = Text,\n DateTimeSelectorComponent,\n bottomOffset,\n rightComponent,\n animationType = 'fade',\n style,\n ...rest\n}) => {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [modalVisible, setModalVisible] = React.useState(false);\n\n const handlePressInput = () => {\n setModalVisible(true);\n handleFocus();\n };\n\n const handleCloseModal = () => {\n setModalVisible(false);\n handleBlur();\n };\n\n const StyledText = getStyledTextComponent(TextComponent);\n const displayValue = (value ? formatDate(value, format) : placeholder) || ' ';\n\n return (\n <>\n {controlComponent ? (\n controlComponent(handlePressInput, displayValue)\n ) : (\n <HintInputContainer\n focused={focused}\n viewStyle={style}\n onPress={handlePressInput}\n disabled={disabled}\n LabelComponent={TextComponent}\n variant={variant}\n hint={hint}\n hintComponent={hintComponent}\n rightComponent={\n <>\n <CalendarIcon name=\"calendar-sharp\" type=\"ionicon\" size=\"centi\" />\n {rightComponent}\n </>\n }\n {...rest}\n >\n <StyledText fontWeight=\"bold\" disabled={disabled}>\n {displayValue}\n </StyledText>\n </HintInputContainer>\n )}\n <Modal\n DateTimeSelectorComponent={DateTimeSelectorComponent}\n bottomOffset={bottomOffset}\n visible={modalVisible}\n onRequestClose={handleCloseModal}\n animated\n animationType={animationType}\n onChange={onChange}\n value={value}\n mode={mode}\n format={format}\n locale={locale}\n upperDateThreshold={upperDateThreshold}\n lowerDateThreshold={lowerDateThreshold}\n offsetThreshold={offsetThreshold}\n upperOffsetThreshold={upperOffsetThreshold}\n lowerOffsetThreshold={lowerOffsetThreshold}\n dateModalTitle={dateModalTitle}\n timeModalTitle={timeModalTitle}\n dateConfirmButtonText={dateConfirmButtonText}\n timeConfirmButtonText={timeConfirmButtonText}\n dayLabel={dayLabel}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n hourLabel={hourLabel}\n minuteLabel={minuteLabel}\n />\n </>\n );\n};\n\nexport default DateTimePicker;\n"],"file":"DateTimePicker.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/DateTimePicker.tsx"],"names":["DateTimePicker","onChange","value","mode","format","locale","upperDateThreshold","lowerDateThreshold","offsetThreshold","upperOffsetThreshold","lowerOffsetThreshold","dateModalTitle","timeModalTitle","dateConfirmButtonText","timeConfirmButtonText","dayLabel","monthLabel","yearLabel","hourLabel","minuteLabel","placeholder","onFocus","onBlur","disabled","controlComponent","hintComponent","hint","variant","TextComponent","Text","DateTimeSelectorComponent","bottomOffset","rightComponent","animationType","style","rest","focused","handleBlur","handleFocus","modalVisible","setModalVisible","React","useState","handlePressInput","handleCloseModal","StyledText","displayValue"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;AAiBA,MAAMA,cAA6C,GAAG,CAAC;AACrDC,EAAAA,QADqD;AAErDC,EAAAA,KAFqD;AAGrDC,EAAAA,IAAI,GAAG,MAH8C;AAIrDC,EAAAA,MAAM,GAAG,qBAJ4C;AAKrDC,EAAAA,MALqD;AAMrDC,EAAAA,kBANqD;AAOrDC,EAAAA,kBAPqD;AAQrDC,EAAAA,eARqD;AASrDC,EAAAA,oBATqD;AAUrDC,EAAAA,oBAVqD;AAYrDC,EAAAA,cAZqD;AAarDC,EAAAA,cAbqD;AAcrDC,EAAAA,qBAdqD;AAerDC,EAAAA,qBAfqD;AAgBrDC,EAAAA,QAhBqD;AAiBrDC,EAAAA,UAjBqD;AAkBrDC,EAAAA,SAlBqD;AAmBrDC,EAAAA,SAnBqD;AAoBrDC,EAAAA,WApBqD;AAsBrDC,EAAAA,WAtBqD;AAuBrDC,EAAAA,OAvBqD;AAwBrDC,EAAAA,MAxBqD;AAyBrDC,EAAAA,QAzBqD;AA0BrDC,EAAAA,gBA1BqD;AA2BrDC,EAAAA,aA3BqD;AA4BrDC,EAAAA,IA5BqD;AA6BrDC,EAAAA,OAAO,GAAG,SA7B2C;AA8BrDC,EAAAA,aAAa,GAAGC,UA9BqC;AA+BrDC,EAAAA,yBA/BqD;AAgCrDC,EAAAA,YAhCqD;AAiCrDC,EAAAA,cAjCqD;AAkCrDC,EAAAA,aAAa,GAAG,MAlCqC;AAmCrDC,EAAAA,KAnCqD;AAoCrD,KAAGC;AApCkD,CAAD,KAqChD;AACJ,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,UAAX;AAAuBC,IAAAA;AAAvB,MAAuC,0BAC3CjB,OAD2C,EAE3CC,MAF2C,EAG3C,CAACC,QAH0C,C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hB;AAGE,IAAA,OAAO,EAAEQ,YAHX;AAIE,IAAA,cAAc,EAAEK,gBAJlB;AAKE,IAAA,QAAQ,MALV;AAME,IAAA,aAAa,EAAEX,aANjB;AAOE,IAAA,QAAQ,EAAEhC,QAPZ;AAQE,IAAA,KAAK,EAAEC,KART;AASE,IAAA,IAAI,EAAEC,IATR;AAUE,IAAA,MAAM,EAAEC,MAVV;AAWE,IAAA,MAAM,EAAEC,MAXV;AAYE,IAAA,kBAAkB,EAAEC,kBAZtB;AAaE,IAAA,kBAAkB,EAAEC,kBAbtB;AAcE,IAAA,eAAe,EAAEC,eAdnB;AAeE,IAAA,oBAAoB,EAAEC,oBAfxB;AAgBE,IAAA,oBAAoB,EAAEC,oBAhBxB;AAiBE,IAAA,cAAc,EAAEC,cAjBlB;AAkBE,IAAA,cAAc,EAAEC,cAlBlB;AAmBE,IAAA,qBAAqB,EAAEC,qBAnBzB;AAoBE,IAAA,qBAAqB,EAAEC,qBApBzB;AAqBE,IAAA,QAAQ,EAAEC,QArBZ;AAsBE,IAAA,UAAU,EAAEC,UAtBd;AAuBE,IAAA,SAAS,EAAEC,SAvBb;AAwBE,IAAA,SAAS,EAAEC,SAxBb;AAyBE,IAAA,WAAW,EAAEC;AAzBf,IA1BF,CADF;AAwDD,CArHD;;eAuHenB,c","sourcesContent":["import { format as formatDate } from 'date-fns';\nimport * as React from 'react';\nimport { ModalBaseProps } from 'react-native';\nimport { InputContainerProps, useInputFocus } from '../../atoms/Input';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { CalendarIcon, getStyledTextComponent } from '../DatePicker/styled';\nimport { DateTimeSelectorProps } from '../DateTimeSelector';\nimport { DateTimePickerModalProps, Modal } from './Modal';\nimport { HintInputContainer } from '../HintInputContainer';\n\nexport interface DateTimePickerProps\n extends InputContainerProps,\n DateTimePickerModalProps,\n Omit<DateTimeSelectorProps, 'style'> {\n controlComponent?: (\n onPress: () => void,\n displayValue?: string\n ) => JSX.Element;\n TextComponent?: React.FC<TextProps>;\n animationType?: ModalBaseProps['animationType'];\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n}\n\nconst DateTimePicker: React.FC<DateTimePickerProps> = ({\n onChange,\n value,\n mode = 'date',\n format = 'yyyy-MM-dd hh:mm:ss',\n locale,\n upperDateThreshold,\n lowerDateThreshold,\n offsetThreshold,\n upperOffsetThreshold,\n lowerOffsetThreshold,\n\n dateModalTitle,\n timeModalTitle,\n dateConfirmButtonText,\n timeConfirmButtonText,\n dayLabel,\n monthLabel,\n yearLabel,\n hourLabel,\n minuteLabel,\n\n placeholder,\n onFocus,\n onBlur,\n disabled,\n controlComponent,\n hintComponent,\n hint,\n variant = 'default',\n TextComponent = Text,\n DateTimeSelectorComponent,\n bottomOffset,\n rightComponent,\n animationType = 'fade',\n style,\n ...rest\n}) => {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [modalVisible, setModalVisible] = React.useState(false);\n\n const handlePressInput = () => {\n setModalVisible(true);\n handleFocus();\n };\n\n const handleCloseModal = () => {\n setModalVisible(false);\n handleBlur();\n };\n\n const StyledText = getStyledTextComponent(TextComponent);\n const displayValue =\n (value ? formatDate(value, format, { locale: locale }) : placeholder) ||\n ' ';\n\n return (\n <>\n {controlComponent ? (\n controlComponent(handlePressInput, displayValue)\n ) : (\n <HintInputContainer\n focused={focused}\n viewStyle={style}\n onPress={handlePressInput}\n disabled={disabled}\n LabelComponent={TextComponent}\n variant={variant}\n hint={hint}\n hintComponent={hintComponent}\n rightComponent={\n <>\n <CalendarIcon name=\"calendar-sharp\" type=\"ionicon\" size=\"centi\" />\n {rightComponent}\n </>\n }\n {...rest}\n >\n <StyledText fontWeight=\"bold\" disabled={disabled}>\n {displayValue}\n </StyledText>\n </HintInputContainer>\n )}\n <Modal\n DateTimeSelectorComponent={DateTimeSelectorComponent}\n bottomOffset={bottomOffset}\n visible={modalVisible}\n onRequestClose={handleCloseModal}\n animated\n animationType={animationType}\n onChange={onChange}\n value={value}\n mode={mode}\n format={format}\n locale={locale}\n upperDateThreshold={upperDateThreshold}\n lowerDateThreshold={lowerDateThreshold}\n offsetThreshold={offsetThreshold}\n upperOffsetThreshold={upperOffsetThreshold}\n lowerOffsetThreshold={lowerOffsetThreshold}\n dateModalTitle={dateModalTitle}\n timeModalTitle={timeModalTitle}\n dateConfirmButtonText={dateConfirmButtonText}\n timeConfirmButtonText={timeConfirmButtonText}\n dayLabel={dayLabel}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n hourLabel={hourLabel}\n minuteLabel={minuteLabel}\n />\n </>\n );\n};\n\nexport default DateTimePicker;\n"],"file":"DateTimePicker.js"}
@@ -113,7 +113,9 @@ const DateTimeSelector = ({
113
113
  };
114
114
 
115
115
  const getDisplayedValue = granularity => value => {
116
- return granularity === 'month' ? (0, _dateFns.format)(date, 'MMM').slice(0, 3) : value.toString().padStart(2, '0');
116
+ return granularity === 'month' ? (0, _dateFns.format)(date, 'MMM', {
117
+ locale: locale
118
+ }).slice(0, 3) : value.toString().padStart(2, '0');
117
119
  };
118
120
 
119
121
  const handlePressConfirm = () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DateTimeSelector/DateTimeSelector.tsx"],"names":["getThresholdUnit","mode","threshold","months","includes","days","hours","DateTimeSelector","TextComponent","Text","value","onChange","format","locale","upperDateThreshold","_upperDateThreshold","lowerDateThreshold","_lowerDateThreshold","offsetThreshold","upperOffsetThreshold","lowerOffsetThreshold","dateModalTitle","timeModalTitle","dateConfirmButtonText","timeConfirmButtonText","dayLabel","monthLabel","yearLabel","hourLabel","minuteLabel","rest","Date","date","setDate","React","useState","currentMode","setCurrentMode","isDate","modalTitle","confirmButtonText","handleChange","granularity","newValue","newState","newDate","daysInMonth","getMonth","month","getDate","getDisplayedValue","slice","toString","padStart","handlePressConfirm","handlePressBack","getFullYear","getHours","getMinutes"],"mappings":";;;;;;;AAAA;;AAWA;;AAEA;;AACA;;AACA;;AAC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AAC,kBAAD;AACE,IAAA,aAAa,EAAE1C,aADjB;AAEE,IAAA,QAAQ,EAAEiC,YAAY,CAAC,SAAD,CAFxB;AAGE,IAAA,aAAa,EAAET,IAHjB;AAIE,IAAA,KAAK,EAAEA,IAAI,CAAC0B,UAAL,EAJT;AAKE,IAAA,KAAK,EAAE7B,WAAW,IAAI,QALxB;AAME,IAAA,WAAW,EAAE,SANf;AAOE,IAAA,eAAe,EAAEqB,iBAAiB,CAAC,SAAD;AAPpC,IADF,CAZF,CAtFJ,EA+GE,oBAAC,cAAD;AAAQ,IAAA,KAAK,EAAE,SAAf;AAA0B,IAAA,OAAO,EAAEI;AAAnC,KACE,oBAAC,aAAD;AAAe,IAAA,UAAU,EAAC,MAA1B;AAAiC,IAAA,SAAS,EAAC;AAA3C,KACGd,iBAAiB,IAAI,IADxB,CADF,CA/GF,CADF;AAuHD,CA7ND;;eA+NejC,gB","sourcesContent":["import {\n add,\n compareAsc,\n format as formatDate,\n getDaysInMonth,\n isSameDay,\n isSameMonth,\n isSameYear,\n set,\n sub,\n} from 'date-fns';\nimport * as React from 'react';\nimport { ViewProps } from 'react-native';\nimport { Button } from '../../atoms/Button';\nimport { Icon } from '../../atoms/Icon';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { Granularity, Selector } from './Selector';\nimport { BackButton, Content, Header, Root, SelectorContainer } from './styled';\n\nexport type DateTimeSelectorMode = 'date' | 'time' | 'datetime' | 'month';\n\nexport interface DateTimeSelectorProps extends ViewProps {\n TextComponent?: React.FC<TextProps>;\n value?: Date;\n onChange?: (value: Date) => void | never;\n\n /**\n * Defines the Picker behavior\n * Must be one of ['date', 'time', 'datetime', 'month']\n */\n mode?: DateTimeSelectorMode;\n format?: string;\n locale?: Locale;\n\n /**\n * Maximum date from today\n */\n upperDateThreshold?: Date;\n\n /**\n * Minimum date from today\n */\n lowerDateThreshold?: Date;\n\n /**\n * Minimum and maximum date in distance units from today.\n * The distance unit used depends on the picker mode\n * If mode is date, the unit is day\n * If mode is time, the unit is hour\n * If mode is datetime, the unit is day\n * If mode is month, the unit is month\n */\n offsetThreshold?: number;\n\n /**\n * Maximum date in distance units from today.\n * The distance unit used depends on the picker mode\n * If mode is date, the unit is day\n * If mode is time, the unit is hour\n * If mode is datetime, the unit is day\n * If mode is month, the unit is month\n */\n upperOffsetThreshold?: number;\n\n /**\n * Minimum date in distance units from today.\n * The distance unit used depends on the picker mode\n * If mode is date, the unit is day\n * If mode is time, the unit is hour\n * If mode is datetime, the unit is day\n * If mode is month, the unit is month\n */\n lowerOffsetThreshold?: number;\n\n dateModalTitle?: string;\n timeModalTitle?: string;\n dateConfirmButtonText?: string;\n timeConfirmButtonText?: string;\n dayLabel?: string;\n monthLabel?: string;\n yearLabel?: string;\n hourLabel?: string;\n minuteLabel?: string;\n}\n\nfunction getThresholdUnit(mode: DateTimeSelectorMode, threshold?: number) {\n if (!threshold) return {};\n if (mode === 'month') {\n return { months: threshold };\n } else if (['date', 'datetime'].includes(mode)) {\n return { days: threshold };\n } else {\n return { hours: threshold };\n }\n}\n\nconst DateTimeSelector: React.FC<DateTimeSelectorProps> = ({\n TextComponent = Text,\n value,\n onChange,\n mode = 'date',\n format,\n locale,\n upperDateThreshold: _upperDateThreshold,\n lowerDateThreshold: _lowerDateThreshold,\n offsetThreshold,\n upperOffsetThreshold,\n lowerOffsetThreshold,\n dateModalTitle,\n timeModalTitle,\n dateConfirmButtonText,\n timeConfirmButtonText,\n dayLabel,\n monthLabel,\n yearLabel,\n hourLabel,\n minuteLabel,\n ...rest\n}) => {\n const lowerDateThreshold =\n _lowerDateThreshold ||\n ((offsetThreshold || lowerOffsetThreshold) &&\n sub(\n new Date(),\n getThresholdUnit(mode, offsetThreshold || lowerOffsetThreshold)\n ));\n\n const upperDateThreshold =\n _upperDateThreshold ||\n ((offsetThreshold || upperOffsetThreshold) &&\n add(\n new Date(),\n getThresholdUnit(mode, offsetThreshold || upperOffsetThreshold)\n ));\n\n const [date, setDate] = React.useState<Date>(value || new Date());\n const [currentMode, setCurrentMode] = React.useState<0 | 1>(0);\n\n const isDate =\n ['date', 'month'].includes(mode) ||\n (mode === 'datetime' && currentMode === 0);\n\n const modalTitle = isDate ? dateModalTitle : timeModalTitle;\n const confirmButtonText = isDate\n ? dateConfirmButtonText\n : timeConfirmButtonText;\n\n const handleChange = (granularity: Granularity) => (newValue: number) => {\n setDate(date => {\n let newState: Date;\n // Months and years must have a different handling for being\n // the only date units that may interfere another unit.\n if (['month', 'year'].includes(granularity)) {\n let newDate = set(date, { [granularity]: newValue });\n const daysInMonth = getDaysInMonth(newDate);\n if (granularity === 'year' && date.getMonth() != newDate.getMonth()) {\n newDate = set(newDate, { month: date.getMonth() });\n newState = set(newDate, { date: getDaysInMonth(newDate) });\n }\n newState =\n daysInMonth < date.getDate()\n ? set(newDate, { date: daysInMonth })\n : newDate;\n } else {\n newState = set(date, { [granularity]: newValue });\n }\n\n if (upperDateThreshold && compareAsc(newState, upperDateThreshold) > 0) {\n return upperDateThreshold;\n } else if (\n lowerDateThreshold &&\n compareAsc(newState, lowerDateThreshold) < 0\n ) {\n return lowerDateThreshold;\n } else {\n return newState;\n }\n });\n };\n\n const getDisplayedValue = (granularity: Granularity) => (value: number) => {\n return granularity === 'month'\n ? formatDate(date, 'MMM').slice(0, 3)\n : value.toString().padStart(2, '0');\n };\n\n const handlePressConfirm = () => {\n if (mode === 'datetime' && currentMode === 0) {\n setCurrentMode(1);\n } else {\n onChange?.(date);\n }\n };\n\n const handlePressBack = () => {\n setCurrentMode(0);\n };\n\n return (\n <Root {...rest}>\n <Header>\n {currentMode === 1 && (\n <BackButton onPress={handlePressBack}>\n <Icon\n type={'material-community'}\n name={'chevron-left'}\n size={'mega'}\n colorVariant={'secondary'}\n />\n </BackButton>\n )}\n <TextComponent typography={'base'} colorVariant={'secondary'}>\n {modalTitle}\n </TextComponent>\n </Header>\n\n {isDate ? (\n <Content>\n {mode !== 'month' && (\n <SelectorContainer isFirst>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('date')}\n referenceDate={date}\n value={date.getDate()}\n label={dayLabel || 'Day'}\n granularity={'date'}\n getDisplayValue={getDisplayedValue('date')}\n preventUpper={\n upperDateThreshold\n ? isSameDay(upperDateThreshold, date)\n : false\n }\n preventLower={\n lowerDateThreshold\n ? isSameDay(lowerDateThreshold, date)\n : false\n }\n />\n </SelectorContainer>\n )}\n <SelectorContainer>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('month')}\n referenceDate={date}\n value={date.getMonth()}\n label={monthLabel || 'Month'}\n granularity={'month'}\n getDisplayValue={getDisplayedValue('month')}\n preventUpper={\n upperDateThreshold\n ? isSameMonth(upperDateThreshold, date)\n : false\n }\n preventLower={\n lowerDateThreshold\n ? isSameMonth(lowerDateThreshold, date)\n : false\n }\n />\n </SelectorContainer>\n <SelectorContainer isLast>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('year')}\n referenceDate={date}\n value={date.getFullYear()}\n label={yearLabel || 'Year'}\n granularity={'year'}\n getDisplayValue={getDisplayedValue('year')}\n preventUpper={\n upperDateThreshold\n ? isSameYear(upperDateThreshold, date)\n : false\n }\n preventLower={\n lowerDateThreshold\n ? isSameYear(lowerDateThreshold, date)\n : false\n }\n />\n </SelectorContainer>\n </Content>\n ) : (\n <Content>\n <SelectorContainer isFirst>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('hours')}\n referenceDate={date}\n value={date.getHours()}\n label={hourLabel || 'Hour'}\n granularity={'hours'}\n getDisplayValue={getDisplayedValue('hours')}\n />\n </SelectorContainer>\n <SelectorContainer isLast>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('minutes')}\n referenceDate={date}\n value={date.getMinutes()}\n label={minuteLabel || 'Minute'}\n granularity={'minutes'}\n getDisplayValue={getDisplayedValue('minutes')}\n />\n </SelectorContainer>\n </Content>\n )}\n <Button color={'primary'} onPress={handlePressConfirm}>\n <TextComponent fontWeight=\"bold\" fontColor=\"light\">\n {confirmButtonText || 'OK'}\n </TextComponent>\n </Button>\n </Root>\n );\n};\n\nexport default DateTimeSelector;\n"],"file":"DateTimeSelector.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DateTimeSelector/DateTimeSelector.tsx"],"names":["getThresholdUnit","mode","threshold","months","includes","days","hours","DateTimeSelector","TextComponent","Text","value","onChange","format","locale","upperDateThreshold","_upperDateThreshold","lowerDateThreshold","_lowerDateThreshold","offsetThreshold","upperOffsetThreshold","lowerOffsetThreshold","dateModalTitle","timeModalTitle","dateConfirmButtonText","timeConfirmButtonText","dayLabel","monthLabel","yearLabel","hourLabel","minuteLabel","rest","Date","date","setDate","React","useState","currentMode","setCurrentMode","isDate","modalTitle","confirmButtonText","handleChange","granularity","newValue","newState","newDate","daysInMonth","getMonth","month","getDate","getDisplayedValue","slice","toString","padStart","handlePressConfirm","handlePressBack","getFullYear","getHours","getMinutes"],"mappings":";;;;;;;AAAA;;AAWA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAoEA,SAASA,gBAAT,CAA0BC,IAA1B,EAAsDC,SAAtD,EAA0E;AACxE,MAAI,CAACA,SAAL,EAAgB,OAAO,EAAP;;AAChB,MAAID,IAAI,KAAK,OAAb,EAAsB;AACpB,WAAO;AAAEE,MAAAA,MAAM,EAAED;AAAV,KAAP;AACD,GAFD,MAEO,IAAI,CAAC,MAAD,EAAS,UAAT,EAAqBE,QAArB,CAA8BH,IAA9B,CAAJ,EAAyC;AAC9C,WAAO;AAAEI,MAAAA,IAAI,EAAEH;AAAR,KAAP;AACD,GAFM,MAEA;AACL,WAAO;AAAEI,MAAAA,KAAK,EAAEJ;AAAT,KAAP;AACD;AACF;;AAED,MAAMK,gBAAiD,GAAG,CAAC;AACzDC,EAAAA,aAAa,GAAGC,UADyC;AAEzDC,EAAAA,KAFyD;AAGzDC,EAAAA,QAHyD;AAIzDV,EAAAA,IAAI,GAAG,MAJkD;AAKzDW,EAAAA,MALyD;AAMzDC,EAAAA,MANyD;AAOzDC,EAAAA,kBAAkB,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atDate,\n getDaysInMonth,\n isSameDay,\n isSameMonth,\n isSameYear,\n set,\n sub,\n} from 'date-fns';\nimport * as React from 'react';\nimport { ViewProps } from 'react-native';\nimport { Button } from '../../atoms/Button';\nimport { Icon } from '../../atoms/Icon';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { Granularity, Selector } from './Selector';\nimport { BackButton, Content, Header, Root, SelectorContainer } from './styled';\n\nexport type DateTimeSelectorMode = 'date' | 'time' | 'datetime' | 'month';\n\nexport interface DateTimeSelectorProps extends ViewProps {\n TextComponent?: React.FC<TextProps>;\n value?: Date;\n onChange?: (value: Date) => void | never;\n\n /**\n * Defines the Picker behavior\n * Must be one of ['date', 'time', 'datetime', 'month']\n */\n mode?: DateTimeSelectorMode;\n format?: string;\n locale?: Locale;\n\n /**\n * Maximum date from today\n */\n upperDateThreshold?: Date;\n\n /**\n * Minimum date from today\n */\n lowerDateThreshold?: Date;\n\n /**\n * Minimum and maximum date in distance units from today.\n * The distance unit used depends on the picker mode\n * If mode is date, the unit is day\n * If mode is time, the unit is hour\n * If mode is datetime, the unit is day\n * If mode is month, the unit is month\n */\n offsetThreshold?: number;\n\n /**\n * Maximum date in distance units from today.\n * The distance unit used depends on the picker mode\n * If mode is date, the unit is day\n * If mode is time, the unit is hour\n * If mode is datetime, the unit is day\n * If mode is month, the unit is month\n */\n upperOffsetThreshold?: number;\n\n /**\n * Minimum date in distance units from today.\n * The distance unit used depends on the picker mode\n * If mode is date, the unit is day\n * If mode is time, the unit is hour\n * If mode is datetime, the unit is day\n * If mode is month, the unit is month\n */\n lowerOffsetThreshold?: number;\n\n dateModalTitle?: string;\n timeModalTitle?: string;\n dateConfirmButtonText?: string;\n timeConfirmButtonText?: string;\n dayLabel?: string;\n monthLabel?: string;\n yearLabel?: string;\n hourLabel?: string;\n minuteLabel?: string;\n}\n\nfunction getThresholdUnit(mode: DateTimeSelectorMode, threshold?: number) {\n if (!threshold) return {};\n if (mode === 'month') {\n return { months: threshold };\n } else if (['date', 'datetime'].includes(mode)) {\n return { days: threshold };\n } else {\n return { hours: threshold };\n }\n}\n\nconst DateTimeSelector: React.FC<DateTimeSelectorProps> = ({\n TextComponent = Text,\n value,\n onChange,\n mode = 'date',\n format,\n locale,\n upperDateThreshold: _upperDateThreshold,\n lowerDateThreshold: _lowerDateThreshold,\n offsetThreshold,\n upperOffsetThreshold,\n lowerOffsetThreshold,\n dateModalTitle,\n timeModalTitle,\n dateConfirmButtonText,\n timeConfirmButtonText,\n dayLabel,\n monthLabel,\n yearLabel,\n hourLabel,\n minuteLabel,\n ...rest\n}) => {\n const lowerDateThreshold =\n _lowerDateThreshold ||\n ((offsetThreshold || lowerOffsetThreshold) &&\n sub(\n new Date(),\n getThresholdUnit(mode, offsetThreshold || lowerOffsetThreshold)\n ));\n\n const upperDateThreshold =\n _upperDateThreshold ||\n ((offsetThreshold || upperOffsetThreshold) &&\n add(\n new Date(),\n getThresholdUnit(mode, offsetThreshold || upperOffsetThreshold)\n ));\n\n const [date, setDate] = React.useState<Date>(value || new Date());\n const [currentMode, setCurrentMode] = React.useState<0 | 1>(0);\n\n const isDate =\n ['date', 'month'].includes(mode) ||\n (mode === 'datetime' && currentMode === 0);\n\n const modalTitle = isDate ? dateModalTitle : timeModalTitle;\n const confirmButtonText = isDate\n ? dateConfirmButtonText\n : timeConfirmButtonText;\n\n const handleChange = (granularity: Granularity) => (newValue: number) => {\n setDate(date => {\n let newState: Date;\n // Months and years must have a different handling for being\n // the only date units that may interfere another unit.\n if (['month', 'year'].includes(granularity)) {\n let newDate = set(date, { [granularity]: newValue });\n const daysInMonth = getDaysInMonth(newDate);\n if (granularity === 'year' && date.getMonth() != newDate.getMonth()) {\n newDate = set(newDate, { month: date.getMonth() });\n newState = set(newDate, { date: getDaysInMonth(newDate) });\n }\n newState =\n daysInMonth < date.getDate()\n ? set(newDate, { date: daysInMonth })\n : newDate;\n } else {\n newState = set(date, { [granularity]: newValue });\n }\n\n if (upperDateThreshold && compareAsc(newState, upperDateThreshold) > 0) {\n return upperDateThreshold;\n } else if (\n lowerDateThreshold &&\n compareAsc(newState, lowerDateThreshold) < 0\n ) {\n return lowerDateThreshold;\n } else {\n return newState;\n }\n });\n };\n\n const getDisplayedValue = (granularity: Granularity) => (value: number) => {\n return granularity === 'month'\n ? formatDate(date, 'MMM', { locale: locale }).slice(0, 3)\n : value.toString().padStart(2, '0');\n };\n\n const handlePressConfirm = () => {\n if (mode === 'datetime' && currentMode === 0) {\n setCurrentMode(1);\n } else {\n onChange?.(date);\n }\n };\n\n const handlePressBack = () => {\n setCurrentMode(0);\n };\n\n return (\n <Root {...rest}>\n <Header>\n {currentMode === 1 && (\n <BackButton onPress={handlePressBack}>\n <Icon\n type={'material-community'}\n name={'chevron-left'}\n size={'mega'}\n colorVariant={'secondary'}\n />\n </BackButton>\n )}\n <TextComponent typography={'base'} colorVariant={'secondary'}>\n {modalTitle}\n </TextComponent>\n </Header>\n\n {isDate ? (\n <Content>\n {mode !== 'month' && (\n <SelectorContainer isFirst>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('date')}\n referenceDate={date}\n value={date.getDate()}\n label={dayLabel || 'Day'}\n granularity={'date'}\n getDisplayValue={getDisplayedValue('date')}\n preventUpper={\n upperDateThreshold\n ? isSameDay(upperDateThreshold, date)\n : false\n }\n preventLower={\n lowerDateThreshold\n ? isSameDay(lowerDateThreshold, date)\n : false\n }\n />\n </SelectorContainer>\n )}\n <SelectorContainer>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('month')}\n referenceDate={date}\n value={date.getMonth()}\n label={monthLabel || 'Month'}\n granularity={'month'}\n getDisplayValue={getDisplayedValue('month')}\n preventUpper={\n upperDateThreshold\n ? isSameMonth(upperDateThreshold, date)\n : false\n }\n preventLower={\n lowerDateThreshold\n ? isSameMonth(lowerDateThreshold, date)\n : false\n }\n />\n </SelectorContainer>\n <SelectorContainer isLast>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('year')}\n referenceDate={date}\n value={date.getFullYear()}\n label={yearLabel || 'Year'}\n granularity={'year'}\n getDisplayValue={getDisplayedValue('year')}\n preventUpper={\n upperDateThreshold\n ? isSameYear(upperDateThreshold, date)\n : false\n }\n preventLower={\n lowerDateThreshold\n ? isSameYear(lowerDateThreshold, date)\n : false\n }\n />\n </SelectorContainer>\n </Content>\n ) : (\n <Content>\n <SelectorContainer isFirst>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('hours')}\n referenceDate={date}\n value={date.getHours()}\n label={hourLabel || 'Hour'}\n granularity={'hours'}\n getDisplayValue={getDisplayedValue('hours')}\n />\n </SelectorContainer>\n <SelectorContainer isLast>\n <Selector\n TextComponent={TextComponent}\n onChange={handleChange('minutes')}\n referenceDate={date}\n value={date.getMinutes()}\n label={minuteLabel || 'Minute'}\n granularity={'minutes'}\n getDisplayValue={getDisplayedValue('minutes')}\n />\n </SelectorContainer>\n </Content>\n )}\n <Button color={'primary'} onPress={handlePressConfirm}>\n <TextComponent fontWeight=\"bold\" fontColor=\"light\">\n {confirmButtonText || 'OK'}\n </TextComponent>\n </Button>\n </Root>\n );\n};\n\nexport default DateTimeSelector;\n"],"file":"DateTimeSelector.js"}
@@ -1 +1,2 @@
1
1
  export declare const extractNumbersFromString: (value: string) => number;
2
+ export declare const extractDigitsFromString: (value: string) => string;
@@ -3,9 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.extractNumbersFromString = void 0;
6
+ exports.extractDigitsFromString = exports.extractNumbersFromString = void 0;
7
7
 
8
8
  const extractNumbersFromString = value => Number(value.replace(/[^0-9]/g, ''));
9
9
 
10
10
  exports.extractNumbersFromString = extractNumbersFromString;
11
+
12
+ const extractDigitsFromString = value => value.replace(/[^0-9]/g, '');
13
+
14
+ exports.extractDigitsFromString = extractDigitsFromString;
11
15
  //# sourceMappingURL=extractNumbersFromString.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/extractNumbersFromString.ts"],"names":["extractNumbersFromString","value","Number","replace"],"mappings":";;;;;;;AAAO,MAAMA,wBAAwB,GAAIC,KAAD,IACtCC,MAAM,CAACD,KAAK,CAACE,OAAN,CAAc,SAAd,EAAyB,EAAzB,CAAD,CADD","sourcesContent":["export const extractNumbersFromString = (value: string): number =>\n Number(value.replace(/[^0-9]/g, ''));\n"],"file":"extractNumbersFromString.js"}
1
+ {"version":3,"sources":["../../src/utils/extractNumbersFromString.ts"],"names":["extractNumbersFromString","value","Number","replace","extractDigitsFromString"],"mappings":";;;;;;;AAAO,MAAMA,wBAAwB,GAAIC,KAAD,IACtCC,MAAM,CAACD,KAAK,CAACE,OAAN,CAAc,SAAd,EAAyB,EAAzB,CAAD,CADD;;;;AAMA,MAAMC,uBAAuB,GAAIH,KAAD,IACrCA,KAAK,CAACE,OAAN,CAAc,SAAd,EAAyB,EAAzB,CADK","sourcesContent":["export const extractNumbersFromString = (value: string): number =>\n Number(value.replace(/[^0-9]/g, ''));\n\n/*\n * implemented for the case: string numbers start with 0. Example: 012.345.678-91 Example: 012.345.678-91\n * */\nexport const extractDigitsFromString = (value: string): string =>\n value.replace(/[^0-9]/g, '');\n"],"file":"extractNumbersFromString.js"}
@@ -1,2 +1,2 @@
1
1
  export { lightenDarkenColor } from './lightenDarkenColor';
2
- export { extractNumbersFromString } from './extractNumbersFromString';
2
+ export { extractNumbersFromString, extractDigitsFromString, } from './extractNumbersFromString';
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "extractNumbersFromString", {
15
15
  return _extractNumbersFromString.extractNumbersFromString;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "extractDigitsFromString", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _extractNumbersFromString.extractDigitsFromString;
22
+ }
23
+ });
18
24
 
19
25
  var _lightenDarkenColor = require("./lightenDarkenColor");
20
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { lightenDarkenColor } from './lightenDarkenColor';\nexport { extractNumbersFromString } from './extractNumbersFromString';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { lightenDarkenColor } from './lightenDarkenColor';\nexport {\n extractNumbersFromString,\n extractDigitsFromString,\n} from './extractNumbersFromString';\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-core",
3
3
  "description": "TecSinapse hybrid React components",
4
- "version": "1.10.2",
4
+ "version": "1.11.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -31,5 +31,5 @@
31
31
  "react-native": ">=0.64.0",
32
32
  "react-native-vector-icons": ">=8.1.0"
33
33
  },
34
- "gitHead": "fb3e15d84dc2e9d529dc3a00343751302c325c39"
34
+ "gitHead": "4334fe0f86e0e31cfdbea1acd24c8a1fe64319f4"
35
35
  }
@@ -13,7 +13,6 @@ export const ContainerButtonAvatar = styled(PressableSurface)<
13
13
  theme.iconSize[size]};
14
14
  height: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>
15
15
  theme.iconSize[size]};
16
- cursor: ${({ onPress }) => (onPress ? 'pointer' : 'default')};
17
16
  `;
18
17
 
19
18
  export const StyledAvatar = styled(Image)<Partial<StyleProps>>`
@@ -41,6 +41,7 @@ export interface GroupButtonProps<T> {
41
41
  onChange: (option: T) => void;
42
42
  buttonSize?: ButtonSizeType;
43
43
  style?: StyleProp<ViewStyle>;
44
+ disableAllOptions?: boolean;
44
45
  }
45
46
 
46
47
  const GroupButton = <T extends unknown>({
@@ -58,6 +59,7 @@ const groupOptions = <T extends unknown>({
58
59
  renderKey,
59
60
  onChange,
60
61
  value,
62
+ disableAllOptions,
61
63
  ...rest
62
64
  }: Partial<GroupButtonProps<T>>) => {
63
65
  const theme = useTheme() as ThemeProp;
@@ -71,7 +73,7 @@ const groupOptions = <T extends unknown>({
71
73
  activeBackgroundColorTone,
72
74
  inactiveBackgroundColor,
73
75
  inactiveBackgroundColorTone,
74
- disabled,
76
+ disabled = disableAllOptions || option.options?.disabled,
75
77
  } = {},
76
78
  } = option;
77
79
 
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useState } from 'react';
2
- import { extractNumbersFromString } from '@tecsinapse/react-core';
2
+ import { extractDigitsFromString } from '@tecsinapse/react-core';
3
3
 
4
4
  export interface IMaskValue {
5
5
  formatted?: string;
@@ -57,9 +57,7 @@ export const useMask = (
57
57
  ): [IMask, (text: string) => void] => {
58
58
  const applyMask = useCallback(
59
59
  (value = ''): IMaskValue => {
60
- const onlyNumbers = value
61
- ? String(extractNumbersFromString(value))
62
- : value;
60
+ const onlyNumbers = value ? extractDigitsFromString(value) : value;
63
61
  const selectedMask = getMask(onlyNumbers, mask);
64
62
  const formattedValue = mergeMask(onlyNumbers, selectedMask);
65
63
 
@@ -8,5 +8,5 @@ export const Masks = {
8
8
  PHONE: '(99) 9999-9999',
9
9
  PHONE_EXTENDED: '(99) 99999-9999',
10
10
  COMBINED_PHONE: (value: string) =>
11
- value.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED,
11
+ value?.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED,
12
12
  };
@@ -15,7 +15,7 @@ const Template: Story<SwitchProps> = args => {
15
15
  args.onChange(arg);
16
16
  };
17
17
 
18
- return <Switch active={active} onChange={onChange} />;
18
+ return <Switch active={active} onChange={onChange} disabled={args.disabled}/>;
19
19
  };
20
20
 
21
21
  export const Base = Template.bind({});
@@ -23,4 +23,5 @@ export const Base = Template.bind({});
23
23
  Base.args = {
24
24
  active: true,
25
25
  onChange: value => action('Cicked')(value),
26
+ disabled: false,
26
27
  };
@@ -1,6 +1,6 @@
1
1
  import { useTheme } from '@emotion/react';
2
- import React, { FC, useCallback } from 'react';
3
- import { Animated, StyleProp, ViewStyle } from 'react-native';
2
+ import React, { FC, useCallback, useEffect } from 'react';
3
+ import { Animated, StyleProp, ViewStyle, Text } from 'react-native';
4
4
  import {
5
5
  ColorGradationType,
6
6
  ColorType,
@@ -9,7 +9,7 @@ import {
9
9
  import { PressableSurface } from '../PressableSurface';
10
10
  import { StyledSwitch } from './styled';
11
11
  import { transitionSwitch } from './animation';
12
- import { extractNumbersFromString } from '../../../utils';
12
+ import { extractNumbersFromString, lightenDarkenColor } from '../../../utils';
13
13
 
14
14
  export interface SwitchProps {
15
15
  onChange: (active: boolean) => void;
@@ -20,6 +20,7 @@ export interface SwitchProps {
20
20
  inactiveColorTone?: ColorGradationType;
21
21
  style?: StyleProp<ViewStyle>;
22
22
  dotStyle?: StyleProp<ViewStyle>;
23
+ disabled?: boolean;
23
24
  }
24
25
 
25
26
  const Switch: FC<SwitchProps> = ({
@@ -30,6 +31,7 @@ const Switch: FC<SwitchProps> = ({
30
31
  inactiveColorTone = 'light',
31
32
  active,
32
33
  dotStyle,
34
+ disabled = false,
33
35
  ...rest
34
36
  }): JSX.Element => {
35
37
  const theme = useTheme() as ThemeProp;
@@ -40,11 +42,15 @@ const Switch: FC<SwitchProps> = ({
40
42
  const animatedColor = React.useRef(new Animated.Value(active ? 1 : 0))
41
43
  .current;
42
44
 
45
+ const getBackgroundColor = (color: string, variation: number) => {
46
+ return disabled ? lightenDarkenColor(color, variation) : color;
47
+ };
48
+
43
49
  const interpolateColor = animatedColor.interpolate({
44
50
  inputRange: [0, 1],
45
51
  outputRange: [
46
- theme.color[inactiveColor][inactiveColorTone],
47
- theme.color[activeColor][activeColorTone],
52
+ getBackgroundColor(theme.color[inactiveColor][inactiveColorTone], 25),
53
+ getBackgroundColor(theme.color[activeColor][activeColorTone], 50),
48
54
  ],
49
55
  });
50
56
 
@@ -52,12 +58,15 @@ const Switch: FC<SwitchProps> = ({
52
58
  backgroundColor: interpolateColor,
53
59
  };
54
60
 
61
+ useEffect(() => {
62
+ transitionSwitch(!active, transitionValue, animatedColor);
63
+ }, [active]);
64
+
55
65
  const handleChange = useCallback(() => {
56
66
  onChange(!active);
57
- transitionSwitch(active, transitionValue, animatedColor);
58
67
  }, [active, onChange]);
59
68
 
60
- const stylesDefaut: ViewStyle = {
69
+ const stylesDefault: ViewStyle = {
61
70
  borderRadius: extractNumbersFromString(theme.borderRadius.pill),
62
71
  paddingHorizontal: extractNumbersFromString(theme.spacing.micro),
63
72
  paddingVertical: 0,
@@ -67,8 +76,13 @@ const Switch: FC<SwitchProps> = ({
67
76
  };
68
77
 
69
78
  return (
70
- <PressableSurface {...rest} onPress={handleChange} effect="none">
71
- <Animated.View style={{ ...animatedStyle, ...stylesDefaut }}>
79
+ <PressableSurface
80
+ {...rest}
81
+ onPress={handleChange}
82
+ effect="none"
83
+ disabled={disabled}
84
+ >
85
+ <Animated.View style={{ ...animatedStyle, ...stylesDefault }}>
72
86
  <StyledSwitch
73
87
  style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}
74
88
  />
@@ -8,23 +8,23 @@ export const transitionSwitch = (
8
8
  if (active) {
9
9
  Animated.timing(transitionValue, {
10
10
  toValue: 0,
11
- duration: 250,
11
+ duration: 150,
12
12
  useNativeDriver: true,
13
13
  }).start();
14
14
  Animated.timing(animatedColor, {
15
15
  toValue: 0,
16
- duration: 250,
16
+ duration: 150,
17
17
  useNativeDriver: false,
18
18
  }).start();
19
19
  } else {
20
20
  Animated.timing(transitionValue, {
21
21
  toValue: 16.5,
22
- duration: 250,
22
+ duration: 150,
23
23
  useNativeDriver: true,
24
24
  }).start();
25
25
  Animated.timing(animatedColor, {
26
26
  toValue: 1,
27
- duration: 250,
27
+ duration: 150,
28
28
  useNativeDriver: false,
29
29
  }).start();
30
30
  }
@@ -74,12 +74,14 @@ function DatePicker<T extends SelectionType>({
74
74
  const getDisplayValue = () => {
75
75
  if (!value) return placeholder;
76
76
  if (type === 'day') {
77
- return formatDate(value as Date, format);
77
+ return formatDate(value as Date, format, { locale: locale });
78
78
  } else {
79
79
  const { lowest, highest } = value as DateRange;
80
80
  if (highest)
81
- return `${formatDate(lowest, format)} - ${formatDate(highest, format)}`;
82
- else return formatDate(lowest, format);
81
+ return `${formatDate(lowest, format, {
82
+ locale: locale,
83
+ })} - ${formatDate(highest, format, { locale: locale })}`;
84
+ else return formatDate(lowest, format, { locale: locale });
83
85
  }
84
86
  };
85
87
 
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { Modal as RNModal, ModalProps } from 'react-native';
3
3
  import { Calendar, CalendarProps, SelectionType } from '../Calendar';
4
4
  import { Backdrop, ModalContent } from './styled';
5
+ import { PressableSurface } from '@tecsinapse/react-core';
5
6
 
6
7
  export interface DatePickerModalProps<T extends SelectionType> {
7
8
  CalendarComponent?: React.FC<CalendarProps<T>>;
@@ -29,17 +30,19 @@ const Component = <T extends SelectionType>({
29
30
  onRequestClose={onRequestClose}
30
31
  >
31
32
  <Backdrop onPress={onRequestClose} effect="none">
32
- <ModalContent offset={bottomOffset}>
33
- <CalendarComponent
34
- pointerEvents={'box-none'}
35
- type={type}
36
- value={value}
37
- month={month}
38
- year={year}
39
- onChange={onChange}
40
- locale={locale}
41
- />
42
- </ModalContent>
33
+ <PressableSurface>
34
+ <ModalContent offset={bottomOffset}>
35
+ <CalendarComponent
36
+ pointerEvents={'box-none'}
37
+ type={type}
38
+ value={value}
39
+ month={month}
40
+ year={year}
41
+ onChange={onChange}
42
+ locale={locale}
43
+ />
44
+ </ModalContent>
45
+ </PressableSurface>
43
46
  </Backdrop>
44
47
  </RNModal>
45
48
  );
@@ -80,7 +80,9 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
80
80
  };
81
81
 
82
82
  const StyledText = getStyledTextComponent(TextComponent);
83
- const displayValue = (value ? formatDate(value, format) : placeholder) || ' ';
83
+ const displayValue =
84
+ (value ? formatDate(value, format, { locale: locale }) : placeholder) ||
85
+ ' ';
84
86
 
85
87
  return (
86
88
  <>
@@ -180,7 +180,7 @@ const DateTimeSelector: React.FC<DateTimeSelectorProps> = ({
180
180
 
181
181
  const getDisplayedValue = (granularity: Granularity) => (value: number) => {
182
182
  return granularity === 'month'
183
- ? formatDate(date, 'MMM').slice(0, 3)
183
+ ? formatDate(date, 'MMM', { locale: locale }).slice(0, 3)
184
184
  : value.toString().padStart(2, '0');
185
185
  };
186
186
 
@@ -1,2 +1,8 @@
1
1
  export const extractNumbersFromString = (value: string): number =>
2
2
  Number(value.replace(/[^0-9]/g, ''));
3
+
4
+ /*
5
+ * implemented for the case: string numbers start with 0. Example: 012.345.678-91 Example: 012.345.678-91
6
+ * */
7
+ export const extractDigitsFromString = (value: string): string =>
8
+ value.replace(/[^0-9]/g, '');
@@ -1,2 +1,5 @@
1
1
  export { lightenDarkenColor } from './lightenDarkenColor';
2
- export { extractNumbersFromString } from './extractNumbersFromString';
2
+ export {
3
+ extractNumbersFromString,
4
+ extractDigitsFromString,
5
+ } from './extractNumbersFromString';