@tecsinapse/react-core 1.10.4 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.4...@tecsinapse/react-core@1.11.0) (2021-12-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * [163127] Modais de picker do DS estão em inglês ([a95b0b2](https://github.com/tecsinapse/design-system/commit/a95b0b283f3535af20a23ac6a9a5e5633127d5b0))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [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)
7
18
 
8
19
  **Note:** Version bump only for package @tecsinapse/react-core
@@ -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,WADO;AAEPC,QAAAA,aAFO;AAGPC,QAAAA,qBAHO;AAIPC,QAAAA,yBAJO;AAKPC,QAAAA,uBALO;AAMPC,QAAAA,2BANO;AAOPC,QAAAA;AAPO,UAQL;AAVA,QAWFT,MAXJ;AAaA,UAAMU,GAAG,GAAGf,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAGO,WAAH,CAArB;AACA,UAAMS,MAAM,GAAGD,GAAG,M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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,YAFuC;AAGvCC,EAAAA,SAHuC;AAIvCC,EAAAA,QAJuC;AAKvCC,EAAAA,KALuC;AAMvCC,EAAAA,iBANuC;AAOvC,KAAGP;AAPoC,CAApB,KAQe;AAClC,QAAMQ,KAAK,GAAG,sBAAd;AACA,SAAON,OAAP,aAAOA,OAAP,uBAAOA,OAAO,CAAEO,GAAT,CAAa,CAACC,MAAD,EAASC,GAAT,KAAiB;AAAA;;A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EC,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"}
@@ -53,9 +53,11 @@ const Switch = ({
53
53
  const animatedStyle = {
54
54
  backgroundColor: interpolateColor
55
55
  };
56
+ (0, _react2.useEffect)(() => {
57
+ (0, _animation.transitionSwitch)(active, transitionValue, animatedColor);
58
+ }, [active]);
56
59
  const handleChange = (0, _react2.useCallback)(() => {
57
60
  onChange(!active);
58
- (0, _animation.transitionSwitch)(active, transitionValue, animatedColor);
59
61
  }, [active, onChange]);
60
62
  const stylesDefault = {
61
63
  borderRadius: (0, _utils.extractNumbersFromString)(theme.borderRadius.pill),
@@ -1 +1 @@
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;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/BC,EAAAA,QAAQ,GAAG,KARoB;AAS/B,KAAGC;AAT4B,CAAD,KAUb;AACjB,QAAMC,KAAK,GAAG,sBAAd;;AAEA,QAAMC,eAAe,GAAGC,gBAAMC,MAAN,CAAa,IAAIC,sBAASC,KAAb,CAAmBT,MAAM,GAAG,IAAH,GAAU,CAAnC,CAAb,EACrBU,OADH;;AAGA,QAAMC,aAAa,GAAGL,gBAAMC,MAAN,CAAa,IAAIC,sBAASC,KAAb,CAAmBT,MAAM,GAAG,CAAH,GAAO,CAAhC,CAAb,EACnBU,OADH;;AAGA,QAAME,kBAAkB,GAAG,CAACC,KAAD,EAAgBC,SAAhB,KAAsC;AAC/D,WAAOZ,QAAQ,GAAG,+BAAmBW,KAAnB,EAA0BC,SAA1B,CAAH,GAA0CD,KAAzD;AACD,GAFD;;AAIA,QAAME,gBAAgB,GAAGJ,aAAa,CAACK,WAAd,CAA0B;AACjDC,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,CADqC;AAEjDC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AcD,CA/DD;;eAiEeX,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, 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 const handleChange = useCallback(() => {\n onChange(!active);\n transitionSwitch(active, transitionValue, animatedColor);\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"}
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;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/BC,EAAAA,QAAQ,GAAG,KARoB;AAS/B,KAAGC;AAT4B,CAAD,KAUb;AACjB,QAAMC,KAAK,GAAG,sBAAd;;AAEA,QAAMC,eAAe,GAAGC,gBAAMC,MAAN,CAAa,IAAIC,sBAASC,KAAb,CAAmBT,MAAM,GAAG,IAAH,GAAU,CAAnC,CAAb,EACrBU,OADH;;AAGA,QAAMC,aAAa,GAAGL,gBAAMC,MAAN,CAAa,IAAIC,sBAASC,KAAb,CAAmBT,MAAM,GAAG,CAAH,GAAO,CAAhC,CAAb,EACnBU,OADH;;AAGA,QAAME,kBAAkB,GAAG,CAACC,KAAD,EAAgBC,SAAhB,KAAsC;AAC/D,WAAOZ,QAAQ,GAAG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AAe,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,CADJ;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"}
@@ -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"}
@@ -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;;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,EAAEC,mBAPqC;AAQzDC,EAAAA,kBAAkB,EAAEC,mBARqC;AASzDC,EAAAA,eATyD;AAUzDC,EAAAA,oBAVyD;AAWzDC,EAAAA,oBAXyD;AAYzDC,EAAAA,cA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F,CADK,GAqEL,oBAAC,eAAD,QACE,oBAAC,yBAAD;AAAmB,IAAA,OAAO;AAA1B,KACE,oBAAC,kBAAD;AACE,IAAA,aAAa,EAAExB,aADjB;AAEE,IAAA,QAAQ,EAAEiC,YAAY,CAAC,OAAD,CAFxB;AAGE,IAAA,aAAa,EAAET,IAHjB;AAIE,IAAA,KAAK,EAAEA,IAAI,CAACyB,QAAL,EAJT;AAKE,IAAA,KAAK,EAAE7B,SAAS,IAAI,MALtB;AAME,IAAA,WAAW,EAAE,OANf;AAOE,IAAA,eAAe,EAAEsB,iBAAiB,CAAC,OAAD;AAPpC,IADF,CADF,EAYE,oBAAC,yBAAD;AAAmB,IAAA,MAAM;AAAzB,KACE,oBAAC,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;AA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AEA,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', { 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"}
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.4",
4
+ "version": "1.11.0",
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": "a0f4ed0567683273692e4336ca4f05a9ee98a881"
34
+ "gitHead": "27a01035cee1b709734bd4b6b6f518c4320814f6"
35
35
  }
@@ -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,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,
@@ -58,9 +58,12 @@ const Switch: FC<SwitchProps> = ({
58
58
  backgroundColor: interpolateColor,
59
59
  };
60
60
 
61
+ useEffect(() => {
62
+ transitionSwitch(active, transitionValue, animatedColor);
63
+ }, [active]);
64
+
61
65
  const handleChange = useCallback(() => {
62
66
  onChange(!active);
63
- transitionSwitch(active, transitionValue, animatedColor);
64
67
  }, [active, onChange]);
65
68
 
66
69
  const stylesDefault: ViewStyle = {
@@ -73,18 +76,18 @@ const Switch: FC<SwitchProps> = ({
73
76
  };
74
77
 
75
78
  return (
76
- <PressableSurface
77
- {...rest}
78
- onPress={handleChange}
79
- effect="none"
80
- disabled={disabled}
81
- >
82
- <Animated.View style={{ ...animatedStyle, ...stylesDefault }}>
83
- <StyledSwitch
84
- style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}
85
- />
86
- </Animated.View>
87
- </PressableSurface>
79
+ <PressableSurface
80
+ {...rest}
81
+ onPress={handleChange}
82
+ effect="none"
83
+ disabled={disabled}
84
+ >
85
+ <Animated.View style={{ ...animatedStyle, ...stylesDefault }}>
86
+ <StyledSwitch
87
+ style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}
88
+ />
89
+ </Animated.View>
90
+ </PressableSurface>
88
91
  );
89
92
  };
90
93
 
@@ -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
  }
@@ -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
  );
@@ -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