@tecsinapse/react-core 1.12.8 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/components/atoms/Input/InputElement/InputElement.d.ts +5 -3
  3. package/dist/components/atoms/Input/InputElement/InputElement.js +22 -8
  4. package/dist/components/atoms/Input/InputElement/InputElement.js.map +1 -1
  5. package/dist/components/atoms/Input/hooks/useNumberMask.d.ts +8 -0
  6. package/dist/components/atoms/Input/hooks/useNumberMask.js +98 -0
  7. package/dist/components/atoms/Input/hooks/useNumberMask.js.map +1 -0
  8. package/dist/components/atoms/Input/hooks/useStringMask.d.ts +8 -0
  9. package/dist/components/atoms/Input/hooks/useStringMask.js +109 -0
  10. package/dist/components/atoms/Input/hooks/useStringMask.js.map +1 -0
  11. package/dist/components/atoms/Input/index.d.ts +2 -3
  12. package/dist/components/atoms/Input/index.js +12 -26
  13. package/dist/components/atoms/Input/index.js.map +1 -1
  14. package/dist/components/atoms/ProgressBar/ProgressBar.d.ts +1 -1
  15. package/dist/components/atoms/ProgressBar/ProgressBar.js +6 -6
  16. package/dist/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
  17. package/dist/components/molecules/Calendar/components/MonthWeek.js +5 -10
  18. package/dist/components/molecules/Calendar/components/MonthWeek.js.map +1 -1
  19. package/dist/components/molecules/Calendar/index.d.ts +1 -1
  20. package/dist/components/molecules/Calendar/index.js +6 -0
  21. package/dist/components/molecules/Calendar/index.js.map +1 -1
  22. package/dist/components/molecules/Calendar/styled.js +0 -17
  23. package/dist/components/molecules/Calendar/styled.js.map +1 -1
  24. package/dist/components/molecules/DatePicker/DatePicker.d.ts +6 -5
  25. package/dist/components/molecules/DatePicker/DatePicker.js +22 -32
  26. package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
  27. package/dist/components/molecules/DatePicker/styled.d.ts +0 -14
  28. package/dist/components/molecules/DatePicker/styled.js +1 -46
  29. package/dist/components/molecules/DatePicker/styled.js.map +1 -1
  30. package/dist/components/molecules/DateTimePicker/DateTimePicker.d.ts +5 -4
  31. package/dist/components/molecules/DateTimePicker/DateTimePicker.js +35 -37
  32. package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  33. package/dist/components/molecules/DateTimePicker/styled.d.ts +0 -21
  34. package/dist/components/molecules/DateTimePicker/styled.js +3 -51
  35. package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
  36. package/dist/components/molecules/Grid/Item/Item.d.ts +1 -1
  37. package/dist/components/molecules/Grid/Item/Item.js +7 -5
  38. package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
  39. package/dist/components/molecules/HintInputContainer/HintInputContainer.d.ts +3 -2
  40. package/dist/components/molecules/HintInputContainer/HintInputContainer.js +4 -4
  41. package/dist/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
  42. package/dist/components/molecules/TextArea/TextArea.d.ts +3 -1
  43. package/dist/components/molecules/TextArea/TextArea.js +4 -4
  44. package/dist/components/molecules/TextArea/TextArea.js.map +1 -1
  45. package/dist/index.d.ts +2 -2
  46. package/dist/index.js +15 -29
  47. package/dist/index.js.map +1 -1
  48. package/dist/utils/ResponsiveFontSize.js +1 -1
  49. package/dist/utils/ResponsiveFontSize.js.map +1 -1
  50. package/dist/utils/formatWithMask.d.ts +3 -0
  51. package/dist/utils/formatWithMask.js +31 -0
  52. package/dist/utils/formatWithMask.js.map +1 -0
  53. package/dist/utils/index.d.ts +2 -0
  54. package/dist/utils/index.js +28 -0
  55. package/dist/utils/index.js.map +1 -1
  56. package/dist/utils/masks.d.ts +10 -0
  57. package/dist/utils/masks.js +18 -0
  58. package/dist/utils/masks.js.map +1 -0
  59. package/package.json +2 -2
  60. package/src/components/atoms/Input/InputElement/InputElement.tsx +37 -11
  61. package/src/components/atoms/Input/hooks/useNumberMask.ts +99 -0
  62. package/src/components/atoms/Input/hooks/useStringMask.ts +126 -0
  63. package/src/components/atoms/Input/index.ts +2 -3
  64. package/src/components/atoms/ProgressBar/ProgressBar.tsx +5 -5
  65. package/src/components/molecules/Calendar/components/MonthWeek.tsx +5 -10
  66. package/src/components/molecules/Calendar/index.ts +1 -0
  67. package/src/components/molecules/Calendar/styled.ts +0 -22
  68. package/src/components/molecules/DatePicker/DatePicker.tsx +32 -41
  69. package/src/components/molecules/DatePicker/styled.ts +0 -40
  70. package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +46 -52
  71. package/src/components/molecules/DateTimePicker/styled.ts +1 -49
  72. package/src/components/molecules/Grid/Item/Item.tsx +3 -5
  73. package/src/components/molecules/HintInputContainer/HintInputContainer.tsx +3 -8
  74. package/src/components/molecules/TextArea/TextArea.tsx +3 -9
  75. package/src/index.ts +3 -5
  76. package/src/utils/ResponsiveFontSize.ts +2 -2
  77. package/src/utils/formatWithMask.ts +25 -0
  78. package/src/utils/index.ts +4 -2
  79. package/src/utils/masks.ts +13 -0
  80. package/dist/components/atoms/Input/hooks/useCurrencyMask.d.ts +0 -3
  81. package/dist/components/atoms/Input/hooks/useCurrencyMask.js +0 -69
  82. package/dist/components/atoms/Input/hooks/useCurrencyMask.js.map +0 -1
  83. package/dist/components/atoms/Input/hooks/useMask.d.ts +0 -9
  84. package/dist/components/atoms/Input/hooks/useMask.js +0 -61
  85. package/dist/components/atoms/Input/hooks/useMask.js.map +0 -1
  86. package/dist/components/atoms/Input/masks/index.d.ts +0 -10
  87. package/dist/components/atoms/Input/masks/index.js +0 -18
  88. package/dist/components/atoms/Input/masks/index.js.map +0 -1
  89. package/dist/components/molecules/DatePicker/Modal.d.ts +0 -8
  90. package/dist/components/molecules/DatePicker/Modal.js +0 -60
  91. package/dist/components/molecules/DatePicker/Modal.js.map +0 -1
  92. package/dist/components/molecules/DateTimePicker/Modal.d.ts +0 -7
  93. package/dist/components/molecules/DateTimePicker/Modal.js +0 -89
  94. package/dist/components/molecules/DateTimePicker/Modal.js.map +0 -1
  95. package/src/components/atoms/Input/hooks/useCurrencyMask.ts +0 -74
  96. package/src/components/atoms/Input/hooks/useMask.ts +0 -92
  97. package/src/components/atoms/Input/masks/index.ts +0 -12
  98. package/src/components/molecules/DatePicker/DatePicker.stories.tsx +0 -44
  99. package/src/components/molecules/DatePicker/Modal.tsx +0 -51
  100. package/src/components/molecules/DateTimePicker/DateTimePicker.stories.tsx +0 -26
  101. package/src/components/molecules/DateTimePicker/Modal.tsx +0 -84
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/molecules/Calendar/components/MonthWeek.tsx"],"names":["MonthWeek","week","referenceDate","type","value","TextComponent","onChange","checkIfIsBetween","React","useCallback","date","_value","lowest","highest","checkIfIsSelected","handlePressCell","newValue","undefined","lowestDiff","Math","abs","highestDiff","map","index","isSelected","isBetween","isRangeStart","isRangeEnd","colorTone","getMonth","getDate","memo"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAcA,MAAMA,SAAS,GAAG,CAA0B;AAC1CC,EAAAA,IAD0C;AAE1CC,EAAAA,aAF0C;AAG1CC,EAAAA,IAH0C;AAI1CC,EAAAA,KAJ0C;AAK1CC,EAAAA,aAL0C;AAM1CC,EAAAA;AAN0C,CAA1B,KAOG;AACnB,QAAMC,gBAAgB,GAAGC,eAAMC,WAAN,CACvB,CAACC,IAAD,EAAaC,MAAb,KAAmC;AACjC,QAAIR,IAAI,KAAK,OAAT,IAAoB,CAACQ,MAAzB,EAAiC,OAAO,KAAP,CAAjC,KACK;AACH,YAAM;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAsBF,MAA5B;AACA,UAAI,CAACE,OAAL,EAAc,OAAO,KAAP;AACd,aAAO,yBAAQD,MAAR,EAAgBF,IAAhB,KAAyB,CAAzB,IAA8B,yBAAQG,OAAR,EAAiBH,IAAjB,KAA0B,CAA/D;AACD;AACF,GARsB,EASvB,CAACP,IAAD,CATuB,CAAzB;;AAYA,QAAMW,iBAAiB,GAAGN,eAAMC,WAAN,CACxB,CAACC,IAAD,E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CAACL,IAAD,EAAON,KAAP;AAR1B,OAUE,6BAAC,gBAAD;AAAU,MAAA,QAAQ,EAAEoB,UAApB;AAAgC,MAAA,aAAa,EAAE;AAA/C,OACE,6BAAC,aAAD;AAAe,MAAA,YAAY,EAAE,WAA7B;AAA0C,MAAA,SAAS,EAAEI;AAArD,OACGlB,IAAI,CAACoB,OAAL,EADH,CADF,CAVF,CADF;AAkBD,GAvCA,CADH,CADF;AA4CD,CA7HD;;eA+HetB,eAAMuB,IAAN,CAAW/B,SAAX,C","sourcesContent":["import React from 'react';\nimport { compareAsc as compare, differenceInDays, isSameDay } from 'date-fns';\nimport { Cell, Selected, Week } from '../styled';\nimport { Value, DateRange, SelectionType } from '../Calendar';\nimport { TextProps } from '@tecsinapse/react-core';\n\ninterface IMonthWeek<T extends SelectionType> {\n TextComponent: React.FC<TextProps>;\n /** any as workaround for TS type mismatching */\n onChange?: (value?: any) => void | never;\n type?: T;\n value?: Value<T>;\n week: Date[];\n referenceDate: Date;\n}\n\nconst MonthWeek = <T extends SelectionType>({\n week,\n referenceDate,\n type,\n value,\n TextComponent,\n onChange,\n}: IMonthWeek<T>) => {\n const checkIfIsBetween = React.useCallback(\n (date: Date, _value?: Value<T>) => {\n if (type !== 'range' || !_value) return false;\n else {\n const { lowest, highest } = _value as DateRange;\n if (!highest) return false;\n return compare(lowest, date) <= 0 && compare(highest, date) >= 0;\n }\n },\n [type]\n );\n\n const checkIfIsSelected = React.useCallback(\n (date: Date, _value?: Value<T>) => {\n if (!_value) return false;\n else if (type === 'range' && _value) {\n const { lowest, highest } = _value as DateRange;\n return (\n isSameDay(lowest, date) ||\n (highest ? isSameDay(highest, date) : false)\n );\n } else {\n return isSameDay(_value as Date, date);\n }\n },\n [type]\n );\n\n const handlePressCell = React.useCallback(\n (date: Date, _value?: Value<T>) => () => {\n if (type === 'day') {\n onChange?.(date as never);\n } else if (!_value) {\n onChange?.({ lowest: date } as never);\n } else {\n let newValue;\n const { lowest, highest } = _value as DateRange;\n\n if (!highest) {\n if (compare(date, lowest) === -1) {\n newValue = { lowest: date, highest: lowest };\n } else if (compare(date, lowest) === 0) {\n newValue = undefined;\n } else {\n newValue = { lowest: lowest, highest: date };\n }\n } else {\n if (compare(date, lowest) === -1) {\n newValue = { lowest: date, highest: highest };\n } else if (compare(date, lowest) === 0) {\n newValue = { lowest: highest, highest: undefined };\n } else {\n if (compare(date, highest) === -1) {\n const lowestDiff = Math.abs(differenceInDays(date, lowest));\n const highestDiff = Math.abs(differenceInDays(date, highest));\n newValue = {\n lowest: lowestDiff < highestDiff ? date : lowest,\n highest: highestDiff <= lowestDiff ? date : highest,\n };\n } else if (compare(date, highest) === 0) {\n newValue = { lowest: lowest, highest: undefined };\n } else {\n newValue = { lowest: lowest, highest: date };\n }\n }\n }\n\n onChange?.(newValue as never);\n }\n },\n [onChange, type]\n );\n\n return (\n <Week>\n {week.map((date, index) => {\n const isSelected = checkIfIsSelected(date, value);\n const isBetween = checkIfIsBetween(date, value);\n\n let isRangeStart, isRangeEnd;\n\n if (type === 'range' && value) {\n const { lowest, highest } = value as DateRange;\n isRangeStart = highest && isSameDay(lowest, date);\n isRangeEnd = !!highest && isSameDay(highest, date);\n } else {\n isRangeStart = false;\n isRangeEnd = false;\n }\n\n const colorTone = isSelected\n ? 'xlight'\n : date.getMonth() === referenceDate.getMonth()\n ? 'xdark'\n : 'light';\n\n return (\n <Cell\n key={date.getDate()}\n selected={isSelected}\n highlighted={isBetween}\n isLineEnd={index === 6}\n isLineStart={index === 0}\n isRangeStart={isRangeStart}\n isRangeEnd={isRangeEnd}\n onPress={handlePressCell(date, value)}\n >\n <Selected selected={isSelected} pointerEvents={'none'}>\n <TextComponent colorVariant={'secondary'} colorTone={colorTone}>\n {date.getDate()}\n </TextComponent>\n </Selected>\n </Cell>\n );\n })}\n </Week>\n );\n};\n\nexport default React.memo(MonthWeek);\n"],"file":"MonthWeek.js"}
1
+ {"version":3,"sources":["../../../../../src/components/molecules/Calendar/components/MonthWeek.tsx"],"names":["MonthWeek","week","referenceDate","type","value","TextComponent","onChange","checkIfIsBetween","React","useCallback","date","_value","lowest","highest","checkIfIsSelected","handlePressCell","newValue","undefined","map","index","isSelected","isBetween","isRangeStart","isRangeEnd","colorTone","getMonth","getDate","memo"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAcA,MAAMA,SAAS,GAAG,CAA0B;AAC1CC,EAAAA,IAD0C;AAE1CC,EAAAA,aAF0C;AAG1CC,EAAAA,IAH0C;AAI1CC,EAAAA,KAJ0C;AAK1CC,EAAAA,aAL0C;AAM1CC,EAAAA;AAN0C,CAA1B,KAOG;AACnB,QAAMC,gBAAgB,GAAGC,eAAMC,WAAN,CACvB,CAACC,IAAD,EAAaC,MAAb,KAAmC;AACjC,QAAIR,IAAI,KAAK,OAAT,IAAoB,CAACQ,MAAzB,EAAiC,OAAO,KAAP,CAAjC,KACK;AACH,YAAM;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAsBF,MAA5B;AACA,UAAI,CAACE,OAAL,EAAc,OAAO,KAAP;AACd,aAAO,yBAAQD,MAAR,EAAgBF,IAAhB,KAAyB,CAAzB,IAA8B,yBAAQG,OAAR,EAAiBH,IAAjB,KAA0B,CAA/D;AACD;AACF,GARsB,EASvB,CAACP,IAAD,CATuB,CAAzB;;AAYA,QAAMW,iBAAiB,GAAGN,eAAMC,WAAN,CACxB,CAACC,IAAD,EAAaC,MAAb,KAAmC;AACjC,QAAI,CAACA,MAAL,EAAa,OAAO,KAAP,CAAb,KACK,IAAIR,IAAI,KAAK,OAAT,IAAoBQ,MAAxB,EAAgC;AACnC,YAAM;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAsBF,MAA5B;AACA,aACE,wBAAUC,MAAV,EAAkBF,IAAlB,MACCG,OAAO,GAAG,wBAAUA,OAAV,EAAmBH,IAAnB,CAAH,GAA8B,KADtC,CADF;AAID,KANI,MAME;AACL,aAAO,wBAAUC,MAAV,EAA0BD,IAA1B,CA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O;AACLY,MAAAA,YAAY,GAAG,KAAf;AACAC,MAAAA,UAAU,GAAG,KAAb;AACD;;AAED,UAAMC,SAAS,GAAGJ,UAAU,GACxB,QADwB,GAExBV,IAAI,CAACe,QAAL,OAAoBvB,aAAa,CAACuB,QAAd,EAApB,GACA,OADA,GAEA,OAJJ;AAMA,WACE,6BAAC,YAAD;AACE,MAAA,GAAG,EAAEf,IAAI,CAACgB,OAAL,EADP;AAEE,MAAA,QAAQ,EAAEN,UAFZ;AAGE,MAAA,WAAW,EAAEC,SAHf;AAIE,MAAA,SAAS,EAAEF,KAAK,KAAK,CAJvB;AAKE,MAAA,WAAW,EAAEA,KAAK,KAAK,CALzB;AAME,MAAA,YAAY,EAAEG,YANhB;AAOE,MAAA,UAAU,EAAEC,UAPd;AAQE,MAAA,OAAO,EAAER,eAAe,CAACL,IAAD,EAAON,KAAP;AAR1B,OAUE,6BAAC,gBAAD;AAAU,MAAA,QAAQ,EAAEgB,UAApB;AAAgC,MAAA,aAAa,EAAE;AAA/C,OACE,6BAAC,aAAD;AAAe,MAAA,YAAY,EAAE,WAA7B;AAA0C,MAAA,SAAS,EAAEI;AAArD,OACGd,IAAI,CAACgB,OAAL,EADH,CADF,CAVF,CADF;AAkBD,GAvCA,CADH,CADF;AA4CD,CAxHD;;eA0HelB,eAAMmB,IAAN,CAAW3B,SAAX,C","sourcesContent":["import React from 'react';\nimport { compareAsc as compare, isSameDay } from 'date-fns';\nimport { Cell, Selected, Week } from '../styled';\nimport { Value, DateRange, SelectionType } from '../Calendar';\nimport { TextProps } from '@tecsinapse/react-core';\n\ninterface IMonthWeek<T extends SelectionType> {\n TextComponent: React.FC<TextProps>;\n /** any as workaround for TS type mismatching */\n onChange?: (value?: any) => void | never;\n type?: T;\n value?: Value<T>;\n week: Date[];\n referenceDate: Date;\n}\n\nconst MonthWeek = <T extends SelectionType>({\n week,\n referenceDate,\n type,\n value,\n TextComponent,\n onChange,\n}: IMonthWeek<T>) => {\n const checkIfIsBetween = React.useCallback(\n (date: Date, _value?: Value<T>) => {\n if (type !== 'range' || !_value) return false;\n else {\n const { lowest, highest } = _value as DateRange;\n if (!highest) return false;\n return compare(lowest, date) <= 0 && compare(highest, date) >= 0;\n }\n },\n [type]\n );\n\n const checkIfIsSelected = React.useCallback(\n (date: Date, _value?: Value<T>) => {\n if (!_value) return false;\n else if (type === 'range' && _value) {\n const { lowest, highest } = _value as DateRange;\n return (\n isSameDay(lowest, date) ||\n (highest ? isSameDay(highest, date) : false)\n );\n } else {\n return isSameDay(_value as Date, date);\n }\n },\n [type]\n );\n\n const handlePressCell = React.useCallback(\n (date: Date, _value?: Value<T>) => () => {\n if (type === 'day') {\n onChange?.(date as never);\n } else if (!_value) {\n onChange?.({ lowest: date } as never);\n } else {\n let newValue;\n const { lowest, highest } = _value as DateRange;\n\n if (!highest) {\n if (compare(date, lowest) === -1) {\n newValue = { lowest: date, highest: undefined };\n } else if (compare(date, lowest) === 0) {\n newValue = undefined;\n } else {\n newValue = { lowest: lowest, highest: date };\n }\n } else {\n if (compare(date, lowest) === -1) {\n newValue = { lowest: date, highest: undefined };\n } else if (compare(date, lowest) === 0) {\n newValue = undefined;\n } else {\n if (compare(date, highest) === -1) {\n newValue = { lowest: lowest, highest: date };\n } else if (compare(date, highest) === 0) {\n newValue = { lowest: lowest, highest: undefined };\n } else {\n newValue = { lowest: lowest, highest: date };\n }\n }\n }\n\n onChange?.(newValue as never);\n }\n },\n [onChange, type]\n );\n\n return (\n <Week>\n {week.map((date, index) => {\n const isSelected = checkIfIsSelected(date, value);\n const isBetween = checkIfIsBetween(date, value);\n\n let isRangeStart, isRangeEnd;\n\n if (type === 'range' && value) {\n const { lowest, highest } = value as DateRange;\n isRangeStart = highest && isSameDay(lowest, date);\n isRangeEnd = !!highest && isSameDay(highest, date);\n } else {\n isRangeStart = false;\n isRangeEnd = false;\n }\n\n const colorTone = isSelected\n ? 'xlight'\n : date.getMonth() === referenceDate.getMonth()\n ? 'xdark'\n : 'light';\n\n return (\n <Cell\n key={date.getDate()}\n selected={isSelected}\n highlighted={isBetween}\n isLineEnd={index === 6}\n isLineStart={index === 0}\n isRangeStart={isRangeStart}\n isRangeEnd={isRangeEnd}\n onPress={handlePressCell(date, value)}\n >\n <Selected selected={isSelected} pointerEvents={'none'}>\n <TextComponent colorVariant={'secondary'} colorTone={colorTone}>\n {date.getDate()}\n </TextComponent>\n </Selected>\n </Cell>\n );\n })}\n </Week>\n );\n};\n\nexport default React.memo(MonthWeek);\n"],"file":"MonthWeek.js"}
@@ -1 +1 @@
1
- export { default as Calendar, CalendarProps, SelectionType, DateRange, } from './Calendar';
1
+ export { default as Calendar, CalendarProps, SelectionType, DateRange, Value } from './Calendar';
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "DateRange", {
27
27
  return _Calendar.DateRange;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "Value", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _Calendar.Value;
34
+ }
35
+ });
30
36
 
