ivue 1.0.2 → 1.0.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.
Files changed (71) hide show
  1. package/.idea/codeStyles/Project.xml +65 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/ivue.iml +8 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/php.xml +19 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/README.md +5 -5
  9. package/coverage/clover.xml +128 -128
  10. package/coverage/coverage-final.json +1 -1
  11. package/coverage/index.html +1 -1
  12. package/coverage/index.ts.html +27 -33
  13. package/dist/src/index.d.ts +5 -2
  14. package/docs/docs/.vitepress/config.ts +29 -6
  15. package/docs/docs/.vitepress/dist/404.html +3 -3
  16. package/docs/docs/.vitepress/dist/api/ivue.html +7 -7
  17. package/docs/docs/.vitepress/dist/api/propsWithDefaults.html +7 -7
  18. package/docs/docs/.vitepress/dist/assets/{api_ivue.md.BCZ4q_0D.js → api_ivue.md.MRwb9Lcb.js} +1 -1
  19. package/docs/docs/.vitepress/dist/assets/{api_ivue.md.BCZ4q_0D.lean.js → api_ivue.md.MRwb9Lcb.lean.js} +1 -1
  20. package/docs/docs/.vitepress/dist/assets/{api_propsWithDefaults.md.Cr5FwI9o.js → api_propsWithDefaults.md.CeE4IC-K.js} +1 -1
  21. package/docs/docs/.vitepress/dist/assets/{api_propsWithDefaults.md.Cr5FwI9o.lean.js → api_propsWithDefaults.md.CeE4IC-K.lean.js} +1 -1
  22. package/docs/docs/.vitepress/dist/assets/{app.DRiljpSE.js → app.CbDr3eFe.js} +1 -1
  23. package/docs/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.xSEJiuF6.js +1 -0
  24. package/docs/docs/.vitepress/dist/assets/chunks/Button.vue_vue_type_script_setup_true_lang.P7niV-n8.js +1 -0
  25. package/docs/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.C1TPvqwb.js +7 -0
  26. package/docs/docs/.vitepress/dist/assets/chunks/framework.CNtPHGsN.js +1 -0
  27. package/docs/docs/.vitepress/dist/assets/chunks/theme.DSY3Mj9W.js +2 -0
  28. package/docs/docs/.vitepress/dist/assets/index.md.CktQD561.js +1 -0
  29. package/docs/docs/.vitepress/dist/assets/index.md.CktQD561.lean.js +1 -0
  30. package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.COGFS1PH.js +8 -0
  31. package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.COGFS1PH.lean.js +1 -0
  32. package/docs/docs/.vitepress/dist/assets/{pages_how-it-works.md.DKizt6Ny.js → pages_how-it-works.md.DEn1nBQc.js} +1 -1
  33. package/docs/docs/.vitepress/dist/assets/{pages_how-it-works.md.DKizt6Ny.lean.js → pages_how-it-works.md.DEn1nBQc.lean.js} +1 -1
  34. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.UHEKhynF.js +1 -0
  35. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.UHEKhynF.lean.js +1 -0
  36. package/docs/docs/.vitepress/dist/assets/pages_usage.md.B75xObUi.js +275 -0
  37. package/docs/docs/.vitepress/dist/assets/pages_usage.md.B75xObUi.lean.js +275 -0
  38. package/docs/docs/.vitepress/dist/assets/{style.BSZVsGuP.css → style.DamVQLpl.css} +1 -1
  39. package/docs/docs/.vitepress/dist/hashmap.json +1 -1
  40. package/docs/docs/.vitepress/dist/index.html +8 -7
  41. package/docs/docs/.vitepress/dist/pages/getting-started.html +10 -10
  42. package/docs/docs/.vitepress/dist/pages/how-it-works.html +7 -7
  43. package/docs/docs/.vitepress/dist/pages/introduction.html +8 -7
  44. package/docs/docs/.vitepress/dist/pages/usage.html +272 -14
  45. package/docs/docs/components/examples/{Counter.vue → CounterBasic.vue} +4 -4
  46. package/docs/docs/components/examples/CounterComposables.vue +20 -0
  47. package/docs/docs/components/examples/CounterComposablesDestructuring.vue +66 -0
  48. package/docs/docs/components/examples/CounterDefineExpose.vue +12 -0
  49. package/docs/docs/components/examples/CounterDefineExposeClass.ts +11 -0
  50. package/docs/docs/components/examples/CounterExternalRefs.vue +25 -0
  51. package/docs/docs/components/examples/CounterInternalRefs.vue +26 -0
  52. package/docs/docs/components/examples/CounterWithProps.vue +29 -0
  53. package/docs/docs/components/examples/CounterWithPropsAndEmits.vue +36 -0
  54. package/docs/docs/index.md +5 -5
  55. package/docs/docs/pages/getting-started.md +9 -5
  56. package/docs/docs/pages/introduction.md +19 -11
  57. package/docs/docs/pages/usage.md +218 -9
  58. package/docs/package.json +3 -2
  59. package/package.json +1 -1
  60. package/src/index.ts +22 -24
  61. package/vitest.config.ts.timestamp-1723424289354-74cf8d2d72cb7.mjs +162 -0
  62. package/docs/docs/.vitepress/dist/assets/chunks/framework.CEhE-9HF.js +0 -1
  63. package/docs/docs/.vitepress/dist/assets/chunks/theme.CldUEgAJ.js +0 -1
  64. package/docs/docs/.vitepress/dist/assets/index.md.B1vDz5mb.js +0 -1
  65. package/docs/docs/.vitepress/dist/assets/index.md.B1vDz5mb.lean.js +0 -1
  66. package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.C7qtPEWU.js +0 -8
  67. package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.C7qtPEWU.lean.js +0 -1
  68. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.Dkqu-XCz.js +0 -1
  69. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.Dkqu-XCz.lean.js +0 -1
  70. package/docs/docs/.vitepress/dist/assets/pages_usage.md.qo7ICfLC.js +0 -17
  71. package/docs/docs/.vitepress/dist/assets/pages_usage.md.qo7ICfLC.lean.js +0 -17
