@paprika/time-picker 2.0.6-next.1 → 2.0.7-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.7-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - e39d814: fix period select issue when hour is 12
8
+
9
+ ## 2.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - 0dcf307: Refactored to use `getActiveElement` from `@paprika/helpers` to support web components.
14
+ - Updated dependencies [0dcf307]
15
+ - Updated dependencies [0bf34d9]
16
+ - Updated dependencies [0dcf307]
17
+ - Updated dependencies [9ac6aca]
18
+ - @paprika/popover@2.0.4
19
+ - @paprika/helpers@2.3.0
20
+ - @paprika/tokens@2.0.0
21
+ - @paprika/icon@2.1.7
22
+ - @paprika/input@4.0.18
23
+ - @paprika/raw-button@1.0.12
24
+ - @paprika/stylers@1.1.6
25
+
26
+ ## 2.0.6-next.2
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [9ac6aca]
31
+ - @paprika/tokens@2.0.0-next.1
32
+ - @paprika/icon@2.1.7-next.1
33
+ - @paprika/input@4.0.18-next.2
34
+ - @paprika/popover@2.0.4-next.2
35
+ - @paprika/raw-button@1.0.12-next.1
36
+ - @paprika/stylers@1.1.6-next.1
37
+
3
38
  ## 2.0.6-next.1
4
39
 
5
40
  ### Patch Changes
@@ -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() && momentValue.hours() < 12) {
23
+ if (momentValue.isValid()) {
24
24
  var lowerCaseTime = time.toLowerCase();
25
25
 
26
- if (lowerCaseTime.endsWith("pm") || lowerCaseTime.endsWith("p")) {
27
- momentValue.add(12, "hours");
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","hours","lowerCaseTime","toLowerCase","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,MAAyBD,WAAW,CAACE,KAAZ,KAAsB,EAAnD,EAAuD;AACrD,QAAMC,aAAa,GAAGL,IAAI,CAACM,WAAL,EAAtB;;AACA,QAAID,aAAa,CAACE,QAAd,CAAuB,IAAvB,KAAgCF,aAAa,CAACE,QAAd,CAAuB,GAAvB,CAApC,EAAiE;AAC/DL,MAAAA,WAAW,CAACM,GAAZ,CAAgB,EAAhB,EAAoB,OAApB;AACD;AACF;;AAED,SAAON,WAAP;AACD;;AAED,SAASO,oBAAT,CAA8BP,WAA9B,EAA2C;AACzC,MAAMQ,QAAQ,GAAG,SAAXA,QAAW,CAAAN,KAAK,EAAI;AACxB,QAAIO,EAAE,GAAGP,KAAK,GAAG,EAAjB;AACAO,IAAAA,EAAE,GAAGA,EAAE,KAAK,CAAP,GAAW,EAAX,GAAgBA,EAArB;AACA,WAAOA,EAAP;AACD,GAJD;;AAMA,MAAIT,WAAW,CAACC,OAAZ,EAAJ,EAA2B;AACzB,WAAO;AACLS,MAAAA,KAAK,EAAE,EADF;AAELC,MAAAA,OAAO,EAAEX,WAAW,CAACY,MAAZ,CAAmB,QAAnB,CAFJ;AAGLC,MAAAA,gBAAgB,EAAEb,WAAW,CAACY,MAAZ,CAAmB,SAAnB,CAHb;AAILH,MAAAA,EAAE,EAAED,QAAQ,CAACR,WAAW,CAACE,KAAZ,EAAD,CAJP;AAKLY,MAAAA,EAAE,EAAEd,WAAW,CAACe,OAAZ,EALC;AAMLC,MAAAA,MAAM,EAAEhB,WAAW,CAACY,MAAZ,CAAmB,GAAnB;AANH,KAAP;AAQD;;AACD,SAAO;AACLF,IAAAA,KAAK,EAAEd,oBADF;AAELe,IAAAA,OAAO,EAAE,IAFJ;AAGLE,IAAAA,gBAAgB,EAAE,IAHb;AAILJ,IAAAA,EAAE,EAAE,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() && momentValue.hours() < 12) {\n const lowerCaseTime = time.toLowerCase();\n if (lowerCaseTime.endsWith(\"pm\") || lowerCaseTime.endsWith(\"p\")) {\n momentValue.add(12, \"hours\");\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"}
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,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AAE,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.6-next.1",
3
+ "version": "2.0.7-next.0",
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-next.0",
20
- "@paprika/icon": "^2.1.7-next.0",
21
- "@paprika/input": "^4.0.18-next.1",
22
- "@paprika/popover": "^2.0.4-next.1",
23
- "@paprika/raw-button": "^1.0.12-next.0",
24
- "@paprika/stylers": "^1.1.6-next.0",
25
- "@paprika/tokens": "^1.1.5-next.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": {