studiokit-scaffolding-js 5.1.0 → 5.1.2

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.
@@ -1,26 +1,64 @@
1
- import { ComponentClass, ComponentType } from 'react';
1
+ import React, { ComponentClass, ComponentType } from 'react';
2
+ import { ModalsState } from '../../redux/reducers/modalsReducer';
3
+ import { BaseReduxState } from '../../types';
2
4
  import { GuidComponentWrappedProps } from '../HOC/GuidComponent';
3
5
  export interface ConnectedModalWrappedProps {
4
6
  onEntering: () => void;
5
7
  onExited: () => void;
8
+ isTopOpenFullscreenModal?: boolean;
6
9
  }
7
10
  export interface ConnectedModalState {
8
11
  isModalOpen: boolean;
9
12
  }
13
+ export declare type ConnectedModalReduxProps = {
14
+ modals: ModalsState;
15
+ };
16
+ export declare const configureMapStateToProps: () => (state: BaseReduxState) => ConnectedModalReduxProps;
10
17
  /**
11
18
  * HOC that provides modal lifecycle event methods to coordinate modal state in redux.
12
19
  *
13
20
  * NOTE: Meant for testing. Should be wrapped in `guidComponent` to provide the `guid` prop normally.
14
21
  *
15
22
  * @param {*} WrappedComponent The component to wrap.
23
+ * @param {*} isFullscreen Are we rendering a fullscreen modal?
16
24
  */
17
- export declare function configureConnectedModalComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps>): ComponentClass<TOwnProps & GuidComponentWrappedProps>;
25
+ export declare function configureConnectedModalComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps>, isFullscreen?: boolean): {
26
+ new (props: TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps): {
27
+ componentWillUnmount(): void;
28
+ onEntering: () => void;
29
+ onExited: () => void;
30
+ render(): JSX.Element;
31
+ context: any;
32
+ setState<K extends "isModalOpen">(state: ConnectedModalState | ((prevState: Readonly<ConnectedModalState>, props: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>) => ConnectedModalState | Pick<ConnectedModalState, K> | null) | Pick<ConnectedModalState, K> | null, callback?: (() => void) | undefined): void;
33
+ forceUpdate(callback?: (() => void) | undefined): void;
34
+ readonly props: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps> & Readonly<{
35
+ children?: React.ReactNode;
36
+ }>;
37
+ state: Readonly<ConnectedModalState>;
38
+ refs: {
39
+ [key: string]: React.ReactInstance;
40
+ };
41
+ componentDidMount?(): void;
42
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, nextState: Readonly<ConnectedModalState>, nextContext: any): boolean;
43
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
44
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, prevState: Readonly<ConnectedModalState>): any;
45
+ componentDidUpdate?(prevProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, prevState: Readonly<ConnectedModalState>, snapshot?: any): void;
46
+ componentWillMount?(): void;
47
+ UNSAFE_componentWillMount?(): void;
48
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, nextContext: any): void;
49
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, nextContext: any): void;
50
+ componentWillUpdate?(nextProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, nextState: Readonly<ConnectedModalState>, nextContext: any): void;
51
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps & ConnectedModalReduxProps>, nextState: Readonly<ConnectedModalState>, nextContext: any): void;
52
+ };
53
+ contextType?: React.Context<any> | undefined;
54
+ };
18
55
  /**
19
56
  * HOC that provides modal lifecycle event methods to coordinate modal state in redux.
20
57
  *
21
58
  * Uses `guidComponent`.
22
59
  *
23
60
  * @param {*} WrappedComponent The component to wrap.
61
+ * @param {*} isFullscreen Are we rendering a fullscreen modal?
24
62
  */
25
- export declare function connectedModalComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps>): ComponentClass<TOwnProps>;
63
+ export declare function connectedModalComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & ConnectedModalWrappedProps & GuidComponentWrappedProps>, isFullscreen?: boolean): ComponentClass<TOwnProps>;
26
64
  export default connectedModalComponent;
@@ -46,26 +46,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
47
  };
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.connectedModalComponent = exports.configureConnectedModalComponent = void 0;
49
+ exports.connectedModalComponent = exports.configureConnectedModalComponent = exports.configureMapStateToProps = void 0;
50
+ var lodash_1 = require("lodash");
50
51
  var react_1 = __importStar(require("react"));
