@loadsmart/loadsmart-ui 6.2.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadsmart/loadsmart-ui",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "main": "dist",
6
6
  "files": [
@@ -518,17 +518,17 @@ export function WithExpandableRow(args: TableProps): JSX.Element {
518
518
 
519
519
  return (
520
520
  <div className="p-4 bg-neutral-white">
521
- <Table {...args}>
522
- <Table.Head>
521
+ <Table withExpandableRows {...args}>
522
+ <Table.Expandable.Head>
523
523
  <Table.Row>
524
524
  <Table.Expandable.HeadCell />
525
525
  <Table.Expandable.HeadCell>reference</Table.Expandable.HeadCell>
526
526
  <Table.Expandable.HeadCell>product</Table.Expandable.HeadCell>
527
527
  <Table.Expandable.HeadCell>price</Table.Expandable.HeadCell>
528
528
  </Table.Row>
529
- </Table.Head>
529
+ </Table.Expandable.Head>
530
530
 
531
- <Table.Body withExpandableRows>
531
+ <Table.Body>
532
532
  <Table.Expandable.Row
533
533
  leading={leading}
534
534
  expandableContent={<div>Forced expanded with custom leading</div>}
@@ -196,7 +196,7 @@ describe('<Table />', () => {
196
196
  <Table.HeadCell alignment="right">Price $</Table.HeadCell>
197
197
  </Table.Row>
198
198
  </Table.Head>
199
- <Table.Body withExpandableRows>
199
+ <Table.Body>
200
200
  <Table.Expandable.Row
201
201
  expandableContent={<div>This is an expandable content on index 0</div>}
202
202
  expanded
@@ -36,15 +36,11 @@ import type {
36
36
  TablePickerItemProps,
37
37
  TablePickerProps,
38
38
  ExpandableTableRowProps,
39
- TableBodyProps,
40
39
  TableHeadCellProps,
41
40
  } from './Table.types'
42
41
 
43
- const StyledTableBody = styled.tbody<{ $withExpandableRows?: boolean }>`
44
- background-color: ${conditional({
45
- 'color-neutral-lightest': whenProps({ $withExpandableRows: true }),
46
- initial: whenProps({ $withExpandableRows: false }),
47
- })};
42
+ const StyledTableBody = styled.tbody`
43
+ /* placeholder */
48
44
  `
49
45
 
50
46
  const StyledTableFoot = styled.tfoot`
@@ -117,6 +113,17 @@ const StyledTableHead = styled.thead`
117
113
  }
118
114
  `
119
115
 
116
+ const StyledExpandableTableHead = styled.thead`
117
+ border: 1px solid ${token('color-neutral-lighter')};
118
+
119
+ ${StyledTableCell} {
120
+ padding: ${token('space-s')};
121
+
122
+ font-weight: ${token('font-weight-bold')};
123
+ text-transform: capitalize;
124
+ }
125
+ `
126
+
120
127
  const BaseStyledTableRow = styled.tr`
121
128
  ${StyledTableHead} > & {
122
129
  height: 36px;
@@ -155,22 +162,23 @@ const StyledTableRow = styled(BaseStyledTableRow)<{ selected?: boolean }>`
155
162
  const StyledExpandableTableRow = styled.tr<{ $isExpanded: boolean }>`
156
163
  background-color: ${token('color-neutral-white')};
157
164
 
158
- border-color: ${token('color-neutral-light')};
165
+ border-color: ${token('color-neutral-lighter')};
159
166
  border-width: 1px;
160
- border-style: ${conditional({
167
+ border-top-style: solid;
168
+ border-right-style: solid;
169
+ border-left-style: solid;
170
+ border-bottom-style: ${conditional({
161
171
  solid: whenProps({ $isExpanded: false }),
162
- 'hidden solid': whenProps({ $isExpanded: true }),
172
+ hidden: whenProps({ $isExpanded: true }),
163
173
  })};
164
174
 
165
175
  box-shadow: ${conditional({
166
- '0px 4px 8px 3px rgba(32, 42, 49, 0.15), 0px 1px 3px 0px rgba(94, 118, 138, 0.20)': whenProps({
167
- $isExpanded: true,
168
- }),
176
+ '0px 3px 3px 0px #C1CED9': whenProps({ $isExpanded: true }),
169
177
  none: whenProps({ $isExpanded: false }),
170
178
  })};
171
179
 
172
180
  ${hoverable`
173
- background-color: ${token('table-row-variant-color')};
181
+ background-color: ${token('color-neutral-lighter')};
174
182
  `}
175
183
 
176
184
  ${focusable`
@@ -179,17 +187,23 @@ const StyledExpandableTableRow = styled.tr<{ $isExpanded: boolean }>`
179
187
  `
180
188
 
181
189
  const StyledExpandableContentRow = styled.tr`
182
- border-color: ${token('color-neutral-light')};
190
+ border-color: ${token('color-neutral-lighter')};
183
191
  border-width: 1px;
184
- border-style: hidden solid;
192
+ border-top-style: hidden;
193
+ border-right-style: solid;
194
+ border-left-style: solid;
195
+ border-bottom-style: solid;
185
196
  `
186
197
 
187
- const StyledTable = styled.table<{ scale?: string }>`
198
+ const StyledTable = styled.table<{ scale?: string; withExpandableRows?: boolean }>`
188
199
  width: 100%;
189
200
 
190
201
  white-space: nowrap;
191
202
 
192
- background-color: ${token('color-neutral-white')};
203
+ background-color: ${conditional({
204
+ 'color-neutral-lightest': whenProps({ withExpandableRows: true }),
205
+ 'color-neutral-white': whenProps({ withExpandableRows: false }),
206
+ })};
193
207
 
194
208
  border-collapse: collapse;
195
209
 
@@ -226,13 +240,14 @@ function Table<T>({
226
240
  children,
227
241
  selection,
228
242
  scale = 'default',
243
+ withExpandableRows,
229
244
  ...others
230
245
  }: TableProps<T>): JSX.Element {
231
246
  return (
232
247
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
233
248
  // @ts-ignore
234
249
  <TableSelectionProvider selection={selection}>
235
- <StyledTable scale={scale} {...others}>
250
+ <StyledTable scale={scale} withExpandableRows={withExpandableRows} {...others}>
236
251
  {children}
237
252
  </StyledTable>
238
253
  </TableSelectionProvider>
@@ -258,16 +273,12 @@ function TableHead({ children, ...others }: TableSectionProps): JSX.Element {
258
273
  return <StyledTableHead {...others}>{children}</StyledTableHead>
259
274
  }
260
275
 
261
- function TableBody({
262
- children,
263
- withExpandableRows = false,
264
- ...others
265
- }: TableBodyProps): JSX.Element {
266
- return (
267
- <StyledTableBody {...others} $withExpandableRows={withExpandableRows}>
268
- {children}
269
- </StyledTableBody>
270
- )
276
+ function ExpandableTableHead({ children, ...others }: TableSectionProps): JSX.Element {
277
+ return <StyledExpandableTableHead {...others}>{children}</StyledExpandableTableHead>
278
+ }
279
+
280
+ function TableBody({ children, ...others }: TableSectionProps): JSX.Element {
281
+ return <StyledTableBody {...others}>{children}</StyledTableBody>
271
282
  }
272
283
 
273
284
  function TableCell({
@@ -553,6 +564,7 @@ Table.Selection = {
553
564
  HeadCell: SelectionHeadCell,
554
565
  }
555
566
  Table.Expandable = {
567
+ Head: ExpandableTableHead,
556
568
  HeadCell: ExpandableHeadCell,
557
569
  Cell: ExpandableCell,
558
570
  Row: ExpandableTableRow,
@@ -17,6 +17,7 @@ export interface TableProps<T extends Selectable = TableSelectableRow>
17
17
  extends HTMLAttributes<HTMLTableElement> {
18
18
  scale?: Scale
19
19
  selection?: TableSelectionConfig<T>
20
+ withExpandableRows?: boolean
20
21
  }
21
22
 
22
23
  export interface TableCaptionProps extends HTMLAttributes<HTMLTableCaptionElement> {
@@ -38,10 +39,6 @@ export interface TableSectionProps extends HTMLAttributes<HTMLTableSectionElemen
38
39
  scale?: Scale
39
40
  }
40
41
 
41
- export interface TableBodyProps extends TableSectionProps {
42
- withExpandableRows?: boolean
43
- }
44
-
45
42
  export type TableRowProps = HTMLAttributes<HTMLTableRowElement>
46
43
 
47
44
  export type ExpandableTableRowProps = TableRowProps & {