-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: workaround tree shakable expression in ngrid/state
- Loading branch information
1 parent
b195880
commit abae5a5
Showing
12 changed files
with
289 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"name": "@pebula/ngrid-material", | ||
"version": "1.0.0-alpha.21", | ||
"version": "1.0.0-alpha.22", | ||
"peerDependencies": { | ||
"@angular/material": "^7.3.1", | ||
"@pebula/ngrid": "1.0.0-alpha.21" | ||
"@pebula/ngrid": "1.0.0-alpha.22" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { registerGridHandlers } from './grid-primitives/index'; | ||
import { registerColumnOrderHandlers } from './column-order/index'; | ||
import { registerColumnDefHandlers } from './column-def/index'; | ||
|
||
export function registerBuiltInHandlers() { | ||
registerGridHandlers(); | ||
registerColumnOrderHandlers(); | ||
registerColumnDefHandlers(); | ||
} |
256 changes: 129 additions & 127 deletions
256
libs/ngrid/state/src/lib/core/built-in-handlers/column-def/children.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,144 +1,146 @@ | ||
import { PblColumnTypeDefinition } from '@pebula/ngrid'; | ||
import { createStateChunkHandler } from '../../handling'; | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('dataColumn') | ||
.requiredKeys('id', 'prop') | ||
.handleKeys( | ||
'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) | ||
'headerType', 'footerType', 'sort', 'sortAlias', 'editable', 'pin' // All Optional | ||
) | ||
.serialize( (key, ctx) => { | ||
const c = ctx.data.activeColumn || ctx.data.pblColumn; | ||
if (c) { | ||
export function registerColumnDefChildHandlers() { | ||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('dataColumn') | ||
.requiredKeys('id', 'prop') | ||
.handleKeys( | ||
'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) | ||
'headerType', 'footerType', 'sort', 'sortAlias', 'editable', 'pin' // All Optional | ||
) | ||
.serialize( (key, ctx) => { | ||
const c = ctx.data.activeColumn || ctx.data.pblColumn; | ||
if (c) { | ||
switch (key) { | ||
case 'prop': | ||
return c.orgProp; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
const value = c ? c[key] : ctx.source[key]; | ||
|
||
switch (key) { | ||
case 'prop': | ||
return c.orgProp; | ||
case 'sort': | ||
if (typeof value === 'boolean') { | ||
return value; | ||
} else { | ||
return; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
const value = c ? c[key] : ctx.source[key]; | ||
|
||
switch (key) { | ||
case 'sort': | ||
if (typeof value === 'boolean') { | ||
return value; | ||
} else { | ||
return; | ||
return value; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
const { activeColumn } = ctx.data; | ||
if (activeColumn) { | ||
switch (key) { | ||
case 'width': | ||
activeColumn.updateWidth(true, stateValue as any); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
|
||
return value; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
const { activeColumn } = ctx.data; | ||
if (activeColumn) { | ||
switch (key) { | ||
case 'width': | ||
activeColumn.updateWidth(true, stateValue as any); | ||
break; | ||
} | ||
} | ||
if (ctx.source) { | ||
switch (key) { | ||
case 'prop': | ||
return; | ||
case 'type': | ||
case 'headerType': | ||
case 'footerType': | ||
const typeValue = ctx.source[key]; | ||
const stateTypeDef: PblColumnTypeDefinition = stateValue as any; | ||
if (stateTypeDef && typeof stateTypeDef !== 'string' && typeValue && typeof typeValue !== 'string') { | ||
typeValue.name = stateTypeDef.name; | ||
if (stateTypeDef.data) { | ||
typeValue.data = Object.assign(typeValue.data || {}, stateTypeDef.data); | ||
} | ||
if (ctx.source) { | ||
switch (key) { | ||
case 'prop': | ||
return; | ||
} | ||
break; | ||
case 'type': | ||
case 'headerType': | ||
case 'footerType': | ||
const typeValue = ctx.source[key]; | ||
const stateTypeDef: PblColumnTypeDefinition = stateValue as any; | ||
if (stateTypeDef && typeof stateTypeDef !== 'string' && typeValue && typeof typeValue !== 'string') { | ||
typeValue.name = stateTypeDef.name; | ||
if (stateTypeDef.data) { | ||
typeValue.data = Object.assign(typeValue.data || {}, stateTypeDef.data); | ||
} | ||
return; | ||
} | ||
break; | ||
} | ||
ctx.source[key] = stateValue; | ||
} | ||
|
||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('dataMetaRow') | ||
.handleKeys('rowClassName', 'type') // All Optional | ||
.serialize( (key, ctx) => { | ||
const active = ctx.data.active || ctx.source; | ||
if (active) { | ||
return active[key]; | ||
} | ||
ctx.source[key] = stateValue; | ||
} | ||
|
||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('dataMetaRow') | ||
.handleKeys('rowClassName', 'type') // All Optional | ||
.serialize( (key, ctx) => { | ||
const active = ctx.data.active || ctx.source; | ||
if (active) { | ||
return active[key]; | ||
} | ||
}) | ||
.deserialize( (key, stateValue, ctx) => ctx.source[key] = stateValue ) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaRow') | ||
// Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column | ||
.handleKeys( | ||
'rowClassName', 'type', // All Optional like dataMetaRow | ||
'rowIndex', // Required | ||
}) | ||
.deserialize( (key, stateValue, ctx) => ctx.source[key] = stateValue ) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaRow') | ||
// Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column | ||
.handleKeys( | ||
'rowClassName', 'type', // All Optional like dataMetaRow | ||
'rowIndex', // Required | ||
) | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaGroupRow') | ||
// Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column | ||
.handleKeys( | ||
'rowClassName', 'type', // All Optional like dataMetaRow | ||
'rowIndex', // Required | ||
) | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaColumn') | ||
.requiredKeys('kind', 'rowIndex') | ||
.handleKeys( | ||
'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) | ||
) | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaGroupRow') | ||
// Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column | ||
.handleKeys( | ||
'rowClassName', 'type', // All Optional like dataMetaRow | ||
'rowIndex', // Required | ||
createStateChunkHandler('metaGroupColumn') | ||
.requiredKeys('prop', 'rowIndex', 'span') | ||
.handleKeys( | ||
'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) | ||
) | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaColumn') | ||
.requiredKeys('kind', 'rowIndex') | ||
.handleKeys( | ||
'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) | ||
) | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
|
||
/* ====================================================================================================================================================== */ | ||
|
||
createStateChunkHandler('metaGroupColumn') | ||
.requiredKeys('prop', 'rowIndex', 'span') | ||
.handleKeys( | ||
'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) | ||
) | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
.serialize( (key, ctx) => { | ||
return ctx.source[key]; | ||
}) | ||
.deserialize( (key, stateValue, ctx) => { | ||
|
||
}) | ||
.register(); | ||
} |
Oops, something went wrong.