@paprika/time-picker 2.0.6-next.2 → 2.0.7
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 +29 -0
- package/lib/TimeInterpreter.js +11 -3
- package/lib/TimeInterpreter.js.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e39d814: fix period select issue when hour is 12
|
|
8
|
+
|
|
9
|
+
## 2.0.7-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- e39d814: fix period select issue when hour is 12
|
|
14
|
+
|
|
15
|
+
## 2.0.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 0dcf307: Refactored to use `getActiveElement` from `@paprika/helpers` to support web components.
|
|
20
|
+
- Updated dependencies [0dcf307]
|
|
21
|
+
- Updated dependencies [0bf34d9]
|
|
22
|
+
- Updated dependencies [0dcf307]
|
|
23
|
+
- Updated dependencies [9ac6aca]
|
|
24
|
+
- @paprika/popover@2.0.4
|
|
25
|
+
- @paprika/helpers@2.3.0
|
|
26
|
+
- @paprika/tokens@2.0.0
|
|
27
|
+
- @paprika/icon@2.1.7
|
|
28
|
+
- @paprika/input@4.0.18
|
|
29
|
+
- @paprika/raw-button@1.0.12
|
|
30
|
+
- @paprika/stylers@1.1.6
|
|
31
|
+
|
|
3
32
|
## 2.0.6-next.2
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/lib/TimeInterpreter.js
CHANGED
|
@@ -20,11 +20,19 @@ function getValidFormatMomentValue(time) {
|
|
|
20
20
|
var possibleFormats = ["Hmm", "HHmm"];
|
|
21
21
|
var momentValue = (0, _moment["default"])(time, possibleFormats); // Add extra am/pm logic to help handle period cases
|
|
22
22
|
|
|
23
|
-
if (momentValue.isValid()
|
|
23
|
+
if (momentValue.isValid()) {
|
|
24
24
|
var lowerCaseTime = time.toLowerCase();
|
|
25
25
|
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (momentValue.hours() === 12) {
|
|
27
|
+
if (lowerCaseTime.endsWith("am") || lowerCaseTime.endsWith("a")) {
|
|
28
|
+
momentValue.add(12, "hours");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (momentValue.hours() < 12) {
|
|
33
|
+
if (lowerCaseTime.endsWith("pm") || lowerCaseTime.endsWith("p")) {
|
|
34
|
+
momentValue.add(12, "hours");
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TimeInterpreter.js"],"names":["ERROR_INVALID_FORMAT","getValidFormatMomentValue","time","possibleFormats","momentValue","isValid","
|
|
1
|
+
{"version":3,"sources":["../src/TimeInterpreter.js"],"names":["ERROR_INVALID_FORMAT","getValidFormatMomentValue","time","possibleFormats","momentValue","isValid","lowerCaseTime","toLowerCase","hours","endsWith","add","momentValueToTimeObj","getHours","hh","error","timeStr","format","timeStrWithSpace","mm","minutes","period","parse","timeObj","value","isVisible"],"mappings":";;;;;;;;;;;;AAAA;;AAEA,IAAMA,oBAAoB,GAAG,sBAA7B;;AAEA,SAASC,yBAAT,CAAmCC,IAAnC,EAAyC;AACvC;AACA;AACA,MAAMC,eAAe,GAAG,CAAC,KAAD,EAAQ,MAAR,CAAxB;AACA,MAAMC,WAAW,GAAG,wBAAOF,IAAP,EAAaC,eAAb,CAApB,CAJuC,CAMvC;;AACA,MAAIC,WAAW,CAACC,OAAZ,EAAJ,EAA2B;AACzB,QAAMC,aAAa,GAAGJ,IAAI,CAACK,WAAL,EAAtB;;AACA,QAAIH,WAAW,CAACI,KAAZ,OAAwB,EAA5B,EAAgC;AAC9B,UAAI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IAJC;AAKLK,IAAAA,EAAE,EAAE,IALC;AAMLE,IAAAA,MAAM,EAAE;AANH,GAAP;AAQD;;AAED,SAASC,KAAT,CAAenB,IAAf,EAAqB;AACnB,MAAME,WAAW,GAAGH,yBAAyB,CAACC,IAAD,CAA7C;AAEA,MAAMoB,OAAO,GAAGX,oBAAoB,CAACP,WAAD,CAApC;AACAkB,EAAAA,OAAO,CAACC,KAAR,GAAgBrB,IAAhB;AACAoB,EAAAA,OAAO,CAACE,SAAR,GAAoB,IAApB;AAEA,SAAOF,OAAP;AACD;;eAEc;AAAED,EAAAA,KAAK,EAALA;AAAF,C","sourcesContent":["import moment from \"moment\";\n\nconst ERROR_INVALID_FORMAT = \"invalid time pattern\";\n\nfunction getValidFormatMomentValue(time) {\n // Using unit test determined these formats properly interpret every value\n // passed to moment\n const possibleFormats = [\"Hmm\", \"HHmm\"];\n const momentValue = moment(time, possibleFormats);\n\n // Add extra am/pm logic to help handle period cases\n if (momentValue.isValid()) {\n const lowerCaseTime = time.toLowerCase();\n if (momentValue.hours() === 12) {\n if (lowerCaseTime.endsWith(\"am\") || lowerCaseTime.endsWith(\"a\")) {\n momentValue.add(12, \"hours\");\n }\n }\n if (momentValue.hours() < 12) {\n if (lowerCaseTime.endsWith(\"pm\") || lowerCaseTime.endsWith(\"p\")) {\n momentValue.add(12, \"hours\");\n }\n }\n }\n\n return momentValue;\n}\n\nfunction momentValueToTimeObj(momentValue) {\n const getHours = hours => {\n let hh = hours % 12;\n hh = hh === 0 ? 12 : hh;\n return hh;\n };\n\n if (momentValue.isValid()) {\n return {\n error: \"\",\n timeStr: momentValue.format(\"hh:mma\"),\n timeStrWithSpace: momentValue.format(\"hh:mm a\"),\n hh: getHours(momentValue.hours()),\n mm: momentValue.minutes(),\n period: momentValue.format(\"a\"),\n };\n }\n return {\n error: ERROR_INVALID_FORMAT,\n timeStr: null,\n timeStrWithSpace: null,\n hh: null,\n mm: null,\n period: null,\n };\n}\n\nfunction parse(time) {\n const momentValue = getValidFormatMomentValue(time);\n\n const timeObj = momentValueToTimeObj(momentValue);\n timeObj.value = time;\n timeObj.isVisible = true;\n\n return timeObj;\n}\n\nexport default { parse };\n"],"file":"TimeInterpreter.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paprika/time-picker",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "The TimePicker component gives users the ability to select a specific time from a popover.",
|
|
5
5
|
"author": "@paprika",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime-corejs2": "^7.3.1",
|
|
19
|
-
"@paprika/helpers": "^2.3.0
|
|
20
|
-
"@paprika/icon": "^2.1.7
|
|
21
|
-
"@paprika/input": "^4.0.18
|
|
22
|
-
"@paprika/popover": "^2.0.4
|
|
23
|
-
"@paprika/raw-button": "^1.0.12
|
|
24
|
-
"@paprika/stylers": "^1.1.6
|
|
25
|
-
"@paprika/tokens": "^2.0.0
|
|
19
|
+
"@paprika/helpers": "^2.3.0",
|
|
20
|
+
"@paprika/icon": "^2.1.7",
|
|
21
|
+
"@paprika/input": "^4.0.18",
|
|
22
|
+
"@paprika/popover": "^2.0.4",
|
|
23
|
+
"@paprika/raw-button": "^1.0.12",
|
|
24
|
+
"@paprika/stylers": "^1.1.6",
|
|
25
|
+
"@paprika/tokens": "^2.0.0",
|
|
26
26
|
"prop-types": "^15.7.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|