@mindees/atlas 0.1.0 → 0.3.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/for.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { KeyedRegion, MindeesNode } from "@mindees/core";
2
+
3
+ //#region src/for.d.ts
4
+ /** Props for {@link For}. */
5
+ interface ForProps<T> {
6
+ /** The items, static or reactive. */
7
+ readonly each: readonly T[] | (() => readonly T[]);
8
+ /** Render one row from reactive `item`/`index` accessors. */
9
+ readonly children: (item: () => T, index: () => number) => MindeesNode;
10
+ /** Stable key per item (defaults to item identity). Provide it for primitive/object lists that change shape. */
11
+ readonly key?: (item: T, index: number) => unknown;
12
+ /** Rendered when the list is empty. */
13
+ readonly fallback?: () => MindeesNode;
14
+ }
15
+ /** A keyed, identity-preserving list. Returns a {@link KeyedRegion} node the renderer reconciles. */
16
+ declare function For<T>(props: ForProps<T>): KeyedRegion<T>;
17
+ //#endregion
18
+ export { For, ForProps };
19
+ //# sourceMappingURL=for.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"for.d.ts","names":[],"sources":["../src/for.ts"],"mappings":";;;;UAoBiB,QAAA;EAIiB;EAAA,SAFvB,IAAA,WAAe,CAAA,qBAAsB,CAAA;EAEX;EAAA,SAA1B,QAAA,GAAW,IAAA,QAAY,CAAA,EAAG,KAAA,mBAAwB,WAAA;EAElD;EAAA,SAAA,GAAA,IAAO,IAAA,EAAM,CAAA,EAAG,KAAA;EAAT;EAAA,SAEP,QAAA,SAAiB,WAAA;AAAA;;iBAIZ,GAAA,IAAO,KAAA,EAAO,QAAA,CAAS,CAAA,IAAK,WAAA,CAAY,CAAA"}
package/dist/for.js ADDED
@@ -0,0 +1,26 @@
1
+ import { keyedRegion } from "@mindees/core";
2
+ //#region src/for.ts
3
+ /**
4
+ * Atlas `For` — the ergonomic, keyed list component (on the `@mindees/atlas/for` subpath).
5
+ *
6
+ * `For` is keyed identity (rows keep their host node, focus, scroll across reorders); the
7
+ * virtualized {@link import('./list').List} is for huge lists — complementary, not competing.
8
+ * Use `For` when you'd otherwise write `() => items().map(...)` (which full-rebuilds): it
9
+ * reconciles by key so only the diff is created/moved/disposed. Consume the `item`/`index`
10
+ * accessors lazily so a row patches in place.
11
+ *
12
+ * @example
13
+ * For({ each: () => todos(), key: (t) => t.id, children: (todo) => (
14
+ * <Row><Text>{() => todo().title}</Text></Row>
15
+ * )})
16
+ *
17
+ * @module
18
+ */
19
+ /** A keyed, identity-preserving list. Returns a {@link KeyedRegion} node the renderer reconciles. */
20
+ function For(props) {
21
+ return keyedRegion(props);
22
+ }
23
+ //#endregion
24
+ export { For };
25
+
26
+ //# sourceMappingURL=for.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"for.js","names":[],"sources":["../src/for.ts"],"sourcesContent":["/**\n * Atlas `For` — the ergonomic, keyed list component (on the `@mindees/atlas/for` subpath).\n *\n * `For` is keyed identity (rows keep their host node, focus, scroll across reorders); the\n * virtualized {@link import('./list').List} is for huge lists — complementary, not competing.\n * Use `For` when you'd otherwise write `() => items().map(...)` (which full-rebuilds): it\n * reconciles by key so only the diff is created/moved/disposed. Consume the `item`/`index`\n * accessors lazily so a row patches in place.\n *\n * @example\n * For({ each: () => todos(), key: (t) => t.id, children: (todo) => (\n * <Row><Text>{() => todo().title}</Text></Row>\n * )})\n *\n * @module\n */\n\nimport { type KeyedRegion, keyedRegion, type MindeesNode } from '@mindees/core'\n\n/** Props for {@link For}. */\nexport interface ForProps<T> {\n /** The items, static or reactive. */\n readonly each: readonly T[] | (() => readonly T[])\n /** Render one row from reactive `item`/`index` accessors. */\n readonly children: (item: () => T, index: () => number) => MindeesNode\n /** Stable key per item (defaults to item identity). Provide it for primitive/object lists that change shape. */\n readonly key?: (item: T, index: number) => unknown\n /** Rendered when the list is empty. */\n readonly fallback?: () => MindeesNode\n}\n\n/** A keyed, identity-preserving list. Returns a {@link KeyedRegion} node the renderer reconciles. */\nexport function For<T>(props: ForProps<T>): KeyedRegion<T> {\n return keyedRegion<T>(props)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,IAAO,OAAoC;CACzD,OAAO,YAAe,KAAK;AAC7B"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  import { A11yProps, A11yState, Role, toA11yProps } from "./a11y.js";
2
2
  import { StyleInput, StyleObject, StyleValue, flattenStyle } from "./style.js";
3
3
  import { BaseProps, Reactive, resolveStyle, toHostProps } from "./host.js";
4
+ import { ActivityIndicator, ActivityIndicatorProps, Avatar, AvatarProps, Badge, BadgeProps, Card, CardProps, Chip, ChipProps, Divider, DividerProps, KeyboardAvoidingView, KeyboardAvoidingViewProps, ProgressBar, ProgressBarProps, SafeAreaView, SafeAreaViewProps, Switch, SwitchProps } from "./components.js";
5
+ import { ColorScheme, KeyboardState, PlatformEnvironment, SafeAreaInsets, WindowDimensions, getEnvironment, setEnvironment, useColorScheme, useKeyboard, useSafeAreaInsets, useWindowDimensions } from "./environment.js";
4
6
  import { Button, ButtonProps, Column, Image, ImageProps, InteractionState, Pressable, PressableProps, Row, ScrollView, ScrollViewProps, Spacer, SpacerProps, Stack, StackProps, Text, TextInput, TextInputProps, TextProps, View, ViewProps, usePressable } from "./primitives.js";
7
+ import { Theme, ThemeColors, duration, easing, fontSize, fontWeight, getTheme, lineHeight, palette, radius, space, tokens, useTheme } from "./tokens.js";
5
8
  import { Maturity, NotImplementedError, PackageInfo, notImplemented } from "@mindees/core";
6
9
 
7
10
  //#region src/index.d.ts
8
11
  /** The npm package name. */
9
12
  declare const name = "@mindees/atlas";
10
13
  /** The package version. All `@mindees/*` packages share one locked version line. */
11
- declare const VERSION = "0.1.0";
14
+ declare const VERSION = "0.3.0";
12
15
  /** Current maturity of this package. See the repository `STATUS.md`. */
13
16
  declare const maturity: Maturity;
14
17
  /**
@@ -18,5 +21,5 @@ declare const maturity: Maturity;
18
21
  */
19
22
  declare const info: PackageInfo;
20
23
  //#endregion
