vue-context-storage 0.1.39 → 0.1.40
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/README.md +4 -4
- package/dist/index.d.ts +19 -19
- package/dist/zod.d.ts +5 -5
- package/dist/zod.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -712,17 +712,17 @@ const DataSchema = z.object({
|
|
|
712
712
|
})
|
|
713
713
|
```
|
|
714
714
|
|
|
715
|
-
### `
|
|
715
|
+
### `zBoolean(defaultValue?)`
|
|
716
716
|
|
|
717
717
|
Creates a Zod schema for booleans serialized as URL query parameters. Standard `z.coerce.boolean()` cannot be used because `Boolean('0')` is `true` in JavaScript. This helper correctly handles `'1'`, `'true'`, `'0'`, `'false'`, and native booleans.
|
|
718
718
|
|
|
719
719
|
```typescript
|
|
720
720
|
import { z } from 'zod'
|
|
721
|
-
import {
|
|
721
|
+
import { zBoolean } from 'vue-context-storage/zod'
|
|
722
722
|
|
|
723
723
|
const Schema = z.object({
|
|
724
|
-
active:
|
|
725
|
-
enabled:
|
|
724
|
+
active: zBoolean(), // defaults to false
|
|
725
|
+
enabled: zBoolean(true), // defaults to true
|
|
726
726
|
})
|
|
727
727
|
```
|
|
728
728
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue39 from "vue";
|
|
2
2
|
import { ComputedRef, InjectionKey, MaybeRefOrGetter, Plugin, PropType, UnwrapNestedRefs } from "vue";
|
|
3
3
|
import { LocationQuery, LocationQueryValue } from "vue-router";
|
|
4
4
|
|
|
5
5
|
//#region src/components/ContextStorageActivator.vue.d.ts
|
|
6
6
|
declare const _default$1: typeof __VLS_export$4;
|
|
7
|
-
declare const __VLS_export$4:
|
|
7
|
+
declare const __VLS_export$4: vue39.DefineComponent<{}, () => vue39.VNode<vue39.RendererNode, vue39.RendererElement, {
|
|
8
8
|
[key: string]: any;
|
|
9
|
-
}>, {}, {}, {},
|
|
9
|
+
}>, {}, {}, {}, vue39.ComponentOptionsMixin, vue39.ComponentOptionsMixin, {}, string, vue39.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue39.ComponentProvideOptions, true, {}, any>;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/handlers/types.d.ts
|
|
12
12
|
interface HandlerSchema<T> {
|
|
@@ -65,7 +65,7 @@ interface ContextStorageHandler<T, O> {
|
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/components/ContextStorageCollection.vue.d.ts
|
|
67
67
|
declare const _default$2: typeof __VLS_export$3;
|
|
68
|
-
declare const __VLS_export$3:
|
|
68
|
+
declare const __VLS_export$3: vue39.DefineComponent<vue39.ExtractPropTypes<{
|
|
69
69
|
handlers: {
|
|
70
70
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
71
71
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
@@ -81,9 +81,9 @@ declare const __VLS_export$3: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
|
81
81
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
82
82
|
default: undefined;
|
|
83
83
|
};
|
|
84
|
-
}>, () =>
|
|
84
|
+
}>, () => vue39.VNode<vue39.RendererNode, vue39.RendererElement, {
|
|
85
85
|
[key: string]: any;
|
|
86
|
-
}>[] | undefined, {}, {}, {},
|
|
86
|
+
}>[] | undefined, {}, {}, {}, vue39.ComponentOptionsMixin, vue39.ComponentOptionsMixin, {}, string, vue39.PublicProps, Readonly<vue39.ExtractPropTypes<{
|
|
87
87
|
handlers: {
|
|
88
88
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
89
89
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
@@ -102,27 +102,27 @@ declare const __VLS_export$3: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
|
102
102
|
}>> & Readonly<{}>, {
|
|
103
103
|
handlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
104
104
|
additionalHandlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
105
|
-
}, {}, {}, {}, string,
|
|
105
|
+
}, {}, {}, {}, string, vue39.ComponentProvideOptions, true, {}, any>;
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/components/ContextStorageProvider.vue.d.ts
|
|
108
108
|
declare const _default$4: typeof __VLS_export$2;
|
|
109
|
-
declare const __VLS_export$2:
|
|
109
|
+
declare const __VLS_export$2: vue39.DefineComponent<vue39.ExtractPropTypes<{
|
|
110
110
|
itemKey: {
|
|
111
111
|
type: StringConstructor;
|
|
112
112
|
required: true;
|
|
113
113
|
};
|
|
114
|
-
}>, () =>
|
|
114
|
+
}>, () => vue39.VNode<vue39.RendererNode, vue39.RendererElement, {
|
|
115
115
|
[key: string]: any;
|
|
116
|
-
}>[] | undefined, {}, {}, {},
|
|
116
|
+
}>[] | undefined, {}, {}, {}, vue39.ComponentOptionsMixin, vue39.ComponentOptionsMixin, {}, string, vue39.PublicProps, Readonly<vue39.ExtractPropTypes<{
|
|
117
117
|
itemKey: {
|
|
118
118
|
type: StringConstructor;
|
|
119
119
|
required: true;
|
|
120
120
|
};
|
|
121
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string,
|
|
121
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue39.ComponentProvideOptions, true, {}, any>;
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/components/ContextStorage.vue.d.ts
|
|
124
124
|
declare const _default: typeof __VLS_export$1;
|
|
125
|
-
declare const __VLS_export$1:
|
|
125
|
+
declare const __VLS_export$1: vue39.DefineComponent<vue39.ExtractPropTypes<{
|
|
126
126
|
handlers: {
|
|
127
127
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
128
128
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
@@ -138,9 +138,9 @@ declare const __VLS_export$1: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
|
138
138
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
139
139
|
default: undefined;
|
|
140
140
|
};
|
|
141
|
-
}>, () =>
|
|
141
|
+
}>, () => vue39.VNode<vue39.RendererNode, vue39.RendererElement, {
|
|
142
142
|
[key: string]: any;
|
|
143
|
-
}>[] | undefined, {}, {}, {},
|
|
143
|
+
}>[] | undefined, {}, {}, {}, vue39.ComponentOptionsMixin, vue39.ComponentOptionsMixin, {}, string, vue39.PublicProps, Readonly<vue39.ExtractPropTypes<{
|
|
144
144
|
handlers: {
|
|
145
145
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
146
146
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
@@ -159,7 +159,7 @@ declare const __VLS_export$1: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
|
159
159
|
}>> & Readonly<{}>, {
|
|
160
160
|
handlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
161
161
|
additionalHandlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
162
|
-
}, {}, {}, {}, string,
|
|
162
|
+
}, {}, {}, {}, string, vue39.ComponentProvideOptions, true, {}, any>;
|
|
163
163
|
//#endregion
|
|
164
164
|
//#region src/prefix.d.ts
|
|
165
165
|
/**
|
|
@@ -181,19 +181,19 @@ declare const contextStoragePrefixSegmentsInjectKey: InjectionKey<MaybeRefOrGett
|
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/components/ContextStoragePrefix.vue.d.ts
|
|
183
183
|
declare const _default$3: typeof __VLS_export;
|
|
184
|
-
declare const __VLS_export:
|
|
184
|
+
declare const __VLS_export: vue39.DefineComponent<vue39.ExtractPropTypes<{
|
|
185
185
|
name: {
|
|
186
186
|
type: PropType<ContextStoragePrefixSegment>;
|
|
187
187
|
required: true;
|
|
188
188
|
};
|
|
189
|
-
}>, () =>
|
|
189
|
+
}>, () => vue39.VNode<vue39.RendererNode, vue39.RendererElement, {
|
|
190
190
|
[key: string]: any;
|
|
191
|
-
}>, {}, {}, {},
|
|
191
|
+
}>, {}, {}, {}, vue39.ComponentOptionsMixin, vue39.ComponentOptionsMixin, {}, string, vue39.PublicProps, Readonly<vue39.ExtractPropTypes<{
|
|
192
192
|
name: {
|
|
193
193
|
type: PropType<ContextStoragePrefixSegment>;
|
|
194
194
|
required: true;
|
|
195
195
|
};
|
|
196
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string,
|
|
196
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue39.ComponentProvideOptions, true, {}, any>;
|
|
197
197
|
//#endregion
|
|
198
198
|
//#region src/plugin.d.ts
|
|
199
199
|
declare const VueContextStoragePlugin: Plugin;
|
package/dist/zod.d.ts
CHANGED
|
@@ -53,15 +53,15 @@ declare function zObjectArray<T extends z.ZodTypeAny>(itemSchema: T): z.ZodPipe<
|
|
|
53
53
|
* @example
|
|
54
54
|
* ```ts
|
|
55
55
|
* import { z } from 'zod'
|
|
56
|
-
* import {
|
|
56
|
+
* import { zBoolean } from 'vue-context-storage/zod'
|
|
57
57
|
*
|
|
58
58
|
* const Schema = z.object({
|
|
59
|
-
* active:
|
|
60
|
-
* enabled:
|
|
59
|
+
* active: zBoolean(), // defaults to false
|
|
60
|
+
* enabled: zBoolean(true), // defaults to true
|
|
61
61
|
* })
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
|
-
declare function
|
|
64
|
+
declare function zBoolean(defaultValue?: boolean): z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>, z.ZodTransform<boolean, string | boolean>>>;
|
|
65
65
|
/**
|
|
66
66
|
* Creates a Zod schema for arrays of numbers serialized as URL query parameters.
|
|
67
67
|
*
|
|
@@ -136,4 +136,4 @@ declare function createEmptyObject<T extends ZodRawShape>(schema: ZodObject<T>,
|
|
|
136
136
|
withSchema?: false;
|
|
137
137
|
}): z.infer<ZodObject<T>>;
|
|
138
138
|
//#endregion
|
|
139
|
-
export { MaybeWithSchema, SCHEMA_SYMBOL, createEmptyObject, zNumberArray, zObjectArray, zStringArray
|
|
139
|
+
export { MaybeWithSchema, SCHEMA_SYMBOL, createEmptyObject, zBoolean, zNumberArray, zObjectArray, zStringArray };
|
package/dist/zod.js
CHANGED
|
@@ -6,7 +6,7 @@ const SCHEMA_SYMBOL = /* @__PURE__ */ Symbol("schema");
|
|
|
6
6
|
function zObjectArray(itemSchema) {
|
|
7
7
|
return z.record(z.string(), itemSchema).default({}).transform((record) => Object.entries(record).sort(([a], [b]) => Number(a) - Number(b)).map(([, v]) => v));
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function zBoolean(defaultValue = false) {
|
|
10
10
|
return z.union([z.boolean(), z.string()]).transform((val) => {
|
|
11
11
|
if (typeof val === "boolean") return val;
|
|
12
12
|
return val === "1" || val === "true";
|
|
@@ -77,4 +77,4 @@ function createEmptyObject(schema, options) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
|
-
export { SCHEMA_SYMBOL, createEmptyObject, zNumberArray, zObjectArray, zStringArray
|
|
80
|
+
export { SCHEMA_SYMBOL, createEmptyObject, zBoolean, zNumberArray, zObjectArray, zStringArray };
|