@digigov/ui 0.32.2 → 0.33.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/CHANGELOG.md +12 -1
- package/admin/Drawer/__stories__/Default.js +3 -0
- package/admin/Dropdown/index.d.ts +1 -1
- package/admin/Dropdown/index.js +14 -3
- package/core/CaretContainer/index.d.ts +3 -0
- package/core/CaretContainer/index.js +30 -0
- package/core/Table/Table.stories.d.ts +1 -0
- package/core/Table/Table.stories.js +14 -0
- package/core/Table/Table.stories.playwright.json +16 -0
- package/core/Table/__stories__/WithSortFilters.d.ts +2 -0
- package/core/Table/__stories__/WithSortFilters.js +141 -0
- package/core/Table/index.d.ts +22 -1
- package/core/Table/index.js +210 -24
- package/core/index.d.ts +1 -0
- package/core/index.js +13 -0
- package/es/admin/Drawer/__stories__/Default.js +3 -0
- package/es/admin/Dropdown/index.js +14 -3
- package/es/core/CaretContainer/index.js +3 -0
- package/es/core/Table/Table.stories.js +1 -0
- package/es/core/Table/Table.stories.playwright.json +16 -0
- package/es/core/Table/__stories__/WithSortFilters.js +126 -0
- package/es/core/Table/index.js +170 -1
- package/es/core/index.js +1 -0
- package/es/registry.js +2 -0
- package/esm/admin/Drawer/__stories__/Default.js +3 -0
- package/esm/admin/Dropdown/index.js +14 -3
- package/esm/core/CaretContainer/index.js +3 -0
- package/esm/core/Table/Table.stories.js +1 -0
- package/esm/core/Table/Table.stories.playwright.json +16 -0
- package/esm/core/Table/__stories__/WithSortFilters.js +126 -0
- package/esm/core/Table/index.js +170 -1
- package/esm/core/index.js +1 -0
- package/esm/index.js +1 -1
- package/esm/registry.js +2 -0
- package/package.json +3 -3
- package/registry.d.ts +1 -0
- package/registry.js +3 -0
- package/src/admin/Drawer/__stories__/Default.tsx +3 -1
- package/src/admin/Dropdown/index.tsx +16 -7
- package/src/core/CaretContainer/index.tsx +3 -0
- package/src/core/Table/Table.stories.js +1 -0
- package/src/core/Table/Table.stories.playwright.json +16 -0
- package/src/core/Table/__stories__/WithSortFilters.tsx +189 -0
- package/src/core/Table/index.tsx +195 -2
- package/src/core/index.ts +1 -0
- package/src/registry.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Change Log - @digigov/ui
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 19 May 2023 13:15:06 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.33.0
|
|
6
|
+
Fri, 19 May 2023 13:15:06 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Implement TableHeadCellSort logic for table, fix close Dropdown by clicking escape
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- Fix default Drawer
|
|
4
15
|
|
|
5
16
|
## 0.32.2
|
|
6
17
|
Tue, 16 May 2023 13:42:28 GMT
|
|
@@ -98,7 +98,9 @@ var Default = function Default() {
|
|
|
98
98
|
|
|
99
99
|
var layout = 'vertical';
|
|
100
100
|
var border = false;
|
|
101
|
+
var fixed = false;
|
|
101
102
|
return /*#__PURE__*/_react["default"].createElement(_Drawer.Drawer, {
|
|
103
|
+
upRelative: "m",
|
|
102
104
|
direction: "left",
|
|
103
105
|
open: open
|
|
104
106
|
}, /*#__PURE__*/_react["default"].createElement(_Drawer.DrawerHeading, {
|
|
@@ -109,6 +111,7 @@ var Default = function Default() {
|
|
|
109
111
|
layout: layout,
|
|
110
112
|
links: links,
|
|
111
113
|
border: border,
|
|
114
|
+
fixed: fixed,
|
|
112
115
|
"aria-label": "Nav list"
|
|
113
116
|
}, links.map(function (item, key) {
|
|
114
117
|
var _item$subMenu;
|
|
@@ -17,6 +17,6 @@ export interface DropdownProps extends DropdownBaseProps {
|
|
|
17
17
|
/**
|
|
18
18
|
* Dropdown component is used for showing more options with a button.
|
|
19
19
|
*/
|
|
20
|
-
export declare const Dropdown:
|
|
20
|
+
export declare const Dropdown: React.ForwardRefExoticComponent<Pick<DropdownProps, "slot" | "style" | "title" | "as" | "className" | "color" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "disabled" | "open" | "onToggle" | "align" | "margin" | "marginTop" | "marginBottom" | "marginLeft" | "marginRight" | "padding" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "printHidden" | "xsUpHidden" | "smUpHidden" | "mdUpHidden" | "lgUpHidden" | "xlUpHidden" | "xsHidden" | "smHidden" | "mdHidden" | "lgHidden" | "xlHidden" | "placement" | "closeBehaviour" | "float"> & React.RefAttributes<HTMLDetailsElement>>;
|
|
21
21
|
export { DropdownBase };
|
|
22
22
|
export default Dropdown;
|
package/admin/Dropdown/index.js
CHANGED
|
@@ -64,15 +64,22 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
64
64
|
/**
|
|
65
65
|
* Dropdown component is used for showing more options with a button.
|
|
66
66
|
*/
|
|
67
|
-
var Dropdown = function Dropdown(_ref) {
|
|
67
|
+
var Dropdown = /*#__PURE__*/_react["default"].forwardRef(function Dropdown(_ref, ref) {
|
|
68
68
|
var _ref$closeBehaviour = _ref.closeBehaviour,
|
|
69
69
|
closeBehaviour = _ref$closeBehaviour === void 0 ? 'clickOutside' : _ref$closeBehaviour,
|
|
70
70
|
_ref$float = _ref["float"],
|
|
71
71
|
_float = _ref$float === void 0 ? false : _ref$float,
|
|
72
72
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
73
73
|
|
|
74
|
-
var innerRef = (0, _react.useRef)();
|
|
74
|
+
var innerRef = ref || (0, _react.useRef)();
|
|
75
75
|
(0, _react.useEffect)(function () {
|
|
76
|
+
var keyDownHandler = function keyDownHandler(event) {
|
|
77
|
+
if (event.key === 'Escape') {
|
|
78
|
+
innerRef.current.open = false;
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
76
83
|
var handleClickOutside = function handleClickOutside(event) {
|
|
77
84
|
if (innerRef.current && !innerRef.current.contains(event.target)) {
|
|
78
85
|
innerRef.current.open = false;
|
|
@@ -83,6 +90,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
83
90
|
document.addEventListener('click', handleClickOutside, true);
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
document.addEventListener('keydown', keyDownHandler);
|
|
94
|
+
|
|
86
95
|
var toggleFloat = function toggleFloat() {
|
|
87
96
|
var _innerRef$current;
|
|
88
97
|
|
|
@@ -130,6 +139,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
130
139
|
if (_float) {
|
|
131
140
|
innerRef.current.removeEventListener('toggle', toggleFloat);
|
|
132
141
|
}
|
|
142
|
+
|
|
143
|
+
document.removeEventListener('keydown', keyDownHandler);
|
|
133
144
|
};
|
|
134
145
|
}, []); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
146
|
// @ts-ignore
|
|
@@ -137,7 +148,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
137
148
|
return /*#__PURE__*/_react["default"].createElement(_DropdownBase["default"], (0, _extends2["default"])({
|
|
138
149
|
ref: innerRef
|
|
139
150
|
}, props));
|
|
140
|
-
};
|
|
151
|
+
});
|
|
141
152
|
|
|
142
153
|
exports.Dropdown = Dropdown;
|
|
143
154
|
var _default = Dropdown;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {};
|
|
9
|
+
exports["default"] = void 0;
|
|
10
|
+
|
|
11
|
+
var _CaretContainer = _interopRequireWildcard(require("@digigov/react-core/CaretContainer"));
|
|
12
|
+
|
|
13
|
+
Object.keys(_CaretContainer).forEach(function (key) {
|
|
14
|
+
if (key === "default" || key === "__esModule") return;
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
+
if (key in exports && exports[key] === _CaretContainer[key]) return;
|
|
17
|
+
Object.defineProperty(exports, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function get() {
|
|
20
|
+
return _CaretContainer[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
|
+
|
|
27
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
|
|
29
|
+
var _default = _CaretContainer["default"];
|
|
30
|
+
exports["default"] = _default;
|
|
@@ -19,6 +19,7 @@ export * from "./__stories__/WithLoader";
|
|
|
19
19
|
export * from "./__stories__/DefinedWidth";
|
|
20
20
|
export * from "./__stories__/Densed";
|
|
21
21
|
export * from "./__stories__/MultipleProps";
|
|
22
|
+
export * from "./__stories__/WithSortFilters";
|
|
22
23
|
export * from "./__stories__/WithFloatingScroll";
|
|
23
24
|
export * from "./__stories__/Full";
|
|
24
25
|
import Table from "@digigov/ui/core/Table";
|
|
@@ -192,6 +192,20 @@ Object.keys(_MultipleProps).forEach(function (key) {
|
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
+
var _WithSortFilters = require("./__stories__/WithSortFilters");
|
|
196
|
+
|
|
197
|
+
Object.keys(_WithSortFilters).forEach(function (key) {
|
|
198
|
+
if (key === "default" || key === "__esModule") return;
|
|
199
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
200
|
+
if (key in exports && exports[key] === _WithSortFilters[key]) return;
|
|
201
|
+
Object.defineProperty(exports, key, {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get: function get() {
|
|
204
|
+
return _WithSortFilters[key];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
195
209
|
var _WithFloatingScroll = require("./__stories__/WithFloatingScroll");
|
|
196
210
|
|
|
197
211
|
Object.keys(_WithFloatingScroll).forEach(function (key) {
|
|
@@ -16,6 +16,22 @@
|
|
|
16
16
|
"title": "Toggle Loading"
|
|
17
17
|
}
|
|
18
18
|
]
|
|
19
|
+
},
|
|
20
|
+
"digigov-ui-core-table--with-sort-filters": {
|
|
21
|
+
"actionSets": [
|
|
22
|
+
{
|
|
23
|
+
"actions": [
|
|
24
|
+
{
|
|
25
|
+
"name": "click",
|
|
26
|
+
"args": {
|
|
27
|
+
"selector": "html>body>div:nth-child(5)>div>div>table>thead>tr>th:nth-child(2)>details>summary"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"id": "Gdm_Fpollj7d",
|
|
32
|
+
"title": "Table with filter action"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
19
35
|
}
|
|
20
36
|
}
|
|
21
37
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.WithSortFilters = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _Table = require("@digigov/ui/core/Table");
|
|
15
|
+
|
|
16
|
+
var headerItems = [{
|
|
17
|
+
name: 'product',
|
|
18
|
+
label: 'Προϊόν',
|
|
19
|
+
sortLabels: [{
|
|
20
|
+
label: 'Αλφαβητική σειρά (Α -> Ω)',
|
|
21
|
+
direction: 'asc',
|
|
22
|
+
value: 1
|
|
23
|
+
}, {
|
|
24
|
+
label: 'Αλφαβητική σειρά (Ω -> Α)',
|
|
25
|
+
direction: 'desc',
|
|
26
|
+
value: -1
|
|
27
|
+
}]
|
|
28
|
+
}, {
|
|
29
|
+
name: 'price',
|
|
30
|
+
label: 'Τιμή',
|
|
31
|
+
sortLabels: [{
|
|
32
|
+
label: 'Αύξουσα σειρά',
|
|
33
|
+
direction: 'ascending',
|
|
34
|
+
value: 1
|
|
35
|
+
}, {
|
|
36
|
+
label: 'Φθίνουσα σειρά',
|
|
37
|
+
direction: 'descending',
|
|
38
|
+
value: -1
|
|
39
|
+
}]
|
|
40
|
+
}, {
|
|
41
|
+
name: 'stock',
|
|
42
|
+
label: 'Στοκ',
|
|
43
|
+
sortLabels: [{
|
|
44
|
+
label: 'Αύξουσα σειρά',
|
|
45
|
+
direction: 'ascending',
|
|
46
|
+
value: 1
|
|
47
|
+
}, {
|
|
48
|
+
label: 'Φθίνουσα σειρά',
|
|
49
|
+
direction: 'descending',
|
|
50
|
+
value: -1
|
|
51
|
+
}]
|
|
52
|
+
}, {
|
|
53
|
+
name: 'date',
|
|
54
|
+
label: 'Ημερομηνία',
|
|
55
|
+
sortLabels: [{
|
|
56
|
+
label: 'Αύξουσα σειρά',
|
|
57
|
+
direction: 'ascending',
|
|
58
|
+
value: 1
|
|
59
|
+
}, {
|
|
60
|
+
label: 'Φθίνουσα σειρά',
|
|
61
|
+
direction: 'descending',
|
|
62
|
+
value: -1
|
|
63
|
+
}]
|
|
64
|
+
}];
|
|
65
|
+
var data = [{
|
|
66
|
+
id: 1,
|
|
67
|
+
product: 'Τυρί',
|
|
68
|
+
price: '4.9€',
|
|
69
|
+
stock: 20,
|
|
70
|
+
date: '2013-04-01'
|
|
71
|
+
}, {
|
|
72
|
+
id: 2,
|
|
73
|
+
product: 'Γάλα',
|
|
74
|
+
price: '1.9€',
|
|
75
|
+
stock: 32,
|
|
76
|
+
date: '2013-01-01'
|
|
77
|
+
}, {
|
|
78
|
+
id: 3,
|
|
79
|
+
product: 'Γιαούρτι',
|
|
80
|
+
price: '2.4€',
|
|
81
|
+
stock: 12,
|
|
82
|
+
date: '2002-04-12'
|
|
83
|
+
}, {
|
|
84
|
+
id: 4,
|
|
85
|
+
product: 'Κρέμα',
|
|
86
|
+
price: '3.9€',
|
|
87
|
+
stock: 8,
|
|
88
|
+
date: '2011-12-12'
|
|
89
|
+
}, {
|
|
90
|
+
id: 5,
|
|
91
|
+
product: 'Βούτυρο',
|
|
92
|
+
price: '0.9€',
|
|
93
|
+
stock: 99,
|
|
94
|
+
date: '2019-06-01'
|
|
95
|
+
}, {
|
|
96
|
+
id: 6,
|
|
97
|
+
product: 'Καφές',
|
|
98
|
+
price: '2.9€',
|
|
99
|
+
stock: 86,
|
|
100
|
+
date: '2023-02-11'
|
|
101
|
+
}, {
|
|
102
|
+
id: 7,
|
|
103
|
+
product: 'Ψωμί',
|
|
104
|
+
price: '99€',
|
|
105
|
+
stock: 12,
|
|
106
|
+
date: '2000-12-12'
|
|
107
|
+
}];
|
|
108
|
+
|
|
109
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_Table.TableCaption, null, "Table of products");
|
|
110
|
+
|
|
111
|
+
var _ref2 = /*#__PURE__*/_react["default"].createElement(_Table.TableNoDataRow, null, "No data");
|
|
112
|
+
|
|
113
|
+
var WithSortFilters = function WithSortFilters() {
|
|
114
|
+
var _useSortableData = (0, _Table.useSortableData)(data),
|
|
115
|
+
sortedData = _useSortableData.sortedData,
|
|
116
|
+
sortedProps = _useSortableData.sortedProps;
|
|
117
|
+
|
|
118
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
119
|
+
className: "example"
|
|
120
|
+
}, /*#__PURE__*/_react["default"].createElement(_Table.TableContainer
|
|
121
|
+
/* Possible style solution in order to display dropdown properly when we have only one table row
|
|
122
|
+
* style={{
|
|
123
|
+
* overflow: 'inherit',
|
|
124
|
+
* }}
|
|
125
|
+
*/
|
|
126
|
+
, null, /*#__PURE__*/_react["default"].createElement(_Table.Table, null, _ref, /*#__PURE__*/_react["default"].createElement(_Table.TableHead, null, /*#__PURE__*/_react["default"].createElement(_Table.TableRow, null, headerItems && headerItems.length > 0 && headerItems.map(function (header, index) {
|
|
127
|
+
return /*#__PURE__*/_react["default"].createElement(_Table.TableHeadCellSort, (0, _extends2["default"])({
|
|
128
|
+
key: index
|
|
129
|
+
}, sortedProps, {
|
|
130
|
+
headerItems: header
|
|
131
|
+
}), header.label);
|
|
132
|
+
}))), /*#__PURE__*/_react["default"].createElement(_Table.TableBody, null, sortedData && sortedData.length > 0 ? sortedData.map(function (d, index) {
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement(_Table.TableRow, {
|
|
134
|
+
key: index
|
|
135
|
+
}, /*#__PURE__*/_react["default"].createElement(_Table.TableDataCell, null, d.product), /*#__PURE__*/_react["default"].createElement(_Table.TableDataCell, null, d.price), /*#__PURE__*/_react["default"].createElement(_Table.TableDataCell, null, d.stock), /*#__PURE__*/_react["default"].createElement(_Table.TableDataCell, null, new Date(d.date).toLocaleDateString('en-GB')));
|
|
136
|
+
}) : _ref2))));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
exports.WithSortFilters = WithSortFilters;
|
|
140
|
+
var _default = WithSortFilters;
|
|
141
|
+
exports["default"] = _default;
|
package/core/Table/index.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Table from '@digigov/react-core/Table';
|
|
3
|
+
import { TableHeadCellProps as TableHeadCellSortProps } from '@digigov/react-core/TableHeadCell';
|
|
4
|
+
export interface sortedProps extends TableHeadCellSortProps {
|
|
5
|
+
sortedAscDesc?: (x: any, y: number) => void;
|
|
6
|
+
sortedField?: string;
|
|
7
|
+
sortedDirectionValue?: number;
|
|
8
|
+
headerItems?: any;
|
|
9
|
+
sortedData?: any[];
|
|
10
|
+
}
|
|
11
|
+
declare const useSortableData: (items: any) => {
|
|
12
|
+
sortedData: any[] | undefined;
|
|
13
|
+
sortedProps: {
|
|
14
|
+
sortedData: any[] | undefined;
|
|
15
|
+
sortedDirectionValue: number;
|
|
16
|
+
sortedField: string;
|
|
17
|
+
sortedAscDesc: (item: any, value: any) => void;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
declare const TableHeadCellSort: React.ForwardRefExoticComponent<Pick<sortedProps, "abbr" | "slot" | "style" | "title" | "as" | "className" | "color" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "align" | "colSpan" | "headers" | "rowSpan" | "scope" | "margin" | "marginTop" | "marginBottom" | "marginLeft" | "marginRight" | "padding" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "printHidden" | "xsUpHidden" | "smUpHidden" | "mdUpHidden" | "lgUpHidden" | "xlUpHidden" | "xsHidden" | "smHidden" | "mdHidden" | "lgHidden" | "xlHidden" | "dataType" | "cellWidth" | "sortedAscDesc" | "sortedField" | "sortedDirectionValue" | "headerItems" | "sortedData"> & React.RefAttributes<HTMLTableCellElement>>;
|
|
21
|
+
export declare const TableHeadCellSortBase: React.ForwardRefExoticComponent<Pick<sortedProps, "abbr" | "slot" | "style" | "title" | "as" | "className" | "color" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "align" | "colSpan" | "headers" | "rowSpan" | "scope" | "margin" | "marginTop" | "marginBottom" | "marginLeft" | "marginRight" | "padding" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "printHidden" | "xsUpHidden" | "smUpHidden" | "mdUpHidden" | "lgUpHidden" | "xlUpHidden" | "xsHidden" | "smHidden" | "mdHidden" | "lgHidden" | "xlHidden" | "dataType" | "cellWidth" | "sortedAscDesc" | "sortedField" | "sortedDirectionValue" | "headerItems" | "sortedData"> & React.RefAttributes<HTMLTableCellElement>>;
|
|
1
22
|
export * from '@digigov/react-core/TableContainer';
|
|
2
23
|
export * from '@digigov/react-core/Table';
|
|
3
24
|
export * from '@digigov/react-core/TableBody';
|
|
@@ -8,5 +29,5 @@ export * from '@digigov/react-core/TableHeadCell';
|
|
|
8
29
|
export * from '@digigov/react-core/TableRow';
|
|
9
30
|
export * from '@digigov/react-core/TableNoDataRow';
|
|
10
31
|
export * from '@digigov/ui/core/Table/TableFloatingScroll';
|
|
11
|
-
|
|
32
|
+
export { TableHeadCellSort, useSortableData };
|
|
12
33
|
export default Table;
|