@zambezi/grid
Advanced tools
Comparing version 0.6.0 to 0.7.0-grouped-rows.0
{ | ||
"name": "@zambezi/grid", | ||
"version": "0.6.0", | ||
"version": "0.7.0-grouped-rows.0", | ||
"description": "D3 component for drawing financial grids.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -71,7 +71,7 @@ import { basicPrecisionPxFormatter as px } from './basic-precision-px-formatter' | ||
, blockData = bodyBlockLayout(bundle) | ||
, blocksUpdate = target.selectAll('.body-section') | ||
, blocksUpdate = target.selectAll('.zambezi-body-section') | ||
.data(blockData) | ||
, blocksEnter = blocksUpdate.enter() | ||
.append('ul') | ||
.classed('body-section', true) | ||
.classed('zambezi-body-section', true) | ||
.each(setSectionClasses) | ||
@@ -141,3 +141,3 @@ , blocks = blocksUpdate.merge(blocksEnter) | ||
function updateBlockLayout(d, i) { | ||
const blockSelector = `#${ id } .body-section.${ d.className }` | ||
const blockSelector = `#${ id } .zambezi-body-section.${ d.className }` | ||
, value = {} | ||
@@ -144,0 +144,0 @@ , rowSelector = blockSelector + ' > .zambezi-grid-row' |
import { appendFromTemplate, selectionChanged, rebind, forward } from '@zambezi/d3-utils' | ||
import { dispatch as createDispatch } from 'd3-dispatch' | ||
import { partial } from 'underscore' | ||
import { property, batch } from '@zambezi/fun' | ||
@@ -156,12 +155,6 @@ import { select } from 'd3-selection' | ||
function updateRow(d) { | ||
var index = d.index | ||
, className = this.className | ||
, rowClass = 'grid-row-index-' + index | ||
, newClassName = className.replace(rowIndexMatch, useClass(rowClass)) | ||
, selector = `#${ gridId } .zambezi-grid-body .${ rowClass }` | ||
const index = d.index | ||
, selector = `#${ gridId } [data-grid-row-index="${index}"]` | ||
if (className == newClassName) return | ||
this.className = newClassName | ||
this.dataset.gridRowIndex = index | ||
sheet(selector, { top: top(d) }) | ||
@@ -168,0 +161,0 @@ } |
@@ -9,2 +9,4 @@ import { emptyIfUndefinedFormat } from '@zambezi/d3-utils' | ||
let columnIdCount = 0xA | ||
export function columnLayout(columns) { | ||
@@ -71,6 +73,8 @@ const result = validateAndSegregateColumns(columns) | ||
, k = ( | ||
column.key || (label && label.toLowerCase()) || '').replace(/\W+/g, '-') | ||
column.key | ||
|| (label && label.toLowerCase()) || '').replace(/\W+/g, '-') | ||
, columnKeyCount = k && predefinedColumnId[k] | ||
if (!k) return 'c-' + (++columnIdCount).toString(16).toUpperCase() | ||
if (!k) return 'gen-' + (columnIdCount++).toString(16).toUpperCase() | ||
if (columnKeyCount) return k + '-' + ++predefinedColumnId[k] | ||
@@ -77,0 +81,0 @@ |
@@ -8,2 +8,3 @@ import { calculateColumnLayout } from './calculate-column-layout' | ||
import { createExportServerSideFilterAndSort } from './export-server-side-filter-and-sort' | ||
import { createGroupRows } from './group-rows' | ||
import { createHeaders } from './headers' | ||
@@ -17,2 +18,3 @@ import { createLayOutBodyAndOverlays } from './lay-out-body-and-overlays' | ||
import { createSetupGridTemplate } from './setup-grid-template' | ||
import { createShareDispatcher } from './share-dispatcher' | ||
import { createSortRowHeaders } from './sort-row-headers' | ||
@@ -24,4 +26,3 @@ import { createSortRows } from './sort-rows' | ||
import { ensureId } from './ensure-id' | ||
import { rebind, redispatch, call, each, redraw, createResize, createAutoDirty, | ||
throttle, throttleToAnimationFrame } from '@zambezi/d3-utils' | ||
import { rebind, redispatch, call, each, redraw, createResize, createAutoDirty, throttle, throttleToAnimationFrame } from '@zambezi/d3-utils' | ||
@@ -40,29 +41,8 @@ import './grid.css' | ||
, dispatchDraw = createDispatch('draw') | ||
, groupRows = createGroupRows() | ||
, body = createBody() | ||
, sortRowHeaders = createSortRowHeaders() | ||
, serverSideFilterAndSort = createExportServerSideFilterAndSort() | ||
, shareDispatcher = createShareDispatcher() | ||
, autodirty = createAutoDirty() | ||
, grid = compose( | ||
call(() => dispatchDraw.call('draw')) | ||
, call(createScrollers()) | ||
, call(sortRowHeaders) | ||
, call(columnSizers) | ||
, call(columnDrag) | ||
, call(createHeaders()) | ||
, call(body) | ||
, each(createLayOutBodyAndOverlays()) | ||
, call(processSizeAndClipping) | ||
, call(createMeasureGridArea()) | ||
, call(createMarkRowIndices()) | ||
, call(createUnpackNestedRows()) | ||
, call(createSortRows()) | ||
, call(processRowData) | ||
, call(resize) | ||
, call(setupTemplate) | ||
, each(calculateColumnLayout) | ||
, call(ensureColumns) | ||
, call(serverSideFilterAndSort) | ||
, each(ensureData) | ||
, each(ensureId) | ||
) | ||
@@ -89,2 +69,3 @@ , redispatcher = redispatch() | ||
.from(ensureColumns, 'columns') | ||
.from(groupRows, 'groupings') | ||
.from(processRowData, 'filters', 'filtersUse', 'skipRowLocking') | ||
@@ -98,3 +79,29 @@ .from(processSizeAndClipping, 'scroll') | ||
, grid = compose( | ||
call(() => dispatchDraw.call('draw')) | ||
, call(createScrollers()) | ||
, call(sortRowHeaders) | ||
, call(columnSizers) | ||
, call(columnDrag) | ||
, call(createHeaders()) | ||
, call(body) | ||
, each(createLayOutBodyAndOverlays()) | ||
, call(processSizeAndClipping) | ||
, call(createMeasureGridArea()) | ||
, call(createMarkRowIndices()) | ||
, call(createUnpackNestedRows()) | ||
, call(createSortRows()) | ||
, call(processRowData) | ||
, call(resize) | ||
, call(setupTemplate) | ||
, each(calculateColumnLayout) | ||
, call(groupRows) | ||
, call(ensureColumns) | ||
, call(serverSideFilterAndSort) | ||
, each(shareDispatcher.dispatcher(redispatcher)) | ||
, each(ensureData) | ||
, each(ensureId) | ||
) | ||
return api(autodirty(redraw(throttle(throttleToAnimationFrame(grid), 10)))) | ||
} |
@@ -42,4 +42,3 @@ import './nested-row-expanders.css' | ||
merge | ||
.filter(isNestedTextField) | ||
merge.filter(isNestedTextField) | ||
.text(String) | ||
@@ -46,0 +45,0 @@ .classed('nested-text-field', true) |
@@ -0,4 +1,9 @@ | ||
import { property } from '@zambezi/fun' | ||
import { select } from 'd3-selection' | ||
import { selectionChanged } from '@zambezi/d3-utils' | ||
import { wrap } from './wrap-row' | ||
const rowNestedLevelChanged = selectionChanged() | ||
.key(property('row.nestLevel')) | ||
export function createUnpackNestedRows() { | ||
@@ -19,4 +24,9 @@ | ||
if (!cache) cache = unpackRows(d) | ||
select(this).on('data-dirty.unpack-nested-rows', onDataDirty) | ||
select(this) | ||
.on('data-dirty.unpack-nested-rows', onDataDirty) | ||
d.rows = cache | ||
d.dispatcher.on('row-update.unpack-nested-rows', setRowNestLevel) | ||
} | ||
@@ -28,2 +38,8 @@ | ||
function setRowNestLevel(d, i) { | ||
select(this) | ||
.select(rowNestedLevelChanged) | ||
.each(() => this.dataset.nestLevel = d.row.nestLevel) | ||
} | ||
function unpackRows(d) { | ||
@@ -47,3 +63,2 @@ | ||
function unpackNestedRowsForLevel(level) { | ||
return function unpack(acc, row, i, a) { | ||
@@ -50,0 +65,0 @@ const children = row.children |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
417615
68
5086