dce-reactkit 3.11.3 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ type Props = {
14
14
  */
15
15
  onChanged: (updatedItems: PickableItem[]) => void;
16
16
  noBottomMargin?: boolean;
17
+ hideSelectAllOrNoneButtons?: boolean;
17
18
  };
18
19
  declare const ItemPicker: React.FC<Props>;
19
20
  export default ItemPicker;
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  type Props = {
7
7
  title: React.ReactNode;
8
8
  children: React.ReactNode;
9
+ topRightChildren?: React.ReactNode;
9
10
  noBottomMargin?: boolean;
10
11
  noBottomPadding?: boolean;
11
12
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get number of words in string
3
+ * @author Gardenia Liu
4
+ * @author Allison Zhang
5
+ * @author Gabe Abrams
6
+ * @param text the string to check
7
+ * @returns number of words in the string
8
+ */
9
+ declare const getWordCount: (text: string) => number;
10
+ export default getWordCount;
@@ -79,6 +79,7 @@ import someAsync from './helpers/asyncArrayFunctions/someAsync';
79
79
  import capitalize from './helpers/capitalize';
80
80
  import shuffleArray from './helpers/shuffleArray';
81
81
  import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
82
+ import getWordCount from './helpers/getWordCount';
82
83
  import ModalButtonType from './types/ModalButtonType';
83
84
  import ModalSize from './types/ModalSize';
84
85
  import ModalType from './types/ModalType';
@@ -99,4 +100,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
99
100
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
100
101
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
101
102
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
102
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
103
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
package/dist/esm/index.js CHANGED
@@ -1599,7 +1599,9 @@ const style$7 = `
1599
1599
 
1600
1600
  /* Container for Title */
1601
1601
  .TabBox-title-container {
1602
- /* Place on Left */
1602
+ display: flex;
1603
+ justify-content: space-between;
1604
+ align-items: center;
1603
1605
  position: relative;
1604
1606
  left: 0;
1605
1607
  text-align: left;
@@ -1632,6 +1634,19 @@ const style$7 = `
1632
1634
  background: #fdfdfd;
1633
1635
  }
1634
1636
 
1637
+ .TabBox-title-right-container {
1638
+ display: flex;
1639
+ flex-direction: row;
1640
+ align-items: bottom;
1641
+ height: 2.4rem;
1642
+ overflow: visible;
1643
+ }
1644
+
1645
+ .TabBox-title-right-contents {
1646
+ margin-right: 0.5rem;
1647
+ margin-bottom: 0.2rem;
1648
+ }
1649
+
1635
1650
  /* Make the TabBox's Children Appear Above Title if Overlap Occurs */
1636
1651
  .TabBox-children {
1637
1652
  position: relative;
@@ -1645,19 +1660,16 @@ const TabBox = (props) => {
1645
1660
  /*------------------------------------------------------------------------*/
1646
1661
  /* -------------------------------- Setup ------------------------------- */
1647
1662
  /*------------------------------------------------------------------------*/
1648
- /* -------------- Props ------------- */
1649
- const { title, children, noBottomPadding, noBottomMargin, } = props;
1663
+ const { title, children, topRightChildren, noBottomPadding, noBottomMargin, } = props;
1650
1664
  /*------------------------------------------------------------------------*/
1651
1665
  /* ------------------------------- Render ------------------------------- */
1652
1666
  /*------------------------------------------------------------------------*/
1653
- /*----------------------------------------*/
1654
- /* --------------- Main UI -------------- */
1655
- /*----------------------------------------*/
1656
- // Full UI
1657
1667
  return (React__default.createElement("div", { className: `TabBox-container ${noBottomMargin ? '' : 'mb-2'}` },
1658
1668
  React__default.createElement("style", null, style$7),
1659
1669
  React__default.createElement("div", { className: "TabBox-title-container" },
1660
- React__default.createElement("div", { className: "TabBox-title" }, title)),
1670
+ React__default.createElement("div", { className: "TabBox-title" }, title),
1671
+ topRightChildren && (React__default.createElement("div", { className: "TabBox-title-right-container" },
1672
+ React__default.createElement("div", { className: "TabBox-title-right-contents" }, topRightChildren)))),
1661
1673
  React__default.createElement("div", { className: `TabBox-box ps-2 pt-2 pe-2 ${noBottomPadding ? '' : 'pb-2'}` },
1662
1674
  React__default.createElement("div", { className: "TabBox-children" }, children))));
1663
1675
  };
@@ -2667,17 +2679,62 @@ const ItemPicker = (props) => {
2667
2679
  /*------------------------------------------------------------------------*/
2668
2680
  /* -------------- Props ------------- */
2669
2681
  // Destructure all props
2670
- const { title, items, onChanged, noBottomMargin, } = props;
2682
+ const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, } = props;
2671
2683
  /*------------------------------------------------------------------------*/
