@datarobot/design-system 29.7.7 → 29.7.9
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/cjs/scheduler/utils.d.ts +2 -2
- package/cjs/scheduler/utils.js +80 -78
- package/cjs/scheduler/utils.test.js +3 -3
- package/esm/scheduler/utils.d.ts +2 -2
- package/esm/scheduler/utils.js +80 -78
- package/esm/scheduler/utils.test.js +3 -3
- package/js/bundle/bundle.js +27031 -26992
- package/js/bundle/bundle.min.js +1 -1
- package/js/bundle/index.d.ts +2 -2
- package/package.json +2 -2
package/cjs/scheduler/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Frequency, Schedule, ScheduleValidity } from './constants';
|
|
2
2
|
export declare const stringToArrayOfNumbersOrAll: (value?: string | number) => (number | "*")[];
|
|
3
3
|
export declare function useArrayOfRangedNumbersOrAllValidator(): ({ min, max, values, allowAll, }: ScheduleValidity) => ScheduleValidity | undefined;
|
|
4
|
-
export declare function useGetScheduleString(schedule: Schedule, stringOptions?: {
|
|
4
|
+
export declare function useGetScheduleString(): (schedule: Schedule, stringOptions?: {
|
|
5
5
|
complexScheduleString?: string | null;
|
|
6
6
|
timeStandardString?: string | null;
|
|
7
|
-
})
|
|
7
|
+
}) => string | null;
|
|
8
8
|
export declare function getFrequency({ minute, hour, month, dayOfMonth, dayOfWeek, }: Schedule): Frequency | undefined;
|
package/cjs/scheduler/utils.js
CHANGED
|
@@ -63,91 +63,93 @@ function useArrayOfRangedNumbersOrAllValidator() {
|
|
|
63
63
|
return validity;
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
function useGetScheduleString(
|
|
66
|
+
function useGetScheduleString() {
|
|
67
67
|
const {
|
|
68
68
|
t
|
|
69
69
|
} = (0, _useTranslation.useTranslation)();
|
|
70
|
-
const {
|
|
71
|
-
complexScheduleString = t('Complex schedule'),
|
|
72
|
-
timeStandardString = t('(UTC)')
|
|
73
|
-
} = stringOptions;
|
|
74
|
-
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
75
70
|
const months = (0, _constants.useMonths)();
|
|
76
71
|
const daysOfWeek = (0, _constants.useDaysOfWeek)();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
case _constants.FREQUENCIES.WEEKLY:
|
|
90
|
-
{
|
|
91
|
-
const options = {
|
|
92
|
-
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
93
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
94
|
-
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
95
|
-
};
|
|
96
|
-
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
97
|
-
...options
|
|
98
|
-
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
99
|
-
...options
|
|
72
|
+
return (schedule, stringOptions = {}) => {
|
|
73
|
+
const {
|
|
74
|
+
complexScheduleString = t('Complex schedule'),
|
|
75
|
+
timeStandardString = t('(UTC)')
|
|
76
|
+
} = stringOptions;
|
|
77
|
+
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
78
|
+
switch (getFrequency(schedule)) {
|
|
79
|
+
case _constants.FREQUENCIES.HOURLY:
|
|
80
|
+
return schedule?.minute?.[0] === 1 ? t('Hourly at {{minutes}} minute past the hour', {
|
|
81
|
+
minutes: schedule.minute[0].toString()
|
|
82
|
+
}) : t('Hourly at {{minutes}} minutes past the hour', {
|
|
83
|
+
minutes: schedule?.minute?.[0].toString()
|
|
100
84
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
case _constants.FREQUENCIES.MONTHLY:
|
|
104
|
-
{
|
|
105
|
-
const options = {
|
|
85
|
+
case _constants.FREQUENCIES.DAILY:
|
|
86
|
+
return `${t('Daily at {{hour}}:{{minutes}}', {
|
|
106
87
|
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
107
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
88
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
89
|
+
})}${scheduleStringTimeStandard}`;
|
|
90
|
+
case _constants.FREQUENCIES.WEEKLY:
|
|
91
|
+
{
|
|
92
|
+
const options = {
|
|
93
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
94
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
95
|
+
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
96
|
+
};
|
|
97
|
+
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
98
|
+
...options
|
|
99
|
+
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
100
|
+
...options
|
|
101
|
+
});
|
|
102
|
+
return `${weeklyString}${scheduleStringTimeStandard}`;
|
|
103
|
+
}
|
|
104
|
+
case _constants.FREQUENCIES.MONTHLY:
|
|
105
|
+
{
|
|
106
|
+
const options = {
|
|
107
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
108
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
109
|
+
day: schedule?.dayOfMonth?.[0],
|
|
110
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
111
|
+
};
|
|
112
|
+
const monthlyString = schedule?.dayOfMonth?.length === 1 ? t('Monthly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
113
|
+
...options
|
|
114
|
+
}) : t('Monthly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
115
|
+
...options
|
|
116
|
+
});
|
|
117
|
+
return `${monthlyString}${scheduleStringTimeStandard}`;
|
|
118
|
+
}
|
|
119
|
+
case _constants.FREQUENCIES.QUARTERLY:
|
|
120
|
+
{
|
|
121
|
+
const options = {
|
|
122
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
123
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
124
|
+
day: schedule?.dayOfMonth?.[0],
|
|
125
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
126
|
+
};
|
|
127
|
+
const quarterlyString = schedule?.dayOfMonth?.length === 1 ? t('Quarterly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
128
|
+
...options
|
|
129
|
+
}) : t('Quarterly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
130
|
+
...options
|
|
131
|
+
});
|
|
132
|
+
return `${quarterlyString}${scheduleStringTimeStandard}`;
|
|
133
|
+
}
|
|
134
|
+
case _constants.FREQUENCIES.YEARLY:
|
|
135
|
+
{
|
|
136
|
+
const options = {
|
|
137
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
138
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
139
|
+
day: schedule?.dayOfMonth?.[0],
|
|
140
|
+
month: Object.values(months).find(m => m.index === schedule?.month?.[0])?.label
|
|
141
|
+
};
|
|
142
|
+
const yearlyString = Math.max(schedule?.month?.length ?? 0, schedule?.dayOfMonth?.length ?? 0) ? t('Yearly on {{month}} {{day}} at {{hour}}:{{minutes}}', {
|
|
143
|
+
...options
|
|
144
|
+
}) : t('Yearly on multiple dates at {{hour}}:{{minutes}}', {
|
|
145
|
+
...options
|
|
146
|
+
});
|
|
147
|
+
return `${yearlyString}${scheduleStringTimeStandard}`;
|
|
148
|
+
}
|
|
149
|
+
default:
|
|
150
|
+
return complexScheduleString;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
151
153
|
}
|
|
152
154
|
function hasSameItems(arr1, arr2) {
|
|
153
155
|
return arr1.length === arr2?.length && arr1.every(item1 => {
|
|
@@ -108,7 +108,7 @@ describe('useGetScheduleString', function () {
|
|
|
108
108
|
it(`should generate "${expectedString}"`, function () {
|
|
109
109
|
const {
|
|
110
110
|
result
|
|
111
|
-
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)(schedule));
|
|
111
|
+
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)()(schedule));
|
|
112
112
|
expect(result.current).toBe(`${expectedString}`);
|
|
113
113
|
});
|
|
114
114
|
});
|
|
@@ -123,7 +123,7 @@ describe('useGetScheduleString', function () {
|
|
|
123
123
|
it(`should generate "${expectedString}"`, function () {
|
|
124
124
|
const {
|
|
125
125
|
result
|
|
126
|
-
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)(schedule, {
|
|
126
|
+
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)()(schedule, {
|
|
127
127
|
timeStandardString: '(EST)'
|
|
128
128
|
}));
|
|
129
129
|
expect(result.current).toBe(`${expectedString}`);
|
|
@@ -138,7 +138,7 @@ describe('useGetScheduleString', function () {
|
|
|
138
138
|
it(`should generate "${expectedScheduleString}"`, function () {
|
|
139
139
|
const {
|
|
140
140
|
result
|
|
141
|
-
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)(schedule, {
|
|
141
|
+
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)()(schedule, {
|
|
142
142
|
timeStandardString: null
|
|
143
143
|
}));
|
|
144
144
|
expect(result.current).toBe(expectedScheduleString);
|
package/esm/scheduler/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Frequency, Schedule, ScheduleValidity } from './constants';
|
|
2
2
|
export declare const stringToArrayOfNumbersOrAll: (value?: string | number) => (number | "*")[];
|
|
3
3
|
export declare function useArrayOfRangedNumbersOrAllValidator(): ({ min, max, values, allowAll, }: ScheduleValidity) => ScheduleValidity | undefined;
|
|
4
|
-
export declare function useGetScheduleString(schedule: Schedule, stringOptions?: {
|
|
4
|
+
export declare function useGetScheduleString(): (schedule: Schedule, stringOptions?: {
|
|
5
5
|
complexScheduleString?: string | null;
|
|
6
6
|
timeStandardString?: string | null;
|
|
7
|
-
})
|
|
7
|
+
}) => string | null;
|
|
8
8
|
export declare function getFrequency({ minute, hour, month, dayOfMonth, dayOfWeek, }: Schedule): Frequency | undefined;
|
package/esm/scheduler/utils.js
CHANGED
|
@@ -53,91 +53,93 @@ export function useArrayOfRangedNumbersOrAllValidator() {
|
|
|
53
53
|
return validity;
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
export function useGetScheduleString(
|
|
56
|
+
export function useGetScheduleString() {
|
|
57
57
|
const {
|
|
58
58
|
t
|
|
59
59
|
} = useTranslation();
|
|
60
|
-
const {
|
|
61
|
-
complexScheduleString = t('Complex schedule'),
|
|
62
|
-
timeStandardString = t('(UTC)')
|
|
63
|
-
} = stringOptions;
|
|
64
|
-
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
65
60
|
const months = useMonths();
|
|
66
61
|
const daysOfWeek = useDaysOfWeek();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case FREQUENCIES.WEEKLY:
|
|
80
|
-
{
|
|
81
|
-
const options = {
|
|
82
|
-
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
83
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
84
|
-
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
85
|
-
};
|
|
86
|
-
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
87
|
-
...options
|
|
88
|
-
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
89
|
-
...options
|
|
62
|
+
return (schedule, stringOptions = {}) => {
|
|
63
|
+
const {
|
|
64
|
+
complexScheduleString = t('Complex schedule'),
|
|
65
|
+
timeStandardString = t('(UTC)')
|
|
66
|
+
} = stringOptions;
|
|
67
|
+
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
68
|
+
switch (getFrequency(schedule)) {
|
|
69
|
+
case FREQUENCIES.HOURLY:
|
|
70
|
+
return schedule?.minute?.[0] === 1 ? t('Hourly at {{minutes}} minute past the hour', {
|
|
71
|
+
minutes: schedule.minute[0].toString()
|
|
72
|
+
}) : t('Hourly at {{minutes}} minutes past the hour', {
|
|
73
|
+
minutes: schedule?.minute?.[0].toString()
|
|
90
74
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
case FREQUENCIES.MONTHLY:
|
|
94
|
-
{
|
|
95
|
-
const options = {
|
|
75
|
+
case FREQUENCIES.DAILY:
|
|
76
|
+
return `${t('Daily at {{hour}}:{{minutes}}', {
|
|
96
77
|
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
97
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
78
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
79
|
+
})}${scheduleStringTimeStandard}`;
|
|
80
|
+
case FREQUENCIES.WEEKLY:
|
|
81
|
+
{
|
|
82
|
+
const options = {
|
|
83
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
84
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
85
|
+
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
86
|
+
};
|
|
87
|
+
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
88
|
+
...options
|
|
89
|
+
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
90
|
+
...options
|
|
91
|
+
});
|
|
92
|
+
return `${weeklyString}${scheduleStringTimeStandard}`;
|
|
93
|
+
}
|
|
94
|
+
case FREQUENCIES.MONTHLY:
|
|
95
|
+
{
|
|
96
|
+
const options = {
|
|
97
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
98
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
99
|
+
day: schedule?.dayOfMonth?.[0],
|
|
100
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
101
|
+
};
|
|
102
|
+
const monthlyString = schedule?.dayOfMonth?.length === 1 ? t('Monthly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
103
|
+
...options
|
|
104
|
+
}) : t('Monthly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
105
|
+
...options
|
|
106
|
+
});
|
|
107
|
+
return `${monthlyString}${scheduleStringTimeStandard}`;
|
|
108
|
+
}
|
|
109
|
+
case FREQUENCIES.QUARTERLY:
|
|
110
|
+
{
|
|
111
|
+
const options = {
|
|
112
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
113
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
114
|
+
day: schedule?.dayOfMonth?.[0],
|
|
115
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
116
|
+
};
|
|
117
|
+
const quarterlyString = schedule?.dayOfMonth?.length === 1 ? t('Quarterly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
118
|
+
...options
|
|
119
|
+
}) : t('Quarterly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
120
|
+
...options
|
|
121
|
+
});
|
|
122
|
+
return `${quarterlyString}${scheduleStringTimeStandard}`;
|
|
123
|
+
}
|
|
124
|
+
case FREQUENCIES.YEARLY:
|
|
125
|
+
{
|
|
126
|
+
const options = {
|
|
127
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
128
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
129
|
+
day: schedule?.dayOfMonth?.[0],
|
|
130
|
+
month: Object.values(months).find(m => m.index === schedule?.month?.[0])?.label
|
|
131
|
+
};
|
|
132
|
+
const yearlyString = Math.max(schedule?.month?.length ?? 0, schedule?.dayOfMonth?.length ?? 0) ? t('Yearly on {{month}} {{day}} at {{hour}}:{{minutes}}', {
|
|
133
|
+
...options
|
|
134
|
+
}) : t('Yearly on multiple dates at {{hour}}:{{minutes}}', {
|
|
135
|
+
...options
|
|
136
|
+
});
|
|
137
|
+
return `${yearlyString}${scheduleStringTimeStandard}`;
|
|
138
|
+
}
|
|
139
|
+
default:
|
|
140
|
+
return complexScheduleString;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
141
143
|
}
|
|
142
144
|
function hasSameItems(arr1, arr2) {
|
|
143
145
|
return arr1.length === arr2?.length && arr1.every(item1 => {
|
|
@@ -106,7 +106,7 @@ describe('useGetScheduleString', function () {
|
|
|
106
106
|
it(`should generate "${expectedString}"`, function () {
|
|
107
107
|
const {
|
|
108
108
|
result
|
|
109
|
-
} = renderHook(() => useGetScheduleString(schedule));
|
|
109
|
+
} = renderHook(() => useGetScheduleString()(schedule));
|
|
110
110
|
expect(result.current).toBe(`${expectedString}`);
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -121,7 +121,7 @@ describe('useGetScheduleString', function () {
|
|
|
121
121
|
it(`should generate "${expectedString}"`, function () {
|
|
122
122
|
const {
|
|
123
123
|
result
|
|
124
|
-
} = renderHook(() => useGetScheduleString(schedule, {
|
|
124
|
+
} = renderHook(() => useGetScheduleString()(schedule, {
|
|
125
125
|
timeStandardString: '(EST)'
|
|
126
126
|
}));
|
|
127
127
|
expect(result.current).toBe(`${expectedString}`);
|
|
@@ -136,7 +136,7 @@ describe('useGetScheduleString', function () {
|
|
|
136
136
|
it(`should generate "${expectedScheduleString}"`, function () {
|
|
137
137
|
const {
|
|
138
138
|
result
|
|
139
|
-
} = renderHook(() => useGetScheduleString(schedule, {
|
|
139
|
+
} = renderHook(() => useGetScheduleString()(schedule, {
|
|
140
140
|
timeStandardString: null
|
|
141
141
|
}));
|
|
142
142
|
expect(result.current).toBe(expectedScheduleString);
|