lightning-base-components 1.14.6-alpha → 1.15.2-alpha

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.
Files changed (169) hide show
  1. package/metadata/raptor.json +31 -4
  2. package/package.json +13 -2
  3. package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
  6. package/src/lightning/alert/__docs__/alert.md +99 -0
  7. package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
  8. package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
  9. package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
  10. package/src/lightning/alert/alert.html +3 -0
  11. package/src/lightning/alert/alert.js +78 -0
  12. package/src/lightning/alert/alert.js-meta.xml +6 -0
  13. package/src/lightning/baseCombobox/baseCombobox.html +2 -1
  14. package/src/lightning/baseCombobox/baseCombobox.js +41 -6
  15. package/src/lightning/button/__wdio__/utam/utam.html +3 -0
  16. package/src/lightning/button/__wdio__/utam/utam.js +3 -0
  17. package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
  18. package/src/lightning/button/button.js +22 -1
  19. package/src/lightning/buttonMenu/buttonMenu.js +12 -0
  20. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  21. package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
  22. package/src/lightning/combobox/__docs__/combobox.md +3 -1
  23. package/src/lightning/combobox/combobox.js +0 -1
  24. package/src/lightning/confirm/__docs__/confirm.md +98 -0
  25. package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
  26. package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
  27. package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
  28. package/src/lightning/confirm/confirm.html +3 -0
  29. package/src/lightning/confirm/confirm.js +80 -0
  30. package/src/lightning/confirm/confirm.js-meta.xml +6 -0
  31. package/src/lightning/datatable/__docs__/datatable.md +45 -0
  32. package/src/lightning/datatable/__wdio__/utam/utam.html +32 -0
  33. package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
  34. package/src/lightning/datatable/__wdio__/utam/utam.spec.js +214 -0
  35. package/src/lightning/datatable/columns.js +166 -71
  36. package/src/lightning/datatable/datatable.js +103 -20
  37. package/src/lightning/datatable/headerActions.js +2 -2
  38. package/src/lightning/datatable/inlineEdit.js +0 -5
  39. package/src/lightning/datatable/inlineEditShared.js +4 -2
  40. package/src/lightning/datatable/keyboard.js +17 -13
  41. package/src/lightning/datatable/renderManager.js +45 -13
  42. package/src/lightning/datatable/resizeSensor.js +11 -3
  43. package/src/lightning/datatable/rowSelection.js +9 -3
  44. package/src/lightning/datatable/rowSelectionShared.js +33 -20
  45. package/src/lightning/datatable/rows.js +3 -2
  46. package/src/lightning/datatable/sort.js +8 -8
  47. package/src/lightning/datatable/state.js +9 -1
  48. package/src/lightning/datatable/templates/div/div.html +6 -2
  49. package/src/lightning/datatable/templates/table/table.html +7 -4
  50. package/src/lightning/datatable/tree.js +25 -0
  51. package/src/lightning/datatable/types.js +77 -9
  52. package/src/lightning/datatable/utils.js +51 -24
  53. package/src/lightning/datatable/virtualization.js +319 -0
  54. package/src/lightning/datatable/wrapText.js +54 -16
  55. package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
  56. package/src/lightning/datepicker/datepicker.html +1 -0
  57. package/src/lightning/datepicker/datepicker.js +10 -0
  58. package/src/lightning/datetimepicker/datetimepicker.html +2 -0
  59. package/src/lightning/datetimepicker/datetimepicker.js +8 -0
  60. package/src/lightning/dualListbox/dualListbox.js +2 -1
  61. package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
  62. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
  63. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
  64. package/src/lightning/formattedAddress/formattedAddress.js +7 -1
  65. package/src/lightning/groupedCombobox/groupedCombobox.html +2 -1
  66. package/src/lightning/groupedCombobox/groupedCombobox.js +16 -2
  67. package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
  68. package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
  69. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
  70. package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
  71. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
  72. package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
  73. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
  74. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
  75. package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
  76. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
  77. package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
  78. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
  79. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
  80. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
  81. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
  82. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
  83. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
  84. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
  85. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  86. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
  87. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
  88. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
  89. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
  90. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
  91. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
  92. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
  93. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
  94. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
  95. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
  96. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
  97. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
  98. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
  99. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
  100. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
  101. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
  102. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
  103. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
  104. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
  105. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
  106. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
  107. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
  108. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
  109. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  110. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
  111. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
  112. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
  113. package/src/lightning/input/__docs__/input.md +2 -0
  114. package/src/lightning/input/input.html +6 -0
  115. package/src/lightning/input/input.js +2 -1
  116. package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
  117. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
  118. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
  119. package/src/lightning/inputAddress/inputAddress.html +2 -0
  120. package/src/lightning/inputAddress/inputAddress.js +26 -3
  121. package/src/lightning/inputName/__docs__/inputName.md +2 -0
  122. package/src/lightning/inputName/inputName.html +4 -1
  123. package/src/lightning/inputUtils/inputUtils.js +11 -0
  124. package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
  125. package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
  126. package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
  127. package/src/lightning/menuItem/menuItem.js +4 -1
  128. package/src/lightning/modalBase/modalBase.css +20 -0
  129. package/src/lightning/modalBase/modalBase.html +54 -0
  130. package/src/lightning/modalBase/modalBase.js +1039 -0
  131. package/src/lightning/overlay/__docs__/overlay.md +90 -0
  132. package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
  133. package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
  134. package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
  135. package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
  136. package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
  137. package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
  138. package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
  139. package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
  140. package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
  141. package/src/lightning/overlay/overlay.html +3 -0
  142. package/src/lightning/overlay/overlay.js +45 -0
  143. package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
  144. package/src/lightning/overlayContainer/overlayContainer.html +3 -0
  145. package/src/lightning/overlayContainer/overlayContainer.js +138 -0
  146. package/src/lightning/overlayManager/overlayManager.js +54 -0
  147. package/src/lightning/overlayUtils/overlayUtils.js +17 -0
  148. package/src/lightning/picklist/picklist.js +6 -1
  149. package/src/lightning/progressBar/progressBar.html +2 -1
  150. package/src/lightning/progressBar/progressBar.js +18 -1
  151. package/src/lightning/prompt/__docs__/prompt.md +100 -0
  152. package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
  153. package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
  154. package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
  155. package/src/lightning/prompt/prompt.css +81 -0
  156. package/src/lightning/prompt/prompt.html +8 -0
  157. package/src/lightning/prompt/prompt.js +92 -0
  158. package/src/lightning/prompt/prompt.js-meta.xml +6 -0
  159. package/src/lightning/radioGroup/radioGroup.js +9 -0
  160. package/src/lightning/select/select.html +3 -1
  161. package/src/lightning/select/select.js +5 -1
  162. package/src/lightning/textarea/textarea.html +1 -0
  163. package/src/lightning/textarea/textarea.js +5 -0
  164. package/src/lightning/timepicker/timepicker.html +3 -1
  165. package/src/lightning/timepicker/timepicker.js +8 -0
  166. package/src/lightning/utilsPrivate/aria.js +26 -0
  167. package/src/lightning/utilsPrivate/linkify.js +1 -1
  168. package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
  169. package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
