@mediafly/js-ui 51.4.0 → 51.4.1

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 (43) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/constants/constants.js +2 -1
  3. package/lib/constants/constants.js.map +1 -1
  4. package/lib/date-input/date-input.js +33 -12
  5. package/lib/date-input/date-input.js.map +1 -1
  6. package/lib/date-input/validate-date.js +12 -8
  7. package/lib/date-input/validate-date.js.map +1 -1
  8. package/lib/date-time-zone-picker/date-time-zone-factory.js +62 -49
  9. package/lib/date-time-zone-picker/date-time-zone-factory.js.map +1 -1
  10. package/lib/date-time-zone-picker/date-time-zone-picker.html +6 -6
  11. package/lib/date-time-zone-picker/date-time-zone-picker.js +119 -59
  12. package/lib/date-time-zone-picker/date-time-zone-picker.js.map +1 -1
  13. package/lib/date-time-zone-picker/datepicker.html +2 -3
  14. package/lib/date-time-zone-picker/datepicker.js +79 -26
  15. package/lib/date-time-zone-picker/datepicker.js.map +1 -1
  16. package/lib/date-time-zone-picker/time-format-filter.js +8 -8
  17. package/lib/date-time-zone-picker/time-format-filter.js.map +1 -1
  18. package/lib/date-time-zone-picker/time-zone-picker.js +1 -1
  19. package/lib/date-time-zone-picker/timepicker.html +1 -2
  20. package/lib/date-time-zone-picker/timepicker.js +35 -40
  21. package/lib/date-time-zone-picker/timepicker.js.map +1 -1
  22. package/lib/time-input/time-input.js +27 -23
  23. package/lib/time-input/time-input.js.map +1 -1
  24. package/lib/time-input/validate-time.js +6 -3
  25. package/lib/time-input/validate-time.js.map +1 -1
  26. package/lib/tsconfig.deploy.tsbuildinfo +163 -25
  27. package/package.json +4 -4
  28. package/src/components/constants/constants.js +2 -1
  29. package/src/components/date-input/date-input.js +31 -12
  30. package/src/components/date-input/validate-date.js +14 -10
  31. package/src/components/date-time-zone-picker/date-time-zone-factory.ts +62 -49
  32. package/src/components/date-time-zone-picker/date-time-zone-picker.html +6 -6
  33. package/src/components/date-time-zone-picker/date-time-zone-picker.ts +131 -70
  34. package/src/components/date-time-zone-picker/datepicker.html +2 -3
  35. package/src/components/date-time-zone-picker/datepicker.ts +83 -26
  36. package/src/components/date-time-zone-picker/time-format-filter.ts +8 -8
  37. package/src/components/date-time-zone-picker/time-zone-picker.js +1 -1
  38. package/src/components/date-time-zone-picker/timepicker.html +1 -2
  39. package/src/components/date-time-zone-picker/timepicker.js +46 -47
  40. package/src/components/time-input/time-input.js +27 -24
  41. package/src/components/time-input/validate-time.js +6 -3
  42. package/webpack.config.js +6 -0
  43. package/tsconfig.tsbuildinfo +0 -7221
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## @mediafly/js-ui changelog
2
2
 
3
+ **51.4.1**
4
+
5
+ * Replace `moment` with `Luxon` (date/time packages)
6
+
3
7
  **51.4.0**
4
8
 
5
9
  * Added `light` and `dark` variants of several `ui-theme` colors
@@ -4,9 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const angular_1 = __importDefault(require("angular"));
7
+ const { DateTime } = require('luxon');
7
8
  angular_1.default.module('app')
8
9
  .constant('_', require('lodash'))
9
- .constant('$moment', require('moment'))
10
+ .constant('$luxon', DateTime)
10
11
  .constant('Pikaday', require('pikaday'))
11
12
  .constant('PREFIX', '/components/');
12
13
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/components/constants/constants.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAE7B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC;KACnB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;KACvC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/components/constants/constants.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAErC,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC;KACnB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;KACvC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC"}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const angular_1 = __importDefault(require("angular"));
7
7
  const date_input_html_1 = __importDefault(require("./date-input.html"));
8
- const moment_1 = __importDefault(require("moment"));
8
+ const { DateTime } = require('luxon');
9
9
  const pikaday_1 = __importDefault(require("pikaday"));
