vue-context-storage 0.1.8 → 0.1.10
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/index.d.ts +411 -10
- package/dist/index.js +193 -22
- package/package.json +38 -37
- package/dist/collection.d.cts +0 -22
- package/dist/collection.d.ts +0 -22
- package/dist/constants.d.cts +0 -2
- package/dist/constants.d.ts +0 -2
- package/dist/handlers/query/helpers.d.cts +0 -45
- package/dist/handlers/query/helpers.d.ts +0 -45
- package/dist/handlers/query/index.d.cts +0 -31
- package/dist/handlers/query/index.d.ts +0 -31
- package/dist/handlers/query/transform-helpers.d.cts +0 -123
- package/dist/handlers/query/transform-helpers.d.ts +0 -123
- package/dist/handlers/query/types.d.cts +0 -103
- package/dist/handlers/query/types.d.ts +0 -103
- package/dist/handlers.d.cts +0 -15
- package/dist/handlers.d.ts +0 -15
- package/dist/index.cjs +0 -409
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -10
- package/dist/index.js.map +0 -1
- package/dist/injectionSymbols.d.cts +0 -7
- package/dist/injectionSymbols.d.ts +0 -7
- package/dist/symbols.d.cts +0 -4
- package/dist/symbols.d.ts +0 -4
- package/src/collection.ts +0 -71
- package/src/components/ContextStorage.vue +0 -23
- package/src/components/ContextStorageActivator.vue +0 -20
- package/src/components/ContextStorageCollection.vue +0 -92
- package/src/components/ContextStorageProvider.vue +0 -38
- package/src/constants.ts +0 -5
- package/src/handlers/query/helpers.ts +0 -134
- package/src/handlers/query/index.ts +0 -355
- package/src/handlers/query/transform-helpers.ts +0 -309
- package/src/handlers/query/types.ts +0 -125
- package/src/handlers.ts +0 -18
- package/src/index.ts +0 -40
- package/src/injectionSymbols.ts +0 -15
- package/src/main.ts +0 -12
- package/src/plugin.ts +0 -16
- package/src/shims-vue.d.ts +0 -5
- package/src/symbols.ts +0 -4
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { LocationQueryValue } from 'vue-router'
|
|
2
|
-
import { MaybeRefOrGetter, UnwrapNestedRefs, WatchHandle } from 'vue'
|
|
3
|
-
import { ContextStorageHandler, RegisterBaseOptions } from '../../handlers'
|
|
4
|
-
|
|
5
|
-
export type QueryValue = LocationQueryValue | LocationQueryValue[]
|
|
6
|
-
|
|
7
|
-
// A recursive type that transforms all properties to CustomType
|
|
8
|
-
export type DeepTransformValuesToLocationQueryValue<T> = {
|
|
9
|
-
[K in keyof T]?: T[K] extends object // Check if the property is an object
|
|
10
|
-
? // Exclude Array from being treated as an object for recursion
|
|
11
|
-
T[K] extends Array<any>
|
|
12
|
-
? QueryValue // Arrays will just become the CustomType (or you could handle them differently)
|
|
13
|
-
: DeepTransformValuesToLocationQueryValue<T[K]> // Recursively apply the type to nested objects
|
|
14
|
-
: QueryValue // Non-object (leaf) properties get the CustomType
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface QueryHandlerSharedOptions {
|
|
18
|
-
/**
|
|
19
|
-
* Default: false
|
|
20
|
-
*
|
|
21
|
-
* If enabled - empty state will be preserved in query.
|
|
22
|
-
*
|
|
23
|
-
* Useful, when you have default values, and want to preserve empty state in query.
|
|
24
|
-
* @example
|
|
25
|
-
* ```
|
|
26
|
-
* Options: {preserveEmptyState: true, prefix: 'filters'}
|
|
27
|
-
*
|
|
28
|
-
* When filters are empty we will get this in query string:
|
|
29
|
-
*
|
|
30
|
-
* /list?filters
|
|
31
|
-
*
|
|
32
|
-
* After page reload state will be not restored to default
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```
|
|
37
|
-
* Options: {preserveEmptyState: false, prefix: 'filters'}
|
|
38
|
-
*
|
|
39
|
-
* When filters are empty we will get this in query string:
|
|
40
|
-
*
|
|
41
|
-
* /list
|
|
42
|
-
*
|
|
43
|
-
* After page reload state will be restored to default
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```
|
|
48
|
-
* Options: {preserveEmptyState: true}
|
|
49
|
-
*
|
|
50
|
-
* When filters are empty we will get this in query string:
|
|
51
|
-
*
|
|
52
|
-
* /list?_
|
|
53
|
-
*
|
|
54
|
-
* After page reload state will be not restored to default.
|
|
55
|
-
* Underscore (_) is default value for emptyPlaceholder option
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
preserveEmptyState?: boolean
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Default: true
|
|
62
|
-
*
|
|
63
|
-
* If transform option is not passed, ref will be merged with query only by keys that exists in ref.
|
|
64
|
-
*/
|
|
65
|
-
mergeOnlyExistingKeysWithoutTransform?: boolean
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface QueryHandlerBaseOptions extends QueryHandlerSharedOptions {
|
|
69
|
-
/**
|
|
70
|
-
* Default: replace
|
|
71
|
-
*
|
|
72
|
-
* Vue-router navigate mode.
|
|
73
|
-
* Use push if you want to add new query to history.
|
|
74
|
-
* Use replace if you want to replace current query without adding to history.
|
|
75
|
-
*/
|
|
76
|
-
mode?: 'replace' | 'push'
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Default: _
|
|
80
|
-
*
|
|
81
|
-
* Placeholder for empty state, used when preserveEmptyState is true and all ref values are empty.
|
|
82
|
-
*/
|
|
83
|
-
emptyPlaceholder?: string
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Default: false
|
|
87
|
-
*
|
|
88
|
-
* If enabled - unused keys will be preserved in query.
|
|
89
|
-
* Unused keys are keys, that are not exists in ref.
|
|
90
|
-
*/
|
|
91
|
-
preserveUnusedKeys?: boolean
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface RegisterQueryHandlerBaseOptions<T> extends QueryHandlerSharedOptions {
|
|
95
|
-
/**
|
|
96
|
-
* Prefix in query string.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```
|
|
100
|
-
* filters, table-1[filters], table-2[filters]
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
prefix?: string
|
|
104
|
-
transform?: (
|
|
105
|
-
deserialized: DeepTransformValuesToLocationQueryValue<UnwrapNestedRefs<T>>,
|
|
106
|
-
initialData: T,
|
|
107
|
-
) => UnwrapNestedRefs<T>
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface RegisterQueryHandlerOptions<T>
|
|
111
|
-
extends RegisterBaseOptions, RegisterQueryHandlerBaseOptions<T> {}
|
|
112
|
-
|
|
113
|
-
export interface IContextStorageQueryHandler extends ContextStorageHandler {
|
|
114
|
-
register: <T extends Record<string, unknown>>(
|
|
115
|
-
data: MaybeRefOrGetter<T>,
|
|
116
|
-
options: RegisterQueryHandlerOptions<T>,
|
|
117
|
-
) => () => void
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface ContextStorageQueryRegisteredItem<T extends Record<string, unknown>> {
|
|
121
|
-
data: MaybeRefOrGetter<T>
|
|
122
|
-
initialData: T
|
|
123
|
-
options: RegisterQueryHandlerOptions<T>
|
|
124
|
-
watchHandle: WatchHandle
|
|
125
|
-
}
|
package/src/handlers.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { InjectionKey, MaybeRefOrGetter } from 'vue'
|
|
2
|
-
|
|
3
|
-
export interface ContextStorageHandlerConstructor {
|
|
4
|
-
new (): ContextStorageHandler
|
|
5
|
-
getInitialStateResolver?: () => () => Record<string, unknown>
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface RegisterBaseOptions {
|
|
9
|
-
causer: string
|
|
10
|
-
uid: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ContextStorageHandler {
|
|
14
|
-
register: (data: MaybeRefOrGetter, options: RegisterBaseOptions) => () => void
|
|
15
|
-
setInitialState?: (state: Record<string, unknown>) => void
|
|
16
|
-
setEnabled?: (enabled: boolean, initial: boolean) => void
|
|
17
|
-
getInjectionKey(): InjectionKey<ContextStorageHandler>
|
|
18
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Core exports
|
|
2
|
-
export type {
|
|
3
|
-
ContextStorageHandler,
|
|
4
|
-
ContextStorageHandlerConstructor,
|
|
5
|
-
RegisterBaseOptions,
|
|
6
|
-
} from './handlers'
|
|
7
|
-
|
|
8
|
-
export { ContextStorageQueryHandler, useContextStorageQueryHandler } from './handlers/query'
|
|
9
|
-
|
|
10
|
-
// Query helpers
|
|
11
|
-
export { deserializeParams, serializeParams } from './handlers/query/helpers'
|
|
12
|
-
export type { SerializeOptions } from './handlers/query/helpers'
|
|
13
|
-
|
|
14
|
-
// Query transform helpers
|
|
15
|
-
export {
|
|
16
|
-
asArray,
|
|
17
|
-
asBoolean,
|
|
18
|
-
asNumber,
|
|
19
|
-
asNumberArray,
|
|
20
|
-
asString,
|
|
21
|
-
transform,
|
|
22
|
-
} from './handlers/query/transform-helpers'
|
|
23
|
-
|
|
24
|
-
// Injection symbols
|
|
25
|
-
export {
|
|
26
|
-
contextStorageCollectionInjectKey,
|
|
27
|
-
contextStorageCollectionItemInjectKey,
|
|
28
|
-
contextStorageHandlersInjectKey,
|
|
29
|
-
contextStorageQueryHandlerInjectKey,
|
|
30
|
-
} from './injectionSymbols'
|
|
31
|
-
|
|
32
|
-
// Symbols
|
|
33
|
-
export { collection, collectionItem, contextStorageQueryHandler, handlers } from './symbols'
|
|
34
|
-
|
|
35
|
-
// Re-export defaultHandlers from constants to ensure single instance
|
|
36
|
-
export { defaultHandlers } from './constants'
|
|
37
|
-
export type { QueryValue, IContextStorageQueryHandler } from './handlers/query/types'
|
|
38
|
-
|
|
39
|
-
// Export only type for ContextStorageCollectionItem to avoid naming conflict with component
|
|
40
|
-
export type { ContextStorageCollectionItem } from './collection'
|
package/src/injectionSymbols.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ContextStorageCollection, ContextStorageCollectionItem } from './collection'
|
|
2
|
-
import { ContextStorageQueryHandler } from './handlers/query'
|
|
3
|
-
import { collection, collectionItem, contextStorageQueryHandler, handlers } from './symbols'
|
|
4
|
-
import { InjectionKey } from 'vue'
|
|
5
|
-
|
|
6
|
-
export const contextStorageCollectionInjectKey: InjectionKey<ContextStorageCollection> = collection
|
|
7
|
-
export const contextStorageCollectionItemInjectKey: InjectionKey<ContextStorageCollectionItem> =
|
|
8
|
-
collectionItem
|
|
9
|
-
export const contextStorageHandlersInjectKey: InjectionKey<
|
|
10
|
-
ContextStorageCollectionItem['handlers']
|
|
11
|
-
> = handlers
|
|
12
|
-
|
|
13
|
-
export const contextStorageQueryHandlerInjectKey: InjectionKey<
|
|
14
|
-
InstanceType<typeof ContextStorageQueryHandler>
|
|
15
|
-
> = contextStorageQueryHandler
|
package/src/main.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Main entry point that includes everything (for ESM usage)
|
|
2
|
-
// This ensures all imports come from the same module instance
|
|
3
|
-
export * from './index'
|
|
4
|
-
|
|
5
|
-
// Components
|
|
6
|
-
export { default as ContextStorageActivator } from './components/ContextStorageActivator.vue'
|
|
7
|
-
export { default as ContextStorageCollection } from './components/ContextStorageCollection.vue'
|
|
8
|
-
export { default as ContextStorageProvider } from './components/ContextStorageProvider.vue'
|
|
9
|
-
export { default as ContextStorage } from './components/ContextStorage.vue'
|
|
10
|
-
|
|
11
|
-
// Plugin
|
|
12
|
-
export { VueContextStoragePlugin, VueContextStoragePlugin as default } from './plugin'
|
package/src/plugin.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { App, Plugin } from 'vue'
|
|
2
|
-
import ContextStorageActivator from './components/ContextStorageActivator.vue'
|
|
3
|
-
import ContextStorageCollection from './components/ContextStorageCollection.vue'
|
|
4
|
-
import ContextStorageProvider from './components/ContextStorageProvider.vue'
|
|
5
|
-
import ContextStorage from './components/ContextStorage.vue'
|
|
6
|
-
|
|
7
|
-
export const VueContextStoragePlugin: Plugin = {
|
|
8
|
-
install(app: App) {
|
|
9
|
-
app.component('ContextStorageActivator', ContextStorageActivator)
|
|
10
|
-
app.component('ContextStorageCollection', ContextStorageCollection)
|
|
11
|
-
app.component('ContextStorageProvider', ContextStorageProvider)
|
|
12
|
-
app.component('ContextStorage', ContextStorage)
|
|
13
|
-
},
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default VueContextStoragePlugin
|
package/src/shims-vue.d.ts
DELETED
package/src/symbols.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export const collection: unique symbol = Symbol('context-storage-collection')
|
|
2
|
-
export const collectionItem: unique symbol = Symbol('context-storage-collection-item')
|
|
3
|
-
export const handlers: unique symbol = Symbol('context-storage-handlers')
|
|
4
|
-
export const contextStorageQueryHandler: unique symbol = Symbol('context-storage-query-handler')
|