21
- export { type A11yProps, type A11yState, type BaseProps, Button, type ButtonProps, Column, Image, type ImageProps, type InteractionState, type Maturity, NotImplementedError, type PackageInfo, Pressable, type PressableProps, type Reactive, type Role, Row, ScrollView, type ScrollViewProps, Spacer, type SpacerProps, Stack, type StackProps, type StyleInput, type StyleObject, type StyleValue, Text, TextInput, type TextInputProps, type TextProps, VERSION, View, type ViewProps, flattenStyle, info, maturity, name, notImplemented, resolveStyle, toA11yProps, toHostProps, usePressable };
24
+ export { type A11yProps, type A11yState, ActivityIndicator, type ActivityIndicatorProps, Avatar, type AvatarProps, Badge, type BadgeProps, type BaseProps, Button, type ButtonProps, Card, type CardProps, Chip, type ChipProps, type ColorScheme, Column, Divider, type DividerProps, Image, type ImageProps, type InteractionState, KeyboardAvoidingView, type KeyboardAvoidingViewProps, type KeyboardState, type Maturity, NotImplementedError, type PackageInfo, type PlatformEnvironment, Pressable, type PressableProps, ProgressBar, type ProgressBarProps, type Reactive, type Role, Row, type SafeAreaInsets, SafeAreaView, type SafeAreaViewProps, ScrollView, type ScrollViewProps, Spacer, type SpacerProps, Stack, type StackProps, type StyleInput, type StyleObject, type StyleValue, Switch, type SwitchProps, Text, TextInput, type TextInputProps, type TextProps, type Theme, type ThemeColors, VERSION, View, type ViewProps, type WindowDimensions, duration, easing, flattenStyle, fontSize, fontWeight, getEnvironment, getTheme, info, lineHeight, maturity, name, notImplemented, palette, radius, resolveStyle, setEnvironment, space, toA11yProps, toHostProps, tokens, useColorScheme, useKeyboard, usePressable, useSafeAreaInsets, useTheme, useWindowDimensions };
22
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;AAkBA;AAAA,cAHa,IAAA;;cAGA,OAAA;AAAO;AAAA,cAGP,QAAA,EAAU,QAAyB;;;;AAAA;AAOhD;cAAa,IAAA,EAAM,WAAiE"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;cAea,IAAA;AAAI;AAAA,cAGJ,OAAA;;cAGA,QAAA,EAAU,QAAyB;;AAH5B;AAGpB;;;cAOa,IAAA,EAAM,WAAiE"}
package/dist/index.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { toA11yProps } from "./a11y.js";
2
+ import { getEnvironment, setEnvironment, useColorScheme, useKeyboard, useSafeAreaInsets, useWindowDimensions } from "./environment.js";
2
3
  import { flattenStyle } from "./style.js";
3
4
  import { resolveStyle, toHostProps } from "./host.js";
4
5
  import { Button, Column, Image, Pressable, Row, ScrollView, Spacer, Stack, Text, TextInput, View, usePressable } from "./primitives.js";
6
+ import { duration, easing, fontSize, fontWeight, getTheme, lineHeight, palette, radius, space, tokens, useTheme } from "./tokens.js";
7
+ import { ActivityIndicator, Avatar, Badge, Card, Chip, Divider, KeyboardAvoidingView, ProgressBar, SafeAreaView, Switch } from "./components.js";
5
8
  import { NotImplementedError, notImplemented } from "@mindees/core";
6
9
  //#region src/index.ts
7
10
  /** The npm package name. */
8
11
  const name = "@mindees/atlas";
9
12
  /** The package version. All `@mindees/*` packages share one locked version line. */
10
- const VERSION = "0.1.0";
13
+ const VERSION = "0.3.0";
11
14
  /** Current maturity of this package. See the repository `STATUS.md`. */
12
15
  const maturity = "experimental";
