@tanstack/solid-router 1.132.0-alpha.12 → 1.132.0-alpha.15

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.
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const routerCore = require("@tanstack/router-core");
4
- const Solid = require("solid-js");
5
- const useMatch = require("./useMatch.cjs");
6
- const useRouter = require("./useRouter.cjs");
7
- const useRouterState = require("./useRouterState.cjs");
8
- function useActiveLocation(location) {
9
- const router = useRouter.useRouter();
10
- const [activeLocation, setActiveLocation] = Solid.createSignal(
11
- location ?? useRouterState.useRouterState({ select: (s) => s.location })()
12
- );
13
- const [customActiveLocation, setCustomActiveLocation] = Solid.createSignal(location);
14
- Solid.createEffect(() => {
15
- setActiveLocation(
16
- customActiveLocation() ?? useRouterState.useRouterState({ select: (s) => s.location })()
17
- );
18
- });
19
- const matchIndex = useMatch.useMatch({
20
- strict: false,
21
- select: (match) => match.index
22
- });
23
- const getFromPath = (from) => Solid.createMemo(() => {
24
- const activeLocationMatches = router.matchRoutes(
25
- customActiveLocation() ?? activeLocation(),
26
- {
27
- _buildLocation: false
28
- }
29
- );
30
- const activeLocationMatch = routerCore.last(activeLocationMatches);
31
- return from ?? activeLocationMatch?.fullPath ?? router.state.matches[matchIndex()].fullPath;
32
- });
33
- return {
34
- activeLocation,
35
- getFromPath,
36
- setActiveLocation: setCustomActiveLocation
37
- };
38
- }
39
- exports.useActiveLocation = useActiveLocation;
40
- //# sourceMappingURL=useActiveLocation.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useActiveLocation.cjs","sources":["../../src/useActiveLocation.ts"],"sourcesContent":["import { last } from '@tanstack/router-core'\nimport { createEffect, createMemo, createSignal } from 'solid-js'\nimport { useMatch } from './useMatch'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport type { Accessor } from 'solid-js'\nimport type { ParsedLocation } from '@tanstack/router-core'\n\nexport type UseLocationResult = {\n activeLocation: Accessor<ParsedLocation>\n getFromPath: (from?: string) => Accessor<string>\n setActiveLocation: (location?: ParsedLocation) => void\n}\n\nexport function useActiveLocation(\n location?: ParsedLocation,\n): UseLocationResult {\n const router = useRouter()\n // we are not using a variable here for router state location since we need to only calculate that if the location is not passed in. It can result in unnecessary history actions if we do that.\n const [activeLocation, setActiveLocation] = createSignal<ParsedLocation>(\n location ?? useRouterState({ select: (s) => s.location })(),\n )\n const [customActiveLocation, setCustomActiveLocation] = createSignal<\n ParsedLocation | undefined\n >(location)\n\n createEffect(() => {\n setActiveLocation(\n customActiveLocation() ?? useRouterState({ select: (s) => s.location })(),\n )\n })\n\n const matchIndex = useMatch({\n strict: false,\n select: (match) => match.index,\n })\n\n const getFromPath = (from?: string) =>\n createMemo(() => {\n const activeLocationMatches = router.matchRoutes(\n customActiveLocation() ?? activeLocation(),\n {\n _buildLocation: false,\n },\n )\n\n const activeLocationMatch = last(activeLocationMatches)\n\n return (\n from ??\n activeLocationMatch?.fullPath ??\n router.state.matches[matchIndex()]!.fullPath\n )\n })\n\n return {\n activeLocation,\n getFromPath,\n setActiveLocation: setCustomActiveLocation,\n }\n}\n"],"names":["useRouter","createSignal","useRouterState","createEffect","useMatch","createMemo","last"],"mappings":";;;;;;;AAcO,SAAS,kBACd,UACmB;AACnB,QAAM,SAASA,UAAAA,UAAA;AAEf,QAAM,CAAC,gBAAgB,iBAAiB,IAAIC,MAAAA;AAAAA,IAC1C,YAAYC,eAAAA,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAA;AAAA,EAAE;AAE5D,QAAM,CAAC,sBAAsB,uBAAuB,IAAID,MAAAA,aAEtD,QAAQ;AAEVE,QAAAA,aAAa,MAAM;AACjB;AAAA,MACE,qBAAA,KAA0BD,eAAAA,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAA;AAAA,IAAE;AAAA,EAE5E,CAAC;AAED,QAAM,aAAaE,SAAAA,SAAS;AAAA,IAC1B,QAAQ;AAAA,IACR,QAAQ,CAAC,UAAU,MAAM;AAAA,EAAA,CAC1B;AAED,QAAM,cAAc,CAAC,SACnBC,MAAAA,WAAW,MAAM;AACf,UAAM,wBAAwB,OAAO;AAAA,MACnC,qBAAA,KAA0B,eAAA;AAAA,MAC1B;AAAA,QACE,gBAAgB;AAAA,MAAA;AAAA,IAClB;AAGF,UAAM,sBAAsBC,WAAAA,KAAK,qBAAqB;AAEtD,WACE,QACA,qBAAqB,YACrB,OAAO,MAAM,QAAQ,WAAA,CAAY,EAAG;AAAA,EAExC,CAAC;AAEH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,EAAA;AAEvB;;"}
@@ -1,8 +0,0 @@
1
- import { Accessor } from 'solid-js';
2
- import { ParsedLocation } from '@tanstack/router-core';
3
- export type UseLocationResult = {
4
- activeLocation: Accessor<ParsedLocation>;
5
- getFromPath: (from?: string) => Accessor<string>;
6
- setActiveLocation: (location?: ParsedLocation) => void;
7
- };
8
- export declare function useActiveLocation(location?: ParsedLocation): UseLocationResult;
@@ -1,8 +0,0 @@
1
- import { Accessor } from 'solid-js';
2
- import { ParsedLocation } from '@tanstack/router-core';
3
- export type UseLocationResult = {
4
- activeLocation: Accessor<ParsedLocation>;
5
- getFromPath: (from?: string) => Accessor<string>;
6
- setActiveLocation: (location?: ParsedLocation) => void;
7
- };
8
- export declare function useActiveLocation(location?: ParsedLocation): UseLocationResult;
@@ -1,40 +0,0 @@
1
- import { last } from "@tanstack/router-core";
2
- import { createSignal, createEffect, createMemo } from "solid-js";
3
- import { useMatch } from "./useMatch.js";
4
- import { useRouter } from "./useRouter.js";
5
- import { useRouterState } from "./useRouterState.js";
6
- function useActiveLocation(location) {
7
- const router = useRouter();
8
- const [activeLocation, setActiveLocation] = createSignal(
9
- location ?? useRouterState({ select: (s) => s.location })()
10
- );
11
- const [customActiveLocation, setCustomActiveLocation] = createSignal(location);
12
- createEffect(() => {
13
- setActiveLocation(
14
- customActiveLocation() ?? useRouterState({ select: (s) => s.location })()
15
- );
16
- });
17
- const matchIndex = useMatch({
18
- strict: false,
19
- select: (match) => match.index
20
- });
21
- const getFromPath = (from) => createMemo(() => {
22
- const activeLocationMatches = router.matchRoutes(
23
- customActiveLocation() ?? activeLocation(),
24
- {
25
- _buildLocation: false
26
- }
27
- );
28
- const activeLocationMatch = last(activeLocationMatches);
29
- return from ?? activeLocationMatch?.fullPath ?? router.state.matches[matchIndex()].fullPath;
30
- });
31
- return {
32
- activeLocation,
33
- getFromPath,
34
- setActiveLocation: setCustomActiveLocation
35
- };
36
- }
37
- export {
38
- useActiveLocation
39
- };
40
- //# sourceMappingURL=useActiveLocation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useActiveLocation.js","sources":["../../src/useActiveLocation.ts"],"sourcesContent":["import { last } from '@tanstack/router-core'\nimport { createEffect, createMemo, createSignal } from 'solid-js'\nimport { useMatch } from './useMatch'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport type { Accessor } from 'solid-js'\nimport type { ParsedLocation } from '@tanstack/router-core'\n\nexport type UseLocationResult = {\n activeLocation: Accessor<ParsedLocation>\n getFromPath: (from?: string) => Accessor<string>\n setActiveLocation: (location?: ParsedLocation) => void\n}\n\nexport function useActiveLocation(\n location?: ParsedLocation,\n): UseLocationResult {\n const router = useRouter()\n // we are not using a variable here for router state location since we need to only calculate that if the location is not passed in. It can result in unnecessary history actions if we do that.\n const [activeLocation, setActiveLocation] = createSignal<ParsedLocation>(\n location ?? useRouterState({ select: (s) => s.location })(),\n )\n const [customActiveLocation, setCustomActiveLocation] = createSignal<\n ParsedLocation | undefined\n >(location)\n\n createEffect(() => {\n setActiveLocation(\n customActiveLocation() ?? useRouterState({ select: (s) => s.location })(),\n )\n })\n\n const matchIndex = useMatch({\n strict: false,\n select: (match) => match.index,\n })\n\n const getFromPath = (from?: string) =>\n createMemo(() => {\n const activeLocationMatches = router.matchRoutes(\n customActiveLocation() ?? activeLocation(),\n {\n _buildLocation: false,\n },\n )\n\n const activeLocationMatch = last(activeLocationMatches)\n\n return (\n from ??\n activeLocationMatch?.fullPath ??\n router.state.matches[matchIndex()]!.fullPath\n )\n })\n\n return {\n activeLocation,\n getFromPath,\n setActiveLocation: setCustomActiveLocation,\n }\n}\n"],"names":[],"mappings":";;;;;AAcO,SAAS,kBACd,UACmB;AACnB,QAAM,SAAS,UAAA;AAEf,QAAM,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,YAAY,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAA;AAAA,EAAE;AAE5D,QAAM,CAAC,sBAAsB,uBAAuB,IAAI,aAEtD,QAAQ;AAEV,eAAa,MAAM;AACjB;AAAA,MACE,qBAAA,KAA0B,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAA;AAAA,IAAE;AAAA,EAE5E,CAAC;AAED,QAAM,aAAa,SAAS;AAAA,IAC1B,QAAQ;AAAA,IACR,QAAQ,CAAC,UAAU,MAAM;AAAA,EAAA,CAC1B;AAED,QAAM,cAAc,CAAC,SACnB,WAAW,MAAM;AACf,UAAM,wBAAwB,OAAO;AAAA,MACnC,qBAAA,KAA0B,eAAA;AAAA,MAC1B;AAAA,QACE,gBAAgB;AAAA,MAAA;AAAA,IAClB;AAGF,UAAM,sBAAsB,KAAK,qBAAqB;AAEtD,WACE,QACA,qBAAqB,YACrB,OAAO,MAAM,QAAQ,WAAA,CAAY,EAAG;AAAA,EAExC,CAAC;AAEH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,EAAA;AAEvB;"}
@@ -1,8 +0,0 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { ParsedLocation } from '@tanstack/router-core';
3
- export type UseLocationResult = {
4
- activeLocation: Accessor<ParsedLocation>;
5
- getFromPath: (from?: string) => Accessor<string>;
6
- setActiveLocation: (location?: ParsedLocation) => void;
7
- };
8
- export declare function useActiveLocation(location?: ParsedLocation): UseLocationResult;
@@ -1,33 +0,0 @@
1
- import { last } from '@tanstack/router-core';
2
- import { createEffect, createMemo, createSignal } from 'solid-js';
3
- import { useMatch } from './useMatch';
4
- import { useRouter } from './useRouter';
5
- import { useRouterState } from './useRouterState';
6
- export function useActiveLocation(location) {
7
- const router = useRouter();
8
- // we are not using a variable here for router state location since we need to only calculate that if the location is not passed in. It can result in unnecessary history actions if we do that.
9
- const [activeLocation, setActiveLocation] = createSignal(location ?? useRouterState({ select: (s) => s.location })());
10
- const [customActiveLocation, setCustomActiveLocation] = createSignal(location);
11
- createEffect(() => {
12
- setActiveLocation(customActiveLocation() ?? useRouterState({ select: (s) => s.location })());
13
- });
14
- const matchIndex = useMatch({
15
- strict: false,
16
- select: (match) => match.index,
17
- });
18
- const getFromPath = (from) => createMemo(() => {
19
- const activeLocationMatches = router.matchRoutes(customActiveLocation() ?? activeLocation(), {
20
- _buildLocation: false,
21
- });
22
- const activeLocationMatch = last(activeLocationMatches);
23
- return (from ??
24
- activeLocationMatch?.fullPath ??
25
- router.state.matches[matchIndex()].fullPath);
26
- });
27
- return {
28
- activeLocation,
29
- getFromPath,
30
- setActiveLocation: setCustomActiveLocation,
31
- };
32
- }
33
- //# sourceMappingURL=useActiveLocation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useActiveLocation.js","sourceRoot":"","sources":["../../src/useActiveLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAUjD,MAAM,UAAU,iBAAiB,CAC/B,QAAyB;IAEzB,MAAM,MAAM,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createMemo, createSignal } from 'solid-js'
3
- import { useMatch } from './useMatch'
4
- import { useRouter } from './useRouter'
5
- import { useRouterState } from './useRouterState'
6
- import type { Accessor } from 'solid-js'
7
- import type { ParsedLocation } from '@tanstack/router-core'
8
-
9
- export type UseLocationResult = {
10
- activeLocation: Accessor<ParsedLocation>
11
- getFromPath: (from?: string) => Accessor<string>
12
- setActiveLocation: (location?: ParsedLocation) => void
13
- }
14
-
15
- export function useActiveLocation(
16
- location?: ParsedLocation,
17
- ): UseLocationResult {
18
- const router = useRouter()
19
- // we are not using a variable here for router state location since we need to only calculate that if the location is not passed in. It can result in unnecessary history actions if we do that.
20
- const [activeLocation, setActiveLocation] = createSignal<ParsedLocation>(
21
- location ?? useRouterState({ select: (s) => s.location })(),
22
- )
23
- const [customActiveLocation, setCustomActiveLocation] = createSignal<
24
- ParsedLocation | undefined
25
- >(location)
26
-
27
- createEffect(() => {
28
- setActiveLocation(
29
- customActiveLocation() ?? useRouterState({ select: (s) => s.location })(),
30
- )
31
- })
32
-
33
- const matchIndex = useMatch({
34
- strict: false,
35
- select: (match) => match.index,
36
- })
37
-
38
- const getFromPath = (from?: string) =>
39
- createMemo(() => {
40
- const activeLocationMatches = router.matchRoutes(
41
- customActiveLocation() ?? activeLocation(),
42
- {
43
- _buildLocation: false,
44
- },
45
- )
46
-
47
- const activeLocationMatch = last(activeLocationMatches)
48
-
49
- return (
50
- from ??
51
- activeLocationMatch?.fullPath ??
52
- router.state.matches[matchIndex()]!.fullPath
53
- )
54
- })
55
-
56
- return {
57
- activeLocation,
58
- getFromPath,
59
- setActiveLocation: setCustomActiveLocation,
60
- }
61
- }