@mantine-vue/store 1.1.2
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/cjs/index.cjs +24 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/index.mjs +23 -0
- package/esm/index.mjs.map +1 -0
- package/lib/index.d.mts +8 -0
- package/lib/index.d.ts +8 -0
- package/package.json +36 -0
package/cjs/index.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
function createStore(initialState) {
|
|
5
|
+
const state = (0, vue.ref)(initialState);
|
|
6
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
const setState = (value) => {
|
|
8
|
+
state.value = typeof value === "function" ? value(state.value) : value;
|
|
9
|
+
listeners.forEach((listener) => listener(state.value));
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
value: (0, vue.readonly)(state),
|
|
13
|
+
getState: () => state.value,
|
|
14
|
+
setState,
|
|
15
|
+
subscribe: (listener) => {
|
|
16
|
+
listeners.add(listener);
|
|
17
|
+
return () => listeners.delete(listener);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.createStore = createStore;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { readonly, ref, type Ref } from 'vue'\n\nexport interface MantineStore<T> {\n value: Readonly<Ref<T>>\n getState: () => T\n setState: (value: T | ((current: T) => T)) => void\n subscribe: (listener: (value: T) => void) => () => void\n}\n\nexport function createStore<T>(initialState: T): MantineStore<T> {\n const state = ref(initialState) as Ref<T>\n const listeners = new Set<(value: T) => void>()\n\n const setState = (value: T | ((current: T) => T)) => {\n state.value = typeof value === 'function' ? (value as (current: T) => T)(state.value) : value\n listeners.forEach((listener) => listener(state.value))\n }\n\n return {\n value: readonly(state) as Readonly<Ref<T>>,\n getState: () => state.value,\n setState,\n subscribe: (listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n}\n"],"mappings":";;;AASA,SAAgB,YAAe,cAAkC;CAC/D,MAAM,SAAA,GAAA,IAAA,KAAY,YAAY;CAC9B,MAAM,4BAAY,IAAI,IAAwB;CAE9C,MAAM,YAAY,UAAmC;EACnD,MAAM,QAAQ,OAAO,UAAU,aAAc,MAA4B,MAAM,KAAK,IAAI;EACxF,UAAU,SAAS,aAAa,SAAS,MAAM,KAAK,CAAC;CACvD;CAEA,OAAO;EACL,QAAA,GAAA,IAAA,UAAgB,KAAK;EACrB,gBAAgB,MAAM;EACtB;EACA,YAAY,aAAa;GACvB,UAAU,IAAI,QAAQ;GACtB,aAAa,UAAU,OAAO,QAAQ;EACxC;CACF;AACF"}
|
package/esm/index.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readonly, ref } from "vue";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
function createStore(initialState) {
|
|
4
|
+
const state = ref(initialState);
|
|
5
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
6
|
+
const setState = (value) => {
|
|
7
|
+
state.value = typeof value === "function" ? value(state.value) : value;
|
|
8
|
+
listeners.forEach((listener) => listener(state.value));
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
value: readonly(state),
|
|
12
|
+
getState: () => state.value,
|
|
13
|
+
setState,
|
|
14
|
+
subscribe: (listener) => {
|
|
15
|
+
listeners.add(listener);
|
|
16
|
+
return () => listeners.delete(listener);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createStore };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { readonly, ref, type Ref } from 'vue'\n\nexport interface MantineStore<T> {\n value: Readonly<Ref<T>>\n getState: () => T\n setState: (value: T | ((current: T) => T)) => void\n subscribe: (listener: (value: T) => void) => () => void\n}\n\nexport function createStore<T>(initialState: T): MantineStore<T> {\n const state = ref(initialState) as Ref<T>\n const listeners = new Set<(value: T) => void>()\n\n const setState = (value: T | ((current: T) => T)) => {\n state.value = typeof value === 'function' ? (value as (current: T) => T)(state.value) : value\n listeners.forEach((listener) => listener(state.value))\n }\n\n return {\n value: readonly(state) as Readonly<Ref<T>>,\n getState: () => state.value,\n setState,\n subscribe: (listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n}\n"],"mappings":";;AASA,SAAgB,YAAe,cAAkC;CAC/D,MAAM,QAAQ,IAAI,YAAY;CAC9B,MAAM,4BAAY,IAAI,IAAwB;CAE9C,MAAM,YAAY,UAAmC;EACnD,MAAM,QAAQ,OAAO,UAAU,aAAc,MAA4B,MAAM,KAAK,IAAI;EACxF,UAAU,SAAS,aAAa,SAAS,MAAM,KAAK,CAAC;CACvD;CAEA,OAAO;EACL,OAAO,SAAS,KAAK;EACrB,gBAAgB,MAAM;EACtB;EACA,YAAY,aAAa;GACvB,UAAU,IAAI,QAAQ;GACtB,aAAa,UAAU,OAAO,QAAQ;EACxC;CACF;AACF"}
|
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface MantineStore<T> {
|
|
3
|
+
value: Readonly<Ref<T>>;
|
|
4
|
+
getState: () => T;
|
|
5
|
+
setState: (value: T | ((current: T) => T)) => void;
|
|
6
|
+
subscribe: (listener: (value: T) => void) => () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function createStore<T>(initialState: T): MantineStore<T>;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface MantineStore<T> {
|
|
3
|
+
value: Readonly<Ref<T>>;
|
|
4
|
+
getState: () => T;
|
|
5
|
+
setState: (value: T | ((current: T) => T)) => void;
|
|
6
|
+
subscribe: (listener: (value: T) => void) => () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function createStore<T>(initialState: T): MantineStore<T>;
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mantine-vue/store",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "External store primitive for later extension packages",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"cjs",
|
|
8
|
+
"esm",
|
|
9
|
+
"lib",
|
|
10
|
+
"styles.css",
|
|
11
|
+
"styles.layer.css",
|
|
12
|
+
"styles"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"main": "./cjs/index.cjs",
|
|
16
|
+
"module": "./esm/index.mjs",
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./lib/index.d.mts",
|
|
22
|
+
"default": "./esm/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"default": "./cjs/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"vue": "^3.5.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"vue": "^3.5.0"
|
|
35
|
+
}
|
|
36
|
+
}
|