@salesforce/design-system-react 0.10.35 → 0.10.39

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 (172) hide show
  1. package/assets/styles/table.css +70 -0
  2. package/components/builder-header/utilities.d.ts +20 -0
  3. package/components/card/__docs__/__snapshots__/storybook-stories.storyshot +20 -5
  4. package/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot +178 -169
  5. package/components/combobox/__tests__/combobox.browser-test.jsx +4 -5
  6. package/components/combobox/combobox.jsx +20 -18
  7. package/components/component-docs.json +160 -0
  8. package/components/data-table/__docs__/__snapshots__/storybook-stories.storyshot +17997 -11862
  9. package/components/data-table/__docs__/storybook-stories.jsx +5 -1
  10. package/components/data-table/__examples__/advanced-single-select-fixed-header.jsx +1 -0
  11. package/components/data-table/__examples__/basic-fluid-headless.jsx +105 -0
  12. package/components/data-table/__examples__/interactive-elements.jsx +14 -0
  13. package/components/data-table/__examples__/joined-with-page-header.jsx +11 -18
  14. package/components/data-table/__examples__/resizable-columns.jsx +237 -0
  15. package/components/data-table/__tests__/data-table.browser-test.jsx +133 -0
  16. package/components/data-table/column.resizer.d.ts +1 -0
  17. package/components/data-table/component.json +11 -7
  18. package/components/data-table/index.jsx +431 -80
  19. package/components/data-table/private/head.jsx +8 -3
  20. package/components/data-table/private/header-cell.jsx +9 -1
  21. package/components/data-table.d.ts +8 -0
  22. package/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +17 -17
  23. package/components/expression/__docs__/__snapshots__/storybook-stories.storyshot +90 -90
  24. package/components/global-header/__docs__/__snapshots__/storybook-stories.storyshot +9 -9
  25. package/components/index.d.ts +2 -0
  26. package/components/menu-dropdown/__docs__/__snapshots__/storybook-stories.storyshot +552 -26
  27. package/components/menu-dropdown/__docs__/storybook-stories.jsx +4 -16
  28. package/components/menu-dropdown/__examples__/checkmark.jsx +48 -31
  29. package/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +12 -7
  30. package/components/modal/__tests__/modal.browser-test.jsx +4 -10
  31. package/components/portal-settings/__docs__/__snapshots__/storybook-stories.storyshot +6 -6
  32. package/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot +161 -14
  33. package/components/progress-indicator/private/step-vertical.jsx +28 -2
  34. package/components/setup-assistant/__docs__/__snapshots__/storybook-stories.storyshot +180 -13
  35. package/components/site-stories.js +16 -4
  36. package/components/utilities/menu-list/index.jsx +3 -0
  37. package/components/utilities/menu-list/item.jsx +5 -2
  38. package/components/vertical-navigation/__docs__/__snapshots__/storybook-stories.storyshot +326 -0
  39. package/components/vertical-navigation/__docs__/storybook-stories.jsx +4 -0
  40. package/components/vertical-navigation/__examples__/icons.jsx +70 -0
  41. package/components/vertical-navigation/__examples__/notifications.jsx +66 -0
  42. package/components/vertical-navigation/component.json +8 -0
  43. package/components/vertical-navigation/private/item.d.ts +2 -0
  44. package/components/vertical-navigation/private/item.jsx +23 -1
  45. package/docs/PULL_REQUEST_TEMPLATE.md +1 -1
  46. package/lib/assets/styles/table.css +70 -0
  47. package/lib/components/builder-header/utilities.d.ts +20 -0
  48. package/lib/components/card/__docs__/__snapshots__/storybook-stories.storyshot +20 -5
  49. package/lib/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot +178 -169
  50. package/lib/components/combobox/__tests__/combobox.browser-test.jsx +4 -5
  51. package/lib/components/combobox/combobox.js +27 -23
  52. package/lib/components/component-docs.json +160 -0
  53. package/lib/components/data-table/__docs__/__snapshots__/storybook-stories.storyshot +17997 -11862
  54. package/lib/components/data-table/__docs__/storybook-stories.jsx +5 -1
  55. package/lib/components/data-table/__examples__/advanced-single-select-fixed-header.jsx +1 -0
  56. package/lib/components/data-table/__examples__/basic-fluid-headless.jsx +105 -0
  57. package/lib/components/data-table/__examples__/interactive-elements.jsx +14 -0
  58. package/lib/components/data-table/__examples__/joined-with-page-header.jsx +11 -18
  59. package/lib/components/data-table/__examples__/resizable-columns.jsx +237 -0
  60. package/lib/components/data-table/__tests__/data-table.browser-test.jsx +133 -0
  61. package/lib/components/data-table/column.resizer.d.ts +1 -0
  62. package/lib/components/data-table/component.json +11 -7
  63. package/lib/components/data-table/index.js +444 -107
  64. package/lib/components/data-table/private/head.js +8 -3
  65. package/lib/components/data-table/private/header-cell.js +3 -1
  66. package/lib/components/data-table.d.ts +8 -0
  67. package/lib/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +17 -17
  68. package/lib/components/expression/__docs__/__snapshots__/storybook-stories.storyshot +90 -90
  69. package/lib/components/global-header/__docs__/__snapshots__/storybook-stories.storyshot +9 -9
  70. package/lib/components/index.d.ts +2 -0
  71. package/lib/components/menu-dropdown/__docs__/__snapshots__/storybook-stories.storyshot +552 -26
  72. package/lib/components/menu-dropdown/__docs__/storybook-stories.jsx +4 -16
  73. package/lib/components/menu-dropdown/__examples__/checkmark.jsx +48 -31
  74. package/lib/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +12 -7
  75. package/lib/components/modal/__tests__/modal.browser-test.jsx +4 -10
  76. package/lib/components/portal-settings/__docs__/__snapshots__/storybook-stories.storyshot +6 -6
  77. package/lib/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot +161 -14
  78. package/lib/components/progress-indicator/private/step-vertical.js +18 -4
  79. package/lib/components/setup-assistant/__docs__/__snapshots__/storybook-stories.storyshot +180 -13
  80. package/lib/components/site-stories.js +12 -3
  81. package/lib/components/utilities/menu-list/index.js +5 -2
  82. package/lib/components/utilities/menu-list/item.js +3 -2
  83. package/lib/components/vertical-navigation/__docs__/__snapshots__/storybook-stories.storyshot +326 -0
  84. package/lib/components/vertical-navigation/__docs__/storybook-stories.jsx +4 -0
  85. package/lib/components/vertical-navigation/__examples__/icons.jsx +70 -0
  86. package/lib/components/vertical-navigation/__examples__/notifications.jsx +66 -0
  87. package/lib/components/vertical-navigation/component.json +8 -0
  88. package/lib/components/vertical-navigation/private/item.d.ts +2 -0
  89. package/lib/components/vertical-navigation/private/item.js +5 -1
  90. package/lib/docs/PULL_REQUEST_TEMPLATE.md +1 -1
  91. package/lib/package.json +19 -6
  92. package/module/assets/styles/table.css +70 -0
  93. package/module/components/builder-header/utilities.d.ts +20 -0
  94. package/module/components/card/__docs__/__snapshots__/storybook-stories.storyshot +20 -5
  95. package/module/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot +178 -169
  96. package/module/components/combobox/__tests__/combobox.browser-test.js +5 -6
  97. package/module/components/combobox/__tests__/combobox.browser-test.js.map +1 -1
  98. package/module/components/combobox/combobox.js +27 -23
  99. package/module/components/combobox/combobox.js.map +1 -1
  100. package/module/components/component-docs.json +160 -0
  101. package/module/components/data-table/__docs__/__snapshots__/storybook-stories.storyshot +17997 -11862
  102. package/module/components/data-table/__docs__/storybook-stories.js +6 -0
  103. package/module/components/data-table/__docs__/storybook-stories.js.map +1 -1
  104. package/module/components/data-table/__examples__/advanced-single-select-fixed-header.js +1 -0
  105. package/module/components/data-table/__examples__/advanced-single-select-fixed-header.js.map +1 -1
  106. package/module/components/data-table/__examples__/basic-fluid-headless.js +152 -0
  107. package/module/components/data-table/__examples__/basic-fluid-headless.js.map +1 -0
  108. package/module/components/data-table/__examples__/interactive-elements.js +9 -0
  109. package/module/components/data-table/__examples__/interactive-elements.js.map +1 -1
  110. package/module/components/data-table/__examples__/joined-with-page-header.js +9 -20
  111. package/module/components/data-table/__examples__/joined-with-page-header.js.map +1 -1
  112. package/module/components/data-table/__examples__/resizable-columns.js +266 -0
  113. package/module/components/data-table/__examples__/resizable-columns.js.map +1 -0
  114. package/module/components/data-table/__tests__/data-table.browser-test.js +99 -0
  115. package/module/components/data-table/__tests__/data-table.browser-test.js.map +1 -1
  116. package/module/components/data-table/column.resizer.d.ts +1 -0
  117. package/module/components/data-table/component.json +11 -7
  118. package/module/components/data-table/index.js +443 -107
  119. package/module/components/data-table/index.js.map +1 -1
  120. package/module/components/data-table/private/head.js +8 -3
  121. package/module/components/data-table/private/head.js.map +1 -1
  122. package/module/components/data-table/private/header-cell.js +3 -1
  123. package/module/components/data-table/private/header-cell.js.map +1 -1
  124. package/module/components/data-table.d.ts +8 -0
  125. package/module/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +17 -17
  126. package/module/components/expression/__docs__/__snapshots__/storybook-stories.storyshot +90 -90
  127. package/module/components/global-header/__docs__/__snapshots__/storybook-stories.storyshot +9 -9
  128. package/module/components/index.d.ts +2 -0
  129. package/module/components/menu-dropdown/__docs__/__snapshots__/storybook-stories.storyshot +552 -26
  130. package/module/components/menu-dropdown/__docs__/storybook-stories.js +9 -15
  131. package/module/components/menu-dropdown/__docs__/storybook-stories.js.map +1 -1
  132. package/module/components/menu-dropdown/__examples__/checkmark.js +53 -33
  133. package/module/components/menu-dropdown/__examples__/checkmark.js.map +1 -1
  134. package/module/components/menu-dropdown/__tests__/dropdown.browser-test.js +7 -4
  135. package/module/components/menu-dropdown/__tests__/dropdown.browser-test.js.map +1 -1
  136. package/module/components/modal/__tests__/modal.browser-test.js +4 -10
  137. package/module/components/modal/__tests__/modal.browser-test.js.map +1 -1
  138. package/module/components/portal-settings/__docs__/__snapshots__/storybook-stories.storyshot +6 -6
  139. package/module/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot +161 -14
  140. package/module/components/progress-indicator/private/step-vertical.js +18 -4
  141. package/module/components/progress-indicator/private/step-vertical.js.map +1 -1
  142. package/module/components/setup-assistant/__docs__/__snapshots__/storybook-stories.storyshot +180 -13
  143. package/module/components/site-stories.js +12 -3
  144. package/module/components/site-stories.js.map +1 -1
  145. package/module/components/utilities/menu-list/index.js +5 -2
  146. package/module/components/utilities/menu-list/index.js.map +1 -1
  147. package/module/components/utilities/menu-list/item.js +3 -2
  148. package/module/components/utilities/menu-list/item.js.map +1 -1
  149. package/module/components/vertical-navigation/__docs__/__snapshots__/storybook-stories.storyshot +326 -0
  150. package/module/components/vertical-navigation/__docs__/storybook-stories.js +10 -0
  151. package/module/components/vertical-navigation/__docs__/storybook-stories.js.map +1 -1
  152. package/module/components/vertical-navigation/__examples__/icons.js +149 -0
  153. package/module/components/vertical-navigation/__examples__/icons.js.map +1 -0
  154. package/module/components/vertical-navigation/__examples__/notifications.js +143 -0
  155. package/module/components/vertical-navigation/__examples__/notifications.js.map +1 -0
  156. package/module/components/vertical-navigation/component.json +8 -0
  157. package/module/components/vertical-navigation/private/item.d.ts +2 -0
  158. package/module/components/vertical-navigation/private/item.js +5 -1
  159. package/module/components/vertical-navigation/private/item.js.map +1 -1
  160. package/package.json +19 -6
  161. package/design-system-react-components.js +0 -62702
  162. package/design-system-react-components.js.map +0 -1
  163. package/design-system-react-components.min.js +0 -3
  164. package/design-system-react-components.min.js.LICENSE.txt +0 -83
  165. package/design-system-react-components.min.js.map +0 -1
  166. package/design-system-react.js +0 -73487
  167. package/design-system-react.js.map +0 -1
  168. package/design-system-react.min.js +0 -3
  169. package/design-system-react.min.js.LICENSE.txt +0 -83
  170. package/design-system-react.min.js.map +0 -1
  171. package/lib/design-system-react-components.min.js.LICENSE.txt +0 -83
  172. package/lib/design-system-react.min.js.LICENSE.txt +0 -83
