@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.
@@ -26,13 +26,18 @@ var index_exports = {};
26
26
  __export(index_exports, {
27
27
  Table: () => Table,
28
28
  TableCellContext: () => import_tableCellContext2.TableCellContext,
29
+ TableEdgeCells: () => TableEdgeCells,
30
+ TableEdgeInset: () => TableEdgeInset,
29
31
  getTableCellPadding: () => getTableCellPadding,
30
32
  isBareTextChild: () => import_textRidesText2.isBareTextChild,
33
+ phoneBleedListProps: () => phoneBleedListProps,
34
+ phoneBleedRowProps: () => phoneBleedRowProps,
31
35
  tablePressFill: () => tablePressFill,
32
36
  tableZebraFill: () => tableZebraFill,
33
37
  tableZebraStripe: () => tableZebraStripe,
34
38
  useIsInTableCell: () => import_tableCellContext2.useIsInTableCell,
35
39
  useTableCellContext: () => import_tableCellContext2.useTableCellContext,
40
+ useTableEdgeInset: () => useTableEdgeInset,
36
41
  wrapBareTextChildren: () => import_textRidesText2.wrapBareTextChildren
37
42
  });
38
43
  module.exports = __toCommonJS(index_exports);
@@ -306,6 +311,88 @@ function tablePressFill(restFill) {
306
311
  if (step >= 12) return "$color11";
307
312
  return `$color${Math.max(step + 1, 4)}`;
308
313
  }
314
+ var TableEdgeInsetContext = /* @__PURE__ */(0, import_react.createContext)(null);
315
+ var CellEdgeContext = /* @__PURE__ */(0, import_react.createContext)(void 0);
316
+ function useTableEdgeInset() {
317
+ return (0, import_react.useContext)(TableEdgeInsetContext);
318
+ }
319
+ function TableEdgeInset(param) {
320
+ var {
321
+ inset,
322
+ children
323
+ } = param;
324
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableEdgeInsetContext.Provider, {
325
+ value: inset,
326
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.PageGutter, {
327
+ inset: null,
328
+ children
329
+ })
330
+ });
331
+ }
332
+ function isRtlDocument() {
333
+ var _document_documentElement;
334
+ return import_tamagui.isWeb && typeof document !== "undefined" && ((_document_documentElement = document.documentElement) === null || _document_documentElement === void 0 ? void 0 : _document_documentElement.dir) === "rtl";
335
+ }
336
+ function cellEdgePadding(edge, inset, own) {
337
+ var _own_paddingLeft, _own_paddingRight;
338
+ var start = edge === "first" || edge === "only";
339
+ var end = edge === "last" || edge === "only";
340
+ if (!import_tamagui.isWeb) {
341
+ return {
342
+ ...(start ? {
343
+ paddingStart: inset
344
+ } : {}),
345
+ ...(end ? {
346
+ paddingEnd: inset
347
+ } : {})
348
+ };
349
+ }
350
+ var rtl = isRtlDocument();
351
+ var left = rtl ? end : start;
352
+ var right = rtl ? start : end;
353
+ return {
354
+ paddingLeft: left ? inset : (_own_paddingLeft = own.paddingLeft) !== null && _own_paddingLeft !== void 0 ? _own_paddingLeft : own.paddingHorizontal,
355
+ paddingRight: right ? inset : (_own_paddingRight = own.paddingRight) !== null && _own_paddingRight !== void 0 ? _own_paddingRight : own.paddingHorizontal
356
+ };
357
+ }
358
+ function markEdgeCells(children) {
359
+ var cells = flattenChildren(children).filter(import_react.isValidElement);
360
+ return cells.map(function (cell, index) {
361
+ var _cell_key;
362
+ var edge = cells.length === 1 ? "only" : index === 0 ? "first" : index === cells.length - 1 ? "last" : void 0;
363
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CellEdgeContext.Provider, {
364
+ value: edge,
365
+ children: cell
366
+ }, (_cell_key = cell.key) !== null && _cell_key !== void 0 ? _cell_key : index);
367
+ });
368
+ }
369
+ function TableEdgeCells(param) {
370
+ var {
371
+ children
372
+ } = param;
373
+ var inset = (0, import_react.useContext)(TableEdgeInsetContext);
374
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
375
+ children: inset ? markEdgeCells(children) : children
376
+ });
377
+ }
378
+ function phoneBleedRowProps(inset) {
379
+ return {
380
+ borderRadius: 0,
381
+ borderWidth: 0,
382
+ ...import_theme.hairline.bottom,
383
+ borderColor: "$borderColor",
384
+ elevation: 0,
385
+ shadowColor: "transparent",
386
+ paddingLeft: inset,
387
+ paddingRight: inset
388
+ };
389
+ }
390
+ function phoneBleedListProps(bleed) {
391
+ return {
392
+ ...(bleed ? bleed.frame : {}),
393
+ gap: 0
394
+ };
395
+ }
309
396
  var BodyRowIndexContext = /* @__PURE__ */(0, import_react.createContext)(void 0);
