@salesforce/design-system-react 0.10.44 → 0.10.45

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 (38) hide show
  1. package/components/button/__tests__/button.browser-test.jsx +0 -1
  2. package/components/data-table/cell.jsx +2 -2
  3. package/components/data-table/index.jsx +130 -85
  4. package/components/data-table/private/context-helper.js +26 -14
  5. package/components/data-table/private/head.jsx +269 -260
  6. package/components/data-table/private/header-cell.jsx +204 -230
  7. package/components/data-table/private/row.jsx +140 -105
  8. package/components/data-table/row-actions.jsx +2 -2
  9. package/components/utilities/truncate/index.jsx +1 -1
  10. package/lib/components/button/__tests__/button.browser-test.jsx +0 -1
  11. package/lib/components/data-table/cell.js +6 -6
  12. package/lib/components/data-table/index.js +127 -99
  13. package/lib/components/data-table/private/context-helper.js +13 -14
  14. package/lib/components/data-table/private/head.js +233 -252
  15. package/lib/components/data-table/private/header-cell.js +185 -221
  16. package/lib/components/data-table/private/row.js +97 -89
  17. package/lib/components/data-table/row-actions.js +6 -6
  18. package/lib/components/utilities/truncate/index.js +2 -2
  19. package/lib/package.json +4 -4
  20. package/module/components/button/__tests__/button.browser-test.js +0 -1
  21. package/module/components/button/__tests__/button.browser-test.js.map +1 -1
  22. package/module/components/data-table/cell.js +6 -6
  23. package/module/components/data-table/cell.js.map +1 -1
  24. package/module/components/data-table/index.js +120 -95
  25. package/module/components/data-table/index.js.map +1 -1
  26. package/module/components/data-table/private/context-helper.js +12 -12
  27. package/module/components/data-table/private/context-helper.js.map +1 -1
  28. package/module/components/data-table/private/head.js +230 -255
  29. package/module/components/data-table/private/head.js.map +1 -1
  30. package/module/components/data-table/private/header-cell.js +184 -225
  31. package/module/components/data-table/private/header-cell.js.map +1 -1
  32. package/module/components/data-table/private/row.js +95 -87
  33. package/module/components/data-table/private/row.js.map +1 -1
  34. package/module/components/data-table/row-actions.js +6 -6
  35. package/module/components/data-table/row-actions.js.map +1 -1
  36. package/module/components/utilities/truncate/index.js +1 -1
  37. package/module/components/utilities/truncate/index.js.map +1 -1
  38. package/package.json +4 -4
@@ -4,7 +4,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
4
4
 
5
5
  /* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
6
6
  // ### React
7
- import React, { useContext } from 'react';
7
+ import React, { useCallback, useContext, useMemo } from 'react';
8
8
  import PropTypes from 'prop-types'; // ### classNames
9
9
 
10
10
  import classNames from 'classnames'; // ### find
@@ -18,7 +18,7 @@ import { DATA_TABLE_ROW, DATA_TABLE_ROW_ACTIONS, DATA_TABLE_CELL } from '../../.
18
18
  import InteractiveElement from '../interactive-element';
19
19
  import CellContext from '../private/cell-context';
20
20
  import TableContext from '../private/table-context';
21
- import contextHelper from './context-helper';
21
+ import useContextHelper from './context-helper';
22
22
  var InteractiveCheckbox = InteractiveElement(Checkbox);
23
23
  var InteractiveRadio = InteractiveElement(Radio);
24
24
  var propTypes = {
@@ -54,29 +54,35 @@ var propTypes = {
54
54
 
55
55
  var DataTableRow = function DataTableRow(props) {
56
56
  var tableContext = useContext(TableContext);
57
- var selectRowCellContext = {
58
- rowIndex: props.rowIndex,
59
- columnIndex: 0
60
- };
57
+ var selectRowCellContext = useMemo(function () {
58
+ return {
59
+ rowIndex: props.rowIndex,
60
+ columnIndex: 0
61
+ };
62
+ }, [props.rowIndex]);
61
63
 
62
- var _contextHelper = contextHelper(tableContext, selectRowCellContext, props.fixedLayout),
63
- tabIndex = _contextHelper.tabIndex,
64
- hasFocus = _contextHelper.hasFocus,
65
- handleFocus = _contextHelper.handleFocus,
66
- handleKeyDown = _contextHelper.handleKeyDown;
64
+ var _useContextHelper = useContextHelper(tableContext, selectRowCellContext, props.fixedLayout),
65
+ tabIndex = _useContextHelper.tabIndex,
66
+ hasFocus = _useContextHelper.hasFocus,
67
+ handleFocus = _useContextHelper.handleFocus,
68
+ handleKeyDown = _useContextHelper.handleKeyDown;
67
69
 
68
- var handleToggle = function handleToggle(e, _ref) {
70
+ var item = props.item,
71
+ onToggle = props.onToggle;
72
+ var handleToggle = useCallback(function (e, _ref) {
69
73
  var checked = _ref.checked;
70
- return props.onToggle(props.item, checked, e);
71
- };
74
+ return onToggle(item, checked, e);
75
+ }, [item, onToggle]);
76
+ var isSelected = !!find(props.selection, item);
77
+ var ariaProps = useMemo(function () {
78
+ var result = {};
72
79
 
73
- var ariaProps = {};
74
- var isSelected = !!find(props.selection, props.item);
75
-
76
- if (props.canSelectRows) {
77
- ariaProps['aria-selected'] = isSelected ? 'true' : 'false';
78
- } // i18n
80
+ if (props.canSelectRows) {
81
+ result['aria-selected'] = isSelected ? 'true' : 'false';
82
+ }
79
83
 
84
+ return result;
85
+ }, [isSelected, props.canSelectRows]); // i18n
80
86
 
81
87
  return /*#__PURE__*/React.createElement("tr", _extends({}, ariaProps, {
82
88
  className: classNames(props.className, {
@@ -84,76 +90,78 @@ var DataTableRow = function DataTableRow(props) {
84
90
  'slds-is-selected': props.canSelectRows && isSelected,
85
91
  'slds-has-focus': hasFocus
86
92
  })
87
- }), props.canSelectRows ?
88
- /*#__PURE__*/
89
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
90
- React.createElement("td", {
91
- role: props.fixedLayout ? 'gridcell' : null,
92
- className: "slds-text-align_right",
93
- "data-label": props.stacked ? 'Select Row' : undefined,
94
- style: {
95
- width: '3.25rem'
96
- },
97
- onFocus: handleFocus,
98
- onKeyDown: handleKeyDown,
99
- ref: function ref(_ref2) {
100
- if (_ref2 && hasFocus) {
101
- _ref2.focus();
102
- }
103
- },
104
- tabIndex: tabIndex
105
- }, /*#__PURE__*/React.createElement(CellContext.Provider, {
106
- value: selectRowCellContext
107
- }, props.canSelectRows === 'radio' ? /*#__PURE__*/React.createElement(InteractiveRadio, {
108
- assistiveText: {
109
- label: "".concat(props.assistiveText.selectRow, " ").concat(Number(props.index) + 1)
110
- },
111
- "aria-labelledby": "".concat(props.id, "-SelectRow-label ").concat(props.tableId, "-SLDSDataTableHead-column-group-header-row-select"),
112
- checked: isSelected,
113
- className: "slds-m-right_x-small",
114
- id: "".concat(props.id, "-SelectRow"),
115
- labelId: "".concat(props.id, "-SelectRow-label"),
116
- name: "".concat(props.tableId, "-SelectRow"),
117
- onChange: handleToggle
118
- }) : /*#__PURE__*/React.createElement(InteractiveCheckbox, {
119
- assistiveText: {
120
- label: "".concat(props.assistiveText.selectRow, " ").concat(Number(props.index) + 1)
121
- },
122
- "aria-labelledby": "".concat(props.id, "-SelectRow-label ").concat(props.tableId, "-SLDSDataTableHead-column-group-header-row-select"),
123
- checked: isSelected,
124
- id: "".concat(props.id, "-SelectRow"),
125
- labelId: "".concat(props.id, "-SelectRow-label"),
126
- name: "SelectRow".concat(props.index + 1),
127
- onChange: handleToggle
128
- }))) : null, props.columns.map(function (column, index) {
129
- var Cell = column.Cell;
130
- var cellId = "".concat(props.id, "-").concat(DATA_TABLE_CELL, "-").concat(column.props.property);
131
- return /*#__PURE__*/React.createElement(CellContext.Provider, {
132
- key: cellId,
93
+ }), useMemo(function () {
94
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.canSelectRows ?
95
+ /*#__PURE__*/
96
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
97
+ React.createElement("td", {
98
+ role: props.fixedLayout ? 'gridcell' : null,
99
+ className: "slds-text-align_right",
100
+ "data-label": props.stacked ? 'Select Row' : undefined,
101
+ style: {
102
+ width: '3.25rem'
103
+ },
104
+ onFocus: handleFocus,
105
+ onKeyDown: handleKeyDown,
106
+ ref: function ref(_ref2) {
107
+ if (_ref2 && hasFocus) {
108
+ _ref2.focus();
109
+ }
110
+ },
111
+ tabIndex: tabIndex
112
+ }, /*#__PURE__*/React.createElement(CellContext.Provider, {
113
+ value: selectRowCellContext
114
+ }, props.canSelectRows === 'radio' ? /*#__PURE__*/React.createElement(InteractiveRadio, {
115
+ assistiveText: {
116
+ label: "".concat(props.assistiveText.selectRow, " ").concat(Number(props.index) + 1)
117
+ },
118
+ "aria-labelledby": "".concat(props.id, "-SelectRow-label ").concat(props.tableId, "-SLDSDataTableHead-column-group-header-row-select"),
119
+ checked: isSelected,
120
+ className: "slds-m-right_x-small",
121
+ id: "".concat(props.id, "-SelectRow"),
122
+ labelId: "".concat(props.id, "-SelectRow-label"),
123
+ name: "".concat(props.tableId, "-SelectRow"),
124
+ onChange: handleToggle
125
+ }) : /*#__PURE__*/React.createElement(InteractiveCheckbox, {
126
+ assistiveText: {
127
+ label: "".concat(props.assistiveText.selectRow, " ").concat(Number(props.index) + 1)
128
+ },
129
+ "aria-labelledby": "".concat(props.id, "-SelectRow-label ").concat(props.tableId, "-SLDSDataTableHead-column-group-header-row-select"),
130
+ checked: isSelected,
131
+ id: "".concat(props.id, "-SelectRow"),
132
+ labelId: "".concat(props.id, "-SelectRow-label"),
133
+ name: "SelectRow".concat(props.index + 1),
134
+ onChange: handleToggle
135
+ }))) : null, props.columns.map(function (column, index) {
136
+ var Cell = column.Cell;
137
+ var cellId = "".concat(props.id, "-").concat(DATA_TABLE_CELL, "-").concat(column.props.property);
138
+ return /*#__PURE__*/React.createElement(CellContext.Provider, {
139
+ key: cellId,
140
+ value: {
141
+ columnIndex: props.canSelectRows ? index + 1 : index,
142
+ rowIndex: props.rowIndex
143
+ }
144
+ }, /*#__PURE__*/React.createElement(Cell, _extends({}, column.props, {
145
+ className: column.props.truncate ? 'slds-truncate' : null,
146
+ fixedLayout: props.fixedLayout,
147
+ rowHeader: column.props.primaryColumn,
148
+ id: cellId,
149
+ item: item,
150
+ width: column.props.width,
151
+ headerId: item.headerId,
152
+ columns: props.columns
153
+ }), item[column.props.property]));
154
+ }), /*#__PURE__*/React.createElement(CellContext.Provider, {
133
155
  value: {
134
- columnIndex: props.canSelectRows ? index + 1 : index,
156
+ columnIndex: props.canSelectRows ? props.columns.length + 1 : props.columns.length,
135
157
  rowIndex: props.rowIndex
136
158
  }
137
- }, /*#__PURE__*/React.createElement(Cell, _extends({}, column.props, {
138
- className: column.props.truncate ? 'slds-truncate' : null,
139
- fixedLayout: props.fixedLayout,
140
- rowHeader: column.props.primaryColumn,
141
- id: cellId,
142
- item: props.item,
143
- width: column.props.width,
144
- headerId: props.item.headerId,
145
- columns: props.columns
146
- }), props.item[column.props.property]));
147
- }), /*#__PURE__*/React.createElement(CellContext.Provider, {
148
- value: {
149
- columnIndex: props.canSelectRows ? props.columns.length + 1 : props.columns.length,
150
- rowIndex: props.rowIndex
151
- }
152
- }, props.rowActions ? /*#__PURE__*/React.cloneElement(props.rowActions, {
153
- id: "".concat(props.id, "-").concat(DATA_TABLE_ROW_ACTIONS),
154
- item: props.item,
155
- fixedLayout: props.fixedLayout
156
- }) : null));
159
+ }, props.rowActions ? /*#__PURE__*/React.cloneElement(props.rowActions, {
160
+ id: "".concat(props.id, "-").concat(DATA_TABLE_ROW_ACTIONS),
161
+ item: item,
162
+ fixedLayout: props.fixedLayout
163
+ }) : null));
164
+ }, [handleFocus, handleKeyDown, handleToggle, hasFocus, isSelected, item, tabIndex, props.assistiveText.selectRow, props.canSelectRows, props.columns, props.fixedLayout, props.id, props.index, props.rowActions, props.rowIndex, props.stacked, props.tableId, selectRowCellContext]));
157
165
  };
