@react-fabric/data 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/cjs/histogram/Histogram.js +89 -0
- package/dist/cjs/histogram/Histogram.module.css +1 -0
- package/dist/cjs/hooks/useFilteredList.js +56 -0
- package/dist/cjs/hooks/usePagination.js +85 -0
- package/dist/cjs/i18n/ar.json.js +56 -0
- package/dist/cjs/i18n/en.json.js +56 -0
- package/dist/cjs/i18n/index.js +33 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/json/JsonViewer.js +246 -0
- package/dist/cjs/pagination/Pagination.js +100 -0
- package/dist/cjs/table/BodyCell.js +47 -0
- package/dist/cjs/table/HeaderCell.js +79 -0
- package/dist/cjs/table/Table.js +133 -0
- package/dist/cjs/table/useTableColumns.js +26 -0
- package/dist/cjs/table/useVirtualTable.js +56 -0
- package/dist/cjs/tree/TreeNode.js +107 -0
- package/dist/cjs/tree/TreePanel.js +136 -0
- package/dist/cjs/tree/types.js +30 -0
- package/dist/cjs/tree/useTree.js +181 -0
- package/dist/cjs/tree/utils.js +145 -0
- package/dist/cjs/virtual/Gallery.js +229 -0
- package/dist/cjs/virtual/List.js +218 -0
- package/dist/cjs/virtual/Scroller.js +77 -0
- package/dist/esm/histogram/Histogram.js +89 -0
- package/dist/esm/histogram/Histogram.module.css +1 -0
- package/dist/esm/hooks/useFilteredList.js +56 -0
- package/dist/esm/hooks/usePagination.js +85 -0
- package/dist/esm/i18n/ar.json.js +47 -0
- package/dist/esm/i18n/en.json.js +47 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/json/JsonViewer.js +246 -0
- package/dist/esm/pagination/Pagination.js +100 -0
- package/dist/esm/table/BodyCell.js +47 -0
- package/dist/esm/table/HeaderCell.js +79 -0
- package/dist/esm/table/Table.js +133 -0
- package/dist/esm/table/useTableColumns.js +26 -0
- package/dist/esm/table/useVirtualTable.js +56 -0
- package/dist/esm/tree/TreeNode.js +107 -0
- package/dist/esm/tree/TreePanel.js +136 -0
- package/dist/esm/tree/types.js +29 -0
- package/dist/esm/tree/useTree.js +181 -0
- package/dist/esm/tree/utils.js +140 -0
- package/dist/esm/virtual/Gallery.js +229 -0
- package/dist/esm/virtual/List.js +218 -0
- package/dist/esm/virtual/Scroller.js +77 -0
- package/dist/types/histogram/Histogram.d.ts +41 -0
- package/dist/types/hooks/useFilteredList.d.ts +7 -0
- package/dist/types/hooks/usePagination.d.ts +25 -0
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/json/JsonViewer.d.ts +59 -0
- package/dist/types/pagination/Pagination.d.ts +24 -0
- package/dist/types/table/BodyCell.d.ts +5 -0
- package/dist/types/table/HeaderCell.d.ts +2 -0
- package/dist/types/table/Table.d.ts +2 -0
- package/dist/types/table/types.d.ts +26 -0
- package/dist/types/table/useTableColumns.d.ts +8 -0
- package/dist/types/table/useVirtualTable.d.ts +8 -0
- package/dist/types/tree/TreeNode.d.ts +2 -0
- package/dist/types/tree/TreePanel.d.ts +2 -0
- package/dist/types/tree/types.d.ts +138 -0
- package/dist/types/tree/useTree.d.ts +20 -0
- package/dist/types/tree/utils.d.ts +10 -0
- package/dist/types/virtual/Gallery.d.ts +55 -0
- package/dist/types/virtual/List.d.ts +59 -0
- package/dist/types/virtual/Scroller.d.ts +8 -0
- package/package.json +55 -0
- package/src/histogram/Histogram.module.css +57 -0
- package/src/histogram/Histogram.tsx +176 -0
- package/src/hooks/useFilteredList.tsx +78 -0
- package/src/hooks/usePagination.tsx +135 -0
- package/src/i18n/ar.json +36 -0
- package/src/i18n/en.json +36 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +35 -0
- package/src/json/JsonViewer.tsx +381 -0
- package/src/pagination/Pagination.tsx +157 -0
- package/src/table/BodyCell.tsx +54 -0
- package/src/table/HeaderCell.tsx +70 -0
- package/src/table/Table.tsx +143 -0
- package/src/table/types.ts +65 -0
- package/src/table/useTableColumns.ts +52 -0
- package/src/table/useVirtualTable.ts +54 -0
- package/src/tree/TreeNode.tsx +163 -0
- package/src/tree/TreePanel.tsx +157 -0
- package/src/tree/types.ts +181 -0
- package/src/tree/useTree.ts +227 -0
- package/src/tree/utils.ts +185 -0
- package/src/virtual/Gallery.tsx +349 -0
- package/src/virtual/List.tsx +351 -0
- package/src/virtual/Scroller.tsx +81 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import { useState, useTransition, useMemo, useEffect, useCallback } from 'react';
|
|
5
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var TOTAL_PILLS = 12;
|
|
8
|
+
var TOTAL_SIBLINGS = 2;
|
|
9
|
+
var TOTAL_MID_SIBLINGS = 3;
|
|
10
|
+
var makeRange = function makeRange(start, end) {
|
|
11
|
+
var length = end - start;
|
|
12
|
+
return Array.from({
|
|
13
|
+
length: length
|
|
14
|
+
}, function (_, idx) {
|
|
15
|
+
return idx + start;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var usePagination = function usePagination(_ref) {
|
|
19
|
+
var totalRecords = _ref.totalRecords,
|
|
20
|
+
_ref$currentPage = _ref.currentPage,
|
|
21
|
+
currentPage = _ref$currentPage === void 0 ? 0 : _ref$currentPage,
|
|
22
|
+
_ref$perPage = _ref.perPage,
|
|
23
|
+
perPage = _ref$perPage === void 0 ? 25 : _ref$perPage,
|
|
24
|
+
onChange = _ref.onChange;
|
|
25
|
+
var _useState = useState(0),
|
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
+
page = _useState2[0],
|
|
28
|
+
setPage = _useState2[1];
|
|
29
|
+
var _useTransition = useTransition(),
|
|
30
|
+
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
31
|
+
startTransition = _useTransition2[1];
|
|
32
|
+
|
|
33
|
+
/** ***************** calculate total pages *******************/
|
|
34
|
+
var totalPages = useMemo(function () {
|
|
35
|
+
return Math.max(1, Math.ceil(totalRecords / perPage));
|
|
36
|
+
}, [totalRecords, perPage]);
|
|
37
|
+
|
|
38
|
+
/** ***************** calculate ranges *******************/
|
|
39
|
+
var ranges = useMemo(function () {
|
|
40
|
+
if (totalPages <= TOTAL_PILLS) {
|
|
41
|
+
return [makeRange(0, totalPages)];
|
|
42
|
+
}
|
|
43
|
+
var leftSiblingIndex = Math.max(page - TOTAL_MID_SIBLINGS, 0);
|
|
44
|
+
var rightSiblingIndex = Math.min(page + TOTAL_MID_SIBLINGS, totalPages - 1);
|
|
45
|
+
var shouldShowLeftDots = leftSiblingIndex >= TOTAL_SIBLINGS;
|
|
46
|
+
var shouldShowRightDots = rightSiblingIndex < totalPages - TOTAL_SIBLINGS;
|
|
47
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
48
|
+
return [makeRange(0, TOTAL_SIBLINGS * 3), makeRange(totalPages - TOTAL_SIBLINGS, totalPages)];
|
|
49
|
+
}
|
|
50
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
51
|
+
return [makeRange(0, TOTAL_SIBLINGS), makeRange(totalPages - TOTAL_SIBLINGS * 3, totalPages)];
|
|
52
|
+
}
|
|
53
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
54
|
+
return [makeRange(0, TOTAL_SIBLINGS), makeRange(leftSiblingIndex + 1, rightSiblingIndex), makeRange(totalPages - TOTAL_SIBLINGS, totalPages)];
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}, [page, totalPages]);
|
|
58
|
+
|
|
59
|
+
/** ***************** set page *******************/
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
setPage(Math.min(currentPage, totalPages - 1));
|
|
62
|
+
onChange === null || onChange === void 0 || onChange(Math.min(currentPage, totalPages - 1));
|
|
63
|
+
}, [currentPage, totalPages]);
|
|
64
|
+
var headLabel = useMemo(function () {
|
|
65
|
+
return /*#__PURE__*/jsxs("span", {
|
|
66
|
+
className: "text-muted",
|
|
67
|
+
children: [page * perPage + 1, "\xA0-\xA0", Math.min(page * perPage + perPage, totalRecords)]
|
|
68
|
+
});
|
|
69
|
+
}, [page, perPage, totalRecords]);
|
|
70
|
+
var onPageChange = useCallback(function (page) {
|
|
71
|
+
setPage(page);
|
|
72
|
+
startTransition(function () {
|
|
73
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange(page);
|
|
74
|
+
});
|
|
75
|
+
}, []);
|
|
76
|
+
return {
|
|
77
|
+
page: page,
|
|
78
|
+
totalPages: totalPages,
|
|
79
|
+
headLabel: headLabel,
|
|
80
|
+
ranges: ranges,
|
|
81
|
+
onPageChange: onPageChange
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { usePagination };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
var label = {
|
|
4
|
+
noRecords: "لا تسجيلات"
|
|
5
|
+
};
|
|
6
|
+
var tree = {
|
|
7
|
+
noItems: "لا توجد عناصر",
|
|
8
|
+
error: "خطأ في تحميل العناصر",
|
|
9
|
+
loading: "تحميل العناصر…"
|
|
10
|
+
};
|
|
11
|
+
var datagrid = {
|
|
12
|
+
empty: "لا توجد سجلات متاحة"
|
|
13
|
+
};
|
|
14
|
+
var json = {
|
|
15
|
+
empty: "لا توجد خصائص بيانات",
|
|
16
|
+
"true": "نعم",
|
|
17
|
+
"false": "رقم"
|
|
18
|
+
};
|
|
19
|
+
var checkList = {
|
|
20
|
+
empty: "لا توجد عناصر قائمة"
|
|
21
|
+
};
|
|
22
|
+
var histogram = {
|
|
23
|
+
empty: "لا توجد رسوم بيانية"
|
|
24
|
+
};
|
|
25
|
+
var action = {
|
|
26
|
+
find: "تجد…",
|
|
27
|
+
copy: "قيمة النسخ",
|
|
28
|
+
filter: "منقي…",
|
|
29
|
+
showShortcuts: "اختصارات لوحة المفاتيح…",
|
|
30
|
+
collapseAll: "انهيار جميع",
|
|
31
|
+
expandAll: "توسيع الكل",
|
|
32
|
+
checkAll: "تحقق من الكل",
|
|
33
|
+
uncheckAll: "الغاءالكل",
|
|
34
|
+
addFilter: "أضف عامل تصفية",
|
|
35
|
+
addFilterNot: "إضافة لا تصفية"
|
|
36
|
+
};
|
|
37
|
+
var ar = {
|
|
38
|
+
label: label,
|
|
39
|
+
tree: tree,
|
|
40
|
+
datagrid: datagrid,
|
|
41
|
+
json: json,
|
|
42
|
+
checkList: checkList,
|
|
43
|
+
histogram: histogram,
|
|
44
|
+
action: action
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { action, checkList, datagrid, ar as default, histogram, json, label, tree };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
var label = {
|
|
4
|
+
noRecords: "No Records"
|
|
5
|
+
};
|
|
6
|
+
var tree = {
|
|
7
|
+
noItems: "No items",
|
|
8
|
+
error: "Error loading items",
|
|
9
|
+
loading: "Loading items..."
|
|
10
|
+
};
|
|
11
|
+
var datagrid = {
|
|
12
|
+
empty: "No records available"
|
|
13
|
+
};
|
|
14
|
+
var json = {
|
|
15
|
+
empty: "No data properties",
|
|
16
|
+
"true": "Yes",
|
|
17
|
+
"false": "No"
|
|
18
|
+
};
|
|
19
|
+
var checkList = {
|
|
20
|
+
empty: "No list items"
|
|
21
|
+
};
|
|
22
|
+
var histogram = {
|
|
23
|
+
empty: "No histograms"
|
|
24
|
+
};
|
|
25
|
+
var action = {
|
|
26
|
+
find: "Find...",
|
|
27
|
+
copy: "Copy Value",
|
|
28
|
+
filter: "Filter...",
|
|
29
|
+
showShortcuts: "Keyboard shortcuts...",
|
|
30
|
+
collapseAll: "Collapse All",
|
|
31
|
+
expandAll: "Expand All",
|
|
32
|
+
checkAll: "Check All",
|
|
33
|
+
uncheckAll: "Uncheck All",
|
|
34
|
+
addFilter: "Add Filter",
|
|
35
|
+
addFilterNot: "Add not Filter"
|
|
36
|
+
};
|
|
37
|
+
var en = {
|
|
38
|
+
label: label,
|
|
39
|
+
tree: tree,
|
|
40
|
+
datagrid: datagrid,
|
|
41
|
+
json: json,
|
|
42
|
+
checkList: checkList,
|
|
43
|
+
histogram: histogram,
|
|
44
|
+
action: action
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { action, checkList, datagrid, en as default, histogram, json, label, tree };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addTranslationBundle } from '@react-fabric/core';
|
|
4
|
+
import ar from './ar.json.js';
|
|
5
|
+
import en from './en.json.js';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* React Fabric
|
|
9
|
+
* @version: 1.0.0
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* The MIT License (MIT)
|
|
13
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
16
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
17
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
18
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
+
* subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
22
|
+
* portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
25
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
26
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
27
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
addTranslationBundle("data", {
|
|
31
|
+
en: en,
|
|
32
|
+
ar: ar
|
|
33
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import './i18n/index.js';
|
|
4
|
+
export { Histogram } from './histogram/Histogram.js';
|
|
5
|
+
export { JsonViewer } from './json/JsonViewer.js';
|
|
6
|
+
export { Pagination } from './pagination/Pagination.js';
|
|
7
|
+
export { Table } from './table/Table.js';
|
|
8
|
+
export { TreePanel } from './tree/TreePanel.js';
|
|
9
|
+
export { VirtualGallery } from './virtual/Gallery.js';
|
|
10
|
+
export { VirtualList } from './virtual/List.js';
|
|
11
|
+
export { useFilteredList } from './hooks/useFilteredList.js';
|
|
12
|
+
export { usePagination } from './hooks/usePagination.js';
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
|
+
import { EmptyContent, Text, Meter, ActionLabel, Button, CoreIcons, Icon, Copy } from '@react-fabric/core';
|
|
8
|
+
import { isEmpty, isArray, isObject, isNil, Format, isBoolean, isTrue } from '@react-fabric/utilities';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import { useMemo, useState, Fragment } from 'react';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
var _excluded = ["className", "json", "copy", "propertyScheme", "filters", "inline", "labelWidth", "formatter", "labeler", "onFilter", "emptyMessage", "showPropertyTree"];
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
var reduceObject = function reduceObject(json) {
|
|
18
|
+
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
19
|
+
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
20
|
+
var ret = [];
|
|
21
|
+
Object.entries(json).forEach(function (_ref) {
|
|
22
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
23
|
+
key = _ref2[0],
|
|
24
|
+
value = _ref2[1];
|
|
25
|
+
if (isArray(value) && isObject(value[0])) {
|
|
26
|
+
ret.push.apply(ret, _toConsumableArray(reduceObject(value, [].concat(_toConsumableArray(keys), [key]), key)));
|
|
27
|
+
} else {
|
|
28
|
+
var obj = {
|
|
29
|
+
field: prefix ? "".concat(prefix, ".").concat(key) : key,
|
|
30
|
+
value: value,
|
|
31
|
+
path: [].concat(_toConsumableArray(keys), [key]).join(".")
|
|
32
|
+
};
|
|
33
|
+
if (isObject(value) && !isEmpty(value) && !("_score_" in value)) {
|
|
34
|
+
obj.children = reduceObject(value, [].concat(_toConsumableArray(keys), [key]));
|
|
35
|
+
}
|
|
36
|
+
ret.push(obj);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return ret.flat(99);
|
|
40
|
+
};
|
|
41
|
+
var JsonEntry = function JsonEntry(_ref3) {
|
|
42
|
+
var value = _ref3.value,
|
|
43
|
+
path = _ref3.path,
|
|
44
|
+
field = _ref3.field,
|
|
45
|
+
children = _ref3.children,
|
|
46
|
+
copy = _ref3.copy,
|
|
47
|
+
filters = _ref3.filters,
|
|
48
|
+
labeler = _ref3.labeler,
|
|
49
|
+
formatter = _ref3.formatter,
|
|
50
|
+
propertyScheme = _ref3.propertyScheme,
|
|
51
|
+
showPropertyTree = _ref3.showPropertyTree,
|
|
52
|
+
onFilter = _ref3.onFilter,
|
|
53
|
+
inline = _ref3.inline,
|
|
54
|
+
_ref3$labelWidth = _ref3.labelWidth,
|
|
55
|
+
labelWidth = _ref3$labelWidth === void 0 ? "30%" : _ref3$labelWidth,
|
|
56
|
+
_ref3$level = _ref3.level,
|
|
57
|
+
level = _ref3$level === void 0 ? 0 : _ref3$level;
|
|
58
|
+
var _useTranslation = useTranslation("data"),
|
|
59
|
+
t = _useTranslation.t;
|
|
60
|
+
var _useState = useState(true),
|
|
61
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
+
expanded = _useState2[0],
|
|
63
|
+
setExpanded = _useState2[1];
|
|
64
|
+
var canExpand = useMemo(function () {
|
|
65
|
+
return !!children;
|
|
66
|
+
}, [children]);
|
|
67
|
+
var actualValue = useMemo(function () {
|
|
68
|
+
var _ref4, _value$_label_;
|
|
69
|
+
return (_ref4 = (_value$_label_ = value === null || value === void 0 ? void 0 : value._label_) !== null && _value$_label_ !== void 0 ? _value$_label_ : value) !== null && _ref4 !== void 0 ? _ref4 : "";
|
|
70
|
+
}, [value]);
|
|
71
|
+
var display = useMemo(function () {
|
|
72
|
+
var _propertyScheme$date, _propertyScheme$time, _propertyScheme$numbe, _propertyScheme$bytes, _propertyScheme$perce, _propertyScheme$numbe2, _propertyScheme$boole, _ret;
|
|
73
|
+
if (children) return null;
|
|
74
|
+
if (isNil(value)) return /*#__PURE__*/jsx("span", {
|
|
75
|
+
className: "text-muted",
|
|
76
|
+
children: "null"
|
|
77
|
+
});
|
|
78
|
+
if (isEmpty(value)) return /*#__PURE__*/jsx("span", {
|
|
79
|
+
className: "text-muted",
|
|
80
|
+
children: "empty"
|
|
81
|
+
});
|
|
82
|
+
var ret = actualValue;
|
|
83
|
+
if (formatter) {
|
|
84
|
+
var formatted = formatter === null || formatter === void 0 ? void 0 : formatter(path, actualValue);
|
|
85
|
+
if (!isNil(formatted)) ret = formatted;
|
|
86
|
+
}
|
|
87
|
+
if (isArray(actualValue)) {
|
|
88
|
+
ret = "[".concat(actualValue.join(", "), "]");
|
|
89
|
+
}
|
|
90
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$date = propertyScheme.date) !== null && _propertyScheme$date !== void 0 && _propertyScheme$date.includes(path)) ;
|
|
91
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$time = propertyScheme.time) !== null && _propertyScheme$time !== void 0 && _propertyScheme$time.includes(path)) ret = Format.date(actualValue, "pp");
|
|
92
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$numbe = propertyScheme.number) !== null && _propertyScheme$numbe !== void 0 && _propertyScheme$numbe.phone(path)) ret = Format.phone(actualValue);
|
|
93
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$bytes = propertyScheme.bytes) !== null && _propertyScheme$bytes !== void 0 && _propertyScheme$bytes.includes(path)) ret = Format.bytes(actualValue);
|
|
94
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$perce = propertyScheme.percent) !== null && _propertyScheme$perce !== void 0 && _propertyScheme$perce.includes(path)) ret = Format.percent(actualValue);
|
|
95
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$numbe2 = propertyScheme.number) !== null && _propertyScheme$numbe2 !== void 0 && _propertyScheme$numbe2.includes(path)) ret = Format.number(actualValue);
|
|
96
|
+
if (propertyScheme !== null && propertyScheme !== void 0 && (_propertyScheme$boole = propertyScheme["boolean"]) !== null && _propertyScheme$boole !== void 0 && _propertyScheme$boole.includes(path) || isBoolean(actualValue)) ret = actualValue ? t("json.true") : t("json.false");
|
|
97
|
+
if (((_ret = ret) === null || _ret === void 0 ? void 0 : _ret.length) > 128) {
|
|
98
|
+
ret = /*#__PURE__*/jsx(Text, {
|
|
99
|
+
clamp: 3,
|
|
100
|
+
children: ret
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
104
|
+
children: [ret, isObject(value) && value._score_ > 0 && /*#__PURE__*/jsx(Meter, {
|
|
105
|
+
className: "text-xs",
|
|
106
|
+
value: value._score_
|
|
107
|
+
})]
|
|
108
|
+
});
|
|
109
|
+
}, [value, path, formatter, propertyScheme, actualValue]);
|
|
110
|
+
var pathWithoutOrdinal = useMemo(function () {
|
|
111
|
+
return path.replace(/\.\d*\./, ".");
|
|
112
|
+
}, [path]);
|
|
113
|
+
var canCopy = useMemo(function () {
|
|
114
|
+
var _copy$includes, _copy$includes2;
|
|
115
|
+
return !isEmpty(value) && (isTrue(copy) || (copy === null || copy === void 0 || (_copy$includes = copy.includes) === null || _copy$includes === void 0 ? void 0 : _copy$includes.call(copy, path)) || (copy === null || copy === void 0 || (_copy$includes2 = copy.includes) === null || _copy$includes2 === void 0 ? void 0 : _copy$includes2.call(copy, pathWithoutOrdinal)));
|
|
116
|
+
}, [copy, value, path, pathWithoutOrdinal]);
|
|
117
|
+
var canFilter = useMemo(function () {
|
|
118
|
+
var _filters$includes, _filters$includes2;
|
|
119
|
+
return isTrue(filters) || (filters === null || filters === void 0 || (_filters$includes = filters.includes) === null || _filters$includes === void 0 ? void 0 : _filters$includes.call(filters, path)) || (filters === null || filters === void 0 || (_filters$includes2 = filters.includes) === null || _filters$includes2 === void 0 ? void 0 : _filters$includes2.call(filters, pathWithoutOrdinal));
|
|
120
|
+
}, [filters, path, pathWithoutOrdinal]);
|
|
121
|
+
var labelDisplay = useMemo(function () {
|
|
122
|
+
var _labeler;
|
|
123
|
+
return /*#__PURE__*/jsx(ActionLabel, {
|
|
124
|
+
className: "text-dimmed text-sm px-2 flex-1 truncate",
|
|
125
|
+
actions: !canExpand && canFilter ? [/*#__PURE__*/jsx(Button, {
|
|
126
|
+
color: "danger",
|
|
127
|
+
size: "sm",
|
|
128
|
+
variant: "link",
|
|
129
|
+
icon: CoreIcons.funnelMinus,
|
|
130
|
+
"aria-label": "Filter Negative",
|
|
131
|
+
onClick: function onClick() {
|
|
132
|
+
return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue, true);
|
|
133
|
+
}
|
|
134
|
+
}, "negative"), /*#__PURE__*/jsx(Button, {
|
|
135
|
+
color: "primary",
|
|
136
|
+
size: "sm",
|
|
137
|
+
variant: "link",
|
|
138
|
+
icon: CoreIcons.funnelPlus,
|
|
139
|
+
"aria-label": "Filter",
|
|
140
|
+
onClick: function onClick() {
|
|
141
|
+
return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue);
|
|
142
|
+
}
|
|
143
|
+
}, "positive")] : [],
|
|
144
|
+
children: (_labeler = labeler === null || labeler === void 0 ? void 0 : labeler(path)) !== null && _labeler !== void 0 ? _labeler : field
|
|
145
|
+
});
|
|
146
|
+
}, [field, labeler, pathWithoutOrdinal, actualValue, canExpand, canFilter]);
|
|
147
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
148
|
+
children: [showPropertyTree && /*#__PURE__*/jsxs("div", {
|
|
149
|
+
className: classNames("py-2", inline && "flex flex-nowrap items-center"),
|
|
150
|
+
style: {
|
|
151
|
+
paddingInlineStart: level * 8
|
|
152
|
+
},
|
|
153
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
154
|
+
role: "none",
|
|
155
|
+
className: classNames("flex overflow-hidden items-center", inline && "flex-content"),
|
|
156
|
+
style: {
|
|
157
|
+
flexBasis: labelWidth
|
|
158
|
+
},
|
|
159
|
+
onClick: function onClick() {
|
|
160
|
+
return canExpand && setExpanded(!expanded);
|
|
161
|
+
},
|
|
162
|
+
children: [canExpand && /*#__PURE__*/jsx(Icon, {
|
|
163
|
+
rtlFlip: true,
|
|
164
|
+
icon: expanded ? CoreIcons.chevronDown : CoreIcons.chevronRight
|
|
165
|
+
}), labelDisplay]
|
|
166
|
+
}), display && /*#__PURE__*/jsxs("div", {
|
|
167
|
+
className: classNames("px-2", inline && "flex-1"),
|
|
168
|
+
children: [canCopy && /*#__PURE__*/jsx(Copy, {
|
|
169
|
+
size: "xs",
|
|
170
|
+
text: actualValue
|
|
171
|
+
}), display]
|
|
172
|
+
})]
|
|
173
|
+
}), !showPropertyTree && !children && /*#__PURE__*/jsxs("div", {
|
|
174
|
+
className: classNames("py-2", inline && "flex flex-nowrap items-center"),
|
|
175
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
176
|
+
role: "none",
|
|
177
|
+
className: classNames("flex overflow-hidden items-center", inline && "flex-content"),
|
|
178
|
+
style: {
|
|
179
|
+
flexBasis: labelWidth
|
|
180
|
+
},
|
|
181
|
+
children: labelDisplay
|
|
182
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
183
|
+
className: classNames("px-2", inline && "flex-1"),
|
|
184
|
+
children: [canCopy && /*#__PURE__*/jsx(Copy, {
|
|
185
|
+
size: "xs",
|
|
186
|
+
text: value
|
|
187
|
+
}), display]
|
|
188
|
+
})]
|
|
189
|
+
}), expanded && (children === null || children === void 0 ? void 0 : children.map(function (item) {
|
|
190
|
+
return /*#__PURE__*/jsx(JsonEntry, _objectSpread(_objectSpread({}, item), {}, {
|
|
191
|
+
level: level + 1,
|
|
192
|
+
copy: copy,
|
|
193
|
+
inline: inline,
|
|
194
|
+
showPropertyTree: showPropertyTree,
|
|
195
|
+
propertyScheme: propertyScheme,
|
|
196
|
+
filters: filters,
|
|
197
|
+
labelWidth: labelWidth,
|
|
198
|
+
formatter: formatter,
|
|
199
|
+
labeler: labeler,
|
|
200
|
+
onFilter: onFilter
|
|
201
|
+
}), item.path);
|
|
202
|
+
}))]
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
var JsonViewer = function JsonViewer(_ref5) {
|
|
206
|
+
var className = _ref5.className,
|
|
207
|
+
json = _ref5.json,
|
|
208
|
+
copy = _ref5.copy,
|
|
209
|
+
propertyScheme = _ref5.propertyScheme,
|
|
210
|
+
filters = _ref5.filters,
|
|
211
|
+
inline = _ref5.inline,
|
|
212
|
+
labelWidth = _ref5.labelWidth,
|
|
213
|
+
formatter = _ref5.formatter,
|
|
214
|
+
labeler = _ref5.labeler,
|
|
215
|
+
onFilter = _ref5.onFilter,
|
|
216
|
+
emptyMessage = _ref5.emptyMessage,
|
|
217
|
+
_ref5$showPropertyTre = _ref5.showPropertyTree,
|
|
218
|
+
showPropertyTree = _ref5$showPropertyTre === void 0 ? true : _ref5$showPropertyTre,
|
|
219
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
220
|
+
var _useTranslation2 = useTranslation("data"),
|
|
221
|
+
t = _useTranslation2.t;
|
|
222
|
+
var list = useMemo(function () {
|
|
223
|
+
return reduceObject(json);
|
|
224
|
+
}, [json]);
|
|
225
|
+
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
226
|
+
className: classNames(className, "p-4 bg-alternate"),
|
|
227
|
+
children: !isEmpty(json) ? list.map(function (item) {
|
|
228
|
+
return /*#__PURE__*/jsx(JsonEntry, _objectSpread(_objectSpread({}, item), {}, {
|
|
229
|
+
copy: copy,
|
|
230
|
+
inline: inline,
|
|
231
|
+
showPropertyTree: showPropertyTree,
|
|
232
|
+
propertyScheme: propertyScheme,
|
|
233
|
+
filters: filters,
|
|
234
|
+
labelWidth: labelWidth,
|
|
235
|
+
formatter: formatter,
|
|
236
|
+
labeler: labeler,
|
|
237
|
+
onFilter: onFilter
|
|
238
|
+
}), item.path);
|
|
239
|
+
}) : /*#__PURE__*/jsx(EmptyContent, {
|
|
240
|
+
size: "sm",
|
|
241
|
+
message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("json.empty")
|
|
242
|
+
})
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export { JsonViewer };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import { Icon, CoreIcons } from '@react-fabric/core';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { memo, useMemo, Fragment } from 'react';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
10
|
+
var page = _ref.page,
|
|
11
|
+
ranges = _ref.ranges,
|
|
12
|
+
totalPages = _ref.totalPages,
|
|
13
|
+
minimal = _ref.minimal,
|
|
14
|
+
onPageChange = _ref.onPageChange;
|
|
15
|
+
var _ranges = _slicedToArray(ranges, 3),
|
|
16
|
+
start = _ranges[0],
|
|
17
|
+
mid = _ranges[1],
|
|
18
|
+
last = _ranges[2];
|
|
19
|
+
var pageBody = useMemo(function () {
|
|
20
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
21
|
+
children: [start === null || start === void 0 ? void 0 : start.map(function (pg) {
|
|
22
|
+
return /*#__PURE__*/jsx("button", {
|
|
23
|
+
onClick: function onClick() {
|
|
24
|
+
return onPageChange(pg);
|
|
25
|
+
},
|
|
26
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
27
|
+
children: pg + 1
|
|
28
|
+
}, pg);
|
|
29
|
+
}), mid && /*#__PURE__*/jsx("span", {
|
|
30
|
+
className: "leading-none inline-block w-8 text-center text-dimmed",
|
|
31
|
+
children: "..."
|
|
32
|
+
}), mid === null || mid === void 0 ? void 0 : mid.map(function (pg) {
|
|
33
|
+
return /*#__PURE__*/jsx("button", {
|
|
34
|
+
onClick: function onClick() {
|
|
35
|
+
return onPageChange(pg);
|
|
36
|
+
},
|
|
37
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
38
|
+
children: pg + 1
|
|
39
|
+
}, pg);
|
|
40
|
+
}), last && /*#__PURE__*/jsx("span", {
|
|
41
|
+
className: "leading-none inline-block w-8 text-center text-dimmed",
|
|
42
|
+
children: "..."
|
|
43
|
+
}), last === null || last === void 0 ? void 0 : last.map(function (pg) {
|
|
44
|
+
return /*#__PURE__*/jsx("button", {
|
|
45
|
+
onClick: function onClick() {
|
|
46
|
+
return onPageChange(pg);
|
|
47
|
+
},
|
|
48
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
49
|
+
children: pg + 1
|
|
50
|
+
}, pg);
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}, [start, mid, last, page]);
|
|
54
|
+
return /*#__PURE__*/jsxs("div", {
|
|
55
|
+
className: "inline-flex items-center",
|
|
56
|
+
children: [/*#__PURE__*/jsx("button", {
|
|
57
|
+
onClick: function onClick() {
|
|
58
|
+
return onPageChange(0);
|
|
59
|
+
},
|
|
60
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
|
|
61
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
62
|
+
icon: CoreIcons.chevronsLeft,
|
|
63
|
+
rtlFlip: true
|
|
64
|
+
})
|
|
65
|
+
}), /*#__PURE__*/jsx("button", {
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
return onPageChange(page - 1);
|
|
68
|
+
},
|
|
69
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
|
|
70
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
71
|
+
icon: CoreIcons.chevronLeft,
|
|
72
|
+
rtlFlip: true
|
|
73
|
+
})
|
|
74
|
+
}), !minimal && pageBody, minimal && /*#__PURE__*/jsxs("label", {
|
|
75
|
+
className: "leading-none inline-block px-1 text-center text-sm select-none fixed-numbers",
|
|
76
|
+
children: [page + 1, "/", totalPages]
|
|
77
|
+
}), /*#__PURE__*/jsx("button", {
|
|
78
|
+
onClick: function onClick() {
|
|
79
|
+
return onPageChange(page + 1);
|
|
80
|
+
},
|
|
81
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
|
|
82
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
83
|
+
icon: CoreIcons.chevronRight,
|
|
84
|
+
rtlFlip: true
|
|
85
|
+
})
|
|
86
|
+
}), /*#__PURE__*/jsx("button", {
|
|
87
|
+
onClick: function onClick() {
|
|
88
|
+
return onPageChange(totalPages - 1);
|
|
89
|
+
},
|
|
90
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
|
|
91
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
92
|
+
icon: CoreIcons.chevronsRight,
|
|
93
|
+
rtlFlip: true
|
|
94
|
+
})
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
Pagination.displayName = "Pagination";
|
|
99
|
+
|
|
100
|
+
export { Pagination };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* React Fabric
|
|
8
|
+
* @version: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
15
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
16
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
17
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
21
|
+
* portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
24
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
25
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
26
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
var BodyCell = function BodyCell(_ref) {
|
|
30
|
+
var _column$width, _column$minWidth, _column$maxWidth, _column$renderer, _column$renderer2;
|
|
31
|
+
var column = _ref.column,
|
|
32
|
+
item = _ref.item;
|
|
33
|
+
return /*#__PURE__*/jsx("div", {
|
|
34
|
+
className: "overflow-hidden bg-inherit start-0",
|
|
35
|
+
style: {
|
|
36
|
+
width: (_column$width = column.width) !== null && _column$width !== void 0 ? _column$width : "12rem",
|
|
37
|
+
minWidth: (_column$minWidth = column.minWidth) !== null && _column$minWidth !== void 0 ? _column$minWidth : "2rem",
|
|
38
|
+
maxWidth: (_column$maxWidth = column.maxWidth) !== null && _column$maxWidth !== void 0 ? _column$maxWidth : "32rem"
|
|
39
|
+
},
|
|
40
|
+
children: /*#__PURE__*/jsx("div", {
|
|
41
|
+
className: classNames("px-2 py-1 border-e truncate", column.align === "center" && "text-center", column.align === "end" && "text-end"),
|
|
42
|
+
children: (_column$renderer = (_column$renderer2 = column.renderer) === null || _column$renderer2 === void 0 ? void 0 : _column$renderer2.call(column, item[column.id], item)) !== null && _column$renderer !== void 0 ? _column$renderer : item[column.id]
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { BodyCell };
|