本文整理汇总了TypeScript中@devexpress/dx-core.PureComputed.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PureComputed.default方法的具体用法?TypeScript PureComputed.default怎么用?TypeScript PureComputed.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@devexpress/dx-core.PureComputed
的用法示例。
在下文中一共展示了PureComputed.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: calculateInsideOffset
export const timeBoundariesByDrag: TimeBoundariesByDrag = (
payload, targetData, targetType,
cellDurationMinutes, insidePart, offsetTimeTopBase,
) => {
let offsetTimeTop;
let appointmentStartTime;
let appointmentEndTime;
const insideOffset = calculateInsideOffset(targetType, insidePart, cellDurationMinutes);
const start = moment(targetData.startDate as Date).add(insideOffset, SECONDS);
if (offsetTimeTopBase === null) {
offsetTimeTop = moment(targetData.startDate as Date)
.diff(payload.startDate as Date, SECONDS) + insideOffset;
} else {
offsetTimeTop = offsetTimeTopBase;
}
if (payload.type === targetType) {
const appointmentDurationSeconds = intervalDuration(payload, SECONDS);
appointmentStartTime = moment(start).add((offsetTimeTop) * (-1), SECONDS).toDate();
appointmentEndTime = moment(start)
.add((appointmentDurationSeconds - offsetTimeTop), SECONDS).toDate();
} else {
appointmentStartTime = moment(targetData.startDate as Date)
.add(insideOffset, SECONDS).toDate();
appointmentEndTime = moment(targetData.endDate as Date).add(insideOffset, SECONDS).toDate();
}
return { appointmentStartTime, appointmentEndTime, offsetTimeTop };
};
示例2: rectCalculatorBase
> = (
appointment,
{
rectByDates,
multiline,
rectByDatesMeta: {
cellElements,
viewCellsData,
},
},
) => {
const {
top, left,
width, height, parentWidth,
} = rectCalculatorBase(
appointment,
rectByDates,
{
multiline,
cellElements,
viewCellsData,
},
);
return {
top: top + ((height / appointment.reduceValue) * appointment.offset),
height: height / appointment.reduceValue,
left: toPercentage(left, parentWidth),
width: toPercentage(width, parentWidth),
dataItem: appointment.dataItem,
fromPrev: appointment.fromPrev,
toNext: appointment.toNext,
type: HORIZONTAL_TYPE,
};
};
示例3: pluckSubarray
export const mergeRows: MergeRowsFn = (
rowsInterval, cacheInterval, rows, cacheRows, rowsStart, cacheStart,
) => {
const breakpoints = [
rowsInterval.start, rowsInterval.end,
cacheInterval.start, cacheInterval.end,
]
.filter(i => 0 <= i && i < Number.POSITIVE_INFINITY)
.sort((a, b) => a - b);
let result: Row[] = [];
if (breakpoints.length > 1) {
for (let i = 0; i < breakpoints.length - 1; i += 1) {
const left = breakpoints[i];
const right = breakpoints[i + 1];
const chunk = rowsInterval.start <= left && right <= rowsInterval.end
? pluckSubarray(rows, rowsStart, left, right) // rows have higher priority
: pluckSubarray(cacheRows, cacheStart, left, right);
result = result.concat(chunk);
}
}
return {
skip: breakpoints[0],
rows: result,
};
};
示例4: calculateTextByDays
export const viewBoundText: ViewBoundTextFn = (
startViewDate, endViewDate, step, currentDate, intervalCount, formatDate,
) => (
step !== 'month'
? calculateTextByDays(startViewDate, endViewDate, formatDate)
: calculateTextByMonths(currentDate, intervalCount, formatDate)
);
示例5: getColumnBoundaries
export const getCollapsedGrids: GetCollapsedGridsFn = ({
headerRows = [],
bodyRows = [],
footerRows = [],
columns,
loadedRowsStart,
totalRowCount,
getCellColSpan,
viewportLeft,
containerWidth,
visibleRowBoundaries,
getColumnWidth,
getRowHeight,
},
) => {
const getColSpan = (
tableRow: any, tableColumn: any,
) => getCellColSpan!({ tableRow, tableColumn, tableColumns: columns });
const columnBoundaries = getColumnBoundaries(
columns, viewportLeft, containerWidth, getColumnWidth,
);
const getCollapsedGridBlock: PureComputed<
[any[], any[]?, number?, number?], CollapsedGrid
> = (
rows, rowsVisibleBoundary, rowCount = rows.length, offset = 0,
) => getCollapsedGrid({
rows,
columns,
rowsVisibleBoundary,
columnsVisibleBoundary: columnBoundaries,
getColumnWidth,
getRowHeight,
getColSpan,
totalRowCount: rowCount,
offset,
});
const headerGrid = getCollapsedGridBlock(
headerRows, getRenderRowBounds(visibleRowBoundaries.header, headerRows.length),
);
const bodyGrid = getCollapsedGridBlock(
bodyRows,
adjustedRenderRowBounds(
visibleRowBoundaries.body, bodyRows.length, loadedRowsStart,
),
totalRowCount || 1,
loadedRowsStart,
);
const footerGrid = getCollapsedGridBlock(
footerRows, getRenderRowBounds(visibleRowBoundaries.footer, footerRows.length),
);
return {
headerGrid,
bodyGrid,
footerGrid,
};
};
示例6: clamp
> = (timeTableCells, clientOffset) => timeTableCells.findIndex((timeTableCell) => {
const {
left, top,
right, bottom,
} = timeTableCell.getBoundingClientRect();
const isOver = clientOffset
&& clamp(clientOffset.x, left, right) === clientOffset.x
&& clamp(clientOffset.y, top, bottom) === clientOffset.y;
return isOver;
});
示例7: isOnTheSameLine
.findIndex((geometry, index) => {
const inVerticalBounds = isOnTheSameLine(geometry, y);
const inHorizontalBounds = x >= geometry.left && x <= geometry.right;
const shouldGoFirst = index === 0 && x < geometry.left;
const shouldGoOnLineBreak = !inVerticalBounds
&& !!geometries[index - 1]
&& isOnTheSameLine(geometries[index - 1], y);
return (inVerticalBounds && inHorizontalBounds)
|| shouldGoFirst
|| shouldGoOnLineBreak;
});
示例8: unwrapGroups
export const calculateRectByDateIntervals: CalculateRectByDateIntervalsFn = (
type, intervals, rectByDates, rectByDatesMeta,
) => {
const { growDirection, multiline } = type;
const sorted = sortAppointments(intervals, multiline);
const grouped = findOverlappedAppointments(sorted as AppointmentMoment[], multiline);
const rectCalculator = growDirection === HORIZONTAL_TYPE
? horizontalRectCalculator
: verticalRectCalculator;
return unwrapGroups(adjustAppointments(grouped, multiline))
.map(appointment => rectCalculator(appointment, { rectByDates, multiline, rectByDatesMeta }));
};
示例9: mergeSort
export const sortedRows: SortedRowsFn = (
rows, sorting, getCellValue, getColumnCompare, isGroupRow, getRowLevelKey,
) => {
if (!sorting.length || !rows.length) return rows;
let compare;
if (!getRowLevelKey) {
compare = createCompare(sorting, getColumnCompare, getCellValue);
return mergeSort(rows.slice(), compare);
}
compare = createCompare(sorting, getColumnCompare, (row, columnName) => {
if (isGroupRow && isGroupRow(row)) {
if (row.groupedBy === columnName) {
return row.value;
}
return undefined;
}
return getCellValue(row, columnName);
});
return sortHierarchicalRows(
rows,
compare,
getRowLevelKey,
);
};
示例10: warnIfRowIdUndefined
export const rowIdGetter: PureComputed<[GetRowIdFn, Row[]]> = (getRowId, rows) => {
if (!getRowId) {
const map = new Map(rows.map((row, rowIndex) => [row, rowIndex]) as [any, number]);
return (row: Row) => map.get(row) as RowId;
}
return warnIfRowIdUndefined(getRowId);
};