@@ -2,16 +2,16 @@
2
2
  import { ref } from 'vue';
3
3
  import { ivue } from 'ivue';
4
4
 
5
- class ToDo {
5
+ class Counter {
6
6
  count = ref(0) as unknown as number;
7
7
  increment() {
8
8
  this.count++;
9
9
  }
10
10
  }
11
11
 
12
- const todo = ivue(ToDo);
12
+ const counter = ivue(Counter);
13
13
  </script>
14
14
  <template>
15
- <a href="javascript:void" @click="() => todo.increment()">Increment</a>
16
- Count: {{ todo.count }}
15
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
16
+ Count: {{ counter.count }}
17
17
  </template>
@@ -0,0 +1,20 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue';
3
+ import { ivue, UnwrapComposable } from 'ivue';
4
+ import { useMouse } from '@vueuse/core';
5
+
6
+ class Counter {
7
+ count = ref(0) as unknown as number;
8
+ increment() {
9
+ this.count++;
10
+ }
11
+ mouse = useMouse() as unknown as UnwrapComposable<typeof useMouse>
12
+ }
13
+
14
+ const counter = ivue(Counter);
15
+ </script>
16
+ <template>
17
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
18
+ Count: {{ counter.count }} <br />
19
+ Mouse: X: {{ counter.mouse.x }}, Y: {{ counter.mouse.y }}
20
+ </template>
@@ -0,0 +1,66 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref } from 'vue';
3
+ import { ivue, type UnwrapComposable } from 'ivue';
4
+ import { useMouse as _useMouse } from '@vueuse/core';
5
+
6
+ function useMouse() {
7
+ const { x, y } = _useMouse();
8
+ const _sum = ref(0);
9
+
10
+ function sum() {
11
+ _sum.value = x.value + y.value;
12
+ }
13
+
14
+ const total = computed(() => {
15
+ return _sum;
16
+ });
17
+
18
+ return {
19
+ x,
20
+ y,
21
+ sum,
22
+ total,
23
+ };
24
+ }
25
+
26
+ /**
27
+ * Use the Utility Type: UnwrapComposable<typeof YourComposableFunctionName>
28
+ * to get he resulting unwrapped composable properties and functions.
29
+ */
30
+ type UseMouse = UnwrapComposable<typeof useMouse>;
31
+
32
+ class Counter {
33
+ count = ref(0) as unknown as number;
34
+
35
+ increment() {
36
+ this.count++;
37
+ }
38
+
39
+ // x, y are properties that will be destructured into this class
40
+ x!: UseMouse['x']; // Unwrapped Ref<number> becomes -> number
41
+ y!: UseMouse['y']; // Unwrapped Ref<number> becomes -> number
42
+
43
+ sum!: UseMouse['sum']; // 'sum' method that will be destructured into this class on construct()
44
+ total!: UseMouse['total']; // 'total' method that will be destructured into this class on construct()
45
+
46
+ constructor() {
47
+ ({
48
+ x: this.x,
49
+ y: this.y,
50
+ sum: this.sum,
51
+ total: this.total
52
+ } = useMouse() as unknown as UseMouse);
53
+ }
54
+ }
55
+
56
+ const counter = ivue(Counter);
57
+ </script>
58
+ <template>
59
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
60
+ Count: {{ counter.count }} <br />
61
+ Mouse: X: {{ counter.x }}, Y: {{ counter.y }}
62
+ <br />
63
+ Total (computed): {{ counter.total }}
64
+ <br />
65
+ <button class="button" @click="() => counter.sum()">Click This Big Sum Button To Total X + Y</button>
66
+ </template>
@@ -0,0 +1,12 @@
1
+ <script lang="ts" setup>
2
+ import { ivue } from 'ivue';
3
+
4
+ import Counter from './CounterDefineExposeClass'
5
+
6
+ const counter = ivue(Counter);
7
+
8
+ defineExpose<Counter>(counter);
9
+ </script>
10
+ <template>
11
+ Count: {{ counter.count }}
12
+ </template>
@@ -0,0 +1,11 @@
1
+ import { ref } from 'vue';
2
+
3
+ export default class Counter {
4
+ count = ref(0) as unknown as number;
5
+ increment() {
6
+ this.count++;
7
+ }
8
+ decrement() {
9
+ this.count--;
10
+ }
11
+ }
@@ -0,0 +1,25 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue';
3
+ import { ivue } from 'ivue';
4
+
5
+ type SpanRef = HTMLElement | null;
6
+
7
+ class Counter {
8
+ constructor(public span: SpanRef) {}
9
+ count = ref(0) as unknown as number;
10
+ increment() {
11
+ this.count++;
12
+ (this.span as HTMLElement).innerHTML = String(this.count + 1);
13
+ }
14
+ }
15
+
16
+ const span = ref<SpanRef>();
17
+ const counter = ivue(Counter, span as unknown as SpanRef);
18
+
19
+ defineExpose<Counter>(counter);
20
+ </script>
21
+ <template>
22
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
23
+ Count: {{ counter.count }}
24
+ <span ref="span"></span>
25
+ </template>
@@ -0,0 +1,26 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue';
3
+ import { ivue } from 'ivue';
4
+
5
+ class Counter {
6
+ count = ref(0) as unknown as number;
7
+ span = ref(null) as unknown as HTMLElement | null;
8
+ increment() {
9
+ this.count++;
10
+ (this.span as HTMLElement).innerHTML = String(this.count + 1);
11
+ }
12
+ }
13
+
14
+ const counter = ivue(Counter);
15
+ const { span } = counter.toRefs(['span']);
16
+ /**
17
+ * Or you can use `const { span } = counter.toRefs();`
18
+ * but `const { span } = counter.toRefs(['span']);` is more performant
19
+ * because we are only looping through 1 property instead of all of them.
20
+ */
21
+ </script>
22
+ <template>
23
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
24
+ Count: {{ counter.count }}
25
+ <span ref="span"></span>
26
+ </template>
@@ -0,0 +1,29 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue';
3
+ import { ivue } from 'ivue';
4
+
5
+ interface CounterProps {
6
+ initialCount: number;
7
+ }
8
+ const props = defineProps<CounterProps>();
9
+
10
+ class Counter {
11
+ constructor(public props: CounterProps) {
12
+ this.count = this.props.initialCount;
13
+ }
14
+ count = ref(0) as unknown as number;
15
+ increment() {
16
+ this.count++;
17
+ }
18
+ }
19
+
20
+ /**
21
+ * NOTICE that: ivue(ClassName, ...args) uses TypeScript to infer
22
+ * the correct argument types that you need to pass to the constructor.
23
+ */
24
+ const counter = ivue(Counter, props);
25
+ </script>
26
+ <template>
27
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
28
+ Count: {{ counter.count }}
29
+ </template>
@@ -0,0 +1,36 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue';
3
+ import { ivue } from 'ivue';
4
+
5
+ interface CounterProps {
6
+ initialCount: number;
7
+ }
8
+
9
+ interface CounterEmits {
10
+ (e: 'increment', count: number): void;
11
+ }
12
+
13
+ const props = defineProps<CounterProps>();
14
+ const emit = defineEmits<CounterEmits>();
15
+
16
+ class Counter {
17
+ constructor(public props: CounterProps, public emit: CounterEmits) {
18
+ this.count = this.props.initialCount;
19
+ }
20
+ count = ref(0) as unknown as number;
21
+ increment() {
22
+ this.count++;
23
+ this.emit('increment', this.count);
24
+ }
25
+ }
26
+
27
+ /**
28
+ * NOTICE that: ivue(ClassName, ...args) uses TypeScript to infer
29
+ * the correct argument types that you need to pass to the constructor.
30
+ */
31
+ const counter = ivue(Counter, props, emit);
32
+ </script>
33
+ <template>
34
+ <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
35
+ Count: {{ counter.count }}
36
+ </template>
@@ -12,11 +12,11 @@ import Button from './components/Button.vue'
12
12
  ## Features