@@ -10,8 +10,8 @@ const VALID_SORT_DIRECTIONS = {
10
10
  * Determines if the supplied sort direction is valid.
11
11
  * Refer to `VALID_SORT_DIRECTIONS` for valid solid directions.
12
12
  *
13
- * @param {string} value The sort direction to validate
14
- * @return {boolean} Whether the supplied sort direction is valid
13
+ * @param {String} value The sort direction to validate
14
+ * @returns {Boolean} Whether the supplied sort direction is valid
15
15
  */
16
16
  export function isValidSortDirection(value) {
17
17
  return !!VALID_SORT_DIRECTIONS[value];
@@ -22,7 +22,7 @@ export function isValidSortDirection(value) {
22
22
  * the default sort direction is applied first. Clicking again reverses it
23
23
  *
24
24
  * @param {Object} state The current datatable state
25
- * @return {string} The default sort direction
25
+ * @returns {String} The default sort direction
26
26
  */
27
27
  export function getDefaultSortDirection(state) {
28
28
  return state.defaultSortDirection;
@@ -33,7 +33,7 @@ export function getDefaultSortDirection(state) {
33
33
  * the default sort direction is applied first. Clicking again reverses it
34
34
  *
35
35
  * @param {Object} state The current datatable state
36
- * @param {string} value The value to update the default sort direction to
36
+ * @param {String} value The value to update the default sort direction to
37
37
  */
38
38
  export function setDefaultSortDirection(state, value) {
39
39
  assert(
@@ -51,7 +51,7 @@ export function setDefaultSortDirection(state, value) {
51
51
  * Gets the current sort direction
52
52
  *
53
53
  * @param {Object} state The current datatable state
54
- * @return {string} The current sort direction
54
+ * @returns {String} The current sort direction
55
55
  */
56
56
  export function getSortedDirection(state) {
57
57
  return state.sortedDirection;
@@ -64,7 +64,7 @@ export function getSortedDirection(state) {
64
64
  * `sortedDirection` will be `undefined`
65
65
  *
66
66
  * @param {Object} state The current datatable state
67
- * @param {string} value The value to update the sort direction to
67
+ * @param {String} value The value to update the sort direction to
68
68
  */
69
69
  export function setSortedDirection(state, value) {
70
70
  assert(
@@ -81,7 +81,7 @@ export function setSortedDirection(state, value) {
81
81
  * of a given column in the datatable
82
82
  *
83
83
  * @param {Object} state The current datatable state
84
- * @return {string} The current sort value
84
+ * @returns {String} The current sort value
85
85
  */
86
86
  export function getSortedBy(state) {
87
87
  return state.sortedBy;
@@ -94,7 +94,7 @@ export function getSortedBy(state) {
94
94
  * to `undefined`
95
95
  *
96
96
  * @param {Object} state The current datatable state
97
- * @param {string} value The value to update the sort state to
97
+ * @param {String} value The value to update the sort state to
98
98
  */
99
99
  export function setSortedBy(state, value) {
100
100
  if (typeof value === 'string') {
@@ -3,7 +3,8 @@
3
3
  * The state object is further manipulated while it is passed around by datatable
4
4
  *
5
5
  * TODO: Check to see if there are other items that need to be added to the default state
6
- * @returns {Object} - intial state of the datatable
6
+ *
7
+ * @returns {Object} Intial state of the datatable
7
8
  */
8
9
  export const getDefaultState = function () {
9
10
  return {
@@ -62,6 +63,13 @@ export const getDefaultState = function () {
62
63
  rowHeight: 30.5,
63
64
  renderedRowCount: 0,
64
65
  firstVisibleIndex: 0, // first row that should be visible in viewport
66
+ fixedHeight: false, // by default, assume that not all rows are same height
67
+ heightCache: {}, // cache of row heights
68
+ offsets: [0],
69
+ offsetRanges: [],
70
+ firstRowOffset: 0, // how many pixels scrollTop is from top of first visible row
71
+ tableHeight: 0,
72
+ shouldResetHeights: false,
65
73
 
66
74
  // inline edit
67
75
  inlineEdit: {
@@ -35,7 +35,10 @@
35
35
  aria-label={ariaLabel}
36
36
  aria-labelledby={ariaLabelledBy}
37
37
  aria-rowcount={ariaRowCount}
38
- aria-colcount={ariaColCount}>
38
+ aria-colcount={ariaColCount}
39
+ data-num-rows={data.length}
40
+ data-num-selected-rows={selectedRows.length}
41
+ data-last-rendered-row={_lastRenderedRow}>
39
42
  <template if:false={hasValidKeyField}>
40
43
  <!-- empty since keyField wasn't provided -->
41
44
  </template>
@@ -128,7 +131,8 @@
128
131
  aria-posinset={row.posInSet}
129
132
  aria-rowindex={row.ariaRowIndex}
130
133
  style={row.style}
131
- tabindex={row.tabIndex}>
134
+ tabindex={row.tabIndex}
135
+ data-row-number={row.rowNumber}>
132
136
  <template for:each={row.cells} for:item="cell">
133
137
  <template if:true={cell.isCheckbox}>
134
138
  <!-- Checkbox Cell -->
@@ -33,12 +33,14 @@
33
33
  onfocusout={handleTableFocusOut}
34
34
  aria-label={ariaLabel}
35
35
  aria-labelledby={ariaLabelledBy}
36
- aria-rowcount={ariaRowCount}>
36
+ data-num-rows={data.length}
37
+ data-num-selected-rows={selectedRows.length}
38
+ data-last-rendered-row={_lastRenderedRow}>
37
39
  <template if:false={hasValidKeyField}>
38
40
  <!-- empty since keyField wasn't provided TODO: Why is this here? Test and remove! -->
39
41
  </template>
40
42
  <template if:true={hasValidKeyField}>
41
- <thead>
43
+ <thead data-rowgroup-header>
42
44
  <!-- Column Header Row -->
43
45
  <tr class="slds-line-height_reset"
44
46
  data-row-key-value="HEADER"
@@ -99,7 +101,7 @@
99
101
  </template>
100
102
  </tr>
101
103
  </thead>
102
- <tbody style={computedTbodyStyle}>
104
+ <tbody data-rowgroup-body style={computedTbodyStyle}>
103
105
  <template for:each={renderedRows} for:item="row" for:index="rowIndex">
104
106
  <!-- Data Rows -->
105
107
  <tr class={row.classnames}
@@ -111,7 +113,8 @@
111
113
  aria-expanded={row.isExpanded}
112
114
  aria-setsize={row.setSize}
113
115
  aria-posinset={row.posInSet}
114
- tabindex={row.tabIndex}>
116
+ tabindex={row.tabIndex}
117
+ data-row-number={row.rowNumber}>
115
118
  <template for:each={row.cells} for:item="cell">
116
119
  <template if:true={cell.isCheckbox}>
117
120
  <!-- Checkbox Cell -->
@@ -1,6 +1,13 @@
1
1
  import { getColumns } from './columns';
2
2
  import { isTreeType } from './types';
3
3
 
4
+ /**
5
+ * Retrieves the default values for the tree state indicator field names.
6
+ * These values are used to make logic decisions later and may be updated
7
+ * during normal operation.
8
+ *
9
+ * @returns {Object} The default tree state indicator field names
10
+ */
4
11
  export function getTreeStateIndicatorFieldNames() {
5
12
  return {
6
13
  children: 'hasChildren',
@@ -11,6 +18,12 @@ export function getTreeStateIndicatorFieldNames() {
11
18
  };
12
19
  }
13
20
 
21
+ /**
22
+ * Determines if any of the columns in the datatable are of a tree-type.
23
+ *
24
+ * @param {Object} state The datatable state
25
+ * @returns {Boolean} Whether any of the columns are of a tree-type
26
+ */
14
27
  export function hasTreeDataType(state) {
15
28
  const columns = getColumns(state);
16
29
  return columns.some((column) => {
@@ -18,6 +31,12 @@ export function hasTreeDataType(state) {
18
31
  });
19
32
  }
20
33
 
34
+ /**
35
+ * Retrieves the first tree-type column from the state.
36
+ *
37
+ * @param {Object} state The datatable state
38
+ * @returns {Object} The first tree-type column, else `null`
39
+ */
21
40
  export function getStateTreeColumn(state) {
22
41
  const columns = getColumns(state);
23
42
  for (let i = 0; i < columns.length; i++) {
@@ -28,6 +47,12 @@ export function getStateTreeColumn(state) {
28
47
  return null;
29
48
  }
30
49
 
50
+ /**
51
+ * Dispatches an event when a row is toggled to be expanded or collapsed.
52
+ *
53
+ * @param {String} rowKeyValue The row key being acted upon
54
+ * @param {Boolean} expanded The current expand/collapse state of the row
55
+ */
31
56
  export function fireRowToggleEvent(rowKeyValue, expanded) {
32
57
  const customEvent = new CustomEvent('privatetogglecell', {
33
58
  bubbles: true,
@@ -102,35 +102,66 @@ const EDITABLE_STANDARD_TYPES = {
102
102
  date: true,
103
103
  };
104
104
 
105
+ /**
106
+ * Determines if a supplied type is a valid datatable type.
107
+ *
108
+ * @param {String} typeName The type to validate
109
+ * @returns {Boolean} Whether the supplied type is valid
110
+ */
105
111
  export function isValidType(typeName) {
106
112
  return !!STANDARD_TYPES[typeName];
107
113
  }
108
114
 
115
+ /**
116
+ * Determines if a supplied type is a tree type.
117
+ *
118
+ * @param {String} typeName The type to validate
119
+ * @returns {Boolean} Whether the supplied type is a tree type
120
+ */
109
121
  export function isTreeType(typeName) {
110
122
  return typeName === 'tree';
111
123
  }
112
124
 
125
+ /**
126
+ * Determines if a supplied type is valid for a tree type datatable.
127
+ *
128
+ * @param {String} typeName The type to validate
129
+ * @returns {Boolean} Whether the supplied type is valid for a tree
130
+ */
131
+ export function isValidTypeForTree(typeName) {
132
+ return !!TREE_SUPPORTED_TYPES[typeName];
133
+ }
134
+
135
+ /**
136
+ * Retrieves the attributes for a given type. Additionally, verifies
137
+ * the supplied type is valid.
138
+ *
139
+ * @param {String} typeName The type to get the attributes for
140
+ * @returns {Array} An array of attributes for the supplied type
141
+ */
113
142
  export function getAttributesNames(typeName) {
114
143
  assert(
115
144
  isValidType(typeName),
116
- `your are trying to access an invalid type (${typeName})`
145
+ `You are trying to access an invalid type (${typeName})`
117
146
  );
118
-
119
- return Array.isArray(STANDARD_TYPES[typeName])
120
- ? STANDARD_TYPES[typeName]
121
- : [];
122
- }
123
-
124
- export function isValidTypeForTree(dataType) {
125
- return !!TREE_SUPPORTED_TYPES[dataType];
147
+ return getStandardTypeAttributesNames(typeName);
126
148
  }
127
149
 
150
+ /**
151
+ * Retrieves the attributes for a given type.
152
+ *
153
+ * @param {String} typeName The type to get the attributes for
154
+ * @returns {Array} An array of attributes for the supplied type
155
+ */
128
156
  function getStandardTypeAttributesNames(typeName) {
129
157
  return Array.isArray(STANDARD_TYPES[typeName])
130
158
  ? STANDARD_TYPES[typeName]
131
159
  : [];
132
160
  }
133
161
 
162
+ /**
163
+ * A class for handling valid datatable types.
164
+ */
134
165
  export default class DatatableTypes {
135
166
  privateCustomTypes = {};
136
167
  isValidTypeForTree = isValidTypeForTree;
@@ -156,6 +187,13 @@ export default class DatatableTypes {
156
187
  }
157
188
  }
158
189
 
190
+ /**
191
+ * Retrieves a type. If the specified type is not a custom type,
192
+ * lookup the type in our standard types. Otherwise, return undefined.
193
+ *
194
+ * @param {String} typeName The type to retrieve
195
+ * @returns {Object | Undefined} The type metadata
196
+ */
159
197
  getType(typeName) {
160
198
  if (this.privateCustomTypes[typeName]) {
161
199
  return this.privateCustomTypes[typeName];
@@ -169,6 +207,12 @@ export default class DatatableTypes {
169
207
  return undefined;
170
208
  }
171
209
 
210
+ /**
211
+ * Retrieves a custom type's edit template if it exists.
212
+ *
213
+ * @param {String} typeName The custom type to retrieve
214
+ * @returns {Object | Undefined} The custom type's edit template
215
+ */
172
216
  getCustomTypeEditTemplate(typeName) {
173
217
  if (this.privateCustomTypes[typeName]) {
174
218
  return this.privateCustomTypes[typeName].editTemplate;
@@ -176,10 +220,22 @@ export default class DatatableTypes {
176
220
  return undefined;
177
221
  }
178
222
 
223
+ /**
224
+ * Determines if a type is a valid custom or standard type.
225
+ *
226
+ * @param {String} typeName The type to validate
227
+ * @returns {Boolean} Whether the type is valid
228
+ */
179
229
  isValidType(typeName) {
180
230
  return !!this.getType(typeName);
181
231
  }
182
232
 
233
+ /**
234
+ * Determines if a given type is editable.
235
+ *
236
+ * @param {String} typeName The type to test
237
+ * @returns {Boolean} Whether the type is editable
238
+ */
183
239
  isEditableType(typeName) {
184
240
  return (
185
241
  !!EDITABLE_STANDARD_TYPES[typeName] ||
@@ -187,12 +243,24 @@ export default class DatatableTypes {
187
243
  );
188
244
  }
189
245
 
246
+ /**
247
+ * Determines if a given type is a non-standard type.
248
+ *
249
+ * @param {String} typeName The type to test
250
+ * @returns {Boolean} Whether the type is a non-standard type
251
+ */
190
252
  isCustomType(typeName) {
191
253
  return (
192
254
  this.getType(typeName) && this.getType(typeName).type === 'custom'
193
255
  );
194
256
  }
195
257
 
258
+ /**
259
+ * Determines whether or not a given custom type is using a standard cell layout.
260
+ *
261
+ * @param {String} typeName The custom type to test
262
+ * @returns {Boolean} Whether the custom type is using a standard cell layout
263
+ */
196
264
  isStandardCellLayoutForCustomType(typeName) {
197
265
  return (
198
266
  this.isCustomType(typeName) &&
@@ -1,8 +1,4 @@
1
- export const isObjectLike = function (value) {
2
- return typeof value === 'object' && value !== null;
3
- };
4
-
5
- const proto = {
1
+ const CLASSSET_PROTOTYPE = {
6
2
  add(className) {
7
3
  if (typeof className === 'string') {
8
4
  this[className] = true;
@@ -24,32 +20,59 @@ const proto = {
24
20
  },
25
21
  };
26
22
 
23
+ /**
24
+ * Determines if a given value is object-like.
25
+ *
26
+ * @param {*} value Any value to check for object-like status
27
+ * @returns {Boolean} Whether the value is object-like
28
+ */
29
+ export const isObjectLike = function (value) {
30
+ return typeof value === 'object' && value !== null;
31
+ };
32
+
33
+ /**
34
+ * Creates an object of CSS class names based on a given config.
35
+ * Then, attaches an interface for managing the classes.
36
+ *
37
+ * @param {String | Object} config The initial class configuration
38
+ * @returns An interface, as defined in the `proto` method.
39
+ */
27
40
  export const classSet = function (config) {
28
41
  if (typeof config === 'string') {
29
42
  const key = config;
30
43
  config = {};
31
44
  config[key] = true;
32
45
  }
33
- return Object.assign(Object.create(proto), config);
46
+ return Object.assign(Object.create(CLASSSET_PROTOTYPE), config);
34
47
  };
35
48
 
49
+ /**
50
+ * Clamps a value between a minimum and maximum value
51
+ *
52
+ * @param {Number} num The input number
53
+ * @param {Number} min The minimum value the number can be
54
+ * @param {Number} max The maximum value the number can be
55
+ * @returns The clamped number
56
+ */
36
57
  export const clamp = function (num, min, max) {
37
58
  return num <= min ? min : num >= max ? max : num;
38
59
  };
39
60
 
40
61
  /**
41
- * Tests if the value passed in is a value greater than 0
42
- * @param {Integer} value - value to test
43
- * @returns {Boolean} - true if value is > 0
62
+ * Tests if the value passed in is a value greater than 0.
63
+ *
64
+ * @param {Integer} value Value to test
65
+ * @returns {Boolean} Whether the value is greater than 0
44
66
  */
45
67
  export const isPositiveInteger = function (value) {
46
68
  return /^[0-9]*[1-9][0-9]*$/.test(value);
47
69
  };
48
70
 
49
71
  /**
50
- * Tests if the value passed in is 0 or a number greater than 0
51
- * @param {Integer} value - value to test
52
- * @returns {Boolean} - true if value is >= 0
72
+ * Tests if the value passed in is 0 or a number greater than 0.
73
+ *
74
+ * @param {Integer} value Value to test
75
+ * @returns {Boolean} Whether the value is greater than or equal to 0
53
76
  */
54
77
  export const isNonNegativeInteger = function (value) {
55
78
  return /^\d+$/.test(value);
@@ -62,11 +85,11 @@ export const isNonNegativeInteger = function (value) {
62
85
  * b. numberType - non-negative: if value >= 0
63
86
  * If the value fails the test, the fallback value is returned
64
87
  *
65
- * @param {String} attrName - name of attribute to normalize
66
- * @param {Integer/String} value - value to normalize
67
- * @param {String} numberType - number type to validate against: positive / non-negative
68
- * @param {Integer} fallback - value to return if validation fails
69
- * @returns {Integer} - Returns normalized value if validation passes; else returns fallback
88
+ * @param {String} attrName Name of attribute to normalize
89
+ * @param {Integer | String} value Value to normalize
90
+ * @param {String} numberType Number type to validate against: positive / non-negative
91
+ * @param {Integer} fallback Value to return if validation fails
92
+ * @returns {Integer} Returns normalized value if validation passes; else returns fallback
70
93
  */
71
94
  export function normalizeNumberAttribute(
72
95
  attrName,
@@ -98,11 +121,14 @@ export function normalizeNumberAttribute(
98
121
  return fallback;
99
122
  }
100
123
 
101
- // TODO: move into scroller-specific utility when more scroll-related functionality
102
- // needs to be shared between libraries
103
124
  /**
104
- * Utility for calculating the scroll offset
105
- * @param {HTMLElement} el - target element of the scroll
125
+ * Utility for calculating the scroll offset.
126
+ *
127
+ * TODO: move into scroller-specific utility when more scroll-related functionality
128
+ * needs to be shared between libraries.
129
+ *
130
+ * @param {HTMLElement} el Target element of the scroll
131
+ * @returns {Number} The scroll offset from the table's end
106
132
  */
107
133
  export function getScrollOffsetFromTableEnd(el) {
108
134
  return (
@@ -111,9 +137,10 @@ export function getScrollOffsetFromTableEnd(el) {
111
137
  }
112
138
 
113
139
  /**
114
- * Utility for converting arrays and plain objects to style strings
115
- * @param {Array|Object} style
116
- * @returns {string} representing array/object as a string
140
+ * Utility for converting arrays and plain objects to style strings.
141
+ *
142
+ * @param {Array | Object} style The CSS style array/object
143
+ * @returns {String} Representing array/object as a string
117
144
  */
118
145
  export function styleToString(style) {
119
146
  if (!Array.isArray(style)) {