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
package/docs/docs/pages/usage.md
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
import CounterBasic from '../components/usage/CounterBasic.vue'
|
|
5
|
-
import CounterWithProps from '../components/usage/CounterWithProps.vue'
|
|
6
|
-
import CounterWithPropsAndEmits from '../components/usage/CounterWithPropsAndEmits.vue'
|
|
7
|
-
import CounterDefineExpose from '../components/usage/CounterDefineExpose.vue'
|
|
8
|
-
import CounterDefineExposeClass from '../components/usage/CounterDefineExposeClass'
|
|
9
|
-
import CounterExternalRefs from '../components/usage/CounterExternalRefs.vue'
|
|
10
|
-
import CounterInternalRefs from '../components/usage/CounterInternalRefs.vue'
|
|
11
|
-
import CounterComposables from '../components/usage/CounterComposables.vue'
|
|
12
|
-
import CounterComposablesDestructuring from '../components/usage/CounterComposablesDestructuring.vue'
|
|
13
|
-
import CounterComposablesIvueDestructuring from '../components/usage/CounterComposablesIvueDestructuring.vue'
|
|
14
|
-
import CounterComposablesIvue from '../components/usage/CounterComposablesIvue.vue'
|
|
15
|
-
import CounterInsideComposables from '../components/usage/CounterInsideComposables.vue'
|
|
16
|
-
import CounterComputeds from '../components/usage/CounterComputeds.vue'
|
|
17
|
-
import CounterComputedsDisabled from '../components/usage/CounterComputedsDisabled.vue'
|
|
18
|
-
import CounterWatch from '../components/usage/CounterWatch.vue'
|
|
19
|
-
import CounterLifecycleHooks from '../components/usage/CounterLifecycleHooks.vue'
|
|
20
|
-
|
|
21
|
-
// <For CounterWithPropsAndEmits example start>
|
|
22
|
-
function onIncrement(value: number) {
|
|
23
|
-
alert('Count is now: ' + value);
|
|
24
|
-
}
|
|
25
|
-
// </For CounterWithPropsAndEmits example end>
|
|
26
|
-
|
|
27
|
-
// <For CounterDefineExpose example start>
|
|
28
|
-
const defineExposeRef = ref<CounterDefineExposeClass | null>(null);
|
|
29
|
-
|
|
30
|
-
function increment() {
|
|
31
|
-
defineExposeRef.value.increment();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function decrement() {
|
|
35
|
-
defineExposeRef.value.decrement();
|
|
36
|
-
}
|
|
37
|
-
// </For CounterDefineExpose example end>
|
|
38
|
-
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
# Example Usage
|
|
42
|
-
|
|
43
|
-
Using ivue is very simple, but you need to understand a few principles. See the examples below expanding on each principle.
|
|
44
|
-
|
|
45
|
-
## Basic Usage
|
|
46
|
-
|
|
47
|
-
Classic Counter example built with `ivue`
|
|
48
|
-
::: code-group
|
|
49
|
-
<<< @/components/usage/CounterBasic.vue{vue:line-numbers}
|
|
50
|
-
:::
|
|
51
|
-
|
|
52
|
-
:::details For this example we initialize the component like this:
|
|
53
|
-
|
|
54
|
-
```vue
|
|
55
|
-
<template>
|
|
56
|
-
<CounterBasic />
|
|
57
|
-
</template>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
:::
|
|
61
|
-
|
|
62
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
63
|
-
|
|
64
|
-
<CounterBasic />
|
|
65
|
-
::: warning NOTICE: JavaScript Class Caveat
|
|
66
|
-
See `() => counter.increment()`. You cannot simply use `counter.increment` to refer to the method when it was defined as an 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.
|
|
67
|
-
:::
|
|
68
|
-
|
|
69
|
-
## Using Props
|
|
70
|
-
|
|
71
|
-
See the highlighted sections related to props.
|
|
72
|
-
::: code-group
|
|
73
|
-
<<< @/components/usage/CounterWithProps.vue{vue:line-numbers}
|
|
74
|
-
:::
|
|
75
|
-
|
|
76
|
-
:::details For this example we initialize the component like this:
|
|
77
|
-
|
|
78
|
-
```vue
|
|
79
|
-
<template>
|
|
80
|
-
<CounterWithProps :initial-count="5" />
|
|
81
|
-
</template>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
:::
|
|
85
|
-
|
|
86
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
87
|
-
|
|
88
|
-
<CounterWithProps :initial-count="5" />
|
|
89
|
-
|
|
90
|
-
## Using Emits
|
|
91
|
-
|
|
92
|
-
See the highlighted sections related to using emits.
|
|
93
|
-
|
|
94
|
-
::: code-group
|
|
95
|
-
<<< @/components/usage/CounterWithPropsAndEmits.vue{vue:line-numbers}
|
|
96
|
-
:::
|
|
97
|
-
|
|
98
|
-
:::details For this example we initialize the component like this:
|
|
99
|
-
|
|
100
|
-
```vue
|
|
101
|
-
<script setup lang="ts">
|
|
102
|
-
function onIncrement(value: number) {
|
|
103
|
-
alert('Count is now: ' + value);
|
|
104
|
-
}
|
|
105
|
-
</script>
|
|
106
|
-
<template>
|
|
107
|
-
<CounterWithPropsAndEmits :initial-count="5" @increment="onIncrement" />
|
|
108
|
-
</template>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
:::
|
|
112
|
-
|
|
113
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
114
|
-
|
|
115
|
-
<CounterWithPropsAndEmits :initial-count="5" @increment="onIncrement" />
|
|
116
|
-
|
|
117
|
-
## Using Refs
|
|
118
|
-
|
|
119
|
-
### Refs defined externally in the component outside of the class.
|
|
120
|
-
|
|
121
|
-
::: code-group
|
|
122
|
-
<<< @/components/usage/CounterExternalRefs.vue{vue:line-numbers}
|
|
123
|
-
:::
|
|
124
|
-
:::details For this example we initialize the component like this:
|
|
125
|
-
|
|
126
|
-
```vue
|
|
127
|
-
<template>
|
|
128
|
-
<CounterExternalRefs />
|
|
129
|
-
</template>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
:::
|
|
133
|
-
|
|
134
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
135
|
-
|
|
136
|
-
<CounterExternalRefs />
|
|
137
|
-
|
|
138
|
-
### Refs defined internally inside of the class.
|
|
139
|
-
|
|
140
|
-
::: code-group
|
|
141
|
-
<<< @/components/usage/CounterInternalRefs.vue{vue:line-numbers}
|
|
142
|
-
:::
|
|
143
|
-
|
|
144
|
-
:::details For this example we initialize the component like this:
|
|
145
|
-
|
|
146
|
-
```vue
|
|
147
|
-
<template>
|
|
148
|
-
<CounterInternalRefs />
|
|
149
|
-
</template>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
:::
|
|
153
|
-
|
|
154
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
155
|
-
|
|
156
|
-
<CounterInternalRefs />
|
|
157
|
-
|
|
158
|
-
## Using Define Expose
|
|
159
|
-
|
|
160
|
-
### Use class as interface for `defineExpose()`
|
|
161
|
-
See the highlighted sections related to `defineExpose`.
|
|
162
|
-
|
|
163
|
-
::: code-group
|
|
164
|
-
<<< @/components/usage/CounterDefineExpose.vue{vue:line-numbers}
|
|
165
|
-
<<< @/components/usage/CounterDefineExposeClass.ts{ts:line-numbers}
|
|
166
|
-
:::
|
|
167
|
-
|
|
168
|
-
:::details For this example we initialize the component like this:
|
|
169
|
-
|
|
170
|
-
```vue
|
|
171
|
-
<script setup lang="ts">
|
|
172
|
-
const defineExposeRef = ref<CounterDefineExposeClass | null>(null);
|
|
173
|
-
|
|
174
|
-
function increment() {
|
|
175
|
-
defineExposeRef.value.increment();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function decrement() {
|
|
179
|
-
defineExposeRef.value.decrement();
|
|
180
|
-
}
|
|
181
|
-
</script>
|
|
182
|
-
<template>
|
|
183
|
-
<button @click="increment">
|
|
184
|
-
Increment via Component Ref from Parent Component</button
|
|
185
|
-
><br />
|
|
186
|
-
<button @click="decrement">
|
|
187
|
-
Decrement via Component Ref from Parent Component
|
|
188
|
-
</button>
|
|
189
|
-
<CounterDefineExpose />
|
|
190
|
-
</template>
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
:::
|
|
194
|
-
|
|
195
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
196
|
-
|
|
197
|
-
<button class="button" @click="increment">Increment via Component Ref from Parent Component</button><br />
|
|
198
|
-
<button class="button" @click="decrement">Decrement via Component Ref from Parent Component</button>
|
|
199
|
-
<CounterDefineExpose ref="defineExposeRef" />
|
|
200
|
-
|
|
201
|
-
### Pick allowed interface properties for `defineExpose()`
|
|
202
|
-
|
|
203
|
-
::: code-group
|
|
204
|
-
<<< @/components/usage/CounterDefineExposeAdvanced.vue{vue:line-numbers}
|
|
205
|
-
:::
|
|
206
|
-
|
|
207
|
-
## Using Composables
|
|
208
|
-
|
|
209
|
-
### Assign Vue 3 Composable to a class property
|
|
210
|
-
|
|
211
|
-
See the highlighted sections related to composable usage.
|
|
212
|
-
::: code-group
|
|
213
|
-
<<< @/components/usage/CounterComposables.vue{vue:line-numbers}
|
|
214
|
-
:::
|
|
215
|
-
|
|
216
|
-
:::details For this example we initialize the component like this:
|
|
217
|
-
|
|
218
|
-
```vue
|
|
219
|
-
<template>
|
|
220
|
-
<CounterComposables />
|
|
221
|
-
</template>
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
:::
|
|
225
|
-
|
|
226
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
227
|
-
|
|
228
|
-
<CounterComposables />
|
|
229
|
-
|
|
230
|
-
### Destructure Vue 3 Composable into the class
|
|
231
|
-
|
|
232
|
-
See the highlighted sections related to destructuring composable usage.
|
|
233
|
-
|
|
234
|
-
::: code-group
|
|
235
|
-
<<< @/components/usage/CounterComposablesDestructuring.vue{vue:line-numbers}
|
|
236
|
-
<<< @/components/usage/functions/useCustomMouse.ts{ts:line-numbers} [functions/useCustomMouse.ts]
|
|
237
|
-
:::
|
|
238
|
-
|
|
239
|
-
:::details For this example we initialize the component like this:
|
|
240
|
-
|
|
241
|
-
```vue
|
|
242
|
-
<template>
|
|
243
|
-
<CounterComposablesDestructuring />
|
|
244
|
-
</template>
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
:::
|
|
248
|
-
|
|
249
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
250
|
-
|
|
251
|
-
<CounterComposablesDestructuring />
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
### Assign `ivue` Composables to a class property
|
|
255
|
-
|
|
256
|
-
Using `ivue` based composables assigned to a class property:
|
|
257
|
-
|
|
258
|
-
::: code-group
|
|
259
|
-
<<< @/components/usage/CounterComposablesIvue.vue{vue:line-numbers}
|
|
260
|
-
<<< @/components/usage/classes/CustomMouse.ts{ts:line-numbers} [classes/CustomMouse.ts]
|
|
261
|
-
:::
|
|
262
|
-
|
|
263
|
-
:::details For this example we initialize the component like this:
|
|
264
|
-
|
|
265
|
-
```vue
|
|
266
|
-
<template>
|
|
267
|
-
<CounterComposablesIvue />
|
|
268
|
-
</template>
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
:::
|
|
272
|
-
|
|
273
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
274
|
-
|
|
275
|
-
<CounterComposablesIvue />
|
|
276
|
-
|
|
277
|
-
### Destructure `ivue` Composables Into Class Scope
|
|
278
|
-
|
|
279
|
-
See the sections related to using `ivue` based composables initialized through class destructuring assignment.
|
|
280
|
-
|
|
281
|
-
::: code-group
|
|
282
|
-
<<< @/components/usage/CounterComposablesIvueDestructuring.vue{vue:line-numbers}
|
|
283
|
-
<<< @/components/usage/classes/CustomMouse.ts{ts:line-numbers} [classes/CustomMouse.ts]
|
|
284
|
-
:::
|
|
285
|
-
|
|
286
|
-
:::details For this example we initialize the component like this:
|
|
287
|
-
|
|
288
|
-
```vue
|
|
289
|
-
<template>
|
|
290
|
-
<CounterComposablesIvueDestructuring />
|
|
291
|
-
</template>
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
:::
|
|
295
|
-
|
|
296
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
297
|
-
|
|
298
|
-
<CounterComposablesIvueDestructuring />
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
## Using Inside Composables
|
|
302
|
-
|
|
303
|
-
See the highlighted sections related to using `ivue` inside a composable.
|
|
304
|
-
|
|
305
|
-
::: code-group
|
|
306
|
-
<<< @/components/usage/CounterInsideComposables.vue{vue:line-numbers}
|
|
307
|
-
:::
|
|
308
|
-
|
|
309
|
-
:::details For this example we initialize the component like this:
|
|
310
|
-
|
|
311
|
-
```vue
|
|
312
|
-
<template>
|
|
313
|
-
<CounterInsideComposables />
|
|
314
|
-
</template>
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
:::
|
|
318
|
-
|
|
319
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
320
|
-
|
|
321
|
-
<CounterInsideComposables />
|
|
322
|
-
|
|
323
|
-
## Using Computeds
|
|
324
|
-
|
|
325
|
-
### Getters are computeds in `ivue` unless disabled.<br />
|
|
326
|
-
See the highlighted sections related to getters.
|
|
327
|
-
|
|
328
|
-
::: code-group
|
|
329
|
-
<<< @/components/usage/CounterComputeds.vue{vue:line-numbers}
|
|
330
|
-
:::
|
|
331
|
-
|
|
332
|
-
:::details For this example we initialize the component like this:
|
|
333
|
-
```vue
|
|
334
|
-
<template>
|
|
335
|
-
<CounterComputeds />
|
|
336
|
-
</template>
|
|
337
|
-
```
|
|
338
|
-
:::
|
|
339
|
-
|
|
340
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
341
|
-
<CounterComputeds />
|
|
342
|
-
|
|
343
|
-
### Disable computed behavior for certain getters in `ivue`.<br />
|
|
344
|
-
You can disable computed getters via `static ivue = { getter: false }`, see below:
|
|
345
|
-
|
|
346
|
-
::: code-group
|
|
347
|
-
<<< @/components/usage/CounterComputedsDisabled.vue{vue:line-numbers}
|
|
348
|
-
:::
|
|
349
|
-
|
|
350
|
-
The result of this example is identical to the above.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
## Using Watch
|
|
355
|
-
|
|
356
|
-
To use `watch`, `watchEffect`, and other reactive functions, declare `.init()` method in the class.
|
|
357
|
-
See the highlighted sections related to using `init()` below:
|
|
358
|
-
|
|
359
|
-
::: code-group
|
|
360
|
-
<<< @/components/usage/CounterWatch.vue{vue:line-numbers}
|
|
361
|
-
:::
|
|
362
|
-
|
|
363
|
-
:::details For this example we initialize the component like this:
|
|
364
|
-
|
|
365
|
-
```vue
|
|
366
|
-
<template>
|
|
367
|
-
<CounterWatch />
|
|
368
|
-
</template>
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
:::
|
|
372
|
-
|
|
373
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
374
|
-
|
|
375
|
-
<CounterWatch />
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
## Using Lifecycle Hooks
|
|
380
|
-
|
|
381
|
-
To use `onMounted`, `onBeforeMount` and other lifecycle hooks, declare `.init()` method in the class.
|
|
382
|
-
See the highlighted sections related to using `init()` below:
|
|
383
|
-
|
|
384
|
-
::: tip NOTICE:
|
|
385
|
-
`init()` method can be declared as `async` if needed.
|
|
386
|
-
:::
|
|
387
|
-
|
|
388
|
-
::: code-group
|
|
389
|
-
<<< @/components/usage/CounterLifecycleHooks.vue{vue:line-numbers}
|
|
390
|
-
:::
|
|
391
|
-
|
|
392
|
-
:::details For this example we initialize the component like this:
|
|
393
|
-
|
|
394
|
-
```vue
|
|
395
|
-
<template>
|
|
396
|
-
<CounterLifecycleHooks />
|
|
397
|
-
</template>
|
|
398
|
-
```
|
|
399
|
-
:::
|
|
400
|
-
|
|
401
|
-
<div style="font-size: 18px; font-weight: 500;">Result</div>
|
|
402
|
-
<CounterLifecycleHooks />
|
package/docs/package.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vitepress-project",
|
|
3
|
-
"private": true,
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vitepress dev docs",
|
|
7
|
-
"build": "vitepress build docs",
|
|
8
|
-
"serve": "vitepress serve docs",
|
|
9
|
-
"preview": "vitepress build docs && vitepress serve docs",
|
|
10
|
-
"deploy": "node scripts/gh-pages-deploy.js"
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
14
|
-
"@typescript-eslint/parser": "^5.10.0",
|
|
15
|
-
"cpy-cli": "^4.2.0",
|
|
16
|
-
"eslint": "^8.10.0",
|
|
17
|
-
"eslint-config-prettier": "^8.1.0",
|
|
18
|
-
"eslint-plugin-import": "^2.29.1",
|
|
19
|
-
"eslint-plugin-vue": "^9.14.1",
|
|
20
|
-
"execa": "^8.0.0",
|
|
21
|
-
"ivue": "^1.5.1",
|
|
22
|
-
"typescript": "^4.5.4",
|
|
23
|
-
"vite-plugin-dynamic-import": "^1.5.0",
|
|
24
|
-
"vite-tsconfig-paths": "^4.3.2",
|
|
25
|
-
"vitepress": "^1.0.0",
|
|
26
|
-
"vue": "3.2.44",
|
|
27
|
-
"vue-dd": "1.6.7",
|
|
28
|
-
"vue-use": "^0.2.0"
|
|
29
|
-
},
|
|
30
|
-
"pnpm": {
|
|
31
|
-
"peerDependencyRules": {
|
|
32
|
-
"ignoreMissing": [
|
|
33
|
-
"@algolia/client-search"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa'
|
|
2
|
-
// import fs from "fs"
|
|
3
|
-
|
|
4
|
-
(async () => {
|
|
5
|
-
try {
|
|
6
|
-
var datetime = new Date();
|
|
7
|
-
|
|
8
|
-
// this will save potential changes that might get lost if you didn't commit them
|
|
9
|
-
await execa("git", ["stash", "push", "-m", "before deploy on " + datetime]);
|
|
10
|
-
await execa("git", ["checkout", "--orphan", "gh-pages"]);
|
|
11
|
-
|
|
12
|
-
console.log("Building...")
|
|
13
|
-
|
|
14
|
-
await execa("yarn", ["run", "build"])
|
|
15
|
-
// Understand if it's dist or build folder
|
|
16
|
-
const folderName = "docs/.vitepress/dist"
|
|
17
|
-
await execa("git", ["--work-tree", folderName, "add", "--all"])
|
|
18
|
-
await execa("git", ["--work-tree", folderName, "commit", "-m", "gh-pages"])
|
|
19
|
-
|
|
20
|
-
console.log("Pushing to gh-pages...")
|
|
21
|
-
|
|
22
|
-
await execa("git", ["push", "origin", "HEAD:gh-pages", "--force"])
|
|
23
|
-
await execa("rm", ["-r", folderName])
|
|
24
|
-
await execa("git", ["fetch"])
|
|
25
|
-
await execa("git", ["checkout", "-f", "main"])
|
|
26
|
-
await execa("git", ["branch", "-D", "gh-pages"])
|
|
27
|
-
|
|
28
|
-
console.log("Successfully deployed")
|
|
29
|
-
} catch (e) {
|
|
30
|
-
|
|
31
|
-
console.log(e.message)
|
|
32
|
-
process.exit(1)
|
|
33
|
-
}
|
|
34
|
-
})();
|
package/docs/vite-env.d.ts
DELETED
package/docs/vite.config.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
-
|
|
3
|
-
import { defineConfig } from 'vite'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// https://vitejs.dev/config/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
server: {
|
|
15
|
-
fs: {
|
|
16
|
-
allow: ['..']
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
})
|
package/index.html
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>MyComponent</title>
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body>
|
|
11
|
-
<div id="app"></div>
|
|
12
|
-
<script type="module" src="./demo/main.ts"></script>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"target": "es2016",
|
|
6
|
-
"lib": ["DOM", "ESNext"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"incremental": false,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"moduleResolution": "node",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"noUnusedLocals": true,
|
|
14
|
-
"strictNullChecks": true,
|
|
15
|
-
"allowJs": true,
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"forceConsistentCasingInFileNames": true,
|
|
18
|
-
"types": ["vitest/globals"],
|
|
19
|
-
"paths": {
|
|
20
|
-
"@/*": ["lib/*"]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"include": ["lib"],
|
|
24
|
-
"exclude": ["dist", "node_modules"]
|
|
25
|
-
}
|
package/vite-env.d.ts
DELETED
package/vite.config.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
-
|
|
3
|
-
import { defineConfig } from 'vite'
|
|
4
|
-
import vue from '@vitejs/plugin-vue'
|
|
5
|
-
import dts from "vite-plugin-dts";
|
|
6
|
-
import pkg from "./package.json";
|
|
7
|
-
import libCss from 'vite-plugin-libcss';
|
|
8
|
-
import { terser } from 'rollup-plugin-terser';
|
|
9
|
-
|
|
10
|
-
// https://vitejs.dev/config/
|
|
11
|
-
export default defineConfig({
|
|
12
|
-
resolve: {
|
|
13
|
-
alias: {
|
|
14
|
-
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
server: {
|
|
18
|
-
fs: {
|
|
19
|
-
allow: ['..']
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
plugins: [
|
|
23
|
-
vue(),
|
|
24
|
-
dts({
|
|
25
|
-
cleanVueFileName: true,
|
|
26
|
-
}),
|
|
27
|
-
libCss()
|
|
28
|
-
],
|
|
29
|
-
build: {
|
|
30
|
-
cssCodeSplit: true,
|
|
31
|
-
lib: {
|
|
32
|
-
entry: "./lib/index.ts",
|
|
33
|
-
formats: ["es", "umd"],
|
|
34
|
-
// the name expose in umd mode
|
|
35
|
-
name: pkg.name,
|
|
36
|
-
fileName: (format) => `index.${format}.js`,
|
|
37
|
-
},
|
|
38
|
-
rollupOptions: {
|
|
39
|
-
external: ["vue"],
|
|
40
|
-
plugins:[
|
|
41
|
-
terser()
|
|
42
|
-
],
|
|
43
|
-
output: {
|
|
44
|
-
globals: {
|
|
45
|
-
vue: "Vue"
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
})
|
package/vitest.config.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { mergeConfig } from "vite";
|
|
3
|
-
import { configDefaults, defineConfig } from "vitest/config";
|
|
4
|
-
import viteConfig from "./vite.config";
|
|
5
|
-
|
|
6
|
-
export default mergeConfig(
|
|
7
|
-
viteConfig,
|
|
8
|
-
defineConfig({
|
|
9
|
-
test: {
|
|
10
|
-
environment: "jsdom",
|
|
11
|
-
exclude: [...configDefaults.exclude, "e2e/*", "**/demo/**"],
|
|
12
|
-
root: fileURLToPath(new URL("./", import.meta.url)),
|
|
13
|
-
reporters: ["default", "html", "verbose"],
|
|
14
|
-
coverage: {
|
|
15
|
-
include: ['lib/**']
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
);
|