13
13
  <div style="padding-left:20px;">
14
14
  &ndash; Simple & Elegant Architecture<br />
15
- &ndash; Extendible Classes aligned with TypeScript Class design<br />
16
- &ndash; Extendible Props Defaults<br />
17
- &ndash; Extendible Emits<br />
18
- &ndash; Extendible Slots<br />
19
- &ndash; Extendible Components<br />
15
+ &ndash; Extensible Classes aligned with TypeScript Class design<br />
16
+ &ndash; Extensible Props Defaults<br />
17
+ &ndash; Extensible Emits<br />
18
+ &ndash; Extensible Slots<br />
19
+ &ndash; Extensible Components<br />
20
20
  &ndash; Improves DX by elegantly dealing with .value in the background<br />
21
21
  &ndash; Can be used both as a Store and a View Model for Components<br />
22
22
  &ndash; Provides Full TypeScript Support<br />
@@ -1,14 +1,18 @@
1
- # Installation
1
+ # Getting Started
2
2
 
3
- In your terminal install ivue:
3
+ ## Install
4
+
5
+ The only dependency for `ivue` is Vue 3, so it is easy to get started.
6
+
7
+ In your terminal install `ivue` using:
4
8
  ```bash
5
- # via yarn
9
+ # yarn
6
10
  yarn add ivue
7
11
 
8
- # via npm
12
+ # npm
9
13
  npm i ivue
10
14
 
11
- # via pnpm
15
+ # pnpm
12
16
  pnpm i ivue
13
17
  ```