31
37
  var _Calendar = _interopRequireWildcard(require("./Calendar"));
32
38
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/Calendar/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export {\n default as Calendar,\n CalendarProps,\n SelectionType,\n DateRange,\n} from './Calendar';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/Calendar/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export {\n default as Calendar,\n CalendarProps,\n SelectionType,\n DateRange,\n Value\n} from './Calendar';\n"],"file":"index.js"}
@@ -25,21 +25,6 @@ const TitleContainer = _native.default.View`
25
25
  }) => theme.color.secondary.xlight};
26
26
  `;
27
27
  exports.TitleContainer = TitleContainer;
28
-
29
- const surfaceBorderRight = ({
30
- isRright,
31
- theme
32
- }) => !isWeb && isRright && (0, _native.css)`
33
- border-top-right-radius: ${theme === null || theme === void 0 ? void 0 : theme.borderRadius.deca};
34
- `;
35
-
36
- const surfaceBorderLeft = ({
37
- isLeft,
38
- theme
39
- }) => !isWeb && isLeft && (0, _native.css)`
40
- border-top-left-radius: ${theme === null || theme === void 0 ? void 0 : theme.borderRadius.deca};
41
- `;
42
-
43
28
  const Control = (0, _native.default)(_PressableSurface.PressableSurface)(props => {
44
29
  var _props$theme, _props$theme2, _props$theme3;
45
30
 
@@ -48,8 +33,6 @@ const Control = (0, _native.default)(_PressableSurface.PressableSurface)(props =
48
33
  padding: ${(_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : _props$theme.spacing.centi};
49
34
  border-radius: ${(_props$theme2 = props.theme) === null || _props$theme2 === void 0 ? void 0 : _props$theme2.borderRadius.mili};
50
35
  margin: ${(_props$theme3 = props.theme) === null || _props$theme3 === void 0 ? void 0 : _props$theme3.spacing.mili};
51
- ${surfaceBorderRight(props)}
52
- ${surfaceBorderLeft(props)}
53
36
  `;
54
37
  });
55
38
  exports.Control = Control;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/Calendar/styled.ts"],"names":["isWeb","Platform","OS","TitleContainer","styled","View","theme","color","secondary","xlight","surfaceBorderRight","isRright","borderRadius","deca","surfaceBorderLeft","isLeft","Control","PressableSurface","props","align","spacing","centi","mili","getCapitalizedTextComponent","component","Content","miscellaneous","surfaceColor","Week","Selected","selected","primary","medium","Cell","highlighted","isLineEnd","isLineStart","isRangeStart","isRangeEnd","borderRadiusSize","rightBorderRadius","leftBorderRadius","borderEffect","backgroundColor","light"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;;;;;AAGA,MAAMA,KAAK,GAAGC,sBAASC,EAAT,KAAgB,KAA9B;AAOO,MAAMC,cAAc,GAAGC,gBAAOC,IAA0B;AAC/D;AACA;AACA;AACA,sBAAsB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,KAAN,CAAYC,SAAZ,CAAsBC,MAAO;AA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AAuB0C,YAAa;AACpC,gCAAgCD,gBAAiB;AACjD,mCAAmCA,gBAAiB;AACpD,iCAAiCD,iBAAkB;AACnD,oCAAoCA,iBAAkB;AACtD,0BAA0BG,eAAgB;AAC1C,KAnBI;AAoBD,CAvDiB,CAAb","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { FC } from 'react';\nimport { Platform, PressableProps, ViewProps } from 'react-native';\nimport { StyleProps } from '../../../types/defaults';\nimport { PressableSurface } from '../../atoms/PressableSurface';\nimport { TextProps } from '../../atoms/Text';\n\nconst isWeb = Platform.OS === 'web';\n\ninterface ButtonBorders {\n isLeft?: boolean;\n isRright?: boolean;\n}\n\nexport const TitleContainer = styled.View<Partial<StyleProps>>`\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n background-color: ${({ theme }) => theme.color.secondary.xlight};\n`;\n\nconst surfaceBorderRight = ({\n isRright,\n theme,\n}: ButtonBorders & Partial<StyleProps>) =>\n !isWeb &&\n isRright &&\n css`\n border-top-right-radius: ${theme?.borderRadius.deca};\n `;\n\nconst surfaceBorderLeft = ({\n isLeft,\n theme,\n}: ButtonBorders & Partial<StyleProps>) =>\n !isWeb &&\n isLeft &&\n css`\n border-top-left-radius: ${theme?.borderRadius.deca};\n `;\n\nexport const Control = styled(PressableSurface)(\n (\n props: Partial<StyleProps> & ButtonBorders & { align: 'start' | 'end' }\n ) => css`\n align-items: flex-${props.align};\n padding: ${props.theme?.spacing.centi};\n border-radius: ${props.theme?.borderRadius.mili};\n margin: ${props.theme?.spacing.mili};\n ${surfaceBorderRight(props)}\n ${surfaceBorderLeft(props)}\n `\n);\n\nexport const getCapitalizedTextComponent = (component: FC<TextProps>) => {\n return styled(component)`\n text-transform: capitalize;\n `;\n};\n\nexport const Content = styled.View<ViewProps & Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.deca};\n background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};\n`;\n\nexport const Week = styled.View<Partial<StyleProps>>`\n flex-direction: row;\n`;\n\nexport const Selected = styled.View<\n Partial<StyleProps> & { selected: boolean }\n>`\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: ${({ theme, selected }) =>\n selected ? theme.color.primary.medium : 'transparent'};\n border-radius: ${({ theme }) => theme.borderRadius.mili};\n width: 100%;\n height: 100%;\n`;\n\nexport const Cell = styled(PressableSurface)<\n PressableProps &\n Partial<StyleProps> & {\n selected: boolean;\n highlighted: boolean;\n isLineEnd: boolean;\n isLineStart: boolean;\n isRangeStart: boolean;\n isRangeEnd: boolean;\n }\n>(\n ({\n theme,\n selected,\n highlighted,\n isLineEnd,\n isLineStart,\n isRangeStart,\n isRangeEnd,\n }) => {\n const borderRadiusSize = theme.borderRadius.mili;\n\n const { rightBorderRadius, leftBorderRadius } = {\n rightBorderRadius:\n (selected && !isRangeStart) || isLineEnd ? borderRadiusSize : 0,\n leftBorderRadius:\n (selected && !isRangeEnd) || isLineStart ? borderRadiusSize : 0,\n };\n\n const borderEffect = highlighted ? 0 : borderRadiusSize;\n\n const backgroundColor = highlighted\n ? theme.color.primary.light\n : 'transparent';\n\n return css`\n ${isWeb\n ? css`\n width: 32px;\n height: 32px;\n `\n : css`\n aspect-ratio: 1;\n flex: 1;\n `}\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: ${borderEffect};\n border-top-left-radius: ${leftBorderRadius};\n border-bottom-left-radius: ${leftBorderRadius};\n border-top-right-radius: ${rightBorderRadius};\n border-bottom-right-radius: ${rightBorderRadius};\n background-color: ${backgroundColor};\n `;\n }\n);\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/Calendar/styled.ts"],"names":["isWeb","Platform","OS","TitleContainer","styled","View","theme","color","secondary","xlight","Control","PressableSurface","props","align","spacing","centi","borderRadius","mili","getCapitalizedTextComponent","component","Content","deca","miscellaneous","surfaceColor","Week","Selected","selected","primary","medium","Cell","highlighted","isLineEnd","isLineStart","isRangeStart","isRangeEnd","borderRadiusSize","rightBorderRadius","leftBorderRadius","borderE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Z,CAAoBC,MAAvB,GAAgC,aAAc;AAC1D,mBAAmB,CAAC;AAAEtB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACU,YAAN,CAAmBC,IAAK;AAC1D;AACA;AACA,CAXO;;AAaA,MAAMY,IAAI,GAAG,qBAAOlB,kCAAP,EAWlB,CAAC;AACCL,EAAAA,KADD;AAECoB,EAAAA,QAFD;AAGCI,EAAAA,WAHD;AAICC,EAAAA,SAJD;AAKCC,EAAAA,WALD;AAMCC,EAAAA,YAND;AAOCC,EAAAA;AAPD,CAAD,KAQM;AACJ,QAAMC,gBAAgB,GAAG7B,KAAK,CAACU,YAAN,CAAmBC,IAA5C;AAEA,QAAM;AAAEmB,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAA0C;AAC9CD,IAAAA,iBAAiB,EACdV,QAAQ,IAAI,CAACO,YAAd,IAA+BF,SAA/B,GAA2CI,gBAA3C,GAA8D,CAFlB;AAG9CE,IAAAA,gBAAgB,EACbX,QAAQ,IAAI,CAACQ,UAAd,IAA6BF,WAA7B,GAA2CG,gBAA3C,GAA8D;AAJlB,GAAhD;AAOA,QAAMG,YAAY,GAAGR,WAAW,GAAG,CAAH,GAAOK,gBAAvC;AAEA,QAAMI,eAAe,GAAGT,WAAW,GAC/BxB,KAAK,CAACC,KAAN,CAAYoB,OAAZ,CAAoBa,KADW,GAE/B,aAFJ;AAIA,SAAO,gBAAI;AACf,QAAQxC,KAAK,GACH,gBAAI;AACd;AACA;AACA,WAJa,GAKH,gBAAI;AACd;AACA;AACA,WAAY;AACZ;AACA;AACA;AACA,uBAAuBsC,YAAa;AACpC,gCAAgCD,gBAAiB;AACjD,mCAAmCA,gBAAiB;AACpD,iCAAiCD,iBAAkB;AACnD,oCAAoCA,iBAAkB;AACtD,0BAA0BG,eAAgB;AAC1C,KAnBI;AAoBD,CAvDiB,CAAb","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { FC } from 'react';\nimport { Platform, PressableProps, ViewProps } from 'react-native';\nimport { StyleProps } from '../../../types/defaults';\nimport { PressableSurface } from '../../atoms/PressableSurface';\nimport { TextProps } from '../../atoms/Text';\n\nconst isWeb = Platform.OS === 'web';\n\ninterface ButtonBorders {\n isLeft?: boolean;\n isRright?: boolean;\n}\n\nexport const TitleContainer = styled.View<Partial<StyleProps>>`\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n background-color: ${({ theme }) => theme.color.secondary.xlight};\n`;\n\nexport const Control = styled(PressableSurface)(\n (\n props: Partial<StyleProps> & ButtonBorders & { align: 'start' | 'end' }\n ) => css`\n align-items: flex-${props.align};\n padding: ${props.theme?.spacing.centi};\n border-radius: ${props.theme?.borderRadius.mili};\n margin: ${props.theme?.spacing.mili};\n `\n);\n\nexport const getCapitalizedTextComponent = (component: FC<TextProps>) => {\n return styled(component)`\n text-transform: capitalize;\n `;\n};\n\nexport const Content = styled.View<ViewProps & Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.deca};\n background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};\n`;\n\nexport const Week = styled.View<Partial<StyleProps>>`\n flex-direction: row;\n`;\n\nexport const Selected = styled.View<\n Partial<StyleProps> & { selected: boolean }\n>`\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: ${({ theme, selected }) =>\n selected ? theme.color.primary.medium : 'transparent'};\n border-radius: ${({ theme }) => theme.borderRadius.mili};\n width: 100%;\n height: 100%;\n`;\n\nexport const Cell = styled(PressableSurface)<\n PressableProps &\n Partial<StyleProps> & {\n selected: boolean;\n highlighted: boolean;\n isLineEnd: boolean;\n isLineStart: boolean;\n isRangeStart: boolean;\n isRangeEnd: boolean;\n }\n>(\n ({\n theme,\n selected,\n highlighted,\n isLineEnd,\n isLineStart,\n isRangeStart,\n isRangeEnd,\n }) => {\n const borderRadiusSize = theme.borderRadius.mili;\n\n const { rightBorderRadius, leftBorderRadius } = {\n rightBorderRadius:\n (selected && !isRangeStart) || isLineEnd ? borderRadiusSize : 0,\n leftBorderRadius:\n (selected && !isRangeEnd) || isLineStart ? borderRadiusSize : 0,\n };\n\n const borderEffect = highlighted ? 0 : borderRadiusSize;\n\n const backgroundColor = highlighted\n ? theme.color.primary.light\n : 'transparent';\n\n return css`\n ${isWeb\n ? css`\n width: 32px;\n height: 32px;\n `\n : css`\n aspect-ratio: 1;\n flex: 1;\n `}\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: ${borderEffect};\n border-top-left-radius: ${leftBorderRadius};\n border-bottom-left-radius: ${leftBorderRadius};\n border-top-right-radius: ${rightBorderRadius};\n border-bottom-right-radius: ${rightBorderRadius};\n background-color: ${backgroundColor};\n `;\n }\n);\n"],"file":"styled.js"}
@@ -1,18 +1,19 @@
1
1
  import * as React from 'react';
2
- import { ModalBaseProps } from 'react-native';
3
2
  import { InputContainerProps } from '../../atoms/Input';
4
3
  import { TextProps } from '../../atoms/Text';
5
4
  import { CalendarProps, SelectionType } from '../Calendar';
6
- import { DatePickerModalProps } from './Modal';
7
- export interface DatePickerProps<T extends SelectionType> extends InputContainerProps, DatePickerModalProps<T>, Omit<CalendarProps<T>, 'style'> {
5
+ export interface DatePickerProps<T extends SelectionType> extends InputContainerProps, Omit<CalendarProps<T>, 'style'> {
8
6
  controlComponent?: (onPress: () => void, displayValue?: string) => JSX.Element;
9
7
  TextComponent?: React.FC<TextProps>;
10
- animationType?: ModalBaseProps['animationType'];
8
+ CalendarComponent: React.FC<CalendarProps<T>>;
11
9
  placeholder?: string;
12
10
  onFocus?: () => void | never;
13
11
  onBlur?: () => void | never;
14
12
  format?: string;
15
13
  closeOnPick?: boolean;
14
+ renderCalendar: (calendar: React.ReactElement, blur?: () => void) => JSX.Element | null;
15
+ requestShowCalendar: () => void;
16
+ requestCloseCalendar: () => void;
16
17
  }
17
- declare function DatePicker<T extends SelectionType>({ month, year, onChange, value, type, format, placeholder, onFocus, onBlur, disabled, controlComponent, hintComponent, hint, variant, TextComponent, CalendarComponent, bottomOffset, rightComponent, animationType, style, locale, closeOnPick, ...rest }: DatePickerProps<T>): JSX.Element;
18
+ declare function DatePicker<T extends SelectionType>({ month, year, onChange, value, type, format, placeholder, onFocus, onBlur, disabled, controlComponent, hintComponent, hint, variant, TextComponent, CalendarComponent, rightComponent, style, locale, closeOnPick, renderCalendar, requestShowCalendar, requestCloseCalendar, ...rest }: DatePickerProps<T>): JSX.Element;
18
19
  export default DatePicker;
@@ -13,12 +13,10 @@ var _Input = require("../../atoms/Input");
13
13
 
14
14
  var _Text = require("../../atoms/Text");
15
15
 
16
- var _Modal = require("./Modal");
16
+ var _HintInputContainer = require("../HintInputContainer");
17
17
 
18
18
  var _styled = require("./styled");
19
19
 
20
- var _HintInputContainer = require("../HintInputContainer");
21
-
22
20
  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); }
23
21
 
24
22
  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; }
@@ -42,12 +40,13 @@ function DatePicker({
42
40
  variant,
43
41
  TextComponent = _Text.Text,
44
42
  CalendarComponent,
45
- bottomOffset,
46
43
  rightComponent,
47
- animationType = 'fade',
48
44
  style,
49
45
  locale,
50
46
  closeOnPick = false,
47
+ renderCalendar,
48
+ requestShowCalendar,
49
+ requestCloseCalendar,
51
50
  ...rest
52
51
  }) {
53
52
  const {
@@ -55,15 +54,10 @@ function DatePicker({
55
54
  handleBlur,
56
55
  handleFocus
57
56
  } = (0, _Input.useInputFocus)(onFocus, onBlur, !disabled);
58
- const [modalVisible, setModalVisible] = React.useState(false);
59
- const handlePressInput = React.useCallback(() => {
60
- setModalVisible(true);
57
+ const handleShowCalendar = React.useCallback(() => {
58
+ requestShowCalendar();
61
59
  handleFocus();
62
- }, [handleFocus, setModalVisible]);
63
- const handleCloseModal = React.useCallback(() => {
64
- setModalVisible(false);
65
- handleBlur();
66
- }, [handleBlur, setModalVisible]);
60
+ }, [handleFocus, requestShowCalendar]);
67
61
 
68
62
  const getDisplayValue = () => {
69
63
  if (!value) return placeholder;
@@ -90,7 +84,7 @@ function DatePicker({
90
84
  const StyledText = (0, _styled.getStyledTextComponent)(TextComponent);
91
85
  (0, React.useEffect)(() => {
92
86
  if (closeOnPick && value && type === 'day') {
93
- setTimeout(handleCloseModal, 200);
87
+ setTimeout(requestCloseCalendar, 200);
94
88
  }
95
89
 
96
90
  if (closeOnPick && value && type === 'range') {
@@ -98,13 +92,22 @@ function DatePicker({
98
92
  lowest,
99
93
  highest
100
94
  } = value;
101
- lowest && highest && setTimeout(handleCloseModal, 200);
95
+ lowest && highest && setTimeout(requestCloseCalendar, 200);
102
96
  }
103
- }, [value, closeOnPick, type, handleCloseModal]);
104
- return React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue()) : React.createElement(_HintInputContainer.HintInputContainer, _extends({
97
+ }, [value, closeOnPick, type, requestCloseCalendar]);
98
+ const calendar = React.createElement(CalendarComponent, {
99
+ pointerEvents: 'box-none',
100
+ type: type,
101
+ value: value,
102
+ month: month,
103
+ year: year,
104
+ onChange: onChange,
105
+ locale: locale
106
+ });
107
+ return React.createElement(React.Fragment, null, controlComponent ? controlComponent(handleShowCalendar, getDisplayValue()) : React.createElement(_HintInputContainer.HintInputContainer, _extends({
105
108
  focused: focused,
106
109
  viewStyle: style,
107
- onPress: handlePressInput,
110
+ onPress: handleShowCalendar,
108
111
  disabled: disabled,
109
112
  hintComponent: hintComponent,
110
113
  LabelComponent: TextComponent,
@@ -118,20 +121,7 @@ function DatePicker({
118
121
  }, rest), React.createElement(StyledText, {
119
122
  fontWeight: "bold",
120
123
  disabled: disabled
121
- }, getDisplayValue() || ' ')), React.createElement(_Modal.Modal, {
122
- CalendarComponent: CalendarComponent,
123
- bottomOffset: bottomOffset,
124
- visible: modalVisible,
125
- onRequestClose: handleCloseModal,
126
- animated: true,
127
- animationType: animationType,
128
- month: month,
129
- year: year,
130
- onChange: onChange,
131
- value: value,
132
- type: type,
133
- locale: locale
134
- }));
124
+ }, getDisplayValue() || ' ')), renderCalendar(calendar, handleBlur));
135
125
  }
136
126
 
137
127
  var _default = DatePicker;
@@ -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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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, { 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"}
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","rightComponent","style","locale","closeOnPick","renderCalendar","requestShowCalendar","requestCloseCalendar","rest","focused","handleBlur","handleFocus","handleShowCalendar","React","useCallback","getDisplayValue","lowest","highest","StyledText","setTimeout","calendar"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;AAmBA,SAASA,UAAT,CAA6C;AAE3CC,EAAAA,KAF2C;AAG3CC,EAAAA,IAH2C;AAI3CC,EAAAA,QAJ2C;AAK3CC,EAAAA,KAL2C;AAM3CC,EAAAA,IAN2C;AAO3CC,EAAAA,MAAM,GAAG,YAPkC;AAQ3CC,EAAAA,WAR2C;AAS3CC,EAAAA,OAT2C;AAU3CC,EAAAA,MAV2C;AAW3CC,EAAAA,QAX2C;AAY3CC,EAAAA,gBAZ2C;AAa3CC,EAAAA,aAb2C;AAc3CC,EAAAA,IAd2C;AAe3CC,EAAAA,OAf2C;AAgB3CC,EAAAA,aAAa,GAAGC,UAhB2B;AAiB3CC,EAAAA,iBAjB2C;AAkB3CC,EAAAA,cAlB2C;AAmB3CC,EAAAA,KAnB2C;AAoB3CC,EAAAA,MApB2C;AAqB3CC,EAAAA,WAAW,GAAG,KArB6B;AAsB3CC,EAAAA,cAtB2C;AAuB3CC,EAAAA,mBAvB2C;AAwB3CC,EAAAA,oBAxB2C;AAyB3C,KAAGC;AAzBwC,CAA7C,EA0BoC;AAElC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Date } from 'date-fns';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { InputContainerProps, useInputFocus } from '../../atoms/Input';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { CalendarProps, DateRange, SelectionType } from '../Calendar';\nimport { HintInputContainer } from '../HintInputContainer';\nimport { CalendarIcon, getStyledTextComponent } from './styled';\n\nexport interface DatePickerProps<T extends SelectionType> extends InputContainerProps, Omit<CalendarProps<T>, 'style'> {\n controlComponent?: (\n onPress: () => void,\n displayValue?: string\n ) => JSX.Element;\n TextComponent?: React.FC<TextProps>;\n CalendarComponent: React.FC<CalendarProps<T>>\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n format?: string;\n closeOnPick?: boolean;\n renderCalendar: (calendar: React.ReactElement, blur?: () => void) => JSX.Element|null\n requestShowCalendar: () => void\n requestCloseCalendar: () => void\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 placeholder,\n onFocus,\n onBlur,\n disabled,\n controlComponent,\n hintComponent,\n hint,\n variant,\n TextComponent = Text,\n CalendarComponent,\n rightComponent,\n style,\n locale,\n closeOnPick = false,\n renderCalendar,\n requestShowCalendar,\n requestCloseCalendar,\n ...rest\n}: DatePickerProps<T>): JSX.Element {\n \n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const handleShowCalendar = React.useCallback(() => {\n requestShowCalendar()\n handleFocus();\n }, [handleFocus, requestShowCalendar]);\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(requestCloseCalendar, 200);\n }\n if (closeOnPick && value && type === 'range') {\n const { lowest, highest } = value as DateRange;\n lowest && highest && setTimeout(requestCloseCalendar, 200);\n }\n }, [value, closeOnPick, type, requestCloseCalendar]);\n\n const calendar = (\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 )\n\n return (\n <>\n {controlComponent ? (\n controlComponent(handleShowCalendar, getDisplayValue())\n ) : (\n <HintInputContainer\n focused={focused}\n viewStyle={style}\n onPress={handleShowCalendar}\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 {renderCalendar(calendar, handleBlur)}\n </>\n );\n}\n\nexport default DatePicker;\n"],"file":"DatePicker.js"}
@@ -1,20 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { InputContainerProps } from '../../atoms/Input';
3
3
  import { TextProps } from '../../atoms/Text';
4
- export declare const Backdrop: import("@emotion/native").StyledComponent<import("../../atoms/PressableSurface").PressableSurfaceProps & {
5
- children?: import("react").ReactNode;
6
- } & {
7
- theme?: import("@emotion/react").Theme | undefined;
8
- as?: import("react").ElementType<any> | undefined;
9
- } & Partial<import("../../../types/defaults").ThemeProviderProps>, {}, {}>;
10
- export declare const ModalContent: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
11
- theme?: import("@emotion/react").Theme | undefined;
12
- as?: import("react").ElementType<any> | undefined;
13
- } & {
14
- offset: number;
15
- } & Partial<import("../../../types/defaults").ThemeProviderProps>, {}, {
16
- ref?: import("react").Ref<import("react-native").View> | undefined;
17
- }>;
18
4
  export declare const getStyledTextComponent: (component: FC<TextProps>) => import("@emotion/native").StyledComponent<TextProps & {
19
5
  children?: import("react").ReactNode;
20
6
  } & {
@@ -3,63 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CalendarIcon = exports.getStyledTextComponent = exports.ModalContent = exports.Backdrop = void 0;
6
+ exports.CalendarIcon = exports.getStyledTextComponent = void 0;
7
7
 
8
8
  var _native = _interopRequireWildcard(require("@emotion/native"));
9
9
 
10
- var _reactNative = require("react-native");
11
-
12
- var _definitions = require("../../../styles/definitions");
13
-
14
- var _utils = require("../../../utils");
15
-
16
10
  var _Icon = require("../../atoms/Icon");
17
11
 
18
12
  var _Input = require("../../atoms/Input");
19
13
 
20
- var _PressableSurface = require("../../atoms/PressableSurface");
21
-
22
14
  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); }
23
15
 
24
16
  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; }
25
17
 
26
- const isWeb = _reactNative.Platform.OS === 'web';
27
- const Backdrop = (0, _native.default)(_PressableSurface.PressableSurface)`
28
- ${({
29
- theme
30
- }) => isWeb ? (0, _native.css)`
31
- justify-content: center;
32
- align-items: center;
33
- background-color: ${(0, _definitions.hex2rgba)(theme.miscellaneous.overlay, 0.5)};
34
- height: 100vh;
35
- ` : (0, _native.css)`
36
- justify-content: flex-end;
37
- background-color: ${(0, _definitions.hex2rgba)(theme.miscellaneous.overlay, 0.5)};
38
- height: 100%;
39
- `}
40
- `;
41
- exports.Backdrop = Backdrop;
42
- const ModalContent = _native.default.View`
43
- background-color: transparent;
44
- padding-bottom: ${({
45
- offset
46
- }) => `${(0, _utils.RFValue)(offset)}px`};
47
- ${({
48
- theme: {
49
- borderRadius
50
- }
51
- }) => (0, _native.css)`
52
- ${isWeb ? `
53
- border-radius: ${borderRadius.micro};
54
- ` : `
55
- border-top-left-radius: ${borderRadius.deca};
56
- border-top-right-radius: ${borderRadius.deca};
57
- `}
58
- `}
59
- overflow: hidden;
60
- `;
61
- exports.ModalContent = ModalContent;
62
-
63
18
  const getStyledTextComponent = component => {
64
19
  return (0, _native.default)(component)(props => {
65
20
  var _props$theme;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DatePicker/styled.ts"],"names":["isWeb","Platform","OS","Backdrop","PressableSurface","theme","miscellaneous","overlay","ModalContent","styled","View","offset","borderRadius","micro","deca","getStyledTextComponent","component","props","typography","h5","lineHeight","CalendarIcon","Icon","spacing","centi","color","secondary","medium"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAGA,MAAMA,KAAK,GAAGC,sBAASC,EAAT,KAAgB,KAA9B;AAEO,MAAMC,QAAQ,GAAG,qBAAOC,kCAAP,CAA8C;AACtE,IAAI,CAAC;AAAEC,EAAAA;AAAF,CAAD,KACAL,KAAK,GACD,gBAAI;AACZ;AACA;AACA,8BAA8B,2BAASK,KAAK,CAACC,aAAN,CAAoBC,OAA7B,EAAsC,GAAtC,CAA2C;AACzE;AACA,SANS,GAOD,gBAAI;AACZ;AACA,8BAA8B,2BAASF,KAAK,CAACC,aAAN,CAAoBC,OAA7B,EAAsC,GAAtC,CAA2C;AACzE;AACA,SAAU;AACV,CAdO;;AAgBA,MAAMC,YAAY,GAAGC,gBAAOC,IAEjC;AACF;AACA,oBAAoB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAiB,GAAE,oBAAQA,MAAR,CAAgB,IAAI;AAC3D,IAAI,CAAC;AAAEN,EAAAA,KAAK,EAAE;AAAEO,IAAAA;AAAF;AAAT,CAAD,KAAiC,gBAAI;AACzC,MAAMZ,KAAK,GACF;AACT,uBAAuBY,YAAY,CAACC,KAAM;AAC1C,KAHW,GAIF;AACT,gCAAgCD,YAAY,CAACE,IAAK;AAClD,iCAAiCF,YAAY,CAACE,IAAK;AACnD,KAAM;AACN,GAAI;AACJ;AACA,CAhBO;;;AAkBA,MAAMC,sBAAsB,GAAIC,SAAD,IAA8B;AAClE,SAAO,qBAAOA,SAAP,EACJC,KAAD;AAAA;;AAAA,WAA+D,gBAAI;AACvE,qBADsE,gBACjDA,KAAK,CAACZ,KAD2C,iDACjD,aAAaa,UAAb,CAAwBC,EAAxB,CAA2BC,UAAW;AAC3D,QAAQ,gCAAoBH,KAApB,CAA2B;AACnC,KAHI;AAAA,GADK,CAAP;AAMD,CAPM;;;AASA,MAAMI,YAAY,GAAG,qBAAOC,UAAP,CAAkC;AAC9D,aAAa,CAAC;AAAEjB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACkB,OAAN,CAAcC,KAAM;AAChD,WAAW,CAAC;AAAEnB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACoB,KAAN,CAAYC,SAAZ,CAAsBC,MAAO;AACvD,CAHO","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { FC } from 'react';\nimport { Platform } from 'react-native';\nimport { hex2rgba } from '../../../styles/definitions';\nimport { StyleProps } from '../../../types/defaults';\nimport { RFValue } from '../../../utils';\nimport { Icon } from '../../atoms/Icon';\nimport { disabledInputStyles, InputContainerProps } from '../../atoms/Input';\nimport { PressableSurface } from '../../atoms/PressableSurface';\nimport { TextProps } from '../../atoms/Text';\n\nconst isWeb = Platform.OS === 'web';\n\nexport const Backdrop = styled(PressableSurface)<Partial<StyleProps>>`\n ${({ theme }) =>\n isWeb\n ? css`\n justify-content: center;\n align-items: center;\n background-color: ${hex2rgba(theme.miscellaneous.overlay, 0.5)};\n height: 100vh;\n `\n : css`\n justify-content: flex-end;\n background-color: ${hex2rgba(theme.miscellaneous.overlay, 0.5)};\n height: 100%;\n `}\n`;\n\nexport const ModalContent = styled.View<\n { offset: number } & Partial<StyleProps>\n>`\n background-color: transparent;\n padding-bottom: ${({ offset }) => `${RFValue(offset)}px`};\n ${({ theme: { borderRadius } }) => css`\n ${isWeb\n ? `\n border-radius: ${borderRadius.micro};\n `\n : `\n border-top-left-radius: ${borderRadius.deca};\n border-top-right-radius: ${borderRadius.deca};\n `}\n `}\n overflow: hidden;\n`;\n\nexport const getStyledTextComponent = (component: FC<TextProps>) => {\n return styled(component)(\n (props: Partial<InputContainerProps> & Partial<StyleProps>) => css`\n line-height: ${props.theme?.typography.h5.lineHeight};\n ${disabledInputStyles(props)}\n `\n );\n};\n\nexport const CalendarIcon = styled(Icon)<Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.centi};\n color: ${({ theme }) => theme.color.secondary.medium};\n`;\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DatePicker/styled.ts"],"names":["getStyledTextComponent","component","props","theme","typography","h5","lineHeight","CalendarIcon","Icon","spacing","centi","color","secondary","medium"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;;;;;AAGO,MAAMA,sBAAsB,GAAIC,SAAD,IAA8B;AAClE,SAAO,qBAAOA,SAAP,EACJC,KAAD;AAAA;;AAAA,WAA+D,gBAAI;AACvE,qBADsE,gBACjDA,KAAK,CAACC,KAD2C,iDACjD,aAAaC,UAAb,CAAwBC,EAAxB,CAA2BC,UAAW;AAC3D,QAAQ,gCAAoBJ,KAApB,CAA2B;AACnC,KAHI;AAAA,GADK,CAAP;AAMD,CAPM;;;AASA,MAAMK,YAAY,GAAG,qBAAOC,UAAP,CAAkC;AAC9D,aAAa,CAAC;AAAEL,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACM,OAAN,CAAcC,KAAM;AAChD,WAAW,CAAC;AAAEP,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACQ,KAAN,CAAYC,SAAZ,CAAsBC,MAAO;AACvD,CAHO","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { FC } from 'react';\nimport { StyleProps } from '../../../types/defaults';\nimport { Icon } from '../../atoms/Icon';\nimport { disabledInputStyles, InputContainerProps } from '../../atoms/Input';\nimport { TextProps } from '../../atoms/Text';\n\nexport const getStyledTextComponent = (component: FC<TextProps>) => {\n return styled(component)(\n (props: Partial<InputContainerProps> & Partial<StyleProps>) => css`\n line-height: ${props.theme?.typography.h5.lineHeight};\n ${disabledInputStyles(props)}\n `\n );\n};\n\nexport const CalendarIcon = styled(Icon)<Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.centi};\n color: ${({ theme }) => theme.color.secondary.medium};\n`;\n"],"file":"styled.js"}