2672
2684
  /* ------------------------- Component Functions ------------------------ */
2673
2685
  /*------------------------------------------------------------------------*/
2686
+ /**
2687
+ * Updates the checked state of an item (including all children)
2688
+ * @author Yuen Ler Chow
2689
+ * @param item the item to update
2690
+ * @param checked the new checked state
2691
+ * @returns the updated item
2692
+ */
2693
+ const updateItemChecked = (item, checked) => {
2694
+ if (item.isGroup) {
2695
+ return Object.assign(Object.assign({}, item), { children: item.children.map((child) => {
2696
+ return updateItemChecked(child, checked);
2697
+ }) });
2698
+ }
2699
+ return Object.assign(Object.assign({}, item), { checked });
2700
+ };
2701
+ /**
2702
+ * Selects all items in the list
2703
+ * @author Yuen Ler Chow
2704
+ */
2705
+ const handleSelectAll = () => {
2706
+ const updatedItems = items.map((item) => {
2707
+ return updateItemChecked(item, true);
2708
+ });
2709
+ onChanged(updatedItems);
2710
+ };
2711
+ /**
2712
+ * Deselects all items in the list
2713
+ * @author Yuen Ler Chow
2714
+ */
2715
+ const handleDeselectAll = () => {
2716
+ const updatedItems = items.map((item) => {
2717
+ return updateItemChecked(item, false);
2718
+ });
2719
+ onChanged(updatedItems);
2720
+ };
2674
2721
  /*------------------------------------------------------------------------*/
2675
2722
  /* ------------------------------- Render ------------------------------- */
2676
2723
  /*------------------------------------------------------------------------*/
2677
2724
  /*----------------------------------------*/
2678
2725
  /* --------------- Main UI -------------- */
2679
2726
  /*----------------------------------------*/
2680
- return (React__default.createElement(TabBox, { title: title, noBottomMargin: noBottomMargin },
2727
+ // Select all/none
2728
+ const selectAllOrNone = (!hideSelectAllOrNoneButtons
2729
+ ? (React__default.createElement("div", { className: "d-flex h-100 align-items-end flex-row" },
2730
+ React__default.createElement("div", { className: "d-flex justify-content-end" },
2731
+ React__default.createElement("div", { className: "me-2", style: { fontSize: '1.2rem' } }, "Select"),
2732
+ React__default.createElement("div", { className: "btn-group", role: "group" },
2733
+ React__default.createElement("button", { type: "button", style: { borderRight: '0.1rem solid white' }, "aria-label": "Select all contexts", className: "btn btn-secondary py-0", onClick: handleSelectAll }, "All"),
2734
+ React__default.createElement("button", { type: "button", "aria-label": "Deselect all contexts", className: "btn btn-secondary py-0", onClick: handleDeselectAll }, "None")))))
2735
+ : undefined);
2736
+ // Main UI
2737
+ return (React__default.createElement(TabBox, { title: title, noBottomMargin: noBottomMargin, topRightChildren: selectAllOrNone },
2681
2738
  React__default.createElement("div", { style: { overflowX: 'auto' } },
2682
2739
  React__default.createElement(NestableItemList, { items: items, onChanged: onChanged }))));
2683
2740
  };
@@ -16374,6 +16431,27 @@ const visitEndpointOnAnotherServer = (opts) => __awaiter(void 0, void 0, void 0,
16374
16431
  return body;
16375
16432
  });
16376
16433
 
16434
+ const punctuationRegex = /[!@#$%^&*(),.?\/;:'"\-\[\]]/g;
16435
+ /**
16436
+ * Get number of words in string
16437
+ * @author Gardenia Liu
16438
+ * @author Allison Zhang
16439
+ * @author Gabe Abrams
16440
+ * @param text the string to check
16441
+ * @returns number of words in the string
16442
+ */
16443
+ const getWordCount = (text) => {
16444
+ const trimmedTextWithoutPunctuation = (text
16445
+ // Remove leading and trailing whitespace
16446
+ .trim()
16447
+ // Remove punctuation
16448
+ .replace(punctuationRegex, ''));
16449
+ if (trimmedTextWithoutPunctuation.length === 0) {
16450
+ return 0;
16451
+ }
16452
+ return trimmedTextWithoutPunctuation.split(/\s+/g).length;
16453
+ };
16454
+
16377
16455
  /**
16378
16456
  * Days of the week
16379
16457
  * @author Gabe Abrams
@@ -16390,5 +16468,5 @@ var DayOfWeek;
16390
16468
  })(DayOfWeek || (DayOfWeek = {}));
16391
16469
  var DayOfWeek$1 = DayOfWeek;
16392
16470
 
16393
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
16471
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getWordCount, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
16394
16472
  //# sourceMappingURL=index.js.map