mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
feat: ✨ Aggiunti tipi agli attributi dei componenti
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
type Children,
|
||||
type Vnode
|
||||
} from 'mithril';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Component from '../Component.jsx';
|
||||
import Mdi from '../Mdi.jsx';
|
||||
@@ -15,6 +16,14 @@ import TableFooter from './TableFooter.jsx';
|
||||
import TableRow from './TableRow.jsx';
|
||||
|
||||
export default class DataTable extends Component {
|
||||
static propTypes = {
|
||||
'rows-per-page': PropTypes.number,
|
||||
'default-rows-per-page': PropTypes.number,
|
||||
'aria-label': PropTypes.string,
|
||||
checkable: PropTypes.bool,
|
||||
paginated: PropTypes.bool
|
||||
};
|
||||
|
||||
rows: Cash[] = [];
|
||||
columns: Children[];
|
||||
footer: Children[];
|
||||
|
@@ -1,13 +1,14 @@
|
||||
import {type Cash} from 'cash-dom/dist/cash';
|
||||
import {inRange} from 'lodash-es';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Component from '../Component.jsx';
|
||||
|
||||
/**
|
||||
* Attributes:
|
||||
* - type: numeric, checkbox
|
||||
*/
|
||||
export default class TableCell extends Component {
|
||||
static propTypes = {
|
||||
type: PropTypes.string
|
||||
};
|
||||
|
||||
view(vnode) {
|
||||
this.attrs.addClassNames('mdc-data-table__cell', {
|
||||
[`mdc-data-table__cell--${this.attrs.get('type')}`]: this.attrs.has('type')
|
||||
@@ -28,7 +29,7 @@ export default class TableCell extends Component {
|
||||
.find('tbody tr[checkable] mwc-checkbox');
|
||||
|
||||
const cell: Cash = $(this.element);
|
||||
cell.children('mwc-checkbox').on('change', (event) => {
|
||||
cell.children('mwc-checkbox').on('change', () => {
|
||||
const row = cell.parent();
|
||||
row.toggleClass('mdc-data-table__row--selected');
|
||||
|
||||
|
@@ -1,15 +1,19 @@
|
||||
import '@material/mwc-icon-button-toggle';
|
||||
|
||||
import {type Cash} from 'cash-dom/dist/cash';
|
||||
import {type Cash} from 'cash-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Component from '../Component.jsx';
|
||||
import Mdi from '../Mdi.jsx';
|
||||
|
||||
/**
|
||||
* Attributes:
|
||||
* - type?: numeric, checkbox
|
||||
*/
|
||||
export default class TableColumn extends Component {
|
||||
static propTypes = {
|
||||
type: PropTypes.oneOf(['numeric', 'checkbox']),
|
||||
id: PropTypes.string,
|
||||
sortable: PropTypes.bool,
|
||||
filterable: PropTypes.bool
|
||||
};
|
||||
|
||||
view(vnode) {
|
||||
this.attrs.addClassNames('mdc-data-table__header-cell', {
|
||||
[`mdc-data-table__header-cell--${this.attrs.get('type')}`]: this.attrs.has('type')
|
||||
@@ -111,10 +115,11 @@ export default class TableColumn extends Component {
|
||||
const index = $(this.element).index();
|
||||
const rows: Cash = $(this.element).closest('table').find('tbody tr');
|
||||
rows.hide();
|
||||
rows.filter((index_, element) => $(element)
|
||||
.find(`td:nth-child(${index + 1})`)
|
||||
.text()
|
||||
.search(event.target.value) !== -1
|
||||
).show();
|
||||
rows.filter((index_, element) => (
|
||||
$(element)
|
||||
.find(`td:nth-child(${index + 1})`)
|
||||
.text()
|
||||
.search(event.target.value) !== -1
|
||||
)).show();
|
||||
}
|
||||
}
|
||||
|
@@ -4,11 +4,16 @@ import {
|
||||
type Children,
|
||||
type Vnode
|
||||
} from 'mithril';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Component from '../Component.jsx';
|
||||
import TableCell from './TableCell.jsx';
|
||||
|
||||
export default class TableRow extends Component {
|
||||
static propTypes = {
|
||||
checkable: PropTypes.bool
|
||||
};
|
||||
|
||||
view(vnode) {
|
||||
this.attrs.addClassNames('mdc-data-table__row');
|
||||
|
||||
|
Reference in New Issue
Block a user