@multiplatform.one/table-primitives 7.45.1 → 7.47.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 +186 -29
- package/dist/cjs/index.native.js +202 -37
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.mjs +185 -33
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +201 -41
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/index.js +185 -33
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +185 -33
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +202 -37
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/index.tsx +252 -40
- package/types/index.d.ts +55 -8
- package/types/index.d.ts.map +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -24,13 +24,18 @@ var index_exports = {};
|
|
|
24
24
|
__export(index_exports, {
|
|
25
25
|
Table: () => Table,
|
|
26
26
|
TableCellContext: () => import_tableCellContext2.TableCellContext,
|
|
27
|
+
TableEdgeCells: () => TableEdgeCells,
|
|
28
|
+
TableEdgeInset: () => TableEdgeInset,
|
|
27
29
|
getTableCellPadding: () => getTableCellPadding,
|
|
28
30
|
isBareTextChild: () => import_textRidesText2.isBareTextChild,
|
|
31
|
+
phoneBleedListProps: () => phoneBleedListProps,
|
|
32
|
+
phoneBleedRowProps: () => phoneBleedRowProps,
|
|
29
33
|
tablePressFill: () => tablePressFill,
|
|
30
34
|
tableZebraFill: () => tableZebraFill,
|
|
31
35
|
tableZebraStripe: () => tableZebraStripe,
|
|
32
36
|
useIsInTableCell: () => import_tableCellContext2.useIsInTableCell,
|
|
33
37
|
useTableCellContext: () => import_tableCellContext2.useTableCellContext,
|
|
38
|
+
useTableEdgeInset: () => useTableEdgeInset,
|
|
34
39
|
wrapBareTextChildren: () => import_textRidesText2.wrapBareTextChildren
|
|
35
40
|
});
|
|
36
41
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -265,6 +270,83 @@ function tablePressFill(restFill) {
|
|
|
265
270
|
if (step >= 12) return "$color11";
|
|
266
271
|
return `$color${Math.max(step + 1, 4)}`;
|
|
267
272
|
}
|
|
273
|
+
const TableEdgeInsetContext = (0, import_react.createContext)(null);
|
|
274
|
+
const CellEdgeContext = (0, import_react.createContext)(void 0);
|
|
275
|
+
function useTableEdgeInset() {
|
|
276
|
+
return (0, import_react.useContext)(TableEdgeInsetContext);
|
|
277
|
+
}
|
|
278
|
+
function TableEdgeInset({
|
|
279
|
+
inset,
|
|
280
|
+
children
|
|
281
|
+
}) {
|
|
282
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableEdgeInsetContext.Provider, {
|
|
283
|
+
value: inset,
|
|
284
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.PageGutter, {
|
|
285
|
+
inset: null,
|
|
286
|
+
children
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function isRtlDocument() {
|
|
291
|
+
return import_tamagui.isWeb && typeof document !== "undefined" && document.documentElement?.dir === "rtl";
|
|
292
|
+
}
|
|
293
|
+
function cellEdgePadding(edge, inset, own) {
|
|
294
|
+
const start = edge === "first" || edge === "only";
|
|
295
|
+
const end = edge === "last" || edge === "only";
|
|
296
|
+
if (!import_tamagui.isWeb) {
|
|
297
|
+
return {
|
|
298
|
+
...(start ? {
|
|
299
|
+
paddingStart: inset
|
|
300
|
+
} : {}),
|
|
301
|
+
...(end ? {
|
|
302
|
+
paddingEnd: inset
|
|
303
|
+
} : {})
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const rtl = isRtlDocument();
|
|
307
|
+
const left = rtl ? end : start;
|
|
308
|
+
const right = rtl ? start : end;
|
|
309
|
+
return {
|
|
310
|
+
paddingLeft: left ? inset : own.paddingLeft ?? own.paddingHorizontal,
|
|
311
|
+
paddingRight: right ? inset : own.paddingRight ?? own.paddingHorizontal
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function markEdgeCells(children) {
|
|
315
|
+
const cells = flattenChildren(children).filter(import_react.isValidElement);
|
|
316
|
+
return cells.map((cell, index) => {
|
|
317
|
+
const edge = cells.length === 1 ? "only" : index === 0 ? "first" : index === cells.length - 1 ? "last" : void 0;
|
|
318
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CellEdgeContext.Provider, {
|
|
319
|
+
value: edge,
|
|
320
|
+
children: cell
|
|
321
|
+
}, cell.key ?? index);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function TableEdgeCells({
|
|
325
|
+
children
|
|
326
|
+
}) {
|
|
327
|
+
const inset = (0, import_react.useContext)(TableEdgeInsetContext);
|
|
328
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
329
|
+
children: inset ? markEdgeCells(children) : children
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function phoneBleedRowProps(inset) {
|
|
333
|
+
return {
|
|
334
|
+
borderRadius: 0,
|
|
335
|
+
borderWidth: 0,
|
|
336
|
+
...import_theme.hairline.bottom,
|
|
337
|
+
borderColor: "$borderColor",
|
|
338
|
+
elevation: 0,
|
|
339
|
+
shadowColor: "transparent",
|
|
340
|
+
paddingLeft: inset,
|
|
341
|
+
paddingRight: inset
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function phoneBleedListProps(bleed) {
|
|
345
|
+
return {
|
|
346
|
+
...(bleed ? bleed.frame : {}),
|
|
347
|
+
gap: 0
|
|
348
|
+
};
|
|
349
|
+
}
|
|
268
350
|
const BodyRowIndexContext = (0, import_react.createContext)(void 0);
|
|
269
351
|
function indexBodyRows(children, counter) {
|
|
270
352
|
return import_react.Children.map(children, child => {
|
|
@@ -274,6 +356,7 @@ function indexBodyRows(children, counter) {
|
|
|
274
356
|
children: indexBodyRows(child.props.children, counter)
|
|
275
357
|
});
|
|
276
358
|
}
|
|
359
|
+
if (child.props["aria-hidden"] === true) return child;
|
|
277
360
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(BodyRowIndexContext.Provider, {
|
|
278
361
|
value: counter.next++,
|
|
279
362
|
children: child
|
|
@@ -489,6 +572,8 @@ function extractCardModel(children) {
|
|
|
489
572
|
}
|
|
490
573
|
function TableCardsList({
|
|
491
574
|
children,
|
|
575
|
+
edgeInset,
|
|
576
|
+
selfBleed,
|
|
492
577
|
...props
|
|
493
578
|
}) {
|
|
494
579
|
const {
|
|
@@ -518,25 +603,39 @@ function TableCardsList({
|
|
|
518
603
|
"data-animation": knobProps.motion.control.transition ? "on" : "none"
|
|
519
604
|
},
|
|
520
605
|
...viewProps,
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
606
|
+
...(edgeInset ? phoneBleedListProps(selfBleed ?? null) : {}),
|
|
607
|
+
...(edgeInset ? {
|
|
608
|
+
"data-phone-bleed": "true"
|
|
609
|
+
} : {}),
|
|
610
|
+
children: [caption != null &&
|
|
611
|
+
// LC-146: the caption stays on the page line while the cards bleed.
|
|
612
|
+
/* @__PURE__ */
|
|
613
|
+
(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
614
|
+
...(edgeInset ? {
|
|
615
|
+
paddingHorizontal: edgeInset
|
|
616
|
+
} : {}),
|
|
617
|
+
children: typeof caption === "string" || typeof caption === "number" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.SizableText, {
|
|
618
|
+
fontSize: knobProps.sizeToken,
|
|
619
|
+
color: "$color10",
|
|
620
|
+
children: caption
|
|
621
|
+
}) : caption
|
|
622
|
+
}), rows.map((row, rowIndex) => {
|
|
526
623
|
const stripe = tableZebraStripe(knobProps.tableZebra, rowIndex);
|
|
527
624
|
const card = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.ThemeableStack, {
|
|
528
625
|
testID: "table-card",
|
|
529
626
|
...knobProps.surface,
|
|
530
627
|
...knobProps.cardSurface,
|
|
531
|
-
elevation: knobProps.elevation,
|
|
532
628
|
...motion,
|
|
533
|
-
borderColor: "$color6",
|
|
534
629
|
...(stripe === "odd" ? {
|
|
535
630
|
backgroundColor: tableZebraFill(knobProps.cardSurface.backgroundColor)
|
|
536
631
|
} : {}),
|
|
537
632
|
...(row.intent ? {
|
|
538
633
|
backgroundColor: "$color3"
|
|
539
634
|
} : {}),
|
|
635
|
+
...(edgeInset ? phoneBleedRowProps(edgeInset) : {
|
|
636
|
+
elevation: knobProps.elevation,
|
|
637
|
+
borderColor: (0, import_theme.edgeColorAt)("$color6", knobProps.borderWidthStop)
|
|
638
|
+
}),
|
|
540
639
|
...{
|
|
541
640
|
"data-table-zebra": stripe
|
|
542
641
|
},
|
|
@@ -547,7 +646,7 @@ function TableCardsList({
|
|
|
547
646
|
alignItems: "center",
|
|
548
647
|
gap: "$2",
|
|
549
648
|
paddingVertical: "$1.5",
|
|
550
|
-
children: [label != null && /* @__PURE__ */(0, import_jsx_runtime.jsx)(
|
|
649
|
+
children: [label != null && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.SizableText, {
|
|
551
650
|
fontSize: knobProps.sizeToken,
|
|
552
651
|
color: knobProps.textAccentColor,
|
|
553
652
|
width: "40%",
|
|
@@ -589,6 +688,7 @@ function ThemedTableComp({
|
|
|
589
688
|
}
|
|
590
689
|
function ThemedTableFrame({
|
|
591
690
|
layout = "table",
|
|
691
|
+
edgeInset,
|
|
592
692
|
...props
|
|
593
693
|
}) {
|
|
594
694
|
const {
|
|
@@ -597,35 +697,70 @@ function ThemedTableFrame({
|
|
|
597
697
|
const {
|
|
598
698
|
sm
|
|
599
699
|
} = (0, import_tamagui.useMedia)();
|
|
700
|
+
const bleed = (0, import_theme.usePhoneTableBleed)();
|
|
701
|
+
const selfBleed = edgeInset === void 0 ? bleed : null;
|
|
702
|
+
const inset = edgeInset === void 0 ? bleed?.inset ?? null : edgeInset;
|
|
600
703
|
const resolvedBorderWidth = knobProps.surface.borderWidth;
|
|
601
704
|
const showCards = layout === "cards" || layout === "auto" && sm === false;
|
|
602
705
|
if (showCards) {
|
|
603
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(
|
|
604
|
-
|
|
706
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.PageGutter, {
|
|
707
|
+
inset: null,
|
|
708
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableCardsList, {
|
|
709
|
+
...props,
|
|
710
|
+
edgeInset: inset,
|
|
711
|
+
selfBleed
|
|
712
|
+
})
|
|
605
713
|
});
|
|
606
714
|
}
|
|
607
715
|
const motion = (0, import_theme.transitionProps)(knobProps.motion.control);
|
|
716
|
+
const table = /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableComp, {
|
|
717
|
+
...knobProps.surface,
|
|
718
|
+
...knobProps.borderRadiusNested,
|
|
719
|
+
borderWidth: resolvedBorderWidth,
|
|
720
|
+
elevation: knobProps.elevation,
|
|
721
|
+
...motion,
|
|
722
|
+
cellHeight: knobProps.sizeToken,
|
|
723
|
+
...{
|
|
724
|
+
"data-animation": knobProps.motion.control.transition ? "on" : "none"
|
|
725
|
+
},
|
|
726
|
+
...props,
|
|
727
|
+
...(inset ? {
|
|
728
|
+
borderLeftWidth: 0,
|
|
729
|
+
borderRightWidth: 0,
|
|
730
|
+
borderRadius: 0,
|
|
731
|
+
...{
|
|
732
|
+
"data-phone-bleed": "true"
|
|
733
|
+
}
|
|
734
|
+
} : {}),
|
|
735
|
+
style: [{
|
|
736
|
+
tableLayout: "fixed",
|
|
737
|
+
borderSpacing: 0
|
|
738
|
+
}, props.style],
|
|
739
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableEdgeInset, {
|
|
740
|
+
inset,
|
|
741
|
+
children: props.children
|
|
742
|
+
})
|
|
743
|
+
});
|
|
608
744
|
return (
|
|
609
745
|
// A table nested in a body cell must not stripe its rows by the outer index.
|
|
610
746
|
/* @__PURE__ */
|
|
611
747
|
(0, import_jsx_runtime.jsx)(BodyRowIndexContext.Provider, {
|
|
612
748
|
value: void 0,
|
|
613
|
-
children:
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
...
|
|
619
|
-
|
|
620
|
-
...{
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
})
|
|
749
|
+
children: selfBleed ?
|
|
750
|
+
// The table keeps width 100%, which ignores a negative end margin, so
|
|
751
|
+
// a plain stack takes the bleed and the table fills it.
|
|
752
|
+
/* @__PURE__ */
|
|
753
|
+
(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
754
|
+
...selfBleed.frame,
|
|
755
|
+
alignSelf: "stretch",
|
|
756
|
+
...((props.displayMode ?? (import_tamagui.isWeb ? "table" : "flex")) === "flex" ? {
|
|
757
|
+
flexGrow: 1,
|
|
758
|
+
flexShrink: 1,
|
|
759
|
+
flexBasis: "auto",
|
|
760
|
+
minHeight: 0
|
|
761
|
+
} : {}),
|
|
762
|
+
children: table
|
|
763
|
+
}) : table
|
|
629
764
|
})
|
|
630
765
|
);
|
|
631
766
|
}
|
|
@@ -657,6 +792,8 @@ function ThemedRow({
|
|
|
657
792
|
knobProps
|
|
658
793
|
} = (0, import_theme.useResolvedKnobs)();
|
|
659
794
|
const context = TableContext.useStyledContext();
|
|
795
|
+
const edgeInset = (0, import_react.useContext)(TableEdgeInsetContext);
|
|
796
|
+
const children = edgeInset && props.role !== "presentation" ? markEdgeCells(props.children) : props.children;
|
|
660
797
|
const motion = (0, import_theme.transitionProps)(knobProps.motion.control);
|
|
661
798
|
const intent = resolveIntent({
|
|
662
799
|
accent,
|
|
@@ -688,7 +825,8 @@ function ThemedRow({
|
|
|
688
825
|
...props,
|
|
689
826
|
...(stripe === "odd" && !intent && props.backgroundColor == null ? {
|
|
690
827
|
backgroundColor: tableZebraFill(knobProps.surface.backgroundColor)
|
|
691
|
-
} : {})
|
|
828
|
+
} : {}),
|
|
829
|
+
children
|
|
692
830
|
});
|
|
693
831
|
if (intent) {
|
|
694
832
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Theme, {
|
|
@@ -742,6 +880,19 @@ function TableCellSurfaceBody({
|
|
|
742
880
|
children: label
|
|
743
881
|
}, key));
|
|
744
882
|
}
|
|
883
|
+
function useCellEdgePadding(own, base) {
|
|
884
|
+
const inset = (0, import_react.useContext)(TableEdgeInsetContext);
|
|
885
|
+
const edge = (0, import_react.useContext)(CellEdgeContext);
|
|
886
|
+
if (!inset || !edge) return null;
|
|
887
|
+
return {
|
|
888
|
+
...cellEdgePadding(edge, inset, {
|
|
889
|
+
paddingHorizontal: own.paddingHorizontal ?? base.paddingHorizontal,
|
|
890
|
+
paddingLeft: own.paddingLeft,
|
|
891
|
+
paddingRight: own.paddingRight
|
|
892
|
+
}),
|
|
893
|
+
"data-cell-edge": edge
|
|
894
|
+
};
|
|
895
|
+
}
|
|
745
896
|
function ThemedCell({
|
|
746
897
|
children,
|
|
747
898
|
style,
|
|
@@ -751,13 +902,16 @@ function ThemedCell({
|
|
|
751
902
|
knobProps
|
|
752
903
|
} = (0, import_theme.useResolvedKnobs)();
|
|
753
904
|
const motion = (0, import_theme.transitionProps)(knobProps.motion.control);
|
|
905
|
+
const base = getTableCellPadding((0, import_theme.sizeTokenStop)(knobProps.sizeToken));
|
|
906
|
+
const edgePadding = useCellEdgePadding(props, base);
|
|
754
907
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Cell, {
|
|
755
|
-
...
|
|
908
|
+
...base,
|
|
756
909
|
...motion,
|
|
757
910
|
...{
|
|
758
911
|
"data-animation": knobProps.motion.control.transition ? "on" : "none"
|
|
759
912
|
},
|
|
760
913
|
...props,
|
|
914
|
+
...edgePadding,
|
|
761
915
|
style: [{
|
|
762
916
|
verticalAlign: "middle"
|
|
763
917
|
}, style],
|
|
@@ -776,13 +930,16 @@ function ThemedHeaderCell({
|
|
|
776
930
|
knobProps
|
|
777
931
|
} = (0, import_theme.useResolvedKnobs)();
|
|
778
932
|
const motion = (0, import_theme.transitionProps)(knobProps.motion.control);
|
|
933
|
+
const base = getTableCellPadding((0, import_theme.sizeTokenStop)(knobProps.sizeToken));
|
|
934
|
+
const edgePadding = useCellEdgePadding(props, base);
|
|
779
935
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(HeaderCell, {
|
|
780
|
-
...
|
|
936
|
+
...base,
|
|
781
937
|
...motion,
|
|
782
938
|
...{
|
|
783
939
|
"data-animation": knobProps.motion.control.transition ? "on" : "none"
|
|
784
940
|
},
|
|
785
941
|
...props,
|
|
942
|
+
...edgePadding,
|
|
786
943
|
style: [{
|
|
787
944
|
verticalAlign: "middle",
|
|
788
945
|
fontWeight: "normal",
|