14
18
 
@@ -1,6 +1,9 @@
1
+ <script setup lang="ts">
2
+ import Button from '../components/Button.vue'
3
+ </script>
1
4
  # What is Infinite Vue (ivue) ?
2
5
 
3
- ## The Purpose of Infinite Vue
6
+ ## The Problem `ivue` Aims to Solve
4
7
 
5
8
  With the development of React hooks and Vue following in its footsteps with introduction of Vue 3 Composition API, the ecosystem has moved away from Options API.
6
9
 
@@ -12,34 +15,39 @@ See: https://vuejs.org/guide/extras/reactivity-transform.html
12
15
 
13
16
 
14
17
  ::: info IVUE UNIFIES COMPOSITION & OPTIONS API VIA CLASS BASED ARCHITECTURE
15
- &mdash;&nbsp; ivue mitigates the downsides of both Composition API and Options API, uses only their strengths and brings back Object Oriented Programming to allow the development of complex and scallable apps.
18
+ &mdash;&nbsp; `ivue` mitigates the downsides of both Composition API and Options API, uses only their strengths and brings back Object Oriented Programming to allow the development of complex and scallable apps.
16
19
 
17
- &mdash;&nbsp; ivue is fully interoperable with Composition API and does not work against it but rather with it, so you can use all of ecosystems composables seamlessly.
20
+ &mdash;&nbsp; `ivue` is fully interoperable with Composition API and does not work against it but rather with it, so you can use all of ecosystems composables seamlessly.
18
21
 