13
16
  /**
@@ -21,6 +24,6 @@ const info = Object.freeze({
21
24
  maturity
22
25
  });
23
26
  //#endregion
24
- export { Button, Column, Image, NotImplementedError, Pressable, Row, ScrollView, Spacer, Stack, Text, TextInput, VERSION, View, flattenStyle, info, maturity, name, notImplemented, resolveStyle, toA11yProps, toHostProps, usePressable };
27
+ export { ActivityIndicator, Avatar, Badge, Button, Card, Chip, Column, Divider, Image, KeyboardAvoidingView, NotImplementedError, Pressable, ProgressBar, Row, SafeAreaView, ScrollView, Spacer, Stack, Switch, Text, TextInput, VERSION, View, duration, easing, flattenStyle, fontSize, fontWeight, getEnvironment, getTheme, info, lineHeight, maturity, name, notImplemented, palette, radius, resolveStyle, setEnvironment, space, toA11yProps, toHostProps, tokens, useColorScheme, useKeyboard, usePressable, useSafeAreaInsets, useTheme, useWindowDimensions };
25
28
 
26
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@mindees/atlas` (Atlas) — accessible, signals-native UI primitives. Function components\n * over `@mindees/core`'s `createElement` that return renderer-agnostic `MindeesNode` trees:\n * web rendering is real via the Helix DOM backend; native is a labeled 🔬 research track (the\n * same serializable tree, interpreted by a native host later). A curated cross-platform\n * `StyleObject`, typed accessibility, and a structural theme (on the `@mindees/atlas/theme`\n * subpath). The virtualized recycling `List` is on the `@mindees/atlas/list` subpath.\n *\n * @module\n */\n\nimport type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** The npm package name. */\nexport const name = '@mindees/atlas'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.1.0'\n\n/** Current maturity of this package. See the repository `STATUS.md`. */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n\nexport { type A11yProps, type A11yState, type Role, toA11yProps } from './a11y'\nexport { type BaseProps, type Reactive, resolveStyle, toHostProps } from './host'\nexport {\n Button,\n type ButtonProps,\n Column,\n Image,\n type ImageProps,\n type InteractionState,\n Pressable,\n type PressableProps,\n Row,\n ScrollView,\n type ScrollViewProps,\n Spacer,\n type SpacerProps,\n Stack,\n type StackProps,\n Text,\n TextInput,\n type TextInputProps,\n type TextProps,\n usePressable,\n View,\n type ViewProps,\n} from './primitives'\nexport { flattenStyle, type StyleInput, type StyleObject, type StyleValue } from './style'\nexport type { Maturity, PackageInfo }\nexport { NotImplementedError, notImplemented }\n"],"mappings":";;;;;;;AAeA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;AAGvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@mindees/atlas` (Atlas) — accessible, signals-native UI primitives. Function components\n * over `@mindees/core`'s `createElement` that return renderer-agnostic `MindeesNode` trees:\n * web rendering is real via the Helix DOM backend; native is a labeled 🔬 research track (the\n * same serializable tree, interpreted by a native host later). A curated cross-platform\n * `StyleObject`, typed accessibility, and a structural theme (on the `@mindees/atlas/theme`\n * subpath). The virtualized recycling `List` is on the `@mindees/atlas/list` subpath.\n *\n * @module\n */\n\nimport type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** The npm package name. */\nexport const name = '@mindees/atlas'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.3.0'\n\n/** Current maturity of this package. See the repository `STATUS.md`. */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n\nexport { type A11yProps, type A11yState, type Role, toA11yProps } from './a11y'\nexport {\n ActivityIndicator,\n type ActivityIndicatorProps,\n Avatar,\n type AvatarProps,\n Badge,\n type BadgeProps,\n Card,\n type CardProps,\n Chip,\n type ChipProps,\n Divider,\n type DividerProps,\n KeyboardAvoidingView,\n type KeyboardAvoidingViewProps,\n ProgressBar,\n type ProgressBarProps,\n SafeAreaView,\n type SafeAreaViewProps,\n Switch,\n type SwitchProps,\n} from './components'\nexport {\n type ColorScheme,\n getEnvironment,\n type KeyboardState,\n type PlatformEnvironment,\n type SafeAreaInsets,\n setEnvironment,\n useColorScheme,\n useKeyboard,\n useSafeAreaInsets,\n useWindowDimensions,\n type WindowDimensions,\n} from './environment'\nexport { type BaseProps, type Reactive, resolveStyle, toHostProps } from './host'\nexport {\n Button,\n type ButtonProps,\n Column,\n Image,\n type ImageProps,\n type InteractionState,\n Pressable,\n type PressableProps,\n Row,\n ScrollView,\n type ScrollViewProps,\n Spacer,\n type SpacerProps,\n Stack,\n type StackProps,\n Text,\n TextInput,\n type TextInputProps,\n type TextProps,\n usePressable,\n View,\n type ViewProps,\n} from './primitives'\nexport { flattenStyle, type StyleInput, type StyleObject, type StyleValue } from './style'\nexport {\n duration,\n easing,\n fontSize,\n fontWeight,\n getTheme,\n lineHeight,\n palette,\n radius,\n space,\n type Theme,\n type ThemeColors,\n tokens,\n useTheme,\n} from './tokens'\nexport type { Maturity, PackageInfo }\nexport { NotImplementedError, notImplemented }\n"],"mappings":";;;;;;;;;;AAeA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;AAGvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
package/dist/list.d.ts CHANGED
@@ -52,6 +52,51 @@ interface ListOptions<T> {
52
52
  declare function createList<T>(options: ListOptions<T>): MindeesNode;
53
53
  /** Component-style alias for {@link createList}. */
54
54
  declare function List<T>(options: ListOptions<T>): MindeesNode;
55
+ /** A list section: an optional header + its rows. */
56
+ interface Section<T> {
57
+ /** Header title (used by the default header when `renderSectionHeader` is omitted). */
58
+ readonly title?: string;
59
+ readonly data: readonly T[];
60
+ /** Stable key for the section (optional). */
61
+ readonly key?: string;
62
+ }
63
+ /** A flattened section-list entry: a header or a row. */
64
+ type Entry<T> = {
65
+ readonly kind: 'header';
66
+ readonly section: Section<T>;
67
+ readonly sectionIndex: number;
68
+ } | {
69
+ readonly kind: 'item';
70
+ readonly section: Section<T>;
71
+ readonly item: T;
72
+ readonly sectionIndex: number;
73
+ readonly itemIndex: number;
74
+ };
75
+ /** Flatten sections into a single ordered entry list (header, its rows, next header, …). */
76
+ declare function flattenSections<T>(sections: readonly Section<T>[]): Entry<T>[];
77
+ /** Options for {@link createSectionList}. */
78
+ interface SectionListOptions<T> {
79
+ /** The sections, static or reactive. */
80
+ readonly sections: readonly Section<T>[] | (() => readonly Section<T>[]);
81
+ /** Render one row (same lazy-accessor contract as {@link ListOptions.renderItem}). */
82
+ readonly renderItem: (item: () => T, index: () => number) => MindeesNode;
83
+ /** Render a section header (defaults to a `text` of `section.title`). */
84
+ readonly renderSectionHeader?: (section: () => Section<T>) => MindeesNode;
85
+ /** Fixed row height in px (headers and rows share it in v1). */
86
+ readonly itemHeight: number;
87
+ readonly height: number;
88
+ readonly overscan?: number;
89
+ readonly onEndReached?: () => void;
90
+ readonly style?: Reactive<StyleInput>;
91
+ }
92
+ /**
93
+ * A virtualized **section list** built on {@link createList}: sections are flattened to a
94
+ * single entry stream (header, rows, …) and windowed, so only visible headers/rows render.
95
+ * Fixed row height in v1 (headers share it) — variable heights track the List's research item.
96
+ */
97
+ declare function createSectionList<T>(options: SectionListOptions<T>): MindeesNode;
98
+ /** Component-style alias for {@link createSectionList}. */
99
+ declare function SectionList<T>(options: SectionListOptions<T>): MindeesNode;
55
100
  //#endregion
56
- export { List, ListOptions, ListWindow, computeWindow, createList };
101
+ export { List, ListOptions, ListWindow, Section, SectionList, SectionListOptions, computeWindow, createList, createSectionList, flattenSections };
57
102
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","names":[],"sources":["../src/list.ts"],"mappings":";;;;;;UA6BiB,UAAA;EAef;EAAA,SAbS,UAAA;EAeT;EAAA,SAbS,QAAA;EAeR;EAAA,SAbQ,WAAA;AAAA;AAyBX;;;;AAAA,iBAlBgB,aAAA,CACd,SAAA,UACA,cAAA,UACA,UAAA,UACA,SAAA,UACA,QAAA,WACC,UAAU;;UAYI,WAAA;EAwBW;EAAA,SAtBjB,KAAA,WAA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ZX;EAAA,SAcL,GAAA;AAAA;;KAIN,KAAA;EAAA,SACU,IAAA;EAAA,SAAyB,OAAA,EAAS,OAAA,CAAQ,CAAA;EAAA,SAAa,YAAA;AAAA;EAAA,SAEvD,IAAA;EAAA,SACA,OAAA,EAAS,OAAA,CAAQ,CAAA;EAAA,SACjB,IAAA,EAAM,CAAA;EAAA,SACN,YAAA;EAAA,SACA,SAAA;AAAA;AAhBf;AAAA,iBAoBgB,eAAA,IAAmB,QAAA,WAAmB,OAAA,CAAQ,CAAA,MAAO,KAAA,CAAM,CAAA;;UAY1D,kBAAA;EAhCQ;EAAA,SAkCd,QAAA,WAAmB,OAAA,CAAQ,CAAA,sBAAuB,OAAA,CAAQ,CAAA;EA/B1D;EAAA,SAiCA,UAAA,GAAa,IAAA,QAAY,CAAA,EAAG,KAAA,mBAAwB,WAAA;EA/BpD;EAAA,SAiCA,mBAAA,IAAuB,OAAA,QAAe,OAAA,CAAQ,CAAA,MAAO,WAAA;EAjClD;EAAA,SAmCH,UAAA;EAAA,SACA,MAAA;EAAA,SACA,QAAA;EAAA,SACA,YAAA;EAAA,SACA,KAAA,GAAQ,QAAA,CAAS,UAAA;AAAA;;;;;;iBAQZ,iBAAA,IAAqB,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,WAAA;;iBA+BtD,WAAA,IAAe,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,WAAA"}
package/dist/list.js CHANGED
@@ -105,12 +105,14 @@ function createList(options) {
105
105
  })
106
106
  }, content);
107
107
  }));
108
+ const baseScrollStyle = {
109
+ height,
110
+ position: "relative"
111
+ };
112
+ const callerStyle = options.style;
108
113
  return createElement(ScrollView, {
109
114
  onScroll: (event) => scrollTop.set(readScrollTop(event)),
110
- style: flattenStyle([{
111
- height,
112
- position: "relative"
113
- }, options.style])
115
+ style: typeof callerStyle === "function" ? () => flattenStyle([baseScrollStyle, callerStyle()]) : flattenStyle([baseScrollStyle, callerStyle])
114
116
  }, spacer);
115
117
  };
116
118
  }