@@ -14,12 +14,14 @@ import BasicFluid from '../__examples__/basic-fluid';
14
14
  import BasicFluidColumnBordered from '../__examples__/basic-fluid-column-bordered';
15
15
  import BasicFluidNoRowHover from '../__examples__/basic-fluid-no-row-hover';
16
16
  import BasicFluidStriped from '../__examples__/basic-fluid-striped';
17
+ import BasicFluidHeadless from '../__examples__/basic-fluid-headless';
17
18
  import FixedHeader from '../__examples__/fixed-header';
18
19
  import InteractiveElements from '../__examples__/interactive-elements';
19
20
  import FixedHeaderHorizontalScroller from '../__examples__/fixed-header-horizontal-scrolling';
20
21
  import JoinedWithPageHeader from '../__examples__/joined-with-page-header';
21
22
  import CustomClasses from '../__examples__/custom-classes';
22
23
  import InfiniteScrolling from '../__examples__/infinite-scrolling';
24
+ import ResizableColumns from '../__examples__/resizable-columns';
23
25
 
24
26
  storiesOf(DATA_TABLE, module)
25
27
  .addDecorator((getStory) => (
@@ -33,6 +35,7 @@ storiesOf(DATA_TABLE, module)
33
35
  .add('Basic Fluid Layout - Column Bordered', () => (
34
36
  <BasicFluidColumnBordered />
35
37
  ))
38
+ .add('Basic Fluid Layout - Headless', () => <BasicFluidHeadless />)
36
39
  .add('Basic Fixed Layout', () => <BasicFixedLayout />)
37
40
  .add('Advanced (Fixed Layout)', () => <Advanced log={action} />)
38
41
  .add('Advanced Single Select (Fixed Layout)', () => (
@@ -49,4 +52,5 @@ storiesOf(DATA_TABLE, module)
49
52
  ))
50
53
  .add('Joined with Page Header', () => <JoinedWithPageHeader />)
51
54
  .add('Custom Classes', () => <CustomClasses />)
52
- .add('Infinite Scrolling', () => <InfiniteScrolling />);
55
+ .add('Infinite Scrolling', () => <InfiniteScrolling />)
56
+ .add('Resizable Columns', () => <ResizableColumns />);
@@ -117,6 +117,7 @@ class Example extends React.Component {
117
117
  selectRow: 'Select this row',
118
118
  }}
119
119
  fixedLayout
120
+ fixedHeader
120
121
  keyboardNavigation
121
122
  items={this.state.items}
122
123
  id="DataTableExample-SingleRequiredSelect"
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+
3
+ import DataTable from '~/components/data-table'; // `~` is replaced with design-system-react at runtime
4
+ import DataTableColumn from '~/components/data-table/column';
5
+ import DataTableCell from '~/components/data-table/cell';
6
+ import IconSettings from '~/components/icon-settings';
7
+
8
+ const CustomDataTableCell = ({ children, ...props }) => (
9
+ <DataTableCell {...props}>
10
+ <a
11
+ href="#"
12
+ onClick={(event) => {
13
+ event.preventDefault();
14
+ }}
15
+ >
16
+ {children}
17
+ </a>
18
+ </DataTableCell>
19
+ );
20
+ CustomDataTableCell.displayName = DataTableCell.displayName;
21
+
22
+ const columns = [
23
+ <DataTableColumn
24
+ key="opportunity"
25
+ label="Opportunity Name"
26
+ property="opportunityName"
27
+ >
28
+ <CustomDataTableCell />
29
+ </DataTableColumn>,
30
+
31
+ <DataTableColumn
32
+ key="account-name"
33
+ label="Account Name"
34
+ property="accountName"
35
+ />,
36
+
37
+ <DataTableColumn key="close-date" label="Close Date" property="closeDate" />,
38
+
39
+ <DataTableColumn key="stage" label="Stage" property="stage" />,
40
+
41
+ <DataTableColumn key="confidence" label="Confidence" property="confidence" />,
42
+
43
+ <DataTableColumn key="amount" label="Amount" property="amount" />,
44
+
45
+ <DataTableColumn key="contact" label="Contact" property="contact">
46
+ <CustomDataTableCell />
47
+ </DataTableColumn>,
48
+ ];
49
+
50
+ class Example extends React.Component {
51
+ static displayName = 'DataTableExample';
52
+
53
+ state = {
54
+ items: [
55
+ {
56
+ id: '8IKZHZZV80',
57
+ opportunityName: 'Cloudhub',
58
+ accountName: 'Cloudhub',
59
+ closeDate: '4/14/2015',
60
+ stage: 'Prospecting',
61
+ confidence: '20%',
62
+ amount: '$25k',
63
+ contact: 'jrogers@cloudhub.com',
64
+ },
65
+ {
66
+ id: '5GJOOOPWU7',
67
+ opportunityName: 'Cloudhub + Anypoint Connectors',
68
+ accountName: 'Cloudhub',
69
+ closeDate: '4/14/2015',
70
+ stage: 'Prospecting',
71
+ confidence: '20%',
72
+ amount: '$25k',
73
+ contact: 'jrogers@cloudhub.com',
74
+ },
75
+ {
76
+ id: '8IKZHZZV81',
77
+ opportunityName: 'Cloudhub',
78
+ accountName: 'Cloudhub',
79
+ closeDate: '4/14/2015',
80
+ stage: 'Prospecting',
81
+ confidence: '20%',
82
+ amount: '$25k',
83
+ contact: 'jrogers@cloudhub.com',
84
+ },
85
+ ],
86
+ };
87
+
88
+ render() {
89
+ return (
90
+ <IconSettings iconPath="/assets/icons">
91
+ <div style={{ overflow: 'auto' }}>
92
+ <DataTable
93
+ items={this.state.items}
94
+ id="DataTableExample-headless"
95
+ isHeadless
96
+ >
97
+ {columns}
98
+ </DataTable>
99
+ </div>
100
+ </IconSettings>
101
+ );
102
+ }
103
+ }
104
+
105
+ export default Example; // export is replaced with `ReactDOM.render(<Example />, mountNode);` at runtime
@@ -141,6 +141,20 @@ class Example extends React.Component {
141
141
  >
142
142
  {columns}
143
143
  </DataTable>
144
+
145
+ <h3 className="slds-text-heading_medium slds-m-vertical_medium">
146
+ Resizable columns
147
+ </h3>
148
+ <DataTable
149
+ items={this.state.items}
150
+ id="DataTableExample-column-resizable"
151
+ fixedLayout
152
+ fixedHeader
153
+ resizable
154
+ keyboardNavigation
155
+ >
156
+ {columns}
157
+ </DataTable>
144
158
  </div>
145
159
  </IconSettings>
146
160
  );
@@ -12,17 +12,17 @@ import Icon from '~/components/icon';
12
12
  import IconSettings from '~/components/icon-settings';
13
13
  import PageHeader from '~/components/page-header';
14
14
  import PageHeaderControl from '~/components/page-header/control';
15
+ import DataTableInteractiveLink from '~/components/data-table/interactive-link';
15
16
 
16
17
  const CustomDataTableCell = ({ children, ...props }) => (
17
- <DataTableCell title={children} {...props}>
18
- <a
19
- href="#"
18
+ <DataTableCell {...props}>
19
+ <DataTableInteractiveLink
20
20
  onClick={(event) => {
21
21
  event.preventDefault();
22
22
  }}
23
23
  >
24
24
  {children}
25
- </a>
25
+ </DataTableInteractiveLink>
26
26
  </DataTableCell>
27
27
  );
28
28
  CustomDataTableCell.displayName = DataTableCell.displayName;
@@ -107,7 +107,7 @@ const controls = () => (
107
107
  assistiveText={{ icon: 'Edit List' }}
108
108
  iconCategory="utility"
109
109
  iconName="edit"
110
- iconVariant="border"
110
+ iconVariant="border-filled"
111
111
  variant="icon"
112
112
  />
113
113
  </PageHeaderControl>
@@ -116,7 +116,7 @@ const controls = () => (
116
116
  assistiveText={{ icon: 'Refresh' }}
117
117
  iconCategory="utility"
118
118
  iconName="refresh"
119
- iconVariant="border"
119
+ iconVariant="border-filled"
120
120
  variant="icon"
121
121
  />
122
122
  </PageHeaderControl>
@@ -126,14 +126,14 @@ const controls = () => (
126
126
  assistiveText={{ icon: 'Charts' }}
127
127
  iconCategory="utility"
128
128
  iconName="chart"
129
- iconVariant="border"
129
+ iconVariant="border-filled"
130
130
  variant="icon"
131
131
  />
132
132
  <Button
133
133
  assistiveText={{ icon: 'Filters' }}
134
134
  iconCategory="utility"
135
135
  iconName="filterList"
136
- iconVariant="border"
136
+ iconVariant="border-filled"
137
137
  variant="icon"
138
138
  />
139
139
  </ButtonGroup>
@@ -371,18 +371,11 @@ class Example extends React.Component {
371
371
  variant="object-home"
372
372
  />
373
373
  <DataTable
374
- assistiveText={{
375
- actionsHeader: 'actions',
376
- columnSort: 'sort this column',
377
- columnSortedAscending: 'asc',
378
- columnSortedDescending: 'desc',
379
- selectAllRows: 'Select all rows',
380
- selectRow: 'Select this row',
381
- }}
382
- fixedHeader
383
374
  fixedLayout
375
+ resizable
376
+ keyboardNavigation
384
377
  items={this.state.items}
385
- id="DataTableExample-FixedHeaders"
378
+ id="DataTableExample-JoinedWithPageHeader"
386
379
  joined
387
380
  onRowChange={this.handleChanged}
388
381
  onSort={this.handleSort}
@@ -0,0 +1,237 @@
1
+ import React from 'react';
2
+
3
+ import DataTable from '~/components/data-table'; // `~` is replaced with design-system-react at runtime
4
+ import DataTableColumn from '~/components/data-table/column';
5
+ import DataTableCell from '~/components/data-table/cell';
6
+ import DataTableInteractiveLink from '~/components/data-table/interactive-link';
7
+ import IconSettings from '~/components/icon-settings';
8
+
9
+ const CustomDataTableCell = ({ children, ...props }) => (
10
+ <DataTableCell {...props}>
11
+ <DataTableInteractiveLink
12
+ onClick={(event) => {
13
+ event.preventDefault();
14
+ }}
15
+ >
16
+ {children}
17
+ </DataTableInteractiveLink>
18
+ </DataTableCell>
19
+ );
20
+ CustomDataTableCell.displayName = DataTableCell.displayName;
21
+
22
+ const columns = [
23
+ <DataTableColumn
24
+ key="opportunity"
25
+ label="Opportunity Name"
26
+ property="opportunityName"
27
+ >
28
+ <CustomDataTableCell />
29
+ </DataTableColumn>,
30
+
31
+ <DataTableColumn
32
+ key="account-name"
33
+ label="Account Name"
34
+ property="accountName"
35
+ />,
36
+
37
+ <DataTableColumn key="close-date" label="Close Date" property="closeDate" />,
38
+
39
+ <DataTableColumn key="stage" label="Stage" property="stage" />,
40
+
41
+ <DataTableColumn key="confidence" label="Confidence" property="confidence" />,
42
+
43
+ <DataTableColumn key="amount" label="Amount" property="amount" />,
44
+
45
+ <DataTableColumn key="contact" label="Contact" property="contact">
46
+ <CustomDataTableCell />
47
+ </DataTableColumn>,
48
+ ];
49
+
50
+ class Example extends React.Component {
51
+ static displayName = 'DataTableExample';
52
+
53
+ state = {
54
+ sortColumn: 'opportunityName',
55
+ sortColumnDirection: {
56
+ opportunityName: 'asc',
57
+ },
58
+ items: [
59
+ {
60
+ id: '896a6a60',
61
+ opportunityName: 'Acme - 1,200 Widgets',
62
+ accountName: 'Acme',
63
+ closeDate: '4/10/15',
64
+ stage: 'Value Proposition',
65
+ confidence: '70%',
66
+ amount: '$25,000,000',
67
+ contact: 'jrogers@acme.com',
68
+ },
69
+ {
70
+ id: '44da9dcd',
71
+ opportunityName: 'Acme - 200 Widgets',
72
+ accountName: 'Acme',
73
+ closeDate: '1/31/15',
74
+ stage: 'Prospecting',
75
+ confidence: '30%',
76
+ amount: '$5,000,000',
77
+ contact: 'bob@acme.com',
78
+ },
79
+ {
80
+ id: 'f988a721',
81
+ opportunityName: 'salesforce.com - 1,000 Widgets',
82
+ accountName: 'salesforce.com',
83
+ closeDate: '1/31/15 3:45PM',
84
+ stage: 'Id. Decision Makers',
85
+ confidence: '60%',
86
+ amount: '$25,000',
87
+ contact: 'nathan@salesforce.com',
88
+ },
89
+ {
90
+ id: 'd7679cdd',
91
+ opportunityName: 'Acme - 800 Widgets',
92
+ accountName: 'Acme',
93
+ closeDate: '6/11/18',
94
+ stage: 'Value Proposition',
95
+ confidence: '85%',
96
+ amount: '$970,000',
97
+ contact: 'jrogers@acme.com',
98
+ },
99
+ {
100
+ id: '0085f7a0',
101
+ opportunityName: 'Acme - 744 Widgets',
102
+ accountName: 'Acme',
103
+ closeDate: '4/15/17',
104
+ stage: 'Prospecting',
105
+ confidence: '56%',
106
+ amount: '$3,110,000',
107
+ contact: 'bob@acme.com',
108
+ },
109
+ {
110
+ id: 'b7acc778',
111
+ opportunityName: 'salesforce.com - 847 Widgets',
112
+ accountName: 'salesforce.com',
113
+ closeDate: '5/23/18 1:02PM',
114
+ stage: 'Id. Decision Makers',
115
+ confidence: '62%',
116
+ amount: '$18,000',
117
+ contact: 'nathan@salesforce.com',
118
+ },
119
+ {
120
+ id: '17991de5',
121
+ opportunityName: 'Acme - 1,621 Widgets',
122
+ accountName: 'Acme',
123
+ closeDate: '5/16/17',
124
+ stage: 'Value Proposition',
125
+ confidence: '70%',
126
+ amount: '$23,600,000',
127
+ contact: 'jrogers@acme.com',
128
+ },
129
+ {
130
+ id: '09b2cee9',
131
+ opportunityName: 'Acme - 430 Widgets',
132
+ accountName: 'Acme',
133
+ closeDate: '6/12/18',
134
+ stage: 'Prospecting',
135
+ confidence: '42%',
136
+ amount: '$4,222,222',
137
+ contact: 'bob@acme.com',
138
+ },
139
+ {
140
+ id: 'd0035700',
141
+ opportunityName: 'salesforce.com - 677 Widgets',
142
+ accountName: 'salesforce.com',
143
+ closeDate: '7/21/17 10:11AM',
144
+ stage: 'Id. Decision Makers',
145
+ confidence: '42%',
146
+ amount: '$24,200',
147
+ contact: 'nathan@salesforce.com',
148
+ },
149
+ {
150
+ id: '4a526f0c',
151
+ opportunityName: 'Acme - 1,444 Widgets',
152
+ accountName: 'Acme',
153
+ closeDate: '3/18/18',
154
+ stage: 'Value Proposition',
155
+ confidence: '66%',
156
+ amount: '$22,000,000',
157
+ contact: 'jrogers@acme.com',
158
+ },
159
+ {
160
+ id: '9a5dbdb2',
161
+ opportunityName: 'Acme - 320 Widgets',
162
+ accountName: 'Acme',
163
+ closeDate: '1/31/18',
164
+ stage: 'Prospecting',
165
+ confidence: '36%',
166
+ amount: '$4,322,000',
167
+ contact: 'bob@acme.com',
168
+ },
169
+ {
170
+ id: '356dbb52',
171
+ opportunityName: 'salesforce.com - 4,000 Widgets',
172
+ accountName: 'salesforce.com',
173
+ closeDate: '2/21/17 8:33PM',
174
+ stage: 'Id. Decision Makers',
175
+ confidence: '72%',
176
+ amount: '$15,000',
177
+ contact: 'nathan@salesforce.com',
178
+ },
179
+ ],
180
+ };
181
+
182
+ render() {
183
+ return (
184
+ <React.Fragment>
185
+ <React.Fragment>
186
+ <h3 className="slds-text-heading_medium slds-m-vertical_medium">
187
+ With keyboard navigation
188
+ </h3>
189
+ <IconSettings iconPath="/assets/icons">
190
+ <div style={{ height: '200px' }}>
191
+ <DataTable
192
+ items={this.state.items}
193
+ id="DataTableExample-4-resizable-cols"
194
+ resizable
195
+ keyboardNavigation
196
+ fixedLayout
197
+ resizableOptions={{
198
+ onResize: (columnsResized) => {
199
+ console.log(JSON.stringify(columnsResized));
200
+ },
201
+ }}
202
+ >
203
+ {columns}
204
+ </DataTable>
205
+ </div>
206
+ </IconSettings>
207
+ </React.Fragment>
208
+ <React.Fragment>
209
+ <h3 className="slds-text-heading_medium slds-m-vertical_medium">
210
+ Resizeable: Columns 0 and 3 fixed
211
+ </h3>
212
+ <IconSettings iconPath="/assets/icons">
213
+ <div style={{ height: '200px' }}>
214
+ <DataTable
215
+ items={this.state.items}
216
+ id="DataTableExample-2-resizable-cols"
217
+ fixedLayout
218
+ resizable
219
+ keyboardNavigation
220
+ resizableOptions={{
221
+ onResize: (columnsResized) => {
222
+ console.log(JSON.stringify(columnsResized));
223
+ },
224
+ disabledColumns: [0, 3],
225
+ }}
226
+ >
227
+ {columns}
228
+ </DataTable>
229
+ </div>
230
+ </IconSettings>
231
+ </React.Fragment>
232
+ </React.Fragment>
233
+ );
234
+ }
235
+ }
236
+
237
+ export default Example; // export is replaced with `ReactDOM.render(<Example />, mountNode);` at runtime
@@ -704,6 +704,139 @@ describe('DataTable: ', function describeFunction() {
704
704
  4
705
705
  );
706
706
  });
707
+
708
+ it('Renders a fixedHeader table with column resizing functionality as expected', function () {
709
+ renderTable(
710
+ <DataTable
711
+ {...defaultProps}
712
+ fixedHeader
713
+ fixedLayout
714
+ resizable
715
+ id="DataTable-resizable-cols-Test"
716
+ >
717
+ <DataTableColumn
718
+ isSorted
719
+ label="Name"
720
+ primaryColumn
721
+ property="name"
722
+ sortable
723
+ sortDirection="asc"
724
+ />
725
+ <DataTableColumn label="Count" property="count" />
726
+ <DataTableRowActions
727
+ options={[
728
+ {
729
+ id: 0,
730
+ label: 'Add to Group',
731
+ value: '1',
732
+ },
733
+ {
734
+ id: 1,
735
+ label: 'Publish',
736
+ value: '2',
737
+ },
738
+ ]}
739
+ onAction={() => {}}
740
+ dropdown={<Dropdown length="5" />}
741
+ />
742
+ </DataTable>
743
+ ).call(this);
744
+
745
+ // actions column is not resizable
746
+ expect(this.dom.querySelectorAll('.grip-resizable').length).to.eql(4);
747
+ expect(this.dom.querySelectorAll('.grip-container').length).to.eql(1);
748
+ });
749
+ });
750
+
751
+ describe('Column resizing', function describeFunction2() {
752
+ beforeEach(
753
+ mountComponent(
754
+ <DataTable
755
+ {...defaultProps}
756
+ fixedLayout
757
+ keyboardNavigation
758
+ resizable
759
+ resizableOptions={{
760
+ resizeMode: 'overflow',
761
+ onResize: () => {},
762
+ }}
763
+ >
764
+ {[
765
+ ...columns.map((columnProps) => (
766
+ <DataTableColumn {...columnProps} key={columnProps.property} />
767
+ )),
768
+ ...[
769
+ <DataTableRowActions
770
+ key="actions"
771
+ options={[
772
+ {
773
+ id: 0,
774
+ label: 'Add to Group',
775
+ value: '1',
776
+ },
777
+ {
778
+ id: 1,
779
+ label: 'Publish',
780
+ value: '2',
781
+ },
782
+ ]}
783
+ onAction={() => {}}
784
+ dropdown={<Dropdown length="5" />}
785
+ />,
786
+ ],
787
+ ]}
788
+ </DataTable>
789
+ )
790
+ );
791
+
792
+ afterEach(unmountComponent);
793
+
794
+ it('Resize functionality should work with left key', function () {
795
+ const initial = this.dom.querySelectorAll('th')[0].style.width;
796
+
797
+ let cell = this.wrapper.find('td').first();
798
+ cell.simulate('focus');
799
+ expect(this.wrapper.find('td').first().prop('tabIndex')).to.equal('0');
800
+
801
+ cell.simulate('keyDown', keyObjects.UP);
802
+ cell = this.wrapper.find('th').at(0);
803
+ expect(this.wrapper.find('th').first().prop('tabIndex')).to.equal('0');
804
+
805
+ cell.simulate('keyDown', keyObjects.ENTER);
806
+ cell.simulate('keyDown', keyObjects.LEFT);
807
+ cell.simulate('keyDown', keyObjects.LEFT);
808
+ cell.simulate('keyDown', keyObjects.LEFT);
809
+ cell.simulate('keyDown', keyObjects.ESCAPE);
810
+
811
+ expect(`${parseInt(initial, 10) - 30}px`).to.equal(
812
+ this.dom.querySelectorAll('th')[0].style.width
813
+ );
814
+ });
815
+
816
+ it('Resize functionality should work with right key', function () {
817
+ const initial = this.dom.querySelectorAll('th')[0].style.width;
818
+
819
+ let cell = this.wrapper.find('td').first();
820
+ cell.simulate('focus');
821
+ expect(this.wrapper.find('td').first().prop('tabIndex')).to.equal('0');
822
+
823
+ cell.simulate('keyDown', keyObjects.UP);
824
+ cell = this.wrapper.find('th').at(0);
825
+ expect(this.wrapper.find('th').first().prop('tabIndex')).to.equal('0');
826
+
827
+ cell.simulate('keyDown', keyObjects.ENTER);
828
+ cell.simulate('keyDown', keyObjects.RIGHT);
829
+ cell.simulate('keyDown', keyObjects.RIGHT);
830
+ cell.simulate('keyDown', keyObjects.RIGHT);
831
+ cell.simulate('keyDown', keyObjects.RIGHT);
832
+ cell.simulate('keyDown', keyObjects.RIGHT);
833
+ cell.simulate('keyDown', keyObjects.RIGHT);
834
+ cell.simulate('keyDown', keyObjects.ESCAPE);
835
+
836
+ expect(`${parseInt(initial, 10) + 60}px`).to.equal(
837
+ this.dom.querySelectorAll('th')[0].style.width
838
+ );
839
+ });
707
840
  });
708
841
 
709
842
  describe('w/ Infinite Scrolling', function describeFunction2() {
@@ -0,0 +1 @@
1
+ declare module 'column-resizer';
@@ -28,7 +28,7 @@
28
28
  }
29
29
  ],
30
30
  "site-stories": [
31
- {
31
+ {
32
32
  "heading": "Basic",
33
33
  "path": "/__examples__/basic-fluid.jsx"
34
34
  },
@@ -44,6 +44,10 @@
44
44
  "heading": "Basic: Columns bordered",
45
45
  "path": "/__examples__/basic-fluid-column-bordered.jsx"
46
46
  },
47
+ {
48
+ "heading": "Basic: Headless",
49
+ "path": "/__examples__/basic-fluid-headless.jsx"
50
+ },
47
51
  {
48
52
  "heading": "Fixed Layout",
49
53
  "path": "/__examples__/basic-fixed-layout.jsx"
@@ -61,16 +65,16 @@
61
65
  "path": "/__examples__/fixed-header.jsx"
62
66
  },
63
67
  {
64
- "heading": "Advanced: Joined with Page Header",
65
- "path": "/__examples__/joined-with-page-header.jsx"
66
- },
67
- {
68
- "heading": "Custom Classes",
69
- "path": "/__examples__/custom-classes.jsx"
68
+ "heading": "Advanced: Joined with Page Header",
69
+ "path": "/__examples__/joined-with-page-header.jsx"
70
70
  },
71
71
  {
72
72
  "heading": "Infinite Scrolling",
73
73
  "path": "/__examples__/infinite-scrolling.jsx"
74
+ },
75
+ {
76
+ "heading": "Resizable Columns",
77
+ "path": "/__examples__/resizable-columns.jsx"
74
78
  }
75
79
  ],
76
80
  "url-slug": "data-tables"