@uxf/data-grid
Advanced tools
Comparing version 11.2.6 to 11.3.0
@@ -1,2 +0,2 @@ | ||
import { DataGridSortDir, RequestFilter, Response } from "../types"; | ||
import { DataGridSortDir, RequestFilter, Response, Tab } from "../types"; | ||
export declare const dataGridActions: { | ||
@@ -18,5 +18,5 @@ filter: (filterValue: RequestFilter) => { | ||
}; | ||
changeTab: (tabName: string) => { | ||
changeTab: (tab: Tab) => { | ||
type: string; | ||
name: string; | ||
tab: Tab; | ||
}; | ||
@@ -23,0 +23,0 @@ reload: () => { |
@@ -20,5 +20,5 @@ "use strict"; | ||
}), | ||
changeTab: (tabName) => ({ | ||
changeTab: (tab) => ({ | ||
type: "CHANGE_TAB", | ||
name: tabName, | ||
tab, | ||
}), | ||
@@ -25,0 +25,0 @@ reload: () => ({ |
@@ -7,17 +7,18 @@ "use strict"; | ||
const getInitialState = (schema, init, initialUserConfig) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; | ||
const initialState = (0, is_nil_1.isNil)(init) ? {} : typeof init === "string" ? (_a = (0, utils_1.decodeFilter)(init)) !== null && _a !== void 0 ? _a : {} : init; | ||
const tabName = (_e = (_b = initialState.tab) !== null && _b !== void 0 ? _b : (_d = (_c = schema.tabs) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : null; | ||
const tabSort = tabName !== null ? (_g = (_f = schema.tabs) === null || _f === void 0 ? void 0 : _f.find((t) => t.name === tabName)) === null || _g === void 0 ? void 0 : _g.s : null; | ||
return { | ||
request: { | ||
f: (_b = initialState.f) !== null && _b !== void 0 ? _b : [], | ||
page: (_c = initialState.page) !== null && _c !== void 0 ? _c : 0, | ||
dir: (_d = initialState.dir) !== null && _d !== void 0 ? _d : schema.dir, | ||
sort: (_e = initialState.sort) !== null && _e !== void 0 ? _e : schema.sort, | ||
perPage: (_g = (_f = initialState.perPage) !== null && _f !== void 0 ? _f : initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _g !== void 0 ? _g : schema.perPage, | ||
tab: (_l = (_h = initialState.tab) !== null && _h !== void 0 ? _h : (_k = (_j = schema.tabs) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.name) !== null && _l !== void 0 ? _l : null, | ||
search: (_m = initialState.search) !== null && _m !== void 0 ? _m : "", | ||
f: (_h = initialState.f) !== null && _h !== void 0 ? _h : [], | ||
s: (_k = (_j = initialState.s) !== null && _j !== void 0 ? _j : tabSort) !== null && _k !== void 0 ? _k : schema.s, | ||
page: (_l = initialState.page) !== null && _l !== void 0 ? _l : 0, | ||
perPage: (_o = (_m = initialState.perPage) !== null && _m !== void 0 ? _m : initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _o !== void 0 ? _o : schema.perPage, | ||
tab: tabName, | ||
search: (_p = initialState.search) !== null && _p !== void 0 ? _p : "", | ||
}, | ||
userConfig: { | ||
columns: (_o = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.columns) !== null && _o !== void 0 ? _o : {}, | ||
perPage: (_p = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _p !== void 0 ? _p : schema.perPage, | ||
columns: (_q = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.columns) !== null && _q !== void 0 ? _q : {}, | ||
perPage: (_r = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _r !== void 0 ? _r : schema.perPage, | ||
}, | ||
@@ -79,4 +80,6 @@ tabRequests: {}, | ||
...state.request, | ||
sort: action.columnName, | ||
dir: action.direction, | ||
s: { | ||
name: action.columnName, | ||
dir: action.direction, | ||
}, | ||
}, | ||
@@ -89,4 +92,3 @@ }; | ||
...state.request, | ||
sort: null, | ||
dir: null, | ||
s: null, | ||
}, | ||
@@ -105,3 +107,3 @@ }; | ||
// eslint-disable-next-line no-case-declarations,@typescript-eslint/no-unnecessary-condition | ||
const tabHistory = (_a = state.tabRequests[action.name]) !== null && _a !== void 0 ? _a : {}; | ||
const tabHistory = (_a = state.tabRequests[action.tab.name]) !== null && _a !== void 0 ? _a : {}; | ||
return { | ||
@@ -112,11 +114,10 @@ ...state, | ||
f: (_b = tabHistory.f) !== null && _b !== void 0 ? _b : [], | ||
s: (_d = (_c = tabHistory.s) !== null && _c !== void 0 ? _c : action.tab.s) !== null && _d !== void 0 ? _d : state.request.s, | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
search: (_c = tabHistory.search) !== null && _c !== void 0 ? _c : "", | ||
search: (_e = tabHistory.search) !== null && _e !== void 0 ? _e : "", | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
page: (_d = tabHistory.page) !== null && _d !== void 0 ? _d : 0, | ||
page: (_f = tabHistory.page) !== null && _f !== void 0 ? _f : 0, | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
perPage: (_e = tabHistory.perPage) !== null && _e !== void 0 ? _e : state.request.perPage, | ||
dir: (_f = tabHistory.dir) !== null && _f !== void 0 ? _f : state.request.dir, | ||
sort: (_g = tabHistory.sort) !== null && _g !== void 0 ? _g : state.request.sort, | ||
tab: action.name, | ||
perPage: (_g = tabHistory.perPage) !== null && _g !== void 0 ? _g : state.request.perPage, | ||
tab: action.tab.name, | ||
}, | ||
@@ -123,0 +124,0 @@ tabRequests: { |
@@ -6,3 +6,3 @@ "use strict"; | ||
const loader = async (_, request) => { | ||
const { page = 1, perPage = 10, tab, sort, dir, f } = request; | ||
const { page = 1, perPage = 10, tab, s, f } = request; | ||
// eslint-disable-next-line no-console | ||
@@ -14,3 +14,3 @@ console.log("filter", f === null || f === void 0 ? void 0 : f.length); | ||
.sort((a, b) => { | ||
if (!sort || !dir) { | ||
if (!s) { | ||
return 1; | ||
@@ -25,5 +25,5 @@ } | ||
if (typeof first === "number") { | ||
return dir === "asc" ? first - second : second - first; | ||
return s.dir === "asc" ? first - second : second - first; | ||
} | ||
return dir === "asc" ? first.localeCompare(second) : second.localeCompare(first); | ||
return s.dir === "asc" ? first.localeCompare(second) : second.localeCompare(first); | ||
}); | ||
@@ -30,0 +30,0 @@ // eslint-disable-next-line no-console |
@@ -58,9 +58,18 @@ "use strict"; | ||
{ name: "all", label: "All" }, | ||
{ name: "only-odd-ids", label: "Only odd ids blablabla" }, | ||
{ | ||
name: "only-odd-ids", | ||
label: "Only odd ids blablabla", | ||
s: { | ||
name: "id", | ||
dir: types_1.DataGridSortDir.Desc, | ||
}, | ||
}, | ||
// { name: "only-odd-ids", label: "Only odd ids" }, | ||
], | ||
dir: types_1.DataGridSortDir.Asc, | ||
sort: "id", | ||
s: { | ||
name: "id", | ||
dir: types_1.DataGridSortDir.Asc, | ||
}, | ||
perPage: 10, | ||
fullText: true, | ||
}; |
@@ -12,5 +12,5 @@ "use strict"; | ||
function ExportButton(props) { | ||
return (react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", onClick: () => props.onCsvDownload((0, utils_1.createRequest)(props.state.request, props.schema.sort, props.schema.dir)), title: "St\u00E1hnout CSV", className: "uxf-data-grid__plugin-button" }, | ||
return (react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", onClick: () => props.onCsvDownload((0, utils_1.createRequest)(props.state.request)), title: "St\u00E1hnout CSV", className: "uxf-data-grid__plugin-button" }, | ||
react_1.default.createElement(icon_1.Icon, { name: "file-arrow-down" }))); | ||
} | ||
exports.ExportButton = ExportButton; |
{ | ||
"name": "@uxf/data-grid", | ||
"version": "11.2.6", | ||
"version": "11.3.0", | ||
"description": "UXF DataGrid", | ||
@@ -34,3 +34,3 @@ "homepage": "https://gitlab.com/uxf-npm/data-grid#readme", | ||
"dependencies": { | ||
"@uxf/ui": "11.1.0", | ||
"@uxf/ui": "11.3.0", | ||
"dayjs": "1.11.10", | ||
@@ -37,0 +37,0 @@ "fast-glob": "^3.3.2", |
@@ -77,4 +77,4 @@ "use strict"; | ||
}; | ||
const sortColumns = props.state.request.sort && props.state.request.dir | ||
? [{ columnKey: props.state.request.sort, direction: props.state.request.dir.toUpperCase() }] | ||
const sortColumns = props.state.request.s | ||
? [{ columnKey: props.state.request.s.name, direction: props.state.request.s.dir.toUpperCase() }] | ||
: []; | ||
@@ -81,0 +81,0 @@ const rdgVisuals = (0, use_rdg_visuals_1.useRdgVisuals)({ |
@@ -20,3 +20,3 @@ "use strict"; | ||
react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-tabs" }, | ||
react_1.default.createElement("nav", { className: "uxf-data-grid__toolbar-tabs-nav uxf-data-grid__toolbar-tabs-nav--desktop", "aria-label": "Tabs" }, (_b = props.schema.tabs) === null || _b === void 0 ? void 0 : _b.map((t) => (react_1.default.createElement(Tab, { key: t.name, title: t.label, isActive: props.state.request.tab === t.name, onClick: () => props.actions.changeTab(t.name) })))), | ||
react_1.default.createElement("nav", { className: "uxf-data-grid__toolbar-tabs-nav uxf-data-grid__toolbar-tabs-nav--desktop", "aria-label": "Tabs" }, (_b = props.schema.tabs) === null || _b === void 0 ? void 0 : _b.map((t) => (react_1.default.createElement(Tab, { key: t.name, title: t.label, isActive: props.state.request.tab === t.name, onClick: () => props.actions.changeTab(t) })))), | ||
react_1.default.createElement("nav", { className: "uxf-data-grid__toolbar-tabs-nav uxf-data-grid__toolbar-tabs-nav--mobile" }, | ||
@@ -27,3 +27,3 @@ react_1.default.createElement(button_1.Button, { variant: "text", className: "uxf-data-grid__toolbar-tabs-button", size: "sm", onClick: () => { | ||
children: (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-tabs-modal-content" }, (_a = props.schema.tabs) === null || _a === void 0 ? void 0 : _a.map((item) => (react_1.default.createElement(button_1.Button, { className: "uxf-data-grid__toolbar-tabs-modal-button", key: item.name, variant: "text", size: "xl", onClick: () => { | ||
props.actions.changeTab(item.name); | ||
props.actions.changeTab(item); | ||
(0, modal_service_1.closeModal)(); | ||
@@ -30,0 +30,0 @@ } }, |
@@ -1,2 +0,2 @@ | ||
import { DataGridSortDir } from "./schema"; | ||
import { DataGridSort } from "./schema"; | ||
export type ResultItem = any; | ||
@@ -11,4 +11,3 @@ export interface RequestFilter<T = any> { | ||
f?: RequestFilter[]; | ||
sort?: string; | ||
dir?: DataGridSortDir; | ||
s?: DataGridSort; | ||
page?: number; | ||
@@ -15,0 +14,0 @@ perPage?: number; |
@@ -6,2 +6,6 @@ import { ReactElement } from "react"; | ||
} | ||
export interface DataGridSort { | ||
name: string; | ||
dir: DataGridSortDir; | ||
} | ||
export interface Tab { | ||
@@ -11,2 +15,3 @@ name: string; | ||
icon?: string; | ||
s?: DataGridSort; | ||
} | ||
@@ -49,6 +54,5 @@ export type BaseGridType = { | ||
tabs?: Tab[]; | ||
sort: string; | ||
dir: DataGridSortDir; | ||
s: DataGridSort; | ||
perPage: number; | ||
fullText?: boolean; | ||
} |
import { RequestFilter } from "./api"; | ||
import { DataGridSortDir } from "./schema"; | ||
import { DataGridSort } from "./schema"; | ||
export type GridRequest = { | ||
f: RequestFilter[]; | ||
sort: string | null; | ||
dir: DataGridSortDir | null; | ||
s: DataGridSort | null; | ||
page: number; | ||
@@ -8,0 +7,0 @@ perPage: number; |
import { Dispatch } from "react"; | ||
import { RequestFilter } from "../types/api"; | ||
import { Tab } from "../types/schema"; | ||
export declare function createActions(dispatch: Dispatch<any>): { | ||
@@ -10,3 +11,3 @@ changePage: (page: number) => void; | ||
search: (search: string) => void; | ||
changeTab: (tabName: string) => void; | ||
changeTab: (tab: Tab) => void; | ||
setSelectedRows: (rows: any[]) => void; | ||
@@ -13,0 +14,0 @@ hideColumn: (name: string) => void; |
@@ -12,3 +12,3 @@ "use strict"; | ||
search: (search) => dispatch({ type: "FULLTEXT", search }), | ||
changeTab: (tabName) => dispatch({ type: "CHANGE_TAB", name: tabName }), | ||
changeTab: (tab) => dispatch({ type: "CHANGE_TAB", tab }), | ||
setSelectedRows: (rows) => dispatch({ type: "SET_SELECTED_ROWS", rows }), | ||
@@ -15,0 +15,0 @@ hideColumn: (name) => dispatch({ type: "HIDE_COLUMN", name }), |
@@ -20,3 +20,3 @@ import { Nullish } from "@uxf/core/types"; | ||
search: (search: string) => void; | ||
changeTab: (tabName: string) => void; | ||
changeTab: (tab: import("../types/schema").Tab) => void; | ||
setSelectedRows: (rows: any[]) => void; | ||
@@ -23,0 +23,0 @@ hideColumn: (name: string) => void; |
@@ -8,3 +8,3 @@ "use strict"; | ||
function useDataGridFetching(config) { | ||
const { state, schema, loader = loader_1.dataGridLoader, gridName } = config; | ||
const { state, loader = loader_1.dataGridLoader, gridName } = config; | ||
const [isLoading, setIsLoading] = (0, react_1.useState)(false); | ||
@@ -16,3 +16,3 @@ const [error, setError] = (0, react_1.useState)(null); | ||
const stateRequest = JSON.parse(stringStateRequest); | ||
const request = (0, utils_1.createRequest)(stateRequest, schema.sort, schema.dir); | ||
const request = (0, utils_1.createRequest)(stateRequest); | ||
setIsLoading(true); | ||
@@ -32,3 +32,3 @@ loader(gridName, request, (0, utils_1.encodeFilter)(request)) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [stringStateRequest, schema.sort, schema.dir, gridName]); | ||
}, [stringStateRequest, gridName]); | ||
(0, react_1.useEffect)(() => { | ||
@@ -35,0 +35,0 @@ reload(); |
import { Request } from "./types/api"; | ||
import { DataGridSortDir } from "./types/schema"; | ||
import { GridRequest } from "./types/state"; | ||
export declare function decodeFilter(filterString: string): null | Request; | ||
export declare function encodeFilter(request: Request): string; | ||
export declare function createRequest(request: GridRequest, defaultSort: string, defaultDir: DataGridSortDir): Request; | ||
export declare function createRequest(request: GridRequest): Request; |
@@ -12,4 +12,3 @@ "use strict"; | ||
page: filter.page || 0, | ||
dir: filter.dir || "asc", | ||
sort: filter.sort || "id", | ||
s: filter.s, | ||
tab: (_a = filter.tab) !== null && _a !== void 0 ? _a : null, | ||
@@ -28,10 +27,8 @@ search: (_b = filter.search) !== null && _b !== void 0 ? _b : "", | ||
exports.encodeFilter = encodeFilter; | ||
function createRequest(request, defaultSort, defaultDir) { | ||
var _a, _b; | ||
function createRequest(request) { | ||
return { | ||
sort: (_a = request.sort) !== null && _a !== void 0 ? _a : defaultSort, | ||
dir: (_b = request.dir) !== null && _b !== void 0 ? _b : defaultDir, | ||
perPage: request.perPage, | ||
page: request.page, | ||
f: request.f.filter((f) => f.value !== undefined && f.value !== null && f.value !== ""), | ||
s: request.s || undefined, | ||
search: request.search, | ||
@@ -38,0 +35,0 @@ tab: request.tab, |
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
3877
173526
+ Added@uxf/ui@11.3.0(transitive)
- Removed@uxf/ui@11.1.0(transitive)
Updated@uxf/ui@11.3.0