@multiplatform.one/theme 7.78.0 → 7.79.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/theme",
3
- "version": "7.78.0",
3
+ "version": "7.79.0",
4
4
  "description": "Tamagui theme system for multiplatform.one",
5
5
  "keywords": [
6
6
  "multiplatform",
@@ -72,8 +72,8 @@
72
72
  "access": "public"
73
73
  },
74
74
  "dependencies": {
75
- "@multiplatform.one/platform": "^7.78.0",
76
- "@multiplatform.one/store": "^7.78.0",
75
+ "@multiplatform.one/platform": "^7.79.0",
76
+ "@multiplatform.one/store": "^7.79.0",
77
77
  "@tamagui/animations-react-native": "2.7.6",
78
78
  "@tamagui/colors": "2.7.6",
79
79
  "@tamagui/config": "2.7.6",
@@ -89,8 +89,8 @@
89
89
  },
90
90
  "devDependencies": {
91
91
  "@expo/prebuild-config": "55.0.18",
92
- "@multiplatform.one/config": "7.78.0",
93
- "@multiplatform.one/test-utils": "7.78.0",
92
+ "@multiplatform.one/config": "7.79.0",
93
+ "@multiplatform.one/test-utils": "7.79.0",
94
94
  "@tamagui/animations-css": "2.7.6",
95
95
  "@tamagui/animations-reanimated": "2.7.6",
96
96
  "@tamagui/font-inter": "2.7.6",
@@ -43,6 +43,7 @@ export * from "./scale/index";
43
43
  export * from "./shared";
44
44
  export * from "./themeValue";
45
45
  export * from "./sizeRecipes";
46
+ export * from "./listRows";
46
47
  export * from "./subsetThemes";
47
48
  export * from "./Surface";
48
49
  export * from "./Text";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * LC-222 LIST-HEIGHT-IN-ROWS: an embedded list's cap is a row count at its
3
+ * row pitch, so every size step and the touch scale show the same visible
4
+ * rows where a pixel cap would show more or fewer.
5
+ */
6
+ import { describe, expect, it } from "vitest";
7
+ import { listHeightForRows, menuListHeight, rowsInListHeight } from "./listRows";
8
+ import { SIZE_RECIPE_TOKENS, sizeRecipeForToken } from "./sizeRecipes";
9
+
10
+ describe("listHeightForRows (LC-222)", () => {
11
+ it("is rows times pitch plus the separators between them", () => {
12
+ expect(listHeightForRows(8, 36)).toBe(288);
13
+ expect(listHeightForRows(3, 40, 1)).toBe(122);
14
+ expect(listHeightForRows(0, 40, 1)).toBe(0);
15
+ expect(rowsInListHeight(122, 40, 1)).toBe(3);
16
+ });
17
+
18
+ it("shows the same visible rows on every size step and on touch", () => {
19
+ const counts = new Set<number>();
20
+ const pixelCapCounts = new Set<number>();
21
+ for (const token of SIZE_RECIPE_TOKENS) {
22
+ for (const touch of [false, true]) {
23
+ const pitch = sizeRecipeForToken(token, { touch, family: "menuRow" }).height;
24
+ counts.add(rowsInListHeight(menuListHeight(8, token, { touch }), pitch));
25
+ pixelCapCounts.add(rowsInListHeight(320, pitch));
26
+ }
27
+ }
28
+ expect([...counts]).toEqual([8]);
29
+ expect(pixelCapCounts.size).toBeGreaterThan(1);
30
+ });
31
+ });
@@ -0,0 +1,22 @@
1
+ import { sizeRecipeForToken } from "./sizeRecipes";
2
+
3
+ /**
4
+ * LC-222 LIST-HEIGHT-IN-ROWS: an embedded list's bounded height is a count of
5
+ * visible rows at its row pitch, never pixels, so every preset scale shows the
6
+ * same number of rows. `separator` is the hairline between rows, if any.
7
+ */
8
+ export function listHeightForRows(rows: number, rowPitch: number, separator = 0): number {
9
+ const count = Math.max(0, Math.floor(rows));
10
+ return count * rowPitch + Math.max(count - 1, 0) * separator;
11
+ }
12
+
13
+ /** Visible rows a list of `height` shows at `rowPitch`; the inverse of listHeightForRows. */
14
+ export function rowsInListHeight(height: number, rowPitch: number, separator = 0): number {
15
+ return rowPitch > 0 ? Math.floor((height + separator) / (rowPitch + separator)) : 0;
16
+ }
17
+
18
+ /** Height of `rows` menu or listbox rows at a size token (the menuRow recipe pitch). */
19
+ export function menuListHeight(rows: number, sizeToken: string, options?: { touch?: boolean }) {
20
+ const pitch = sizeRecipeForToken(sizeToken, { touch: options?.touch, family: "menuRow" }).height;
21
+ return listHeightForRows(rows, pitch);
22
+ }
@@ -43,6 +43,7 @@ export * from "./scale/index";
43
43
  export * from "./shared";
44
44
  export * from "./themeValue";
45
45
  export * from "./sizeRecipes";
46
+ export * from "./listRows";
46
47
  export * from "./subsetThemes";
47
48
  export * from "./Surface";
48
49
  export * from "./Text";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,MAAM,IAAI,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjF,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,C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AoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAElC,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,eAAe,IAAI,kBAAkB,EACrC,kBAAkB,EAClB,WAAW,EACX,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,cAAc,YAAY,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * LC-222 LIST-HEIGHT-IN-ROWS: an embedded list's bounded height is a count of
3
+ * visible rows at its row pitch, never pixels, so every preset scale shows the
4
+ * same number of rows. `separator` is the hairline between rows, if any.
5
+ */
6
+ export declare function listHeightForRows(rows: number, rowPitch: number, separator?: number): number;
7
+ /** Visible rows a list of `height` shows at `rowPitch`; the inverse of listHeightForRows. */
8
+ export declare function rowsInListHeight(height: number, rowPitch: number, separator?: number): number;
9
+ /** Height of `rows` menu or listbox rows at a size token (the menuRow recipe pitch). */
10
+ export declare function menuListHeight(rows: number, sizeToken: string, options?: {
11
+ touch?: boolean;
12
+ }): number;
13
+ //# sourceMappingURL=listRows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listRows.d.ts","sourceRoot":"","sources":["../../src/theme/listRows.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAGvF;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAExF;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,UAG5F"}