superdesk-ui-framework 2.4.14 → 2.4.15
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/app/index.js +1 -0
- package/app/scripts/modals.js +23 -9
- package/app/styles/_buttons.scss +17 -0
- package/app/styles/_modals.scss +23 -17
- package/app/styles/_tooltips.scss +66 -0
- package/app/styles/app.scss +1 -0
- package/app/styles/components/_sd-toaster.scss +6 -5
- package/app/styles/form-elements/_inputs.scss +1 -0
- package/app/styles/form-elements/_select-grid.scss +77 -0
- package/app/styles/pr-superdesk-theme.scss +3 -1
- package/app/styles/primereact/_pr-menu.scss +38 -0
- package/app/styles/primereact/_pr-skeleton.scss +35 -0
- package/app/styles/variables/_colors.scss +30 -18
- package/app-typescript/components/Button.tsx +2 -2
- package/app-typescript/components/DropdownFirst.tsx +2 -2
- package/app-typescript/components/IconPicker.tsx +277 -0
- package/app-typescript/components/ListItemLoader.tsx +30 -0
- package/app-typescript/components/Menu.tsx +149 -0
- package/app-typescript/components/PropsList.tsx +2 -2
- package/app-typescript/components/Radio.tsx +19 -10
- package/app-typescript/components/SelectGrid.tsx +233 -0
- package/app-typescript/components/SelectWithTemplate.tsx +0 -2
- package/app-typescript/components/Skeleton.tsx +48 -0
- package/app-typescript/components/Toast.tsx +31 -5
- package/app-typescript/components/ToastMessage.tsx +9 -16
- package/app-typescript/components/ToastText.tsx +2 -4
- package/app-typescript/components/ToastWrapper.tsx +4 -4
- package/app-typescript/components/Togglebox.tsx +108 -0
- package/app-typescript/components/Tooltip.tsx +25 -1
- package/app-typescript/index.ts +8 -0
- package/dist/components/modals.html +180 -4
- package/dist/examples.bundle.css +52 -36
- package/dist/examples.bundle.js +5527 -2989
- package/dist/react/Alerts.tsx +4 -4
- package/dist/react/Autocomplete.tsx +17 -17
- package/dist/react/Badges.tsx +4 -4
- package/dist/react/BigIconFont.tsx +3 -3
- package/dist/react/ButtonGroups.tsx +6 -6
- package/dist/react/Buttons.tsx +11 -11
- package/dist/react/Carousel.tsx +15 -15
- package/dist/react/Checkboxs.tsx +10 -10
- package/dist/react/DatePicker.tsx +6 -6
- package/dist/react/Dropdowns.tsx +15 -15
- package/dist/react/EmptyStates.tsx +4 -4
- package/dist/react/GridItem.tsx +8 -8
- package/dist/react/GridList.tsx +3 -3
- package/dist/react/IconButtons.tsx +3 -3
- package/dist/react/IconFont.tsx +10 -9
- package/dist/react/IconLabels.tsx +4 -4
- package/dist/react/IconPicker.tsx +65 -0
- package/dist/react/Index.tsx +27 -2
- package/dist/react/Inputs.tsx +9 -9
- package/dist/react/Labels.tsx +6 -6
- package/dist/react/LeftNavigations.tsx +6 -6
- package/dist/react/ListItems.tsx +34 -0
- package/dist/react/Menu.tsx +159 -0
- package/dist/react/Modal.tsx +9 -9
- package/dist/react/NavButtons.tsx +7 -7
- package/dist/react/Popover.tsx +5 -5
- package/dist/react/Radios.tsx +29 -29
- package/dist/react/SelectGrid.tsx +121 -0
- package/dist/react/Selects.tsx +8 -8
- package/dist/react/Switch.tsx +5 -5
- package/dist/react/Tabs.tsx +12 -12
- package/dist/react/TimePicker.tsx +4 -4
- package/dist/react/Toasts.tsx +44 -56
- package/dist/react/Togglebox.tsx +51 -0
- package/dist/react/Tooltips.tsx +48 -4
- package/dist/superdesk-ui.bundle.css +3771 -94
- package/dist/superdesk-ui.bundle.js +4468 -2037
- package/dist/vendor.bundle.js +53380 -53380
- package/examples/pages/components/modals.html +180 -4
- package/examples/pages/react/Alerts.tsx +4 -4
- package/examples/pages/react/Autocomplete.tsx +17 -17
- package/examples/pages/react/Badges.tsx +4 -4
- package/examples/pages/react/BigIconFont.tsx +3 -3
- package/examples/pages/react/ButtonGroups.tsx +6 -6
- package/examples/pages/react/Buttons.tsx +11 -11
- package/examples/pages/react/Carousel.tsx +15 -15
- package/examples/pages/react/Checkboxs.tsx +10 -10
- package/examples/pages/react/DatePicker.tsx +6 -6
- package/examples/pages/react/Dropdowns.tsx +15 -15
- package/examples/pages/react/EmptyStates.tsx +4 -4
- package/examples/pages/react/GridItem.tsx +8 -8
- package/examples/pages/react/GridList.tsx +3 -3
- package/examples/pages/react/IconButtons.tsx +3 -3
- package/examples/pages/react/IconFont.tsx +10 -9
- package/examples/pages/react/IconLabels.tsx +4 -4
- package/examples/pages/react/IconPicker.tsx +65 -0
- package/examples/pages/react/Index.tsx +27 -2
- package/examples/pages/react/Inputs.tsx +9 -9
- package/examples/pages/react/Labels.tsx +6 -6
- package/examples/pages/react/LeftNavigations.tsx +6 -6
- package/examples/pages/react/ListItems.tsx +34 -0
- package/examples/pages/react/Menu.tsx +159 -0
- package/examples/pages/react/Modal.tsx +9 -9
- package/examples/pages/react/NavButtons.tsx +7 -7
- package/examples/pages/react/Popover.tsx +5 -5
- package/examples/pages/react/Radios.tsx +29 -29
- package/examples/pages/react/SelectGrid.tsx +121 -0
- package/examples/pages/react/Selects.tsx +8 -8
- package/examples/pages/react/Switch.tsx +5 -5
- package/examples/pages/react/Tabs.tsx +12 -12
- package/examples/pages/react/TimePicker.tsx +4 -4
- package/examples/pages/react/Toasts.tsx +44 -56
- package/examples/pages/react/Togglebox.tsx +51 -0
- package/examples/pages/react/Tooltips.tsx +48 -4
- package/package.json +2 -2
- package/patches/@superdesk+primereact+5.0.2-4.patch +13 -0
- package/react/components/Button.d.ts +1 -1
- package/react/components/Button.js +2 -1
- package/react/components/DropdownFirst.js +1 -1
- package/react/components/IconPicker.d.ts +24 -0
- package/react/components/IconPicker.js +283 -0
- package/react/components/ListItemLoader.d.ts +4 -0
- package/react/components/ListItemLoader.js +62 -0
- package/react/components/Menu.d.ts +59 -0
- package/react/components/Menu.js +92 -0
- package/react/components/PropsList.d.ts +1 -1
- package/react/components/PropsList.js +1 -1
- package/react/components/Radio.d.ts +8 -7
- package/react/components/Radio.js +1 -1
- package/react/components/SelectGrid.d.ts +45 -0
- package/react/components/SelectGrid.js +179 -0
- package/react/components/SelectWithTemplate.js +0 -1
- package/react/components/Skeleton.d.ts +30 -0
- package/react/components/Skeleton.js +55 -0
- package/react/components/Toast.d.ts +15 -0
- package/react/components/Toast.js +69 -0
- package/react/components/ToastMessage.d.ts +18 -0
- package/react/components/ToastMessage.js +66 -0
- package/react/components/ToastText.d.ts +9 -0
- package/react/components/ToastText.js +42 -0
- package/react/components/ToastWrapper.d.ts +31 -0
- package/react/components/ToastWrapper.js +116 -0
- package/react/components/Togglebox.d.ts +27 -0
- package/react/components/Togglebox.js +76 -0
- package/react/components/Tooltip.d.ts +2 -5
- package/react/components/Tooltip.js +48 -7
- package/react/index.d.ts +7 -0
- package/react/index.js +14 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
17
|
+
};
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
19
|
+
exports.Menu = void 0;
|
20
|
+
var react_1 = __importDefault(require("react"));
|
21
|
+
var tieredmenu_1 = require("@superdesk/primereact/tieredmenu");
|
22
|
+
var superdeskTopBarZIndex = 1030;
|
23
|
+
var Menu = /** @class */ (function (_super) {
|
24
|
+
__extends(Menu, _super);
|
25
|
+
function Menu(props) {
|
26
|
+
var _this = _super.call(this, props) || this;
|
27
|
+
_this.menu = null;
|
28
|
+
_this.focusedBefore = null;
|
29
|
+
_this.close = _this.close.bind(_this);
|
30
|
+
_this.toggle = _this.toggle.bind(_this);
|
31
|
+
_this.toPrimeReactInterface = _this.toPrimeReactInterface.bind(_this);
|
32
|
+
return _this;
|
33
|
+
}
|
34
|
+
Menu.prototype.toPrimeReactInterface = function (items) {
|
35
|
+
var _this = this;
|
36
|
+
return items.map(function (item) {
|
37
|
+
if (item.separator != null) {
|
38
|
+
return { separator: true };
|
39
|
+
}
|
40
|
+
else if (item.children != null) {
|
41
|
+
return {
|
42
|
+
label: item.label,
|
43
|
+
icon: item.icon,
|
44
|
+
items: _this.toPrimeReactInterface(item.children),
|
45
|
+
};
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
return {
|
49
|
+
label: item.label,
|
50
|
+
icon: item.icon,
|
51
|
+
command: function (event) {
|
52
|
+
_this.close(event);
|
53
|
+
item.onClick();
|
54
|
+
},
|
55
|
+
disabled: item.disabled,
|
56
|
+
};
|
57
|
+
}
|
58
|
+
});
|
59
|
+
};
|
60
|
+
Menu.prototype.toggle = function (event) {
|
61
|
+
var _a;
|
62
|
+
(_a = this.menu) === null || _a === void 0 ? void 0 : _a.toggle(event);
|
63
|
+
};
|
64
|
+
Menu.prototype.close = function (event) {
|
65
|
+
var _a;
|
66
|
+
(_a = this.menu) === null || _a === void 0 ? void 0 : _a.toggle(event);
|
67
|
+
};
|
68
|
+
Menu.prototype.render = function () {
|
69
|
+
var _this = this;
|
70
|
+
var _a;
|
71
|
+
return (react_1.default.createElement("div", null,
|
72
|
+
this.props.children(this.toggle),
|
73
|
+
react_1.default.createElement("div", { onKeyDown: function (event) {
|
74
|
+
if (event.key === 'Escape') {
|
75
|
+
event.stopPropagation();
|
76
|
+
_this.close(event);
|
77
|
+
if (_this.focusedBefore instanceof HTMLElement) {
|
78
|
+
_this.focusedBefore.focus();
|
79
|
+
}
|
80
|
+
}
|
81
|
+
} },
|
82
|
+
react_1.default.createElement(tieredmenu_1.TieredMenu, { popup: true, model: this.toPrimeReactInterface(this.props.items), ref: function (el) { return _this.menu = el; }, appendTo: document.body, onShow: function () {
|
83
|
+
_this.focusedBefore = document.activeElement;
|
84
|
+
var firstMenuItem = document.querySelectorAll('.p-tieredmenu [role="menuitem"]')[0];
|
85
|
+
if (firstMenuItem instanceof HTMLElement) {
|
86
|
+
firstMenuItem.focus();
|
87
|
+
}
|
88
|
+
}, "data-test-id": "menu", baseZIndex: (_a = this.props.zIndex) !== null && _a !== void 0 ? _a : superdeskTopBarZIndex }))));
|
89
|
+
};
|
90
|
+
return Menu;
|
91
|
+
}(react_1.default.Component));
|
92
|
+
exports.Menu = Menu;
|
@@ -43,7 +43,7 @@ var Prop = /** @class */ (function (_super) {
|
|
43
43
|
return (React.createElement(React.Fragment, null,
|
44
44
|
React.createElement("tr", null,
|
45
45
|
React.createElement("td", null, this.props.name),
|
46
|
-
React.createElement("td", null, this.props.
|
46
|
+
React.createElement("td", null, this.props.isRequired ? 'yes' : 'no'),
|
47
47
|
React.createElement("td", null, this.props.type),
|
48
48
|
React.createElement("td", null, this.props.default),
|
49
49
|
React.createElement("td", null, this.props.description))));
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
+
interface IOption {
|
3
|
+
label: string;
|
4
|
+
value: string;
|
5
|
+
disabled?: boolean;
|
6
|
+
}
|
2
7
|
interface IProps {
|
3
|
-
value?:
|
4
|
-
options: Array<
|
5
|
-
label: string;
|
6
|
-
value: string;
|
7
|
-
disabled?: boolean;
|
8
|
-
}>;
|
8
|
+
value?: IOption['value'];
|
9
|
+
options: Array<IOption>;
|
9
10
|
labelSide?: 'left' | 'right';
|
10
11
|
required?: boolean;
|
11
|
-
onChange(nextValue:
|
12
|
+
onChange(nextValue: IOption['value']): void;
|
12
13
|
}
|
13
14
|
export declare class Radio extends React.Component<IProps> {
|
14
15
|
htmlId: string;
|
@@ -54,7 +54,7 @@ var Radio = /** @class */ (function (_super) {
|
|
54
54
|
Radio.prototype.render = function () {
|
55
55
|
var _this = this;
|
56
56
|
return (this.props.options.map(function (item, index) { return (React.createElement("span", { className: "sd-check-new__wrapper", key: index, "label-position": _this.props.labelSide || null, tabIndex: -1 },
|
57
|
-
React.createElement("input", { type: "radio", className: "sd-check-new__input", id: _this.htmlId + index, tabIndex: 0, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: item.disabled, required: _this.props.required }),
|
57
|
+
React.createElement("input", { type: "radio", className: "sd-check-new__input", id: _this.htmlId + index, tabIndex: 0, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: item.disabled, required: _this.props.required, checked: item.value === _this.props.value }),
|
58
58
|
React.createElement("span", { className: "sd-radio-new" }),
|
59
59
|
React.createElement("label", { htmlFor: _this.htmlId + index }, item.label))); }));
|
60
60
|
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { OverlayPanel } from '@superdesk/primereact/overlaypanel';
|
3
|
+
/**
|
4
|
+
* @ngdoc react
|
5
|
+
* @name SelectGrid
|
6
|
+
* @description searchable select component with grid view of items
|
7
|
+
*/
|
8
|
+
export interface IItem {
|
9
|
+
value: string;
|
10
|
+
label: string;
|
11
|
+
[extra: string]: any;
|
12
|
+
}
|
13
|
+
interface IProps {
|
14
|
+
getItems(searchString: string | null): Promise<Array<IItem>>;
|
15
|
+
onChange(value: IItem): void;
|
16
|
+
itemTemplate: React.ComponentType<{
|
17
|
+
item: IItem | null;
|
18
|
+
}>;
|
19
|
+
triggerTemplate: React.ComponentType<any>;
|
20
|
+
label: string;
|
21
|
+
filterPlaceholder?: string;
|
22
|
+
}
|
23
|
+
interface IState {
|
24
|
+
items: Array<IItem>;
|
25
|
+
loading: boolean;
|
26
|
+
isOpen: boolean;
|
27
|
+
}
|
28
|
+
export declare class SelectGrid extends React.PureComponent<IProps, IState> {
|
29
|
+
htmlId: string;
|
30
|
+
buttonContainer: React.RefObject<HTMLDivElement>;
|
31
|
+
overlayPanel: React.RefObject<OverlayPanel>;
|
32
|
+
searchInput: React.RefObject<HTMLInputElement>;
|
33
|
+
gridContainer: React.RefObject<HTMLDivElement>;
|
34
|
+
constructor(props: IProps);
|
35
|
+
componentDidMount(): void;
|
36
|
+
componentWillUnmount(): void;
|
37
|
+
togglePopup: (event?: React.SyntheticEvent<Element, Event> | undefined) => void;
|
38
|
+
search: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
39
|
+
loadItems: (searchString?: string | null) => void;
|
40
|
+
select: (item: IItem) => void;
|
41
|
+
getItemElement: (index: number) => HTMLDivElement | null | undefined;
|
42
|
+
handleKeydown: (event: KeyboardEvent) => void;
|
43
|
+
render(): JSX.Element;
|
44
|
+
}
|
45
|
+
export {};
|
@@ -0,0 +1,179 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
17
|
+
};
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
19
|
+
exports.SelectGrid = void 0;
|
20
|
+
var react_1 = __importDefault(require("react"));
|
21
|
+
var react_id_generator_1 = __importDefault(require("react-id-generator"));
|
22
|
+
var overlaypanel_1 = require("@superdesk/primereact/overlaypanel");
|
23
|
+
var Loader_1 = require("./Loader");
|
24
|
+
var SelectGrid = /** @class */ (function (_super) {
|
25
|
+
__extends(SelectGrid, _super);
|
26
|
+
function SelectGrid(props) {
|
27
|
+
var _this = _super.call(this, props) || this;
|
28
|
+
_this.htmlId = react_id_generator_1.default();
|
29
|
+
_this.togglePopup = function (event) {
|
30
|
+
if (!event) {
|
31
|
+
// @ts-ignore
|
32
|
+
_this.overlayPanel.current.hide();
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
// @ts-ignore
|
36
|
+
_this.overlayPanel.current.toggle(event);
|
37
|
+
}
|
38
|
+
setTimeout(function () {
|
39
|
+
// Now that the popup has (dis)appeared handle items and events
|
40
|
+
var _a;
|
41
|
+
if (_this.state.isOpen) {
|
42
|
+
document.removeEventListener('keydown', _this.handleKeydown);
|
43
|
+
// @ts-ignore
|
44
|
+
(_a = _this.buttonContainer.current.querySelector('button')) === null || _a === void 0 ? void 0 : _a.focus();
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
document.addEventListener('keydown', _this.handleKeydown);
|
48
|
+
_this.loadItems();
|
49
|
+
// @ts-ignore
|
50
|
+
_this.searchInput.current.focus();
|
51
|
+
}
|
52
|
+
_this.setState({ isOpen: !_this.state.isOpen });
|
53
|
+
});
|
54
|
+
};
|
55
|
+
_this.search = function (event) {
|
56
|
+
var searchString = event.target.value.toLowerCase();
|
57
|
+
_this.loadItems(searchString);
|
58
|
+
};
|
59
|
+
_this.loadItems = function (searchString) {
|
60
|
+
if (searchString === void 0) { searchString = null; }
|
61
|
+
_this.setState({ loading: true });
|
62
|
+
_this.props.getItems(searchString).then(function (items) {
|
63
|
+
_this.setState({ items: items, loading: false });
|
64
|
+
});
|
65
|
+
};
|
66
|
+
_this.select = function (item) {
|
67
|
+
_this.props.onChange(item);
|
68
|
+
_this.togglePopup();
|
69
|
+
};
|
70
|
+
_this.getItemElement = function (index) {
|
71
|
+
var _a;
|
72
|
+
return (_a = _this.gridContainer.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-item-index=\"" + index + "\"]");
|
73
|
+
};
|
74
|
+
_this.handleKeydown = function (event) {
|
75
|
+
var _a, _b, _c, _d, _e;
|
76
|
+
var navKeys = [
|
77
|
+
"Enter",
|
78
|
+
"ArrowRight",
|
79
|
+
"ArrowLeft",
|
80
|
+
"ArrowUp",
|
81
|
+
"ArrowDown",
|
82
|
+
"PageDown",
|
83
|
+
"PageUp",
|
84
|
+
];
|
85
|
+
var activeElement = document.activeElement;
|
86
|
+
if (event.code === "Escape") {
|
87
|
+
event.preventDefault();
|
88
|
+
event.stopPropagation();
|
89
|
+
_this.togglePopup();
|
90
|
+
}
|
91
|
+
else if (activeElement === ((_a = _this.searchInput) === null || _a === void 0 ? void 0 : _a.current)) {
|
92
|
+
if (event.code === "ArrowDown") {
|
93
|
+
event.preventDefault();
|
94
|
+
(_b = _this.getItemElement(0)) === null || _b === void 0 ? void 0 : _b.focus();
|
95
|
+
}
|
96
|
+
else if (event.code === "Enter" && _this.state.items.length === 1) {
|
97
|
+
event.preventDefault();
|
98
|
+
_this.select(_this.state.items[0]);
|
99
|
+
}
|
100
|
+
// @ts-ignore
|
101
|
+
}
|
102
|
+
else if (document.activeElement.getAttribute('data-item-index') && navKeys.includes(event.code)) {
|
103
|
+
// @ts-ignore
|
104
|
+
var itemIndex = parseInt(activeElement.getAttribute('data-item-index'), 10);
|
105
|
+
// Prevent default behaviour, such as scrolling
|
106
|
+
event.preventDefault();
|
107
|
+
if (event.code === "Enter") {
|
108
|
+
_this.select(_this.state.items[itemIndex]);
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
else if (event.code === "ArrowRight") {
|
112
|
+
itemIndex += 1;
|
113
|
+
}
|
114
|
+
else if (event.code === "ArrowLeft") {
|
115
|
+
itemIndex -= 1;
|
116
|
+
}
|
117
|
+
else if (event.code === "ArrowDown") {
|
118
|
+
itemIndex += 4;
|
119
|
+
}
|
120
|
+
else if (event.code === "ArrowUp") {
|
121
|
+
if (itemIndex === 0) {
|
122
|
+
(_d = (_c = _this.searchInput) === null || _c === void 0 ? void 0 : _c.current) === null || _d === void 0 ? void 0 : _d.focus();
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
itemIndex -= 4;
|
126
|
+
}
|
127
|
+
else if (event.code === "PageDown") {
|
128
|
+
itemIndex += 16;
|
129
|
+
}
|
130
|
+
else if (event.code === "PageUp") {
|
131
|
+
itemIndex -= 16;
|
132
|
+
}
|
133
|
+
if (itemIndex < 0) {
|
134
|
+
itemIndex = 0;
|
135
|
+
}
|
136
|
+
else if (itemIndex >= _this.state.items.length) {
|
137
|
+
itemIndex = _this.state.items.length - 1;
|
138
|
+
}
|
139
|
+
(_e = _this.getItemElement(itemIndex)) === null || _e === void 0 ? void 0 : _e.focus();
|
140
|
+
}
|
141
|
+
};
|
142
|
+
_this.state = { items: [], loading: true, isOpen: false };
|
143
|
+
_this.buttonContainer = react_1.default.createRef();
|
144
|
+
_this.overlayPanel = react_1.default.createRef();
|
145
|
+
_this.searchInput = react_1.default.createRef();
|
146
|
+
_this.gridContainer = react_1.default.createRef();
|
147
|
+
return _this;
|
148
|
+
}
|
149
|
+
SelectGrid.prototype.componentDidMount = function () {
|
150
|
+
var _this = this;
|
151
|
+
this.props.getItems(null).then(function (items) {
|
152
|
+
_this.setState({ items: items, loading: false });
|
153
|
+
});
|
154
|
+
};
|
155
|
+
SelectGrid.prototype.componentWillUnmount = function () {
|
156
|
+
document.removeEventListener('keydown', this.handleKeydown);
|
157
|
+
};
|
158
|
+
SelectGrid.prototype.render = function () {
|
159
|
+
var _this = this;
|
160
|
+
var ItemTemplate = this.props.itemTemplate;
|
161
|
+
var TriggerTemplate = this.props.triggerTemplate;
|
162
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
163
|
+
react_1.default.createElement("div", { className: "sd-input sd-input--grid-select", ref: this.buttonContainer, "aria-label": this.props.label },
|
164
|
+
react_1.default.createElement("label", { className: "sd-input__label" }, this.props.label),
|
165
|
+
react_1.default.createElement(TriggerTemplate, { onClick: this.togglePopup })),
|
166
|
+
react_1.default.createElement(overlaypanel_1.OverlayPanel, { ref: this.overlayPanel, dismissable: true, className: "select-grid__overlay-panel", appendTo: document.body },
|
167
|
+
react_1.default.createElement("div", { className: "sd-shadow--z3 select-grid__panel" },
|
168
|
+
react_1.default.createElement("div", { className: "select-grid__header" },
|
169
|
+
react_1.default.createElement("div", { className: "sd-searchbar sd-searchbar--boxed" },
|
170
|
+
react_1.default.createElement("label", { className: "sd-searchbar__icon" }),
|
171
|
+
react_1.default.createElement("input", { className: "sd-searchbar__input", placeholder: this.props.filterPlaceholder || 'Search...', type: "text", onChange: this.search, ref: this.searchInput }))),
|
172
|
+
react_1.default.createElement("div", { className: "select-grid__body flex-grid flex-grid--wrap-items flex-grid--small-4 flex-grid--boxed", ref: this.gridContainer },
|
173
|
+
react_1.default.createElement(Loader_1.Loader, { overlay: this.state.loading }),
|
174
|
+
this.state.items.map(function (item, index) { return (react_1.default.createElement("div", { key: _this.htmlId + item.label, "data-item-index": index, className: "flex-grid__item select-grid__item sd-padding-y--2", tabIndex: 0, role: "button", "aria-label": item.name, onClick: function () { return _this.select(item); } },
|
175
|
+
react_1.default.createElement(ItemTemplate, { item: item }))); }))))));
|
176
|
+
};
|
177
|
+
return SelectGrid;
|
178
|
+
}(react_1.default.PureComponent));
|
179
|
+
exports.SelectGrid = SelectGrid;
|
@@ -86,7 +86,6 @@ var SelectWithTemplate = /** @class */ (function (_super) {
|
|
86
86
|
onChange(e.value == null ? null : e.value.original);
|
87
87
|
}, placeholder: fakePlaceholderWithNonBreakingSpace, filterPlaceholder: filterPlaceholder, filter: true, filterBy: labelKey, showClear: !required, emptyFilterMessage: emptyFilterMessage, valueTemplate: function (option) { return React.createElement(ItemTemplate, { option: option == null ? null : option.original }); }, itemTemplate: function (option) { return React.createElement(ItemTemplate, { option: option.original }); }, disabled: disabled, required: required, autoFocus: autoFocus, appendTo: document.body, loading: loading, onFilterInputChange: function (searchString) {
|
88
88
|
_this.setState({ loading: true });
|
89
|
-
console.log('change');
|
90
89
|
getItems(searchString).then(function (_options) {
|
91
90
|
_this.setState({ options: _options, loading: false });
|
92
91
|
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
interface IProps {
|
3
|
+
shape: string;
|
4
|
+
size: string;
|
5
|
+
width: string;
|
6
|
+
height: string;
|
7
|
+
borderRadius: string;
|
8
|
+
animation: string;
|
9
|
+
style: object;
|
10
|
+
className: string;
|
11
|
+
}
|
12
|
+
export declare class Skeleton extends React.Component<IProps> {
|
13
|
+
static defaultProps: {
|
14
|
+
shape: string;
|
15
|
+
size: null;
|
16
|
+
width: string;
|
17
|
+
height: string;
|
18
|
+
borderRadius: null;
|
19
|
+
animation: string;
|
20
|
+
style: null;
|
21
|
+
className: null;
|
22
|
+
};
|
23
|
+
skeletonStyle(): {
|
24
|
+
width: string;
|
25
|
+
height: string;
|
26
|
+
borderRadius: string;
|
27
|
+
};
|
28
|
+
render(): JSX.Element;
|
29
|
+
}
|
30
|
+
export {};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
17
|
+
};
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
19
|
+
exports.Skeleton = void 0;
|
20
|
+
var react_1 = __importDefault(require("react"));
|
21
|
+
var classnames_1 = __importDefault(require("classnames"));
|
22
|
+
var Skeleton = /** @class */ (function (_super) {
|
23
|
+
__extends(Skeleton, _super);
|
24
|
+
function Skeleton() {
|
25
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
26
|
+
}
|
27
|
+
Skeleton.prototype.skeletonStyle = function () {
|
28
|
+
if (this.props.size) {
|
29
|
+
return { width: this.props.size, height: this.props.size, borderRadius: this.props.borderRadius };
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
return { width: this.props.width, height: this.props.height, borderRadius: this.props.borderRadius };
|
33
|
+
}
|
34
|
+
};
|
35
|
+
Skeleton.prototype.render = function () {
|
36
|
+
var skeletonClassName = classnames_1.default('p-skeleton p-component', {
|
37
|
+
'p-skeleton-circle': this.props.shape === 'circle',
|
38
|
+
'p-skeleton-none': this.props.animation === 'none',
|
39
|
+
}, this.props.className);
|
40
|
+
var style = this.skeletonStyle();
|
41
|
+
return (react_1.default.createElement("div", { style: style, className: skeletonClassName }));
|
42
|
+
};
|
43
|
+
Skeleton.defaultProps = {
|
44
|
+
shape: 'rectangle',
|
45
|
+
size: null,
|
46
|
+
width: '100%',
|
47
|
+
height: '1.2rem',
|
48
|
+
borderRadius: null,
|
49
|
+
animation: 'wave',
|
50
|
+
style: null,
|
51
|
+
className: null,
|
52
|
+
};
|
53
|
+
return Skeleton;
|
54
|
+
}(react_1.default.Component));
|
55
|
+
exports.Skeleton = Skeleton;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { MessageProp, IMessageOptions, Position } from './ToastMessage';
|
2
|
+
import ToastWrapper from './ToastWrapper';
|
3
|
+
interface IMessageId {
|
4
|
+
id: string;
|
5
|
+
position: Position;
|
6
|
+
}
|
7
|
+
declare class Toasted {
|
8
|
+
componentRef: ToastWrapper | null;
|
9
|
+
constructor();
|
10
|
+
setup(): void;
|
11
|
+
notify(message: MessageProp, options: Partial<IMessageOptions>): IMessageId | null;
|
12
|
+
close(messageId: IMessageId): void;
|
13
|
+
}
|
14
|
+
export declare const toasted: Toasted;
|
15
|
+
export {};
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
+
};
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
+
exports.toasted = void 0;
|
26
|
+
var React = __importStar(require("react"));
|
27
|
+
var ReactDOM = __importStar(require("react-dom"));
|
28
|
+
var ToastWrapper_1 = __importDefault(require("./ToastWrapper"));
|
29
|
+
var TOAST_ID = "react-toast";
|
30
|
+
var Toasted = /** @class */ (function () {
|
31
|
+
function Toasted() {
|
32
|
+
this.componentRef = null;
|
33
|
+
}
|
34
|
+
Toasted.prototype.setup = function () {
|
35
|
+
var _this = this;
|
36
|
+
if (this.componentRef != null) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
var element = null;
|
40
|
+
var existingElement = document.getElementById(TOAST_ID);
|
41
|
+
if (existingElement) {
|
42
|
+
element = existingElement;
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
var el = document.createElement("div");
|
46
|
+
el.id = TOAST_ID;
|
47
|
+
el.className = "sd-toast__container sd-toast__container--top";
|
48
|
+
document.body.appendChild(el);
|
49
|
+
element = el;
|
50
|
+
}
|
51
|
+
ReactDOM.render(React.createElement(ToastWrapper_1.default, { ref: function (ref) {
|
52
|
+
_this.componentRef = ref;
|
53
|
+
} }), element);
|
54
|
+
};
|
55
|
+
Toasted.prototype.notify = function (message, options) {
|
56
|
+
this.setup();
|
57
|
+
if (this.componentRef != null) {
|
58
|
+
return this.componentRef.notify(message, options);
|
59
|
+
}
|
60
|
+
return null;
|
61
|
+
};
|
62
|
+
Toasted.prototype.close = function (messageId) {
|
63
|
+
if (this.componentRef != null) {
|
64
|
+
this.componentRef.requestClose(messageId.id, messageId.position);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
return Toasted;
|
68
|
+
}());
|
69
|
+
exports.toasted = new Toasted();
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export declare type MessageProp = React.ReactNode | string;
|
3
|
+
export declare type Position = 'top' | 'bottom' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
4
|
+
export declare type NotesType = 'default' | 'primary' | 'success' | 'warning' | 'alert' | 'highlight' | 'light';
|
5
|
+
export interface IMessageOptions {
|
6
|
+
id: string;
|
7
|
+
position: Position;
|
8
|
+
message?: MessageProp;
|
9
|
+
duration?: number | null;
|
10
|
+
type?: NotesType;
|
11
|
+
icon?: string;
|
12
|
+
size?: 'fixed-s' | 'fixed-m' | 'fixed-l' | 'fixed-xl';
|
13
|
+
}
|
14
|
+
interface IProps extends IMessageOptions {
|
15
|
+
closeElement(id: string, position: Position): void;
|
16
|
+
}
|
17
|
+
export declare const ToastMessage: ({ id, message, type, icon, size, duration, position, closeElement, }: IProps) => JSX.Element;
|
18
|
+
export {};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
+
};
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
+
exports.ToastMessage = void 0;
|
26
|
+
var React = __importStar(require("react"));
|
27
|
+
var ToastText_1 = __importDefault(require("./ToastText"));
|
28
|
+
var classnames_1 = __importDefault(require("classnames"));
|
29
|
+
exports.ToastMessage = function (_a) {
|
30
|
+
var _b;
|
31
|
+
var id = _a.id, message = _a.message, type = _a.type, icon = _a.icon, size = _a.size, duration = _a.duration, position = _a.position, closeElement = _a.closeElement;
|
32
|
+
var _c = React.useState(false), show = _c[0], setShow = _c[1];
|
33
|
+
var _d = React.useState(false), enter = _d[0], setEnter = _d[1];
|
34
|
+
var timer;
|
35
|
+
React.useEffect(function () { return setShow(true); }, []);
|
36
|
+
if (typeof duration === "number") {
|
37
|
+
React.useEffect(function () {
|
38
|
+
timer = window.setTimeout(function () {
|
39
|
+
close(id, position);
|
40
|
+
}, duration);
|
41
|
+
return function () { return clearTimeout(timer); };
|
42
|
+
}, [enter]);
|
43
|
+
}
|
44
|
+
function onMouseEnter() {
|
45
|
+
clearTimeout(timer);
|
46
|
+
}
|
47
|
+
function onMouseLeave() {
|
48
|
+
setEnter(false);
|
49
|
+
}
|
50
|
+
function close(element, elementPosition) {
|
51
|
+
setShow(false);
|
52
|
+
setTimeout(function () {
|
53
|
+
closeElement(element, elementPosition);
|
54
|
+
}, 100);
|
55
|
+
}
|
56
|
+
var classes = classnames_1.default('sd-toast', (_b = {},
|
57
|
+
_b["sd-toast--" + type] = type,
|
58
|
+
_b["sd-toast--" + size] = size,
|
59
|
+
_b['sd-toast--enter'] = !show && !enter,
|
60
|
+
_b['sd-toast--enter-active'] = show,
|
61
|
+
_b['sd-toast--exit'] = enter && !show,
|
62
|
+
_b['sd-toast--exit-active'] = !show,
|
63
|
+
_b));
|
64
|
+
return (React.createElement("div", { className: classes, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, "aria-live": "assertive", "aria-atomic": "true" },
|
65
|
+
React.createElement(ToastText_1.default, { id: id, title: message, icon: icon, onClose: function () { return close(id, position); } })));
|
66
|
+
};
|