@mediafly/js-ui 51.3.2 → 51.3.3-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 +4 -0
- package/lib/constants/constants.js +2 -1
- package/lib/constants/constants.js.map +1 -1
- package/lib/date-input/date-input.js +33 -12
- package/lib/date-input/date-input.js.map +1 -1
- package/lib/date-input/validate-date.js +12 -8
- package/lib/date-input/validate-date.js.map +1 -1
- package/lib/date-time-zone-picker/date-time-zone-factory.js +62 -49
- package/lib/date-time-zone-picker/date-time-zone-factory.js.map +1 -1
- package/lib/date-time-zone-picker/date-time-zone-picker.html +1 -1
- package/lib/date-time-zone-picker/date-time-zone-picker.js +82 -37
- package/lib/date-time-zone-picker/date-time-zone-picker.js.map +1 -1
- package/lib/date-time-zone-picker/datepicker.html +1 -2
- package/lib/date-time-zone-picker/datepicker.js +71 -19
- package/lib/date-time-zone-picker/datepicker.js.map +1 -1
- package/lib/date-time-zone-picker/time-format-filter.js +6 -6
- package/lib/date-time-zone-picker/time-format-filter.js.map +1 -1
- package/lib/date-time-zone-picker/timepicker.js +35 -20
- package/lib/date-time-zone-picker/timepicker.js.map +1 -1
- package/lib/time-input/time-input.js +27 -23
- package/lib/time-input/time-input.js.map +1 -1
- package/lib/time-input/validate-time.js +6 -2
- package/lib/time-input/validate-time.js.map +1 -1
- package/lib/tsconfig.deploy.tsbuildinfo +166 -24
- package/package.json +4 -4
- package/src/components/constants/constants.js +2 -1
- package/src/components/date-input/date-input.js +31 -12
- package/src/components/date-input/validate-date.js +14 -10
- package/src/components/date-time-zone-picker/date-time-zone-factory.ts +62 -49
- package/src/components/date-time-zone-picker/date-time-zone-picker.html +1 -1
- package/src/components/date-time-zone-picker/date-time-zone-picker.ts +87 -44
- package/src/components/date-time-zone-picker/datepicker.html +1 -2
- package/src/components/date-time-zone-picker/datepicker.ts +76 -20
- package/src/components/date-time-zone-picker/time-format-filter.ts +6 -6
- package/src/components/date-time-zone-picker/timepicker.js +46 -28
- package/src/components/time-input/time-input.js +27 -24
- package/src/components/time-input/validate-time.js +6 -2
- package/src/index.spec.js +1 -1
- package/webpack.config.js +6 -0
- package/tsconfig.tsbuildinfo +0 -7221
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import angular from 'angular'
|
|
2
2
|
import template from './timepicker.html'
|
|
3
|
-
|
|
3
|
+
const { DateTime } = require('luxon')
|
|
4
4
|
|
|
5
|
-
angular.module('app').directive('mflyTimePicker', ['translateFactory', function mflyTimePicker
|
|
5
|
+
angular.module('app').directive('mflyTimePicker', ['translateFactory', function mflyTimePicker(translateFactory) {
|
|
6
6
|
|
|
7
7
|
return {
|
|
8
8
|
restrict: 'E',
|
|
@@ -13,13 +13,15 @@ angular.module('app').directive('mflyTimePicker', ['translateFactory', function
|
|
|
13
13
|
onTimeChange: '&'
|
|
14
14
|
},
|
|
15
15
|
template,
|
|
16
|
-
link: function($scope) {
|
|
16
|
+
link: function ($scope) {
|
|
17
17
|
var validTimeFormats = [
|
|
18
18
|
'h:mm',
|
|
19
19
|
'h:mm A',
|
|
20
20
|
'h:mmA'
|
|
21
21
|
];
|
|
22
22
|
|
|
23
|
+
const luxonFormats = ['H:mm', 'h:mm a', 'h:mma'];
|
|
24
|
+
|
|
23
25
|
$scope.timeValue = {
|
|
24
26
|
time: '',
|
|
25
27
|
initialized: false
|
|
@@ -34,13 +36,23 @@ angular.module('app').directive('mflyTimePicker', ['translateFactory', function
|
|
|
34
36
|
// programmatically, we need to update the time picker accordingly.
|
|
35
37
|
$scope.$watch('timeMoment', function (newValue) {
|
|
36
38
|
if (newValue) {
|
|
37
|
-
$scope.timeValue.time = $scope.timeMoment.
|
|
39
|
+
$scope.timeValue.time = $scope.timeMoment.toFormat('h:mm a');
|
|
38
40
|
}
|
|
39
41
|
});
|
|
40
42
|
|
|
41
|
-
$scope.validateTime = function() {
|
|
43
|
+
$scope.validateTime = function () {
|
|
42
44
|
if ($scope.timeValue.time) {
|
|
43
|
-
var isValid =
|
|
45
|
+
var isValid = false;
|
|
46
|
+
|
|
47
|
+
// Try each format until one works
|
|
48
|
+
for (const format of luxonFormats) {
|
|
49
|
+
const parsed = DateTime.fromFormat($scope.timeValue.time, format);
|
|
50
|
+
if (parsed.isValid) {
|
|
51
|
+
isValid = true;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
$scope.form.validation.mflyTimepicker.$setValidity('invalidTime', isValid);
|
|
45
57
|
if (isValid) {
|
|
46
58
|
processTime();
|
|
@@ -51,13 +63,13 @@ angular.module('app').directive('mflyTimePicker', ['translateFactory', function
|
|
|
51
63
|
}
|
|
52
64
|
};
|
|
53
65
|
|
|
54
|
-
//watch necessary to style
|
|
55
|
-
$scope.$watch('form.validation.mflyTimepicker', function(newValue){
|
|
66
|
+
//watch necessary to style preceding add-on element (CSS has no prev sibling selector)
|
|
67
|
+
$scope.$watch('form.validation.mflyTimepicker', function (newValue) {
|
|
56
68
|
if (newValue) {
|
|
57
|
-
$scope.$watch('form.validation.mflyTimepicker.$valid', function(newValue){
|
|
69
|
+
$scope.$watch('form.validation.mflyTimepicker.$valid', function (newValue) {
|
|
58
70
|
$scope.invalidAddOn = !newValue;
|
|
59
71
|
});
|
|
60
|
-
$scope.$watch('form.validation.mflyTimepicker.$dirty', function(newValue){
|
|
72
|
+
$scope.$watch('form.validation.mflyTimepicker.$dirty', function (newValue) {
|
|
61
73
|
$scope.dirtyAddOn = newValue;
|
|
62
74
|
});
|
|
63
75
|
}
|
|
@@ -65,11 +77,18 @@ angular.module('app').directive('mflyTimePicker', ['translateFactory', function
|
|
|
65
77
|
|
|
66
78
|
function processTime() {
|
|
67
79
|
if ($scope.timeValue.time && $scope.form.validation.mflyTimepicker.$valid) {
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
let tempDateTime;
|
|
81
|
+
for (const format of luxonFormats) {
|
|
82
|
+
tempDateTime = DateTime.fromFormat($scope.timeValue.time, format);
|
|
83
|
+
if (tempDateTime.isValid) break;
|
|
84
|
+
}
|
|
70
85
|
|
|
71
|
-
$scope.timeMoment.
|
|
72
|
-
|
|
86
|
+
$scope.timeMoment = $scope.timeMoment.set({
|
|
87
|
+
hour: tempDateTime.hour,
|
|
88
|
+
minute: tempDateTime.minute,
|
|
89
|
+
second: 0,
|
|
90
|
+
millisecond: 0,
|
|
91
|
+
});
|
|
73
92
|
|
|
74
93
|
//callback to the parent component
|
|
75
94
|
$scope.onTimeChange();
|
|
@@ -81,29 +100,28 @@ angular.module('app').directive('mflyTimePicker', ['translateFactory', function
|
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
|
|
84
|
-
function populateDropdown(){
|
|
103
|
+
function populateDropdown() {
|
|
85
104
|
if ($scope.timeMoment) {
|
|
86
|
-
$scope.timeValue.time = $scope.timeMoment.
|
|
105
|
+
$scope.timeValue.time = $scope.timeMoment.toFormat('hh:mm a');
|
|
87
106
|
}
|
|
88
107
|
|
|
89
|
-
//
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
var todaysDate =
|
|
108
|
+
// Populate the drop down with available times
|
|
109
|
+
var tempDateTime = DateTime.now().startOf('day');
|
|
110
|
+
|
|
111
|
+
var todaysDate = tempDateTime.day;
|
|
93
112
|
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
tempMoment.minute(0);
|
|
113
|
+
// Starting from 12:00 am
|
|
114
|
+
tempDateTime = tempDateTime.set({ hour: 0, minute: 0, second: 0, millisecond: 0 });
|
|
97
115
|
|
|
98
|
-
//
|
|
116
|
+
// Add a time entry on every 30 minutes
|
|
99
117
|
do {
|
|
100
|
-
$scope.dropdownItems.push(
|
|
101
|
-
|
|
102
|
-
} while (todaysDate ===
|
|
118
|
+
$scope.dropdownItems.push(tempDateTime.toFormat('hh:mm a'));
|
|
119
|
+
tempDateTime = tempDateTime.plus({ minutes: 30 });
|
|
120
|
+
} while (todaysDate === tempDateTime.day);
|
|
103
121
|
}
|
|
104
122
|
|
|
105
123
|
|
|
106
|
-
$scope.itemClicked = function(itemValue){
|
|
124
|
+
$scope.itemClicked = function (itemValue) {
|
|
107
125
|
$scope.form.validation.mflyTimepicker.$setDirty();
|
|
108
126
|
$scope.timeValue.time = itemValue;
|
|
109
127
|
$scope.validateTime();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import angular from 'angular'
|
|
2
2
|
import template from './time-input.html'
|
|
3
|
-
|
|
3
|
+
const { DateTime } = require('luxon')
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
angular.module('app').directive('mflyTimeInput', [
|
|
@@ -28,13 +28,6 @@ angular.module('app').directive('mflyTimeInput', [
|
|
|
28
28
|
// ----------------------------------------
|
|
29
29
|
$scope.vm = {};
|
|
30
30
|
|
|
31
|
-
// See: https://momentjs.com/docs/#/parsing/string-format/
|
|
32
|
-
var validTimeFormats = [
|
|
33
|
-
'H:mm',
|
|
34
|
-
'h:mm A',
|
|
35
|
-
'h:mmA'
|
|
36
|
-
];
|
|
37
|
-
|
|
38
31
|
// Format the ng-model value as a time string.
|
|
39
32
|
// The result of this function is assigned to `ngModelCtrl.$viewValue`.
|
|
40
33
|
ngModelCtrl.$formatters.push(function (nativeDate) {
|
|
@@ -43,7 +36,7 @@ angular.module('app').directive('mflyTimeInput', [
|
|
|
43
36
|
return '';
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
return
|
|
39
|
+
return DateTime.fromJSDate(nativeDate).toFormat('h:mm a');
|
|
47
40
|
});
|
|
48
41
|
|
|
49
42
|
// Display the time string in the UI.
|
|
@@ -67,15 +60,25 @@ angular.module('app').directive('mflyTimeInput', [
|
|
|
67
60
|
// component of "today". If a model value exists, we need to set the
|
|
68
61
|
// outgoing date object's date part back to the original model value
|
|
69
62
|
// since the user did not intend to change that part.
|
|
70
|
-
|
|
63
|
+
let targetDateTime;
|
|
64
|
+
const luxonFormats = ['H:mm', 'h:mm a', 'h:mma'];
|
|
65
|
+
|
|
66
|
+
// Try each format until one works
|
|
67
|
+
for (const format of luxonFormats) {
|
|
68
|
+
targetDateTime = DateTime.fromFormat(viewValue, format);
|
|
69
|
+
if (targetDateTime.isValid) break;
|
|
70
|
+
}
|
|
71
71
|
|
|
72
72
|
if (ngModelCtrl.$modelValue) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const modelDateTime = DateTime.fromJSDate(ngModelCtrl.$modelValue);
|
|
74
|
+
targetDateTime = targetDateTime.set({
|
|
75
|
+
year: modelDateTime.year,
|
|
76
|
+
month: modelDateTime.month,
|
|
77
|
+
day: modelDateTime.day
|
|
78
|
+
});
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
return
|
|
81
|
+
return targetDateTime.toJSDate();
|
|
79
82
|
});
|
|
80
83
|
|
|
81
84
|
// When the user input changes the scope model, push it through the
|
|
@@ -91,15 +94,15 @@ angular.module('app').directive('mflyTimeInput', [
|
|
|
91
94
|
|
|
92
95
|
// Time dropdown
|
|
93
96
|
// ----------------------------------------
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
const beginningOfToday = DateTime.now().startOf('day');
|
|
98
|
+
let timeCursor = beginningOfToday;
|
|
96
99
|
$scope.dropdownEntries = [];
|
|
97
100
|
|
|
98
101
|
// Populate time entries for all 30-min intervals on today's date
|
|
99
102
|
do {
|
|
100
|
-
$scope.dropdownEntries.push(timeCursor.
|
|
101
|
-
timeCursor.
|
|
102
|
-
} while (timeCursor.
|
|
103
|
+
$scope.dropdownEntries.push(timeCursor.toFormat('h:mm a'));
|
|
104
|
+
timeCursor = timeCursor.plus({ minutes: 30 });
|
|
105
|
+
} while (timeCursor.day === beginningOfToday.day);
|
|
103
106
|
|
|
104
107
|
// When a time is clicked, update the view model
|
|
105
108
|
$scope.setTime = function (timeString) {
|
|
@@ -123,15 +126,15 @@ angular.module('app').directive('mflyTimeInput', [
|
|
|
123
126
|
function entriesForTime (time) {
|
|
124
127
|
|
|
125
128
|
// Find the number of minutes until our target time.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
const target = DateTime.fromJSDate(time);
|
|
130
|
+
const midnight = target.startOf('day');
|
|
131
|
+
const minutesFromMidnight = target.diff(midnight, 'minutes').minutes;
|
|
129
132
|
|
|
130
133
|
// Round up to the next 30 minute interval.
|
|
131
|
-
|
|
134
|
+
const roundedMinutes = Math.ceil((minutesFromMidnight + 1) / 30) * 30;
|
|
132
135
|
|
|
133
136
|
// Divide by 30 to get number of places we should scroll down.
|
|
134
|
-
return
|
|
137
|
+
return roundedMinutes / 30;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
// If `dropdownDefault` is specified by the consumer, we should
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import angular from 'angular'
|
|
2
|
-
|
|
2
|
+
const { DateTime } = require('luxon')
|
|
3
3
|
|
|
4
4
|
angular.module('app').directive('mflyValidateTime', function mflyValidateTime () {
|
|
5
5
|
|
|
@@ -19,7 +19,11 @@ angular.module('app').directive('mflyValidateTime', function mflyValidateTime ()
|
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// Check if the time is valid according to the given formats
|
|
23
|
+
return validTimeFormats.some(format => {
|
|
24
|
+
const parsed = DateTime.fromFormat(viewValue, format === 'H:mm' ? 'H:mm' : 'h:mm a')
|
|
25
|
+
return parsed.isValid
|
|
26
|
+
})
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
29
|
|
package/src/index.spec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index'
|
|
2
2
|
|
|
3
|
-
import './app/canary.spec'
|
|
3
|
+
import './app/canary.spec.ts'
|
|
4
4
|
import './components/auto-complete/tests/auto-complete-match-renderer.spec'
|
|
5
5
|
import './components/auto-complete/tests/auto-complete.spec'
|
|
6
6
|
import './components/auto-focus/tests/auto-focus.spec'
|
package/webpack.config.js
CHANGED
|
@@ -219,6 +219,12 @@ module.exports = function (env) {
|
|
|
219
219
|
],
|
|
220
220
|
resolve: {
|
|
221
221
|
extensions: ['.js', '.ts', '*'],
|
|
222
|
+
alias: {
|
|
223
|
+
// Ignore moment import in pikaday since we've migrated to luxon
|
|
224
|
+
moment: false,
|
|
225
|
+
// Force luxon to use ES6 build for proper import support
|
|
226
|
+
'luxon': path.resolve(__dirname, 'node_modules/luxon/build/es6/luxon.js'),
|
|
227
|
+
},
|
|
222
228
|
plugins: [
|
|
223
229
|
new TsConfigPathsPlugin(),
|
|
224
230
|
],
|