@marktiderman/genesis-core 2.13.0 → 2.15.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.
Files changed (94) hide show
  1. package/dist/aggregate-y-qqJioF.d.ts +34 -0
  2. package/dist/{chunk-7PUFVNPB.js → chunk-2IGAUXYH.js} +5 -3
  3. package/dist/chunk-2IGAUXYH.js.map +1 -0
  4. package/dist/{chunk-KA3BUJ4H.js → chunk-42NVJJTT.js} +3 -3
  5. package/dist/{chunk-KA3BUJ4H.js.map → chunk-42NVJJTT.js.map} +1 -1
  6. package/dist/{chunk-JN47G4UE.js → chunk-7EFTWOMA.js} +56 -2
  7. package/dist/chunk-7EFTWOMA.js.map +1 -0
  8. package/dist/{chunk-S2VYJWB4.js → chunk-E3K2A3PK.js} +3 -3
  9. package/dist/{chunk-S2VYJWB4.js.map → chunk-E3K2A3PK.js.map} +1 -1
  10. package/dist/{chunk-SDAJSJNN.js → chunk-IYGVJFCV.js} +3 -3
  11. package/dist/{chunk-SDAJSJNN.js.map → chunk-IYGVJFCV.js.map} +1 -1
  12. package/dist/chunk-J54XXKQD.js +104 -0
  13. package/dist/chunk-J54XXKQD.js.map +1 -0
  14. package/dist/{chunk-OYDJGPDY.js → chunk-JFHRSG6G.js} +5 -5
  15. package/dist/{chunk-OYDJGPDY.js.map → chunk-JFHRSG6G.js.map} +1 -1
  16. package/dist/{chunk-UHOMTFBD.js → chunk-JTRRAVR4.js} +55 -3
  17. package/dist/chunk-JTRRAVR4.js.map +1 -0
  18. package/dist/{chunk-KV2HW4G4.js → chunk-LB6FMQQM.js} +11 -3
  19. package/dist/chunk-LB6FMQQM.js.map +1 -0
  20. package/dist/{chunk-G6GQPXQS.js → chunk-M5IX7C6U.js} +5 -5
  21. package/dist/{chunk-G6GQPXQS.js.map → chunk-M5IX7C6U.js.map} +1 -1
  22. package/dist/{chunk-AHFIS42U.js → chunk-NZP7YQHS.js} +5 -5
  23. package/dist/{chunk-AHFIS42U.js.map → chunk-NZP7YQHS.js.map} +1 -1
  24. package/dist/{chunk-DFABPMEQ.js → chunk-POUI7GAI.js} +5 -5
  25. package/dist/{chunk-DFABPMEQ.js.map → chunk-POUI7GAI.js.map} +1 -1
  26. package/dist/{chunk-NE2D74BP.js → chunk-QGWQ6LK3.js} +5 -5
  27. package/dist/{chunk-NE2D74BP.js.map → chunk-QGWQ6LK3.js.map} +1 -1
  28. package/dist/{chunk-2K4747KX.js → chunk-R3YXYVWF.js} +7 -2
  29. package/dist/chunk-R3YXYVWF.js.map +1 -0
  30. package/dist/{chunk-RFHUOXZC.js → chunk-SOO54YYY.js} +4 -4
  31. package/dist/{chunk-RFHUOXZC.js.map → chunk-SOO54YYY.js.map} +1 -1
  32. package/dist/{chunk-P3FHXRS2.js → chunk-TKK7D2ZT.js} +6 -6
  33. package/dist/{chunk-P3FHXRS2.js.map → chunk-TKK7D2ZT.js.map} +1 -1
  34. package/dist/{chunk-WDPM5TBO.js → chunk-UDSTWXXZ.js} +3 -3
  35. package/dist/{chunk-WDPM5TBO.js.map → chunk-UDSTWXXZ.js.map} +1 -1
  36. package/dist/chunk-XPBS5YE4.js +24 -0
  37. package/dist/chunk-XPBS5YE4.js.map +1 -0
  38. package/dist/csv.d.ts +1 -1
  39. package/dist/form-types.d.ts +1 -1
  40. package/dist/gallery/index.d.ts +5 -0
  41. package/dist/gallery/index.js.map +1 -1
  42. package/dist/hooks/index.d.ts +4 -2
  43. package/dist/hooks/index.js +16 -14
  44. package/dist/hooks/mutation-mode.d.ts +1 -1
  45. package/dist/hooks/mutation-mode.js +5 -4
  46. package/dist/hooks/related-keys.d.ts +1 -1
  47. package/dist/hooks/use-aggregate.d.ts +25 -0
  48. package/dist/hooks/use-aggregate.js +10 -0
  49. package/dist/hooks/use-aggregate.js.map +1 -0
  50. package/dist/hooks/use-capabilities.d.ts +1 -1
  51. package/dist/hooks/use-capabilities.js +4 -2
  52. package/dist/hooks/use-infinite-resource.d.ts +1 -1
  53. package/dist/hooks/use-infinite-resource.js +6 -4
  54. package/dist/hooks/use-link-options.d.ts +1 -1
  55. package/dist/hooks/use-link-options.js +8 -6
  56. package/dist/hooks/use-live.d.ts +1 -1
  57. package/dist/hooks/use-live.js +4 -2
  58. package/dist/hooks/use-one.d.ts +1 -1
  59. package/dist/hooks/use-one.js +6 -4
  60. package/dist/hooks/use-persisted-ui-state.js +4 -2
  61. package/dist/hooks/use-relation-label.d.ts +1 -1
  62. package/dist/hooks/use-relation-label.js +4 -2
  63. package/dist/hooks/use-resource-form.d.ts +1 -1
  64. package/dist/hooks/use-resource-form.js +8 -7
  65. package/dist/hooks/use-resource.d.ts +1 -1
  66. package/dist/hooks/use-resource.js +7 -6
  67. package/dist/hooks/use-write.d.ts +1 -1
  68. package/dist/index.d.ts +110 -6
  69. package/dist/index.js +125 -17
  70. package/dist/index.js.map +1 -1
  71. package/dist/navigation.d.ts +77 -1
  72. package/dist/navigation.js +32 -2
  73. package/dist/navigation.js.map +1 -1
  74. package/dist/provider/index.d.ts +12 -4
  75. package/dist/provider/index.js +3 -2
  76. package/dist/resource-view/index.d.ts +456 -166
  77. package/dist/resource-view/index.js +251 -5
  78. package/dist/resource-view/index.js.map +1 -1
  79. package/dist/schema/index.d.ts +3 -3
  80. package/dist/schema/index.js +1 -2
  81. package/dist/testing/index.d.ts +2 -2
  82. package/dist/{types-CtJxwoyv.d.ts → types-D4Bi_Iq8.d.ts} +76 -3
  83. package/dist/workspaces-BKhloJPK.d.ts +255 -0
  84. package/dist/workspaces.d.ts +2 -160
  85. package/dist/workspaces.js +1 -1
  86. package/dist/{write-outcome-Goy1v39G.d.ts → write-outcome-CHPT7Slm.d.ts} +1 -1
  87. package/package.json +1 -1
  88. package/dist/chunk-2K4747KX.js.map +0 -1
  89. package/dist/chunk-7PUFVNPB.js.map +0 -1
  90. package/dist/chunk-JN47G4UE.js.map +0 -1
  91. package/dist/chunk-KV2HW4G4.js.map +0 -1
  92. package/dist/chunk-UHOMTFBD.js.map +0 -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A,EAAM,KAAA,CAAM,KAAA,CAAM,KAAA,GAAQ,CAAC,CAAA,EAAE;AAC1E","file":"navigation.js","sourcesContent":["/**\n * Router-free, DOM-free navigation: the logical navigation tree and the\n * active-path matcher, shared by the web app shell and native shells.\n * `resolveNavigation` never reads browser history or `window`.\n */\n\n/** `path` without its trailing slashes, in one linear pass (a regex can backtrack on many slashes). */\nfunction trimTrailingSlashes(path: string): string {\n let end = path.length;\n while (end > 0 && path.charCodeAt(end - 1) === 47) end--;\n return path.slice(0, end);\n}\n\n/**\n * Split a href into its path (trailing slash dropped, except for `/`), query\n * (no `?`) and hash (no `#`).\n */\nfunction splitHref(href: string): { path: string; search: string; hash: string } {\n const hashAt = href.indexOf(\"#\");\n const hash = hashAt === -1 ? \"\" : href.slice(hashAt + 1);\n const beforeHash = hashAt === -1 ? href : href.slice(0, hashAt);\n const searchAt = beforeHash.indexOf(\"?\");\n const rawPath = searchAt === -1 ? beforeHash : beforeHash.slice(0, searchAt);\n return {\n path: rawPath.length > 1 ? trimTrailingSlashes(rawPath) || \"/\" : rawPath,\n search: searchAt === -1 ? \"\" : beforeHash.slice(searchAt + 1),\n hash,\n };\n}\n\n/**\n * Options for {@link isPathActive}.\n *\n * @stability Beta\n */\nexport interface IsPathActiveOptions {\n /** Require an exact path match instead of a prefix match (like `NavLink end`). */\n end?: boolean;\n}\n\n/**\n * Default active-path matcher, mirroring React Router's `NavLink` (prefix\n * match, with `/` treated as exact). Consumers can override via an `isActive`\n * prop where components accept one.\n *\n * `activePath` may carry a query and hash (`pathname + search + hash`). An\n * item whose `to` has neither compares against the path part only, exactly as\n * before. An item that opts in by putting a query or hash in its `to`\n * (`/admin?tab=users`, `/settings#profile`) is active only when the path\n * matches exactly AND every query param it names has the same value in\n * `activePath` (extra params such as `&page=2` are ignored) AND, if it names a\n * hash, the hash is equal.\n *\n * @stability Beta\n */\nexport function isPathActive(\n to: string,\n activePath?: string,\n options?: IsPathActiveOptions,\n): boolean {\n if (activePath == null) return false;\n if (to === activePath) return true;\n const target = splitHref(to);\n const current = splitHref(activePath);\n\n if (!target.search && !target.hash) {\n if (target.path === current.path) return true;\n if (options?.end) return false;\n return target.path !== \"/\" && current.path.startsWith(target.path + \"/\");\n }\n\n if (target.path !== current.path) return false;\n if (target.hash && target.hash !== current.hash) return false;\n if (target.search) {\n const want = new URLSearchParams(target.search);\n const have = new URLSearchParams(current.search);\n for (const key of new Set(want.keys())) {\n const wanted = want.getAll(key);\n const had = have.getAll(key);\n if (!wanted.every((value) => had.includes(value))) return false;\n }\n }\n return true;\n}\n\n// ---------------------------------------------------------------------------\n// Hierarchical navigation resolver\n// ---------------------------------------------------------------------------\n\n/**\n * One node of a logical navigation hierarchy. `path` is a route pattern whose\n * segments are either static (`clients`) or named params (`$clientId`). A\n * node's place in the tree is its LOGICAL parent, which need not share its URL\n * prefix — `/clients/$clientId` can sit under `/dashboard`.\n *\n * @stability Beta\n */\nexport interface NavigationNode<T> {\n id: string;\n path: string;\n label: string;\n /** Contextual nav items to show while this node is current. */\n items: T[];\n children?: NavigationNode<T>[];\n /**\n * Ask the app shell to open its desktop sidebar collapsed (icon rail) while\n * this node, or a descendant that doesn't set its own value, is current.\n * The nearest node in the resolved trail that sets it wins, so\n * `defaultCollapsed: false` on a child re-opens it under a collapsed\n * parent. Only a default: once the user has toggled the sidebar, their\n * choice wins everywhere. `AppShell` reads it; `resolveNavigation` copies\n * it through untouched.\n *\n * @stability Beta\n */\n defaultCollapsed?: boolean;\n /**\n * How the app shell shows this node's `items` (its child pages, e.g. a\n * form's Questions / Logic / Responses / Settings). `\"tabs\"` (across the\n * top of the content) or `\"sidebar\"` (nested under the active item) turn\n * shell sub-navigation on, which also gives phones a back item plus the\n * children in the bottom bar. `\"section\"` is the legacy rendering (the\n * shell's default) and `\"off\"` hides them. The nearest node in the trail\n * that sets it wins over the shell's `options.subNav`.\n *\n * @stability Beta\n */\n subNav?: \"section\" | \"tabs\" | \"sidebar\" | \"off\";\n}\n\n/**\n * Result of {@link resolveNavigation}. `current`, `parent` and every `trail`\n * entry are shallow copies of their tree nodes with `path` interpolated from\n * `params` (a param the URL did not supply stays as `$name`).\n *\n * @stability Beta\n */\nexport interface ResolvedNavigation<T> {\n /** The best-matching node — the root when nothing else matches. */\n current: NavigationNode<T>;\n /** `current`'s logical parent, for an \"up\" / back-to-parent link. */\n parent?: NavigationNode<T>;\n /** `current.items`. */\n items: T[];\n /** Root → `current`, inclusive. */\n trail: NavigationNode<T>[];\n /** Params captured by `current.path`, URL-decoded. */\n params: Record<string, string>;\n}\n\nfunction pathSegments(path: string): string[] {\n return splitHref(path).path.split(\"/\").filter(Boolean);\n}\n\nfunction decodeSegment(segment: string): string {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n}\n\n/**\n * Resolve where `pathname` sits in a logical navigation tree. Pure: it never\n * reads browser history or `window`.\n *\n * A node matches when its pattern matches a leading run of WHOLE path\n * segments (`/my` matches `/my/tasks`, never `/my-other`). Among matches the\n * winner is decided by positional specificity: at the first position where\n * one pattern is static and the other a `$param`, the static one wins (so\n * `/clients/new` beats `/clients/$clientId` whatever the sibling order, and\n * `/my` beats `/$space/tasks` for `/my/tasks`). Otherwise the pattern matching\n * more segments wins, then the deeper tree node.\n * Non-matching nodes are still searched, so a match keeps its logical\n * ancestors even when their URLs differ.\n *\n * @stability Beta\n */\nexport function resolveNavigation<T>(\n tree: NavigationNode<T>,\n pathname: string,\n): ResolvedNavigation<T> {\n // Compare decoded forms on both sides, so `/caf%C3%A9` matches a `/café`\n // node (and an encoded pattern matches a decoded pathname).\n const segments = pathSegments(pathname).map(decodeSegment);\n\n type Match = { trail: NavigationNode<T>[]; pattern: string[] };\n const matches = (pattern: string[]) =>\n pattern.length <= segments.length &&\n pattern.every(\n (part, i) => part.startsWith(\"$\") || decodeSegment(part) === segments[i],\n );\n\n // > 0 when `a` should win over `b`.\n // Positional specificity, as TanStack Router and React Router rank routes:\n // walking left to right, the first position where one pattern is static and\n // the other a `$param` decides. Only then does the longer match win.\n const compare = (a: Match, b: Match): number => {\n const shared = Math.min(a.pattern.length, b.pattern.length);\n for (let i = 0; i < shared; i++) {\n const aParam = a.pattern[i]!.startsWith(\"$\");\n const bParam = b.pattern[i]!.startsWith(\"$\");\n if (aParam !== bParam) return aParam ? -1 : 1;\n }\n if (a.pattern.length !== b.pattern.length) {\n return a.pattern.length - b.pattern.length;\n }\n return a.trail.length - b.trail.length;\n };\n\n let best: Match | undefined;\n const visit = (node: NavigationNode<T>, ancestors: NavigationNode<T>[]) => {\n const trail = [...ancestors, node];\n const pattern = pathSegments(node.path);\n if (matches(pattern)) {\n const candidate = { trail, pattern };\n if (!best || compare(candidate, best) > 0) best = candidate;\n }\n for (const child of node.children ?? []) visit(child, trail);\n };\n visit(tree, []);\n\n const winner: Match = best ?? { trail: [tree], pattern: [] };\n const params: Record<string, string> = {};\n winner.pattern.forEach((part, i) => {\n if (part.startsWith(\"$\")) params[part.slice(1)] = segments[i]!;\n });\n\n const interpolate = (node: NavigationNode<T>): NavigationNode<T> => ({\n ...node,\n path: node.path\n .split(\"/\")\n .map((part) => {\n if (!part.startsWith(\"$\")) return part;\n const value = params[part.slice(1)];\n return value == null ? part : encodeURIComponent(value);\n })\n .join(\"/\"),\n });\n\n const trail = winner.trail.map(interpolate);\n const current = trail[trail.length - 1]!;\n return {\n current,\n parent: trail.length > 1 ? trail[trail.length - 2] : undefined,\n items: current.items,\n trail,\n params,\n };\n}\n\n/**\n * Most slots a phone bottom tab bar shows before the rest go under \"More\".\n *\n * @stability Beta\n */\nexport const TAB_BAR_MAX = 5;\n\n/**\n * A phone bottom tab bar's split: up to `max` items fit; beyond that, the first `max - 1` show\n * and the rest go under \"More\" in the last slot. Pure, so the web `TabBar`, AppShell's phone\n * bottom nav and genesis-ui-native's `NativeTabBar` all split the same way.\n *\n * @stability Beta\n */\nexport function splitTabBarItems<T>(items: readonly T[], max: number = TAB_BAR_MAX): { shown: T[]; more: T[] } {\n const slots = Math.max(1, max);\n if (items.length <= slots) return { shown: [...items], more: [] };\n return { shown: items.slice(0, slots - 1), more: items.slice(slots - 1) };\n}\n"]}