310
397
  function indexBodyRows(children, counter) {
311
398
  return import_react.Children.map(children, function (child) {
@@ -315,6 +402,7 @@ function indexBodyRows(children, counter) {
315
402
  children: indexBodyRows(child.props.children, counter)
316
403
  });
317
404
  }
405
+ if (child.props["aria-hidden"] === true) return child;
318
406
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(BodyRowIndexContext.Provider, {
319
407
  value: counter.next++,
320
408
  children: child
@@ -599,6 +687,8 @@ function extractCardModel(children) {
599
687
  function TableCardsList(param) {
600
688
  var {
601
689
  children,
690
+ edgeInset,
691
+ selfBleed,
602
692
  ...props
603
693
  } = param;
604
694
  var {
@@ -628,25 +718,39 @@ function TableCardsList(param) {
628
718
  "data-animation": knobProps.motion.control.transition ? "on" : "none"
629
719
  },
630
720
  ...viewProps,
631
- children: [caption != null && (typeof caption === "string" || typeof caption === "number" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.SizableText, {
632
- fontSize: knobProps.sizeToken,
633
- color: "$color10",
634
- children: caption
635
- }) : caption), rows.map(function (row, rowIndex) {
721
+ ...(edgeInset ? phoneBleedListProps(selfBleed !== null && selfBleed !== void 0 ? selfBleed : null) : {}),
722
+ ...(edgeInset ? {
723
+ "data-phone-bleed": "true"
724
+ } : {}),
725
+ children: [caption != null &&
726
+ // LC-146: the caption stays on the page line while the cards bleed.
727
+ /* @__PURE__ */
728
+ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
729
+ ...(edgeInset ? {
730
+ paddingHorizontal: edgeInset
731
+ } : {}),
732
+ children: typeof caption === "string" || typeof caption === "number" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.SizableText, {
733
+ fontSize: knobProps.sizeToken,
734
+ color: "$color10",
735
+ children: caption
736
+ }) : caption
737
+ }), rows.map(function (row, rowIndex) {
636
738
  var stripe = tableZebraStripe(knobProps.tableZebra, rowIndex);
637
739
  var card = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.ThemeableStack, {
638
740
  testID: "table-card",
639
741
  ...knobProps.surface,
640
742
  ...knobProps.cardSurface,
641
- elevation: knobProps.elevation,
642
743
  ...motion,
643
- borderColor: "$color6",
644
744
  ...(stripe === "odd" ? {
645
745
  backgroundColor: tableZebraFill(knobProps.cardSurface.backgroundColor)
646
746
  } : {}),
647
747
  ...(row.intent ? {
648
748
  backgroundColor: "$color3"
649
749
  } : {}),
750
+ ...(edgeInset ? phoneBleedRowProps(edgeInset) : {
751
+ elevation: knobProps.elevation,
752
+ borderColor: (0, import_theme.edgeColorAt)("$color6", knobProps.borderWidthStop)
753
+ }),
650
754
  ...{
651
755
  "data-table-zebra": stripe
652
756
  },
@@ -657,7 +761,7 @@ function TableCardsList(param) {
657
761
  alignItems: "center",
658
762
  gap: "$2",
659
763
  paddingVertical: "$1.5",
660
- children: [label != null && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.SizableText, {
764
+ children: [label != null && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.SizableText, {
661
765
  fontSize: knobProps.sizeToken,
662
766
  color: knobProps.textAccentColor,
663
767
  width: "40%",
@@ -702,51 +806,89 @@ function ThemedTableComp(param) {
702
806
  function ThemedTableFrame(param) {
703
807
  var {
704
808
  layout = "table",
809
+ edgeInset,
705
810
  ...props
706
811
  } = param;
812
+ var _ref, _props_displayMode;
707
813
  var {
708
814
  knobProps
709
815
  } = (0, import_theme.useResolvedKnobs)();
710
816
  var {
711
817
  sm
712
818
  } = (0, import_tamagui.useMedia)();
819
+ var bleed = (0, import_theme.usePhoneTableBleed)();
820
+ var selfBleed = edgeInset === void 0 ? bleed : null;
821
+ var inset = edgeInset === void 0 ? (_ref = bleed === null || bleed === void 0 ? void 0 : bleed.inset) !== null && _ref !== void 0 ? _ref : null : edgeInset;
713
822
  var resolvedBorderWidth = knobProps.surface.borderWidth;
714
823
  var showCards = layout === "cards" || layout === "auto" && sm === false;
715
824
  if (showCards) {
716
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableCardsList, {
717
- ...props
825
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.PageGutter, {
826
+ inset: null,
827
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableCardsList, {
828
+ ...props,
829
+ edgeInset: inset,
830
+ selfBleed
831
+ })
718
832
  });
719
833
  }
720
834
  var motion = (0, import_theme.transitionProps)(knobProps.motion.control);
835
+ var table = /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableComp, {
836
+ // Table frames are R-OUTER + SF-CARD-tier surface (theme-propagation-spec
837
+ // `@multiplatform.one/table-primitives`): outer corners follow the capped
838
+ // outer radius map; like the card list, the fill never takes the
839
+ // control flip.
840
+ ...knobProps.surface,
841
+ ...knobProps.borderRadiusNested,
842
+ borderWidth: resolvedBorderWidth,
843
+ elevation: knobProps.elevation,
844
+ ...motion,
845
+ // Size knob sets default row height through the table context; consumer
846
+ // cellHeight (table- or cell-level) still overrides via {...props}.
847
+ cellHeight: knobProps.sizeToken,
848
+ ...{
849
+ "data-animation": knobProps.motion.control.transition ? "on" : "none"
850
+ },
851
+ ...props,
852
+ // A full-bleed table has no side frame: the screen edge is its edge.
853
+ ...(inset ? {
854
+ borderLeftWidth: 0,
855
+ borderRightWidth: 0,
856
+ borderRadius: 0,
857
+ ...{
858
+ "data-phone-bleed": "true"
859
+ }
860
+ } : {}),
861
+ // borderSpacing 0 neutralizes the real <table> UA default (2px gaps
862
+ // between cells) so the migrated element keeps the div-table look.
863
+ style: [{
864
+ tableLayout: "fixed",
865
+ borderSpacing: 0
866
+ }, props.style],
867
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableEdgeInset, {
868
+ inset,
869
+ children: props.children
870
+ })
871
+ });
721
872
  return (
722
873
  // A table nested in a body cell must not stripe its rows by the outer index.
723
874
  /* @__PURE__ */
724
875
  (0, import_jsx_runtime.jsx)(BodyRowIndexContext.Provider, {
725
876
  value: void 0,
726
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TableComp, {
727
- // Table frames are R-OUTER + SF-CARD-tier surface (theme-propagation-spec
728
- // `@multiplatform.one/table-primitives`): outer corners follow the capped
729
- // outer radius map; like the card list, the fill never takes the
730
- // control flip.
731
- ...knobProps.surface,
732
- ...knobProps.borderRadiusNested,
733
- borderWidth: resolvedBorderWidth,
734
- elevation: knobProps.elevation,
735
- ...motion,
736
- // Size knob sets default row height through the table context; consumer
737
- // cellHeight (table- or cell-level) still overrides via {...props}.
738
- cellHeight: knobProps.sizeToken,
739
- ...{
740
- "data-animation": knobProps.motion.control.transition ? "on" : "none"
741
- },
742
- ...props,
743
- // borderSpacing 0 neutralizes the real <table> UA default (2px gaps
744
- // between cells) so the migrated element keeps the div-table look.
745
- style: [{
746
- tableLayout: "fixed",
747
- borderSpacing: 0
748
- }, props.style]
749
- })
877
+ children: selfBleed ?
878
+ // The table keeps width 100%, which ignores a negative end margin, so
879
+ // a plain stack takes the bleed and the table fills it.
880
+ /* @__PURE__ */
881
+ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
882
+ ...selfBleed.frame,
883
+ alignSelf: "stretch",
884
+ ...(((_props_displayMode = props.displayMode) !== null && _props_displayMode !== void 0 ? _props_displayMode : import_tamagui.isWeb ? "table" : "flex") === "flex" ? {
885
+ flexGrow: 1,
886
+ flexShrink: 1,
887
+ flexBasis: "auto",
888
+ minHeight: 0
889
+ } : {}),
890
+ children: table
891
+ }) : table
750
892
  })
751
893
  );
752
894
  }
@@ -781,6 +923,8 @@ function ThemedRow(param) {
781
923
  knobProps
782
924
  } = (0, import_theme.useResolvedKnobs)();
783
925
  var context = TableContext.useStyledContext();
926
+ var edgeInset = (0, import_react.useContext)(TableEdgeInsetContext);
927
+ var children = edgeInset && props.role !== "presentation" ? markEdgeCells(props.children) : props.children;
784
928
  var motion = (0, import_theme.transitionProps)(knobProps.motion.control);
785
929
  var intent = resolveIntent({
786
930
  accent,
@@ -812,7 +956,8 @@ function ThemedRow(param) {
812
956
  ...props,
813
957
  ...(stripe === "odd" && !intent && props.backgroundColor == null ? {
814
958
  backgroundColor: tableZebraFill(knobProps.surface.backgroundColor)
815
- } : {})
959
+ } : {}),
960
+ children
816
961
  });
817
962
  if (intent) {
818
963
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Theme, {
@@ -872,6 +1017,20 @@ function TableCellSurfaceBody(param) {
872
1017
  }, key);
873
1018
  });
874
1019
  }
1020
+ function useCellEdgePadding(own, base) {
1021
+ var _own_paddingHorizontal;
1022
+ var inset = (0, import_react.useContext)(TableEdgeInsetContext);
1023
+ var edge = (0, import_react.useContext)(CellEdgeContext);
1024
+ if (!inset || !edge) return null;
1025
+ return {
1026
+ ...cellEdgePadding(edge, inset, {
1027
+ paddingHorizontal: (_own_paddingHorizontal = own.paddingHorizontal) !== null && _own_paddingHorizontal !== void 0 ? _own_paddingHorizontal : base.paddingHorizontal,
1028
+ paddingLeft: own.paddingLeft,
1029
+ paddingRight: own.paddingRight
1030
+ }),
1031
+ "data-cell-edge": edge
1032
+ };
1033
+ }
875
1034
  function ThemedCell(param) {
876
1035
  var {
877
1036
  children,
@@ -882,13 +1041,16 @@ function ThemedCell(param) {
882
1041
  knobProps
883
1042
  } = (0, import_theme.useResolvedKnobs)();
884
1043
  var motion = (0, import_theme.transitionProps)(knobProps.motion.control);
1044
+ var base = getTableCellPadding((0, import_theme.sizeTokenStop)(knobProps.sizeToken));
1045
+ var edgePadding = useCellEdgePadding(props, base);
885
1046
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Cell, {
886
- ...getTableCellPadding((0, import_theme.sizeTokenStop)(knobProps.sizeToken)),
1047
+ ...base,
887
1048
  ...motion,
888
1049
  ...{
889
1050
  "data-animation": knobProps.motion.control.transition ? "on" : "none"
890
1051
  },
891
1052
  ...props,
1053
+ ...edgePadding,
892
1054
  // Compose (not replace) the inline style so a consumer style (e.g.
893
1055
  // sticky pinned cells) keeps the verticalAlign baseline.
894
1056
  style: [{
@@ -910,13 +1072,16 @@ function ThemedHeaderCell(param) {
910
1072
  knobProps
911
1073
  } = (0, import_theme.useResolvedKnobs)();
912
1074
  var motion = (0, import_theme.transitionProps)(knobProps.motion.control);
1075
+ var base = getTableCellPadding((0, import_theme.sizeTokenStop)(knobProps.sizeToken));
1076
+ var edgePadding = useCellEdgePadding(props, base);
913
1077
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(HeaderCell, {
914
- ...getTableCellPadding((0, import_theme.sizeTokenStop)(knobProps.sizeToken)),
1078
+ ...base,
915
1079
  ...motion,
916
1080
  ...{
917
1081
  "data-animation": knobProps.motion.control.transition ? "on" : "none"
918
1082
  },
919
1083
  ...props,
1084
+ ...edgePadding,
920
1085
  // Compose (not replace) the inline style so consumer styles (sticky
921
1086
  // pinned headers) keep the real-<th> UA neutralizers (bold/centered).
922
1087
  style: [{