dce-reactkit 3.2.2-beta.3 → 3.2.2-beta.30

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.
@@ -7,6 +7,7 @@ declare type Props = {
7
7
  label: string;
8
8
  minLabelWidth?: string;
9
9
  children: React.ReactNode;
10
+ className?: string;
10
11
  };
11
12
  declare const ButtonInputGroup: React.FC<Props>;
12
13
  export default ButtonInputGroup;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Reusable nested item picker
3
3
  * @author Yuen Ler Chow
4
+ * @author Gabe Abrams
4
5
  */
5
6
  import React from 'react';
6
7
  import PickableItem from './types/PickableItem';
@@ -13,6 +13,7 @@ declare type Props = {
13
13
  * values updated
14
14
  */
15
15
  onChanged: (updatedItems: PickableItem[]) => void;
16
+ noBottomMargin?: boolean;
16
17
  };
17
18
  declare const ItemPicker: React.FC<Props>;
18
19
  export default ItemPicker;
@@ -25,7 +25,7 @@ export declare const internalGetLogCollection: () => any;
25
25
  * @param opts.getLaunchInfo CACCL LTI's get launch info function
26
26
  * @param [opts.logCollection] mongo collection from dce-mango to use for
27
27
  * storing logs. If none is included, logs are written to the console
28
- * @param [opts.logReviewAdmins=all admins] info on which admins can review
28
+ * @param [opts.logReviewAdmins=all] info on which admins can review
29
29
  * logs from the client. If not included, all Canvas admins are allowed to
30
30
  * review logs. If null, no Canvas admins are allowed to review logs.
31
31
  * If an array of Canvas userIds (numbers), only Canvas admins with those
@@ -10,7 +10,7 @@ declare const LogBuiltInMetadata: {
10
10
  ClientFatalError: string;
11
11
  };
12
12
  Target: {
13
- NoSpecificTarget: string;
13
+ NoTarget: string;
14
14
  };
15
15
  };
16
16
  export default LogBuiltInMetadata;
package/dist/index.d.ts CHANGED
@@ -242,6 +242,7 @@ declare type Props$a = {
242
242
  label: string;
243
243
  minLabelWidth?: string;
244
244
  children: React.ReactNode;
245
+ className?: string;
245
246
  };
246
247
  declare const ButtonInputGroup: React.FC<Props$a>;
247
248
 
@@ -363,6 +364,7 @@ declare type Props$3 = {
363
364
  * values updated
364
365
  */
365
366
  onChanged: (updatedItems: PickableItem[]) => void;
367
+ noBottomMargin?: boolean;
366
368
  };
367
369
  declare const ItemPicker: React.FC<Props$3>;
368
370
 
@@ -822,7 +824,7 @@ declare type GetLaunchInfoFunction = (req: any) => {
822
824
  * @param opts.getLaunchInfo CACCL LTI's get launch info function
823
825
  * @param [opts.logCollection] mongo collection from dce-mango to use for
824
826
  * storing logs. If none is included, logs are written to the console
825
- * @param [opts.logReviewAdmins=all admins] info on which admins can review
827
+ * @param [opts.logReviewAdmins=all] info on which admins can review
826
828
  * logs from the client. If not included, all Canvas admins are allowed to
827
829
  * review logs. If null, no Canvas admins are allowed to review logs.
828
830
  * If an array of Canvas userIds (numbers), only Canvas admins with those
@@ -1026,7 +1028,7 @@ declare const LogBuiltInMetadata: {
1026
1028
  ClientFatalError: string;
1027
1029
  };
1028
1030
  Target: {
1029
- NoSpecificTarget: string;
1031
+ NoTarget: string;
1030
1032
  };
1031
1033
  };
1032
1034
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.2.2-beta.3",
3
+ "version": "3.2.2-beta.30",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -18,6 +18,8 @@ type Props = {
18
18
  minLabelWidth?: string,
19
19
  // Buttons
20
20
  children: React.ReactNode,
21
+ // Additional class names to add to the outer container
22
+ className?: string,
21
23
  };
22
24
 
23
25
  /*------------------------------------------------------------------------*/
@@ -36,6 +38,7 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
36
38
  label,
37
39
  minLabelWidth,
38
40
  children,
41
+ className,
39
42
  } = props;
40
43
 
41
44
  /*------------------------------------------------------------------------*/
@@ -47,7 +50,7 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
47
50
  /*----------------------------------------*/
48
51
 