@@ -118,7 +120,53 @@ function createList(options) {
118
120
  function List(options) {
119
121
  return createList(options);
120
122
  }
123
+ /** Flatten sections into a single ordered entry list (header, its rows, next header, …). */
124
+ function flattenSections(sections) {
125
+ const out = [];
126
+ sections.forEach((section, sectionIndex) => {
127
+ out.push({
128
+ kind: "header",
129
+ section,
130
+ sectionIndex
131
+ });
132
+ section.data.forEach((item, itemIndex) => {
133
+ out.push({
134
+ kind: "item",
135
+ section,
136
+ item,
137
+ sectionIndex,
138
+ itemIndex
139
+ });
140
+ });
141
+ });
142
+ return out;
143
+ }
144
+ /**
145
+ * A virtualized **section list** built on {@link createList}: sections are flattened to a
146
+ * single entry stream (header, rows, …) and windowed, so only visible headers/rows render.
147
+ * Fixed row height in v1 (headers share it) — variable heights track the List's research item.
148
+ */
149
+ function createSectionList(options) {
150
+ const sectionsOf = typeof options.sections === "function" ? options.sections : () => options.sections;
151
+ return createList({
152
+ items: () => flattenSections(sectionsOf()),
153
+ itemHeight: options.itemHeight,
154
+ height: options.height,
155
+ ...options.overscan !== void 0 ? { overscan: options.overscan } : {},
156
+ ...options.onEndReached ? { onEndReached: options.onEndReached } : {},
157
+ ...options.style !== void 0 ? { style: options.style } : {},
158
+ renderItem: (entry) => () => {
159
+ const e = entry();
160
+ if (e.kind === "header") return options.renderSectionHeader ? options.renderSectionHeader(() => entry().section) : createElement("text", null, e.section.title ?? "");
161
+ return options.renderItem(() => entry().item, () => entry().itemIndex);
162
+ }
163
+ });
164
+ }
165
+ /** Component-style alias for {@link createSectionList}. */
166
+ function SectionList(options) {
167
+ return createSectionList(options);
168
+ }
121
169
  //#endregion
122
- export { List, computeWindow, createList };
170
+ export { List, SectionList, computeWindow, createList, createSectionList, flattenSections };
123
171
 
124
172
  //# sourceMappingURL=list.js.map
package/dist/list.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","names":[],"sources":["../src/list.ts"],"sourcesContent":["/**\n * Atlas `List` — a virtualized, **recycling** list. Only the visible window (+ overscan) is\n * rendered; rows are a FIXED POOL of per-slot reactive regions, NOT one region returning\n * `items.map(...)` (the Helix reconciler has no keyed array diff, so a single array region\n * would tear down + remount every visible row on each scroll). Each slot region depends only\n * on its own `active` signal, so a row that stays in view keeps its identity and `renderItem`\n * runs once for it — only rows scrolling across the window edge are (re)created. A total-height\n * spacer keeps the native scrollbar correct; rows are absolutely positioned by `transform`.\n *\n * Fixed row height in v1 (deterministic windowing, headless-testable with zero real scroll);\n * variable/measured heights are a 🔬 research track. See `docs/adr/0023-atlas-list.md`.\n *\n * @module\n */\n\nimport {\n batch,\n createElement,\n effect,\n type MindeesNode,\n memo,\n type Signal,\n signal,\n} from '@mindees/core'\nimport type { Reactive } from './host'\nimport { ScrollView } from './primitives'\nimport { flattenStyle, type StyleInput } from './style'\n\n/** The computed visible window over the item list. */\nexport interface ListWindow {\n /** First visible index (inclusive), overscan applied. */\n readonly startIndex: number\n /** Last visible index (exclusive), overscan applied. */\n readonly endIndex: number\n /** Total scrollable height (px) = itemCount × itemHeight. */\n readonly totalHeight: number\n}\n\n/**\n * Pure window math: which item indices are visible for a given scroll offset. Exported and\n * exhaustively unit-tested — the deterministic heart of virtualization (no signals, no DOM).\n */\nexport function computeWindow(\n scrollTop: number,\n viewportHeight: number,\n itemHeight: number,\n itemCount: number,\n overscan: number,\n): ListWindow {\n const totalHeight = itemCount * itemHeight\n if (itemCount <= 0) return { startIndex: 0, endIndex: 0, totalHeight: 0 }\n const top = Math.max(0, Math.min(scrollTop, Math.max(0, totalHeight - viewportHeight)))\n const firstVisible = Math.floor(top / itemHeight)\n const lastVisible = Math.ceil((top + viewportHeight) / itemHeight)\n const startIndex = Math.max(0, firstVisible - overscan)\n const endIndex = Math.min(itemCount, lastVisible + overscan)\n return { startIndex, endIndex, totalHeight }\n}\n\n/** Options for {@link createList}. */\nexport interface ListOptions<T> {\n /** The items, static or reactive. */\n readonly items: readonly T[] | (() => readonly T[])\n /**\n * Render one row. Receives reactive `item`/`index` **accessors** — consume them LAZILY\n * (`Text({ children: () => item().name })`, a `style` fn, or pass them to a child) so a\n * recycled slot patches in place. Reading `item()`/`index()` synchronously in the body bakes\n * the value in and opts the row out of recycling (it re-runs renderItem on reuse instead).\n */\n readonly renderItem: (item: () => T, index: () => number) => MindeesNode\n /** Fixed row height in px (variable heights are a research track). */\n readonly itemHeight: number\n /** Viewport height in px. */\n readonly height: number\n /** Extra rows rendered above/below the viewport (default 3, clamped 0–50). */\n readonly overscan?: number\n /** Read the current scroll offset (test/SSR injection seam; default 0). */\n readonly getScrollOffset?: () => number\n /**\n * Fires once when the last item is within the rendered window — including at mount if the list\n * already fits the viewport — and re-arms when the end scrolls back out (e.g. to load more).\n */\n readonly onEndReached?: () => void\n /** Extra style on the scroll container. */\n readonly style?: Reactive<StyleInput>\n}\n\ninterface Slot<T> {\n readonly item: Signal<T | undefined>\n readonly index: Signal<number>\n readonly top: Signal<number>\n readonly active: Signal<boolean>\n}\n\nfunction readScrollTop(event: unknown): number {\n const top = (event as { target?: { scrollTop?: number } })?.target?.scrollTop\n return typeof top === 'number' && Number.isFinite(top) ? top : 0\n}\n\n/**\n * Create a virtualized recycling list as a renderer-agnostic `MindeesNode`.\n *\n * @throws RangeError if `itemHeight`/`height` are not positive finite numbers.\n */\nexport function createList<T>(options: ListOptions<T>): MindeesNode {\n const { renderItem, itemHeight, height } = options\n if (!Number.isFinite(itemHeight) || itemHeight <= 0) {\n throw new RangeError('List itemHeight must be a positive number')\n }\n if (!Number.isFinite(height) || height <= 0) {\n throw new RangeError('List height must be a positive number')\n }\n const overscan = Math.max(0, Math.min(50, Math.floor(options.overscan ?? 3)))\n const itemsOf: () => readonly T[] =\n typeof options.items === 'function' ? options.items : () => options.items as readonly T[]\n\n // Return a reactive-region accessor so ALL the signals/memo/effect below are created under the\n // mounting owner (the renderer runs this once via bindReactiveChild) and are disposed on\n // unmount. Creating them eagerly here would leave them un-owned (currentOwner === null at call\n // time) and leak past `dispose()`. Validation above stays synchronous (throws at call time).\n return () => {\n const scrollTop = signal(options.getScrollOffset ? options.getScrollOffset() : 0)\n const poolSize = Math.ceil(height / itemHeight) + 2 * overscan + 1\n\n // Re-run the assignment only when the integer window actually changes (not every pixel).\n const windowMemo = memo(\n () => computeWindow(scrollTop(), height, itemHeight, itemsOf().length, overscan),\n {\n equals: (a, b) => a.startIndex === b.startIndex && a.endIndex === b.endIndex,\n },\n )\n\n const slots: Slot<T>[] = Array.from({ length: poolSize }, () => ({\n item: signal<T | undefined>(undefined),\n index: signal(0),\n top: signal(0),\n active: signal(false),\n }))\n\n let endReachedFired = false\n // Assign each visible index to slot `index % poolSize`; deactivate the rest. Max window size\n // equals poolSize (the `+1` is that exact margin — do NOT remove it), and any run of ≤\n // poolSize consecutive indices has distinct residues mod poolSize, so no two visible indices\n // ever share a slot.\n effect(() => {\n const { startIndex, endIndex } = windowMemo()\n const items = itemsOf()\n const used = new Array<boolean>(poolSize).fill(false)\n batch(() => {\n for (let i = startIndex; i < endIndex; i++) {\n const s = ((i % poolSize) + poolSize) % poolSize\n used[s] = true\n const slot = slots[s]\n if (!slot) continue\n slot.item.set(items[i])\n slot.index.set(i)\n slot.top.set(i * itemHeight)\n slot.active.set(true)\n }\n for (let s = 0; s < poolSize; s++) {\n if (!used[s]) slots[s]?.active.set(false)\n }\n })\n // onEndReached: fire when the last item is within the window (incl. at mount if the list\n // fits the viewport); re-arm when the end leaves the window.\n if (options.onEndReached && items.length > 0) {\n if (endIndex >= items.length) {\n if (!endReachedFired) {\n endReachedFired = true\n options.onEndReached()\n }\n } else {\n endReachedFired = false\n }\n }\n })\n\n // One reactive region per slot. The body depends ONLY on `active()`, so a slot that stays\n // active never re-runs renderItem; item/index/top flow through the inner accessors — provided\n // renderItem consumes them lazily (see the ListOptions.renderItem contract).\n const rows: MindeesNode[] = slots.map((slot, s) => () => {\n if (!slot.active()) return null\n const content = renderItem(\n () => slot.item() as T,\n () => slot.index(),\n )\n return createElement(\n 'view',\n {\n key: `atlas-list-row-${s}`,\n style: () => ({\n position: 'absolute',\n left: 0,\n right: 0,\n top: 0,\n height: itemHeight,\n transform: `translateY(${slot.top()}px)`,\n }),\n },\n content,\n )\n })\n\n const spacer = createElement(\n 'view',\n {\n style: () => ({\n position: 'relative',\n width: '100%',\n height: itemsOf().length * itemHeight,\n }),\n },\n ...rows,\n )\n\n return createElement(\n ScrollView,\n {\n onScroll: (event: unknown) => scrollTop.set(readScrollTop(event)),\n style: flattenStyle([{ height, position: 'relative' }, options.style as StyleInput]),\n },\n spacer,\n )\n }\n}\n\n/** Component-style alias for {@link createList}. */\nexport function List<T>(options: ListOptions<T>): MindeesNode {\n return createList(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,cACd,WACA,gBACA,YACA,WACA,UACY;CACZ,MAAM,cAAc,YAAY;CAChC,IAAI,aAAa,GAAG,OAAO;EAAE,YAAY;EAAG,UAAU;EAAG,aAAa;CAAE;CACxE,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,cAAc,cAAc,CAAC,CAAC;CACtF,MAAM,eAAe,KAAK,MAAM,MAAM,UAAU;CAChD,MAAM,cAAc,KAAK,MAAM,MAAM,kBAAkB,UAAU;CAGjE,OAAO;EAAE,YAFU,KAAK,IAAI,GAAG,eAAe,QAE5B;EAAG,UADJ,KAAK,IAAI,WAAW,cAAc,QACvB;EAAG;CAAY;AAC7C;AAqCA,SAAS,cAAc,OAAwB;CAC7C,MAAM,MAAO,OAA+C,QAAQ;CACpE,OAAO,OAAO,QAAQ,YAAY,OAAO,SAAS,GAAG,IAAI,MAAM;AACjE;;;;;;AAOA,SAAgB,WAAc,SAAsC;CAClE,MAAM,EAAE,YAAY,YAAY,WAAW;CAC3C,IAAI,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,GAChD,MAAM,IAAI,WAAW,2CAA2C;CAElE,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,UAAU,GACxC,MAAM,IAAI,WA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QAAQ,gBAAgB,MAAM,SAAS,GACzC,IAAI,YAAY,MAAM;QAChB,CAAC,iBAAiB;KACpB,kBAAkB;KAClB,QAAQ,aAAa;IACvB;UAEA,kBAAkB;EAGxB,CAAC;EA4BD,MAAM,SAAS,cACb,QACA,EACE,cAAc;GACZ,UAAU;GACV,OAAO;GACP,QAAQ,QAAQ,EAAE,SAAS;EAC7B,GACF,GACA,GAhC0B,MAAM,KAAK,MAAM,YAAY;GACvD,IAAI,CAAC,KAAK,OAAO,GAAG,OAAO;GAC3B,MAAM,UAAU,iBACR,KAAK,KAAK,SACV,KAAK,MAAM,CACnB;GACA,OAAO,cACL,QACA;IACE,KAAK,kBAAkB;IACvB,cAAc;KACZ,UAAU;KACV,MAAM;KACN,OAAO;KACP,KAAK;KACL,QAAQ;KACR,WAAW,cAAc,KAAK,IAAI,EAAE;IACtC;GACF,GACA,OACF;EACF,CAWQ,CACR;EAEA,OAAO,cACL,YACA;GACE,WAAW,UAAmB,UAAU,IAAI,cAAc,KAAK,CAAC;GAChE,OAAO,aAAa,CAAC;IAAE;IAAQ,UAAU;GAAW,GAAG,QAAQ,KAAmB,CAAC;EACrF,GACA,MACF;CACF;AACF;;AAGA,SAAgB,KAAQ,SAAsC;CAC5D,OAAO,WAAW,OAAO;AAC3B"}
1
+ {"version":3,"file":"list.js","names":[],"sources":["../src/list.ts"],"sourcesContent":["/**\n * Atlas `List` — a virtualized, **recycling** list. Only the visible window (+ overscan) is\n * rendered; rows are a FIXED POOL of per-slot reactive regions, NOT one region returning\n * `items.map(...)` (the Helix reconciler has no keyed array diff, so a single array region\n * would tear down + remount every visible row on each scroll). Each slot region depends only\n * on its own `active` signal, so a row that stays in view keeps its identity and `renderItem`\n * runs once for it — only rows scrolling across the window edge are (re)created. A total-height\n * spacer keeps the native scrollbar correct; rows are absolutely positioned by `transform`.\n *\n * Fixed row height in v1 (deterministic windowing, headless-testable with zero real scroll);\n * variable/measured heights are a 🔬 research track. See `docs/adr/0023-atlas-list.md`.\n *\n * @module\n */\n\nimport {\n batch,\n createElement,\n effect,\n type MindeesNode,\n memo,\n type Signal,\n signal,\n} from '@mindees/core'\nimport type { Reactive } from './host'\nimport { ScrollView } from './primitives'\nimport { flattenStyle, type StyleInput } from './style'\n\n/** The computed visible window over the item list. */\nexport interface ListWindow {\n /** First visible index (inclusive), overscan applied. */\n readonly startIndex: number\n /** Last visible index (exclusive), overscan applied. */\n readonly endIndex: number\n /** Total scrollable height (px) = itemCount × itemHeight. */\n readonly totalHeight: number\n}\n\n/**\n * Pure window math: which item indices are visible for a given scroll offset. Exported and\n * exhaustively unit-tested — the deterministic heart of virtualization (no signals, no DOM).\n */\nexport function computeWindow(\n scrollTop: number,\n viewportHeight: number,\n itemHeight: number,\n itemCount: number,\n overscan: number,\n): ListWindow {\n const totalHeight = itemCount * itemHeight\n if (itemCount <= 0) return { startIndex: 0, endIndex: 0, totalHeight: 0 }\n const top = Math.max(0, Math.min(scrollTop, Math.max(0, totalHeight - viewportHeight)))\n const firstVisible = Math.floor(top / itemHeight)\n const lastVisible = Math.ceil((top + viewportHeight) / itemHeight)\n const startIndex = Math.max(0, firstVisible - overscan)\n const endIndex = Math.min(itemCount, lastVisible + overscan)\n return { startIndex, endIndex, totalHeight }\n}\n\n/** Options for {@link createList}. */\nexport interface ListOptions<T> {\n /** The items, static or reactive. */\n readonly items: readonly T[] | (() => readonly T[])\n /**\n * Render one row. Receives reactive `item`/`index` **accessors** — consume them LAZILY\n * (`Text({ children: () => item().name })`, a `style` fn, or pass them to a child) so a\n * recycled slot patches in place. Reading `item()`/`index()` synchronously in the body bakes\n * the value in and opts the row out of recycling (it re-runs renderItem on reuse instead).\n */\n readonly renderItem: (item: () => T, index: () => number) => MindeesNode\n /** Fixed row height in px (variable heights are a research track). */\n readonly itemHeight: number\n /** Viewport height in px. */\n readonly height: number\n /** Extra rows rendered above/below the viewport (default 3, clamped 0–50). */\n readonly overscan?: number\n /** Read the current scroll offset (test/SSR injection seam; default 0). */\n readonly getScrollOffset?: () => number\n /**\n * Fires once when the last item is within the rendered window — including at mount if the list\n * already fits the viewport — and re-arms when the end scrolls back out (e.g. to load more).\n */\n readonly onEndReached?: () => void\n /** Extra style on the scroll container. */\n readonly style?: Reactive<StyleInput>\n}\n\ninterface Slot<T> {\n readonly item: Signal<T | undefined>\n readonly index: Signal<number>\n readonly top: Signal<number>\n readonly active: Signal<boolean>\n}\n\nfunction readScrollTop(event: unknown): number {\n const top = (event as { target?: { scrollTop?: number } })?.target?.scrollTop\n return typeof top === 'number' && Number.isFinite(top) ? top : 0\n}\n\n/**\n * Create a virtualized recycling list as a renderer-agnostic `MindeesNode`.\n *\n * @throws RangeError if `itemHeight`/`height` are not positive finite numbers.\n */\nexport function createList<T>(options: ListOptions<T>): MindeesNode {\n const { renderItem, itemHeight, height } = options\n if (!Number.isFinite(itemHeight) || itemHeight <= 0) {\n throw new RangeError('List itemHeight must be a positive number')\n }\n if (!Number.isFinite(height) || height <= 0) {\n throw new RangeError('List height must be a positive number')\n }\n const overscan = Math.max(0, Math.min(50, Math.floor(options.overscan ?? 3)))\n const itemsOf: () => readonly T[] =\n typeof options.items === 'function' ? options.items : () => options.items as readonly T[]\n\n // Return a reactive-region accessor so ALL the signals/memo/effect below are created under the\n // mounting owner (the renderer runs this once via bindReactiveChild) and are disposed on\n // unmount. Creating them eagerly here would leave them un-owned (currentOwner === null at call\n // time) and leak past `dispose()`. Validation above stays synchronous (throws at call time).\n return () => {\n const scrollTop = signal(options.getScrollOffset ? options.getScrollOffset() : 0)\n const poolSize = Math.ceil(height / itemHeight) + 2 * overscan + 1\n\n // Re-run the assignment only when the integer window actually changes (not every pixel).\n const windowMemo = memo(\n () => computeWindow(scrollTop(), height, itemHeight, itemsOf().length, overscan),\n {\n equals: (a, b) => a.startIndex === b.startIndex && a.endIndex === b.endIndex,\n },\n )\n\n const slots: Slot<T>[] = Array.from({ length: poolSize }, () => ({\n item: signal<T | undefined>(undefined),\n index: signal(0),\n top: signal(0),\n active: signal(false),\n }))\n\n let endReachedFired = false\n // Assign each visible index to slot `index % poolSize`; deactivate the rest. Max window size\n // equals poolSize (the `+1` is that exact margin — do NOT remove it), and any run of ≤\n // poolSize consecutive indices has distinct residues mod poolSize, so no two visible indices\n // ever share a slot.\n effect(() => {\n const { startIndex, endIndex } = windowMemo()\n const items = itemsOf()\n const used = new Array<boolean>(poolSize).fill(false)\n batch(() => {\n for (let i = startIndex; i < endIndex; i++) {\n const s = ((i % poolSize) + poolSize) % poolSize\n used[s] = true\n const slot = slots[s]\n if (!slot) continue\n slot.item.set(items[i])\n slot.index.set(i)\n slot.top.set(i * itemHeight)\n slot.active.set(true)\n }\n for (let s = 0; s < poolSize; s++) {\n if (!used[s]) slots[s]?.active.set(false)\n }\n })\n // onEndReached: fire when the last item is within the window (incl. at mount if the list\n // fits the viewport); re-arm when the end leaves the window.\n if (options.onEndReached && items.length > 0) {\n if (endIndex >= items.length) {\n if (!endReachedFired) {\n endReachedFired = true\n options.onEndReached()\n }\n } else {\n endReachedFired = false\n }\n }\n })\n\n // One reactive region per slot. The body depends ONLY on `active()`, so a slot that stays\n // active never re-runs renderItem; item/index/top flow through the inner accessors — provided\n // renderItem consumes them lazily (see the ListOptions.renderItem contract).\n const rows: MindeesNode[] = slots.map((slot, s) => () => {\n if (!slot.active()) return null\n const content = renderItem(\n () => slot.item() as T,\n () => slot.index(),\n )\n return createElement(\n 'view',\n {\n key: `atlas-list-row-${s}`,\n style: () => ({\n position: 'absolute',\n left: 0,\n right: 0,\n top: 0,\n height: itemHeight,\n transform: `translateY(${slot.top()}px)`,\n }),\n },\n content,\n )\n })\n\n const spacer = createElement(\n 'view',\n {\n style: () => ({\n position: 'relative',\n width: '100%',\n height: itemsOf().length * itemHeight,\n }),\n },\n ...rows,\n )\n\n // A reactive (accessor) `style` must stay reactive — eagerly flattening it would\n // Object.assign a function and silently drop it. Keep it a function when the caller's is.\n const baseScrollStyle: StyleInput = { height, position: 'relative' }\n const callerStyle = options.style\n const scrollStyle: Reactive<StyleInput> =\n typeof callerStyle === 'function'\n ? () => flattenStyle([baseScrollStyle, (callerStyle as () => StyleInput)()])\n : flattenStyle([baseScrollStyle, callerStyle as StyleInput])\n\n return createElement(\n ScrollView,\n {\n onScroll: (event: unknown) => scrollTop.set(readScrollTop(event)),\n style: scrollStyle,\n },\n spacer,\n )\n }\n}\n\n/** Component-style alias for {@link createList}. */\nexport function List<T>(options: ListOptions<T>): MindeesNode {\n return createList(options)\n}\n\n// ---------------------------------------------------------------------------\n// SectionList\n// ---------------------------------------------------------------------------\n\n/** A list section: an optional header + its rows. */\nexport interface Section<T> {\n /** Header title (used by the default header when `renderSectionHeader` is omitted). */\n readonly title?: string\n readonly data: readonly T[]\n /** Stable key for the section (optional). */\n readonly key?: string\n}\n\n/** A flattened section-list entry: a header or a row. */\ntype Entry<T> =\n | { readonly kind: 'header'; readonly section: Section<T>; readonly sectionIndex: number }\n | {\n readonly kind: 'item'\n readonly section: Section<T>\n readonly item: T\n readonly sectionIndex: number\n readonly itemIndex: number\n }\n\n/** Flatten sections into a single ordered entry list (header, its rows, next header, …). */\nexport function flattenSections<T>(sections: readonly Section<T>[]): Entry<T>[] {\n const out: Entry<T>[] = []\n sections.forEach((section, sectionIndex) => {\n out.push({ kind: 'header', section, sectionIndex })\n section.data.forEach((item, itemIndex) => {\n out.push({ kind: 'item', section, item, sectionIndex, itemIndex })\n })\n })\n return out\n}\n\n/** Options for {@link createSectionList}. */\nexport interface SectionListOptions<T> {\n /** The sections, static or reactive. */\n readonly sections: readonly Section<T>[] | (() => readonly Section<T>[])\n /** Render one row (same lazy-accessor contract as {@link ListOptions.renderItem}). */\n readonly renderItem: (item: () => T, index: () => number) => MindeesNode\n /** Render a section header (defaults to a `text` of `section.title`). */\n readonly renderSectionHeader?: (section: () => Section<T>) => MindeesNode\n /** Fixed row height in px (headers and rows share it in v1). */\n readonly itemHeight: number\n readonly height: number\n readonly overscan?: number\n readonly onEndReached?: () => void\n readonly style?: Reactive<StyleInput>\n}\n\n/**\n * A virtualized **section list** built on {@link createList}: sections are flattened to a\n * single entry stream (header, rows, …) and windowed, so only visible headers/rows render.\n * Fixed row height in v1 (headers share it) — variable heights track the List's research item.\n */\nexport function createSectionList<T>(options: SectionListOptions<T>): MindeesNode {\n const sectionsOf: () => readonly Section<T>[] =\n typeof options.sections === 'function'\n ? options.sections\n : () => options.sections as readonly Section<T>[]\n\n return createList<Entry<T>>({\n items: () => flattenSections(sectionsOf()),\n itemHeight: options.itemHeight,\n height: options.height,\n ...(options.overscan !== undefined ? { overscan: options.overscan } : {}),\n ...(options.onEndReached ? { onEndReached: options.onEndReached } : {}),\n ...(options.style !== undefined ? { style: options.style } : {}),\n // The branch reads `entry()`, so a recycled slot re-runs this when its entry changes —\n // correct for mixed header/row content (rows still virtualize: only the visible window renders).\n renderItem: (entry) => () => {\n const e = entry()\n if (e.kind === 'header') {\n return options.renderSectionHeader\n ? options.renderSectionHeader(() => entry().section)\n : createElement('text', null, e.section.title ?? '')\n }\n return options.renderItem(\n () => (entry() as Extract<Entry<T>, { kind: 'item' }>).item,\n () => (entry() as Extract<Entry<T>, { kind: 'item' }>).itemIndex,\n )\n },\n })\n}\n\n/** Component-style alias for {@link createSectionList}. */\nexport function SectionList<T>(options: SectionListOptions<T>): MindeesNode {\n return createSectionList(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,cACd,WACA,gBACA,YACA,WACA,UACY;CACZ,MAAM,cAAc,YAAY;CAChC,IAAI,aAAa,GAAG,OAAO;EAAE,YAAY;EAAG,UAAU;EAAG,aAAa;CAAE;CACxE,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,cAAc,cAAc,CAAC,CAAC;CACtF,MAAM,eAAe,KAAK,MAAM,MAAM,UAAU;CAChD,MAAM,cAAc,KAAK,MAAM,MAAM,kBAAkB,UAAU;CAGjE,OAAO;EAAE,YAFU,KAAK,IAAI,GAAG,eAAe,QAE5B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D,GACA,MACF;CACF;AACF;;AAGA,SAAgB,KAAQ,SAAsC;CAC5D,OAAO,WAAW,OAAO;AAC3B;;AA2BA,SAAgB,gBAAmB,UAA6C;CAC9E,MAAM,MAAkB,CAAC;CACzB,SAAS,SAAS,SAAS,iBAAiB;EAC1C,IAAI,KAAK;GAAE,MAAM;GAAU;GAAS;EAAa,CAAC;EAClD,QAAQ,KAAK,SAAS,MAAM,cAAc;GACxC,IAAI,KAAK;IAAE,MAAM;IAAQ;IAAS;IAAM;IAAc;GAAU,CAAC;EACnE,CAAC;CACH,CAAC;CACD,OAAO;AACT;;;;;;AAuBA,SAAgB,kBAAqB,SAA6C;CAChF,MAAM,aACJ,OAAO,QAAQ,aAAa,aACxB,QAAQ,iBACF,QAAQ;CAEpB,OAAO,WAAqB;EAC1B,aAAa,gBAAgB,WAAW,CAAC;EACzC,YAAY,QAAQ;EACpB,QAAQ,QAAQ;EAChB,GAAI,QAAQ,aAAa,KAAA,IAAY,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;EACvE,GAAI,QAAQ,eAAe,EAAE,cAAc,QAAQ,aAAa,IAAI,CAAC;EACrE,GAAI,QAAQ,UAAU,KAAA,IAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EAG9D,aAAa,gBAAgB;GAC3B,MAAM,IAAI,MAAM;GAChB,IAAI,EAAE,SAAS,UACb,OAAO,QAAQ,sBACX,QAAQ,0BAA0B,MAAM,EAAE,OAAO,IACjD,cAAc,QAAQ,MAAM,EAAE,QAAQ,SAAS,EAAE;GAEvD,OAAO,QAAQ,iBACN,MAAM,EAA0C,YAChD,MAAM,EAA0C,SACzD;EACF;CACF,CAAC;AACH;;AAGA,SAAgB,YAAe,SAA6C;CAC1E,OAAO,kBAAkB,OAAO;AAClC"}
@@ -0,0 +1,210 @@
1
+ import { ColorScheme } from "./environment.js";
2
+
3
+ //#region src/tokens.d.ts
4
+ /** Spacing scale — 8pt system with 4 as the half-step (handbook §8). */
5
+ declare const space: {
6
+ readonly none: 0;
7
+ readonly '3xs': 2;
8
+ readonly '2xs': 4;
9
+ readonly xs: 8;
10
+ readonly sm: 12;
11
+ readonly md: 16;
12
+ readonly lg: 24;
13
+ readonly xl: 32;
14
+ readonly '2xl': 48;
15
+ readonly '3xl': 64;
16
+ };
17
+ /** Corner-radius scale (handbook §19). */
18
+ declare const radius: {
19
+ readonly none: 0;
20
+ readonly sm: 8;
21
+ readonly md: 12;
22
+ readonly lg: 16;
23
+ readonly xl: 20;
24
+ readonly '2xl': 28;
25
+ readonly full: 9999;
26
+ };
27
+ /** Type scale (≈1.25 ratio, base 16) — handbook §9. */
28
+ declare const fontSize: {
29
+ readonly caption: 12;
30
+ readonly footnote: 13;
31
+ readonly body: 16;
32
+ readonly callout: 17;
33
+ readonly headline: 20;
34
+ readonly title3: 25;
35
+ readonly title2: 31;
36
+ readonly title1: 39;
37
+ readonly display: 49;
38
+ };
39
+ /** Line-height (leading) ratios (handbook §9). */
40
+ declare const lineHeight: {
41
+ readonly tight: 1.2;
42
+ readonly snug: 1.3;
43
+ readonly normal: 1.5;
44
+ readonly relaxed: 1.6;
45
+ };
46
+ /** Font weights (handbook §9 — regular + semibold/bold do most of the work). */
47
+ declare const fontWeight: {
48
+ readonly regular: 400;
49
+ readonly medium: 500;
50
+ readonly semibold: 600;
51
+ readonly bold: 700;
52
+ readonly heavy: 800;
53
+ };
54
+ /** Motion durations in ms (handbook §21: micro/standard/large). */
55
+ declare const duration: {
56
+ readonly micro: 150;
57
+ readonly standard: 250;
58
+ readonly large: 400;
59
+ };
60
+ /** Easing curves (handbook §21: ease-out for enter, ease-in for exit). */
61
+ declare const easing: {
62
+ readonly standard: "cubic-bezier(0.2, 0, 0, 1)";
63
+ readonly decelerate: "cubic-bezier(0, 0, 0, 1)";
64
+ readonly accelerate: "cubic-bezier(0.3, 0, 1, 1)";
65
+ };
66
+ /** Raw color ramps (primitive tier — never apply directly; go through a {@link Theme}). */
67
+ declare const palette: {
68
+ readonly white: "#ffffff";
69
+ readonly black: "#000000";
70
+ readonly neutral: {
71
+ readonly 50: "#f8fafc";
72
+ readonly 100: "#f1f5f9";
73
+ readonly 200: "#e2e8f0";
74
+ readonly 300: "#cbd5e1";
75
+ readonly 400: "#94a3b8";
76
+ readonly 500: "#64748b";
77
+ readonly 600: "#475569";
78
+ readonly 700: "#334155";
79
+ readonly 800: "#1e293b";
80
+ readonly 900: "#0f172a";
81
+ readonly 950: "#020617";
82
+ };
83
+ readonly blue: {
84
+ readonly 400: "#60a5fa";
85
+ readonly 500: "#3b82f6";
86
+ readonly 600: "#2563eb";
87
+ readonly 700: "#1d4ed8";
88
+ };
89
+ readonly green: {
90
+ readonly 400: "#4ade80";
91
+ readonly 500: "#22c55e";
92
+ readonly 600: "#16a34a";
93
+ readonly 700: "#15803d";
94
+ };
95
+ readonly amber: {
96
+ readonly 400: "#fbbf24";
97
+ readonly 500: "#f59e0b";
98
+ readonly 600: "#d97706";
99
+ readonly 700: "#b45309";
100
+ };
101
+ readonly red: {
102
+ readonly 400: "#f87171";
103
+ readonly 500: "#ef4444";
104
+ readonly 600: "#dc2626";
105
+ readonly 700: "#b91c1c";
106
+ };
107
+ };
108
+ /** Non-color scales, grouped for convenience. */
109
+ declare const tokens: {
110
+ readonly space: {
111
+ readonly none: 0;
112
+ readonly '3xs': 2;
113
+ readonly '2xs': 4;
114
+ readonly xs: 8;
115
+ readonly sm: 12;
116
+ readonly md: 16;
117
+ readonly lg: 24;
118
+ readonly xl: 32;
119
+ readonly '2xl': 48;
120
+ readonly '3xl': 64;
121
+ };
122
+ readonly radius: {
123
+ readonly none: 0;
124
+ readonly sm: 8;
125
+ readonly md: 12;
126
+ readonly lg: 16;
127
+ readonly xl: 20;
128
+ readonly '2xl': 28;
129
+ readonly full: 9999;
130
+ };
131
+ readonly fontSize: {
132
+ readonly caption: 12;
133
+ readonly footnote: 13;
134
+ readonly body: 16;
135
+ readonly callout: 17;
136
+ readonly headline: 20;
137
+ readonly title3: 25;
138
+ readonly title2: 31;
139
+ readonly title1: 39;
140
+ readonly display: 49;
141
+ };
142
+ readonly lineHeight: {
143
+ readonly tight: 1.2;
144
+ readonly snug: 1.3;
145
+ readonly normal: 1.5;
146
+ readonly relaxed: 1.6;
147
+ };
148
+ readonly fontWeight: {
149
+ readonly regular: 400;
150
+ readonly medium: 500;
151
+ readonly semibold: 600;
152
+ readonly bold: 700;
153
+ readonly heavy: 800;
154
+ };
155
+ readonly duration: {
156
+ readonly micro: 150;
157
+ readonly standard: 250;
158
+ readonly large: 400;
159
+ };
160
+ readonly easing: {
161
+ readonly standard: "cubic-bezier(0.2, 0, 0, 1)";
162
+ readonly decelerate: "cubic-bezier(0, 0, 0, 1)";
163
+ readonly accelerate: "cubic-bezier(0.3, 0, 1, 1)";
164
+ };
165
+ };
166
+ /** Semantic color roles (handbook §10/§31) — the layer components and apps consume. */
167
+ interface ThemeColors {
168
+ /** App background. */
169
+ readonly bg: string;
170
+ /** Default surface (cards, sheets). */
171
+ readonly surface: string;
172
+ /** A raised/recessed surface variant. */
173
+ readonly surfaceVariant: string;
174
+ /** High-emphasis text. */
175
+ readonly text: string;
176
+ /** Secondary/muted text. */
177
+ readonly textMuted: string;
178
+ /** Hairline borders/dividers. */
179
+ readonly border: string;
180
+ /** Brand/primary action. */
181
+ readonly primary: string;
182
+ /** Foreground on `primary`. */
183
+ readonly onPrimary: string;
184
+ readonly success: string;
185
+ readonly warning: string;
186
+ readonly danger: string;
187
+ readonly info: string;
188
+ /** Foreground on the semantic tone colors. */
189
+ readonly onTone: string;
190
+ }
191
+ /** A resolved theme: a color scheme + its semantic colors. */
192
+ interface Theme {
193
+ readonly colorScheme: ColorScheme;
194
+ readonly color: ThemeColors;
195
+ }
196
+ /** The theme for a given color scheme (non-reactive). */
197
+ declare function getTheme(colorScheme: ColorScheme): Theme;
198
+ /**
199
+ * The active theme as a reactive accessor — flips light↔dark with
200
+ * {@link useColorScheme}. Use it in accessor styles so dark mode is an automatic,
201
+ * fine-grained token swap (only color nodes re-run).
202
+ *
203
+ * @example
204
+ * const theme = useTheme()
205
+ * <View style={() => ({ backgroundColor: theme().color.surface })} />
206
+ */
207
+ declare function useTheme(): () => Theme;
208
+ //#endregion
209
+ export { Theme, ThemeColors, duration, easing, fontSize, fontWeight, getTheme, lineHeight, palette, radius, space, tokens, useTheme };
210
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","names":[],"sources":["../src/tokens.ts"],"mappings":";;;;cAkBa,KAAA;EAAA;;;;;;;;;;;;cAcA,MAAA;EAAA;;;;;;;;;cAWA,QAAA;EAAA;;;;;;;;;;;cAaA,UAAA;EAAA;;;;;;cAGA,UAAA;EAAA;;;;;;;cASA,QAAA;EAAA;;;;;cAGA,MAAA;EAAA;;;;;cAOA,OAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuBA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAKI,WAAA;;WAEN,EAAA;;WAEA,OAAA;EAJiB;EAAA,SAMjB,cAAA;EANiB;EAAA,SAQjB,IAAA;EAJA;EAAA,SAMA,SAAA;EAFA;EAAA,SAIA,MAAA;EAAA;EAAA,SAEA,OAAA;EAEA;EAAA,SAAA,SAAA;EAAA,SACA,OAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA;EAEM;EAAA,SAAN,MAAA;AAAA;;UAIM,KAAA;EAAA,SACN,WAAA,EAAa,WAAA;EAAA,SACb,KAAA,EAAO,WAAW;AAAA;;iBA6Cb,QAAA,CAAS,WAAA,EAAa,WAAA,GAAc,KAAK;;AA7C5B;AA6C7B;;;;;;;iBAagB,QAAA,UAAkB,KAAK"}