Skip to content

Commit 47ab14a

Browse files
committed
feat: colMode
1 parent cbc46cd commit 47ab14a

File tree

8 files changed

+892
-224
lines changed

8 files changed

+892
-224
lines changed

packages/plus/src/components/OfferList/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,7 @@ exports[`offerList > should work with banner open 1`] = `
31143114
id="_r_3g_"
31153115
>
31163116
<td
3117-
class="uv_inoh54n uv_inoh54k"
3117+
class="uv_inoh54o uv_inoh54k"
31183118
colspan="5"
31193119
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
31203120
>
@@ -3244,7 +3244,7 @@ exports[`offerList > should work with banner open 1`] = `
32443244
id="_r_3m_"
32453245
>
32463246
<td
3247-
class="uv_inoh54n uv_inoh54k"
3247+
class="uv_inoh54o uv_inoh54k"
32483248
colspan="5"
32493249
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
32503250
>
@@ -3374,7 +3374,7 @@ exports[`offerList > should work with banner open 1`] = `
33743374
id="_r_3s_"
33753375
>
33763376
<td
3377-
class="uv_inoh54n uv_inoh54k"
3377+
class="uv_inoh54o uv_inoh54k"
33783378
colspan="5"
33793379
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
33803380
>
@@ -3504,7 +3504,7 @@ exports[`offerList > should work with banner open 1`] = `
35043504
id="_r_42_"
35053505
>
35063506
<td
3507-
class="uv_inoh54n uv_inoh54k"
3507+
class="uv_inoh54o uv_inoh54k"
35083508
colspan="5"
35093509
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
35103510
>
@@ -3634,7 +3634,7 @@ exports[`offerList > should work with banner open 1`] = `
36343634
id="_r_48_"
36353635
>
36363636
<td
3637-
class="uv_inoh54n uv_inoh54k"
3637+
class="uv_inoh54o uv_inoh54k"
36383638
colspan="5"
36393639
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
36403640
>
@@ -3764,7 +3764,7 @@ exports[`offerList > should work with banner open 1`] = `
37643764
id="_r_4e_"
37653765
>
37663766
<td
3767-
class="uv_inoh54n uv_inoh54k"
3767+
class="uv_inoh54o uv_inoh54k"
37683768
colspan="5"
37693769
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
37703770
>
@@ -3894,7 +3894,7 @@ exports[`offerList > should work with banner open 1`] = `
38943894
id="_r_4k_"
38953895
>
38963896
<td
3897-
class="uv_inoh54n uv_inoh54k"
3897+
class="uv_inoh54o uv_inoh54k"
38983898
colspan="5"
38993899
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
39003900
>
@@ -4024,7 +4024,7 @@ exports[`offerList > should work with banner open 1`] = `
40244024
id="_r_4q_"
40254025
>
40264026
<td
4027-
class="uv_inoh54n uv_inoh54k"
4027+
class="uv_inoh54o uv_inoh54k"
40284028
colspan="5"
40294029
style="--uv_1431nf64: auto; --uv_1431nf66: auto; --uv_1431nf65: none; --uv_1431nf67: auto; --uv_1431nf68: none; --uv_1431nf69: auto; --uv_1431nf63: var(--rwwhsl9t);"
40304030
>

packages/ui/src/components/List/Cell.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { assignInlineVars } from '@vanilla-extract/dynamic'
55
import type { CSSProperties, ReactNode } from 'react'
66
import { forwardRef } from 'react'
77
import { useColumnProvider } from './ColumnProvider'
8-
import { listCell } from './styles.css'
8+
import { useListContext } from './ListContext'
9+
import { listCell, listCellStrict } from './styles.css'
910
import {
1011
listCellPadding,
1112
maxWidthCell,
@@ -27,7 +28,7 @@ type CellProps = {
2728
export const Cell = forwardRef<HTMLTableCellElement, CellProps>(
2829
({ children, className, 'data-testid': dataTestid, colSpan, style }, ref) => {
2930
const context = useColumnProvider()
30-
31+
const { colMode } = useListContext()
3132
const width = context?.width
3233
const maxWidth = context?.width
3334
const minWidth = context?.width
@@ -45,7 +46,11 @@ export const Cell = forwardRef<HTMLTableCellElement, CellProps>(
4546

4647
return (
4748
<td
48-
className={cn(className, listCell)}
49+
className={cn(
50+
className,
51+
listCell,
52+
colMode === 'strict' ? listCellStrict : '',
53+
)}
4954
colSpan={colSpan}
5055
data-testid={dataTestid}
5156
ref={ref}

packages/ui/src/components/List/ListContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export type ListContextValue = {
5050
refList: RefObject<HTMLInputElement>[]
5151
setRefList: Dispatch<SetStateAction<RefObject<HTMLInputElement>[]>>
5252
handleOnChange: (value: string, checked: boolean) => void
53+
colMode?: 'strict' | 'flexible'
5354
}
5455

5556
const ListContext = createContext<ListContextValue | undefined>(undefined)
@@ -61,6 +62,7 @@ export type ListProviderProps = {
6162
expandButton: boolean
6263
onSelectedChange?: Dispatch<SetStateAction<string[]>>
6364
columns: ColumnProps[]
65+
colMode?: 'strict' | 'flexible'
6466
}
6567

6668
const checkStateOfCheckboxs = (ids: RowState) => {
@@ -86,6 +88,7 @@ export const ListProvider = ({
8688
expandButton,
8789
onSelectedChange,
8890
columns,
91+
colMode,
8992
}: ListProviderProps) => {
9093
const [expandedRowIds, setExpandedRowIds] = useState<RowState>({})
9194
const [selectedRowIds, setSelectedRowIds] = useState<RowState>({})
@@ -331,6 +334,7 @@ export const ListProvider = ({
331334
() => ({
332335
allRowSelectValue,
333336
collapseRow,
337+
colMode,
334338
columns,
335339
expandButton,
336340
expandedRowIds,
@@ -370,6 +374,7 @@ export const ListProvider = ({
370374
unselectAll,
371375
unselectRow,
372376
handleOnChange,
377+
colMode,
373378
],
374379
)
375380

0 commit comments

Comments
 (0)