158
166
 
159
167
  DataTableRow.displayName = DATA_TABLE_ROW;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../.tmp-es/components/data-table/private/row.jsx"],"names":["React","useContext","PropTypes","classNames","find","Checkbox","Radio","DATA_TABLE_ROW","DATA_TABLE_ROW_ACTIONS","DATA_TABLE_CELL","InteractiveElement","CellContext","TableContext","contextHelper","InteractiveCheckbox","InteractiveRadio","propTypes","assistiveText","shape","actionsHeader","string","columnSort","columnSortedAscending","columnSortedDescending","selectAllRows","selectRow","canSelectRows","oneOfType","bool","oneOf","className","columns","arrayOf","Cell","func","props","object","fixedLayout","id","isRequired","item","onToggle","rowActions","element","selection","array","tableId","DataTableRow","tableContext","selectRowCellContext","rowIndex","columnIndex","tabIndex","hasFocus","handleFocus","handleKeyDown","handleToggle","e","checked","ariaProps","isSelected","stacked","undefined","width","ref","focus","label","Number","index","map","column","cellId","property","truncate","primaryColumn","headerId","length","cloneElement","displayName"],"mappings":";;AAAA;;AACA;AAEA;AACA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,OAAOC,SAAP,MAAsB,YAAtB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;;AACA,OAAOC,IAAP,MAAiB,aAAjB,C,CAEA;;AACA,OAAOC,QAAP,MAAqB,gBAArB;AACA,OAAOC,KAAP,MAAkB,aAAlB,C,CAEA;;AACA,SACCC,cADD,EAECC,sBAFD,EAGCC,eAHD,QAIO,8BAJP;AAMA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,YAAP,MAAyB,0BAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AAEA,IAAMC,mBAAmB,GAAGJ,kBAAkB,CAACL,QAAD,CAA9C;AACA,IAAMU,gBAAgB,GAAGL,kBAAkB,CAACJ,KAAD,CAA3C;AAEA,IAAMU,SAAS,GAAG;AACjBC,EAAAA,aAAa,EAAEf,SAAS,CAACgB,KAAV,CAAgB;AAC9BC,IAAAA,aAAa,EAAEjB,SAAS,CAACkB,MADK;AAE9BC,IAAAA,UAAU,EAAEnB,SAAS,CAACkB,MAFQ;AAG9BE,IAAAA,qBAAqB,EAAEpB,SAAS,CAACkB,MAHH;AAI9BG,IAAAA,sBAAsB,EAAErB,SAAS,CAACkB,MAJJ;AAK9BI,IAAAA,aAAa,EAAEtB,SAAS,CAACkB,MALK;AAM9BK,IAAAA,SAAS,EAAEvB,SAAS,CAACkB;AANS,GAAhB,CADE;AASjBM,EAAAA,aAAa,EAAExB,SAAS,CAACyB,SAAV,CAAoB,CAClCzB,SAAS,CAAC0B,IADwB,EAElC1B,SAAS,CAAC2B,KAAV,CAAgB,CAAC,UAAD,EAAa,OAAb,CAAhB,CAFkC,CAApB,CATE;AAajBC,E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AEL,KAAK,CAACK,IAFyB;AAGrCH,IAAAA,WAAW,EAAEF,KAAK,CAACE;AAHkB,GAArC,CADF,GAME,IAdJ,CAtFD,CADD;AAyGA,CAhID;;AAkIAU,YAAY,CAAC+B,WAAb,GAA2BvE,cAA3B;AACAwC,YAAY,CAAC/B,SAAb,GAAyBA,SAAzB;AACA,eAAe+B,YAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ### find\nimport find from 'lodash.find';\n\n// ## Children\nimport Checkbox from '../../checkbox';\nimport Radio from '../../radio';\n\n// ## Constants\nimport {\n\tDATA_TABLE_ROW,\n\tDATA_TABLE_ROW_ACTIONS,\n\tDATA_TABLE_CELL,\n} from '../../../utilities/constants';\n\nimport InteractiveElement from '../interactive-element';\nimport CellContext from '../private/cell-context';\nimport TableContext from '../private/table-context';\nimport contextHelper from './context-helper';\n\nconst InteractiveCheckbox = InteractiveElement(Checkbox);\nconst InteractiveRadio = InteractiveElement(Radio);\n\nconst propTypes = {\n\tassistiveText: PropTypes.shape({\n\t\tactionsHeader: PropTypes.string,\n\t\tcolumnSort: PropTypes.string,\n\t\tcolumnSortedAscending: PropTypes.string,\n\t\tcolumnSortedDescending: PropTypes.string,\n\t\tselectAllRows: PropTypes.string,\n\t\tselectRow: PropTypes.string,\n\t}),\n\tcanSelectRows: PropTypes.oneOfType([\n\t\tPropTypes.bool,\n\t\tPropTypes.oneOf(['checkbox', 'radio']),\n\t]),\n\tclassName: PropTypes.string,\n\tcolumns: PropTypes.arrayOf(\n\t\tPropTypes.shape({\n\t\t\tCell: PropTypes.func,\n\t\t\tprops: PropTypes.object,\n\t\t})\n\t),\n\t/**\n\t * Use this if you are creating an advanced table (selectable, sortable, or resizable rows)\n\t */\n\tfixedLayout: PropTypes.bool,\n\tid: PropTypes.string.isRequired,\n\titem: PropTypes.object.isRequired,\n\tonToggle: PropTypes.func,\n\trowActions: PropTypes.element,\n\tselection: PropTypes.array,\n\ttableId: PropTypes.string,\n};\n\n/**\n * Used internally, provides row rendering to the DataTable.\n */\nconst DataTableRow = (props) => {\n\tconst tableContext = useContext(TableContext);\n\tconst selectRowCellContext = {\n\t\trowIndex: props.rowIndex,\n\t\tcolumnIndex: 0,\n\t};\n\tconst { tabIndex, hasFocus, handleFocus, handleKeyDown } = contextHelper(\n\t\ttableContext,\n\t\tselectRowCellContext,\n\t\tprops.fixedLayout\n\t);\n\n\tconst handleToggle = (e, { checked }) =>\n\t\tprops.onToggle(props.item, checked, e);\n\n\tconst ariaProps = {};\n\tconst isSelected = !!find(props.selection, props.item);\n\n\tif (props.canSelectRows) {\n\t\tariaProps['aria-selected'] = isSelected ? 'true' : 'false';\n\t}\n\n\t// i18n\n\treturn (\n\t\t<tr\n\t\t\t{...ariaProps}\n\t\t\tclassName={classNames(props.className, {\n\t\t\t\t'slds-hint-parent': props.rowActions,\n\t\t\t\t'slds-is-selected': props.canSelectRows && isSelected,\n\t\t\t\t'slds-has-focus': hasFocus,\n\t\t\t})}\n\t\t>\n\t\t\t{props.canSelectRows ? (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t<td\n\t\t\t\t\trole={props.fixedLayout ? 'gridcell' : null}\n\t\t\t\t\tclassName=\"slds-text-align_right\"\n\t\t\t\t\tdata-label={props.stacked ? 'Select Row' : undefined}\n\t\t\t\t\tstyle={{ width: '3.25rem' }}\n\t\t\t\t\tonFocus={handleFocus}\n\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\tref={(ref) => {\n\t\t\t\t\t\tif (ref && hasFocus) {\n\t\t\t\t\t\t\tref.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\ttabIndex={tabIndex}\n\t\t\t\t>\n\t\t\t\t\t<CellContext.Provider value={selectRowCellContext}>\n\t\t\t\t\t\t{props.canSelectRows === 'radio' ? (\n\t\t\t\t\t\t\t<InteractiveRadio\n\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\tlabel: `${props.assistiveText.selectRow} ${\n\t\t\t\t\t\t\t\t\t\tNumber(props.index) + 1\n\t\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\taria-labelledby={`${props.id}-SelectRow-label ${props.tableId}-SLDSDataTableHead-column-group-header-row-select`}\n\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\tclassName=\"slds-m-right_x-small\"\n\t\t\t\t\t\t\t\tid={`${props.id}-SelectRow`}\n\t\t\t\t\t\t\t\tlabelId={`${props.id}-SelectRow-label`}\n\t\t\t\t\t\t\t\tname={`${props.tableId}-SelectRow`}\n\t\t\t\t\t\t\t\tonChange={handleToggle}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<InteractiveCheckbox\n\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\tlabel: `${props.assistiveText.selectRow} ${\n\t\t\t\t\t\t\t\t\t\tNumber(props.index) + 1\n\t\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\taria-labelledby={`${props.id}-SelectRow-label ${props.tableId}-SLDSDataTableHead-column-group-header-row-select`}\n\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\tid={`${props.id}-SelectRow`}\n\t\t\t\t\t\t\t\tlabelId={`${props.id}-SelectRow-label`}\n\t\t\t\t\t\t\t\tname={`SelectRow${props.index + 1}`}\n\t\t\t\t\t\t\t\tonChange={handleToggle}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</CellContext.Provider>\n\t\t\t\t</td>\n\t\t\t) : null}\n\t\t\t{props.columns.map((column, index) => {\n\t\t\t\tconst { Cell } = column;\n\t\t\t\tconst cellId = `${props.id}-${DATA_TABLE_CELL}-${column.props.property}`;\n\n\t\t\t\treturn (\n\t\t\t\t\t<CellContext.Provider\n\t\t\t\t\t\tkey={cellId}\n\t\t\t\t\t\tvalue={{\n\t\t\t\t\t\t\tcolumnIndex: props.canSelectRows ? index + 1 : index,\n\t\t\t\t\t\t\trowIndex: props.rowIndex,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Cell\n\t\t\t\t\t\t\t{...column.props}\n\t\t\t\t\t\t\tclassName={column.props.truncate ? 'slds-truncate' : null}\n\t\t\t\t\t\t\tfixedLayout={props.fixedLayout}\n\t\t\t\t\t\t\trowHeader={column.props.primaryColumn}\n\t\t\t\t\t\t\tid={cellId}\n\t\t\t\t\t\t\titem={props.item}\n\t\t\t\t\t\t\twidth={column.props.width}\n\t\t\t\t\t\t\theaderId={props.item.headerId}\n\t\t\t\t\t\t\tcolumns={props.columns}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{props.item[column.props.property]}\n\t\t\t\t\t\t</Cell>\n\t\t\t\t\t</CellContext.Provider>\n\t\t\t\t);\n\t\t\t})}\n\t\t\t<CellContext.Provider\n\t\t\t\tvalue={{\n\t\t\t\t\tcolumnIndex: props.canSelectRows\n\t\t\t\t\t\t? props.columns.length + 1\n\t\t\t\t\t\t: props.columns.length,\n\t\t\t\t\trowIndex: props.rowIndex,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{props.rowActions\n\t\t\t\t\t? React.cloneElement(props.rowActions, {\n\t\t\t\t\t\t\tid: `${props.id}-${DATA_TABLE_ROW_ACTIONS}`,\n\t\t\t\t\t\t\titem: props.item,\n\t\t\t\t\t\t\tfixedLayout: props.fixedLayout,\n\t\t\t\t\t })\n\t\t\t\t\t: null}\n\t\t\t</CellContext.Provider>\n\t\t</tr>\n\t);\n};\n\nDataTableRow.displayName = DATA_TABLE_ROW;\nDataTableRow.propTypes = propTypes;\nexport default DataTableRow;\n"],"file":"row.js"}