@@ -1,16 +1,17 @@
1
1
  import * as React from 'react';
2
- import { ModalBaseProps } from 'react-native';
3
2
  import { InputContainerProps } from '../../atoms/Input';
4
3
  import { TextProps } from '../../atoms/Text';
5
4
  import { DateTimeSelectorProps } from '../DateTimeSelector';
6
- import { DateTimePickerModalProps } from './Modal';
7
- export interface DateTimePickerProps extends InputContainerProps, DateTimePickerModalProps, Omit<DateTimeSelectorProps, 'style'> {
5
+ export interface DateTimePickerProps extends InputContainerProps, Omit<DateTimeSelectorProps, 'style'> {
8
6
  controlComponent?: (onPress: () => void, displayValue?: string) => JSX.Element;
9
7
  TextComponent?: React.FC<TextProps>;
10
- animationType?: ModalBaseProps['animationType'];
8
+ DateTimeSelectorComponent: React.FC<DateTimeSelectorProps>;
11
9
  placeholder?: string;
12
10
  onFocus?: () => void | never;
13
11
  onBlur?: () => void | never;
12
+ renderSelector: (selector: React.ReactElement, blur?: () => void) => JSX.Element | null;
13
+ requestShowSelector: () => void;
14
+ requestCloseSelector: () => void;
14
15
  }
15
16
  declare const DateTimePicker: React.FC<DateTimePickerProps>;
16
17
  export default DateTimePicker;
@@ -15,10 +15,12 @@ var _Text = require("../../atoms/Text");
15
15
 
16
16
  var _styled = require("../DatePicker/styled");
17
17
 
18
- var _Modal = require("./Modal");
18
+ var _DateTimeSelector = require("../DateTimeSelector");
19
19
 
20
20
  var _HintInputContainer = require("../HintInputContainer");
21
21
 
22
+ var _styled2 = require("./styled");
23
+
22
24
  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); }
