@multiplatform.one/table-primitives 6.7.0 → 7.1.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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * LC-82 TEXT-RIDES-TEXT (catalog arm) — wrap-and-coalesce for child slots
3
+ * that render into Views. Local copy of the reference remedy in
4
+ * `public/forms/src/Button/index.tsx` (table-primitives is Layer 1 — it
5
+ * depends only on theme + tamagui, so the helper cannot be imported from
6
+ * forms or components): runs of adjacent bare string/number children
7
+ * coalesce into one concatenated label handed to the slot's own Text
8
+ * wrapper; element children pass through untouched, order preserved.
9
+ */
10
+
11
+ import type { ReactNode } from "react";
12
+ import { Children } from "react";
13
+
14
+ /** Bare string/number children are legal only inside Text. */
15
+ export const isBareTextChild = (child: unknown): child is string | number =>
16
+ typeof child === "string" || typeof child === "number";
17
+
18
+ function coalesceBareTextRuns(
19
+ children: ReturnType<typeof Children.toArray>,
20
+ renderLabel: (label: string, key: string) => ReactNode,
21
+ ): ReactNode[] {
22
+ const out: ReactNode[] = [];
23
+ let run: string | undefined;
24
+ let runIndex = 0;
25
+ const flushRun = () => {
26
+ if (run !== undefined && run !== "") out.push(renderLabel(run, `lc50-run-${runIndex++}`));
27
+ run = undefined;
28
+ };
29
+ for (const child of children) {
30
+ if (isBareTextChild(child)) {
31
+ run = (run ?? "") + String(child);
32
+ } else {
33
+ flushRun();
34
+ out.push(child);
35
+ }
36
+ }
37
+ flushRun();
38
+ return out;
39
+ }
40
+
41
+ /**
42
+ * Wrap ALL bare string/number children of a View-rendering slot: singleton
43
+ * strings/numbers and runs inside arrays go through `renderLabel` (the slot's
44
+ * Text wrapper); pure-element children return unchanged.
45
+ */
46
+ export function wrapBareTextChildren(
47
+ children: ReactNode,
48
+ renderLabel: (label: string, key?: string) => ReactNode,
49
+ ): ReactNode {
50
+ if (isBareTextChild(children)) return renderLabel(String(children));
51
+ if (Array.isArray(children)) {
52
+ const flattened = Children.toArray(children);
53
+ if (flattened.some(isBareTextChild)) return coalesceBareTextRuns(flattened, renderLabel);
54
+ }
55
+ return children;
56
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,SAAS,CAAC;AAY1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7F,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IAC9B,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;CAC/B,CAAC;AA6BF;;;;;;;;;;GAUG;AAEH,uBAAuB;AACvB,QAAA,MAAM,GAAG;;;;;;;;;;6CAsBP,CAAC;AAEH,QAAA,MAAM,IAAI;;;;;;;;;;;;;6CA4DR,CAAC;AAEH,QAAA,MAAM,UAAU;;;;;;;;;;;;;6CA6Dd,CAAC;AAEH,QAAA,MAAM,SAAS;;;;;;;;;6CAyBb,CAAC;AAEH,QAAA,MAAM,SAAS;;;;;;;;;6CAmBb,CAAC;AAEH,QAAA,MAAM,SAAS;;;;;;;;;6CAiBb,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;6CAUhB,CAAC;AAEH,QAAA,MAAM,SAAS;;;;;;;;;;;;;6CAsCb,CAAC;AAKH,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAUD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KA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MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAC/D,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAC3E,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;AACpE,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * LC-82 TEXT-RIDES-TEXT (catalog arm) — wrap-and-coalesce for child slots
3
+ * that render into Views. Local copy of the reference remedy in
4
+ * `public/forms/src/Button/index.tsx` (table-primitives is Layer 1 — it
5
+ * depends only on theme + tamagui, so the helper cannot be imported from
6
+ * forms or components): runs of adjacent bare string/number children
7
+ * coalesce into one concatenated label handed to the slot's own Text
8
+ * wrapper; element children pass through untouched, order preserved.
9
+ */
10
+ import type { ReactNode } from "react";
11
+ /** Bare string/number children are legal only inside Text. */
12
+ export declare const isBareTextChild: (child: unknown) => child is string | number;
13
+ /**
14
+ * Wrap ALL bare string/number children of a View-rendering slot: singleton
15
+ * strings/numbers and runs inside arrays go through `renderLabel` (the slot's
16
+ * Text wrapper); pure-element children return unchanged.
17
+ */
18
+ export declare function wrapBareTextChildren(children: ReactNode, renderLabel: (label: string, key?: string) => ReactNode): ReactNode;
19
+ //# sourceMappingURL=textRidesText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textRidesText.d.ts","sourceRoot":"","sources":["../src/textRidesText.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,8DAA8D;AAC9D,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,GAAG,MACX,CAAC;AAyBzD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,SAAS,GACtD,SAAS,CAOX"}