19
- &mdash;&nbsp; ivue also offers a set of functions and utility types to make extensible & exportable props defaults, extensible emits and extensible slots possible.
22
+ &mdash;&nbsp; `ivue` also offers a set of functions and utility types to make extensible & exportable props defaults, extensible emits and extensible slots possible.
20
23
  :::
21
24
 
22
25
  ## Classes are Back with Full Vue 3 Compatibility & Beyond
23
26
 
24
- With failed implementations of classes in React and also failed implementations using class components in Vue 2 / 3, the ecosystem decided that classes are bad and moved to pure procedural designs, while procedural programming has its strength, it also comes with its own weaknesses, like lack of inheritance and true composition.
27
+ With failed implementations of classes in React and also failed implementations using class components in Vue 2 / 3, the ecosystem decided that classes are bad and moved to pure procedural designs.
28
+
29
+ While procedural programming has its strength, it also comes with its own weaknesses, like lack of inheritance and true composition.
25
30
 
26
31
  ::: info IVUE IS DIFFERENT
27
- &mdash; &nbsp;ivue does NOT inherit from a base class<br />
28
- &mdash; &nbsp;ivue does NOT use decorators to achieve its objectives<br />
29
- &mdash; &nbsp;ivue does NOT alter Vue 3 underlying behavior<br />
30
- &mdash; &nbsp;ivue is NOT class components (though you can build components with it)<br />
32
+ &mdash; &nbsp;`ivue` does NOT inherit from a base class<br />
33
+ &mdash; &nbsp;`ivue` does NOT use decorators to achieve its objectives<br />
34
+ &mdash; &nbsp;`ivue` does NOT alter Vue 3 underlying behavior<br />
35
+ &mdash; &nbsp;`ivue` is NOT the same as class components (though you can build components with it)<br />
31
36
  :::
32
37
 
33
38
  ## Infinite Vue Achitecture
34
39
 
35
- ivue mimicks native JavaScript / TypeScript class implementation by extending descriptors up the whole prototype chain thus supporting classical inheritance.
40
+ `ivue` mimicks native JavaScript / TypeScript class implementation by extending descriptors (getters and setters) up the whole prototype chain thus supporting classical inheritance.
36
41
 
37
42
  By using TypeScript we are able to infer the arguments of the main `ivue` initializer function and pass the arguments to the constructor.
38
43
 
39
44
  `ivue` initializer function returns a reactive object with getters converted to computeds and adds `.toRefs()` method to the object, `.toRefs()` allows the object to be converted to native composable structure, so it can interoperate as a composable if needed.
40
45
 
46
+ `ivue` aims to be opaque and minimal, just doing the minimum to convert a class to a reactive object, leaving the rest to be implemented using Vue 3 composition api inside an initializer function called `.init()`
47
+
48
+ You can read more about `ivue` internal architecture in <Button href="/pages/how-it-works" label="How it works?" /> page.
41
49
 
42
50
  ## When to use Infinite Vue?
43
51
 
44
- When complexity of your app or components becomes very high using **ivue** can become a natural choice to deal with that complexity. Because there is no `.value` in ivue, everything is simply a reactive object of unwrapped Refs.
52
+ When complexity of your app or components becomes very high using `ivue` can become a natural choice to deal with that complexity. Because `.value` is abstracted away in `ivue`, everything is simply a reactive object of unwrapped Refs.
45
53
 
@@ -1,16 +1,225 @@
1
+ <style>
2
+ .button {
3
+ padding: 5px 10px;
4
+ border-color: var(--vp-custom-block-details-border);
5
+ color: var(--vp-custom-block-details-text);
6
+ background-color: var(--vp-custom-block-details-bg);
7
+ border-radius: 5px;
8
+ margin-bottom: 2px;
9
+ transition: 0.5s;
10
+ }
11
+ .button:hover {
12
+ opacity: 0.8;
13
+ }
14
+ .button:active {
15
+ opacity:0.9;
16
+ }
17
+ </style>
1
18
  <script lang="ts" setup>
2
- import { createContentLoader } from 'vitepress'
3
- import Counter from '../components/examples/Counter.vue'
19
+ import { ref } from 'vue';
4
20
 
