UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

19 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.invisiblePeriods = exports.withinADay = exports.getLastDate = exports.getFirstDate = exports.isVisible = void 0; const date_fns_1 = require("date-fns"); const isVisible = ({ horizontalPosition }) => horizontalPosition <= 98 && horizontalPosition >= 0; exports.isVisible = isVisible; const getFirstDate = (periods) => { return periods.sort((a, b) => a.start.getTime() - b.start.getTime())[0].start; }; exports.getFirstDate = getFirstDate; const getLastDate = (periods) => { return periods.sort((a, b) => a.end.getTime() - b.end.getTime())[periods.length - 1].end; }; exports.getLastDate = getLastDate; const withinADay = (date1, date2) => (0, date_fns_1.differenceInDays)(date1, date2) <= 1; exports.withinADay = withinADay; const invisiblePeriods = ({ horizontalPosition, width, }) => horizontalPosition >= 0 && horizontalPosition <= 100 && width > 0; exports.invisiblePeriods = invisiblePeriods; //# sourceMappingURL=filter.js.map