1
+ {"version":3,"sources":["../../../../.tmp-es/components/data-table/private/row.jsx"],"names":["React","useCallback","useContext","useMemo","PropTypes","classNames","find","Checkbox","Radio","DATA_TABLE_ROW","DATA_TABLE_ROW_ACTIONS","DATA_TABLE_CELL","InteractiveElement","CellContext","TableContext","useContextHelper","InteractiveCheckbox","InteractiveRadio","propTypes","assistiveText","shape","actionsHeader","string","columnSort","columnSortedAscending","columnSortedDescending","selectAllRows","selectRow","canSelectRows","oneOfType","bool","oneOf","className","columns","arrayOf","Cell","func","props","object","fixedLayout","id","isRequired","item","onToggle","rowActions","element","selection","array","tableId","DataTableRow","tableContext","selectRowCellContext","rowIndex","columnIndex","tabIndex","hasFocus","handleFocus","handleKeyDown","handleToggle","e","checked","isSelected","ariaProps","result","stacked","undefined","width","ref","focus","label","Number","index","map","column","cellId","property","truncate","primaryColumn","headerId","length","cloneElement","displayName"],"mappings":";;AAAA;;AACA;AAEA;AACA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,UAA7B,EAAyCC,OAAzC,QAAwD,OAAxD;AACA,OAAOC,SAAP,MAAsB,YAAtB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;;AACA,OAAOC,IAAP,MAAiB,aAAjB,C,CAEA;;AACA,OAAOC,QAAP,MAAqB,gBAArB;AACA,OAAOC,KAAP,MAAkB,aAAlB,C,CAEA;;AACA,SACCC,cADD,EAECC,sBAFD,EAGCC,eAHD,QAIO,8BAJP;AAMA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,YAAP,MAAyB,0BAAzB;AACA,OAAOC,gBAAP,MAA6B,kBAA7B;AAEA,IAAMC,mBAAmB,GAAGJ,kBAAkB,CAACL,QAAD,CAA9C;AACA,IAAMU,gBAAgB,GAAGL,kBAAkB,CAACJ,KAAD,CAA3C;AAEA,IAAMU,SAAS,GAAG;AACjBC,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EAZP,EAaCH,KAAK,CAACkC,KAbP,EAcClC,KAAK,CAACO,UAdP,EAeCP,KAAK,CAACe,QAfP,EAgBCf,KAAK,CAAC2B,OAhBP,EAiBC3B,KAAK,CAACW,OAjBP,EAkBCG,oBAlBD,CAnGO,CART,CADD;AAmIA,CAnKD;;AAqKAF,YAAY,CAACgC,WAAb,GAA2BxE,cAA3B;AACAwC,YAAY,CAAC/B,SAAb,GAAyBA,SAAzB;AACA,eAAe+B,YAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React, { useCallback, useContext, useMemo } from 'react';\nimport PropTypes from 'prop-types';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ### find\nimport find from 'lodash.find';\n\n// ## Children\nimport Checkbox from '../../checkbox';\nimport Radio from '../../radio';\n\n// ## Constants\nimport {\n\tDATA_TABLE_ROW,\n\tDATA_TABLE_ROW_ACTIONS,\n\tDATA_TABLE_CELL,\n} from '../../../utilities/constants';\n\nimport InteractiveElement from '../interactive-element';\nimport CellContext from '../private/cell-context';\nimport TableContext from '../private/table-context';\nimport useContextHelper from './context-helper';\n\nconst InteractiveCheckbox = InteractiveElement(Checkbox);\nconst InteractiveRadio = InteractiveElement(Radio);\n\nconst propTypes = {\n\tassistiveText: PropTypes.shape({\n\t\tactionsHeader: PropTypes.string,\n\t\tcolumnSort: PropTypes.string,\n\t\tcolumnSortedAscending: PropTypes.string,\n\t\tcolumnSortedDescending: PropTypes.string,\n\t\tselectAllRows: PropTypes.string,\n\t\tselectRow: PropTypes.string,\n\t}),\n\tcanSelectRows: PropTypes.oneOfType([\n\t\tPropTypes.bool,\n\t\tPropTypes.oneOf(['checkbox', 'radio']),\n\t]),\n\tclassName: PropTypes.string,\n\tcolumns: PropTypes.arrayOf(\n\t\tPropTypes.shape({\n\t\t\tCell: PropTypes.func,\n\t\t\tprops: PropTypes.object,\n\t\t})\n\t),\n\t/**\n\t * Use this if you are creating an advanced table (selectable, sortable, or resizable rows)\n\t */\n\tfixedLayout: PropTypes.bool,\n\tid: PropTypes.string.isRequired,\n\titem: PropTypes.object.isRequired,\n\tonToggle: PropTypes.func,\n\trowActions: PropTypes.element,\n\tselection: PropTypes.array,\n\ttableId: PropTypes.string,\n};\n\n/**\n * Used internally, provides row rendering to the DataTable.\n */\nconst DataTableRow = (props) => {\n\tconst tableContext = useContext(TableContext);\n\tconst selectRowCellContext = useMemo(\n\t\t() => ({\n\t\t\trowIndex: props.rowIndex,\n\t\t\tcolumnIndex: 0,\n\t\t}),\n\t\t[props.rowIndex]\n\t);\n\tconst { tabIndex, hasFocus, handleFocus, handleKeyDown } = useContextHelper(\n\t\ttableContext,\n\t\tselectRowCellContext,\n\t\tprops.fixedLayout\n\t);\n\n\tconst { item, onToggle } = props;\n\tconst handleToggle = useCallback(\n\t\t(e, { checked }) => onToggle(item, checked, e),\n\t\t[item, onToggle]\n\t);\n\n\tconst isSelected = !!find(props.selection, item);\n\tconst ariaProps = useMemo(() => {\n\t\tconst result = {};\n\n\t\tif (props.canSelectRows) {\n\t\t\tresult['aria-selected'] = isSelected ? 'true' : 'false';\n\t\t}\n\t\treturn result;\n\t}, [isSelected, props.canSelectRows]);\n\n\t// i18n\n\treturn (\n\t\t<tr\n\t\t\t{...ariaProps}\n\t\t\tclassName={classNames(props.className, {\n\t\t\t\t'slds-hint-parent': props.rowActions,\n\t\t\t\t'slds-is-selected': props.canSelectRows && isSelected,\n\t\t\t\t'slds-has-focus': hasFocus,\n\t\t\t})}\n\t\t>\n\t\t\t{useMemo(\n\t\t\t\t() => (\n\t\t\t\t\t<React.Fragment>\n\t\t\t\t\t\t{props.canSelectRows ? (\n\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\trole={props.fixedLayout ? 'gridcell' : null}\n\t\t\t\t\t\t\t\tclassName=\"slds-text-align_right\"\n\t\t\t\t\t\t\t\tdata-label={props.stacked ? 'Select Row' : undefined}\n\t\t\t\t\t\t\t\tstyle={{ width: '3.25rem' }}\n\t\t\t\t\t\t\t\tonFocus={handleFocus}\n\t\t\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\t\t\tref={(ref) => {\n\t\t\t\t\t\t\t\t\tif (ref && hasFocus) {\n\t\t\t\t\t\t\t\t\t\tref.focus();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\ttabIndex={tabIndex}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<CellContext.Provider value={selectRowCellContext}>\n\t\t\t\t\t\t\t\t\t{props.canSelectRows === 'radio' ? (\n\t\t\t\t\t\t\t\t\t\t<InteractiveRadio\n\t\t\t\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: `${props.assistiveText.selectRow} ${\n\t\t\t\t\t\t\t\t\t\t\t\t\tNumber(props.index) + 1\n\t\t\t\t\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\taria-labelledby={`${props.id}-SelectRow-label ${props.tableId}-SLDSDataTableHead-column-group-header-row-select`}\n\t\t\t\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"slds-m-right_x-small\"\n\t\t\t\t\t\t\t\t\t\t\tid={`${props.id}-SelectRow`}\n\t\t\t\t\t\t\t\t\t\t\tlabelId={`${props.id}-SelectRow-label`}\n\t\t\t\t\t\t\t\t\t\t\tname={`${props.tableId}-SelectRow`}\n\t\t\t\t\t\t\t\t\t\t\tonChange={handleToggle}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<InteractiveCheckbox\n\t\t\t\t\t\t\t\t\t\t\tassistiveText={{\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: `${props.assistiveText.selectRow} ${\n\t\t\t\t\t\t\t\t\t\t\t\t\tNumber(props.index) + 1\n\t\t\t\t\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\taria-labelledby={`${props.id}-SelectRow-label ${props.tableId}-SLDSDataTableHead-column-group-header-row-select`}\n\t\t\t\t\t\t\t\t\t\t\tchecked={isSelected}\n\t\t\t\t\t\t\t\t\t\t\tid={`${props.id}-SelectRow`}\n\t\t\t\t\t\t\t\t\t\t\tlabelId={`${props.id}-SelectRow-label`}\n\t\t\t\t\t\t\t\t\t\t\tname={`SelectRow${props.index + 1}`}\n\t\t\t\t\t\t\t\t\t\t\tonChange={handleToggle}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</CellContext.Provider>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{props.columns.map((column, index) => {\n\t\t\t\t\t\t\tconst { Cell } = column;\n\t\t\t\t\t\t\tconst cellId = `${props.id}-${DATA_TABLE_CELL}-${column.props.property}`;\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<CellContext.Provider\n\t\t\t\t\t\t\t\t\tkey={cellId}\n\t\t\t\t\t\t\t\t\tvalue={{\n\t\t\t\t\t\t\t\t\t\tcolumnIndex: props.canSelectRows ? index + 1 : index,\n\t\t\t\t\t\t\t\t\t\trowIndex: props.rowIndex,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Cell\n\t\t\t\t\t\t\t\t\t\t{...column.props}\n\t\t\t\t\t\t\t\t\t\tclassName={column.props.truncate ? 'slds-truncate' : null}\n\t\t\t\t\t\t\t\t\t\tfixedLayout={props.fixedLayout}\n\t\t\t\t\t\t\t\t\t\trowHeader={column.props.primaryColumn}\n\t\t\t\t\t\t\t\t\t\tid={cellId}\n\t\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\t\twidth={column.props.width}\n\t\t\t\t\t\t\t\t\t\theaderId={item.headerId}\n\t\t\t\t\t\t\t\t\t\tcolumns={props.columns}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{item[column.props.property]}\n\t\t\t\t\t\t\t\t\t</Cell>\n\t\t\t\t\t\t\t\t</CellContext.Provider>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t\t<CellContext.Provider\n\t\t\t\t\t\t\tvalue={{\n\t\t\t\t\t\t\t\tcolumnIndex: props.canSelectRows\n\t\t\t\t\t\t\t\t\t? props.columns.length + 1\n\t\t\t\t\t\t\t\t\t: props.columns.length,\n\t\t\t\t\t\t\t\trowIndex: props.rowIndex,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{props.rowActions\n\t\t\t\t\t\t\t\t? React.cloneElement(props.rowActions, {\n\t\t\t\t\t\t\t\t\t\tid: `${props.id}-${DATA_TABLE_ROW_ACTIONS}`,\n\t\t\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\t\t\tfixedLayout: props.fixedLayout,\n\t\t\t\t\t\t\t\t })\n\t\t\t\t\t\t\t\t: null}\n\t\t\t\t\t\t</CellContext.Provider>\n\t\t\t\t\t</React.Fragment>\n\t\t\t\t),\n\t\t\t\t[\n\t\t\t\t\thandleFocus,\n\t\t\t\t\thandleKeyDown,\n\t\t\t\t\thandleToggle,\n\t\t\t\t\thasFocus,\n\t\t\t\t\tisSelected,\n\t\t\t\t\titem,\n\t\t\t\t\ttabIndex,\n\t\t\t\t\tprops.assistiveText.selectRow,\n\t\t\t\t\tprops.canSelectRows,\n\t\t\t\t\tprops.columns,\n\t\t\t\t\tprops.fixedLayout,\n\t\t\t\t\tprops.id,\n\t\t\t\t\tprops.index,\n\t\t\t\t\tprops.rowActions,\n\t\t\t\t\tprops.rowIndex,\n\t\t\t\t\tprops.stacked,\n\t\t\t\t\tprops.tableId,\n\t\t\t\t\tselectRowCellContext,\n\t\t\t\t]\n\t\t\t)}\n\t\t</tr>\n\t);\n};\n\nDataTableRow.displayName = DATA_TABLE_ROW;\nDataTableRow.propTypes = propTypes;\nexport default DataTableRow;\n"],"file":"row.js"}
@@ -22,7 +22,7 @@ import EventUtil from '../../utilities/event';
22
22
  import InteractiveElement from './interactive-element';