21
+ import CounterBasic from '../components/examples/CounterBasic.vue'
22
+ import CounterWithProps from '../components/examples/CounterWithProps.vue'
23
+ import CounterWithPropsAndEmits from '../components/examples/CounterWithPropsAndEmits.vue'
24
+ import CounterDefineExpose from '../components/examples/CounterDefineExpose.vue'
25
+ import CounterDefineExposeClass from '../components/examples/CounterDefineExposeClass'
26
+ import CounterExternalRefs from '../components/examples/CounterExternalRefs.vue'
27
+ import CounterInternalRefs from '../components/examples/CounterInternalRefs.vue'
28
+ import CounterComposables from '../components/examples/CounterComposables.vue'
29
+ import CounterComposablesDestructuring from '../components/examples/CounterComposablesDestructuring.vue'
30
+
31
+ // <For CounterWithPropsAndEmits example start>
32
+ function onIncrement(value: number) {
33
+ alert('Count is now: ' + value);
34
+ }
35
+ // </For CounterWithPropsAndEmits example end>
36
+
37
+ // <For CounterDefineExpose example start>
38
+ const defineExposeRef = ref<CounterDefineExposeClass | null>(null);
39
+
40
+ function increment() {
41
+ defineExposeRef.value.increment();
42
+ }
43
+
44
+ function decrement() {
45
+ defineExposeRef.value.decrement();
46
+ }
47
+ // </For CounterDefineExpose example end>
48
+
49
+ </script>
50
+
51
+ # Example Usage
52
+
53
+ Using ivue is very simple, but you need to understand a few principles. See the examples below expanding on each principle.
54
+
55
+ ## Basic Usage
56
+
57
+ Classic Counter example built with `ivue`
58
+ ::: code-group
59
+ <<< @/components/examples/CounterBasic.vue{15 vue:line-numbers}
60
+ :::
61
+ :::details For this example we initialize the component like this:
62
+ <template>
63
+ <CounterBasic />
64
+ </template>
65
+ :::
66
+
67
+ ### Result:
68
+
69
+ <CounterBasic />
70
+ ::: warning NOTICE: JavaScript Class Caveat
71
+ See `() => counter.increment()`. You cannot simply use `counter.increment` to refer to the method when it was defined as a object of a class, because that method would not know that it has to be bound to `counter`. You have to either use `() => counter.increment()` or `counter.increment.bind(counter)`, but the latter example is too verbose, so the preferred more readable way is to use an arrow function.
72
+ :::
73
+
74
+ ## Using Props
75
+
76
+ See the highlighted sections related to props.
77
+ ::: code-group
78
+ <<< @/components/examples/CounterWithProps.vue{5-8,15-16,24 vue:line-numbers}
79
+ :::
80
+ :::details For this example we initialize the component like this:
81
+ <template>
82
+ <CounterWithProps :initial-count="5" />
83
+ </template>
84
+ :::
85
+
86
+ ### Result:
87
+
88
+ <CounterWithProps :initial-count="5" />
89
+
90
+ ## Using Emits
91
+
92
+ See the highlighted sections related to `defineExpose`
93
+
94
+ ::: code-group
95
+ <<< @/components/examples/CounterWithPropsAndEmits.vue{9-11,14,20,22,31 vue:line-numbers}
96
+ :::
97
+ :::details For this example we initialize the component like this:
98
+
99
+ ```vue
100
+ <script setup lang="ts">
101
+ function onIncrement(value: number) {
102
+ alert('Count is now: ' + value);
103
+ }
104
+ </script>
105
+ <template>
106
+ <CounterWithPropsAndEmits :initial-count="5" @increment="onIncrement" />
107
+ </template>
108
+ ```
109
+
110
+ :::
111
+
112
+ ### Result:
113
+
114
+ <CounterWithPropsAndEmits :initial-count="5" @increment="onIncrement" />
115
+
116
+ ## Using Refs
117
+
118
+ ### Refs Defined Outside of ivue
119
+
120
+ ::: code-group
121
+ <<< @/components/examples/CounterExternalRefs.vue{vue:line-numbers}
122
+ :::
123
+ :::details For this example we initialize the component like this:
124
+
125
+ ```vue
126
+ <template>
127
+ <CounterExternalRefs />
128
+ </template>
129
+ ```
130
+
131
+ :::
132
+
133
+ ### Result:
134
+
135
+ <CounterExternalRefs />
136
+
137
+ ### Refs Defined Inside of ivue class
138
+
139
+ ::: code-group
140
+ <<< @/components/examples/CounterInternalRefs.vue{vue:line-numbers}
141
+ :::
142
+ :::details For this example we initialize the component like this:
143
+
144
+ ```vue
145
+ <template>
146
+ <CounterInternalRefs />
147
+ </template>
148
+ ```
149
+
150
+ :::
151
+
152
+ ### Result:
153
+
154
+ <CounterInternalRefs />
155
+
156
+ ## Using Define Expose
157
+
158
+ See the highlighted sections related to `defineExpose`.
159
+ ::: code-group
160
+ <<< @/components/examples/CounterDefineExpose.vue{8 vue:line-numbers}
161
+ <<< @/components/examples/CounterDefineExposeClass.ts{ts:line-numbers}
162
+ :::
163
+ :::details For this example we initialize the component like this:
164
+ ```vue
165
+ <script setup lang="ts">
166
+ const defineExposeRef = ref<CounterDefineExposeClass | null>(null);
167
+
168
+ function increment() {
169
+ defineExposeRef.value.increment();
170
+ }
171
+
172
+ function decrement() {
173
+ defineExposeRef.value.decrement();
174
+ }
5
175
  </script>
176
+ <template>
177
+ <button @click="increment">
178
+ Increment via Component Ref from Parent Component</button
179
+ ><br />
180
+ <button @click="decrement">
181
+ Decrement via Component Ref from Parent Component
182
+ </button>
183
+ <CounterDefineExpose />
184
+ </template>
185
+ ```
186
+ :::
187
+
188
+ ### Result:
189
+
190
+ <button class="button" @click="increment">Increment via Component Ref from Parent Component</button><br />
191
+ <button class="button" @click="decrement">Decrement via Component Ref from Parent Component</button>
192
+ <CounterDefineExpose ref="defineExposeRef" />
6
193
 