10
10
  angular_1.default.module('app').directive('mflyDateInput', ['translateFactory', function mflyDateInput(translateFactory) {
11
11
  return {
@@ -23,12 +23,12 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
23
23
  // Ng-model functionality
24
24
  // ----------------------------------------
25
25
  var validDateFormats = [
26
- 'D-MMM-YYYY', 'D/MMM/YYYY',
27
- 'DD-MMM-YYYY', 'DD/MMM/YYYY',
28
- 'MM-DD-YYYY', 'MM/DD/YYYY',
29
- 'M-D-YYYY', 'M/D/YYYY',
30
- 'MM-DD-YY', 'MM/DD/YY',
31
- 'M-D-YY', 'M/D/YY'
26
+ 'd-MMM-yyyy', 'd/MMM/yyyy',
27
+ 'dd-MMM-yyyy', 'dd/MMM/yyyy',
28
+ 'MM-dd-yyyy', 'MM/dd/yyyy',
29
+ 'M-d-yyyy', 'M/d/yyyy',
30
+ 'MM-dd-yy', 'MM/dd/yy',
31
+ 'M-d-yy', 'M/d/yy'
32
32
  ];
33
33
  // Format the ng-model value as a date string.
34
34
  // The result of this function is assigned to `ngModelCtrl.$viewValue`.
@@ -36,7 +36,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
36
36
  if (!nativeDate) {
37
37
  return '';
38
38
  }
39
- return moment_1.default(nativeDate).format('DD-MMM-YYYY');
39
+ return DateTime.fromJSDate(nativeDate).toFormat('dd-MMM-yyyy');
40
40
  });
41
41
  // Display the date string in the UI.
42
42
  ngModelCtrl.$render = function () {
@@ -52,7 +52,14 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
52
52
  $scope.onChange({ value: null });
53
53
  return null;
54
54
  }
55
- const jsDate = moment_1.default(viewValue, validDateFormats, true).toDate();
55
+ // Try parsing with each valid format
56
+ let parsedDate;
57
+ for (const format of validDateFormats) {
58
+ parsedDate = DateTime.fromFormat(viewValue, format);
59
+ if (parsedDate.isValid)
60
+ break;
61
+ }
62
+ const jsDate = parsedDate.toJSDate();
56
63
  $scope.onChange({ value: jsDate });
57
64
  return jsDate;
58
65
  });
@@ -61,7 +68,13 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
61
68
  $scope.$watch('date', function (newValue) {
62
69
  if (pikaday) {
63
70
  // We can't rely on native Date() parsing here (JSUI-185).
64
- pikaday.setDate(moment_1.default(newValue, validDateFormats).toDate(), true); // true = do not trigger onSelect
71
+ let parsedDate;
72
+ for (const format of validDateFormats) {
73
+ parsedDate = DateTime.fromFormat(newValue, format);
74
+ if (parsedDate.isValid)
75
+ break;
76
+ }
77
+ pikaday.setDate(parsedDate.toJSDate(), true); // true = do not trigger onSelect
65
78
  }
66
79
  ngModelCtrl.$setViewValue(newValue);
67
80
  });
@@ -77,7 +90,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
77
90
  // the scope property with a valid-formatted date string.
78
91
  onSelect: function (newDate) {
79
92
  $scope.$apply(function () {
80
- $scope.date = moment_1.default(newDate).format('DD-MMM-YYYY');
93
+ $scope.date = DateTime.fromJSDate(newDate).toFormat('dd-MMM-yyyy');
81
94
  });
82
95
  },
83
96
  // We can make the input field disabled, but we need further measures
@@ -93,7 +106,15 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
93
106
  // object which we initialize from the scope's model date, but ngModel
94
107
  // doesn't fill that value in until the digest cycle has stabilized.
95
108
  setTimeout(function () {
96
- pikadayOptions.defaultDate = moment_1.default($scope.date, validDateFormats).toDate(); // new Date($scope.date)
109
+ if ($scope.date) {
110
+ let parsedDate;
111
+ for (const format of validDateFormats) {
112
+ parsedDate = DateTime.fromFormat($scope.date, format);
113
+ if (parsedDate.isValid)
114
+ break;
115
+ }
116
+ pikadayOptions.defaultDate = parsedDate.toJSDate();
117
+ }
97
118
  pikaday = new pikaday_1.default(pikadayOptions);
98
119
  }, 0);
99
120
  $scope.requiredText = translateFactory.instant('JSUI.REQUIRED');
