dce-reactkit 3.2.2-beta.42 → 3.2.2-beta.46

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/dist/cjs/index.js CHANGED
@@ -2313,7 +2313,7 @@ const CSVDownloadButton = (props) => {
2313
2313
  /* Main UI */
2314
2314
  /*----------------------------------------*/
2315
2315
  // Render the button
2316
- return (React__default["default"].createElement("a", { id: id, download: filename, href: `data:application/octet-stream,${csv}`, className: `CSVDownloadButton-button ${className !== null && className !== void 0 ? className : 'btn btn-secondary'}`, "aria-label": (ariaLabel
2316
+ return (React__default["default"].createElement("a", { id: id, download: filename, href: `data:application/octet-stream,${encodeURIComponent(csv)}`, className: `CSVDownloadButton-button ${className !== null && className !== void 0 ? className : 'btn btn-secondary'}`, "aria-label": (ariaLabel
2317
2317
  ? `Click to download ${filename}`
2318
2318
  : ariaLabel), style: style, onClick: onClick },
2319
2319
  !children && (React__default["default"].createElement(React__default["default"].Fragment, null,
@@ -2345,6 +2345,10 @@ var ActionType$1;
2345
2345
  ActionType["UpdateColumnVisibility"] = "update-column-visibility";
2346
2346
  // Toggle the column visibility customization modal
2347
2347
  ActionType["ToggleColVisCusModalVisibility"] = "toggle-col-vis-cus-modal-visibility";
2348
+ // Show all columns
2349
+ ActionType["ShowAllColumns"] = "show-all-columns";
2350
+ // Hide all columns
2351
+ ActionType["HideAllColumns"] = "hide-all-columns";
2348
2352
  })(ActionType$1 || (ActionType$1 = {}));
2349
2353
  /**
2350
2354
  * Reducer that executes actions
@@ -2374,6 +2378,20 @@ const reducer$1 = (state, action) => {
2374
2378
  case ActionType$1.ToggleColVisCusModalVisibility: {
2375
2379
  return Object.assign(Object.assign({}, state), { columnVisibilityCustomizationModalVisible: !state.columnVisibilityCustomizationModalVisible });
2376
2380
  }
2381
+ case ActionType$1.ShowAllColumns: {
2382
+ const { columnVisibilityMap } = state;
2383
+ Object.keys(columnVisibilityMap).forEach((param) => {
2384
+ columnVisibilityMap[param] = true;
2385
+ });
2386
+ return Object.assign(Object.assign({}, state), { columnVisibilityMap });
2387
+ }
2388
+ case ActionType$1.HideAllColumns: {
2389
+ const { columnVisibilityMap } = state;
2390
+ Object.keys(columnVisibilityMap).forEach((param) => {
2391
+ columnVisibilityMap[param] = false;
2392
+ });
2393
+ return Object.assign(Object.assign({}, state), { columnVisibilityMap });
2394
+ }
2377
2395
  default: {
2378
2396
  return state;
2379
2397
  }
@@ -2394,8 +2412,10 @@ const IntelliTable = (props) => {
2394
2412
  const data = ((props.data && props.data.length > 0)
2395
2413
  ? props.data
2396
2414
  : [{ id: 'empty-row' }]);
2415
+ // Get CSV filename
2416
+ let filename = `${title}.csv`;
2397
2417
  if (props.csvName) {
2398
- (props.csvName.endsWith('.csv')
2418
+ filename = (props.csvName.endsWith('.csv')
2399
2419
  ? props.csvName
2400
2420
  : `${props.csvName}.csv`);
2401
2421
  }
@@ -2427,18 +2447,37 @@ const IntelliTable = (props) => {
2427
2447
  if (columnVisibilityCustomizationModalVisible) {
2428
2448
  // Create modal
2429
2449
  modal = (React__default["default"].createElement(Modal, { type: ModalType$1.Okay, title: "Choose columns to show:", onClose: () => {
2450
+ const noColumnsSelected = (Object.values(columnVisibilityMap)
2451
+ .every((isSelected) => {
2452
+ return !isSelected;
2453
+ }));
2454
+ if (noColumnsSelected) {
2455
+ return alert$1('Choose at least one column', 'To continue, you have to choose at least one column to show');
2456
+ }
2430
2457
  dispatch({
2431
2458
  type: ActionType$1.ToggleColVisCusModalVisibility,
2432
2459
  });
2433
- }, okayVariant: Variant$1.Light }, columns.map((column) => {
2434
- return (React__default["default"].createElement(CheckboxButton, { key: column.param, id: `IntelliTable-${id}-toggle-visibility-${column.param}`, className: "mb-2", text: column.title, onChanged: (checked) => {
2460
+ }, okayVariant: Variant$1.Light },
2461
+ columns.map((column) => {
2462
+ return (React__default["default"].createElement(CheckboxButton, { key: column.param, id: `IntelliTable-${id}-toggle-visibility-${column.param}`, className: "mb-2", text: column.title, onChanged: (checked) => {
2463
+ dispatch({
2464
+ type: ActionType$1.UpdateColumnVisibility,
2465
+ param: column.param,
2466
+ visible: checked,
2467
+ });
2468
+ }, checked: columnVisibilityMap[column.param], ariaLabel: `show "${column.title}" column in the ${title} table`, checkedVariant: Variant$1.Light, uncheckedVariant: Variant$1.Secondary }));
2469
+ }),
2470
+ React__default["default"].createElement("div", { className: "mt-3" }, "Or you can:"),
2471
+ React__default["default"].createElement("button", { type: "button", id: `IntelliTable-${id}-select-all-columns`, className: "btn btn-secondary me-2", "aria-label": `show all columns in the ${title} table`, onClick: () => {
2472
+ dispatch({
2473
+ type: ActionType$1.ShowAllColumns,
2474
+ });
2475
+ } }, "Select All"),
2476
+ React__default["default"].createElement("button", { type: "button", id: `IntelliTable-${id}-select-none-columns`, className: "btn btn-secondary", "aria-label": `hide all columns in the ${title} table`, onClick: () => {
2435
2477
  dispatch({
2436
- type: ActionType$1.UpdateColumnVisibility,
2437
- param: column.param,
2438
- visible: checked,
2478
+ type: ActionType$1.HideAllColumns,
2439
2479
  });
2440
- }, checked: columnVisibilityMap[column.param], ariaLabel: `show "${column.title}" column`, checkedVariant: Variant$1.Light, uncheckedVariant: Variant$1.Secondary }));
2441
- })));
2480
+ } }, "Deselect All")));
2442
2481
  }
2443
2482
  /*----------------------------------------*/
2444
2483
  /* Main UI */
@@ -2664,14 +2703,16 @@ const IntelliTable = (props) => {
2664
2703
  })
2665
2704
  .length);
2666
2705
  // Build CSV
2667
- const csv = genCSV(data, columns);
2706
+ const csv = genCSV(data, columns.filter((column) => {
2707
+ return columnVisibilityMap[column.param];
2708
+ }));
2668
2709
  // Build main UI
2669
2710
  return (React__default["default"].createElement("div", { className: `IntelliTable-container-${id}` },
2670
2711
  modal,
2671
2712
  React__default["default"].createElement("div", { className: "d-flex align-items-center justify-content-start" },
2672
2713
  React__default["default"].createElement("h3", { className: "m-0" }, title),
2673
2714
  React__default["default"].createElement("div", { className: "flex-grow-1 text-end" },
2674
- React__default["default"].createElement(CSVDownloadButton, { "aria-label": `download data as csv for ${title}`, id: `IntelliTable-${id}-download-as-csv`, filename: `${title}.csv`, csv: csv }),
2715
+ React__default["default"].createElement(CSVDownloadButton, { "aria-label": `download data as csv for ${title}`, id: `IntelliTable-${id}-download-as-csv`, filename: filename, csv: csv }),
2675
2716
  React__default["default"].createElement("button", { type: "button", className: "btn btn-secondary ms-2", "aria-label": `show panel for customizing which columns show in table ${title}`, id: `IntelliTable-${id}-show-column-customization-modal`, onClick: () => {
2676
2717
  dispatch({
2677
2718
  type: ActionType$1.ToggleColVisCusModalVisibility,
@@ -2790,6 +2831,195 @@ const style = `
2790
2831
  }
2791
2832
  `;
2792
2833
  /*------------------------------------------------------------------------*/
2834
+ /* Constants */
2835
+ /*------------------------------------------------------------------------*/
2836
+ const columns = [
2837
+ {
2838
+ title: 'First Name',
2839
+ param: 'userFirstName',
2840
+ type: ParamType$1.String,
2841
+ },
2842
+ {
2843
+ title: 'Last Name',
2844
+ param: 'userLastName',
2845
+ type: ParamType$1.String,
2846
+ },
2847
+ {
2848
+ title: 'Email',
2849
+ param: 'userEmail',
2850
+ type: ParamType$1.String,
2851
+ },
2852
+ {
2853
+ title: 'Canvas Id',
2854
+ param: 'userId',
2855
+ type: ParamType$1.Int,
2856
+ },
2857
+ {
2858
+ title: 'Student?',
2859
+ param: 'isLearner',
2860
+ type: ParamType$1.Boolean,
2861
+ },
2862
+ {
2863
+ title: 'Teaching Staff?',
2864
+ param: 'isTTM',
2865
+ type: ParamType$1.Boolean,
2866
+ startsHidden: true,
2867
+ },
2868
+ {
2869
+ title: 'Admin?',
2870
+ param: 'isAdmin',
2871
+ type: ParamType$1.Boolean,
2872
+ startsHidden: true,
2873
+ },
2874
+ {
2875
+ title: 'Course Canvas Id',
2876
+ param: 'courseId',
2877
+ type: ParamType$1.Int,
2878
+ startsHidden: true,
2879
+ },
2880
+ {
2881
+ title: 'Course Name',
2882
+ param: 'courseName',
2883
+ type: ParamType$1.String,
2884
+ },
2885
+ {
2886
+ title: 'Browser Name',
2887
+ param: 'browser.name',
2888
+ type: ParamType$1.String,
2889
+ startsHidden: true,
2890
+ },
2891
+ {
2892
+ title: 'Browser Version',
2893
+ param: 'browser.version',
2894
+ type: ParamType$1.String,
2895
+ startsHidden: true,
2896
+ },
2897
+ {
2898
+ title: 'OS',
2899
+ param: 'device.os',
2900
+ type: ParamType$1.String,
2901
+ startsHidden: true,
2902
+ },
2903
+ {
2904
+ title: 'Mobile?',
2905
+ param: 'device.isMobile',
2906
+ type: ParamType$1.Boolean,
2907
+ startsHidden: true,
2908
+ },
2909
+ {
2910
+ title: 'Year',
2911
+ param: 'year',
2912
+ type: ParamType$1.Int,
2913
+ },
2914
+ {
2915
+ title: 'Month',
2916
+ param: 'month',
2917
+ type: ParamType$1.Int,
2918
+ },
2919
+ {
2920
+ title: 'Day',
2921
+ param: 'day',
2922
+ type: ParamType$1.Int,
2923
+ },
2924
+ {
2925
+ title: 'Hour',
2926
+ param: 'hour',
2927
+ type: ParamType$1.Int,
2928
+ },
2929
+ {
2930
+ title: 'Minute',
2931
+ param: 'minute',
2932
+ type: ParamType$1.Int,
2933
+ startsHidden: true,
2934
+ },
2935
+ {
2936
+ title: 'Timestamp',
2937
+ param: 'timestamp',
2938
+ type: ParamType$1.Int,
2939
+ startsHidden: true,
2940
+ },
2941
+ {
2942
+ title: 'Context',
2943
+ param: 'context',
2944
+ type: ParamType$1.String,
2945
+ },
2946
+ {
2947
+ title: 'Subcontext',
2948
+ param: 'subcontext',
2949
+ type: ParamType$1.String,
2950
+ },
2951
+ {
2952
+ title: 'Tags',
2953
+ param: 'tags',
2954
+ type: ParamType$1.JSON,
2955
+ startsHidden: true,
2956
+ },
2957
+ {
2958
+ title: 'Log Level',
2959
+ param: 'level',
2960
+ type: ParamType$1.String,
2961
+ startsHidden: true,
2962
+ },
2963
+ {
2964
+ title: 'Metadata',
2965
+ param: 'metadata',
2966
+ type: ParamType$1.JSON,
2967
+ startsHidden: true,
2968
+ },
2969
+ {
2970
+ title: 'Source',
2971
+ param: 'source',
2972
+ type: ParamType$1.String,
2973
+ },
2974
+ {
2975
+ title: 'Server Route Path',
2976
+ param: 'routePath',
2977
+ type: ParamType$1.String,
2978
+ startsHidden: true,
2979
+ },
2980
+ {
2981
+ title: 'Server Route Template',
2982
+ param: 'routeTemplate',
2983
+ type: ParamType$1.String,
2984
+ startsHidden: true,
2985
+ },
2986
+ {
2987
+ title: 'Type',
2988
+ param: 'type',
2989
+ type: ParamType$1.String,
2990
+ },
2991
+ {
2992
+ title: 'Error Message',
2993
+ param: 'errorMessage',
2994
+ type: ParamType$1.String,
2995
+ startsHidden: true,
2996
+ },
2997
+ {
2998
+ title: 'Error Code',
2999
+ param: 'errorCode',
3000
+ type: ParamType$1.String,
3001
+ startsHidden: true,
3002
+ },
3003
+ {
3004
+ title: 'Error Stack',
3005
+ param: 'errorStack',
3006
+ type: ParamType$1.String,
3007
+ startsHidden: true,
3008
+ },
3009
+ {
3010
+ title: 'Action Target',
3011
+ param: 'target',
3012
+ type: ParamType$1.String,
3013
+ startsHidden: true,
3014
+ },
3015
+ {
3016
+ title: 'Action Type',
3017
+ param: 'action',
3018
+ type: ParamType$1.String,
3019
+ startsHidden: true,
3020
+ },
3021
+ ];
3022
+ /*------------------------------------------------------------------------*/
2793
3023
  /* Static Functions */
2794
3024
  /*------------------------------------------------------------------------*/
2795
3025
  /**
@@ -3787,193 +4017,6 @@ const LogReviewer = (props) => {
3787
4017
  /*----------------------------------------*/
3788
4018
  /* Data */
3789
4019
  /*----------------------------------------*/
3790
- // Create data table
3791
- const columns = [
3792
- {
3793
- title: 'First Name',
3794
- param: 'userFirstName',
3795
- type: ParamType$1.String,
3796
- },
3797
- {
3798
- title: 'Last Name',
3799
- param: 'userLastName',
3800
- type: ParamType$1.String,
3801
- },
3802
- {
3803
- title: 'Email',
3804
- param: 'userEmail',
3805
- type: ParamType$1.String,
3806
- },
3807
- {
3808
- title: 'Canvas Id',
3809
- param: 'userId',
3810
- type: ParamType$1.Int,
3811
- },
3812
- {
3813
- title: 'Student?',
3814
- param: 'isLearner',
3815
- type: ParamType$1.Boolean,
3816
- },
3817
- {
3818
- title: 'Teaching Staff?',
3819
- param: 'isTTM',
3820
- type: ParamType$1.Boolean,
3821
- startsHidden: true,
3822
- },
3823
- {
3824
- title: 'Admin?',
3825
- param: 'isAdmin',
3826
- type: ParamType$1.Boolean,
3827
- startsHidden: true,
3828
- },
3829
- {
3830
- title: 'Course Canvas Id',
3831
- param: 'courseId',
3832
- type: ParamType$1.Int,
3833
- startsHidden: true,
3834
- },
3835
- {
3836
- title: 'Course Name',
3837
- param: 'courseName',
3838
- type: ParamType$1.String,
3839
- },
3840
- {
3841
- title: 'Browser Name',
3842
- param: 'browser.name',
3843
- type: ParamType$1.String,
3844
- startsHidden: true,
3845
- },
3846
- {
3847
- title: 'Browser Version',
3848
- param: 'browser.version',
3849
- type: ParamType$1.String,
3850
- startsHidden: true,
3851
- },
3852
- {
3853
- title: 'OS',
3854
- param: 'device.os',
3855
- type: ParamType$1.String,
3856
- startsHidden: true,
3857
- },
3858
- {
3859
- title: 'Mobile?',
3860
- param: 'device.isMobile',
3861
- type: ParamType$1.Boolean,
3862
- startsHidden: true,
3863
- },
3864
- {
3865
- title: 'Year',
3866
- param: 'year',
3867
- type: ParamType$1.Int,
3868
- },
3869
- {
3870
- title: 'Month',
3871
- param: 'month',
3872
- type: ParamType$1.Int,
3873
- },
3874
- {
3875
- title: 'Day',
3876
- param: 'day',
3877
- type: ParamType$1.Int,
3878
- },
3879
- {
3880
- title: 'Hour',
3881
- param: 'hour',
3882
- type: ParamType$1.Int,
3883
- },
3884
- {
3885
- title: 'Minute',
3886
- param: 'minute',
3887
- type: ParamType$1.Int,
3888
- startsHidden: true,
3889
- },
3890
- {
3891
- title: 'Timestamp',
3892
- param: 'timestamp',
3893
- type: ParamType$1.Int,
3894
- startsHidden: true,
3895
- },
3896
- {
3897
- title: 'Context',
3898
- param: 'context',
3899
- type: ParamType$1.String,
3900
- },
3901
- {
3902
- title: 'Subcontext',
3903
- param: 'subcontext',
3904
- type: ParamType$1.String,
3905
- },
3906
- {
3907
- title: 'Tags',
3908
- param: 'tags',
3909
- type: ParamType$1.JSON,
3910
- startsHidden: true,
3911
- },
3912
- {
3913
- title: 'Log Level',
3914
- param: 'level',
3915
- type: ParamType$1.String,
3916
- startsHidden: true,
3917
- },
3918
- {
3919
- title: 'Metadata',
3920
- param: 'metadata',
3921
- type: ParamType$1.JSON,
3922
- startsHidden: true,
3923
- },
3924
- {
3925
- title: 'Source',
3926
- param: 'source',
3927
- type: ParamType$1.String,
3928
- },
3929
- {
3930
- title: 'Server Route Path',
3931
- param: 'routePath',
3932
- type: ParamType$1.String,
3933
- startsHidden: true,
3934
- },
3935
- {
3936
- title: 'Server Route Template',
3937
- param: 'routeTemplate',
3938
- type: ParamType$1.String,
3939
- startsHidden: true,
3940
- },
3941
- {
3942
- title: 'Type',
3943
- param: 'type',
3944
- type: ParamType$1.String,
3945
- },
3946
- {
3947
- title: 'Error Message',
3948
- param: 'errorMessage',
3949
- type: ParamType$1.String,
3950
- startsHidden: true,
3951
- },
3952
- {
3953
- title: 'Error Code',
3954
- param: 'errorCode',
3955
- type: ParamType$1.String,
3956
- startsHidden: true,
3957
- },
3958
- {
3959
- title: 'Error Stack',
3960
- param: 'errorStack',
3961
- type: ParamType$1.String,
3962
- startsHidden: true,
3963
- },
3964
- {
3965
- title: 'Action Target',
3966
- param: 'target',
3967
- type: ParamType$1.String,
3968
- startsHidden: true,
3969
- },
3970
- {
3971
- title: 'Action Type',
3972
- param: 'action',
3973
- type: ParamType$1.String,
3974
- startsHidden: true,
3975
- },
3976
- ];
3977
4020
  // Nothing to show notice
3978
4021
  const noLogsNotice = (logs.length === 0
3979
4022
  ? (React__default["default"].createElement("div", { className: "alert alert-warning text-center mt-2" },