@tecsinapse/react-core 1.14.7 → 1.16.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 +30 -0
- package/dist/components/atoms/Avatar/Avatar.js +1 -3
- package/dist/components/atoms/Avatar/Avatar.js.map +1 -1
- package/dist/components/atoms/Avatar/helpers.js +1 -3
- package/dist/components/atoms/Avatar/helpers.js.map +1 -1
- package/dist/components/atoms/Avatar/index.js +5 -15
- package/dist/components/atoms/Avatar/index.js.map +1 -1
- package/dist/components/atoms/Avatar/styled.js +1 -3
- package/dist/components/atoms/Avatar/styled.js.map +1 -1
- package/dist/components/atoms/Badge/Badge.js +1 -3
- package/dist/components/atoms/Badge/Badge.js.map +1 -1
- package/dist/components/atoms/Badge/index.js +5 -15
- package/dist/components/atoms/Badge/index.js.map +1 -1
- package/dist/components/atoms/Badge/styled.js +1 -3
- package/dist/components/atoms/Badge/styled.js.map +1 -1
- package/dist/components/atoms/BoxContent/BoxContent.js +1 -3
- package/dist/components/atoms/BoxContent/BoxContent.js.map +1 -1
- package/dist/components/atoms/BoxContent/index.js +5 -15
- package/dist/components/atoms/BoxContent/index.js.map +1 -1
- package/dist/components/atoms/BoxContent/styled.js +2 -4
- package/dist/components/atoms/BoxContent/styled.js.map +1 -1
- package/dist/components/atoms/Button/Button.js +1 -3
- package/dist/components/atoms/Button/Button.js.map +1 -1
- package/dist/components/atoms/Button/States/BaseState.js +1 -3
- package/dist/components/atoms/Button/States/BaseState.js.map +1 -1
- package/dist/components/atoms/Button/States/Error.js +1 -3
- package/dist/components/atoms/Button/States/Error.js.map +1 -1
- package/dist/components/atoms/Button/States/Loading.js +1 -3
- package/dist/components/atoms/Button/States/Loading.js.map +1 -1
- package/dist/components/atoms/Button/States/Success.js +1 -3
- package/dist/components/atoms/Button/States/Success.js.map +1 -1
- package/dist/components/atoms/Button/States/index.js +8 -21
- package/dist/components/atoms/Button/States/index.js.map +1 -1
- package/dist/components/atoms/Button/States/styled.js +1 -3
- package/dist/components/atoms/Button/States/styled.js.map +1 -1
- package/dist/components/atoms/Button/index.js +12 -51
- package/dist/components/atoms/Button/index.js.map +1 -1
- package/dist/components/atoms/Button/styled.js +1 -3
- package/dist/components/atoms/Button/styled.js.map +1 -1
- package/dist/components/atoms/Card/Card.js +1 -3
- package/dist/components/atoms/Card/Card.js.map +1 -1
- package/dist/components/atoms/Card/Footer/Footer.js +1 -3
- package/dist/components/atoms/Card/Footer/Footer.js.map +1 -1
- package/dist/components/atoms/Card/Footer/index.js +5 -15
- package/dist/components/atoms/Card/Footer/index.js.map +1 -1
- package/dist/components/atoms/Card/Header/Header.js +1 -3
- package/dist/components/atoms/Card/Header/Header.js.map +1 -1
- package/dist/components/atoms/Card/Header/index.js +5 -15
- package/dist/components/atoms/Card/Header/index.js.map +1 -1
- package/dist/components/atoms/Card/index.js +5 -15
- package/dist/components/atoms/Card/index.js.map +1 -1
- package/dist/components/atoms/Card/styled.js +1 -3
- package/dist/components/atoms/Card/styled.js.map +1 -1
- package/dist/components/atoms/Checkbox/Checkbox.js +1 -3
- package/dist/components/atoms/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/atoms/Checkbox/index.js +5 -15
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Checkbox/styled.js +1 -3
- package/dist/components/atoms/Checkbox/styled.js.map +1 -1
- package/dist/components/atoms/Divider/Divider.js +1 -3
- package/dist/components/atoms/Divider/Divider.js.map +1 -1
- package/dist/components/atoms/Divider/index.js +5 -15
- package/dist/components/atoms/Divider/index.js.map +1 -1
- package/dist/components/atoms/Divider/styled.js +1 -3
- package/dist/components/atoms/Divider/styled.js.map +1 -1
- package/dist/components/atoms/GroupButton/GroupButton.js +7 -9
- package/dist/components/atoms/GroupButton/GroupButton.js.map +1 -1
- package/dist/components/atoms/GroupButton/GroupButtonOption.js +1 -3
- package/dist/components/atoms/GroupButton/GroupButtonOption.js.map +1 -1
- package/dist/components/atoms/GroupButton/index.js +9 -33
- package/dist/components/atoms/GroupButton/index.js.map +1 -1
- package/dist/components/atoms/GroupButton/styled.js +12 -14
- package/dist/components/atoms/GroupButton/styled.js.map +1 -1
- package/dist/components/atoms/Icon/Icon.js +1 -3
- package/dist/components/atoms/Icon/Icon.js.map +1 -1
- package/dist/components/atoms/Icon/helpers.js +1 -3
- package/dist/components/atoms/Icon/helpers.js.map +1 -1
- package/dist/components/atoms/Icon/index.js +5 -15
- package/dist/components/atoms/Icon/index.js.map +1 -1
- package/dist/components/atoms/Input/Hint.js +1 -3
- package/dist/components/atoms/Input/Hint.js.map +1 -1
- package/dist/components/atoms/Input/InputContainer/InputContainer.js +1 -3
- package/dist/components/atoms/Input/InputContainer/InputContainer.js.map +1 -1
- package/dist/components/atoms/Input/InputElement/InputElement.d.ts +2 -5
- package/dist/components/atoms/Input/InputElement/InputElement.js +5 -49
- package/dist/components/atoms/Input/InputElement/InputElement.js.map +1 -1
- package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.d.ts +17 -0
- package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.js +84 -0
- package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.js.map +1 -0
- package/dist/components/atoms/Input/PressableInputContainer/PressableInputContainer.js +1 -3
- package/dist/components/atoms/Input/PressableInputContainer/PressableInputContainer.js.map +1 -1
- package/dist/components/atoms/Input/PressableInputContainer/index.js +5 -15
- package/dist/components/atoms/Input/PressableInputContainer/index.js.map +1 -1
- package/dist/components/atoms/Input/PressableInputContainer/styled.js +1 -3
- package/dist/components/atoms/Input/PressableInputContainer/styled.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useInputFocus.js +1 -3
- package/dist/components/atoms/Input/hooks/useInputFocus.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useNumberMask.js +1 -3
- package/dist/components/atoms/Input/hooks/useNumberMask.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useStringMask.js +3 -5
- package/dist/components/atoms/Input/hooks/useStringMask.js.map +1 -1
- package/dist/components/atoms/Input/index.d.ts +1 -0
- package/dist/components/atoms/Input/index.js +28 -82
- package/dist/components/atoms/Input/index.js.map +1 -1
- package/dist/components/atoms/Input/styled.js +2 -4
- package/dist/components/atoms/Input/styled.js.map +1 -1
- package/dist/components/atoms/Paper/Paper.js +1 -3
- package/dist/components/atoms/Paper/Paper.js.map +1 -1
- package/dist/components/atoms/Paper/index.js +5 -15
- package/dist/components/atoms/Paper/index.js.map +1 -1
- package/dist/components/atoms/Paper/styled.js +1 -3
- package/dist/components/atoms/Paper/styled.js.map +1 -1
- package/dist/components/atoms/PressableSurface/PressableSurface.js +1 -3
- package/dist/components/atoms/PressableSurface/PressableSurface.js.map +1 -1
- package/dist/components/atoms/PressableSurface/index.js +5 -15
- package/dist/components/atoms/PressableSurface/index.js.map +1 -1
- package/dist/components/atoms/ProgressBar/ProgressBar.js +3 -7
- package/dist/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/atoms/ProgressBar/index.js +5 -15
- package/dist/components/atoms/ProgressBar/index.js.map +1 -1
- package/dist/components/atoms/ProgressBar/styled.js +1 -3
- package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
- package/dist/components/atoms/RadioButton/RadioButton.js +1 -3
- package/dist/components/atoms/RadioButton/RadioButton.js.map +1 -1
- package/dist/components/atoms/RadioButton/index.js +5 -15
- package/dist/components/atoms/RadioButton/index.js.map +1 -1
- package/dist/components/atoms/RadioButton/styled.js +1 -3
- package/dist/components/atoms/RadioButton/styled.js.map +1 -1
- package/dist/components/atoms/Switch/Switch.js +1 -3
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/atoms/Switch/animation.js +1 -3
- package/dist/components/atoms/Switch/animation.js.map +1 -1
- package/dist/components/atoms/Switch/index.js +5 -15
- package/dist/components/atoms/Switch/index.js.map +1 -1
- package/dist/components/atoms/Switch/styled.js +1 -3
- package/dist/components/atoms/Switch/styled.js.map +1 -1
- package/dist/components/atoms/Tag/Tag.js +2 -4
- package/dist/components/atoms/Tag/Tag.js.map +1 -1
- package/dist/components/atoms/Tag/index.js +5 -15
- package/dist/components/atoms/Tag/index.js.map +1 -1
- package/dist/components/atoms/Tag/styled.js +1 -3
- package/dist/components/atoms/Tag/styled.js.map +1 -1
- package/dist/components/atoms/Text/Text.js +1 -3
- package/dist/components/atoms/Text/Text.js.map +1 -1
- package/dist/components/atoms/Text/index.js +5 -15
- package/dist/components/atoms/Text/index.js.map +1 -1
- package/dist/components/atoms/Text/styled.js +1 -3
- package/dist/components/atoms/Text/styled.js.map +1 -1
- package/dist/components/atoms/shared/PaperAndCard.js +1 -3
- package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
- package/dist/components/molecules/Calendar/Calendar.js +3 -5
- package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
- package/dist/components/molecules/Calendar/components/MonthWeek.js +4 -6
- package/dist/components/molecules/Calendar/components/MonthWeek.js.map +1 -1
- package/dist/components/molecules/Calendar/components/Weekdays.js +1 -3
- package/dist/components/molecules/Calendar/components/Weekdays.js.map +1 -1
- package/dist/components/molecules/Calendar/components/index.js +6 -15
- package/dist/components/molecules/Calendar/components/index.js.map +1 -1
- package/dist/components/molecules/Calendar/index.js +8 -33
- package/dist/components/molecules/Calendar/index.js.map +1 -1
- package/dist/components/molecules/Calendar/styled.js +4 -6
- package/dist/components/molecules/Calendar/styled.js.map +1 -1
- package/dist/components/molecules/DatePicker/DatePicker.js +1 -3
- package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/molecules/DatePicker/index.js +5 -15
- package/dist/components/molecules/DatePicker/index.js.map +1 -1
- package/dist/components/molecules/DatePicker/styled.js +2 -4
- package/dist/components/molecules/DatePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js +2 -4
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/index.js +5 -15
- package/dist/components/molecules/DateTimePicker/index.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/styled.js +1 -3
- package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +2 -4
- package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/Selector.js +1 -3
- package/dist/components/molecules/DateTimeSelector/Selector.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/index.js +6 -21
- package/dist/components/molecules/DateTimeSelector/index.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/styled.js +1 -3
- package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
- package/dist/components/molecules/Grid/Grid.js +3 -5
- package/dist/components/molecules/Grid/Grid.js.map +1 -1
- package/dist/components/molecules/Grid/Item/Item.js +4 -6
- package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
- package/dist/components/molecules/Grid/Item/index.js +5 -15
- package/dist/components/molecules/Grid/Item/index.js.map +1 -1
- package/dist/components/molecules/Grid/index.js +8 -27
- package/dist/components/molecules/Grid/index.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js +1 -3
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/index.js +4 -9
- package/dist/components/molecules/HintInputContainer/index.js.map +1 -1
- package/dist/components/molecules/InputPassword/InputPasswordIcon.js +1 -3
- package/dist/components/molecules/InputPassword/InputPasswordIcon.js.map +1 -1
- package/dist/components/molecules/InputPassword/index.js +4 -9
- package/dist/components/molecules/InputPassword/index.js.map +1 -1
- package/dist/components/molecules/InputPassword/styled.js +1 -3
- package/dist/components/molecules/InputPassword/styled.js.map +1 -1
- package/dist/components/molecules/Snackbar/Snackbar.js +3 -5
- package/dist/components/molecules/Snackbar/Snackbar.js.map +1 -1
- package/dist/components/molecules/Snackbar/index.js +5 -15
- package/dist/components/molecules/Snackbar/index.js.map +1 -1
- package/dist/components/molecules/Snackbar/styled.js +1 -3
- package/dist/components/molecules/Snackbar/styled.js.map +1 -1
- package/dist/components/molecules/TextArea/TextArea.js +1 -3
- package/dist/components/molecules/TextArea/TextArea.js.map +1 -1
- package/dist/components/molecules/TextArea/index.js +7 -21
- package/dist/components/molecules/TextArea/index.js.map +1 -1
- package/dist/components/molecules/TextArea/styled.js +1 -3
- package/dist/components/molecules/TextArea/styled.js.map +1 -1
- package/dist/hooks/index.js +6 -15
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useDebouncedState.js +1 -3
- package/dist/hooks/useDebouncedState.js.map +1 -1
- package/dist/hooks/useTheme.js +1 -3
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +123 -531
- package/dist/index.js.map +1 -1
- package/dist/styles/ThemeProvider.js +1 -3
- package/dist/styles/ThemeProvider.js.map +1 -1
- package/dist/styles/definitions.js +1 -3
- package/dist/styles/definitions.js.map +1 -1
- package/dist/styles/light.js +1 -3
- package/dist/styles/light.js.map +1 -1
- package/dist/types/defaults.js +1 -3
- package/dist/utils/IPhoneXHelper.js +1 -3
- package/dist/utils/IPhoneXHelper.js.map +1 -1
- package/dist/utils/ResponsiveFontSize.js +1 -3
- package/dist/utils/ResponsiveFontSize.js.map +1 -1
- package/dist/utils/extractNumbersFromString.js +1 -3
- package/dist/utils/extractNumbersFromString.js.map +1 -1
- package/dist/utils/formatWithMask.js +1 -3
- package/dist/utils/formatWithMask.js.map +1 -1
- package/dist/utils/index.js +11 -45
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lightenDarkenColor.js +1 -3
- package/dist/utils/lightenDarkenColor.js.map +1 -1
- package/dist/utils/masks.js +3 -5
- package/dist/utils/masks.js.map +1 -1
- package/package.json +6 -6
- package/src/components/atoms/Input/InputElement/InputElement.tsx +5 -74
- package/src/components/atoms/Input/InputMaskElement/InputMaskElement.tsx +120 -0
- package/src/components/atoms/Input/index.ts +4 -0
- package/src/index.ts +2 -0
|
@@ -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","map","index","isSelected","isBetween","isRangeStart","isRangeEnd","colorTone","getMonth","getDate","memo"],"mappings":"
|
|
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,CA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AAEQ,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAsBT,KAA5B;AACAkB,MAAAA,YAAY,GAAGT,OAAO,IAAI,wBAAUD,MAAV,EAAkBF,IAAlB,CAA1B;AACAa,MAAAA,UAAU,GAAG,CAAC,CAACV,OAAF,IAAa,wBAAUA,OAAV,EAAmBH,IAAnB,CAA1B;AACD,KAJD,MAIO;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
|
-
{"version":3,"sources":["../../../../../src/components/molecules/Calendar/components/Weekdays.tsx"],"names":["Weekdays","calendar","locale","Capitalized","map","date","getDate","slice","React","memo"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/molecules/Calendar/components/Weekdays.tsx"],"names":["Weekdays","calendar","locale","Capitalized","map","date","getDate","slice","React","memo"],"mappings":";;;;;AAAA;;AACA;;AACA;;;;AAQA,MAAMA,QAAQ,GAAG,CAAC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,MAAZ;AAAoBC,EAAAA;AAApB,CAAD,KAAkD;AACjE,SACE,6BAAC,YAAD,QACGF,QAAQ,CAAC,CAAD,CAAR,CAAYG,GAAZ,CAAgBC,IAAI,IACnB,6BAAC,YAAD;AACE,IAAA,GAAG,EAAEA,IAAI,CAACC,OAAL,EADP;AAEE,IAAA,QAAQ,EAAE,KAFZ;AAGE,IAAA,WAAW,EAAE,KAHf;AAIE,IAAA,SAAS,EAAE,KAJb;AAKE,IAAA,WAAW,EAAE,KALf;AAME,IAAA,YAAY,EAAE,KANhB;AAOE,IAAA,UAAU,EAAE,KAPd;AAQE,IAAA,aAAa,EAAE;AARjB,KAUE,6BAAC,WAAD;AAAa,IAAA,YAAY,EAAE,WAA3B;AAAwC,IAAA,SAAS,EAAE;AAAnD,KACG,qBAAOD,IAAP,EAAa,KAAb,EAAoB;AAAEH,IAAAA;AAAF,GAApB,EAAgCK,KAAhC,CAAsC,CAAtC,EAAyC,CAAzC,CADH,CAVF,CADD,CADH,CADF;AAoBD,CArBD;;eAuBeC,eAAMC,IAAN,CAAWT,QAAX,C","sourcesContent":["import React from 'react';\nimport { Cell, Week } from '../styled';\nimport { format } from 'date-fns';\n\ninterface IWeekdays {\n calendar: Date[][];\n locale?: Locale;\n Capitalized: React.ElementType;\n}\n\nconst Weekdays = ({ calendar, locale, Capitalized }: IWeekdays) => {\n return (\n <Week>\n {calendar[0].map(date => (\n <Cell\n key={date.getDate()}\n selected={false}\n highlighted={false}\n isLineEnd={false}\n isLineStart={false}\n isRangeStart={false}\n isRangeEnd={false}\n pointerEvents={'none'}\n >\n <Capitalized colorVariant={'secondary'} colorTone={'medium'}>\n {format(date, 'EEE', { locale }).slice(0, 3)}\n </Capitalized>\n </Cell>\n ))}\n </Week>\n );\n};\n\nexport default React.memo(Weekdays);\n"],"file":"Weekdays.js"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Weekdays", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Weekdays.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "MonthWeek", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _MonthWeek.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.MonthWeek = exports.Weekdays = void 0;
|
|
18
5
|
|
|
19
6
|
var _Weekdays = _interopRequireDefault(require("./Weekdays"));
|
|
20
7
|
|
|
8
|
+
exports.Weekdays = _Weekdays.default;
|
|
9
|
+
|
|
21
10
|
var _MonthWeek = _interopRequireDefault(require("./MonthWeek"));
|
|
22
11
|
|
|
12
|
+
exports.MonthWeek = _MonthWeek.default;
|
|
13
|
+
|
|
23
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/molecules/Calendar/components/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/molecules/Calendar/components/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;AACA","sourcesContent":["export { default as Weekdays } from './Weekdays';\nexport { default as MonthWeek } from './MonthWeek';\n"],"file":"index.js"}
|
|
@@ -1,41 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Calendar", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Calendar.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "CalendarProps", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _Calendar.CalendarProps;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "SelectionType", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _Calendar.SelectionType;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "DateRange", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _Calendar.DateRange;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "Value", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _Calendar.Value;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.Value = exports.DateRange = exports.SelectionType = exports.CalendarProps = exports.Calendar = void 0;
|
|
36
5
|
|
|
37
6
|
var _Calendar = _interopRequireWildcard(require("./Calendar"));
|
|
38
7
|
|
|
8
|
+
exports.Calendar = _Calendar.default;
|
|
9
|
+
exports.CalendarProps = _Calendar.CalendarProps;
|
|
10
|
+
exports.SelectionType = _Calendar.SelectionType;
|
|
11
|
+
exports.DateRange = _Calendar.DateRange;
|
|
12
|
+
exports.Value = _Calendar.Value;
|
|
13
|
+
|
|
39
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); }
|
|
40
15
|
|
|
41
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; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/molecules/Calendar/index.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
6
4
|
exports.Cell = exports.Selected = exports.Week = exports.Content = exports.getCapitalizedTextComponent = exports.Control = exports.TitleContainer = void 0;
|
|
7
5
|
|
|
8
6
|
var _native = _interopRequireWildcard(require("@emotion/native"));
|
|
@@ -30,9 +28,9 @@ const Control = (0, _native.default)(_PressableSurface.PressableSurface)(props =
|
|
|
30
28
|
|
|
31
29
|
return (0, _native.css)`
|
|
32
30
|
align-items: flex-${props.align};
|
|
33
|
-
padding: ${(_props$theme = props.theme)
|
|
34
|
-
border-radius: ${(_props$theme2 = props.theme)
|
|
35
|
-
margin: ${(_props$theme3 = props.theme)
|
|
31
|
+
padding: ${(_props$theme = props.theme) == null ? void 0 : _props$theme.spacing.centi};
|
|
32
|
+
border-radius: ${(_props$theme2 = props.theme) == null ? void 0 : _props$theme2.borderRadius.mili};
|
|
33
|
+
margin: ${(_props$theme3 = props.theme) == null ? void 0 : _props$theme3.spacing.mili};
|
|
36
34
|
`;
|
|
37
35
|
});
|
|
38
36
|
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","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","borderEffect","backgroundColor","light"],"mappings":"
|
|
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","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;AAClE,CALO;;AAOA,MAAMC,OAAO,GAAG,qBAAOC,kCAAP,EAEnBC,KADF;AAAA;;AAAA,SAEK,gBAAI;AACX,wBAAwBA,KAAK,CAACC,KAAM;AACpC,eAFU,gBAEKD,KAAK,CAACN,KAFX,qBAEK,aAAaQ,OAAb,CAAqBC,KAAM;AAC1C,qBAHU,iBAGWH,KAAK,CAACN,KAHjB,qBAGW,cAAaU,YAAb,CAA0BC,IAAK;AACpD,cAJU,iBAIIL,KAAK,CAACN,KAJV,qBAII,cAAaQ,OAAb,CAAqBG,IAAK;AACxC,GAPE;AAAA,CADqB,CAAhB;;;AAWA,MAAMC,2BAA2B,GAAIC,SAAD,IAA8B;AACvE,SAAO,qBAAOA,SAAP,CAAkB;AAC3B;AACA,GAFE;AAGD,CAJM;;;AAMA,MAAMC,OAAO,GAAGhB,gBAAOC,IAAsC;AACpE,aAAa,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACQ,OAAN,CAAcO,IAAK;AAC/C,sBAAsB,CAAC;AAAEf,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACgB,aAAN,CAAoBC,YAAa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A,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 +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","rightComponent","style","locale","closeOnPick","renderCalendar","requestShowCalendar","requestCloseCalendar","rest","focused","handleBlur","handleFocus","handleShowCalendar","React","useCallback","getDisplayValue","lowest","highest","StyledText","setTimeout","calendar"],"mappings":"
|
|
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","getD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;AAPV,IADF;AAYA,SACE,0CACGT,gBAAgB,GACfA,gBAAgB,CAACkB,kBAAD,EAAqBG,eAAe,EAApC,CADD,GAGf,oBAAC,sCAAD;AACE,IAAA,OAAO,EAAEN,OADX;AAEE,IAAA,SAAS,EAAEP,KAFb;AAGE,IAAA,OAAO,EAAEU,kBAHX;AAIE,IAAA,QAAQ,EAAEnB,QAJZ;AAKE,IAAA,aAAa,EAAEE,aALjB;AAME,IAAA,cAAc,EAAEG,aANlB;AAOE,IAAA,OAAO,EAAED,OAPX;AAQE,IAAA,IAAI,EAAED,IARR;AASE,IAAA,cAAc,EACZ,0CACE,oBAAC,oBAAD;AAAc,MAAA,IAAI,EAAC,gBAAnB;AAAoC,MAAA,IAAI,EAAC,SAAzC;AAAmD,MAAA,IAAI,EAAC;AAAxD,MADF,EAEGK,cAFH;AAVJ,KAeMO,IAfN,GAiBE,oBAAC,UAAD;AAAY,IAAA,UAAU,EAAC,MAAvB;AAA8B,IAAA,QAAQ,EAAEf;AAAxC,KACGsB,eAAe,MAAM,GADxB,CAjBF,CAJJ,EA0BGV,cAAc,CAACe,QAAD,EAAWV,UAAX,CA1BjB,CADF;AA8BD;;eAEc3B,U","sourcesContent":["import { format as formatDate } 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,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "DatePicker", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _DatePicker.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "DatePickerProps", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _DatePicker.DatePickerProps;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.DatePickerProps = exports.DatePicker = void 0;
|
|
18
5
|
|
|
19
6
|
var _DatePicker = _interopRequireWildcard(require("./DatePicker"));
|
|
20
7
|
|
|
8
|
+
exports.DatePicker = _DatePicker.default;
|
|
9
|
+
exports.DatePickerProps = _DatePicker.DatePickerProps;
|
|
10
|
+
|
|
21
11
|
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); }
|
|
22
12
|
|
|
23
13
|
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; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/molecules/DatePicker/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/molecules/DatePicker/index.ts"],"names":[],"mappings":";;;;;AAAA","sourcesContent":["export { default as DatePicker, DatePickerProps } from './DatePicker';\n"],"file":"index.js"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
6
4
|
exports.CalendarIcon = exports.getStyledTextComponent = void 0;
|
|
7
5
|
|
|
8
6
|
var _native = _interopRequireWildcard(require("@emotion/native"));
|
|
@@ -20,7 +18,7 @@ const getStyledTextComponent = component => {
|
|
|
20
18
|
var _props$theme;
|
|
21
19
|
|
|
22
20
|
return (0, _native.css)`
|
|
23
|
-
line-height: ${(_props$theme = props.theme)
|
|
21
|
+
line-height: ${(_props$theme = props.theme) == null ? void 0 : _props$theme.typography.h5.lineHeight};
|
|
24
22
|
${(0, _Input.disabledInputStyles)(props)}
|
|
25
23
|
`;
|
|
26
24
|
});
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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,qBACjD,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,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
6
4
|
exports.default = void 0;
|
|
7
5
|
|
|
8
6
|
var _dateFns = require("date-fns");
|
|
@@ -76,7 +74,7 @@ const DateTimePicker = ({
|
|
|
76
74
|
};
|
|
77
75
|
|
|
78
76
|
const handleChoosing = value => {
|
|
79
|
-
onChange
|
|
77
|
+
onChange == null ? void 0 : onChange(value);
|
|
80
78
|
requestCloseSelector();
|
|
81
79
|
};
|
|
82
80
|
|
|
@@ -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","DateTimeSelector","rightComponent","style","renderSelector","requestShowSelector","requestCloseSelector","rest","focused","handleBlur","handleFocus","handleShowSelector","handleChoosing","StyledText","displayValue","StyledDateTimeSelector","dateTimeSelector"],"mappings":"
|
|
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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AA,IAAI,EAAED,IAPR;AAQE,IAAA,aAAa,EAAED,aARjB;AASE,IAAA,cAAc,EACZ,0CACE,oBAAC,oBAAD;AAAc,MAAA,IAAI,EAAC,gBAAnB;AAAoC,MAAA,IAAI,EAAC,SAAzC;AAAmD,MAAA,IAAI,EAAC;AAAxD,MADF,EAEGO,cAFH;AAVJ,KAeMK,IAfN,GAiBE,oBAAC,UAAD;AAAY,IAAA,UAAU,EAAC,MAAvB;AAA8B,IAAA,QAAQ,EAAEd;AAAxC,KACGqB,YADH,CAjBF,CAJJ,EA0BGV,cAAc,CAACY,gBAAD,EAAmBP,UAAnB,CA1BjB,CADF;AA8BD,CAhHD;;eAkHevC,c","sourcesContent":["import { format as formatDate } from '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"}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "DateTimePicker", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _DateTimePicker.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "DateTimePickerProps", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _DateTimePicker.DateTimePickerProps;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.DateTimePickerProps = exports.DateTimePicker = void 0;
|
|
18
5
|
|
|
19
6
|
var _DateTimePicker = _interopRequireWildcard(require("./DateTimePicker"));
|
|
20
7
|
|
|
8
|
+
exports.DateTimePicker = _DateTimePicker.default;
|
|
9
|
+
exports.DateTimePickerProps = _DateTimePicker.DateTimePickerProps;
|
|
10
|
+
|
|
21
11
|
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); }
|
|
22
12
|
|
|
23
13
|
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; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/index.ts"],"names":[],"mappings":";;;;;AAAA","sourcesContent":["export {\n default as DateTimePicker,\n DateTimePickerProps,\n} from './DateTimePicker';\n"],"file":"index.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/styled.ts"],"names":["getStyledDateTimeSelector","component","theme","spacing","deca"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/styled.ts"],"names":["getStyledDateTimeSelector","component","theme","spacing","deca"],"mappings":";;;;;AAAA;;;;AAKO,MAAMA,yBAAyB,GACpCC,SADuC,IAEpC;AACH,SAAO,qBAAOA,SAAP,CAAuC;AAChD,eAAe,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,IAAK;AACjD,GAFE;AAGD,CANM","sourcesContent":["import styled from '@emotion/native';\nimport { FC } from 'react';\nimport { StyleProps } from '../../../types/defaults';\nimport { DateTimeSelectorProps } from '../DateTimeSelector';\n\nexport const getStyledDateTimeSelector = (\n component: FC<DateTimeSelectorProps>\n) => {\n return styled(component)<Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.deca};\n `;\n};\n"],"file":"styled.js"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
3
|
+
exports.__esModule = true;
|
|
6
4
|
exports.default = void 0;
|
|
7
5
|
|
|
8
6
|
var _dateFns = require("date-fns");
|
|
@@ -122,7 +120,7 @@ const DateTimeSelector = ({
|
|
|
122
120
|
if (mode === 'datetime' && currentMode === 0) {
|
|
123
121
|
setCurrentMode(1);
|
|
124
122
|
} else {
|
|
125
|
-
onChange
|
|
123
|
+
onChange == null ? void 0 : onChange(date);
|
|
126
124
|
}
|
|
127
125
|
};
|
|
128
126
|
|
|
@@ -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,a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AAe,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"}
|
|
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,cAZyD;AAazDC,EAAAA,cAbyD;AAczDC,EAAAA,qBAdyD;AAezDC,EAAAA,qBAfyD;AAgBzDC,EAAAA,QAhByD;AAiBzDC,EAAAA,UAjByD;AAkBzDC,EAAAA,SAlByD;AAmBzDC,EAAAA,SAnByD;AAoBzDC,EAAAA,WApByD;AAqBzD,KAAGC;AArBsD,CAAD,KAsBpD;AACJ,QAAMd,kBAAkB,GACtBC,mBAAmB,IAClB,CA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AAL,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', { 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"}
|