@@ -1 +1 @@
1
- {"version":3,"file":"date-input.js","sourceRoot":"","sources":["../../src/components/date-input/date-input.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,wEAAwC;AACxC,oDAA2B;AAC3B,sDAA6B;AAE7B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,kBAAkB,EAAE,SAAS,aAAa,CAAE,gBAAgB;QAE7G,OAAO;YACN,QAAQ,EAAE,GAAG;YACb,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE;gBACN,OAAO,EAAE,GAAG;gBACZ,UAAU,EAAE,GAAG;gBACf,QAAQ,EAAE,GAAG;gBACb,QAAQ,EAAE,GAAG;aACb;YACD,QAAQ,EAAR,yBAAQ;YACR,IAAI,EAAE,UAAU,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW;gBAEjD,yBAAyB;gBACzB,2CAA2C;gBAC3C,IAAI,gBA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,gBAAgB,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;YACvE,CAAC;SACD,CAAA;IACF,CAAC,CAAC,CAAC,CAAA"}
@@ -4,23 +4,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const angular_1 = __importDefault(require("angular"));
7
- const moment_1 = __importDefault(require("moment"));
7
+ const { DateTime } = require('luxon');
8
8
  angular_1.default.module('app').directive('mflyValidateDate', function mflyValidateDate() {
9
9
  function link($scope, $element, $attrs, $ctrl) {
10
10
  $ctrl.$validators.dateFormat = function (modelValue, viewValue) {
11
11
  var validDateFormats = [
12
- 'D-MMM-YYYY', 'D/MMM/YYYY',
13
- 'DD-MMM-YYYY', 'DD/MMM/YYYY',
14
- 'MM-DD-YYYY', 'MM/DD/YYYY',
15
- 'M-D-YYYY', 'M/D/YYYY',
16
- 'MM-DD-YY', 'MM/DD/YY',
17
- 'M-D-YY', 'M/D/YY'
12
+ 'd-MMM-yyyy', 'd/MMM/yyyy',
13
+ 'dd-MMM-yyyy', 'dd/MMM/yyyy',
14
+ 'MM-dd-yyyy', 'MM/dd/yyyy',
15
+ 'M-d-yyyy', 'M/d/yyyy',
16
+ 'MM-dd-yy', 'MM/dd/yy',
17
+ 'M-d-yy', 'M/d/yy'
18
18
  ];
19
19
  // Empty models shouldn't be "invalid" - that's covered by "required".
20
20
  if (viewValue === '') {
21
21
  return true;
22
22
  }
23
- return moment_1.default(viewValue, validDateFormats, true).isValid();
23
+ // Check if the date is valid according to any of the given formats
24
+ return validDateFormats.some(format => {
25
+ const parsed = DateTime.fromFormat(viewValue, format);
26
+ return parsed.isValid;
27
+ });
24
28
  };
25
29
  }
26
30
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-date.js","sourceRoot":"","sources":["../../src/components/date-input/validate-date.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAA2B;AAE3B,iBAAO,CAAC,MAAM,CAA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U;gBACtB,QAAQ,EAAE,QAAQ;aAClB,CAAC;YAED,sEAAsE;YACtE,IAAI,SAAS,KAAK,EAAE,EAAE;gBACrB,OAAO,IAAI,CAAC;aACZ;YAED,mEAAmE;YACnE,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;gBACrD,OAAO,MAAM,CAAC,OAAO,CAAA;YACtB,CAAC,CAAC,CAAA;QACH,CAAC,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,IAAI;KACV,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const angular_1 = __importDefault(require("angular"));
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const moment_1 = __importDefault(require("moment"));
8
+ const luxon_1 = require("luxon");
9
9
  angular_1.default.module('app').factory('dateTimeZoneFactory', function dateTimeZoneFactory() {
10
10
  const timeZones = [
11
11
  { value: -12, zone: 'IDLW - Internation Date Line West', display: 'IDLW' },
@@ -40,65 +40,78 @@ angular_1.default.module('app').factory('dateTimeZoneFactory', function dateTime
40
40
  { value: 11, zone: 'SBT - Solomon Islands Time', display: 'SBT' },
41
41
  { value: 12, zone: 'NZST - New Zealand Standard Time', display: 'NZST' }
42
42
  ];
43
- // using string validate on the datepicker gives us more control w moment's loose parsing
43
+ // using string validate on the datepicker gives us more control with luxon's parsing
44
44
  const validDateFormats = [
45
- 'D-MMMM-YYYY',
46
- 'D-MM-YYYY',
47
- 'D-M-YYYY',
48
- 'MMMM-D-YYYY',
49
- 'MM-D-YYYY',
50
- 'M-D-YYYY',
51
- 'D/MMMM/YYYY',
52
- 'D/MM/YYYY',
53
- 'D/M/YYYY',
54
- 'MMMM/D/YYYY',
55
- 'MM/D/YYYY',
56
- 'M/D/YYYY',
57
- 'D.MMMM.YYYY',
58
- 'D.MM.YYYY',
59
- 'D.M.YYYY',
60
- 'MMMM.D.YYYY',
61
- 'MM.D.YYYY',
62
- 'M.D.YYYY',
63
- 'D-MMMM-YY',
64
- 'D-MM-YY',
65
- 'D-M-YY',
66
- 'MMMM-D-YY',
67
- 'MM-D-YY',
68
- 'M-D-YY',
69
- 'D/MMMM/YY',
70
- 'D/MM/YY',
71
- 'D/M/YY',
72
- 'MMMM/D/YY',
73
- 'MM/D/YY',
74
- 'M/D/YY',
75
- 'D.MMMM.YY',
76
- 'D.MM.YY',
77
- 'D.M.YY',
78
- 'MMMM.D.YY',
79
- 'MM.D.YY',
80
- 'M.D.YY'
45
+ // Full month name formats (MMMM)
46
+ 'd-MMMM-yyyy',
47
+ 'd-MM-yyyy',
48
+ 'd-M-yyyy',
49
+ 'MMMM-d-yyyy',
50
+ 'MM-d-yyyy',
51
+ 'M-d-yyyy',
52
+ 'd/MMMM/yyyy',
53
+ 'd/MM/yyyy',
54
+ 'd/M/yyyy',
55
+ 'MMMM/d/yyyy',
56
+ 'MM/d/yyyy',
57
+ 'M/d/yyyy',
58
+ 'd.MMMM.yyyy',
59
+ 'd.MM.yyyy',
60
+ 'd.M.yyyy',
61
+ 'MMMM.d.yyyy',
62
+ 'MM.d.yyyy',
63
+ 'M.d.yyyy',
64
+ 'd-MMMM-yy',
65
+ 'd-MM-yy',
66
+ 'd-M-yy',
67
+ 'MMMM-d-yy',
68
+ 'MM-d-yy',
69
+ 'M-d-yy',
70
+ 'd/MMMM/yy',
71
+ 'd/MM/yy',
72
+ 'd/M/yy',
73
+ 'MMMM/d/yy',
74
+ 'MM/d/yy',
75
+ 'M/d/yy',
76
+ 'd.MMMM.yy',
77
+ 'd.MM.yy',
78
+ 'd.M.yy',
79
+ 'MMMM.d.yy',
80
+ 'MM.d.yy',
81
+ 'M.d.yy',
82
+ // Abbreviated month name formats (MMM)
83
+ 'd-MMM-yyyy',
84
+ 'MMM-d-yyyy',
85
+ 'd/MMM/yyyy',
86
+ 'MMM/d/yyyy',
87
+ 'd.MMM.yyyy',
88
+ 'MMM.d.yyyy',
89
+ 'd-MMM-yy',
90
+ 'MMM-d-yy',
91
+ 'd/MMM/yy',
92
+ 'MMM/d/yy',
93
+ 'd.MMM.yy',
94
+ 'MMM.d.yy'
81
95
  ];
82
96
  return {
83
97
  timeZones,
84
98
  validDateFormats,
85
- getTimeZone(momentDate) {
86
- if (momentDate.isValid()) {
99
+ getTimeZone(dateTime) {
100
+ if (dateTime && dateTime.isValid) {
87
101
  // Get the timezone offset in hours and adjust the sign
88
- let zoneOffset = (momentDate.utcOffset() / 60);
102
+ let zoneOffset = dateTime.offset / 60;
89
103
  // consider a shift for DST
90
- // must use isDST on a frest moment object -
91
- // the passed variable is parsedZone and thus will always return isDST false
92
- const isDST = moment_1.default(momentDate.format()).isDST();
93
- // at this point zoneOffest is our true offest from UTC 0
94
- // so for example if we are UTC -6 AND we are DST, then our moment is really "Mountain Time" which is is -7
104
+ // create a fresh DateTime to check if DST is in effect
105
+ const isDST = luxon_1.DateTime.fromISO(dateTime.toISO()).isInDST;
106
+ // at this point zoneOffset is our true offset from UTC 0
107
+ // so for example if we are UTC -6 AND we are DST, then our dateTime is really "Mountain Time" which is -7
95
108
  // during the winter but is -6 during DST -- if we want to consistently show the label 'MST' for this date
96
- // we need to select -7 although the offset is -6 (or subtracting 1 from our actyual utc output)
109
+ // we need to select -7 although the offset is -6 (or subtracting 1 from our actual utc output)
97
110
  zoneOffset = (isDST) ? zoneOffset - 1 : zoneOffset;
98
111
  // NOTE: The above DST adjustment is somewhat arbitrary.
99
112
  // isDST() cannot be globally accurate as it works purely off a date and an offset.
100
- // No actual timezone information is used except for assumptins made from the users current locale.
101
- // Recommendation to switch to moment's timezone.js in the future.
113
+ // No actual timezone information is used except for assumptions made from the users current locale.
114
+ // Recommendation to switch to luxon's timezone handling in the future.
102
115
  return this.getTimeZoneByOffset(zoneOffset);
103
116
  }
104
117
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"date-time-zone-factory.js","sourceRoot":"","sources":["../../src/components/date-time-zone-picker/date-time-zone-factory.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAAsB;AACtB,oDAA2B;AAE3B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,mBAAmB;IAEhF,MAAM,SAAS,GAAG;QACjB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,mCAAmC,EAAE,OAAO,EAAE,MAAM,EAAE;QAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,KAAK,EAAE;QACjE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,OAAO,EAAE,KAAK,EAAE;QACpE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,6BAA6B,EAAE,OAAO,EAAE,MAAM,EAAE;QACnE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;QACvD,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,IAAI,EAAE;QACxD,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;QACvD,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;QACvD,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,OAAO,EAAE,KAAK,EAAE;QACnE,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,kCAAkC,EAAE,OAAO,EAAE,KAAK,EAAE;QACzE,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C,SAAS,EAAE,GAAG,EAAE,CAAC,CAAA;gBAE9C,2BAA2B;gBAC3B,4CAA4C;gBAC5C,4EAA4E;gBAC5E,MAAM,KAAK,GAAG,gBAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;gBAEjD,yDAAyD;gBACzD,2GAA2G;gBAC3G,0GAA0G;gBAC1G,gGAAgG;gBAChG,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;gBAElD,wDAAwD;gBACxD,mFAAmF;gBACnF,mGAAmG;gBACnG,kEAAkE;gBAElE,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;aAC3C;YAED,OAAO,IAAI,CAAA;QACZ,CAAC;QAED,mBAAmB,CAAC,MAAM;YAEzB,OAAO,gBAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAC5C,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"date-time-zone-factory.js","sourceRoot":"","sources":["../../src/components/date-time-zone-picker/date-time-zone-factory.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAAsB;AACtB,iCAAgC;AAEhC,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,mBAAmB;IAEhF,MAAM,SAAS,GAAG;QACjB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,mCAAmC,EAAE,OAAO,EAAE,MAAM,EAAE;QAC1E,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,KAAK,EAAE;QACjE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,OAAO,EAAE,KAAK,EAAE;QACpE,EA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AAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;aAC3C;YAED,OAAO,IAAI,CAAA;QACZ,CAAC;QAED,mBAAmB,CAAC,MAAM;YAEzB,OAAO,gBAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAC5C,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA"}
@@ -6,18 +6,18 @@
6
6
  input-id="{{ inputId }}"
7
7
  is-disabled="isDisabled"
8
8
  is-required="{{ isRequired }}"
9
- date-moment="dateMoment"
9
+ date-luxon="dateLuxon"
10
10
  on-open="pickerOpened()"
11
11
  on-date-change="updateDate(newDate)">
12
12
  </mfly:date-picker>
13
13
  </div>
14
14
 
15
- <div class="o-col-xs-7" ng-show="type === 'datetime' && dateMoment && !isDisabled">
15
+ <div class="o-col-xs-7" ng-show="type === 'datetime' && dateLuxon && !isDisabled">
16
16
  <mfly:time-picker
17
17
  input-id="{{ inputId }}Time"
18
- time-moment="timeMoment"
18
+ time-luxon="timeLuxon"
19
19
  ng-show="!isDisabled"
20
- on-time-change="updateTime()">
20
+ on-time-change="updateTime(newTime)">
21
21
  </mfly:time-picker>
22
22
 
23
23
  <mfly:time-zone-picker
@@ -28,9 +28,9 @@
28
28
  </div>
29
29
 
30
30
  <!-- If the time is disabled, show plain text instead of controls -->
31
- <div class="o-col-xs-7" ng-show="type === 'datetime' && dateMoment && isDisabled">
31
+ <div class="o-col-xs-7" ng-show="type === 'datetime' && dateLuxon && isDisabled">
32
32
  <div class="pull-left disabled">
33
- <span>{{ parentMoment.format('hh:mm a') }} {{ (timeZone) ? timeZone.display : '' }}</span>
33
+ <span>{{ parentLuxon.toFormat('hh:mm a') }} {{ (timeZone) ? timeZone.display : '' }}</span>
34
34
  </div>
35
35
  </div>
36
36
  </div>
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const angular_1 = __importDefault(require("angular"));
7
- const moment_1 = __importDefault(require("moment"));
7
+ const luxon_1 = require("luxon");
8
8
  angular_1.default.module('app').directive('mflyDateTimeZonePicker', ['dateTimeZoneFactory', function mflyDateTimeZonePicker(dateTimeZoneFactory) {
9
9
  return {
10
10
  restrict: 'E',
@@ -19,106 +19,166 @@ angular_1.default.module('app').directive('mflyDateTimeZonePicker', ['dateTimeZo
19
19
  },
20
20
  template: require('./date-time-zone-picker.html'),
21
21
  link($scope, _element, _attr, ngModelCtrl) {
22
- // Init function creates moment dates from our utc string provided by the API
23
- // These moment dates are bound to the datepicker and timepicker (the
24
- // timezone object is also created but is not a moment)
25
- // Each component only alters its respective moment date, then tells this
22
+ // Init function creates DateTime dates from our utc string provided by the API
23
+ // These DateTime dates are bound to the datepicker and timepicker (the
24
+ // timezone object is also created but is not a DateTime)
25
+ // Each component only alters its respective DateTime date, then tells this
26
26
  // component when a change is made
27
27
  // When a change is made, this component combines the 3 datetime elements
28
28
  // and sends a utc string back to the api
29
29
  // ------------------------------------------------------------------
30
- function initParentMomentFromAPI(value) {
31
- // Create a base moment and bound copies for each child component.
32
- $scope.parentMoment = moment_1.default.parseZone(value);
33
- $scope.timeMoment = moment_1.default({ hour: $scope.parentMoment.hour(), minute: $scope.parentMoment.minute() });
34
- $scope.dateMoment = moment_1.default({ year: $scope.parentMoment.year(), month: $scope.parentMoment.month(), date: $scope.parentMoment.date() });
35
- // The timezone component takes a custom timezone object instead of
36
- // a moment. The factory returns a timezone, adjusting for DST.
37
- $scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentMoment);
30
+ function initParentLuxonFromAPI(value) {
31
+ // Create a base DateTime and bound copies for each child component.
32
+ if (value instanceof Date) {
33
+ $scope.parentLuxon = luxon_1.DateTime.fromJSDate(value);
34
+ }
35
+ else if (typeof value === 'string') {
36
+ // Parse with setZone: true to preserve the offset from the string
37
+ const dt = luxon_1.DateTime.fromISO(value, { setZone: true });
38
+ // Calculate offset in hours (including minutes as decimal)
39
+ const offset = dt.offset / 60;
40
+ // Find the matching time zone object
41
+ const matchedZone = dateTimeZoneFactory.getTimeZoneByOffset(offset);
42
+ // If found, set the zone on the DateTime object
43
+ if (matchedZone) {
44
+ // Format offset as UTC±HH:MM for non-integer offsets
45
+ const absOffset = Math.abs(matchedZone.value);
46
+ const hours = Math.floor(absOffset);
47
+ const minutes = Math.round((absOffset - hours) * 60);
48
+ const sign = matchedZone.value >= 0 ? '+' : '-';
49
+ const zoneString = minutes === 0
50
+ ? `UTC${sign}${hours}`
51
+ : `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
52
+ $scope.parentLuxon = dt.setZone(zoneString, { keepLocalTime: true });
53
+ $scope.timeZone = matchedZone;
54
+ }
55
+ else {
56
+ // Fallback: just use the parsed DateTime
57
+ $scope.parentLuxon = dt;
58
+ $scope.timeZone = null;
59
+ }
60
+ }
61
+ else {
62
+ throw new Error(`Invalid value type ${typeof value} (${value})`);
63
+ }
64
+ $scope.timeLuxon = luxon_1.DateTime.fromObject({ hour: $scope.parentLuxon.hour, minute: $scope.parentLuxon.minute, second: 0, millisecond: 0 });
65
+ $scope.dateLuxon = luxon_1.DateTime.fromObject({ year: $scope.parentLuxon.year, month: $scope.parentLuxon.month, day: $scope.parentLuxon.day });
38
66
  }
39
- function initParentMomentFromDatePicker(newDate) {
67
+ function initParentLuxonFromDatePicker(newDate) {
40
68
  // when selecting a date from null or for the first time we need to
41
- // initialize the parentMoment
42
- $scope.parentMoment = moment_1.default();
43
- // the dateMoment is set by the datepicker, but we want to update the parent
44
- // moment to have the same date
45
- $scope.parentMoment.month(newDate.month());
46
- $scope.parentMoment.year(newDate.year());
47
- $scope.parentMoment.date(newDate.date());
48
- // we then init the timeMoment with a default of 12:00am
49
- $scope.timeMoment = moment_1.default('12:00 AM', 'hh:mm A');
50
- // parent moment will have the now, but should also inisially have 12:00am
51
- $scope.parentMoment.hour($scope.timeMoment.hour());
52
- $scope.parentMoment.minute($scope.timeMoment.minute());
53
- // and init the time zone from the users's local time zone as we did in the initFromAPI funciton
54
- $scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentMoment);
69
+ // initialize the parentLuxon
70
+ $scope.parentLuxon = luxon_1.DateTime.now();
71
+ // the dateLuxon is set by the datepicker, but we want to update the parent
72
+ // luxon to have the same date
73
+ $scope.parentLuxon = $scope.parentLuxon.set({
74
+ month: newDate.month,
75
+ year: newDate.year,
76
+ day: newDate.day
77
+ });
78
+ // we then init the timeLuxon with a default of 12:00am
79
+ $scope.timeLuxon = luxon_1.DateTime.fromFormat('12:00 AM', 'hh:mm a');
80
+ // parent luxon will have the now, but should also initially have 12:00am
81
+ $scope.parentLuxon = $scope.parentLuxon.set({
82
+ hour: $scope.timeLuxon.hour,
83
+ minute: $scope.timeLuxon.minute,
84
+ second: 0,
85
+ millisecond: 0,
86
+ });
87
+ // and init the time zone from the users's local time zone as we did in the initFromAPI function
88
+ $scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentLuxon);
55
89
  }
56
90
  // Formatter runs when incoming values come from the model - this is
57
- // where we initialize our moment.
91
+ // where we initialize our DateTime.
58
92
  ngModelCtrl.$formatters.push(function (modelValue) {
59
93
  if (modelValue) {
60
- initParentMomentFromAPI(modelValue);
94
+ initParentLuxonFromAPI(modelValue);
61
95
  }
62
96
  else {
63
97
  // If we don't have a value, we should insure we clear the control
64
98
  // by passing NULL to the update function.
65
- $scope.dateMoment = null;
99
+ $scope.dateLuxon = null;
66
100
  }
67
101
  return modelValue;
68
102
  });
69
103
  ngModelCtrl.$parsers.push(function (modelValue) {
70
104
  return modelValue;
71
105
  });
72
- function updateAPIFromMoment() {
73
- if ($scope.parentMoment) {
74
- ngModelCtrl.$setViewValue($scope.parentMoment.format());
106
+ function updateAPIFromLuxon() {
107
+ if ($scope.parentLuxon) {
108
+ ngModelCtrl.$setViewValue($scope.parentLuxon.toISO());
75
109
  }
76
110
  else {
77
111
  ngModelCtrl.$setViewValue(null);
78
112
  }
79
113
  }
80
114
  $scope.updateDate = function (newDate) {
81
- // This is fired when the datepicker has updated the date portion of the moment
82
- // Update the parentMoment with only the date change
115
+ // This is fired when the datepicker has updated the date portion of the DateTime
116
+ // Update the parentLuxon with only the date change
83
117
  if (newDate) {
84
- if ($scope.parentMoment) {
85
- // if we have a parent moment update it
86
- $scope.parentMoment.month(newDate.month());
87
- $scope.parentMoment.year(newDate.year());
88
- $scope.parentMoment.date(newDate.date());
118
+ // Update dateLuxon to reflect the new date (needed for template visibility)
119
+ $scope.dateLuxon = newDate;
120
+ if ($scope.parentLuxon) {
121
+ // if we have a parent luxon update it
122
+ $scope.parentLuxon = $scope.parentLuxon.set({
123
+ month: newDate.month,
124
+ year: newDate.year,
125
+ day: newDate.day
126
+ });
89
127
  }
90
128
  else {
91
- // if we do not have a parent moment b/c no previous date existed
92
- initParentMomentFromDatePicker(newDate);
129
+ // if we do not have a parent luxon b/c no previous date existed
130
+ initParentLuxonFromDatePicker(newDate);
93
131
  }
94
132
  }
95
133
  else {
96
134
  // we are clearing out a date
97
- $scope.parentMoment = '';
135
+ $scope.dateLuxon = null;
136
+ $scope.parentLuxon = null;
98
137
  }
99
- // changing between DST could alter our UTC offest
138
+ // changing between DST could alter our UTC offset
100
139
  // this adjustment happens in updateTimeZone which we can call here
101
- $scope.updateTimeZone($scope.timeZone.value);
140
+ if ($scope.timeZone) {
141
+ $scope.updateTimeZone($scope.timeZone.value);
142
+ }
143
+ updateAPIFromLuxon();
102
144
  };
103
- $scope.updateTime = function () {
104
- // This is fired when the timepicker has updated the time portion of the moment
105
- // Update the parentMoment with only the time change
106
- $scope.parentMoment.hour($scope.timeMoment.hour());
107
- $scope.parentMoment.minute($scope.timeMoment.minute());
108
- updateAPIFromMoment();
145
+ $scope.updateTime = function (newTime) {
146
+ // This is fired when the timepicker has updated the time portion of the DateTime
147
+ // Update the parentLuxon with only the time change
148
+ $scope.parentLuxon = $scope.parentLuxon.set({
149
+ hour: newTime.hour,
150
+ minute: newTime.minute,
151
+ second: 0,
152
+ millisecond: 0,
153
+ });
154
+ updateAPIFromLuxon();
109
155
  };
110
156
  $scope.updateTimeZone = function (zoneOffset) {
111
- if ($scope.parentMoment !== '') {
112
- // The zone offest displays with a dst offset (see date-time-zone-factory for details)
157
+ if ($scope.parentLuxon !== '') {
158
+ // The zone offset displays with a dst offset (see date-time-zone-factory for details)
113
159
  // When we save back to the API we need to re-account for that offset
114
- // Create a moment to determine if we are dst
115
- const isDST = moment_1.default($scope.parentMoment.format()).isDST();
160
+ // Create a DateTime to determine if we are dst
161
+ const isDST = luxon_1.DateTime.fromISO($scope.parentLuxon.toISO()).isInDST;
116
162
  // adjust the zoneOffset passed from the UI if the date is dst
117
163
  zoneOffset = (isDST) ? zoneOffset + 1 : zoneOffset;
118
- // update the zone/offset change
119
- $scope.parentMoment.utcOffset(zoneOffset, true);
164
+ // Convert fractional hours to HH:MM format for Luxon
165
+ // Luxon expects UTC offsets in the format "UTC+HH:MM" or "UTC-HH:MM"
166
+ const sign = zoneOffset >= 0 ? '+' : '-';
167
+ const absOffset = Math.abs(zoneOffset);
168
+ const hours = Math.floor(absOffset);
169
+ const minutes = Math.round((absOffset - hours) * 60);
170
+ let zoneString;
171
+ if (minutes === 0) {
172
+ // For whole hours, we can use the simple format like "UTC+3" or "UTC-5"
173
+ zoneString = `UTC${sign}${hours}`;
174
+ }
175
+ else {
176
+ // For fractional hours, we need the HH:MM format like "UTC+03:30" or "UTC-03:30"
177
+ zoneString = `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
178
+ }
179
+ $scope.parentLuxon = $scope.parentLuxon.setZone(zoneString, { keepLocalTime: true });
120
180
  }
121
- updateAPIFromMoment();
181
+ updateAPIFromLuxon();
122
182
  };
123
183
  $scope.pickerOpened = function () {
124
184
  $scope.onOpen();