@trackunit/react-form-components 0.0.158 → 0.0.159
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/index.cjs.js +54 -0
- package/index.esm.js +54 -1
- package/package.json +4 -4
- package/src/components/Schedule/ScheduleParser.d.ts +14 -0
package/index.cjs.js
CHANGED
|
@@ -14951,6 +14951,59 @@ const serializeSchedule = (weekSchedule) => {
|
|
|
14951
14951
|
})
|
|
14952
14952
|
.join(",");
|
|
14953
14953
|
};
|
|
14954
|
+
/**
|
|
14955
|
+
*
|
|
14956
|
+
* @param weekDays week days for when movement must be detected
|
|
14957
|
+
* @param timeStart start time (hour:minute)
|
|
14958
|
+
* @param timeEnd end time (hour:minute)
|
|
14959
|
+
* @returns {DaySchedule[] | undefined} conversion of schedule for when movement must be detected to when movement must not be detected (working hours)
|
|
14960
|
+
*/
|
|
14961
|
+
const workTimeAlarmConversion = (weekDays, timeStart, timeEnd) => {
|
|
14962
|
+
var _a;
|
|
14963
|
+
const startAtMidnight = (timeStart === null || timeStart === void 0 ? void 0 : timeStart.hour) === 0 && (timeStart === null || timeStart === void 0 ? void 0 : timeStart.minute) === 0;
|
|
14964
|
+
const endAtMidnight = (timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.hour) === 0 && (timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.minute) === 0;
|
|
14965
|
+
const wholeWeek = [1, 2, 3, 4, 5, 6, 7];
|
|
14966
|
+
const weekdayIndex = {
|
|
14967
|
+
monday: 1,
|
|
14968
|
+
tuesday: 2,
|
|
14969
|
+
wednesday: 3,
|
|
14970
|
+
thursday: 4,
|
|
14971
|
+
friday: 5,
|
|
14972
|
+
saturday: 6,
|
|
14973
|
+
sunday: 7,
|
|
14974
|
+
};
|
|
14975
|
+
const activeAlarmDays = weekDays === null || weekDays === void 0 ? void 0 : weekDays.map(day => weekdayIndex[day === null || day === void 0 ? void 0 : day.toLowerCase()]);
|
|
14976
|
+
if (startAtMidnight && endAtMidnight) {
|
|
14977
|
+
const result = (_a = wholeWeek === null || wholeWeek === void 0 ? void 0 : wholeWeek.filter(day => activeAlarmDays === null || activeAlarmDays === void 0 ? void 0 : activeAlarmDays.includes(day))) === null || _a === void 0 ? void 0 : _a.map(day => {
|
|
14978
|
+
return {
|
|
14979
|
+
day,
|
|
14980
|
+
range: {
|
|
14981
|
+
timeFrom: "",
|
|
14982
|
+
timeTo: "",
|
|
14983
|
+
},
|
|
14984
|
+
isAllDay: true,
|
|
14985
|
+
};
|
|
14986
|
+
});
|
|
14987
|
+
return result;
|
|
14988
|
+
}
|
|
14989
|
+
else if (startAtMidnight || endAtMidnight) {
|
|
14990
|
+
const result = wholeWeek === null || wholeWeek === void 0 ? void 0 : wholeWeek.map(day => {
|
|
14991
|
+
const allDay = !(activeAlarmDays === null || activeAlarmDays === void 0 ? void 0 : activeAlarmDays.includes(day));
|
|
14992
|
+
return {
|
|
14993
|
+
day,
|
|
14994
|
+
range: {
|
|
14995
|
+
timeFrom: allDay ? "" : `${timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.hour}:${timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.minute}`,
|
|
14996
|
+
timeTo: allDay ? "" : `${timeStart === null || timeStart === void 0 ? void 0 : timeStart.hour}:${timeStart === null || timeStart === void 0 ? void 0 : timeStart.minute}`,
|
|
14997
|
+
},
|
|
14998
|
+
isAllDay: allDay,
|
|
14999
|
+
};
|
|
15000
|
+
});
|
|
15001
|
+
return result;
|
|
15002
|
+
}
|
|
15003
|
+
else {
|
|
15004
|
+
return undefined;
|
|
15005
|
+
}
|
|
15006
|
+
};
|
|
14954
15007
|
|
|
14955
15008
|
/**
|
|
14956
15009
|
* A thin wrapper around the `BaseInput` component for text input fields.
|
|
@@ -15287,3 +15340,4 @@ exports.useCustomComponents = useCustomComponents;
|
|
|
15287
15340
|
exports.usePhoneInput = usePhoneInput;
|
|
15288
15341
|
exports.validatePhoneNumber = validatePhoneNumber;
|
|
15289
15342
|
exports.weekDay = weekDay;
|
|
15343
|
+
exports.workTimeAlarmConversion = workTimeAlarmConversion;
|
package/index.esm.js
CHANGED
|
@@ -14925,6 +14925,59 @@ const serializeSchedule = (weekSchedule) => {
|
|
|
14925
14925
|
})
|
|
14926
14926
|
.join(",");
|
|
14927
14927
|
};
|
|
14928
|
+
/**
|
|
14929
|
+
*
|
|
14930
|
+
* @param weekDays week days for when movement must be detected
|
|
14931
|
+
* @param timeStart start time (hour:minute)
|
|
14932
|
+
* @param timeEnd end time (hour:minute)
|
|
14933
|
+
* @returns {DaySchedule[] | undefined} conversion of schedule for when movement must be detected to when movement must not be detected (working hours)
|
|
14934
|
+
*/
|
|
14935
|
+
const workTimeAlarmConversion = (weekDays, timeStart, timeEnd) => {
|
|
14936
|
+
var _a;
|
|
14937
|
+
const startAtMidnight = (timeStart === null || timeStart === void 0 ? void 0 : timeStart.hour) === 0 && (timeStart === null || timeStart === void 0 ? void 0 : timeStart.minute) === 0;
|
|
14938
|
+
const endAtMidnight = (timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.hour) === 0 && (timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.minute) === 0;
|
|
14939
|
+
const wholeWeek = [1, 2, 3, 4, 5, 6, 7];
|
|
14940
|
+
const weekdayIndex = {
|
|
14941
|
+
monday: 1,
|
|
14942
|
+
tuesday: 2,
|
|
14943
|
+
wednesday: 3,
|
|
14944
|
+
thursday: 4,
|
|
14945
|
+
friday: 5,
|
|
14946
|
+
saturday: 6,
|
|
14947
|
+
sunday: 7,
|
|
14948
|
+
};
|
|
14949
|
+
const activeAlarmDays = weekDays === null || weekDays === void 0 ? void 0 : weekDays.map(day => weekdayIndex[day === null || day === void 0 ? void 0 : day.toLowerCase()]);
|
|
14950
|
+
if (startAtMidnight && endAtMidnight) {
|
|
14951
|
+
const result = (_a = wholeWeek === null || wholeWeek === void 0 ? void 0 : wholeWeek.filter(day => activeAlarmDays === null || activeAlarmDays === void 0 ? void 0 : activeAlarmDays.includes(day))) === null || _a === void 0 ? void 0 : _a.map(day => {
|
|
14952
|
+
return {
|
|
14953
|
+
day,
|
|
14954
|
+
range: {
|
|
14955
|
+
timeFrom: "",
|
|
14956
|
+
timeTo: "",
|
|
14957
|
+
},
|
|
14958
|
+
isAllDay: true,
|
|
14959
|
+
};
|
|
14960
|
+
});
|
|
14961
|
+
return result;
|
|
14962
|
+
}
|
|
14963
|
+
else if (startAtMidnight || endAtMidnight) {
|
|
14964
|
+
const result = wholeWeek === null || wholeWeek === void 0 ? void 0 : wholeWeek.map(day => {
|
|
14965
|
+
const allDay = !(activeAlarmDays === null || activeAlarmDays === void 0 ? void 0 : activeAlarmDays.includes(day));
|
|
14966
|
+
return {
|
|
14967
|
+
day,
|
|
14968
|
+
range: {
|
|
14969
|
+
timeFrom: allDay ? "" : `${timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.hour}:${timeEnd === null || timeEnd === void 0 ? void 0 : timeEnd.minute}`,
|
|
14970
|
+
timeTo: allDay ? "" : `${timeStart === null || timeStart === void 0 ? void 0 : timeStart.hour}:${timeStart === null || timeStart === void 0 ? void 0 : timeStart.minute}`,
|
|
14971
|
+
},
|
|
14972
|
+
isAllDay: allDay,
|
|
14973
|
+
};
|
|
14974
|
+
});
|
|
14975
|
+
return result;
|
|
14976
|
+
}
|
|
14977
|
+
else {
|
|
14978
|
+
return undefined;
|
|
14979
|
+
}
|
|
14980
|
+
};
|
|
14928
14981
|
|
|
14929
14982
|
/**
|
|
14930
14983
|
* A thin wrapper around the `BaseInput` component for text input fields.
|
|
@@ -15200,4 +15253,4 @@ const UploadField = forwardRef((_a, ref) => {
|
|
|
15200
15253
|
*/
|
|
15201
15254
|
setupLibraryTranslations();
|
|
15202
15255
|
|
|
15203
|
-
export { ActionButton, BaseInput, Checkbox, CreatableSelect, DateField, DateInput, DropZone, EmailField, EmailInput, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PhoneField, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, StateManagedSelect$1 as ValueType, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getOrderedOptions, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, parseSchedule, serializeSchedule, useCustomComponents, usePhoneInput, validatePhoneNumber, weekDay };
|
|
15256
|
+
export { ActionButton, BaseInput, Checkbox, CreatableSelect, DateField, DateInput, DropZone, EmailField, EmailInput, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PhoneField, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, StateManagedSelect$1 as ValueType, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getOrderedOptions, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, parseSchedule, serializeSchedule, useCustomComponents, usePhoneInput, validatePhoneNumber, weekDay, workTimeAlarmConversion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.159",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@trackunit/css-class-variance-utilities": "0.0.14",
|
|
11
|
-
"@trackunit/i18n-library-translation": "0.0.
|
|
12
|
-
"@trackunit/react-components": "0.1.
|
|
13
|
-
"@trackunit/shared-utils": "0.0.
|
|
11
|
+
"@trackunit/i18n-library-translation": "0.0.81",
|
|
12
|
+
"@trackunit/react-components": "0.1.168",
|
|
13
|
+
"@trackunit/shared-utils": "0.0.10",
|
|
14
14
|
"@trackunit/ui-icons": "0.0.77",
|
|
15
15
|
"date-fns": "2.29.3",
|
|
16
16
|
"libphonenumber-js": "1.10.36",
|
|
@@ -37,3 +37,17 @@ export declare const parseSchedule: (scheduleString: string) => WeekSchedule;
|
|
|
37
37
|
* @returns {string} Schedule string
|
|
38
38
|
*/
|
|
39
39
|
export declare const serializeSchedule: (weekSchedule: WeekSchedule) => string;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param weekDays week days for when movement must be detected
|
|
43
|
+
* @param timeStart start time (hour:minute)
|
|
44
|
+
* @param timeEnd end time (hour:minute)
|
|
45
|
+
* @returns {DaySchedule[] | undefined} conversion of schedule for when movement must be detected to when movement must not be detected (working hours)
|
|
46
|
+
*/
|
|
47
|
+
export declare const workTimeAlarmConversion: (weekDays: ("MONDAY" | "TUESDAY" | "WEDNESDAY" | "THURSDAY" | "FRIDAY" | "SATURDAY" | "SUNDAY")[] | undefined, timeStart: {
|
|
48
|
+
hour: number;
|
|
49
|
+
minute: number;
|
|
50
|
+
} | undefined, timeEnd: {
|
|
51
|
+
hour: number;
|
|
52
|
+
minute: number;
|
|
53
|
+
} | undefined) => DaySchedule[] | undefined;
|