49
52
  return (
50
- <div className="input-group">
53
+ <div className={`input-group ${className ?? ''}`}>
51
54
  <div className="input-group-prepend d-flex w-100">
52
55
  {/* Label */}
53
56
  <span
@@ -302,14 +302,14 @@ const IntelliTable: React.FC<Props> = (props) => {
302
302
  >
303
303
  <div className="d-flex align-items-center justify-content-center flex-row h-100">
304
304
  {/* Title */}
305
- <h4 className="m-0">
305
+ <span className="text-nowrap">
306
306
  {column.title}
307
- </h4>
307
+ </span>
308
308
  {/* Buttons */}
309
309
  <div>
310
310
  <button
311
311
  type="button"
312
- className="btn btn-light"
312
+ className="btn btn-light btn-sm ms-1"
313
313
  aria-label={sortButtonAriaLabel}
314
314
  onClick={() => {
315
315
  dispatch({
@@ -567,7 +567,7 @@ const IntelliTable: React.FC<Props> = (props) => {
567
567
  {/* Show/Hide Columns */}
568
568
  <button
569
569
  type="button"
570
- className="btn btn-secondary"
570
+ className="btn btn-secondary ms-2"
571
571
  aria-label={`show panel for customizing which columns show in table ${title}`}
572
572
  id={`IntelliTable-${id}-show-column-customization-modal`}
573
573
  onClick={() => {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Reusable nested item picker
3
3
  * @author Yuen Ler Chow
4
+ * @author Gabe Abrams
4
5
  */
5
6
 
6
7
  // Import React
@@ -43,36 +44,46 @@ type Props = {
43
44
  /* -------- State Definition -------- */
44
45
 
45
46
  type State = {
46
- // True if children are being shown
47
- isShowingItems: boolean,
47
+ // Map of children that are expanded
48
+ childExpanded: {
49
+ [k: string]: boolean
50
+ },
48
51
  };
49
52
 
50
53
  /* ------------- Actions ------------ */
51
54
 
52
55
  // Types of actions
53
56
  enum ActionType {
54
- // Toggle whether the children are being shown
55
- ToggleItems = 'toggle-items',
57
+ // Toggle whether a child are being shown
58
+ ToggleChild = 'toggle-child',
56
59
  }
57
60
 
58
61
  // Action definitions
59
62
  type Action = (
60
63
  | {
61
64
  // Action type
62
- type: ActionType.ToggleItems,
65
+ type: ActionType.ToggleChild,
66
+ // Id of the child to show
67
+ id: (string | number),
63
68
  }
64
69
  );
65
70
 
66
71
  /**
67
72
  * Reducer that executes actions
68
- * @author Yuen Ler Chow
73
+ * @author Gabe Abrams
69
74
  * @param state current state
70
75
  * @param action action to execute
71
76
  */
72
77
  const reducer = (state: State, action: Action): State => {
73
78
  switch (action.type) {
74
- case ActionType.ToggleItems: {
75
- return { isShowingItems: !state.isShowingItems };
79
+ case ActionType.ToggleChild: {
80
+ return {
81
+ ...state,
82
+ childExpanded: {
83
+ ...state.childExpanded,
84
+ [String(action.id)]: !state.childExpanded[String(action.id)],
85
+ },
86
+ };
76
87
  }
77
88
  default: {
78
89
  return state;
@@ -99,9 +110,15 @@ const NestableItemList: React.FC<Props> = (props) => {
99
110
 
100
111
  /* -------------- State ------------- */
101
112
 
113
+ // Create initial map of child expanded booleans
114
+ const initChildExpanded: { [k: string]: boolean } = {};
115
+ items.forEach((item) => {
116
+ initChildExpanded[String(item.id)] = false;
117
+ });
118
+
102
119
  // Initial state
103
120
  const initialState: State = {
104
- isShowingItems: false,
121
+ childExpanded: initChildExpanded,
105
122
  };
106
123
 
107
124
  // Initialize state
@@ -109,7 +126,7 @@ const NestableItemList: React.FC<Props> = (props) => {
109
126
 
110
127
  // Destructure common state
111
128
  const {
112
- isShowingItems,
129
+ childExpanded,
113
130
  } = state;
114
131
 
115
132
  /*------------------------------------------------------------------------*/
@@ -231,13 +248,14 @@ const NestableItemList: React.FC<Props> = (props) => {
231
248
  type="button"
232
249
  onClick={() => {
233
250
  dispatch({
234
- type: ActionType.ToggleItems,
251
+ type: ActionType.ToggleChild,
252
+ id: item.id,
235
253
  });
236
254
  }}
237
- aria-label={`${isShowingItems ? 'Hide' : 'Show'} items in ${item.name}`}
255
+ aria-label={`${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${item.name}`}
238
256
  >
239
257
  <FontAwesomeIcon
240
- icon={isShowingItems ? faChevronDown : faChevronRight}
258
+ icon={childExpanded[item.id] ? faChevronDown : faChevronRight}
241
259
  />
242
260
  </button>
243
261
  )}
@@ -257,7 +275,7 @@ const NestableItemList: React.FC<Props> = (props) => {
257
275
  />
258
276
 
259
277
  {/* Children */}
260
- {item.isGroup && isShowingItems && (
278
+ {(item.isGroup && childExpanded[item.id]) && (
261
279
  <div
262
280
  className="NestableItemList-children-container"
263
281
  style={{
@@ -31,6 +31,8 @@ type Props = {
31
31
  * values updated
32
32
  */
33
33
  onChanged: (updatedItems: PickableItem[]) => void,
34
+ // If true, don't add margin to bottom of item picker
35
+ noBottomMargin?: boolean,
34
36
  };
35
37
 
36
38
  /*------------------------------------------------------------------------*/
@@ -49,6 +51,7 @@ const ItemPicker: React.FC<Props> = (props) => {
49
51
  title,
50
52
  items,
51
53
  onChanged,
54
+ noBottomMargin,
52
55
  } = props;
53
56
 
54
57
  /*------------------------------------------------------------------------*/
@@ -66,6 +69,7 @@ const ItemPicker: React.FC<Props> = (props) => {
66
69
  return (
67
70
  <TabBox
68
71
  title={title}
72
+ noBottomMargin={noBottomMargin}
69
73
  >
70
74
  <div style={{ overflowX: 'auto' }}>
71
75
  <NestableItemList