@resistdesign/voltra 3.0.0-alpha.41 → 3.0.0-alpha.43

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/app/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { createEasyLayout, getEasyLayoutTemplateDetails, getPascalCaseAreaName } from '../chunk-2MOLWZMQ.js';
1
+ export { createEasyLayout, getEasyLayoutTemplateDetails, getPascalCaseAreaName } from '../chunk-CMH6L5QQ.js';
2
2
  export { computeTrackPixels } from '../chunk-TJFTWPXQ.js';
3
- export { AutoForm, AutoFormView, Route, RouteContext, RouteContextConsumer, RouteContextProvider, RouteProvider, buildHistoryPath, buildQueryString, buildRoutePath, canUseBrowserHistory, computeAreaBounds, createAutoField, createBrowserRouteAdapter, createFormRenderer, createHistoryBackHandler, createManualRouteAdapter, createMemoryHistory, createNativeRouteAdapter, createRouteAdapterFromHistory, createUniversalAdapter, defaultTranslateValidationErrorCode, getFieldKind, parseHistoryPath, parseTemplate, resolveSuite, useFormEngine, useRouteContext, validateAreas, wrapRouteAdapterWithPathResolver } from '../chunk-DT6WWJUI.js';
3
+ export { AutoForm, AutoFormView, Route, RouteContext, RouteContextConsumer, RouteContextProvider, RouteProvider, buildHistoryPath, buildQueryString, buildRoutePath, canUseBrowserHistory, computeAreaBounds, createAutoField, createBrowserRouteAdapter, createFormRenderer, createHistoryBackHandler, createManualRouteAdapter, createMemoryHistory, createNativeRouteAdapter, createRouteAdapterFromHistory, createUniversalAdapter, defaultTranslateValidationErrorCode, getFieldKind, parseHistoryPath, parseTemplate, resolveSuite, useFormEngine, useRouteContext, validateAreas, wrapRouteAdapterWithPathResolver } from '../chunk-44BMFTKD.js';
4
4
  import '../chunk-7AMEFPPP.js';
5
5
  import '../chunk-YCTVEW2I.js';
6
6
  import { mergeStringPaths, PATH_DELIMITER } from '../chunk-WNFRDIBW.js';
@@ -50,6 +50,15 @@ export type RouteQueryValue = string | number | boolean | null | undefined | Arr
50
50
  * Query string map for route serialization.
51
51
  */
52
52
  export type RouteQuery = Record<string, RouteQueryValue>;
53
+ /**
54
+ * Route path matcher config.
55
+ */
56
+ export type RoutePathConfig = {
57
+ /** Path pattern, using `:` for params. */
58
+ path: string;
59
+ /** Optional exact-match override for this path entry. */
60
+ exact?: boolean;
61
+ };
53
62
  /**
54
63
  * Create a manual adapter for non-DOM runtimes (e.g., React Native).
55
64
  *
@@ -140,9 +149,9 @@ export declare const RouteProvider: ({ adapter, initialPath, children, }: RouteP
140
149
  */