1
+ {"version":3,"sources":["../src/navigation.ts"],"names":["trail"],"mappings":";AAOA,SAAS,oBAAoB,IAAA,EAAsB;AACjD,EAAA,IAAI,MAAM,IAAA,CAAK,MAAA;AACf,EAAA,OAAO,MAAM,CAAA,IAAK,IAAA,CAAK,WAAW,GAAA,GAAM,CAAC,MAAM,EAAA,EAAI,GAAA,EAAA;AACnD,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAG,CAAA;AAC1B;AAMA,SAAS,UAAU,IAAA,EAA8D;AAC/E,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA;AAC/B,EAAA,MAAM,OAAO,MAAA,KAAW,EAAA,GAAK,KAAK,IAAA,CAAK,KAAA,CAAM,SAAS,CAAC,CAAA;AACvD,EAAA,MAAM,aAAa,MAAA,KAAW,EAAA,GAAK,OAAO,IAAA,CAAK,KAAA,CAAM,GAAG,MAAM,CAAA;AAC9D,EAAA,MAAM,QAAA,GAAW,UAAA,CAAW,OAAA,CAAQ,GAAG,CAAA;AACvC,EAAA,MAAM,UAAU,QAAA,KAAa,EAAA,GAAK,aAAa,UAAA,CAAW,KAAA,CAAM,GAAG,QAAQ,CAAA;AAC3E,EAAA,OAAO;AAAA,IACL,MAAM,OAAA,CAAQ,MAAA,GAAS,IAAI,mBAAA,CAAoB,OAAO,KAAK,GAAA,GAAM,OAAA;AAAA,IACjE,QAAQ,QAAA,KAAa,EAAA,GAAK,KAAK,UAAA,CAAW,KAAA,CAAM,WAAW,CAAC,CAAA;AAAA,IAC5D;AAAA,GACF;AACF;AA2BO,SAAS,YAAA,CACd,EAAA,EACA,UAAA,EACA,OAAA,EACS;AACT,EAAA,IAAI,UAAA,IAAc,MAAM,OAAO,KAAA;AAC/B,EAAA,IAAI,EAAA,KAAO,YAAY,OAAO,IAAA;AAC9B,EAAA,MA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, DOM-free navigation: the logical navigation tree and the\n * active-path matcher, shared by the web app shell and native shells.\n * `resolveNavigation` never reads browser history or `window`.\n */\n\n/** `path` without its trailing slashes, in one linear pass (a regex can backtrack on many slashes). */\nfunction trimTrailingSlashes(path: string): string {\n let end = path.length;\n while (end > 0 && path.charCodeAt(end - 1) === 47) end--;\n return path.slice(0, end);\n}\n\n/**\n * Split a href into its path (trailing slash dropped, except for `/`), query\n * (no `?`) and hash (no `#`).\n */\nfunction splitHref(href: string): { path: string; search: string; hash: string } {\n const hashAt = href.indexOf(\"#\");\n const hash = hashAt === -1 ? \"\" : href.slice(hashAt + 1);\n const beforeHash = hashAt === -1 ? href : href.slice(0, hashAt);\n const searchAt = beforeHash.indexOf(\"?\");\n const rawPath = searchAt === -1 ? beforeHash : beforeHash.slice(0, searchAt);\n return {\n path: rawPath.length > 1 ? trimTrailingSlashes(rawPath) || \"/\" : rawPath,\n search: searchAt === -1 ? \"\" : beforeHash.slice(searchAt + 1),\n hash,\n };\n}\n\n/**\n * Options for {@link isPathActive}.\n *\n * @stability Beta\n */\nexport interface IsPathActiveOptions {\n /** Require an exact path match instead of a prefix match (like `NavLink end`). */\n end?: boolean;\n}\n\n/**\n * Default active-path matcher, mirroring React Router's `NavLink` (prefix\n * match, with `/` treated as exact). Consumers can override via an `isActive`\n * prop where components accept one.\n *\n * `activePath` may carry a query and hash (`pathname + search + hash`). An\n * item whose `to` has neither compares against the path part only, exactly as\n * before. An item that opts in by putting a query or hash in its `to`\n * (`/admin?tab=users`, `/settings#profile`) is active only when the path\n * matches exactly AND every query param it names has the same value in\n * `activePath` (extra params such as `&page=2` are ignored) AND, if it names a\n * hash, the hash is equal.\n *\n * @stability Beta\n */\nexport function isPathActive(\n to: string,\n activePath?: string,\n options?: IsPathActiveOptions,\n): boolean {\n if (activePath == null) return false;\n if (to === activePath) return true;\n const target = splitHref(to);\n const current = splitHref(activePath);\n\n if (!target.search && !target.hash) {\n if (target.path === current.path) return true;\n if (options?.end) return false;\n return target.path !== \"/\" && current.path.startsWith(target.path + \"/\");\n }\n\n if (target.path !== current.path) return false;\n if (target.hash && target.hash !== current.hash) return false;\n if (target.search) {\n const want = new URLSearchParams(target.search);\n const have = new URLSearchParams(current.search);\n for (const key of new Set(want.keys())) {\n const wanted = want.getAll(key);\n const had = have.getAll(key);\n if (!wanted.every((value) => had.includes(value))) return false;\n }\n }\n return true;\n}\n\n// ---------------------------------------------------------------------------\n// Hierarchical navigation resolver\n// ---------------------------------------------------------------------------\n\n/**\n * One node of a logical navigation hierarchy. `path` is a route pattern whose\n * segments are either static (`clients`) or named params (`$clientId`). A\n * node's place in the tree is its LOGICAL parent, which need not share its URL\n * prefix — `/clients/$clientId` can sit under `/dashboard`.\n *\n * @stability Beta\n */\nexport interface NavigationNode<T> {\n id: string;\n path: string;\n label: string;\n /** Contextual nav items to show while this node is current. */\n items: T[];\n children?: NavigationNode<T>[];\n /**\n * Ask the app shell to open its desktop sidebar collapsed (icon rail) while\n * this node, or a descendant that doesn't set its own value, is current.\n * The nearest node in the resolved trail that sets it wins, so\n * `defaultCollapsed: false` on a child re-opens it under a collapsed\n * parent. Only a default: once the user has toggled the sidebar, their\n * choice wins everywhere. `AppShell` reads it; `resolveNavigation` copies\n * it through untouched.\n *\n * @stability Beta\n */\n defaultCollapsed?: boolean;\n /**\n * How the app shell shows this node's `items` (its child pages, e.g. a\n * form's Questions / Logic / Responses / Settings). `\"tabs\"` (across the\n * top of the content) or `\"sidebar\"` (nested under the active item) turn\n * shell sub-navigation on, which also gives phones a back item plus the\n * children in the bottom bar. `\"section\"` is the legacy rendering (the\n * shell's default) and `\"off\"` hides them. The nearest node in the trail\n * that sets it wins over the shell's `options.subNav`.\n *\n * @stability Beta\n */\n subNav?: \"section\" | \"tabs\" | \"sidebar\" | \"off\";\n /**\n * The zone this node and its descendants sit in (ADR 0003): a kind of work\n * the viewer enters (their own work, training, admin). A descendant that\n * names no zone of its own is in its nearest ancestor's; a node with none\n * above it is global (settings, messages, help). `resolveNavigation`\n * reports the current zone as `zone`, so an app can key a theme on it;\n * `resolveNavigationZones` groups the tree by zone.\n *\n * @stability Beta\n */\n zone?: string;\n}\n\n/**\n * One zone of an app's navigation (ADR 0003 §1): an ordered entry with an id\n * the tree's `zone` names, a label and an optional icon (the app's own icon\n * type, `I`).\n *\n * @stability Beta\n */\nexport interface NavigationZone<I = unknown> {\n id: string;\n label: string;\n icon?: I;\n}\n\n/**\n * Result of {@link resolveNavigation}. `current`, `parent` and every `trail`\n * entry are shallow copies of their tree nodes with `path` interpolated from\n * `params` (a param the URL did not supply stays as `$name`).\n *\n * @stability Beta\n */\nexport interface ResolvedNavigation<T> {\n /** The best-matching node — the root when nothing else matches. */\n current: NavigationNode<T>;\n /** `current`'s logical parent, for an \"up\" / back-to-parent link. */\n parent?: NavigationNode<T>;\n /** `current.items`. */\n items: T[];\n /** Root → `current`, inclusive. */\n trail: NavigationNode<T>[];\n /** Params captured by `current.path`, URL-decoded. */\n params: Record<string, string>;\n /**\n * The zone the location is in: the `zone` of the nearest node in `trail`\n * that names one, so a page opened from a zone's list keeps that zone\n * through its logical parents. `undefined` on a global page.\n *\n * @stability Beta\n */\n zone?: string;\n}\n\nfunction pathSegments(path: string): string[] {\n return splitHref(path).path.split(\"/\").filter(Boolean);\n}\n\nfunction decodeSegment(segment: string): string {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n}\n\n/**\n * Resolve where `pathname` sits in a logical navigation tree. Pure: it never\n * reads browser history or `window`.\n *\n * A node matches when its pattern matches a leading run of WHOLE path\n * segments (`/my` matches `/my/tasks`, never `/my-other`). Among matches the\n * winner is decided by positional specificity: at the first position where\n * one pattern is static and the other a `$param`, the static one wins (so\n * `/clients/new` beats `/clients/$clientId` whatever the sibling order, and\n * `/my` beats `/$space/tasks` for `/my/tasks`). Otherwise the pattern matching\n * more segments wins, then the deeper tree node.\n * Non-matching nodes are still searched, so a match keeps its logical\n * ancestors even when their URLs differ.\n *\n * @stability Beta\n */\nexport function resolveNavigation<T>(\n tree: NavigationNode<T>,\n pathname: string,\n): ResolvedNavigation<T> {\n // Compare decoded forms on both sides, so `/caf%C3%A9` matches a `/café`\n // node (and an encoded pattern matches a decoded pathname).\n const segments = pathSegments(pathname).map(decodeSegment);\n\n type Match = { trail: NavigationNode<T>[]; pattern: string[] };\n const matches = (pattern: string[]) =>\n pattern.length <= segments.length &&\n pattern.every(\n (part, i) => part.startsWith(\"$\") || decodeSegment(part) === segments[i],\n );\n\n // > 0 when `a` should win over `b`.\n // Positional specificity, as TanStack Router and React Router rank routes:\n // walking left to right, the first position where one pattern is static and\n // the other a `$param` decides. Only then does the longer match win.\n const compare = (a: Match, b: Match): number => {\n const shared = Math.min(a.pattern.length, b.pattern.length);\n for (let i = 0; i < shared; i++) {\n const aParam = a.pattern[i]!.startsWith(\"$\");\n const bParam = b.pattern[i]!.startsWith(\"$\");\n if (aParam !== bParam) return aParam ? -1 : 1;\n }\n if (a.pattern.length !== b.pattern.length) {\n return a.pattern.length - b.pattern.length;\n }\n return a.trail.length - b.trail.length;\n };\n\n let best: Match | undefined;\n const visit = (node: NavigationNode<T>, ancestors: NavigationNode<T>[]) => {\n const trail = [...ancestors, node];\n const pattern = pathSegments(node.path);\n if (matches(pattern)) {\n const candidate = { trail, pattern };\n if (!best || compare(candidate, best) > 0) best = candidate;\n }\n for (const child of node.children ?? []) visit(child, trail);\n };\n visit(tree, []);\n\n const winner: Match = best ?? { trail: [tree], pattern: [] };\n const params: Record<string, string> = {};\n winner.pattern.forEach((part, i) => {\n if (part.startsWith(\"$\")) params[part.slice(1)] = segments[i]!;\n });\n\n const interpolate = (node: NavigationNode<T>): NavigationNode<T> => ({\n ...node,\n path: node.path\n .split(\"/\")\n .map((part) => {\n if (!part.startsWith(\"$\")) return part;\n const value = params[part.slice(1)];\n return value == null ? part : encodeURIComponent(value);\n })\n .join(\"/\"),\n });\n\n const trail = winner.trail.map(interpolate);\n const current = trail[trail.length - 1]!;\n const zone = [...trail].reverse().find((node) => node.zone !== undefined)?.zone;\n return {\n current,\n parent: trail.length > 1 ? trail[trail.length - 2] : undefined,\n items: current.items,\n trail,\n params,\n ...(zone !== undefined ? { zone } : {}),\n };\n}\n\n/**\n * Result of {@link resolveNavigationZones}.\n *\n * @stability Beta\n */\nexport interface ResolvedNavigationZones<T, I = unknown> {\n /** The tree resolved against the location, as `resolveNavigation` returns it. */\n navigation: ResolvedNavigation<T>;\n /** The zone the location is in (`navigation.zone`'s entry), or `undefined` on a global page or the roll-up. */\n zone?: NavigationZone<I>;\n /**\n * The zones that have a page, in the order given, each with the top nodes\n * of its pages (a node whose parent is in another zone or none). A zone\n * with no page in the tree is left out: filter the tree for the viewer\n * first, and access decides which zones show (ADR 0003 §1).\n */\n zones: Array<{ zone: NavigationZone<I>; nodes: NavigationNode<T>[] }>;\n /** The root's children in no zone: pages shown in every zone (settings, messages, help). */\n global: NavigationNode<T>[];\n /** The roll-up page above the zones, when `options.rollUp` names one that is in the tree. */\n rollUp?: NavigationNode<T>;\n}\n\n/**\n * Lay an app's zones over its navigation tree (ADR 0003 §1 and §4): which zone\n * the location is in, each zone's pages, the global pages and the roll-up.\n * Pure, so web and native shells use the same answer; an app with no zones\n * gets every top page in `global` and no `zone`.\n *\n * ```ts\n * const { zone } = resolveNavigationZones(tree, pathname, { zones: ZONES });\n * const theme = THEMES[zone?.id ?? \"home\"]; // a theme per zone\n * ```\n *\n * A zone id the tree names but `zones` doesn't list is ignored (its pages\n * read as global), so a stale id never invents a zone.\n *\n * @stability Beta\n */\nexport function resolveNavigationZones<T, I = unknown>(\n tree: NavigationNode<T>,\n pathname: string,\n options: { zones: readonly NavigationZone<I>[]; rollUp?: string } = { zones: [] },\n): ResolvedNavigationZones<T, I> {\n const known = new Map(options.zones.map((z) => [z.id, z] as const));\n const effective = (own: string | undefined, inherited: string | undefined) =>\n own !== undefined && known.has(own) ? own : inherited;\n const byZone = new Map<string, NavigationNode<T>[]>();\n const global: NavigationNode<T>[] = [];\n let rollUp: NavigationNode<T> | undefined;\n const visit = (node: NavigationNode<T>, parentZone: string | undefined, depth: number) => {\n const zone = effective(node.zone, parentZone);\n if (depth > 0 && options.rollUp !== undefined && node.id === options.rollUp) rollUp = node;\n else if (depth > 0 && zone !== undefined && zone !== parentZone) {\n const list = byZone.get(zone) ?? [];\n list.push(node);\n byZone.set(zone, list);\n } else if (depth === 1 && zone === undefined) global.push(node);\n for (const child of node.children ?? []) visit(child, zone, depth + 1);\n };\n visit(tree, effective(tree.zone, undefined), 0);\n const navigation = resolveNavigation(tree, pathname);\n const currentId = [...navigation.trail].reverse().find((node) => node.zone !== undefined && known.has(node.zone))?.zone;\n const current = currentId !== undefined ? known.get(currentId) : undefined;\n return {\n navigation,\n ...(current ? { zone: current } : {}),\n zones: options.zones.filter((z) => byZone.has(z.id)).map((zone) => ({ zone, nodes: byZone.get(zone.id)! })),\n global,\n ...(rollUp ? { rollUp } : {}),\n };\n}\n\n/**\n * Most slots a phone bottom tab bar shows before the rest go under \"More\".\n *\n * @stability Beta\n */\nexport const TAB_BAR_MAX = 5;\n\n/**\n * A phone bottom tab bar's split: up to `max` items fit; beyond that, the first `max - 1` show\n * and the rest go under \"More\" in the last slot. Pure, so the web `TabBar`, AppShell's phone\n * bottom nav and genesis-ui-native's `NativeTabBar` all split the same way.\n *\n * @stability Beta\n */\nexport function splitTabBarItems<T>(items: readonly T[], max: number = TAB_BAR_MAX): { shown: T[]; more: T[] } {\n const slots = Math.max(1, max);\n if (items.length <= slots) return { shown: [...items], more: [] };\n return { shown: items.slice(0, slots - 1), more: items.slice(slots - 1) };\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { D as DataProvider, b as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, a as FilterParam } from '../types-CtJxwoyv.js';
2
- export { A as ArrayFilter, d as BulkChange, e as BulkResult, f as CreateParams, g as CreateResult, i as DeleteParams, j as DeleteResult, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, L as ListParams, s as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, w as ResourceChangeEvent, M as RowFailure, Q as ScalarFilter, S as SortParam, V as SubscribeParams, X as UpdateParams, Y as UpdateResult } from '../types-CtJxwoyv.js';
3
- import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-Goy1v39G.js';
4
- export { a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataWriteError } from '../write-outcome-Goy1v39G.js';
1
+ import { D as DataProvider, d as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, n as CountMode, a as FilterParam } from '../types-D4Bi_Iq8.js';
2
+ export { i as AggregateMetric, A as AggregateParams, b as AggregateResult, k as ArrayFilter, l as BulkChange, m as BulkResult, o as CreateParams, p as CreateResult, q as DeleteParams, r as DeleteResult, G as GetManyParams, v as GetManyResult, w as GetOneParams, x as GetOneResult, H as HistoryParams, y as ImportParams, c as ListParams, L as ListResult, N as NullFilter, z as PaginationParam, E as RangeFilter, g as ResourceChangeEvent, V as RowFailure, Y as ScalarFilter, S as SortParam, f as SubscribeParams, $ as UpdateParams, a0 as UpdateResult } from '../types-D4Bi_Iq8.js';
3
+ export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from '../aggregate-y-qqJioF.js';
4
+ import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-CHPT7Slm.js';
5
+ export { a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataWriteError } from '../write-outcome-CHPT7Slm.js';
5
6
  import { D as DataReadError, R as ReadOutcome } from '../read-outcome-BnboMYOV.js';
6
7
  export { a as DataReadErrorOptions, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
7
8
  import * as react from 'react';
@@ -307,6 +308,13 @@ interface SupabaseProviderOptions {
307
308
  * gives it.
308
309
  */
309
310
  realtime?: boolean | readonly string[] | ((resource: string) => boolean);
311
+ /**
312
+ * Work out `sum`, `avg`, `min` and `max` in the database with PostgREST's aggregate functions
313
+ * (`amount.sum()`), which a project turns on with `pgrst.db_aggregates_enabled`. Off by
314
+ * default: `aggregate` then counts in the database and totals the other metrics from the
315
+ * rows, paged (`resolveAggregate`, up to 10 000 rows). A count is always the database's.
316
+ */
317
+ aggregateFunctions?: boolean;
310
318
  }
311
319
  /**
312
320
  * The Supabase data provider. Reads and writes go through the client you
@@ -1,5 +1,6 @@
1
- export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-JN47G4UE.js';
2
- export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-2K4747KX.js';
1
+ export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-7EFTWOMA.js';
2
+ export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-R3YXYVWF.js';
3
+ export { aggregateProblems, resolveAggregate, toAggregateValues } from '../chunk-J54XXKQD.js';
3
4
  import '../chunk-4PTQYT5J.js';
4
5
  export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from '../chunk-NOPS5EIH.js';
5
6
  export { DataReadError, isDataReadError, readFailureMessage } from '../chunk-HUNGCTRA.js';