@zag-js/vue
Advanced tools
Comparing version 0.70.0 to 0.71.0
@@ -1,34 +0,9 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
'use strict'; | ||
var core = require('@zag-js/core'); | ||
var types = require('@zag-js/types'); | ||
var store = require('@zag-js/store'); | ||
var vue = require('vue'); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
mergeProps: () => import_core.mergeProps, | ||
normalizeProps: () => normalizeProps, | ||
useActor: () => useActor, | ||
useMachine: () => useMachine, | ||
useSnapshot: () => useSnapshot | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_core = require("@zag-js/core"); | ||
// src/normalize-props.ts | ||
var import_types = require("@zag-js/types"); | ||
function toCase(txt) { | ||
@@ -54,3 +29,3 @@ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); | ||
} | ||
var normalizeProps = (0, import_types.createNormalizer)((props) => { | ||
var normalizeProps = types.createNormalizer((props) => { | ||
const normalized = {}; | ||
@@ -71,23 +46,19 @@ for (const key in props) { | ||
}); | ||
// src/use-snapshot.ts | ||
var import_store = require("@zag-js/store"); | ||
var import_vue = require("vue"); | ||
function useSnapshot(service, options) { | ||
const { actions, context } = options ?? {}; | ||
const state = (0, import_vue.shallowRef)(service.state); | ||
const unsubscribe = (0, import_store.subscribe)(service.state, () => { | ||
state.value = (0, import_store.snapshot)(service.state); | ||
const state = vue.shallowRef(service.state); | ||
const unsubscribe = store.subscribe(service.state, () => { | ||
state.value = store.snapshot(service.state); | ||
}); | ||
(0, import_vue.onUnmounted)(() => { | ||
vue.onUnmounted(() => { | ||
unsubscribe?.(); | ||
}); | ||
(0, import_vue.watchEffect)(() => { | ||
vue.watchEffect(() => { | ||
service.setOptions({ actions }); | ||
}); | ||
if (context) { | ||
(0, import_vue.watch)( | ||
vue.watch( | ||
context, | ||
(ctx) => { | ||
service.setContext((0, import_vue.unref)(ctx)); | ||
service.setContext(vue.unref(ctx)); | ||
}, | ||
@@ -105,13 +76,10 @@ { deep: true } | ||
} | ||
// src/use-service.ts | ||
var import_vue2 = require("vue"); | ||
function useService(machine, options) { | ||
const { state: hydratedState, context } = options ?? {}; | ||
const service = typeof machine === "function" ? machine() : machine; | ||
if (context) service.setContext((0, import_vue2.unref)(context)); | ||
if (context) service.setContext(vue.unref(context)); | ||
service._created(); | ||
(0, import_vue2.onMounted)(() => { | ||
vue.onMounted(() => { | ||
service.start(hydratedState); | ||
(0, import_vue2.onBeforeUnmount)(() => { | ||
vue.onBeforeUnmount(() => { | ||
service.stop(); | ||
@@ -129,10 +97,10 @@ }); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
mergeProps, | ||
normalizeProps, | ||
useActor, | ||
useMachine, | ||
useSnapshot | ||
Object.defineProperty(exports, "mergeProps", { | ||
enumerable: true, | ||
get: function () { return core.mergeProps; } | ||
}); | ||
//# sourceMappingURL=index.js.map | ||
exports.normalizeProps = normalizeProps; | ||
exports.useActor = useActor; | ||
exports.useMachine = useMachine; | ||
exports.useSnapshot = useSnapshot; |
{ | ||
"name": "@zag-js/vue", | ||
"version": "0.70.0", | ||
"version": "0.71.0", | ||
"description": "The vue wrapper for zag", | ||
@@ -19,4 +19,3 @@ "keywords": [ | ||
"files": [ | ||
"dist", | ||
"src" | ||
"dist" | ||
], | ||
@@ -30,10 +29,10 @@ "publishConfig": { | ||
"dependencies": { | ||
"@zag-js/core": "0.70.0", | ||
"@zag-js/store": "0.70.0", | ||
"@zag-js/types": "0.70.0" | ||
"@zag-js/core": "0.71.0", | ||
"@zag-js/store": "0.71.0", | ||
"@zag-js/types": "0.71.0" | ||
}, | ||
"devDependencies": { | ||
"vue": "3.5.6", | ||
"vue": "3.5.8", | ||
"clean-package": "2.2.0", | ||
"@zag-js/utils": "0.70.0" | ||
"@zag-js/utils": "0.71.0" | ||
}, | ||
@@ -40,0 +39,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
12064
6
212
6
15
6
285
+ Added@zag-js/core@0.71.0(transitive)
+ Added@zag-js/store@0.71.0(transitive)
+ Added@zag-js/types@0.71.0(transitive)
+ Added@zag-js/utils@0.71.0(transitive)
- Removed@zag-js/core@0.70.0(transitive)
- Removed@zag-js/store@0.70.0(transitive)
- Removed@zag-js/types@0.70.0(transitive)
Updated@zag-js/core@0.71.0
Updated@zag-js/store@0.71.0
Updated@zag-js/types@0.71.0