@frui.ts/dataviews
Advanced tools
Comparing version 1.0.0-alpha.8 to 1.0.0-alpha.9
@@ -6,34 +6,32 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
function Header(_a) { | ||
var _b, _c, _d, _e, _f; | ||
var column = _a.column, context = _a.context; | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
function Header({ column, context }) { | ||
var _a, _b, _c, _d, _e; | ||
if (column.headerFormatter) { | ||
return react_1.default.createElement(react_1.default.Fragment, null, column.headerFormatter({ key: "list-header", column: column, context: context })); | ||
return react_1.default.createElement(react_1.default.Fragment, null, column.headerFormatter({ key: "list-header", column, context })); | ||
} | ||
else { | ||
return (react_1.default.createElement("th", { scope: "row", className: column.headerClassName }, (_f = (_d = (_c = (_b = column.responsiveTitleFactory) === null || _b === void 0 ? void 0 : _b.call(column, context)) !== null && _c !== void 0 ? _c : column.responsiveTitle) !== null && _d !== void 0 ? _d : (_e = column.titleFactory) === null || _e === void 0 ? void 0 : _e.call(column, context)) !== null && _f !== void 0 ? _f : column.title)); | ||
return (react_1.default.createElement("th", { scope: "row", className: column.headerClassName }, (_e = (_c = (_b = (_a = column.responsiveTitleFactory) === null || _a === void 0 ? void 0 : _a.call(column, context)) !== null && _b !== void 0 ? _b : column.responsiveTitle) !== null && _c !== void 0 ? _c : (_d = column.titleFactory) === null || _d === void 0 ? void 0 : _d.call(column, context)) !== null && _e !== void 0 ? _e : column.title)); | ||
} | ||
} | ||
function DataListRowImpl(_a) { | ||
var item = _a.item, columns = _a.columns, context = _a.context; | ||
function DataListRowImpl({ item, columns, context }) { | ||
return (react_1.default.createElement("tbody", null, columns | ||
.filter(function (x) { return x.responsiveVisible !== false; }) | ||
.map(function (column, i) { | ||
.filter(x => x.responsiveVisible !== false) | ||
.map((column, i) => { | ||
var _a; | ||
var key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
var value = column.property ? item[column.property] : undefined; | ||
var hasHeader = column.responsiveTitle !== false; | ||
const key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
const value = column.property ? item[column.property] : undefined; | ||
const hasHeader = column.responsiveTitle !== false; | ||
return (react_1.default.createElement("tr", { key: key }, | ||
hasHeader && react_1.default.createElement(Header, { column: column, context: context }), | ||
react_1.default.createElement("td", { colSpan: hasHeader ? 1 : 2 }, column.cellFormatter | ||
? column.cellFormatter({ key: key, value: value, item: item, column: column, context: context }) | ||
? column.cellFormatter({ key, value, item, column, context }) | ||
: column.valueFormatter | ||
? column.valueFormatter({ value: value, item: item, column: column, context: context }) | ||
? column.valueFormatter({ value, item, column, context }) | ||
: value))); | ||
}))); | ||
} | ||
var DataListRow = (0, mobx_react_lite_1.observer)(DataListRowImpl); | ||
const DataListRow = (0, mobx_react_lite_1.observer)(DataListRowImpl); | ||
exports.default = DataListRow; | ||
//# sourceMappingURL=dataListRow.js.map |
@@ -6,12 +6,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
var dataListRow_1 = __importDefault(require("./dataListRow")); | ||
var defaultProps = {}; | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
const dataListRow_1 = __importDefault(require("./dataListRow")); | ||
const defaultProps = {}; | ||
function DataListImpl(props) { | ||
return (react_1.default.createElement("table", { id: props.id, className: props.className }, props.items.map(function (item) { return (react_1.default.createElement(dataListRow_1.default, { key: String(item[props.itemKey]), item: item, columns: props.columns, context: props.context })); }))); | ||
return (react_1.default.createElement("table", { id: props.id, className: props.className }, props.items.map(item => (react_1.default.createElement(dataListRow_1.default, { key: String(item[props.itemKey]), item: item, columns: props.columns, context: props.context }))))); | ||
} | ||
DataListImpl.defaultProps = defaultProps; | ||
var DataList = (0, mobx_react_lite_1.observer)(DataListImpl); | ||
const DataList = (0, mobx_react_lite_1.observer)(DataListImpl); | ||
exports.default = DataList; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -17,7 +6,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
var repeaterHeader_1 = __importDefault(require("./repeaterHeader")); | ||
var repeaterRow_1 = __importDefault(require("./repeaterRow")); | ||
var defaultProps = { | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
const repeaterHeader_1 = __importDefault(require("./repeaterHeader")); | ||
const repeaterRow_1 = __importDefault(require("./repeaterRow")); | ||
const defaultProps = { | ||
displayHeader: true, | ||
@@ -27,11 +16,11 @@ }; | ||
var _a, _b; | ||
var Wrapper = (_a = props.wrapperType) !== null && _a !== void 0 ? _a : "table"; | ||
var ItemWrapper = (_b = props.bodyWrapperType) !== null && _b !== void 0 ? _b : "tbody"; | ||
return (react_1.default.createElement(Wrapper, __assign({ id: props.id }, props.wrapperProps), | ||
const Wrapper = (_a = props.wrapperType) !== null && _a !== void 0 ? _a : "table"; | ||
const ItemWrapper = (_b = props.bodyWrapperType) !== null && _b !== void 0 ? _b : "tbody"; | ||
return (react_1.default.createElement(Wrapper, Object.assign({ id: props.id }, props.wrapperProps), | ||
props.displayHeader && (react_1.default.createElement(repeaterHeader_1.default, { columns: props.columns, context: props.context, pagingFilter: props.pagingFilter, onColumnSort: props.onColumnSort, wrapperType: props.headWrapperType, wrapperProps: props.headWrapperProps, itemCellType: props.headCellType, itemCellProps: props.headCellProps })), | ||
react_1.default.createElement(ItemWrapper, __assign({}, props.bodyWrapperProps), props.items.map(function (item) { return (react_1.default.createElement(repeaterRow_1.default, { key: String(item[props.itemKey]), item: item, columns: props.columns, context: props.context, wrapperType: props.itemWrapperType, wrapperProps: props.itemWrapperProps, itemCellType: props.itemCellType, itemCellProps: props.itemCellProps })); })))); | ||
react_1.default.createElement(ItemWrapper, Object.assign({}, props.bodyWrapperProps), props.items.map(item => (react_1.default.createElement(repeaterRow_1.default, { key: String(item[props.itemKey]), item: item, columns: props.columns, context: props.context, wrapperType: props.itemWrapperType, wrapperProps: props.itemWrapperProps, itemCellType: props.itemCellType, itemCellProps: props.itemCellProps })))))); | ||
} | ||
dataRepeater.defaultProps = defaultProps; | ||
var DataRepeater = (0, mobx_react_lite_1.observer)(dataRepeater); | ||
const DataRepeater = (0, mobx_react_lite_1.observer)(dataRepeater); | ||
exports.default = DataRepeater; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -17,8 +6,8 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var data_1 = require("@frui.ts/data"); | ||
var data_2 = require("@frui.ts/data"); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
const data_1 = require("@frui.ts/data"); | ||
const data_2 = require("@frui.ts/data"); | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
function getSortIndicatorClass(pagingFilter, columnName) { | ||
var currentDirection = (0, data_1.getSortingDirection)(pagingFilter, columnName); | ||
const currentDirection = (0, data_1.getSortingDirection)(pagingFilter, columnName); | ||
if (currentDirection) { | ||
@@ -33,13 +22,13 @@ return currentDirection === data_2.SortingDirection.Descending ? "sort-indicator desc" : "sort-indicator asc"; | ||
var _a, _b; | ||
var Wrapper = (_a = props.wrapperType) !== null && _a !== void 0 ? _a : "tr"; | ||
var Item = (_b = props.itemCellType) !== null && _b !== void 0 ? _b : "th"; | ||
var context = props.context; | ||
return (react_1.default.createElement(Wrapper, __assign({}, props.wrapperProps), props.columns.map(function (column, i) { | ||
const Wrapper = (_a = props.wrapperType) !== null && _a !== void 0 ? _a : "tr"; | ||
const Item = (_b = props.itemCellType) !== null && _b !== void 0 ? _b : "th"; | ||
const { context } = props; | ||
return (react_1.default.createElement(Wrapper, Object.assign({}, props.wrapperProps), props.columns.map((column, i) => { | ||
var _a; | ||
var key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
const key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
if (column.headerFormatter) { | ||
return column.headerFormatter({ key: key, column: column, context: context }); | ||
return column.headerFormatter({ key, column, context }); | ||
} | ||
else if (props.pagingFilter && column.sortable && column.property) { | ||
return (react_1.default.createElement(Item, __assign({ key: key, className: column.headerClassName ? "sortable " + column.headerClassName : "sortable", onClick: function () { var _a; return void ((_a = props.onColumnSort) === null || _a === void 0 ? void 0 : _a.call(props, column)); } }, props.itemCellProps), | ||
return (react_1.default.createElement(Item, Object.assign({ key: key, className: column.headerClassName ? `sortable ${column.headerClassName}` : "sortable", onClick: () => { var _a; return void ((_a = props.onColumnSort) === null || _a === void 0 ? void 0 : _a.call(props, column)); } }, props.itemCellProps), | ||
column.titleFactory ? column.titleFactory(context) : column.title, | ||
@@ -49,8 +38,8 @@ react_1.default.createElement("span", { className: getSortIndicatorClass(props.pagingFilter, column.property) }))); | ||
else { | ||
return (react_1.default.createElement(Item, __assign({ key: key, className: column.headerClassName }, props.itemCellProps), column.titleFactory ? column.titleFactory(context) : column.title)); | ||
return (react_1.default.createElement(Item, Object.assign({ key: key, className: column.headerClassName }, props.itemCellProps), column.titleFactory ? column.titleFactory(context) : column.title)); | ||
} | ||
}))); | ||
} | ||
var RepeaterHeader = (0, mobx_react_lite_1.observer)(repeaterHeader); | ||
const RepeaterHeader = (0, mobx_react_lite_1.observer)(repeaterHeader); | ||
exports.default = RepeaterHeader; | ||
//# sourceMappingURL=repeaterHeader.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -17,24 +6,24 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
function repeaterRow(props) { | ||
var _a, _b; | ||
var Wrapper = (_a = props.wrapperType) !== null && _a !== void 0 ? _a : "tr"; | ||
var Item = (_b = props.itemCellType) !== null && _b !== void 0 ? _b : "td"; | ||
var context = props.context; | ||
var columns = props.columns, item = props.item, itemCellProps = props.itemCellProps; | ||
return (react_1.default.createElement(Wrapper, __assign({}, props.wrapperProps), columns.map(function (column, i) { | ||
const Wrapper = (_a = props.wrapperType) !== null && _a !== void 0 ? _a : "tr"; | ||
const Item = (_b = props.itemCellType) !== null && _b !== void 0 ? _b : "td"; | ||
const { context } = props; | ||
const { columns, item, itemCellProps } = props; | ||
return (react_1.default.createElement(Wrapper, Object.assign({}, props.wrapperProps), columns.map((column, i) => { | ||
var _a, _b; | ||
var key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
var value = column.property ? item[column.property] : undefined; | ||
const key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
const value = column.property ? item[column.property] : undefined; | ||
if (column.cellFormatter) { | ||
return column.cellFormatter({ key: key, value: value, item: item, column: column, context: context }); | ||
return column.cellFormatter({ key, value, item, column, context }); | ||
} | ||
else { | ||
return (react_1.default.createElement(Item, __assign({ key: key, className: column.cellClassName }, itemCellProps, (_b = column.cellProps) === null || _b === void 0 ? void 0 : _b.call(column, { value: value, item: item, column: column, context: context })), column.valueFormatter ? column.valueFormatter({ value: value, item: item, column: column, context: context }) : value)); | ||
return (react_1.default.createElement(Item, Object.assign({ key: key, className: column.cellClassName }, itemCellProps, (_b = column.cellProps) === null || _b === void 0 ? void 0 : _b.call(column, { value, item, column, context })), column.valueFormatter ? column.valueFormatter({ value, item, column, context }) : value)); | ||
} | ||
}))); | ||
} | ||
var RepeaterRow = (0, mobx_react_lite_1.observer)(repeaterRow); | ||
const RepeaterRow = (0, mobx_react_lite_1.observer)(repeaterRow); | ||
exports.default = RepeaterRow; | ||
//# sourceMappingURL=repeaterRow.js.map |
@@ -6,7 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
var tableHeader_1 = __importDefault(require("./tableHeader")); | ||
var tableRow_1 = __importDefault(require("./tableRow")); | ||
var defaultProps = { | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
const tableHeader_1 = __importDefault(require("./tableHeader")); | ||
const tableRow_1 = __importDefault(require("./tableRow")); | ||
const defaultProps = { | ||
displayHeader: true, | ||
@@ -18,7 +18,7 @@ }; | ||
react_1.default.createElement(tableHeader_1.default, { columns: props.columns, context: props.context, pagingFilter: props.pagingFilter, onColumnSort: props.onColumnSort, className: props.headerRowClassName }))), | ||
react_1.default.createElement("tbody", null, props.items.map(function (item) { return (react_1.default.createElement(tableRow_1.default, { key: String(item[props.itemKey]), item: item, columns: props.columns, context: props.context, rowProps: props.rowProps })); })))); | ||
react_1.default.createElement("tbody", null, props.items.map(item => (react_1.default.createElement(tableRow_1.default, { key: String(item[props.itemKey]), item: item, columns: props.columns, context: props.context, rowProps: props.rowProps })))))); | ||
} | ||
dataTable.defaultProps = defaultProps; | ||
var DataTable = (0, mobx_react_lite_1.observer)(dataTable); | ||
const DataTable = (0, mobx_react_lite_1.observer)(dataTable); | ||
exports.default = DataTable; | ||
//# sourceMappingURL=index.js.map |
@@ -6,7 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var data_1 = require("@frui.ts/data"); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
const data_1 = require("@frui.ts/data"); | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
function getSortIndicatorClass(pagingFilter, columnName) { | ||
var currentDirection = (0, data_1.getSortingDirection)(pagingFilter, columnName); | ||
const currentDirection = (0, data_1.getSortingDirection)(pagingFilter, columnName); | ||
if (currentDirection) { | ||
@@ -20,10 +20,10 @@ return currentDirection === data_1.SortingDirection.Descending ? "sort-indicator desc" : "sort-indicator asc"; | ||
function tableHeader(props) { | ||
return (react_1.default.createElement("tr", { className: props.className }, props.columns.map(function (column, i) { | ||
return (react_1.default.createElement("tr", { className: props.className }, props.columns.map((column, i) => { | ||
var _a; | ||
var key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
const key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
if (column.headerFormatter) { | ||
return column.headerFormatter({ key: key, column: column, context: props.context }); | ||
return column.headerFormatter({ key, column, context: props.context }); | ||
} | ||
else if (props.pagingFilter && column.sortable && column.property) { | ||
return (react_1.default.createElement("th", { key: key, className: column.headerClassName ? "sortable " + column.headerClassName : "sortable", onClick: function () { var _a; return void ((_a = props.onColumnSort) === null || _a === void 0 ? void 0 : _a.call(props, column)); } }, | ||
return (react_1.default.createElement("th", { key: key, className: column.headerClassName ? `sortable ${column.headerClassName}` : "sortable", onClick: () => { var _a; return void ((_a = props.onColumnSort) === null || _a === void 0 ? void 0 : _a.call(props, column)); } }, | ||
column.titleFactory ? column.titleFactory(props.context) : column.title, | ||
@@ -37,4 +37,4 @@ react_1.default.createElement("span", { className: getSortIndicatorClass(props.pagingFilter, column.property) }))); | ||
} | ||
var TableHeader = (0, mobx_react_lite_1.observer)(tableHeader); | ||
const TableHeader = (0, mobx_react_lite_1.observer)(tableHeader); | ||
exports.default = TableHeader; | ||
//# sourceMappingURL=tableHeader.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -17,20 +6,19 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
function tableRow(_a) { | ||
var item = _a.item, columns = _a.columns, context = _a.context, rowProps = _a.rowProps; | ||
return (react_1.default.createElement("tr", __assign({}, rowProps === null || rowProps === void 0 ? void 0 : rowProps(item, context)), columns.map(function (column, i) { | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
function tableRow({ item, columns, context, rowProps }) { | ||
return (react_1.default.createElement("tr", Object.assign({}, rowProps === null || rowProps === void 0 ? void 0 : rowProps(item, context)), columns.map((column, i) => { | ||
var _a, _b; | ||
var key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
var value = column.property ? item[column.property] : undefined; | ||
const key = (_a = column.property) !== null && _a !== void 0 ? _a : i; | ||
const value = column.property ? item[column.property] : undefined; | ||
if (column.cellFormatter) { | ||
return column.cellFormatter({ key: key, value: value, item: item, column: column, context: context }); | ||
return column.cellFormatter({ key, value, item, column, context }); | ||
} | ||
else { | ||
return (react_1.default.createElement("td", __assign({ key: key, className: column.cellClassName }, (_b = column.cellProps) === null || _b === void 0 ? void 0 : _b.call(column, { value: value, item: item, column: column, context: context })), column.valueFormatter ? column.valueFormatter({ value: value, item: item, column: column, context: context }) : value)); | ||
return (react_1.default.createElement("td", Object.assign({ key: key, className: column.cellClassName }, (_b = column.cellProps) === null || _b === void 0 ? void 0 : _b.call(column, { value, item, column, context })), column.valueFormatter ? column.valueFormatter({ value, item, column, context }) : value)); | ||
} | ||
}))); | ||
} | ||
var TableRow = (0, mobx_react_lite_1.observer)(tableRow); | ||
const TableRow = (0, mobx_react_lite_1.observer)(tableRow); | ||
exports.default = TableRow; | ||
//# sourceMappingURL=tableRow.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
@@ -43,18 +32,2 @@ if (k2 === undefined) k2 = k; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -64,11 +37,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importStar(require("react")); | ||
var dataList_1 = __importDefault(require("./dataList")); | ||
var dataTable_1 = __importDefault(require("./dataTable")); | ||
var helpers_1 = require("@frui.ts/helpers"); | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importStar(require("react")); | ||
const dataList_1 = __importDefault(require("./dataList")); | ||
const dataTable_1 = __importDefault(require("./dataTable")); | ||
const helpers_1 = require("@frui.ts/helpers"); | ||
function getWidth() { | ||
return document.body.clientWidth || document.documentElement.clientWidth || window.innerWidth; | ||
} | ||
var defaultProps = { | ||
const defaultProps = { | ||
widthBreakpoint: 576, | ||
@@ -78,7 +51,7 @@ listModeClassName: "table-list-view", | ||
function ResponsiveTableImpl(_a) { | ||
var widthBreakpoint = _a.widthBreakpoint, listModeClassName = _a.listModeClassName, onModeChanged = _a.onModeChanged, restProps = __rest(_a, ["widthBreakpoint", "listModeClassName", "onModeChanged"]); | ||
var _b = __read((0, react_1.useState)("table"), 2), mode = _b[0], setMode = _b[1]; | ||
(0, react_1.useEffect)(function () { | ||
var resizeHandler = function () { | ||
var newMode = getWidth() < widthBreakpoint ? "list" : "table"; | ||
var { widthBreakpoint, listModeClassName, onModeChanged } = _a, restProps = __rest(_a, ["widthBreakpoint", "listModeClassName", "onModeChanged"]); | ||
const [mode, setMode] = (0, react_1.useState)("table"); | ||
(0, react_1.useEffect)(() => { | ||
const resizeHandler = () => { | ||
const newMode = getWidth() < widthBreakpoint ? "list" : "table"; | ||
if (newMode !== mode) { | ||
@@ -91,3 +64,3 @@ onModeChanged === null || onModeChanged === void 0 ? void 0 : onModeChanged(newMode); | ||
window.addEventListener("resize", resizeHandler); | ||
return function () { | ||
return () => { | ||
window.removeEventListener("resize", resizeHandler); | ||
@@ -97,11 +70,11 @@ }; | ||
if (mode === "list") { | ||
return react_1.default.createElement(dataList_1.default, __assign({}, restProps, { className: (0, helpers_1.combineClassNames)(restProps.className, listModeClassName) })); | ||
return react_1.default.createElement(dataList_1.default, Object.assign({}, restProps, { className: (0, helpers_1.combineClassNames)(restProps.className, listModeClassName) })); | ||
} | ||
else { | ||
return react_1.default.createElement(dataTable_1.default, __assign({}, restProps)); | ||
return react_1.default.createElement(dataTable_1.default, Object.assign({}, restProps)); | ||
} | ||
} | ||
ResponsiveTableImpl.defaultProps = defaultProps; | ||
var ResponsiveTable = (0, mobx_react_lite_1.observer)(ResponsiveTableImpl); | ||
const ResponsiveTable = (0, mobx_react_lite_1.observer)(ResponsiveTableImpl); | ||
exports.default = ResponsiveTable; | ||
//# sourceMappingURL=responsiveTable.js.map |
@@ -6,16 +6,16 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_react_lite_1 = require("mobx-react-lite"); | ||
var react_1 = __importDefault(require("react")); | ||
const mobx_react_lite_1 = require("mobx-react-lite"); | ||
const react_1 = __importDefault(require("react")); | ||
require("./responsiveTableHeaders.scss"); | ||
var defaultProps = { | ||
const defaultProps = { | ||
mediaQuery: "@media only screen and (max-width: 576px) ", | ||
}; | ||
function getStyleWithHeaders(id, headers, mediaQuery) { | ||
var headerStyles = headers | ||
.map(function (label, index) { return "#" + id + " td:nth-of-type(" + (index + 1) + ")::before { content: \"" + headers[index] + "\"; }"; }) | ||
const headerStyles = headers | ||
.map((label, index) => `#${id} td:nth-of-type(${index + 1})::before { content: "${headers[index]}"; }`) | ||
.join(" "); | ||
return mediaQuery ? mediaQuery + " { " + headerStyles + " }" : headerStyles; | ||
return mediaQuery ? `${mediaQuery} { ${headerStyles} }` : headerStyles; | ||
} | ||
function responsiveTableHeaders(props) { | ||
var columnHeaders = props.columns.map(function (column) { | ||
const columnHeaders = props.columns.map(column => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
@@ -33,4 +33,4 @@ return column.responsiveTitle === false | ||
responsiveTableHeaders.defaultProps = defaultProps; | ||
var ResponsiveTableHeaders = (0, mobx_react_lite_1.observer)(responsiveTableHeaders); | ||
const ResponsiveTableHeaders = (0, mobx_react_lite_1.observer)(responsiveTableHeaders); | ||
exports.default = ResponsiveTableHeaders; | ||
//# sourceMappingURL=responsiveTableHeaders.js.map |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.0.0-alpha.8", | ||
"version": "1.0.0-alpha.9", | ||
"description": "View components for data display", | ||
@@ -41,4 +41,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@frui.ts/data": "^1.0.0-alpha.8", | ||
"@frui.ts/helpers": "^1.0.0-alpha.8", | ||
"@frui.ts/data": "^1.0.0-alpha.9", | ||
"@frui.ts/helpers": "^1.0.0-alpha.9", | ||
"mobx-react-lite": "^2.2.2" | ||
@@ -53,3 +53,3 @@ }, | ||
}, | ||
"gitHead": "e774efd68e7bd49b83461fdcae0d110c2b69da90" | ||
"gitHead": "718298c96617555dd2121f87a2dfefb3ea16d039" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
70277
548