-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(table): add new table component with ag-grid
- Loading branch information
hirsch
committed
Jun 1, 2021
1 parent
0fb6fe4
commit 6c8d5bf
Showing
24 changed files
with
745 additions
and
142 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
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
65 changes: 65 additions & 0 deletions
65
packages/components/src/components/bal-table/bal-table-button-renderer.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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ICellRendererComp, ICellRendererParams } from 'ag-grid-community' | ||
import { isNil } from 'lodash' | ||
import { ColorTypes } from '../../types/color.types' | ||
|
||
interface BalTableButtonRendererOptions { | ||
color?: (params: ICellRendererParams) => ColorTypes | ||
loading?: (params: ICellRendererParams) => boolean | ||
href?: (params: ICellRendererParams) => string | ||
icon?: string | ||
iconRight?: boolean | ||
square?: boolean | ||
expanded?: boolean | ||
outlined?: boolean | ||
link?: boolean | ||
target?: '_blank' | ' _parent' | '_self' | '_top' | ||
} | ||
|
||
export function BalTableButtonRenderer(options: BalTableButtonRendererOptions): ICellRendererComp { | ||
function Renderer() {} | ||
Renderer.prototype.params = {} | ||
Renderer.prototype.options = options | ||
|
||
Renderer.prototype.init = function (params: ICellRendererParams): void { | ||
this.params = params | ||
this.element = document.createElement('bal-button') | ||
this.element.setAttribute('size', 'small') | ||
this.element.innerHTML = params.value | ||
this.update() | ||
} | ||
|
||
Renderer.prototype.refresh = function (params: ICellRendererParams) { | ||
this.params = params | ||
this.update() | ||
return true | ||
} | ||
|
||
Renderer.prototype.update = function () { | ||
const color = isNil(options.color) ? '' : options.color(this.params) | ||
this.element.setAttribute('color', color) | ||
|
||
const loading = isNil(options.loading) ? false : options.loading(this.params) | ||
this.element.setAttribute('loading', loading) | ||
|
||
const href = isNil(options.href) ? undefined : options.href(this.params) | ||
if (href) { | ||
this.element.setAttribute('href', href) | ||
} | ||
|
||
this.element.setAttribute('icon', isNil(options.icon) ? '' : options.icon) | ||
this.element.setAttribute('iconRight', isNil(options.iconRight) ? false : options.iconRight) | ||
this.element.setAttribute('square', isNil(options.square) ? false : options.square) | ||
this.element.setAttribute('expanded', isNil(options.expanded) ? false : options.expanded) | ||
this.element.setAttribute('outlined', isNil(options.outlined) ? false : options.outlined) | ||
this.element.setAttribute('link', isNil(options.link) ? false : options.link) | ||
this.element.setAttribute('target', isNil(options.target) ? false : options.target) | ||
} | ||
|
||
Renderer.prototype.getGui = function () { | ||
return this.element | ||
} | ||
|
||
Renderer.prototype.destroy = function () {} | ||
|
||
return Renderer as any | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/components/src/components/bal-table/bal-table-tag-renderer.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ICellRendererComp, ICellRendererParams } from 'ag-grid-community' | ||
import { isNil } from 'lodash' | ||
import { ColorTypes } from '../../types/color.types' | ||
|
||
interface BalTableTagRendererOptions { | ||
color?: (params: ICellRendererParams) => ColorTypes | ||
} | ||
|
||
export function BalTableTagRenderer(options: BalTableTagRendererOptions): ICellRendererComp { | ||
function Renderer() {} | ||
Renderer.prototype.params = {} | ||
Renderer.prototype.options = options | ||
|
||
Renderer.prototype.init = function (params: ICellRendererParams): void { | ||
this.params = params | ||
this.element = document.createElement('bal-tag') | ||
this.element.setAttribute('size', 'small') | ||
this.element.innerHTML = params.value | ||
this.update() | ||
} | ||
|
||
Renderer.prototype.refresh = function (params: ICellRendererParams) { | ||
this.params = params | ||
this.update() | ||
return true | ||
} | ||
|
||
Renderer.prototype.update = function () { | ||
const color = isNil(options.color) ? '' : options.color(this.params) | ||
this.element.setAttribute('color', color) | ||
} | ||
|
||
Renderer.prototype.getGui = function () { | ||
return this.element | ||
} | ||
|
||
Renderer.prototype.destroy = function () {} | ||
|
||
return Renderer as any | ||
} |
Oops, something went wrong.