141
150
  export type RouteProps<ParamsType extends Record<string, any>> = {
142
151
  /**
143
- * Route path pattern, using `:` for params.
152
+ * Route path pattern(s), using `:` for params.
144
153
  */
145
- path?: string;
154
+ path?: string | (string | RoutePathConfig)[];
146
155
  /**
147
156
  * Callback when params update for this route.
148
157
  *
@@ -673,37 +673,58 @@ var RouteMatcher = ({
673
673
  () => currentWindowPath,
674
674
  [currentWindowPath]
675
675
  );
676
- const fullPath = useMemo(
677
- () => mergeStringPaths(parentPath, path),
678
- [parentPath, path]
679
- );
680
- const newParams = useMemo(
681
- () => getParamsAndTestPath(targetCurrentPath, fullPath, exact),
682
- [targetCurrentPath, fullPath, exact]
676
+ const normalizedPaths = useMemo(() => {
677
+ const routePaths = Array.isArray(path) ? path : [path];
678
+ return routePaths.map(
679
+ (routePath) => typeof routePath === "string" ? {
680
+ path: routePath,
681
+ exact
682
+ } : routePath
683
+ );
684
+ }, [path, exact]);
685
+ const matchedRoute = useMemo(
686
+ () => {
687
+ for (const routePathConfig of normalizedPaths) {
688
+ const fullPath = mergeStringPaths(parentPath, routePathConfig.path);
689
+ const newParams = getParamsAndTestPath(
690
+ targetCurrentPath,
691
+ fullPath,
692
+ routePathConfig.exact
693
+ );
694
+ if (newParams) {
695
+ return {
696
+ fullPath,
697
+ newParams
698
+ };
699
+ }
700
+ }
701
+ return null;
702
+ },
703
+ [targetCurrentPath, parentPath, normalizedPaths]
683
704
  );
684
705
  const params = useMemo(
685
706
  () => ({
686
707
  ...parentParams,
687
- ...newParams ? newParams : {}
708
+ ...matchedRoute?.newParams ? matchedRoute.newParams : {}
688
709
  }),
689
- [parentParams, newParams]
710
+ [parentParams, matchedRoute]
690
711
  );
691
712
  const newRouteContext = useMemo(
692
713
  () => ({
693
714
  currentWindowPath: targetCurrentPath,
694
- parentPath: fullPath,
715
+ parentPath: matchedRoute?.fullPath ?? parentPath,
695
716
  params,
696
717
  isTopLevel: false,
697
718
  adapter
698
719
  }),
699
- [targetCurrentPath, fullPath, params, adapter]
720
+ [targetCurrentPath, matchedRoute, parentPath, params, adapter]
700
721
  );
701
722
  useEffect(() => {
702
723
  if (onParamsChange) {
703
724
  onParamsChange(params);
704
725
  }
705
726
  }, [params, onParamsChange]);
706
- return newParams ? /* @__PURE__ */ jsx(RouteContextProvider, { value: newRouteContext, children }) : null;
727
+ return matchedRoute?.newParams ? /* @__PURE__ */ jsx(RouteContextProvider, { value: newRouteContext, children }) : null;
707
728
  };
708
729
  var RouteRootProvider = ({
709
730
  children,
@@ -1,4 +1,4 @@
1
- import { parseTemplate, validateAreas } from './chunk-DT6WWJUI.js';
1
+ import { parseTemplate, validateAreas } from './chunk-44BMFTKD.js';
2
2
 
3
3
  // src/app/utils/EasyLayout.tsx
4
4
  var getPascalCaseAreaName = (area) => {
package/native/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { computeTrackPixels } from '../chunk-TJFTWPXQ.js';
2
- import { createFormRenderer, createHistoryBackHandler, buildHistoryPath, AutoFormView, AutoForm, parseTemplate, validateAreas, computeAreaBounds, parseHistoryPath, createMemoryHistory, Route, buildRoutePath } from '../chunk-DT6WWJUI.js';
2
+ import { createFormRenderer, createHistoryBackHandler, buildHistoryPath, AutoFormView, AutoForm, parseTemplate, validateAreas, computeAreaBounds, parseHistoryPath, createMemoryHistory, Route, buildRoutePath } from '../chunk-44BMFTKD.js';
3
3
  import { ERROR_MESSAGE_CONSTANTS } from '../chunk-YCTVEW2I.js';
4
4
  import { resolveRouteAdapterPath, getPathArray } from '../chunk-WNFRDIBW.js';
5
5
  import '../chunk-I2KLQ2HA.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resistdesign/voltra",
3
- "version": "3.0.0-alpha.41",
3
+ "version": "3.0.0-alpha.43",
4
4
  "description": "With our powers combined!",
5
5
  "homepage": "https://voltra.app",
6
6
  "repository": "git@github.com:resistdesign/voltra.git",
package/web/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createEasyLayout } from '../chunk-2MOLWZMQ.js';
2
- import { createFormRenderer, AutoFormView, AutoForm, createBrowserRouteAdapter, Route } from '../chunk-DT6WWJUI.js';
1
+ import { createEasyLayout } from '../chunk-CMH6L5QQ.js';
2
+ import { createFormRenderer, AutoFormView, AutoForm, createBrowserRouteAdapter, Route } from '../chunk-44BMFTKD.js';
3
3
  import { ERROR_MESSAGE_CONSTANTS } from '../chunk-YCTVEW2I.js';
4
4
  import '../chunk-WNFRDIBW.js';
5
5
  import { __export, __reExport } from '../chunk-I2KLQ2HA.js';