@telus-uds/components-community.data-grid 0.1.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -2
- package/jest.config.cjs +1 -1
- package/lib/cjs/DataGrid.js +369 -0
- package/lib/cjs/DataGridBody.js +27 -0
- package/lib/cjs/DataGridCell.js +138 -0
- package/lib/cjs/DataGridHead.js +27 -0
- package/lib/cjs/DataGridRow.js +96 -0
- package/lib/cjs/DataGridTable.js +68 -0
- package/lib/cjs/dictionary.js +24 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/utility.js +87 -0
- package/lib/{DataGrid.js → esm/DataGrid.js} +5 -11
- package/lib/esm/DataGridCell.js +129 -0
- package/lib/{DataGridRow.js → esm/DataGridRow.js} +14 -30
- package/lib/{DataGridTable.js → esm/DataGridTable.js} +13 -24
- package/package.json +9 -7
- package/src/DataGrid.jsx +1 -3
- package/src/DataGridCell.jsx +1 -3
- package/src/DataGridRow.jsx +1 -3
- package/src/DataGridTable.jsx +1 -3
- package/lib/DataGridCell.js +0 -184
- /package/lib/{DataGridBody.js → esm/DataGridBody.js} +0 -0
- /package/lib/{DataGridHead.js → esm/DataGridHead.js} +0 -0
- /package/lib/{dictionary.js → esm/dictionary.js} +0 -0
- /package/lib/{index.js → esm/index.js} +0 -0
- /package/lib/{utility.js → esm/utility.js} +0 -0
package/lib/DataGridCell.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styledComponents } from '@telus-uds/components-web';
|
|
4
|
-
import { CELL_TYPE } from './utility';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const {
|
|
7
|
-
styled,
|
|
8
|
-
css
|
|
9
|
-
} = styledComponents;
|
|
10
|
-
const StyledHeaderCell = styled.th`
|
|
11
|
-
${props => {
|
|
12
|
-
return css`
|
|
13
|
-
background-color: ${props.headerRowBackgroundColor};
|
|
14
|
-
border-top: solid ${props.headerBorderTopWidth}px ${props.headerBorderTopColor};
|
|
15
|
-
border-bottom: solid ${props.headerBorderBottomWidth}px ${props.headerBorderBottomColor};
|
|
16
|
-
padding: ${props.headerPadding}px;
|
|
17
|
-
text-align: ${props.headerTextAlign};
|
|
18
|
-
box-sizing: border-box;
|
|
19
|
-
font-size: ${props.headerFontSize}px;
|
|
20
|
-
font-weight: bold;
|
|
21
|
-
line-height: ${props.headerLineHeight * props.headerFontSize}px;
|
|
22
|
-
color: ${props.headerTextColor};
|
|
23
|
-
width: ${props.firstColWidth};
|
|
24
|
-
font-family: ${props.headerFontFamily};
|
|
25
|
-
`;
|
|
26
|
-
}}
|
|
27
|
-
`;
|
|
28
|
-
const StyledHeaderCellDiv = styled.div`
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
|
-
`;
|
|
32
|
-
const StyledGroupHeaderCell = styled.td`
|
|
33
|
-
${props => {
|
|
34
|
-
return css`
|
|
35
|
-
background-color: ${props.subHeadingBackgroundColor};
|
|
36
|
-
padding: ${props.cellPadding}px;
|
|
37
|
-
border-top: solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor};
|
|
38
|
-
text-align: ${props.cellTextAlign};
|
|
39
|
-
font-size: ${props.cellFontSize}px;
|
|
40
|
-
font-weight: normal;
|
|
41
|
-
line-height: ${props.cellLineHeight * props.cellFontSize}px;
|
|
42
|
-
color: ${props.cellTextColor};
|
|
43
|
-
font-family: ${props.cellFontFamily};
|
|
44
|
-
`;
|
|
45
|
-
}}
|
|
46
|
-
`;
|
|
47
|
-
const StyledGroupHeaderCellDiv = styled.div`
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
justify-content: start;
|
|
51
|
-
`;
|
|
52
|
-
const StyledExpandedCell = styled.td`
|
|
53
|
-
${props => {
|
|
54
|
-
return css`
|
|
55
|
-
padding: ${props.cellPadding}px;
|
|
56
|
-
border-bottom: ${props.isExpandedRowOpen ? `solid ${props.cellBorderBottomWidth}px ${props.headerBorderBottomColor};` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor};`}
|
|
57
|
-
text-align: ${props.cellTextAlign};
|
|
58
|
-
font-size: ${props.cellFontSize}px;
|
|
59
|
-
font-weight: normal;
|
|
60
|
-
line-height: ${props.cellLineHeight * props.cellFontSize}px;
|
|
61
|
-
color: ${props.cellTextColor};
|
|
62
|
-
font-family: ${props.cellFontFamily};
|
|
63
|
-
`;
|
|
64
|
-
}}
|
|
65
|
-
`;
|
|
66
|
-
const StyledExpandedCellDiv = styled.div`
|
|
67
|
-
${props => {
|
|
68
|
-
return css`
|
|
69
|
-
display: flex;
|
|
70
|
-
align-items: center;
|
|
71
|
-
justify-content: ${props.expandedContentAlignment ? props.expandedContentAlignment : 'start'};
|
|
72
|
-
padding-left: ${props.showCheckbox ? `${props.expandedContentLeftPadding}px` : `${props.expandedContentDefaultLeftPadding}px`};
|
|
73
|
-
`;
|
|
74
|
-
}}
|
|
75
|
-
`;
|
|
76
|
-
export const StyledCell = styled.td`
|
|
77
|
-
${props => {
|
|
78
|
-
if (props.isExpandedRowOpen) {
|
|
79
|
-
return css`
|
|
80
|
-
padding: ${props.cellPadding}px;
|
|
81
|
-
text-align: ${props.cellTextAlign};
|
|
82
|
-
font-size: ${props.cellFontSize}px;
|
|
83
|
-
font-weight: normal;
|
|
84
|
-
line-height: ${props.cellLineHeight * props.cellFontSize}px;
|
|
85
|
-
color: ${props.cellTextColor};
|
|
86
|
-
font-family: ${props.cellFontFamily};
|
|
87
|
-
border-top: solid ${props.headerBorderTopWidth}px ${props.headerBorderTopColor};
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
90
|
-
return css`
|
|
91
|
-
padding: ${props.cellPadding}px;
|
|
92
|
-
border-bottom: ${props.hideRowBottomBorder === 1 ? `none` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor}`};
|
|
93
|
-
text-align: ${props.cellTextAlign};
|
|
94
|
-
font-size: ${props.cellFontSize}px;
|
|
95
|
-
font-weight: normal;
|
|
96
|
-
line-height: ${props.cellLineHeight * props.cellFontSize}px;
|
|
97
|
-
color: ${props.cellTextColor};
|
|
98
|
-
font-family: ${props.cellFontFamily};
|
|
99
|
-
`;
|
|
100
|
-
}}
|
|
101
|
-
`;
|
|
102
|
-
const DataGridCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
103
|
-
let {
|
|
104
|
-
children,
|
|
105
|
-
tokens,
|
|
106
|
-
type,
|
|
107
|
-
columnsLength,
|
|
108
|
-
showCheckbox = false,
|
|
109
|
-
isFirstCol = false,
|
|
110
|
-
isExpandedRowOpen = false
|
|
111
|
-
} = _ref;
|
|
112
|
-
if (type === CELL_TYPE.HEADING) {
|
|
113
|
-
return /*#__PURE__*/_jsx(StyledHeaderCell, {
|
|
114
|
-
...tokens,
|
|
115
|
-
firstColWidth: isFirstCol ? tokens.firstColWidth : 'auto',
|
|
116
|
-
ref: ref,
|
|
117
|
-
children: /*#__PURE__*/_jsx(StyledHeaderCellDiv, {
|
|
118
|
-
children: children
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (type === CELL_TYPE.SUBHEADING) {
|
|
123
|
-
return /*#__PURE__*/_jsx(StyledGroupHeaderCell, {
|
|
124
|
-
colSpan: columnsLength + 1,
|
|
125
|
-
...tokens,
|
|
126
|
-
ref: ref,
|
|
127
|
-
children: /*#__PURE__*/_jsx(StyledGroupHeaderCellDiv, {
|
|
128
|
-
...tokens,
|
|
129
|
-
children: children
|
|
130
|
-
})
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (type === CELL_TYPE.EXPANDEDROWCELL) {
|
|
134
|
-
return /*#__PURE__*/_jsx(StyledExpandedCell, {
|
|
135
|
-
colSpan: columnsLength + 1,
|
|
136
|
-
...tokens,
|
|
137
|
-
isExpandedRowOpen: isExpandedRowOpen,
|
|
138
|
-
ref: ref,
|
|
139
|
-
children: /*#__PURE__*/_jsx(StyledExpandedCellDiv, {
|
|
140
|
-
showCheckbox: showCheckbox,
|
|
141
|
-
...tokens,
|
|
142
|
-
children: children
|
|
143
|
-
})
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return /*#__PURE__*/_jsx(StyledCell, {
|
|
147
|
-
...tokens,
|
|
148
|
-
isExpandedRowOpen: isExpandedRowOpen,
|
|
149
|
-
ref: ref,
|
|
150
|
-
children: children
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
DataGridCell.displayName = 'DataGridCell';
|
|
154
|
-
DataGridCell.propTypes = {
|
|
155
|
-
/**
|
|
156
|
-
cell type
|
|
157
|
-
*/
|
|
158
|
-
type: PropTypes.oneOf(['heading', 'subHeading', 'expandedRowCell']),
|
|
159
|
-
/**
|
|
160
|
-
* Accepts any React or HTML node
|
|
161
|
-
*/
|
|
162
|
-
children: PropTypes.node,
|
|
163
|
-
/**
|
|
164
|
-
* Tokens passed to the component
|
|
165
|
-
*/
|
|
166
|
-
tokens: PropTypes.object,
|
|
167
|
-
/**
|
|
168
|
-
* columnsLength passed to the component for certain scenarios in which colSpan is required
|
|
169
|
-
*/
|
|
170
|
-
columnsLength: PropTypes.number,
|
|
171
|
-
/**
|
|
172
|
-
* showCheckbox passed to the component for certain scenarios in which checkbox visibility impacts the display design
|
|
173
|
-
*/
|
|
174
|
-
showCheckbox: PropTypes.bool,
|
|
175
|
-
/**
|
|
176
|
-
* isFirstCol passed to the component to determine if cell is first within the row
|
|
177
|
-
*/
|
|
178
|
-
isFirstCol: PropTypes.bool,
|
|
179
|
-
/**
|
|
180
|
-
* isExpandedRowOpen passed to the component to determine if cell is displaying additional data
|
|
181
|
-
*/
|
|
182
|
-
isExpandedRowOpen: PropTypes.bool
|
|
183
|
-
};
|
|
184
|
-
export default DataGridCell;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|