7
- # Basic Usage
194
+ ## Using Composables
8
195
 
9
- Classic Counter example built with `ivue`:
196
+ See the highlighted sections related to composable usage.
197
+ ::: code-group
198
+ <<< @/components/examples/CounterComposables.vue{4,11,19 vue:line-numbers}
199
+ :::
200
+ :::details For this example we initialize the component like this:
201
+ ```vue
202
+ <template>
203
+ <CounterComposables />
204
+ </template>
205
+ ```
206
+ :::
207
+
208
+ ### Result:
209
+ <CounterComposables />
10
210
 
11
- <<< @/components/examples/Counter.vue{vue}
12
- ```ts
13
- {{counterContent}}
211
+ ### Destructuring composable into the class
212
+ See the highlighted sections related to destructuring composable usage.
213
+ ::: code-group
214
+ <<< @/components/examples/CounterComposablesDestructuring.vue{4,11,19 vue:line-numbers}
215
+ :::
216
+ :::details For this example we initialize the component like this:
217
+ ```vue
218
+ <template>
219
+ <CounterComposablesDestructuring />
220
+ </template>
14
221
  ```
15
- Result:
16
- <Counter />
222
+ :::
223
+
224
+ ### Result:
225
+ <CounterComposablesDestructuring />
package/docs/package.json CHANGED
@@ -18,13 +18,14 @@
18
18
  "eslint-plugin-import": "^2.29.1",
19
19
  "eslint-plugin-vue": "^9.14.1",
20
20
  "execa": "^8.0.0",
21
- "ivue": "^1.0.0",
21
+ "ivue": "^1.0.2",
22
22
  "typescript": "^4.5.4",
23
23
  "vite-plugin-dynamic-import": "^1.5.0",
24
24
  "vite-tsconfig-paths": "^4.3.2",
25
25
  "vitepress": "^1.0.0",
26
26
  "vue": "3.2.44",
27
- "vue-dd": "1.6.7"
27
+ "vue-dd": "1.6.7",
28
+ "vue-use": "^0.2.0"
28
29
  },
29
30
  "pnpm": {
30
31
  "peerDependencyRules": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ivue",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Infinite Vue – Class Based Architecture for Vue 3",
5
5
  "type": "module",
6
6
  "exports": {