52
+ var react_redux_1 = require("react-redux");
51
53
  var actionCreator_1 = require("../../redux/actionCreator");
52
54
  var actions_1 = require("../../redux/actions");
53
55
  var GuidComponent_1 = __importDefault(require("../HOC/GuidComponent"));
56
+ var configureMapStateToProps = function () { return function (state) {
57
+ return {
58
+ modals: state.modals
59
+ };
60
+ }; };
61
+ exports.configureMapStateToProps = configureMapStateToProps;
54
62
  /**
55
63
  * HOC that provides modal lifecycle event methods to coordinate modal state in redux.
56
64
  *
57
65
  * NOTE: Meant for testing. Should be wrapped in `guidComponent` to provide the `guid` prop normally.
58
66
  *
59
67
  * @param {*} WrappedComponent The component to wrap.
68
+ * @param {*} isFullscreen Are we rendering a fullscreen modal?
60
69
  */
61
- function configureConnectedModalComponent(WrappedComponent) {
70
+ function configureConnectedModalComponent(WrappedComponent, isFullscreen) {
71
+ if (isFullscreen === void 0) { isFullscreen = false; }
62
72
  return /** @class */ (function (_super) {
63
73
  __extends(ConnectedModalComponent, _super);
64
74
  function ConnectedModalComponent(props) {
65
75
  var _this = _super.call(this, props) || this;
66
76
  _this.onEntering = function () {
67
- var guid = _this.props.guid;
68
- actionCreator_1.dispatchAction(actions_1.ACTION.MODAL_ENTERING, { guid: guid });
77
+ var _a;
78
+ var _b = _this.props, guid = _b.guid, modals = _b.modals;
79
+ // Store each modal's GUID in redux with a zero-based index to determine the order in which they were opened
80
+ var maxModal = lodash_1.maxBy(Object.values(modals), function (modal) { return modal.index; });
81
+ actionCreator_1.dispatchAction(actions_1.ACTION.MODAL_ENTERING, { guid: guid, index: ((_a = maxModal === null || maxModal === void 0 ? void 0 : maxModal.index) !== null && _a !== void 0 ? _a : -1) + 1, isFullscreen: isFullscreen });
69
82
  _this.setState({
70
83
  isModalOpen: true
71
84
  });
@@ -89,7 +102,12 @@ function configureConnectedModalComponent(WrappedComponent) {
89
102
  this.onExited();
90
103
  };
91
104
  ConnectedModalComponent.prototype.render = function () {
92
- return react_1.default.createElement(WrappedComponent, __assign({}, this.props, { onEntering: this.onEntering, onExited: this.onExited }));
105
+ var _a, _b;
106
+ var _c = this.props, modals = _c.modals, guid = _c.guid;
107
+ var topOpenFullscreenModal = lodash_1.maxBy(Object.values(modals).filter(function (m) { return m.isFullscreen; }), function (modal) { return modal.index; });
108
+ var thisModalIndex = (_b = (_a = modals[guid]) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : null;
109
+ var isTopOpenFullscreenModal = (topOpenFullscreenModal === null || topOpenFullscreenModal === void 0 ? void 0 : topOpenFullscreenModal.index) === thisModalIndex;
110
+ return (react_1.default.createElement(WrappedComponent, __assign({}, this.props, { onEntering: this.onEntering, onExited: this.onExited, isTopOpenFullscreenModal: isTopOpenFullscreenModal })));
93
111
  };
94
112
  return ConnectedModalComponent;
95
113
  }(react_1.Component));
@@ -101,10 +119,14 @@ exports.configureConnectedModalComponent = configureConnectedModalComponent;
101
119
  * Uses `guidComponent`.
102
120
  *
103
121
  * @param {*} WrappedComponent The component to wrap.
122
+ * @param {*} isFullscreen Are we rendering a fullscreen modal?
104
123
  */
105
- function connectedModalComponent(WrappedComponent) {
106
- var component = configureConnectedModalComponent(WrappedComponent);
107
- return GuidComponent_1.default(component);
124
+ function connectedModalComponent(WrappedComponent, isFullscreen) {
125
+ if (isFullscreen === void 0) { isFullscreen = false; }
126
+ var component = configureConnectedModalComponent(WrappedComponent, isFullscreen);
127
+ var mapStateToProps = exports.configureMapStateToProps();
128
+ // @ts-ignore: could not match inferred type from the `connect` HOC
129
+ return react_redux_1.connect(mapStateToProps)(GuidComponent_1.default(component));
108
130
  }
109
131
  exports.connectedModalComponent = connectedModalComponent;
110
132
  exports.default = connectedModalComponent;
@@ -122,7 +122,7 @@ function configureFullscreenModalComponent(WrappedComponent) {
122
122
  });
123
123
  };
124
124
  FullscreenModalComponent.prototype.render = function () {
125
- var contentLabel = this.props.contentLabel;
125
+ var _a = this.props, contentLabel = _a.contentLabel, isTopOpenFullscreenModal = _a.isTopOpenFullscreenModal;
126
126
  var isOpen = this.state.isOpen;
127
127
  return (react_1.default.createElement(react_modal_1.default, { isOpen: isOpen, contentLabel: contentLabel, style: {
128
128
  content: {
@@ -144,7 +144,9 @@ function configureFullscreenModalComponent(WrappedComponent) {
144
144
  bottom: 0,
145
145
  zIndex: 2000
146
146
  }
147
- }, shouldCloseOnOverlayClick: false },
147
+ },
148
+ // hide the rendered portal if this is not the top open fullscreen modal
149
+ portalClassName: "ReactModalPortal" + (!isTopOpenFullscreenModal ? ' dn' : ''), shouldCloseOnOverlayClick: false },
148
150
  react_1.default.createElement(WrappedComponent, __assign({}, this.props, { closeModal: this.closeModal }))));
149
151
  };
150
152
  return FullscreenModalComponent;
@@ -167,7 +169,7 @@ exports.configureFullscreenModalComponent = configureFullscreenModalComponent;
167
169
  */
168
170
  function fullscreenModalComponent(WrappedComponent) {
169
171
  var component = configureFullscreenModalComponent(WrappedComponent);
170
- return ConnectedModalComponent_1.connectedModalComponent(component);
172
+ return ConnectedModalComponent_1.connectedModalComponent(component, true);
171
173
  }
172
174
  exports.fullscreenModalComponent = fullscreenModalComponent;
173
175
  exports.default = fullscreenModalComponent;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -10,6 +21,10 @@ var react_2 = __importDefault(require("react"));
10
21
  var react_bootstrap_1 = require("react-bootstrap");
11
22
  var react_table_1 = __importDefault(require("react-table"));
12
23
  var table_1 = require("../constants/table");
24
+ var table_2 = require("../utils/table");
25
+ var ManageTableNoDataComponent_1 = require("./ManageTableNoDataComponent");
26
+ var PaginationNextButton_1 = require("./PaginationNextButton");
27
+ var PaginationPreviousButton_1 = require("./PaginationPreviousButton");
13
28
  var RefreshIndicator_1 = require("./RefreshIndicator");
14
29
  var ManageTable = function (_a) {
15
30
  //#region Data
@@ -62,33 +77,15 @@ var ManageTable = function (_a) {
62
77
  var SearchTabs = react_1.useMemo(function () { return (react_2.default.createElement(react_bootstrap_1.Tabs, { activeKey: selectedTab, id: "search-tabs", onSelect: onTabSelect }, tabs.map(function (tab) { return (react_2.default.createElement(react_bootstrap_1.Tab, { key: tab, eventKey: tab.toString(), title: getTabName(tab) + " (" + dataLengthByTab[tab] + ")", disabled: noResultsFound })); }))); }, [dataLengthByTab, getTabName, noResultsFound, onTabSelect, selectedTab, tabs]);
63
78
  //#endregion Tabs
64
79
  //#region Table
65
- var NoDataComponent = react_1.useMemo(function () {
66
- return hasSearched ? (react_2.default.createElement("p", { className: "pt4 tc" },
67
- "No ",
68
- entityName.toLocaleLowerCase(),
69
- " matched your search.",
70
- canQueryAll && !queryAll && (react_2.default.createElement(react_2.default.Fragment, null,
71
- " You might want to try again with \"Search All ",
72
- entityName,
73
- "\" checked.")))) : (react_2.default.createElement("p", { className: "pt4 tc" },
74
- "No ",
75
- getTabName(selectedTab).toLowerCase(),
76
- " ",
77
- entityName.toLocaleLowerCase(),
78
- ' ',
79
- isFiltered ? 'matched your search' : 'found',
80
- "."));
81
- }, [canQueryAll, entityName, getTabName, hasSearched, isFiltered, queryAll, selectedTab]);
80
+ var NoDataComponent = react_1.useMemo(function () { return (react_2.default.createElement(ManageTableNoDataComponent_1.ManageTableNoDataComponent, __assign({}, { canQueryAll: canQueryAll, entityName: entityName, getTabName: getTabName, hasSearched: hasSearched, isFiltered: isFiltered, queryAll: queryAll, selectedTab: selectedTab }))); }, [canQueryAll, entityName, getTabName, hasSearched, isFiltered, queryAll, selectedTab]);
82
81
  var NoDataComponentCallback = react_1.useCallback(function () { return NoDataComponent; }, [NoDataComponent]);
83
82
  var Table = react_1.useMemo(function () {
84
- var _a;
83
+ // show pagination if there are more rows than the default page size
85
84
  var showPagination = !!data && data.length > table_1.TABLE_DEFAULT_PAGE_SIZE;
86
85
  // if pagination is not enabled, or page is not set, ensure page is 0, the first page
87
86
  var pageForTab = showPagination && pageByTab && selectedTab ? pageByTab[selectedTab] : 0;
88
- // if there are less items to display than the page size, shrink the page size so there are not empty rows
89
- var currentPageSize = Math.min((_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : table_1.TABLE_DEFAULT_PAGE_SIZE, pageSize !== null && pageSize !== void 0 ? pageSize : table_1.TABLE_DEFAULT_PAGE_SIZE);
90
- var pageSizeOptions = table_1.TABLE_PAGE_SIZE_OPTIONS.filter(function (s) { return !(data === null || data === void 0 ? void 0 : data.length) || s <= (data === null || data === void 0 ? void 0 : data.length); });
91
- return (react_2.default.createElement(react_table_1.default, { "aria-describedby": "search-results-label", className: "manage-table -striped cb" + ((data === null || data === void 0 ? void 0 : data.length) === 1 ? ' single-row-action-button' : ''), data: data, showPagination: showPagination, showPaginationTop: true, sorted: sortingRules, pageSize: currentPageSize, page: pageForTab, pageSizeOptions: pageSizeOptions, columns: columns, onSortedChange: setSortingRules, onPageSizeChange: setPageSize, onPageChange: setPage, NoDataComponent: NoDataComponentCallback }));
87
+ var pageSizeOptions = table_2.getPageSizeOptions(data === null || data === void 0 ? void 0 : data.length);
88
+ return (react_2.default.createElement(react_table_1.default, { "aria-describedby": "search-results-label", className: "manage-table -striped cb" + ((data === null || data === void 0 ? void 0 : data.length) === 1 ? ' single-row-action-button' : ''), data: data, showPagination: showPagination, showPaginationTop: true, sorted: sortingRules, pageSize: pageSize, page: pageForTab, pageSizeOptions: pageSizeOptions, minRows: 0, columns: columns, onSortedChange: setSortingRules, onPageSizeChange: setPageSize, onPageChange: setPage, NextComponent: PaginationNextButton_1.PaginationNextButton, PreviousComponent: PaginationPreviousButton_1.PaginationPreviousButton, NoDataComponent: NoDataComponentCallback }));
92
89
  }, [
93
90
  NoDataComponentCallback,
94
91
  columns,
@@ -0,0 +1,11 @@
1
+ import { FunctionComponent } from 'react';
2
+ export interface ManageTableNoDataComponentProps {
3
+ entityName: string;
4
+ selectedTab?: number;
5
+ getTabName: (tab?: number) => string;
6
+ queryAll?: boolean;
7
+ canQueryAll?: boolean;
8
+ isFiltered?: boolean;
9
+ hasSearched?: boolean;
10
+ }
11
+ export declare const ManageTableNoDataComponent: FunctionComponent<ManageTableNoDataComponentProps>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ManageTableNoDataComponent = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var ManageTableNoDataComponent = function (_a) {
9
+ var entityName = _a.entityName, selectedTab = _a.selectedTab, getTabName = _a.getTabName, queryAll = _a.queryAll, canQueryAll = _a.canQueryAll, isFiltered = _a.isFiltered, hasSearched = _a.hasSearched;
10
+ return (react_1.default.createElement("p", { className: "pt4 tc" }, hasSearched ? (react_1.default.createElement(react_1.default.Fragment, null,
11
+ "No ",
12
+ entityName.toLocaleLowerCase(),
13
+ " matched your search.",
14
+ canQueryAll && !queryAll && (react_1.default.createElement(react_1.default.Fragment, null,
15
+ " You might want to try again with \"Search All ",
16
+ entityName,
17
+ "\" checked.")))) : (react_1.default.createElement(react_1.default.Fragment, null,
18
+ "No ",
19
+ getTabName(selectedTab).toLowerCase(),
20
+ " ",
21
+ entityName.toLocaleLowerCase(),
22
+ ' ',
23
+ isFiltered ? 'matched your search' : 'found',
24
+ "."))));
25
+ };
26
+ exports.ManageTableNoDataComponent = ManageTableNoDataComponent;
@@ -0,0 +1,3 @@
1
+ import { ButtonProps } from '@material-ui/core';
2
+ import { FunctionComponent } from 'react';
3
+ export declare const PaginationNextButton: FunctionComponent<ButtonProps>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PaginationNextButton = void 0;
18
+ var core_1 = require("@material-ui/core");
19
+ var KeyboardArrowRight_1 = __importDefault(require("@material-ui/icons/KeyboardArrowRight"));
20
+ var react_1 = __importDefault(require("react"));
21
+ var PaginationNextButton = function (props) { return (react_1.default.createElement(core_1.Button, __assign({ className: "btn-text color-primary w-100" }, props),
22
+ "Next ",
23
+ react_1.default.createElement(KeyboardArrowRight_1.default, null))); };
24
+ exports.PaginationNextButton = PaginationNextButton;
@@ -0,0 +1,3 @@
1
+ import { ButtonProps } from '@material-ui/core';
2
+ import { FunctionComponent } from 'react';
3
+ export declare const PaginationPreviousButton: FunctionComponent<ButtonProps>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PaginationPreviousButton = void 0;
18
+ var core_1 = require("@material-ui/core");
19
+ var KeyboardArrowLeft_1 = __importDefault(require("@material-ui/icons/KeyboardArrowLeft"));
20
+ var react_1 = __importDefault(require("react"));
21
+ var PaginationPreviousButton = function (props) { return (react_1.default.createElement(core_1.Button, __assign({ className: "btn-text color-primary w-100" }, props),
22
+ react_1.default.createElement(KeyboardArrowLeft_1.default, null),
23
+ " Previous")); };
24
+ exports.PaginationPreviousButton = PaginationPreviousButton;
@@ -25,7 +25,7 @@ var SearchControls = function (_a) {
25
25
  react_1.default.createElement(DateField_1.DateField, { id: "date", onChange: handleDateChange, label: "Date", "aria-label": "Active date", className: "fl-ns mw5-ns mr3-ns mb3 mb0-ns w-100-lt-xs date-align", value: dateString }))),
26
26
  react_1.default.createElement("div", { className: "fl-ns mt3-ns pt3-ns w-100-lt-xs" },
27
27
  canReadAnyGlobally && !!setQueryAll && (react_1.default.createElement(react_bootstrap_1.FormCheck, { name: "queryAll", id: "queryAll", checked: queryAll, disabled: canReadAnyGlobally && !canReadSome, onChange: setQueryAll, className: "fl-ns f6 mr2-ns mb3 mt2 w-100-lt-xs", label: react_1.default.createElement("span", { className: "b black" }, queryAllText || 'Search All') })),
28
- canReadAnyGlobally && queryAll && (react_1.default.createElement(Button_1.default, { className: "btn-primary fr-ns ml2-ns mb3 w-100-lt-xs search-button", onClick: handleSearchClick, color: "primary", disabled: !keywords || keywords.length < 3 || !!invalidKeywords },
28
+ canReadAnyGlobally && queryAll && (react_1.default.createElement(Button_1.default, { className: "btn-primary fr-ns ml2-ns mb3 w-100-lt-xs search-button", onClick: handleSearchClick, color: "primary", disabled: (!keywords || keywords.length < 3 || !!invalidKeywords) && !dateString },
29
29
  react_1.default.createElement(Search_1.default, null),
30
30
  "Search")),
31
31
  react_1.default.createElement(Button_1.default, { className: "btn-text color-pink fr-ns mb3 w-100-lt-xs", onClick: resetSearch },
@@ -62,6 +62,39 @@ th,
62
62
  * react table
63
63
  */
64
64
 
65
+ .table-container {
66
+ width: 100%;
67
+ overflow-x: auto;
68
+ }
69
+
70
+ .table-search-container {
71
+ padding: 0 !important;
72
+ text-align: left;
73
+ background: white;
74
+ border: 1px solid rgba(0, 0, 0, 0.1);
75
+ border-radius: 3px;
76
+ width: 100%;
77
+
78
+ & .MuiSvgIcon-root {
79
+ margin-top: 0.55rem;
80
+ }
81
+
82
+ & .table-search-input {
83
+ text-align: left;
84
+ outline: none !important;
85
+ border: none !important;
86
+ width: 100%;
87
+ }
88
+
89
+ & input[type=search] {
90
+ -webkit-appearance: none;
91
+ }
92
+
93
+ & input[type=search]::-webkit-search-cancel-button {
94
+ -webkit-appearance: searchfield-cancel-button;
95
+ }
96
+ }
97
+
65
98
  .ReactTable {
66
99
  & .rt-thead .rt-tr {
67
100
  background-color: var(--color-off-white);
@@ -88,10 +121,81 @@ th,
88
121
  overflow: visible;
89
122
  }
90
123
 
91
- & .-pagination .-btn[disabled] {
92
- opacity: 1 !important;
93
- background-color: var(--color-light-grey) !important;
94
- color: var(--color-dark-grey) !important;
124
+ & .pagination-top,
125
+ & .pagination-bottom {
126
+ background-color: var(--color-off-white);
127
+
128
+ & .-pagination {
129
+ padding: 0.5rem 0.6rem;
130
+ border-top: none;
131
+ }
132
+ }
133
+
134
+ & .pagination-top .-pagination {
135
+ border-bottom: 1px solid var(--color-light-grey);
136
+ }
137
+
138
+ & .pagination-bottom .-pagination {
139
+ border-top: 1px solid var(--color-light-grey);
140
+ }
141
+
142
+ & .-pagination .-previous,
143
+ & .-pagination .-next {
144
+ & .MuiButton-text {
145
+ background-color: var(--color-white);
146
+ border: 1px solid var(--color-light-grey);
147
+
148
+ &[disabled] {
149
+ background-color: var(--color-light-grey);
150
+ }
151
+
152
+ & .MuiButton-label .MuiSvgIcon-root {
153
+ margin: 0;
154
+ }
155
+ }
156
+ }
157
+
158
+ /* duplicate .form-control styles */
159
+ & .-pagination input,
160
+ .-pagination select {
161
+ display: block;
162
+ width: 100%;
163
+ height: calc(1.5em + 0.75rem + 2px);
164
+ font-size: 1rem;
165
+ font-weight: 400;
166
+ line-height: 1.5;
167
+ color: #495057;
168
+ background-color: #fff;
169
+ background-clip: padding-box;
170
+ border: 1px solid #ced4da;
171
+ border-radius: 0.25rem;
172
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
173
+ font-family: var(--text-font-stack);
174
+ padding: 0.5rem;
175
+ border-color: var(--color-light-grey);
176
+ box-shadow: none;
177
+
178
+ &:focus {
179
+ border-color: #80bdff;
180
+ outline: 0;
181
+ -webkit-box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
182
+ box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
183
+ }
184
+
185
+ &::placeholder {
186
+ color: #6c757d;
187
+ opacity: 1;
188
+ }
189
+ }
190
+
191
+ & .-pagination .-pageSizeOptions.select {
192
+ padding: 0.375rem 0.75rem;
193
+ }
194
+
195
+ &.single-row-action-button {
196
+ & .rt-tbody {
197
+ padding-bottom: 108px;
198
+ }
95
199
  }
96
200
 
97
201
  & .rt-noData {
@@ -113,39 +217,6 @@ th,
113
217
  }
114
218
  }
115
219
 
116
- .table-container {
117
- width: 100%;
118
- overflow-x: auto;
119
- }
120
-
121
- .table-search-container {
122
- padding: 0 !important;
123
- text-align: left;
124
- background: white;
125
- border: 1px solid rgba(0, 0, 0, 0.1);
126
- border-radius: 3px;
127
- width: 100%;
128
-
129
- & .MuiSvgIcon-root {
130
- margin-top: 0.55rem;
131
- }
132
-
133
- & .table-search-input {
134
- text-align: left;
135
- outline: none !important;
136
- border: none !important;
137
- width: 100%;
138
- }
139
-
140
- & input[type=search] {
141
- -webkit-appearance: none;
142
- }
143
-
144
- & input[type=search]::-webkit-search-cancel-button {
145
- -webkit-appearance: searchfield-cancel-button;
146
- }
147
- }
148
-
149
220
  .striped-table tr:nth-child(even) {
150
221
  background-color: var(--color-light-blue) !important;
151
222
  }
@@ -1,8 +1,12 @@
1
1
  import { Dictionary } from 'lodash';
2
2
  import { Action } from 'redux';
3
- export interface ModalAction extends Action {
3
+ export interface ModalActionValue {
4
+ index: number;
5
+ isFullscreen: boolean;
6
+ }
7
+ export interface ModalAction extends Action, ModalActionValue {
4
8
  guid: string;
5
9
  }
6
- export interface ModalsState extends Dictionary<boolean> {
10
+ export interface ModalsState extends Dictionary<ModalActionValue> {
7
11
  }
8
12
  export default function modalsReducer(state: ModalsState | undefined, action: ModalAction): ModalsState;
@@ -29,13 +29,17 @@ function modalsReducer(state, action) {
29
29
  var _a;
30
30
  if (state === void 0) { state = initialState; }
31
31
  var guid;
32
+ var index;
33
+ var isFullscreen;
32
34
  switch (action.type) {
33
35
  case actions_1.ACTION.MODAL_ENTERING: {
34
36
  guid = action.guid;
37
+ index = action.index;
38
+ isFullscreen = action.isFullscreen;
35
39
  if (state[guid]) {
36
40
  return state;
37
41
  }
38
- var newState = __assign(__assign({}, state), (_a = {}, _a["" + guid] = true, _a));
42
+ var newState = __assign(__assign({}, state), (_a = {}, _a["" + guid] = { index: index, isFullscreen: isFullscreen }, _a));
39
43
  return newState;
40
44
  }
41
45
  case actions_1.ACTION.MODAL_EXITED: {
@@ -0,0 +1,7 @@
1
+ export declare const getManageTableTabName: (selectedTab?: number | undefined) => "" | "Available" | "Deleted";
2
+ export declare const getGroupManageTableTabName: (selectedTab?: number | undefined) => "" | "Deleted" | "Current" | "Past";
3
+ /**
4
+ * return page size options that are less than or equal to the total data length,
5
+ * and one that is greater (if it exists) to allow viewing all data on one page.
6
+ * */
7
+ export declare const getPageSizeOptions: (dataLength?: number | undefined) => number[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGroupManageTableTabName = exports.getManageTableTabName = void 0;
3
+ exports.getPageSizeOptions = exports.getGroupManageTableTabName = exports.getManageTableTabName = void 0;
4
4
  var table_1 = require("../constants/table");
5
5
  var getManageTableTabName = function (selectedTab) {
6
6
  switch (selectedTab) {
@@ -26,3 +26,17 @@ var getGroupManageTableTabName = function (selectedTab) {
26
26
  }
27
27
  };
28
28
  exports.getGroupManageTableTabName = getGroupManageTableTabName;
29
+ /**
30
+ * return page size options that are less than or equal to the total data length,
31
+ * and one that is greater (if it exists) to allow viewing all data on one page.
32
+ * */
33
+ var getPageSizeOptions = function (dataLength) {
34
+ return table_1.TABLE_PAGE_SIZE_OPTIONS.reduce(function (options, option, currentIndex) {
35
+ var prevOption = currentIndex > 0 ? options[currentIndex - 1] : undefined;
36
+ if (!dataLength || option < dataLength || (prevOption && prevOption < dataLength)) {
37
+ options.push(option);
38
+ }
39
+ return options;
40
+ }, []);
41
+ };
42
+ exports.getPageSizeOptions = getPageSizeOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "studiokit-scaffolding-js",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "Common scaffolding for Studio apps at Purdue",
5
5
  "repository": "https://gitlab.com/purdue-informatics/studiokit/studiokit-scaffolding-js",
6
6
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- export declare const getManageTableTabName: (selectedTab?: number | undefined) => "" | "Available" | "Deleted";
2
- export declare const getGroupManageTableTabName: (selectedTab?: number | undefined) => "" | "Deleted" | "Current" | "Past";