@cocoar/vue-fragment-parser 1.3.0 → 1.4.1

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.
@@ -0,0 +1,4 @@
1
+ export { useFragmentNavigation } from './useFragmentNavigation';
2
+ export { useRoutedFragments } from './useRoutedFragments';
3
+ export { useRoutedModals, type DialogFragment, type ModalFragment, type RoutedOverlayFragment } from './useRoutedModals';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Composable for navigating via URL fragments.
3
+ * Provides helpers to open/close fragment-based modals by manipulating the URL hash.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const { navigateToModal, closeModal } = useFragmentNavigation();
8
+ *
9
+ * navigateToModal('todo-42', { tab: 2 });
10
+ * // URL: /todos#todo-42?tab=2
11
+ *
12
+ * closeModal('todo-42');
13
+ * // URL: /todos
14
+ * ```
15
+ */
16
+ export declare function useFragmentNavigation(): {
17
+ navigateToModal: (path: string, params?: Record<string, string | number | boolean | undefined>, options?: {
18
+ append?: boolean;
19
+ }) => void;
20
+ closeModal: (fragmentPath: string) => void;
21
+ };
22
+ //# sourceMappingURL=useFragmentNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFragmentNavigation.d.ts","sourceRoot":"","sources":["../../src/composables/useFragmentNavigation.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB;4BAY3B,MAAM,WACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,YACpD;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;+BA0BE,MAAM;EAuBzC"}
@@ -0,0 +1,24 @@
1
+ import { ParsedRoute } from '../lib/fragment-parser';
2
+ import { RoutedFragmentBase } from '../lib/routed-fragment';
3
+ /**
4
+ * Composable that reactively parses URL fragments against registered routes.
5
+ * Re-evaluates whenever the URL hash changes.
6
+ *
7
+ * @param routes - Optional explicit routes. If not provided, reads from `route.meta.routedFragments`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const { fragments } = useRoutedFragments();
12
+ * // fragments is a computed<ParsedRoute[]> that updates on hash change
13
+ *
14
+ * watchEffect(() => {
15
+ * for (const f of fragments.value) {
16
+ * console.log(f.route.type, f.params);
17
+ * }
18
+ * });
19
+ * ```
20
+ */
21
+ export declare function useRoutedFragments<T extends RoutedFragmentBase = RoutedFragmentBase>(routes?: T[]): {
22
+ fragments: import('vue').ComputedRef<ParsedRoute<T>[]>;
23
+ };
24
+ //# sourceMappingURL=useRoutedFragments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRoutedFragments.d.ts","sourceRoot":"","sources":["../../src/composables/useRoutedFragments.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EAClF,MAAM,CAAC,EAAE,CAAC,EAAE;;EAeb"}
@@ -0,0 +1,41 @@
1
+ import { Component } from 'vue';
2
+ import { DialogConfig, OverlaySpec } from '@cocoar/vue-ui';
3
+ import { RoutedFragmentBase } from '../lib/routed-fragment';
4
+ /** Fragment that opens a component inside a CoarDialog shell (header, title, close button). */
5
+ export interface DialogFragment extends RoutedFragmentBase {
6
+ type: 'dialog';
7
+ component: () => Promise<{
8
+ default: Component;
9
+ }>;
10
+ /** Dialog shell options (title, size, close behavior) */
11
+ dialogOptions?: DialogConfig;
12
+ }
13
+ /** Fragment that opens a component as a raw overlay (no shell, full control). */
14
+ export interface ModalFragment extends RoutedFragmentBase {
15
+ type: 'modal';
16
+ component: () => Promise<{
17
+ default: Component;
18
+ }>;
19
+ /** Overlay spec overrides (backdrop, positioning, sizing, etc.) */
20
+ overlayOptions?: Partial<OverlaySpec>;
21
+ }
22
+ /** Union type for all supported routed fragment types. */
23
+ export type RoutedOverlayFragment = DialogFragment | ModalFragment;
24
+ /**
25
+ * Composable that automatically opens and closes dialogs/modals based on URL fragments.
26
+ *
27
+ * Supports two fragment types:
28
+ * - `type: 'dialog'` — Opens inside CoarDialog shell (header, title, close button)
29
+ * - `type: 'modal'` — Opens as raw overlay (no shell, component is the entire content)
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * // In your view component:
34
+ * useRoutedModals();
35
+ *
36
+ * // Modals open/close automatically based on URL fragments.
37
+ * // Define fragments in route.meta.routedFragments.
38
+ * ```
39
+ */
40
+ export declare function useRoutedModals(): void;
41
+ //# sourceMappingURL=useRoutedModals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRoutedModals.d.ts","sourceRoot":"","sources":["../../src/composables/useRoutedModals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,+FAA+F;AAC/F,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACjD,yDAAyD;IACzD,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,iFAAiF;AACjF,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACjD,mEAAmE;IACnE,cAAc,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACvC;AAED,0DAA0D;AAC1D,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG,aAAa,CAAC;AAOnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,SAuE9B"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export { parseFragment, type ParsedRoute } from './lib/fragment-parser';
2
2
  export { type RoutedFragmentBase } from './lib/routed-fragment';
3
+ export { useFragmentNavigation, useRoutedFragments, useRoutedModals } from './composables';
4
+ export type { DialogFragment, ModalFragment, RoutedOverlayFragment } from './composables';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}