ivue 1.5.2 → 1.5.3
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/package.json +4 -1
- package/.editorconfig +0 -9
- package/.eslintignore +0 -7
- package/.eslintrc.js +0 -120
- package/.github/workflows/ci.yml +0 -68
- package/.idea/codeStyles/Project.xml +0 -65
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/ivue.iml +0 -8
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -19
- package/.idea/vcs.xml +0 -6
- package/.prettierrc +0 -5
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -191
- package/coverage/coverage-final.json +0 -3
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/index.ts.html +0 -88
- package/coverage/ivue.ts.html +0 -1753
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/demo/App.vue +0 -11
- package/demo/main.ts +0 -6
- package/demo/vite.config.ts +0 -12
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +0 -89
- package/dist/index.umd.js +0 -1
- package/dist/ivue.d.ts +0 -247
- package/docs/.editorconfig +0 -9
- package/docs/.eslintignore +0 -7
- package/docs/.eslintrc.js +0 -120
- package/docs/.prettierrc +0 -5
- package/docs/docs/.vitepress/config.ts +0 -172
- package/docs/docs/.vitepress/dist/404.html +0 -21
- package/docs/docs/.vitepress/dist/api/ivue.html +0 -24
- package/docs/docs/.vitepress/dist/api/propsWithDefaults.html +0 -24
- package/docs/docs/.vitepress/dist/assets/api_ivue.md.DyFbv52x.js +0 -1
- package/docs/docs/.vitepress/dist/assets/api_ivue.md.DyFbv52x.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/api_propsWithDefaults.md.C6C7ZBZl.js +0 -1
- package/docs/docs/.vitepress/dist/assets/api_propsWithDefaults.md.C6C7ZBZl.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/app.BEuVrZlt.js +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.BuKNEz2z.js +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/Button.vue_vue_type_script_setup_true_lang.Bynntqk6.js +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.CrwYL8pk.js +0 -7
- package/docs/docs/.vitepress/dist/assets/chunks/framework.CvEKxEoK.js +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/index.es.DRFH_cBG.js +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/theme.CvibXqSO.js +0 -2
- package/docs/docs/.vitepress/dist/assets/index.md.mLYKdUe1.js +0 -1
- package/docs/docs/.vitepress/dist/assets/index.md.mLYKdUe1.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/docs/docs/.vitepress/dist/assets/pages_advanced-usage.md.Xwq8hk_w.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_advanced-usage.md.Xwq8hk_w.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_api.md.Bo9Kusmf.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_api.md.Bo9Kusmf.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_browse-code.md.DtJJKz-E.js +0 -556
- package/docs/docs/.vitepress/dist/assets/pages_browse-code.md.DtJJKz-E.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.BEgX6PyX.js +0 -563
- package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.BEgX6PyX.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_guidelines.md.D5gNjB3w.js +0 -112
- package/docs/docs/.vitepress/dist/assets/pages_guidelines.md.D5gNjB3w.lean.js +0 -112
- package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.YjizQt3g.js +0 -559
- package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.YjizQt3g.lean.js +0 -559
- package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.C02KZK0J.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.C02KZK0J.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_introduction.md.B6foeVXQ.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_introduction.md.B6foeVXQ.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_usage.md.BlTPXw5A.js +0 -591
- package/docs/docs/.vitepress/dist/assets/pages_usage.md.BlTPXw5A.lean.js +0 -591
- package/docs/docs/.vitepress/dist/assets/style.Dtxde_a0.css +0 -1
- package/docs/docs/.vitepress/dist/hashmap.json +0 -1
- package/docs/docs/.vitepress/dist/index.html +0 -25
- package/docs/docs/.vitepress/dist/pages/advanced-usage.html +0 -24
- package/docs/docs/.vitepress/dist/pages/api.html +0 -30
- package/docs/docs/.vitepress/dist/pages/browse-code.html +0 -579
- package/docs/docs/.vitepress/dist/pages/getting-started.html +0 -586
- package/docs/docs/.vitepress/dist/pages/guidelines.html +0 -136
- package/docs/docs/.vitepress/dist/pages/how-it-works.html +0 -582
- package/docs/docs/.vitepress/dist/pages/how-its-made.html +0 -24
- package/docs/docs/.vitepress/dist/pages/introduction.html +0 -25
- package/docs/docs/.vitepress/dist/pages/usage.html +0 -615
- package/docs/docs/.vitepress/theme/index.js +0 -5
- package/docs/docs/.vitepress/theme/main.css +0 -29
- package/docs/docs/api/ivue.md +0 -0
- package/docs/docs/api/propsWithDefaults.md +0 -0
- package/docs/docs/components/Button.vue +0 -13
- package/docs/docs/components/Component.vue +0 -20
- package/docs/docs/components/advanced-usage/ConvertLegacy.vue +0 -58
- package/docs/docs/components/guidelines/CounterExternalRefsDetailed.vue +0 -41
- package/docs/docs/components/usage/CounterBasic.vue +0 -18
- package/docs/docs/components/usage/CounterComposables.vue +0 -29
- package/docs/docs/components/usage/CounterComposablesDestructuring.vue +0 -55
- package/docs/docs/components/usage/CounterComposablesIvue.vue +0 -30
- package/docs/docs/components/usage/CounterComposablesIvueDestructuring.vue +0 -48
- package/docs/docs/components/usage/CounterComputeds.vue +0 -26
- package/docs/docs/components/usage/CounterComputedsDisabled.vue +0 -33
- package/docs/docs/components/usage/CounterDefineExpose.vue +0 -12
- package/docs/docs/components/usage/CounterDefineExposeAdvanced.vue +0 -24
- package/docs/docs/components/usage/CounterDefineExposeClass.ts +0 -11
- package/docs/docs/components/usage/CounterExternalRefs.vue +0 -27
- package/docs/docs/components/usage/CounterInsideComposables.vue +0 -28
- package/docs/docs/components/usage/CounterInternalRefs.vue +0 -27
- package/docs/docs/components/usage/CounterLifecycleHooks.vue +0 -24
- package/docs/docs/components/usage/CounterWatch.vue +0 -30
- package/docs/docs/components/usage/CounterWithProps.vue +0 -30
- package/docs/docs/components/usage/CounterWithPropsAndEmits.vue +0 -37
- package/docs/docs/components/usage/classes/CustomMouse.ts +0 -23
- package/docs/docs/components/usage/functions/useCustomMouse.ts +0 -25
- package/docs/docs/index.md +0 -53
- package/docs/docs/pages/advanced-usage.md +0 -12
- package/docs/docs/pages/api.md +0 -129
- package/docs/docs/pages/browse-code.md +0 -18
- package/docs/docs/pages/getting-started.md +0 -32
- package/docs/docs/pages/guidelines.md +0 -139
- package/docs/docs/pages/how-it-works.md +0 -65
- package/docs/docs/pages/how-its-made.md +0 -32
- package/docs/docs/pages/introduction.md +0 -83
- package/docs/docs/pages/usage.md +0 -402
- package/docs/package.json +0 -37
- package/docs/scripts/gh-pages-deploy.js +0 -34
- package/docs/vite-env.d.ts +0 -7
- package/docs/vite.config.ts +0 -20
- package/index.html +0 -14
- package/tsconfig.json +0 -25
- package/vite-env.d.ts +0 -7
- package/vite.config.ts +0 -50
- package/vitest.config.ts +0 -19
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
@import url('https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,100..900;1,100..900&display=swap');
|
|
2
|
-
|
|
3
|
-
.VPNavBarTitle {
|
|
4
|
-
font-family: 'Public Sans';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.VPNavBarTitle a span {
|
|
8
|
-
font-size: 22px !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
body {
|
|
12
|
-
/* font-family: 'Public Sans'; */
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.button {
|
|
16
|
-
padding: 5px 10px;
|
|
17
|
-
border-color: var(--vp-custom-block-details-border);
|
|
18
|
-
color: var(--vp-custom-block-details-text);
|
|
19
|
-
background-color: var(--vp-custom-block-details-bg);
|
|
20
|
-
border-radius: 5px;
|
|
21
|
-
margin-bottom: 2px;
|
|
22
|
-
transition: 0.5s;
|
|
23
|
-
}
|
|
24
|
-
.button:hover {
|
|
25
|
-
opacity: 0.8;
|
|
26
|
-
}
|
|
27
|
-
.button:active {
|
|
28
|
-
opacity:0.9;
|
|
29
|
-
}
|
package/docs/docs/api/ivue.md
DELETED
|
File without changes
|
|
File without changes
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue } from "../../../lib/ivue";
|
|
3
|
-
import { VueDd } from "vue-dd";
|
|
4
|
-
import { ref } from 'vue';
|
|
5
|
-
|
|
6
|
-
class Test2 {
|
|
7
|
-
prop = ref(1);
|
|
8
|
-
prop2 = ref(2);
|
|
9
|
-
}
|
|
10
|
-
const test = ivue(Test2);
|
|
11
|
-
const a = "Coming soon";
|
|
12
|
-
</script>
|
|
13
|
-
<template>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<ClientOnly>
|
|
18
|
-
<vue-dd get-all-properties :save-focus="false" :open-level="1" :inline="false" v-model="test" name="class Test" />
|
|
19
|
-
</ClientOnly>
|
|
20
|
-
</template>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
class Chair {
|
|
3
|
-
// Defaults that will be common for all the instances
|
|
4
|
-
static backSupport: boolean = true;
|
|
5
|
-
static armRests: boolean = true;
|
|
6
|
-
|
|
7
|
-
// Instance properties
|
|
8
|
-
color: string;
|
|
9
|
-
seatHeight: number;
|
|
10
|
-
recliningAngle: number;
|
|
11
|
-
headSupport: boolean;
|
|
12
|
-
padding: string;
|
|
13
|
-
seatSize: string;
|
|
14
|
-
isHeightAdjustable: boolean;
|
|
15
|
-
isMovable: boolean;
|
|
16
|
-
type: string;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
color: string,
|
|
20
|
-
seatHeight: number,
|
|
21
|
-
recliningAngle: number,
|
|
22
|
-
headSupport: boolean,
|
|
23
|
-
padding: string,
|
|
24
|
-
seatSize: string,
|
|
25
|
-
isHeightAdjustable: boolean,
|
|
26
|
-
isMovable: boolean
|
|
27
|
-
) {
|
|
28
|
-
// Defaults which can be changed by the subclass class.
|
|
29
|
-
this.color = color;
|
|
30
|
-
this.seatHeight = seatHeight;
|
|
31
|
-
this.recliningAngle = recliningAngle;
|
|
32
|
-
this.headSupport = headSupport || false;
|
|
33
|
-
this.padding = padding || "3 inch";
|
|
34
|
-
this.seatSize = seatSize || "16 inch";
|
|
35
|
-
this.isHeightAdjustable = isHeightAdjustable || false;
|
|
36
|
-
this.isMovable = isMovable || false;
|
|
37
|
-
this.type = "Chair";
|
|
38
|
-
console.log(Chair.printDefaultProps()); // Usage of static method inside constructor
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static logObjectProps(): void {
|
|
42
|
-
console.dir(this);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Static within static usage
|
|
46
|
-
static printDefaultProps(): void {
|
|
47
|
-
console.log(`Chair Back Support = ${this.backSupport}`);
|
|
48
|
-
console.log(`Arm rests support = ${this.armRests}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
adjustableHeight(): void {};
|
|
52
|
-
adjustAngle(): void {};
|
|
53
|
-
moveChair(): void {};
|
|
54
|
-
}
|
|
55
|
-
</script>
|
|
56
|
-
<template>
|
|
57
|
-
<div>Hello</div>
|
|
58
|
-
</template>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { onMounted, ref } from 'vue';
|
|
3
|
-
import { ivue, iref, iuse } from 'ivue';
|
|
4
|
-
|
|
5
|
-
type SpanRef = HTMLElement | null;
|
|
6
|
-
|
|
7
|
-
class Counter {
|
|
8
|
-
constructor(public span?: SpanRef) {
|
|
9
|
-
// Do not do this in the constructor() because this.span
|
|
10
|
-
// still refers to this.span.value here:
|
|
11
|
-
// onMounted(() => {
|
|
12
|
-
// (this.span as HTMLElement /*❌*/).innerHTML = 'Initial span text!';
|
|
13
|
-
// });
|
|
14
|
-
}
|
|
15
|
-
init() {
|
|
16
|
-
// Do this inside init() because this.span (.value) is now
|
|
17
|
-
// flattened & (this) is now reactive():
|
|
18
|
-
onMounted(() => {
|
|
19
|
-
(this.span as HTMLElement/*✅*/).innerHTML = 'Initial span text!';
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
count = iref(0);
|
|
23
|
-
increment() {
|
|
24
|
-
this.count++;
|
|
25
|
-
(this.span as HTMLElement).innerHTML = String(this.count + 1);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const span = ref<SpanRef>(null);
|
|
30
|
-
const counter = ivue(
|
|
31
|
-
Counter,
|
|
32
|
-
iuse(span)
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
defineExpose<Counter>(counter);
|
|
36
|
-
</script>
|
|
37
|
-
<template>
|
|
38
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
|
|
39
|
-
Count: {{ counter.count }} <br />
|
|
40
|
-
<span ref="span"></span>
|
|
41
|
-
</template>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
class Counter {
|
|
5
|
-
count = iref(0);
|
|
6
|
-
increment() {
|
|
7
|
-
this.count++;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const counter = ivue(Counter);
|
|
12
|
-
</script>
|
|
13
|
-
<template>
|
|
14
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
15
|
-
Increment
|
|
16
|
-
</a>
|
|
17
|
-
Count: {{ counter.count }}
|
|
18
|
-
</template>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useMouse, usePointer } from '@vueuse/core';
|
|
3
|
-
import { ivue, iref, iuse } from 'ivue';
|
|
4
|
-
|
|
5
|
-
class Counter {
|
|
6
|
-
count = iref(0);
|
|
7
|
-
increment() {
|
|
8
|
-
this.count++;
|
|
9
|
-
}
|
|
10
|
-
mouse = iuse(useMouse);
|
|
11
|
-
pointer = iuse(usePointer);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const counter = ivue(Counter);
|
|
15
|
-
</script>
|
|
16
|
-
<template>
|
|
17
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
18
|
-
Increment
|
|
19
|
-
</a>
|
|
20
|
-
Count: {{ counter.count }} <br />
|
|
21
|
-
<br />
|
|
22
|
-
Mouse: <br />
|
|
23
|
-
X: {{ counter.mouse.x }} <br />
|
|
24
|
-
Y: {{ counter.mouse.y }} <br />
|
|
25
|
-
<br />
|
|
26
|
-
Pointer: <br />
|
|
27
|
-
X: {{ counter.pointer.x }} <br />
|
|
28
|
-
Y: {{ counter.pointer.y }} <br />
|
|
29
|
-
</template>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useCustomMouse } from './functions/useCustomMouse';
|
|
3
|
-
|
|
4
|
-
import { ivue, iuse, iref, type Use } from 'ivue';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Use the ivue Utility Type: Use<typeof YourComposableFunctionName>
|
|
8
|
-
* to get he resulting unwrapped composable properties and functions.
|
|
9
|
-
*/
|
|
10
|
-
type UseCustomMouse = Use<typeof useCustomMouse>;
|
|
11
|
-
|
|
12
|
-
class Counter {
|
|
13
|
-
count = iref(0);
|
|
14
|
-
|
|
15
|
-
increment() {
|
|
16
|
-
this.count++;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 'x', 'y', 'sum', 'total' are Refs that will be unwrapped to their bare raw types and destructured into the class.
|
|
21
|
-
* Even though unwrapped (de-Refed), they will maintain their behavior as Refs and thus will maintain reactivity
|
|
22
|
-
* and at the same time get destructured into this class root level scope because
|
|
23
|
-
* Vue 3's `reactive()` Proxy will be able to resolve those Refs internally.
|
|
24
|
-
*/
|
|
25
|
-
x: UseCustomMouse['x']; // Unwrapped Ref<number> becomes -> number
|
|
26
|
-
y: UseCustomMouse['y']; // Unwrapped Ref<number> becomes -> number
|
|
27
|
-
|
|
28
|
-
sum: UseCustomMouse['sum']; // 'sum' method that will be destructured into this class on construct()
|
|
29
|
-
total: UseCustomMouse['total']; // 'total' computed Ref that will also be destructured into this class on construct()
|
|
30
|
-
|
|
31
|
-
constructor() {
|
|
32
|
-
({
|
|
33
|
-
x: this.x,
|
|
34
|
-
y: this.y,
|
|
35
|
-
sum: this.sum,
|
|
36
|
-
total: this.total,
|
|
37
|
-
} = iuse(useCustomMouse, 5));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const counter = ivue(Counter);
|
|
42
|
-
</script>
|
|
43
|
-
<template>
|
|
44
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
45
|
-
Increment
|
|
46
|
-
</a>
|
|
47
|
-
Count: {{ counter.count }} <br />
|
|
48
|
-
Mouse X: {{ counter.x }}, Y: {{ counter.y }}
|
|
49
|
-
<br />
|
|
50
|
-
Total (computed): {{ counter.total }}
|
|
51
|
-
<br />
|
|
52
|
-
<button class="button" @click="() => counter.sum()">
|
|
53
|
-
Click This Big Sum Button To Total X + Y
|
|
54
|
-
</button>
|
|
55
|
-
</template>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { CustomMouse } from './classes/CustomMouse';
|
|
3
|
-
|
|
4
|
-
import { ivue, iref } from 'ivue';
|
|
5
|
-
|
|
6
|
-
class Counter {
|
|
7
|
-
count = iref(0);
|
|
8
|
-
|
|
9
|
-
increment() {
|
|
10
|
-
this.count++;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
mouse = ivue(CustomMouse, 5);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const counter = ivue(Counter);
|
|
17
|
-
</script>
|
|
18
|
-
<template>
|
|
19
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
20
|
-
Increment
|
|
21
|
-
</a>
|
|
22
|
-
Count: {{ counter.count }} <br />
|
|
23
|
-
Mouse X: {{ counter.mouse.x }}, Y: {{ counter.mouse.y }}
|
|
24
|
-
<br />
|
|
25
|
-
Total (computed): {{ counter.mouse.total }}
|
|
26
|
-
<br />
|
|
27
|
-
<button class="button" @click="() => counter.mouse.sum()">
|
|
28
|
-
Click This Big Sum Button To Total X + Y
|
|
29
|
-
</button>
|
|
30
|
-
</template>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { CustomMouse } from './classes/CustomMouse';
|
|
3
|
-
|
|
4
|
-
import { ivue, iref } from 'ivue';
|
|
5
|
-
|
|
6
|
-
class Counter {
|
|
7
|
-
count = iref(0);
|
|
8
|
-
|
|
9
|
-
increment() {
|
|
10
|
-
this.count++;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 'x', 'y', 'total' are Refs that will be unwrapped to their bare raw types and destructured into the class.
|
|
15
|
-
* Even though unwrapped (de-Refed), they will maintain their behavior as Refs and thus will maintain reactivity
|
|
16
|
-
* and at the same time get destructured into this class root level scope because
|
|
17
|
-
* Vue 3's `reactive()` Proxy will be able to resolve those Refs internally.
|
|
18
|
-
*/
|
|
19
|
-
x: CustomMouse['x']; // Unwrapped Ref<number> becomes -> number
|
|
20
|
-
y: CustomMouse['y']; // Unwrapped Ref<number> becomes -> number
|
|
21
|
-
total: CustomMouse['total']; // Unwrapped ComputedRef<number> becomes -> number
|
|
22
|
-
sum: CustomMouse['sum']; // Function remains a function
|
|
23
|
-
|
|
24
|
-
constructor() {
|
|
25
|
-
({
|
|
26
|
-
x: this.x,
|
|
27
|
-
y: this.y,
|
|
28
|
-
sum: this.sum,
|
|
29
|
-
total: this.total,
|
|
30
|
-
} = ivue(CustomMouse, 5).toRefs(true));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const counter = ivue(Counter);
|
|
35
|
-
</script>
|
|
36
|
-
<template>
|
|
37
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
38
|
-
Increment
|
|
39
|
-
</a>
|
|
40
|
-
Count: {{ counter.count }} <br />
|
|
41
|
-
Mouse X: {{ counter.x }}, Y: {{ counter.y }}
|
|
42
|
-
<br />
|
|
43
|
-
Total (computed): {{ counter.total }}
|
|
44
|
-
<br />
|
|
45
|
-
<button class="button" @click="() => counter.sum()">
|
|
46
|
-
Click This Big Sum Button To Total X + Y
|
|
47
|
-
</button>
|
|
48
|
-
</template>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
class Counter {
|
|
5
|
-
count = iref(0);
|
|
6
|
-
increment() {
|
|
7
|
-
this.count++;
|
|
8
|
-
}
|
|
9
|
-
get doubleCount() {
|
|
10
|
-
return this.count * 2;
|
|
11
|
-
}
|
|
12
|
-
get quadCount() {
|
|
13
|
-
return this.doubleCount * 2;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const counter = ivue(Counter);
|
|
18
|
-
</script>
|
|
19
|
-
<template>
|
|
20
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
21
|
-
Increment
|
|
22
|
-
</a>
|
|
23
|
-
Count: {{ counter.count }} <br />
|
|
24
|
-
Double Count: {{ counter.doubleCount }} <br />
|
|
25
|
-
Quad Count: {{ counter.quadCount }} <br />
|
|
26
|
-
</template>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
class Counter {
|
|
5
|
-
/**
|
|
6
|
-
* Use static ivue property to disable computed
|
|
7
|
-
* behavior for certain getters.
|
|
8
|
-
*/
|
|
9
|
-
static ivue = {
|
|
10
|
-
doubleCount: false, // doubleCount is a regular getter now
|
|
11
|
-
};
|
|
12
|
-
count = iref(0);
|
|
13
|
-
increment() {
|
|
14
|
-
this.count++;
|
|
15
|
-
}
|
|
16
|
-
get doubleCount() {
|
|
17
|
-
return this.count * 2;
|
|
18
|
-
}
|
|
19
|
-
get quadCount() {
|
|
20
|
-
return this.doubleCount * 2;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const counter = ivue(Counter);
|
|
25
|
-
</script>
|
|
26
|
-
<template>
|
|
27
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
28
|
-
Increment
|
|
29
|
-
</a>
|
|
30
|
-
Count: {{ counter.count }} <br />
|
|
31
|
-
Double Count: {{ counter.doubleCount }} <br />
|
|
32
|
-
Quad Count: {{ counter.quadCount }} <br />
|
|
33
|
-
</template>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* See that only 'count', 'increment' properties are picked
|
|
6
|
-
* for the define expose interface.
|
|
7
|
-
*/
|
|
8
|
-
export type CounterExposed = Pick<Counter, 'count' | 'increment'>;
|
|
9
|
-
|
|
10
|
-
class Counter {
|
|
11
|
-
count = iref(0);
|
|
12
|
-
increment() {
|
|
13
|
-
this.count++;
|
|
14
|
-
}
|
|
15
|
-
decrement() {
|
|
16
|
-
this.count--;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const counter = ivue(Counter);
|
|
21
|
-
|
|
22
|
-
defineExpose<CounterExposed>(counter);
|
|
23
|
-
</script>
|
|
24
|
-
<template>Count: {{ counter.count }}</template>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref } from 'vue';
|
|
3
|
-
import { ivue, iref, iuse } from 'ivue';
|
|
4
|
-
|
|
5
|
-
type SpanRef = HTMLElement | null;
|
|
6
|
-
|
|
7
|
-
class Counter {
|
|
8
|
-
constructor(public span: SpanRef) {}
|
|
9
|
-
count = iref(0);
|
|
10
|
-
increment() {
|
|
11
|
-
this.count++;
|
|
12
|
-
(this.span as HTMLElement).innerHTML = String(this.count + 1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const span = ref<SpanRef>(null);
|
|
17
|
-
const counter = ivue(Counter, iuse(span));
|
|
18
|
-
|
|
19
|
-
defineExpose<Counter>(counter);
|
|
20
|
-
</script>
|
|
21
|
-
<template>
|
|
22
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
23
|
-
Increment
|
|
24
|
-
</a>
|
|
25
|
-
Count: {{ counter.count }}
|
|
26
|
-
<span ref="span"></span>
|
|
27
|
-
</template>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
class Counter {
|
|
5
|
-
count = iref(0);
|
|
6
|
-
increment() {
|
|
7
|
-
this.count++;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function useCounter() {
|
|
12
|
-
/** Convert ivue Counter to a composable with .toRefs() */
|
|
13
|
-
const { count, increment } = ivue(Counter).toRefs();
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
count,
|
|
17
|
-
increment,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { count, increment } = useCounter();
|
|
22
|
-
</script>
|
|
23
|
-
<template>
|
|
24
|
-
<a href="javascript:void(0)" @click="increment">
|
|
25
|
-
Increment
|
|
26
|
-
</a>
|
|
27
|
-
Count: {{ count }} <br />
|
|
28
|
-
</template>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
class Counter {
|
|
5
|
-
count = iref(0);
|
|
6
|
-
span = iref<HTMLElement | null>(null);
|
|
7
|
-
increment() {
|
|
8
|
-
this.count++;
|
|
9
|
-
(this.span as HTMLElement).innerHTML = String(this.count + 1);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const counter = ivue(Counter);
|
|
14
|
-
const { span } = counter.toRefs(['span']);
|
|
15
|
-
/**
|
|
16
|
-
* Or you can use `const { span } = counter.toRefs();`
|
|
17
|
-
* but `const { span } = counter.toRefs(['span']);` is more performant
|
|
18
|
-
* because we are only looping through 1 property instead of all of them.
|
|
19
|
-
*/
|
|
20
|
-
</script>
|
|
21
|
-
<template>
|
|
22
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
23
|
-
Increment
|
|
24
|
-
</a>
|
|
25
|
-
Count: {{ counter.count }}
|
|
26
|
-
<span ref="span"></span>
|
|
27
|
-
</template>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { onMounted } from 'vue';
|
|
3
|
-
import { ivue, iref } from 'ivue';
|
|
4
|
-
|
|
5
|
-
class Counter {
|
|
6
|
-
init() {
|
|
7
|
-
onMounted(() => {
|
|
8
|
-
this.count = 100;
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
count = iref(0);
|
|
12
|
-
increment() {
|
|
13
|
-
this.count++;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const counter = ivue(Counter);
|
|
18
|
-
</script>
|
|
19
|
-
<template>
|
|
20
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
21
|
-
Increment
|
|
22
|
-
</a>
|
|
23
|
-
Count: {{ counter.count }} (onMounted we set it to 100)
|
|
24
|
-
</template>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { watch } from 'vue';
|
|
3
|
-
import { ivue, iref } from 'ivue';
|
|
4
|
-
|
|
5
|
-
class Counter {
|
|
6
|
-
init() {
|
|
7
|
-
/** Note that we use this.count as a reactive prop in the watch() function */
|
|
8
|
-
watch(
|
|
9
|
-
() => this.count,
|
|
10
|
-
(newCount) => {
|
|
11
|
-
if (newCount === 5) {
|
|
12
|
-
alert('You already clicked 5 times!');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
count = iref(0);
|
|
18
|
-
increment() {
|
|
19
|
-
this.count++;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const counter = ivue(Counter);
|
|
24
|
-
</script>
|
|
25
|
-
<template>
|
|
26
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
27
|
-
Increment
|
|
28
|
-
</a>
|
|
29
|
-
Count: {{ counter.count }} (Click 5 times to get an alert)
|
|
30
|
-
</template>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
interface CounterProps {
|
|
5
|
-
initialCount: number;
|
|
6
|
-
}
|
|
7
|
-
const props = defineProps<CounterProps>();
|
|
8
|
-
|
|
9
|
-
class Counter {
|
|
10
|
-
constructor(public props: CounterProps) {
|
|
11
|
-
this.count = this.props.initialCount;
|
|
12
|
-
}
|
|
13
|
-
count = iref(0);
|
|
14
|
-
increment() {
|
|
15
|
-
this.count++;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* NOTICE that: ivue(ClassName, ...args) uses TypeScript to infer
|
|
21
|
-
* the correct argument types that you need to pass to the constructor.
|
|
22
|
-
*/
|
|
23
|
-
const counter = ivue(Counter, props);
|
|
24
|
-
</script>
|
|
25
|
-
<template>
|
|
26
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
27
|
-
Increment
|
|
28
|
-
</a>
|
|
29
|
-
Count: {{ counter.count }}
|
|
30
|
-
</template>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ivue, iref } from 'ivue';
|
|
3
|
-
|
|
4
|
-
interface CounterProps {
|
|
5
|
-
initialCount: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface CounterEmits {
|
|
9
|
-
(e: 'increment', count: number): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const props = defineProps<CounterProps>();
|
|
13
|
-
const emit = defineEmits<CounterEmits>();
|
|
14
|
-
|
|
15
|
-
class Counter {
|
|
16
|
-
constructor(public props: CounterProps, public emit: CounterEmits) {
|
|
17
|
-
this.count = this.props.initialCount;
|
|
18
|
-
}
|
|
19
|
-
count = iref(0);
|
|
20
|
-
increment() {
|
|
21
|
-
this.count++;
|
|
22
|
-
this.emit('increment', this.count);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* NOTICE that: ivue(ClassName, ...args) uses TypeScript to infer
|
|
28
|
-
* the correct argument types that you need to pass to the constructor.
|
|
29
|
-
*/
|
|
30
|
-
const counter = ivue(Counter, props, emit);
|
|
31
|
-
</script>
|
|
32
|
-
<template>
|
|
33
|
-
<a href="javascript:void(0)" @click="() => counter.increment()">
|
|
34
|
-
Increment
|
|
35
|
-
</a>
|
|
36
|
-
Count: {{ counter.count }}
|
|
37
|
-
</template>
|