23
23
  import CellContext from './private/cell-context';
24
24
  import TableContext from './private/table-context';
25
- import contextHelper from './private/context-helper'; // ## Constants
25
+ import useContextHelper from './private/context-helper'; // ## Constants
26
26
 
27
27
  import { DATA_TABLE_ROW_ACTIONS } from '../../utilities/constants';
28
28
  var InteractiveDropdown = InteractiveElement(Dropdown);
@@ -83,11 +83,11 @@ var DataTableRowActions = function DataTableRowActions(props) {
83
83
  var tableContext = useContext(TableContext);
84
84
  var cellContext = useContext(CellContext);
85
85
 
86
- var _contextHelper = contextHelper(tableContext, cellContext, props.fixedLayout),
87
- tabIndex = _contextHelper.tabIndex,
88
- hasFocus = _contextHelper.hasFocus,
89
- handleFocus = _contextHelper.handleFocus,
90
- handleKeyDown = _contextHelper.handleKeyDown;
86
+ var _useContextHelper = useContextHelper(tableContext, cellContext, props.fixedLayout),
87
+ tabIndex = _useContextHelper.tabIndex,
88
+ hasFocus = _useContextHelper.hasFocus,
89
+ handleFocus = _useContextHelper.handleFocus,
90
+ handleKeyDown = _useContextHelper.handleKeyDown;
91
91
 
92
92
  var handleClick = function handleClick(e) {
93
93
  EventUtil.trap(e);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../.tmp-es/components/data-table/row-actions.jsx"],"names":["React","useContext","PropTypes","classNames","isFunction","Dropdown","EventUtil","InteractiveElement","CellContext","TableContext","contextHelper","DATA_TABLE_ROW_ACTIONS","InteractiveDropdown","propTypes","assistiveText","object","className","string","id","item","noHint","bool","onAction","func","options","array","dropdown","node","defaultProps","icon","DataTableRowActions","props","tableContext","cellContext","fixedLayout","tabIndex","hasFocus","handleFocus","handleKeyDown","handleClick","e","trap","handleSelect","selection","onSelect","defaultDropdownProps","align","buttonClassName","buttonVariant","iconCategory","iconName","iconSize","iconVariant","hint","dropdownProps","width","ref","focus","displayName"],"mappings":";;;;;;AAAA;;AACA;;AAEA;AAEA;AACA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB,C,CAEA;;AACA,OAAOC,QAAP,MAAqB,kBAArB,C,CAEA;;AACA,OAAOC,SAAP,MAAsB,uBAAtB;AAEA,OAAOC,kBAAP,MAA+B,uBAA/B;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AACA,OAAOC,aAAP,MAA0B,0BAA1B,C,CAEA;;AACA,SAASC,sBAAT,QAAuC,2BAAvC;AAEA,IAAMC,mBAAmB,GAAGL,kBAAkB,CAACF,QAAD,CAA9C;AAEA,IAAMQ,SAAS,GAAG;AACjB;AACD;AACA;AACCC,EAAAA,aAAa,EAAEZ,SAAS,CAACa,MAJR;;AAKjB;AACD;AACA;AACCC,EAAAA,SAAS,EAAEd,SAAS,CAACe,MARJ;;AASjB;AACD;AACA;AACCC,EAAAA,EAAE,EAAEhB,SAAS,CAACe,MAZG;;AAajB;AACD;AACA;AACCE,EAAAA,IAAI,EAAEjB,SAAS,CAACa,MAhBC;;AAiBjB;AACD;AACA;AACCK,EAAAA,MAAM,EAAElB,SAAS,CAACmB,IApBD;;AAqBjB;AACD;AACA;AACCC,EAAAA,QAAQ,EAAEpB,SAAS,CAACqB,IAxBH;;AAyBjB;AACD;AACA;AACCC,EAAAA,OAAO,EAAEtB,SAAS,CAACuB,KA5BF;;AA6BjB;AACD;AACA;AACA;AACCC,EAAAA,QAAQ,E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,CAACjB,SAApB,GAAgCA,SAAhC;AACAiB,mBAAmB,CAACF,YAApB,GAAmCA,YAAnC;AACAE,mBAAmB,CAAC4B,WAApB,GAAkC/C,sBAAlC;AACA,eAAemB,mBAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\n\n// ### React\nimport React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\n// ### isFunction\nimport isFunction from 'lodash.isfunction';\n\n// ## Children\nimport Dropdown from '../menu-dropdown';\n\n// ### Event Helpers\nimport EventUtil from '../../utilities/event';\n\nimport InteractiveElement from './interactive-element';\nimport CellContext from './private/cell-context';\nimport TableContext from './private/table-context';\nimport contextHelper from './private/context-helper';\n\n// ## Constants\nimport { DATA_TABLE_ROW_ACTIONS } from '../../utilities/constants';\n\nconst InteractiveDropdown = InteractiveElement(Dropdown);\n\nconst propTypes = {\n\t/**\n\t * Description of the menu for screenreaders.\n\t */\n\tassistiveText: PropTypes.object,\n\t/**\n\t * Class names to be added to the actions menu.\n\t */\n\tclassName: PropTypes.string,\n\t/**\n\t * HTML ID to be added to the actions menu.\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * `DataTable` row item\n\t */\n\titem: PropTypes.object,\n\t/**\n\t * Disable hint styling which changes the color of the dropdown svg on hover over.\n\t */\n\tnoHint: PropTypes.bool,\n\t/**\n\t * Triggered when an item is selected.\n\t */\n\tonAction: PropTypes.func,\n\t/**\n\t * `Dropdown` options. See `Dropdown`.\n\t */\n\toptions: PropTypes.array,\n\t/**\n\t * A [Dropdown](http://react.lightningdesignsystem.com/components/dropdown-menus/) component. The props from this drop will be merged and override any default props.\n\t * **Note:** onAction will not be overridden, both `DropDown`'s onSelect(dropDownActionOption) and onAction(rowItem, dropdownActionOption) will be called with appropriate parameters\n\t */\n\tdropdown: PropTypes.node,\n};\n\nconst defaultProps = {\n\tassistiveText: { icon: 'Actions' },\n\tnoHint: false,\n\toptions: [],\n};\n\n/**\n * RowActions provide a mechanism for defining a menu to display alongside each row in the DataTable.\n */\nconst DataTableRowActions = (props) => {\n\tconst tableContext = useContext(TableContext);\n\tconst cellContext = useContext(CellContext);\n\tconst { tabIndex, hasFocus, handleFocus, handleKeyDown } = contextHelper(\n\t\ttableContext,\n\t\tcellContext,\n\t\tprops.fixedLayout\n\t);\n\n\tconst handleClick = (e) => {\n\t\tEventUtil.trap(e);\n\t};\n\n\tconst handleSelect = (selection) => {\n\t\tif (isFunction(props.onAction)) {\n\t\t\tprops.onAction(props.item, selection);\n\t\t}\n\t\tif (props.dropdown && isFunction(props.dropdown.props.onSelect)) {\n\t\t\tprops.dropdown.props.onSelect(selection);\n\t\t}\n\t};\n\n\t// i18n\n\tconst defaultDropdownProps = {\n\t\talign: 'right',\n\t\tbuttonClassName: 'slds-button_icon-x-small',\n\t\tbuttonVariant: 'icon',\n\t\ticonCategory: 'utility',\n\t\ticonName: 'down',\n\t\ticonSize: 'small',\n\t\ticonVariant: 'border-filled',\n\t\tassistiveText: props.assistiveText,\n\t\tclassName: props.className,\n\t\toptions: props.options,\n\t\thint: !props.noHint,\n\t\tid: props.id,\n\t};\n\n\tlet dropdownProps = props.dropdown ? props.dropdown.props : {};\n\tdropdownProps = {\n\t\t...defaultDropdownProps,\n\t\t...dropdownProps,\n\t\tonSelect: handleSelect,\n\t};\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\t<td\n\t\t\tclassName={classNames({ 'slds-has-focus': hasFocus })}\n\t\t\tdata-label=\"Actions\"\n\t\t\tonClick={handleClick}\n\t\t\tstyle={{ width: '3.25rem' }}\n\t\t\tonFocus={handleFocus}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\tref={(ref) => {\n\t\t\t\tif (ref && hasFocus) {\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t\trole={props.fixedLayout ? 'gridcell' : null}\n\t\t\ttabIndex={tabIndex}\n\t\t>\n\t\t\t{/* eslint-enable jsx-a11y/no-static-element-interactions */}\n\t\t\t<InteractiveDropdown {...dropdownProps} />\n\t\t</td>\n\t);\n};\n\nDataTableRowActions.propTypes = propTypes;\nDataTableRowActions.defaultProps = defaultProps;\nDataTableRowActions.displayName = DATA_TABLE_ROW_ACTIONS;\nexport default DataTableRowActions;\n"],"file":"row-actions.js"}
1
+ {"version":3,"sources":["../../../.tmp-es/components/data-table/row-actions.jsx"],"names":["React","useContext","PropTypes","classNames","isFunction","Dropdown","EventUtil","InteractiveElement","CellContext","TableContext","useContextHelper","DATA_TABLE_ROW_ACTIONS","InteractiveDropdown","propTypes","assistiveText","object","className","string","id","item","noHint","bool","onAction","func","options","array","dropdown","node","defaultProps","icon","DataTableRowActions","props","tableContext","cellContext","fixedLayout","tabIndex","hasFocus","handleFocus","handleKeyDown","handleClick","e","trap","handleSelect","selection","onSelect","defaultDropdownProps","align","buttonClassName","buttonVariant","iconCategory","iconName","iconSize","iconVariant","hint","dropdownProps","width","ref","focus","displayName"],"mappings":";;;;;;AAAA;;AACA;;AAEA;AAEA;AACA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB,C,CAEA;;AACA,OAAOC,QAAP,MAAqB,kBAArB,C,CAEA;;AACA,OAAOC,SAAP,MAAsB,uBAAtB;AAEA,OAAOC,kBAAP,MAA+B,uBAA/B;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AACA,OAAOC,gBAAP,MAA6B,0BAA7B,C,CAEA;;AACA,SAASC,sBAAT,QAAuC,2BAAvC;AAEA,IAAMC,mBAAmB,GAAGL,kBAAkB,CAACF,QAAD,CAA9C;AAEA,IAAMQ,SAA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AAD,CADtB;AAEC,oBAAW,SAFZ;AAGC,MAAA,OAAO,EAAEG,WAHV;AAIC,MAAA,KAAK,EAAE;AAAEgB,QAAAA,KAAK,EAAE;AAAT,OAJR;AAKC,MAAA,OAAO,EAAElB,WALV;AAMC,MAAA,SAAS,EAAEC,aANZ;AAOC,MAAA,GAAG,EAAE,aAACkB,IAAD,EAAS;AACb,YAAIA,IAAG,IAAIpB,QAAX,EAAqB;AACpBoB,UAAAA,IAAG,CAACC,KAAJ;AACA;AACD,OAXF;AAYC,MAAA,IAAI,EAAE1B,KAAK,CAACG,WAAN,GAAoB,UAApB,GAAiC,IAZxC;AAaC,MAAA,QAAQ,EAAEC;AAbX,oBAgBC,oBAAC,mBAAD,EAAyBmB,aAAzB,CAhBD;AAFD;AAqBA,CAlED;;AAoEAxB,mBAAmB,CAACjB,SAApB,GAAgCA,SAAhC;AACAiB,mBAAmB,CAACF,YAApB,GAAmCA,YAAnC;AACAE,mBAAmB,CAAC4B,WAApB,GAAkC/C,sBAAlC;AACA,eAAemB,mBAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\n\n// ### React\nimport React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\n// ### isFunction\nimport isFunction from 'lodash.isfunction';\n\n// ## Children\nimport Dropdown from '../menu-dropdown';\n\n// ### Event Helpers\nimport EventUtil from '../../utilities/event';\n\nimport InteractiveElement from './interactive-element';\nimport CellContext from './private/cell-context';\nimport TableContext from './private/table-context';\nimport useContextHelper from './private/context-helper';\n\n// ## Constants\nimport { DATA_TABLE_ROW_ACTIONS } from '../../utilities/constants';\n\nconst InteractiveDropdown = InteractiveElement(Dropdown);\n\nconst propTypes = {\n\t/**\n\t * Description of the menu for screenreaders.\n\t */\n\tassistiveText: PropTypes.object,\n\t/**\n\t * Class names to be added to the actions menu.\n\t */\n\tclassName: PropTypes.string,\n\t/**\n\t * HTML ID to be added to the actions menu.\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * `DataTable` row item\n\t */\n\titem: PropTypes.object,\n\t/**\n\t * Disable hint styling which changes the color of the dropdown svg on hover over.\n\t */\n\tnoHint: PropTypes.bool,\n\t/**\n\t * Triggered when an item is selected.\n\t */\n\tonAction: PropTypes.func,\n\t/**\n\t * `Dropdown` options. See `Dropdown`.\n\t */\n\toptions: PropTypes.array,\n\t/**\n\t * A [Dropdown](http://react.lightningdesignsystem.com/components/dropdown-menus/) component. The props from this drop will be merged and override any default props.\n\t * **Note:** onAction will not be overridden, both `DropDown`'s onSelect(dropDownActionOption) and onAction(rowItem, dropdownActionOption) will be called with appropriate parameters\n\t */\n\tdropdown: PropTypes.node,\n};\n\nconst defaultProps = {\n\tassistiveText: { icon: 'Actions' },\n\tnoHint: false,\n\toptions: [],\n};\n\n/**\n * RowActions provide a mechanism for defining a menu to display alongside each row in the DataTable.\n */\nconst DataTableRowActions = (props) => {\n\tconst tableContext = useContext(TableContext);\n\tconst cellContext = useContext(CellContext);\n\tconst { tabIndex, hasFocus, handleFocus, handleKeyDown } = useContextHelper(\n\t\ttableContext,\n\t\tcellContext,\n\t\tprops.fixedLayout\n\t);\n\n\tconst handleClick = (e) => {\n\t\tEventUtil.trap(e);\n\t};\n\n\tconst handleSelect = (selection) => {\n\t\tif (isFunction(props.onAction)) {\n\t\t\tprops.onAction(props.item, selection);\n\t\t}\n\t\tif (props.dropdown && isFunction(props.dropdown.props.onSelect)) {\n\t\t\tprops.dropdown.props.onSelect(selection);\n\t\t}\n\t};\n\n\t// i18n\n\tconst defaultDropdownProps = {\n\t\talign: 'right',\n\t\tbuttonClassName: 'slds-button_icon-x-small',\n\t\tbuttonVariant: 'icon',\n\t\ticonCategory: 'utility',\n\t\ticonName: 'down',\n\t\ticonSize: 'small',\n\t\ticonVariant: 'border-filled',\n\t\tassistiveText: props.assistiveText,\n\t\tclassName: props.className,\n\t\toptions: props.options,\n\t\thint: !props.noHint,\n\t\tid: props.id,\n\t};\n\n\tlet dropdownProps = props.dropdown ? props.dropdown.props : {};\n\tdropdownProps = {\n\t\t...defaultDropdownProps,\n\t\t...dropdownProps,\n\t\tonSelect: handleSelect,\n\t};\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\t<td\n\t\t\tclassName={classNames({ 'slds-has-focus': hasFocus })}\n\t\t\tdata-label=\"Actions\"\n\t\t\tonClick={handleClick}\n\t\t\tstyle={{ width: '3.25rem' }}\n\t\t\tonFocus={handleFocus}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\tref={(ref) => {\n\t\t\t\tif (ref && hasFocus) {\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t}}\n\t\t\trole={props.fixedLayout ? 'gridcell' : null}\n\t\t\ttabIndex={tabIndex}\n\t\t>\n\t\t\t{/* eslint-enable jsx-a11y/no-static-element-interactions */}\n\t\t\t<InteractiveDropdown {...dropdownProps} />\n\t\t</td>\n\t);\n};\n\nDataTableRowActions.propTypes = propTypes;\nDataTableRowActions.defaultProps = defaultProps;\nDataTableRowActions.displayName = DATA_TABLE_ROW_ACTIONS;\nexport default DataTableRowActions;\n"],"file":"row-actions.js"}
@@ -31,7 +31,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
31
31
  /* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
32
32
  import React from 'react';
33
33
  import PropTypes from 'prop-types';
34
- import memoize from 'lodash.memoize';
34
+ import memoize from 'memoize-one';
35
35
  var documentDefined = typeof document !== 'undefined';
36
36
  var canvas;
37
37
  var docFragment;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../.tmp-es/components/utilities/truncate/index.jsx"],"names":["React","PropTypes","memoize","documentDefined","document","canvas","docFragment","canvasContext","measureWidth","createElement","getContext","createDocumentFragment","appendChild","text","font","measureText","width","TextTruncate","update","props","ref","nextProps","scope","propsToRender","containerClassName","line","prefix","suffix","textTruncateChild","truncateText","wrapper","scopeWidth","getBoundingClientRect","style","window","getComputedStyle","join","setState","renderText","child","outputText","currentPos","maxTextLength","length","truncatedText","splitPos","startPos","displayLine","lastIsEng","lastSpaceIndex","ext","extraWidthDueToPrefixStyle","substr","indexOf","lastWidth","lastIndexOf","getRenderText","addEventListener","onResize","removeEventListener","overflow","state","Component","string","number","node","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,IAAMC,eAAe,GAAG,OAAOC,QAAP,KAAoB,WAA5C;AAEA,IAAIC,MAAJ;AACA,IAAIC,WAAJ;AACA,IAAIC,aAAJ;;AACA,IAAIC,YAAY,GAAG;AAAA,SAAM,CAAN;AAAA,CAAnB;;AAEA,IAAIL,eAAJ,EAAqB;AACpBE,EAAAA,MAAM,GAAGD,QAAQ,CAACK,aAAT,CAAuB,QAAvB,CAAT;;AACA,MAAIJ,MAAM,CAACK,UAAX,EAAuB;AACtBJ,IAAAA,WAAW,GAAGF,QAAQ,CAACO,sBAAT,EAAd;AACAL,IAAAA,WAAW,CAACM,WAAZ,CAAwBP,MAAxB;AACAE,IAAAA,aAAa,GAAGF,MAAM,CAACK,UAAP,CAAkB,IAAlB,CAAhB;AACAF,IAAAA,YAAY,GAAGN,OAAO,CAAC,UAACW,IAAD,EAAOC,IAAP,EAAgB;AACtCP,MAAAA,aAAa,CAACO,IAAd,GAAqBA,IAArB;AACA,aAAOP,aAAa,CAACQ,WAAd,CAA0BF,IAA1B,EAAgCG,KAAvC;AACA,KAHqB,CAAtB;AAIA;AACD;;IAEKC,Y;;;;;;;;;;;;;;;;4DAoBG,E;;+DAgBG,YAAM;AAChB,YAAKC,MAAL,CAAY,MAAKC,KAAjB;AACA,K;;oEAEe,UAACC,GAAD,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AkB,EAAEvB,SAAS,CAAC8D,MADZ;AAElBtC,EAAAA,IAAI,EAAExB,SAAS,CAAC+D,MAFE;AAGlBtC,EAAAA,MAAM,EAAEzB,SAAS,CAAC8D,MAHA;AAIlBpC,EAAAA,MAAM,EAAE1B,SAAS,CAAC8D,MAJA;AAKlBlD,EAAAA,IAAI,EAAEZ,SAAS,CAAC8D,MALE;AAMlBnC,EAAAA,iBAAiB,EAAE3B,SAAS,CAACgE,IANX;AAOlBpC,EAAAA,YAAY,EAAE5B,SAAS,CAAC8D,MAPN;AAQlBjC,EAAAA,OAAO,EAAE7B,SAAS,CAACiE;AARD,C;;gBAHdjD,Y,kBAciB;AACrBQ,EAAAA,IAAI,EAAE,CADe;AAErBZ,EAAAA,IAAI,EAAE,EAFe;AAGrBgB,EAAAA,YAAY,EAAE;AAHO,C;;AAsMvB,eAAeZ,YAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\nimport memoize from 'lodash.memoize';\n\nconst documentDefined = typeof document !== 'undefined';\n\nlet canvas;\nlet docFragment;\nlet canvasContext;\nlet measureWidth = () => 0;\n\nif (documentDefined) {\n\tcanvas = document.createElement('canvas');\n\tif (canvas.getContext) {\n\t\tdocFragment = document.createDocumentFragment();\n\t\tdocFragment.appendChild(canvas);\n\t\tcanvasContext = canvas.getContext('2d');\n\t\tmeasureWidth = memoize((text, font) => {\n\t\t\tcanvasContext.font = font;\n\t\t\treturn canvasContext.measureText(text).width;\n\t\t});\n\t}\n}\n\nclass TextTruncate extends React.Component {\n\tstatic displayName = 'TextTruncate';\n\n\tstatic propTypes = {\n\t\tcontainerClassName: PropTypes.string,\n\t\tline: PropTypes.number,\n\t\tprefix: PropTypes.string,\n\t\tsuffix: PropTypes.string,\n\t\ttext: PropTypes.string,\n\t\ttextTruncateChild: PropTypes.node,\n\t\ttruncateText: PropTypes.string,\n\t\twrapper: PropTypes.func,\n\t};\n\n\tstatic defaultProps = {\n\t\tline: 1,\n\t\ttext: '',\n\t\ttruncateText: '…',\n\t};\n\n\tstate = {};\n\n\tcomponentDidMount() {\n\t\twindow.addEventListener('resize', this.onResize, false);\n\t}\n\n\tcomponentDidUpdate(nextProps) {\n\t\tif (nextProps.text !== this.props.text) {\n\t\t\tthis.update(nextProps);\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\twindow.removeEventListener('resize', this.onResize, false);\n\t}\n\n\tonResize = () => {\n\t\tthis.update(this.props);\n\t};\n\n\tgetRenderText = (ref, nextProps) => {\n\t\tif (!ref) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.scope = ref;\n\n\t\t// nextProps will be undefined for resize events, but will change if search or other props are changed\n\t\tlet propsToRender;\n\t\tif (nextProps) {\n\t\t\tpropsToRender = nextProps;\n\t\t} else {\n\t\t\tpropsToRender = this.props;\n\t\t}\n\n\t\tconst {\n\t\t\tcontainerClassName, // eslint-disable-line no-unused-vars\n\t\t\tline,\n\t\t\tprefix,\n\t\t\tsuffix,\n\t\t\ttext,\n\t\t\ttextTruncateChild,\n\t\t\ttruncateText,\n\t\t\twrapper,\n\t\t\t...props\n\t\t} = propsToRender;\n\n\t\tconst scopeWidth = this.scope.getBoundingClientRect().width;\n\t\tconst style = window.getComputedStyle(this.scope);\n\t\tconst font = [\n\t\t\tstyle['font-weight'],\n\t\t\tstyle['font-style'],\n\t\t\tstyle['font-size'],\n\t\t\tstyle['font-family'],\n\t\t].join(' ');\n\n\t\t// return if display:none\n\t\tif (scopeWidth === 0) {\n\t\t\tthis.setState({ renderText: null });\n\t\t\treturn;\n\t\t}\n\n\t\tlet child;\n\t\tlet outputText = text;\n\n\t\t// return if all of text can be displayed\n\t\tif (scopeWidth < measureWidth(text, font)) {\n\t\t\tlet currentPos = 1;\n\t\t\tconst maxTextLength = text.length;\n\t\t\tlet truncatedText = '';\n\t\t\tlet splitPos = 0;\n\t\t\tlet startPos = 0;\n\t\t\tlet displayLine = line;\n\t\t\tlet width = 0;\n\t\t\tlet lastIsEng = false;\n\t\t\tlet lastSpaceIndex = -1;\n\n\t\t\t// eslint-disable-next-line fp/no-loops\n\t\t\twhile (displayLine !== 0) {\n\t\t\t\tlet ext = '';\n\t\t\t\tlet extraWidthDueToPrefixStyle = 0;\n\n\t\t\t\tif (prefix && displayLine === line - 1) {\n\t\t\t\t\text += ` ${prefix}`;\n\t\t\t\t\t// MAGIC NUMBER: (width at letter-spacing of 0.25rems - width at normal) / number of letters\n\t\t\t\t\textraWidthDueToPrefixStyle = prefix.length * 0.66;\n\t\t\t\t}\n\n\t\t\t\tif (!displayLine) {\n\t\t\t\t\text += truncateText;\n\n\t\t\t\t\tif (suffix) {\n\t\t\t\t\t\text += ` ${suffix}`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line fp/no-loops\n\t\t\t\twhile (currentPos <= maxTextLength) {\n\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos);\n\t\t\t\t\twidth =\n\t\t\t\t\t\tmeasureWidth(truncatedText + ext, font) +\n\t\t\t\t\t\textraWidthDueToPrefixStyle;\n\n\t\t\t\t\tif (width < scopeWidth) {\n\t\t\t\t\t\tsplitPos = text.indexOf(' ', currentPos + 1);\n\t\t\t\t\t\tif (splitPos === -1) {\n\t\t\t\t\t\t\tcurrentPos += 1;\n\t\t\t\t\t\t\tlastIsEng = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlastIsEng = true;\n\t\t\t\t\t\t\tcurrentPos = splitPos;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet lastWidth = 0;\n\t\t\t\t\t\t// eslint-disable-next-line fp/no-loops\n\t\t\t\t\t\tdo {\n\t\t\t\t\t\t\tcurrentPos -= 1;\n\t\t\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos);\n\t\t\t\t\t\t\tif (truncatedText[truncatedText.length - 1] === ' ') {\n\t\t\t\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos - 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (lastIsEng) {\n\t\t\t\t\t\t\t\tlastSpaceIndex = truncatedText.lastIndexOf(' ');\n\t\t\t\t\t\t\t\tif (lastSpaceIndex > -1) {\n\t\t\t\t\t\t\t\t\tcurrentPos = lastSpaceIndex;\n\t\t\t\t\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\t\tmeasureWidth(truncatedText + ext, font) +\n\t\t\t\t\t\t\t\textraWidthDueToPrefixStyle;\n\t\t\t\t\t\t\tif (width === lastWidth) {\n\t\t\t\t\t\t\t\tcurrentPos = 0;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tlastWidth = width;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} while (width >= scopeWidth);\n\t\t\t\t\t\tstartPos += currentPos;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (currentPos >= maxTextLength) {\n\t\t\t\t\tstartPos = maxTextLength;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdisplayLine -= 1; // iterate\n\t\t\t}\n\n\t\t\tif (startPos !== maxTextLength) {\n\t\t\t\toutputText = `${text.substr(0, startPos)}${truncateText} `;\n\t\t\t\tchild = textTruncateChild;\n\t\t\t}\n\t\t}\n\n\t\tlet renderText;\n\t\tif (wrapper) {\n\t\t\trenderText = wrapper(outputText, child);\n\t\t} else {\n\t\t\trenderText = (\n\t\t\t\t<div {...props}>\n\t\t\t\t\t{outputText}\n\t\t\t\t\t{child}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tthis.setState({ renderText });\n\t};\n\n\tupdate = (nextProps) => {\n\t\tthis.getRenderText(this.scope, nextProps);\n\t};\n\n\trender() {\n\t\tconst { containerClassName } = this.props;\n\n\t\t// inline style override\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={this.getRenderText}\n\t\t\t\tclassName={containerClassName}\n\t\t\t\tstyle={{ overflow: 'hidden' }}\n\t\t\t>\n\t\t\t\t{this.state.renderText}\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default TextTruncate;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../.tmp-es/components/utilities/truncate/index.jsx"],"names":["React","PropTypes","memoize","documentDefined","document","canvas","docFragment","canvasContext","measureWidth","createElement","getContext","createDocumentFragment","appendChild","text","font","measureText","width","TextTruncate","update","props","ref","nextProps","scope","propsToRender","containerClassName","line","prefix","suffix","textTruncateChild","truncateText","wrapper","scopeWidth","getBoundingClientRect","style","window","getComputedStyle","join","setState","renderText","child","outputText","currentPos","maxTextLength","length","truncatedText","splitPos","startPos","displayLine","lastIsEng","lastSpaceIndex","ext","extraWidthDueToPrefixStyle","substr","indexOf","lastWidth","lastIndexOf","getRenderText","addEventListener","onResize","removeEventListener","overflow","state","Component","string","number","node","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,OAAP,MAAoB,aAApB;AAEA,IAAMC,eAAe,GAAG,OAAOC,QAAP,KAAoB,WAA5C;AAEA,IAAIC,MAAJ;AACA,IAAIC,WAAJ;AACA,IAAIC,aAAJ;;AACA,IAAIC,YAAY,GAAG;AAAA,SAAM,CAAN;AAAA,CAAnB;;AAEA,IAAIL,eAAJ,EAAqB;AACpBE,EAAAA,MAAM,GAAGD,QAAQ,CAACK,aAAT,CAAuB,QAAvB,CAAT;;AACA,MAAIJ,MAAM,CAACK,UAAX,EAAuB;AACtBJ,IAAAA,WAAW,GAAGF,QAAQ,CAACO,sBAAT,EAAd;AACAL,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AAM,CAACyB,mBAAP,CAA2B,QAA3B,EAAqC,KAAKD,QAA1C,EAAoD,KAApD;AACA;;;WAkKD,kBAAS;AACR,UAAQlC,kBAAR,GAA+B,KAAKL,KAApC,CAAQK,kBAAR,CADQ,CAGR;;AACA,0BACC;AACC,QAAA,GAAG,EAAE,KAAKgC,aADX;AAEC,QAAA,SAAS,EAAEhC,kBAFZ;AAGC,QAAA,KAAK,EAAE;AAAEoC,UAAAA,QAAQ,EAAE;AAAZ;AAHR,SAKE,KAAKC,KAAL,CAAWvB,UALb,CADD;AASA;;;;EAjNyBtC,KAAK,CAAC8D,S;;gBAA3B7C,Y,iBACgB,c;;gBADhBA,Y,eAGc;AAClBO,EAAAA,kBAAkB,EAAEvB,SAAS,CAAC8D,MADZ;AAElBtC,EAAAA,IAAI,EAAExB,SAAS,CAAC+D,MAFE;AAGlBtC,EAAAA,MAAM,EAAEzB,SAAS,CAAC8D,MAHA;AAIlBpC,EAAAA,MAAM,EAAE1B,SAAS,CAAC8D,MAJA;AAKlBlD,EAAAA,IAAI,EAAEZ,SAAS,CAAC8D,MALE;AAMlBnC,EAAAA,iBAAiB,EAAE3B,SAAS,CAACgE,IANX;AAOlBpC,EAAAA,YAAY,EAAE5B,SAAS,CAAC8D,MAPN;AAQlBjC,EAAAA,OAAO,EAAE7B,SAAS,CAACiE;AARD,C;;gBAHdjD,Y,kBAciB;AACrBQ,EAAAA,IAAI,EAAE,CADe;AAErBZ,EAAAA,IAAI,EAAE,EAFe;AAGrBgB,EAAAA,YAAY,EAAE;AAHO,C;;AAsMvB,eAAeZ,YAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\nimport memoize from 'memoize-one';\n\nconst documentDefined = typeof document !== 'undefined';\n\nlet canvas;\nlet docFragment;\nlet canvasContext;\nlet measureWidth = () => 0;\n\nif (documentDefined) {\n\tcanvas = document.createElement('canvas');\n\tif (canvas.getContext) {\n\t\tdocFragment = document.createDocumentFragment();\n\t\tdocFragment.appendChild(canvas);\n\t\tcanvasContext = canvas.getContext('2d');\n\t\tmeasureWidth = memoize((text, font) => {\n\t\t\tcanvasContext.font = font;\n\t\t\treturn canvasContext.measureText(text).width;\n\t\t});\n\t}\n}\n\nclass TextTruncate extends React.Component {\n\tstatic displayName = 'TextTruncate';\n\n\tstatic propTypes = {\n\t\tcontainerClassName: PropTypes.string,\n\t\tline: PropTypes.number,\n\t\tprefix: PropTypes.string,\n\t\tsuffix: PropTypes.string,\n\t\ttext: PropTypes.string,\n\t\ttextTruncateChild: PropTypes.node,\n\t\ttruncateText: PropTypes.string,\n\t\twrapper: PropTypes.func,\n\t};\n\n\tstatic defaultProps = {\n\t\tline: 1,\n\t\ttext: '',\n\t\ttruncateText: '…',\n\t};\n\n\tstate = {};\n\n\tcomponentDidMount() {\n\t\twindow.addEventListener('resize', this.onResize, false);\n\t}\n\n\tcomponentDidUpdate(nextProps) {\n\t\tif (nextProps.text !== this.props.text) {\n\t\t\tthis.update(nextProps);\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\twindow.removeEventListener('resize', this.onResize, false);\n\t}\n\n\tonResize = () => {\n\t\tthis.update(this.props);\n\t};\n\n\tgetRenderText = (ref, nextProps) => {\n\t\tif (!ref) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.scope = ref;\n\n\t\t// nextProps will be undefined for resize events, but will change if search or other props are changed\n\t\tlet propsToRender;\n\t\tif (nextProps) {\n\t\t\tpropsToRender = nextProps;\n\t\t} else {\n\t\t\tpropsToRender = this.props;\n\t\t}\n\n\t\tconst {\n\t\t\tcontainerClassName, // eslint-disable-line no-unused-vars\n\t\t\tline,\n\t\t\tprefix,\n\t\t\tsuffix,\n\t\t\ttext,\n\t\t\ttextTruncateChild,\n\t\t\ttruncateText,\n\t\t\twrapper,\n\t\t\t...props\n\t\t} = propsToRender;\n\n\t\tconst scopeWidth = this.scope.getBoundingClientRect().width;\n\t\tconst style = window.getComputedStyle(this.scope);\n\t\tconst font = [\n\t\t\tstyle['font-weight'],\n\t\t\tstyle['font-style'],\n\t\t\tstyle['font-size'],\n\t\t\tstyle['font-family'],\n\t\t].join(' ');\n\n\t\t// return if display:none\n\t\tif (scopeWidth === 0) {\n\t\t\tthis.setState({ renderText: null });\n\t\t\treturn;\n\t\t}\n\n\t\tlet child;\n\t\tlet outputText = text;\n\n\t\t// return if all of text can be displayed\n\t\tif (scopeWidth < measureWidth(text, font)) {\n\t\t\tlet currentPos = 1;\n\t\t\tconst maxTextLength = text.length;\n\t\t\tlet truncatedText = '';\n\t\t\tlet splitPos = 0;\n\t\t\tlet startPos = 0;\n\t\t\tlet displayLine = line;\n\t\t\tlet width = 0;\n\t\t\tlet lastIsEng = false;\n\t\t\tlet lastSpaceIndex = -1;\n\n\t\t\t// eslint-disable-next-line fp/no-loops\n\t\t\twhile (displayLine !== 0) {\n\t\t\t\tlet ext = '';\n\t\t\t\tlet extraWidthDueToPrefixStyle = 0;\n\n\t\t\t\tif (prefix && displayLine === line - 1) {\n\t\t\t\t\text += ` ${prefix}`;\n\t\t\t\t\t// MAGIC NUMBER: (width at letter-spacing of 0.25rems - width at normal) / number of letters\n\t\t\t\t\textraWidthDueToPrefixStyle = prefix.length * 0.66;\n\t\t\t\t}\n\n\t\t\t\tif (!displayLine) {\n\t\t\t\t\text += truncateText;\n\n\t\t\t\t\tif (suffix) {\n\t\t\t\t\t\text += ` ${suffix}`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line fp/no-loops\n\t\t\t\twhile (currentPos <= maxTextLength) {\n\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos);\n\t\t\t\t\twidth =\n\t\t\t\t\t\tmeasureWidth(truncatedText + ext, font) +\n\t\t\t\t\t\textraWidthDueToPrefixStyle;\n\n\t\t\t\t\tif (width < scopeWidth) {\n\t\t\t\t\t\tsplitPos = text.indexOf(' ', currentPos + 1);\n\t\t\t\t\t\tif (splitPos === -1) {\n\t\t\t\t\t\t\tcurrentPos += 1;\n\t\t\t\t\t\t\tlastIsEng = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlastIsEng = true;\n\t\t\t\t\t\t\tcurrentPos = splitPos;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet lastWidth = 0;\n\t\t\t\t\t\t// eslint-disable-next-line fp/no-loops\n\t\t\t\t\t\tdo {\n\t\t\t\t\t\t\tcurrentPos -= 1;\n\t\t\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos);\n\t\t\t\t\t\t\tif (truncatedText[truncatedText.length - 1] === ' ') {\n\t\t\t\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos - 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (lastIsEng) {\n\t\t\t\t\t\t\t\tlastSpaceIndex = truncatedText.lastIndexOf(' ');\n\t\t\t\t\t\t\t\tif (lastSpaceIndex > -1) {\n\t\t\t\t\t\t\t\t\tcurrentPos = lastSpaceIndex;\n\t\t\t\t\t\t\t\t\ttruncatedText = text.substr(startPos, currentPos);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\t\tmeasureWidth(truncatedText + ext, font) +\n\t\t\t\t\t\t\t\textraWidthDueToPrefixStyle;\n\t\t\t\t\t\t\tif (width === lastWidth) {\n\t\t\t\t\t\t\t\tcurrentPos = 0;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tlastWidth = width;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} while (width >= scopeWidth);\n\t\t\t\t\t\tstartPos += currentPos;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (currentPos >= maxTextLength) {\n\t\t\t\t\tstartPos = maxTextLength;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdisplayLine -= 1; // iterate\n\t\t\t}\n\n\t\t\tif (startPos !== maxTextLength) {\n\t\t\t\toutputText = `${text.substr(0, startPos)}${truncateText} `;\n\t\t\t\tchild = textTruncateChild;\n\t\t\t}\n\t\t}\n\n\t\tlet renderText;\n\t\tif (wrapper) {\n\t\t\trenderText = wrapper(outputText, child);\n\t\t} else {\n\t\t\trenderText = (\n\t\t\t\t<div {...props}>\n\t\t\t\t\t{outputText}\n\t\t\t\t\t{child}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tthis.setState({ renderText });\n\t};\n\n\tupdate = (nextProps) => {\n\t\tthis.getRenderText(this.scope, nextProps);\n\t};\n\n\trender() {\n\t\tconst { containerClassName } = this.props;\n\n\t\t// inline style override\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={this.getRenderText}\n\t\t\t\tclassName={containerClassName}\n\t\t\t\tstyle={{ overflow: 'hidden' }}\n\t\t\t>\n\t\t\t\t{this.state.renderText}\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default TextTruncate;\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/design-system-react",
3
- "version": "0.10.44",
3
+ "version": "0.10.45",
4
4
  "description": "Salesforce Lightning Design System for React",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "engines": {},
@@ -44,8 +44,8 @@
44
44
  "lodash.isdate": "^4.0.1",
45
45
  "lodash.isequal": "^4.5.0",
46
46
  "lodash.isfunction": "^3.0.9",
47
- "lodash.memoize": "^4.1.2",
48
47
  "lodash.reject": "^4.6.0",
48
+ "memoize-one": "^6.0.0",
49
49
  "popper.js": "^1.10.8",
50
50
  "prop-types": ">=15.7.2",
51
51
  "react-contenteditable": "^3.3.5",
@@ -59,8 +59,8 @@
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@salesforce-ux/design-system": "^2.14.3",
62
- "react": ">=16.3",
63
- "react-dom": ">=16.3"
62
+ "react": ">=16.8",
63
+ "react-dom": ">=16.8"
64
64
  },
65
65
  "components": [
66
66
  {