23
25
 
24
26
  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; }
@@ -54,11 +56,12 @@ const DateTimePicker = ({
54
56
  hint,
55
57
  variant = 'default',
56
58
  TextComponent = _Text.Text,
57
- DateTimeSelectorComponent,
58
- bottomOffset,
59
+ DateTimeSelectorComponent = _DateTimeSelector.DateTimeSelector,
59
60
  rightComponent,
60
- animationType = 'fade',
61
61
  style,
62
+ renderSelector,
63
+ requestShowSelector,
64
+ requestCloseSelector,
62
65
  ...rest
63
66
  }) => {
64
67
  const {
@@ -66,47 +69,23 @@ const DateTimePicker = ({
66
69
  handleBlur,
67
70
  handleFocus
68
71
  } = (0, _Input.useInputFocus)(onFocus, onBlur, !disabled);
69
- const [modalVisible, setModalVisible] = React.useState(false);
70
72
 
71
- const handlePressInput = () => {
72
- setModalVisible(true);
73
+ const handleShowSelector = () => {
74
+ requestShowSelector();
73
75
  handleFocus();
74
76
  };
75
77
 
76
- const handleCloseModal = () => {
77
- setModalVisible(false);
78
- handleBlur();
78
+ const handleChoosing = value => {
79
+ onChange === null || onChange === void 0 ? void 0 : onChange(value);
80
+ requestCloseSelector();
79
81
  };
80
82
 
81
83
  const StyledText = (0, _styled.getStyledTextComponent)(TextComponent);
82
84
  const displayValue = (value ? (0, _dateFns.format)(value, format, {
83
85
  locale: locale
84
86
  }) : placeholder) || ' ';
85
- return React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, displayValue) : React.createElement(_HintInputContainer.HintInputContainer, _extends({
86
- focused: focused,
87
- viewStyle: style,
88
- onPress: handlePressInput,
89
- disabled: disabled,
90
- LabelComponent: TextComponent,
91
- variant: variant,
92
- hint: hint,
93
- hintComponent: hintComponent,
94
- rightComponent: React.createElement(React.Fragment, null, React.createElement(_styled.CalendarIcon, {
95
- name: "calendar-sharp",
96
- type: "ionicon",
97
- size: "centi"
98
- }), rightComponent)
99
- }, rest), React.createElement(StyledText, {
100
- fontWeight: "bold",
101
- disabled: disabled
102
- }, displayValue)), React.createElement(_Modal.Modal, {
103
- DateTimeSelectorComponent: DateTimeSelectorComponent,
104
- bottomOffset: bottomOffset,
105
- visible: modalVisible,
106
- onRequestClose: handleCloseModal,
107
- animated: true,
108
- animationType: animationType,
109
- onChange: onChange,
87
+ const StyledDateTimeSelector = (0, _styled2.getStyledDateTimeSelector)(DateTimeSelectorComponent);
88
+ const dateTimeSelector = React.createElement(StyledDateTimeSelector, {
110
89
  value: value,
111
90
  mode: mode,
112
91
  format: format,
@@ -124,8 +103,27 @@ const DateTimePicker = ({
124
103
  monthLabel: monthLabel,
125
104
  yearLabel: yearLabel,
126
105
  hourLabel: hourLabel,
127
- minuteLabel: minuteLabel
128
- }));
106
+ minuteLabel: minuteLabel,
107
+ onChange: handleChoosing
108
+ });
109
+ return React.createElement(React.Fragment, null, controlComponent ? controlComponent(handleShowSelector, displayValue) : React.createElement(_HintInputContainer.HintInputContainer, _extends({
110
+ focused: focused,
111
+ viewStyle: style,
112
+ onPress: handleShowSelector,
113
+ disabled: disabled,
114
+ LabelComponent: TextComponent,
115
+ variant: variant,
116
+ hint: hint,
117
+ hintComponent: hintComponent,
118
+ rightComponent: React.createElement(React.Fragment, null, React.createElement(_styled.CalendarIcon, {
119
+ name: "calendar-sharp",
120
+ type: "ionicon",
121
+ size: "centi"
122
+ }), rightComponent)
123
+ }, rest), React.createElement(StyledText, {
124
+ fontWeight: "bold",
125
+ disabled: disabled
126
+ }, displayValue)), renderSelector(dateTimeSelector, handleBlur));
129
127
  };
130
128
 
131
129
  var _default = DateTimePicker;
@@ -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,MAH8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,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"}
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","DateTimeSelector","rightComponent","style","renderSelector","requestShowSelector","requestCloseSelector","rest","focused","handleBlur","handleFocus","handleShowSelector","handleChoosing","StyledText","displayValue","StyledDateTimeSelector","dateTimeSelector"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;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;AAWrDC,EAAAA,cAXqD;AAYrDC,EAAAA,cAZqD;AAarDC,EAAAA,qBAbqD;AAcrDC,EAAAA,qBAdqD;AAerDC,EAAAA,QAfqD;AAgBrDC,EAAAA,UAhBqD;AAiBrDC,EAAAA,SAjBqD;AAkBrDC,EAAAA,SAlBqD;AAmBrDC,EAAAA,WAnBqD;AAoBrDC,EAAAA,WApBqD;AAqBrDC,EAAAA,OArBqD;AAsBrDC,EAAAA,MAtBqD;AAuBrD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'date-fns';\nimport * as React from 'react';\nimport { InputContainerProps, useInputFocus } from '../../atoms/Input';\nimport { Text, TextProps } from '../../atoms/Text';\nimport { CalendarIcon, getStyledTextComponent } from '../DatePicker/styled';\nimport { DateTimeSelector, DateTimeSelectorProps } from '../DateTimeSelector';\nimport { HintInputContainer } from '../HintInputContainer';\nimport { getStyledDateTimeSelector } from './styled';\n\nexport interface DateTimePickerProps extends InputContainerProps, Omit<DateTimeSelectorProps, 'style'> {\n controlComponent?: (\n onPress: () => void,\n displayValue?: string\n ) => JSX.Element;\n TextComponent?: React.FC<TextProps>;\n DateTimeSelectorComponent: React.FC<DateTimeSelectorProps>;\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n renderSelector: (selector: React.ReactElement, blur?: () => void) => JSX.Element|null\n requestShowSelector: () => void\n requestCloseSelector: () => void\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 dateModalTitle,\n timeModalTitle,\n dateConfirmButtonText,\n timeConfirmButtonText,\n dayLabel,\n monthLabel,\n yearLabel,\n hourLabel,\n minuteLabel,\n placeholder,\n onFocus,\n onBlur,\n disabled,\n controlComponent,\n hintComponent,\n hint,\n variant = 'default',\n TextComponent = Text,\n DateTimeSelectorComponent = DateTimeSelector,\n rightComponent,\n style,\n renderSelector,\n requestShowSelector,\n requestCloseSelector,\n ...rest\n}) => {\n \n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const handleShowSelector = () => {\n requestShowSelector()\n handleFocus();\n };\n\n const handleChoosing = (value: Date) => {\n onChange?.(value)\n requestCloseSelector()\n };\n\n const StyledText = getStyledTextComponent(TextComponent);\n const displayValue = (value ? formatDate(value, format, { locale: locale }) : placeholder) || ' ';\n const StyledDateTimeSelector = getStyledDateTimeSelector(DateTimeSelectorComponent)\n\n const dateTimeSelector = (\n <StyledDateTimeSelector\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 onChange={handleChoosing}\n />\n )\n\n return (\n <>\n {controlComponent ? (\n controlComponent(handleShowSelector, displayValue)\n ) : (\n <HintInputContainer\n focused={focused}\n viewStyle={style}\n onPress={handleShowSelector}\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 {renderSelector(dateTimeSelector, handleBlur)}\n </>\n );\n};\n\nexport default DateTimePicker;\n"],"file":"DateTimePicker.js"}