@multiplatform.one/table-primitives 7.47.4 → 7.48.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/dist/cjs/index.cjs +6 -46
- package/dist/cjs/index.native.js +6 -46
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/tableCellContext.native.js.map +1 -1
- package/dist/cjs/textRidesText.native.js.map +1 -1
- package/dist/esm/index.mjs +7 -45
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +7 -45
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/index.js +7 -45
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +7 -45
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +6 -46
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/index.tsx +12 -47
- package/src/table.spec.tsx +14 -19
- package/types/index.d.ts +0 -22
- package/types/index.d.ts.map +1 -1
package/src/index.tsx
CHANGED
|
@@ -16,12 +16,11 @@ import {
|
|
|
16
16
|
useResolvedKnobs,
|
|
17
17
|
sizeTokenStop,
|
|
18
18
|
SizableText,
|
|
19
|
-
type PhoneTableBleed,
|
|
20
19
|
} from "@multiplatform.one/theme";
|
|
21
20
|
import { TableCellContext } from "./tableCellContext";
|
|
22
21
|
import { wrapBareTextChildren } from "./textRidesText";
|
|
23
22
|
import { Children, Fragment, createContext, isValidElement, useContext } from "react";
|
|
24
|
-
import type { FontSizeTokens, SizeTokens
|
|
23
|
+
import type { FontSizeTokens, SizeTokens } from "tamagui";
|
|
25
24
|
import {
|
|
26
25
|
SizableText as TamaguiSizableText,
|
|
27
26
|
Theme,
|
|
@@ -362,29 +361,6 @@ export function TableEdgeCells({ children }: { children: React.ReactNode }) {
|
|
|
362
361
|
return <>{inset ? markEdgeCells(children) : children}</>;
|
|
363
362
|
}
|
|
364
363
|
|
|
365
|
-
/**
|
|
366
|
-
* LC-146 recipe for one row of a full-bleed card or document list: no card
|
|
367
|
-
* chrome at the screen edge, a hairline between rows, and the gutter as the
|
|
368
|
-
* row's horizontal inset.
|
|
369
|
-
*/
|
|
370
|
-
export function phoneBleedRowProps(inset: string) {
|
|
371
|
-
return {
|
|
372
|
-
borderRadius: 0,
|
|
373
|
-
borderWidth: 0,
|
|
374
|
-
...hairline.bottom,
|
|
375
|
-
borderColor: "$borderColor",
|
|
376
|
-
elevation: 0,
|
|
377
|
-
shadowColor: "transparent",
|
|
378
|
-
paddingLeft: inset,
|
|
379
|
-
paddingRight: inset,
|
|
380
|
-
} as const;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/** LC-146 recipe for a full-bleed list frame: out to the screen edges, rows abut. */
|
|
384
|
-
export function phoneBleedListProps(bleed: Pick<PhoneTableBleed, "frame"> | null) {
|
|
385
|
-
return { ...(bleed ? bleed.frame : {}), gap: 0 } as const;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
364
|
const BodyRowIndexContext = createContext<number | undefined>(undefined);
|
|
389
365
|
|
|
390
366
|
function indexBodyRows(children: React.ReactNode, counter: { next: number }): React.ReactNode {
|
|
@@ -642,16 +618,16 @@ function extractCardModel(children: React.ReactNode): {
|
|
|
642
618
|
return { headerLabels, rows, caption };
|
|
643
619
|
}
|
|
644
620
|
|
|
645
|
-
/**
|
|
621
|
+
/**
|
|
622
|
+
* Card list rendering for the Table primitive (layout="cards" / narrow auto).
|
|
623
|
+
* A card is its own surface: it keeps the page gutter (LC-146 bleeds rows,
|
|
624
|
+
* not cards) and never stripes (LC-144 stripes rows, not cards).
|
|
625
|
+
*/
|
|
646
626
|
function TableCardsList({
|
|
647
627
|
children,
|
|
648
|
-
edgeInset,
|
|
649
|
-
selfBleed,
|
|
650
628
|
...props
|
|
651
629
|
}: {
|
|
652
630
|
children?: React.ReactNode;
|
|
653
|
-
edgeInset?: string | null;
|
|
654
|
-
selfBleed?: PhoneTableBleed | null;
|
|
655
631
|
[key: string]: any;
|
|
656
632
|
}) {
|
|
657
633
|
const { knobProps } = useResolvedKnobs();
|
|
@@ -679,12 +655,9 @@ function TableCardsList({
|
|
|
679
655
|
unknown
|
|
680
656
|
>)}
|
|
681
657
|
{...viewProps}
|
|
682
|
-
{...(edgeInset ? phoneBleedListProps(selfBleed ?? null) : {})}
|
|
683
|
-
{...(edgeInset ? ({ "data-phone-bleed": "true" } as Record<string, unknown>) : {})}
|
|
684
658
|
>
|
|
685
659
|
{caption != null && (
|
|
686
|
-
|
|
687
|
-
<YStack {...(edgeInset ? { paddingHorizontal: edgeInset as SpaceTokens } : {})}>
|
|
660
|
+
<YStack>
|
|
688
661
|
{typeof caption === "string" || typeof caption === "number" ? (
|
|
689
662
|
<SizableText fontSize={knobProps.sizeToken as FontSizeTokens} color="$color10">
|
|
690
663
|
{caption}
|
|
@@ -694,8 +667,7 @@ function TableCardsList({
|
|
|
694
667
|
)}
|
|
695
668
|
</YStack>
|
|
696
669
|
)}
|
|
697
|
-
{rows.map((row
|
|
698
|
-
const stripe = tableZebraStripe(knobProps.tableZebra, rowIndex);
|
|
670
|
+
{rows.map((row) => {
|
|
699
671
|
const card = (
|
|
700
672
|
<ThemeableStack
|
|
701
673
|
key={row.key}
|
|
@@ -703,17 +675,10 @@ function TableCardsList({
|
|
|
703
675
|
{...knobProps.surface}
|
|
704
676
|
{...knobProps.cardSurface}
|
|
705
677
|
{...motion}
|
|
706
|
-
{...(stripe === "odd"
|
|
707
|
-
? { backgroundColor: tableZebraFill(knobProps.cardSurface.backgroundColor) }
|
|
708
|
-
: {})}
|
|
709
678
|
{...(row.intent ? { backgroundColor: "$color3" as const } : {})}
|
|
710
|
-
{
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
elevation: knobProps.elevation,
|
|
714
|
-
borderColor: edgeColorAt("$color6", knobProps.borderWidthStop),
|
|
715
|
-
})}
|
|
716
|
-
{...({ "data-table-zebra": stripe } as Record<string, unknown>)}
|
|
679
|
+
elevation={knobProps.elevation}
|
|
680
|
+
borderColor={edgeColorAt("$color6", knobProps.borderWidthStop)}
|
|
681
|
+
{...({ "data-table-zebra": "off" } as Record<string, unknown>)}
|
|
717
682
|
>
|
|
718
683
|
{row.cells.map((cell, index) => {
|
|
719
684
|
const label = headerLabels[index];
|
|
@@ -806,7 +771,7 @@ function ThemedTableFrame({
|
|
|
806
771
|
if (showCards) {
|
|
807
772
|
return (
|
|
808
773
|
<PageGutter inset={null}>
|
|
809
|
-
<TableCardsList {...props}
|
|
774
|
+
<TableCardsList {...props} />
|
|
810
775
|
</PageGutter>
|
|
811
776
|
);
|
|
812
777
|
}
|
package/src/table.spec.tsx
CHANGED
|
@@ -527,7 +527,7 @@ describe("Table Primitives", () => {
|
|
|
527
527
|
expect(fills(container)).toEqual([[], ["_bg-color3"], [], ["_bg-color3"]]);
|
|
528
528
|
});
|
|
529
529
|
|
|
530
|
-
it("stripes
|
|
530
|
+
it("never stripes a card in the card layout and leaves intent cards tinted (FZ-7816)", () => {
|
|
531
531
|
const cards = (tableZebra: "on" | "off") =>
|
|
532
532
|
Array.from(
|
|
533
533
|
zebraTable(
|
|
@@ -555,18 +555,18 @@ describe("Table Primitives", () => {
|
|
|
555
555
|
"off",
|
|
556
556
|
]);
|
|
557
557
|
expect(on.map((card) => card.getAttribute("data-table-zebra"))).toEqual([
|
|
558
|
-
"
|
|
559
|
-
"
|
|
560
|
-
"
|
|
561
|
-
"
|
|
562
|
-
"
|
|
563
|
-
"
|
|
558
|
+
"off",
|
|
559
|
+
"off",
|
|
560
|
+
"off",
|
|
561
|
+
"off",
|
|
562
|
+
"off",
|
|
563
|
+
"off",
|
|
564
564
|
]);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
expect(atomic(on[
|
|
569
|
-
expect(atomic(on[
|
|
565
|
+
for (const index of [0, 1, 3, 5]) {
|
|
566
|
+
expect(atomic(on[index], "bg")).toEqual(atomic(off[index], "bg"));
|
|
567
|
+
}
|
|
568
|
+
expect(atomic(on[1], "bg")).toEqual(atomic(on[0], "bg"));
|
|
569
|
+
expect(atomic(on[4], "bg")).toEqual(["_bg-color3"]);
|
|
570
570
|
});
|
|
571
571
|
|
|
572
572
|
describe("the stripe steps one up the ramp from the surface it sits on (MPO-401)", () => {
|
|
@@ -592,17 +592,12 @@ describe("Table Primitives", () => {
|
|
|
592
592
|
);
|
|
593
593
|
}
|
|
594
594
|
|
|
595
|
-
it("in dark an odd card's background differs from an even card's", () => {
|
|
596
|
-
const [even, odd] = cardFills("dark");
|
|
597
|
-
expect(odd).not.toEqual(even);
|
|
598
|
-
});
|
|
599
|
-
|
|
600
595
|
for (const scheme of ["light", "dark"] as const) {
|
|
601
|
-
it(`${scheme} cards keep the template fill and stripe at
|
|
596
|
+
it(`${scheme} cards keep the template fill and never stripe at any elevation`, () => {
|
|
602
597
|
for (const elevation of ["none", "small", "medium", "large"] as const) {
|
|
603
598
|
expect(cardFills(scheme, elevation).slice(0, 2)).toEqual([
|
|
604
599
|
["_bg-background"],
|
|
605
|
-
["_bg-
|
|
600
|
+
["_bg-background"],
|
|
606
601
|
]);
|
|
607
602
|
}
|
|
608
603
|
});
|
package/types/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Layer 1 only: depends on theme + Tamagui (no forms, no data-table).
|
|
5
5
|
* Consumed by @multiplatform.one/table, @multiplatform.one/forms, etc.
|
|
6
6
|
*/
|
|
7
|
-
import { type PhoneTableBleed } from "@multiplatform.one/theme";
|
|
8
7
|
import type { SizeTokens } from "tamagui";
|
|
9
8
|
export { TableCellContext, useIsInTableCell, useTableCellContext } from "./tableCellContext";
|
|
10
9
|
export type { TableCellContextValue } from "./tableCellContext";
|
|
@@ -86,27 +85,6 @@ export declare function TableEdgeInset({ inset, children, }: {
|
|
|
86
85
|
export declare function TableEdgeCells({ children }: {
|
|
87
86
|
children: React.ReactNode;
|
|
88
87
|
}): import("react/jsx-runtime").JSX.Element;
|
|
89
|
-
/**
|
|
90
|
-
* LC-146 recipe for one row of a full-bleed card or document list: no card
|
|
91
|
-
* chrome at the screen edge, a hairline between rows, and the gutter as the
|
|
92
|
-
* row's horizontal inset.
|
|
93
|
-
*/
|
|
94
|
-
export declare function phoneBleedRowProps(inset: string): {
|
|
95
|
-
readonly borderColor: "$borderColor";
|
|
96
|
-
readonly elevation: 0;
|
|
97
|
-
readonly shadowColor: "transparent";
|
|
98
|
-
readonly paddingLeft: string;
|
|
99
|
-
readonly paddingRight: string;
|
|
100
|
-
readonly borderBottomWidth: number;
|
|
101
|
-
readonly className: "mp-hairline-b";
|
|
102
|
-
readonly borderRadius: 0;
|
|
103
|
-
readonly borderWidth: 0;
|
|
104
|
-
};
|
|
105
|
-
/** LC-146 recipe for a full-bleed list frame: out to the screen edges, rows abut. */
|
|
106
|
-
export declare function phoneBleedListProps(bleed: Pick<PhoneTableBleed, "frame"> | null): {
|
|
107
|
-
readonly gap: 0;
|
|
108
|
-
readonly marginHorizontal?: string | undefined;
|
|
109
|
-
};
|
|
110
88
|
declare const TableBody: import("tamagui").TamaguiComponent<import("@tamagui/web").TamaDefer, import("tamagui").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/web").StackStyleBase, {
|
|
111
89
|
elevation?: number | SizeTokens | undefined;
|
|
112
90
|
transparent?: boolean | undefined;
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,SAAS,CAAC;AAa1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7F,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE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