cja-phoenix 0.0.1
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/README.md +178 -0
- package/dist/cja-phoenix.es.js +79 -0
- package/dist/style.css +1 -0
- package/dist/types/components/ComponentA.vue.d.ts +15 -0
- package/dist/types/components/ComponentB.vue.d.ts +2 -0
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/constants/MyConstants.d.ts +1 -0
- package/dist/types/constants/index.d.ts +2 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/utils/MyUtil.d.ts +5 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/package.json +37 -0
- package/src/assets/fonts/myfont.woff +0 -0
- package/src/assets/main.scss +17 -0
- package/src/components/ComponentA.vue +17 -0
- package/src/components/ComponentB.vue +37 -0
- package/src/components/index.ts +7 -0
- package/src/constants/MyConstants.ts +1 -0
- package/src/constants/index.ts +5 -0
- package/src/env.d.ts +8 -0
- package/src/index.ts +17 -0
- package/src/utils/MyUtil.ts +7 -0
- package/src/utils/index.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# CJA Phoenix
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
> When running `docs:dev` for the first time, you may encounter error like `vitepress data not properly injected in app` in your browser. Restart the server and reload the browser. Refer to [issue #30](https://github.com/wuruoyun/vue-component-lib-starter/issues/30) for more details.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# install dependencies
|
|
9
|
+
npm install
|
|
10
|
+
|
|
11
|
+
# start the doc app with hot reload, great for testing components
|
|
12
|
+
npm run docs:dev
|
|
13
|
+
|
|
14
|
+
# build the library, available under dist
|
|
15
|
+
npm run build:lib
|
|
16
|
+
|
|
17
|
+
# build the doc app, available under docs/.vitepress/dist
|
|
18
|
+
npm run docs:build
|
|
19
|
+
|
|
20
|
+
# preview the doc app locally from docs/.vitepress/dist
|
|
21
|
+
npm run docs:serve
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Develop and test locally
|
|
25
|
+
|
|
26
|
+
The best way to develop and test your component is by creating demos in `docs/components/demo` folder.
|
|
27
|
+
|
|
28
|
+
If you want to test the library in your Vue3 app locally:
|
|
29
|
+
|
|
30
|
+
- In the root folder of this library, run `npm link`. This will create a symbolic link to the library.
|
|
31
|
+
- In the root folder of your client app, run `npm link cja-phoenix`. This will add the symbolic link to the `node_modules` folder in your client app.
|
|
32
|
+
- You can now import `cja-phoenix` in your client app.
|
|
33
|
+
|
|
34
|
+
There is no need to add `cja-phoenix` to your client app's dependency in this case.
|
|
35
|
+
|
|
36
|
+
If you made changes to the library, you will need to rebuild the library. Your Vue3 app will hot reload when the building of library is completed.
|
|
37
|
+
|
|
38
|
+
## Publishing
|
|
39
|
+
|
|
40
|
+
After testing your developments and updating the documentation app, bump the version in `package.json` and run `npm run publish:lib`
|
|
41
|
+
|
|
42
|
+
## How it works
|
|
43
|
+
|
|
44
|
+
### Components
|
|
45
|
+
|
|
46
|
+
The library is a [Vue plugin](https://v3.vuejs.org/guide/plugins.html). The `install` function in [index.ts](src/index.ts) registers all components under [components](src/components) to Vue globaly.
|
|
47
|
+
|
|
48
|
+
The doc app itself is a client app of the libary. The configuration in [docs/.vitepress/config.js](docs/.vitepress/config.js) below forces VitePress to resolve vue with no duplication, avoiding errors at runtime.
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
module.exports = {
|
|
52
|
+
vite: {
|
|
53
|
+
resolve: {
|
|
54
|
+
dedupe: ["vue"],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> In [vite.config.ts](vite.config.ts), format 'umd' is not present in `build.lib.formats` option.
|
|
61
|
+
|
|
62
|
+
### Utilities and constants
|
|
63
|
+
|
|
64
|
+
The library includes example utilities and constants. They are also exported in [index.ts](src/index.ts). The client app may use them as below:
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
<script lang="ts">
|
|
68
|
+
import { MyConstants, MyUtil } from 'cja-phoenix'
|
|
69
|
+
|
|
70
|
+
export default {
|
|
71
|
+
data () {
|
|
72
|
+
return {
|
|
73
|
+
magicNum: MyConstants.MAGIC_NUM
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
methods: {
|
|
77
|
+
add (a:number, b:number) {
|
|
78
|
+
return MyUtil.add(a, b)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Styling
|
|
86
|
+
|
|
87
|
+
Individual components have styles defined in its `.vue` file. They will be processed, combined and minified into `dist/style.css`, which is included in the `exports` list in [package.json](package.json).
|
|
88
|
+
|
|
89
|
+
If you have library level styles shared by all components in the library, you may add them to [src/assets/main.scss](src/assets/main.scss). This file is imported in [index.ts](src/index.ts), the processed styles are also included into `dist/style.css`. To avoid conflicting with other global styles, consider pre-fixing the class names or wrapping them into a namespace class.
|
|
90
|
+
|
|
91
|
+
If you have your own special set of SVG icons, you may create a font file (`.woff` format) using tools like [Icomoon](https://icomoon.io/) or [Fontello](https://fontello.com/). This starter includes an example font file [src/assets/fonts/myfont.woff](src/assets/fonts/myfont.woff) and references it in [src/assets/main.scss](src/assets/main.scss), with utility icon CSS classes. Vite will include the font file into the build, see [https://vitejs.dev/guide/assets.html](https://vitejs.dev/guide/assets.html).
|
|
92
|
+
|
|
93
|
+
The client app imports `style.css`, usually in the entry file:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import "cja-phoenix/dist/style.css";
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Third-party dependencies
|
|
100
|
+
|
|
101
|
+
Third-party libraries used by you library may bloat up the size of your library, if you simply add them to the `dependencies` in [package.json](package.json).
|
|
102
|
+
|
|
103
|
+
The following are some strategies to reduce the size of your library:
|
|
104
|
+
|
|
105
|
+
#### Externalization
|
|
106
|
+
|
|
107
|
+
If you expect the client app of your library may also need the same dependency, you can externalize the dependency. For example, to exclude Vue from your library build artifact, in [vite.config.ts](vite.config.ts), you can have
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
module.exports = defineConfig({
|
|
111
|
+
rollupOptions: {
|
|
112
|
+
external: ['vue']
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The dependency to be externalized can be declared as a peer dependency in your library.
|
|
119
|
+
|
|
120
|
+
#### Cherry picking
|
|
121
|
+
|
|
122
|
+
If you don't expect the client app of your library to also need the same dependency, you may embed cherry-picked functions. For example, to embed the `fill` function of popular library [lodash](https://lodash.com), import the `fill` function like the following:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import fill from "lodash/fill";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Even with tree-shaking, the codes being brought into your library may still be large, as the function may have its own dependencies.
|
|
129
|
+
|
|
130
|
+
Note that `import { fill } from 'lodash'` or `import _ from 'lodash'` will not work and will embed the whole `lodash` library.
|
|
131
|
+
|
|
132
|
+
Finally, if your client app also use `lodash` and you don't want `lodash` to be in both the client app and your libraries, even after cherry-picking, you may consider cherry-picking in the component library and re-export them as utils for client to consume, so that the client does not need to depend on `lodash`, therefore avoiding duplication.
|
|
133
|
+
|
|
134
|
+
### Type generation
|
|
135
|
+
|
|
136
|
+
In [tsconfig.json](tsconfig.json), the following options instructs `tsc` to emit declaration (`.d.ts` files) only, as `vite build` handles the `.js` file generation. The generated `.d.ts` files are sent to `dist/types` folder.
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
"compilerOptions": {
|
|
140
|
+
"declaration": true,
|
|
141
|
+
"emitDeclarationOnly": true,
|
|
142
|
+
"declarationDir": "./dist/types"
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
In [package.json](package.json), the line below locates the generated types for library client.
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
"types": "./dist/types/index.d.ts",
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
> In [vite.config.ts](vite.config.ts), `build.emptyOutDir` is set to `false` and `rimraf` is used instead to remove the `dist` folder before the build. This is to avoid the `dist/types` folder generated by `tsc` being deleted when running `vite build`.
|
|
153
|
+
|
|
154
|
+
### Configuration
|
|
155
|
+
|
|
156
|
+
#### TypeScript
|
|
157
|
+
|
|
158
|
+
In [tsconfig.json](tsconfig.js), set the following as recommended by Vite (since esbuild is used). However, enabling this option leads to https://github.com/vitejs/vite/issues/5814. The workaround is to also enable `compilerOptions.skipLibCheck`.
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
"compilerOptions": {
|
|
162
|
+
"isolatedModules": true
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
In [tsconfig.json](tsconfig.js), set the following to address [Issue #32](https://github.com/wuruoyun/vue-component-lib-starter/issues/32). The solution is from https://github.com/johnsoncodehk/volar/discussions/592.
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
"compilerOptions": {
|
|
170
|
+
"types": [
|
|
171
|
+
"vite/client"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Dependencies
|
|
177
|
+
|
|
178
|
+
In [package.json](package.json), Vue is declared in both `peerDependencies` and `devDependencies`. The former requires the client app to add these dependencies, and the later makes it easier to setup this library by simply running `npm install`.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createElementBlock, createTextVNode, toDisplayString, pushScopeId, popScopeId, createElementVNode, ref } from "vue";
|
|
2
|
+
var ComponentA_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
3
|
+
var _export_sfc = (sfc, props) => {
|
|
4
|
+
const target = sfc.__vccOpts || sfc;
|
|
5
|
+
for (const [key, val] of props) {
|
|
6
|
+
target[key] = val;
|
|
7
|
+
}
|
|
8
|
+
return target;
|
|
9
|
+
};
|
|
10
|
+
const _withScopeId$1 = (n) => (pushScopeId("data-v-5800c09e"), n = n(), popScopeId(), n);
|
|
11
|
+
const _hoisted_1$1 = { class: "component-a-container" };
|
|
12
|
+
const _hoisted_2$1 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("span", { class: "icon-heart" }, null, -1));
|
|
13
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
14
|
+
props: {
|
|
15
|
+
msg: null
|
|
16
|
+
},
|
|
17
|
+
setup(__props) {
|
|
18
|
+
return (_ctx, _cache) => {
|
|
19
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
20
|
+
createTextVNode(" Hello " + toDisplayString(__props.msg) + "! ", 1),
|
|
21
|
+
_hoisted_2$1
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var ComponentA = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5800c09e"]]);
|
|
27
|
+
var ComponentB_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
28
|
+
const _withScopeId = (n) => (pushScopeId("data-v-2c22e62b"), n = n(), popScopeId(), n);
|
|
29
|
+
const _hoisted_1 = { class: "flex align-content-center flex-wrap counter" };
|
|
30
|
+
const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("label", { class: "flex align-items-center justify-content-center" }, "Counter:", -1));
|
|
31
|
+
const _hoisted_3 = { class: "flex align-items-center justify-content-center count" };
|
|
32
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
33
|
+
setup(__props) {
|
|
34
|
+
const count = ref(0);
|
|
35
|
+
return (_ctx, _cache) => {
|
|
36
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
37
|
+
_hoisted_2,
|
|
38
|
+
createElementVNode("button", {
|
|
39
|
+
icon: "pi pi-plus",
|
|
40
|
+
class: "p-button-sm flex align-items-center justify-content-center",
|
|
41
|
+
onClick: _cache[0] || (_cache[0] = ($event) => count.value++)
|
|
42
|
+
}),
|
|
43
|
+
createElementVNode("span", _hoisted_3, toDisplayString(count.value), 1),
|
|
44
|
+
createElementVNode("button", {
|
|
45
|
+
icon: "pi pi-minus",
|
|
46
|
+
class: "p-button-sm flex align-items-center justify-content-center",
|
|
47
|
+
onClick: _cache[1] || (_cache[1] = ($event) => count.value--)
|
|
48
|
+
})
|
|
49
|
+
]);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
var ComponentB = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2c22e62b"]]);
|
|
54
|
+
var components = /* @__PURE__ */ Object.freeze({
|
|
55
|
+
__proto__: null,
|
|
56
|
+
[Symbol.toStringTag]: "Module",
|
|
57
|
+
ComponentA,
|
|
58
|
+
ComponentB
|
|
59
|
+
});
|
|
60
|
+
var main = "";
|
|
61
|
+
const MAGIC_NUM = 100;
|
|
62
|
+
var MyConstants = /* @__PURE__ */ Object.freeze({
|
|
63
|
+
__proto__: null,
|
|
64
|
+
[Symbol.toStringTag]: "Module",
|
|
65
|
+
MAGIC_NUM
|
|
66
|
+
});
|
|
67
|
+
function add(a, b) {
|
|
68
|
+
return a + b;
|
|
69
|
+
}
|
|
70
|
+
var MyUtil = {
|
|
71
|
+
add
|
|
72
|
+
};
|
|
73
|
+
function install(app) {
|
|
74
|
+
for (const key in components) {
|
|
75
|
+
app.component(key, components[key]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
var index = { install };
|
|
79
|
+
export { ComponentA, ComponentB, MyConstants, MyUtil, index as default };
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.icon-heart[data-v-5800c09e]{color:tomato}.counter label[data-v-2c22e62b]{padding-right:10px;font-weight:700}.counter .count[data-v-2c22e62b]{padding:0 10px}@font-face{font-family:myfont;src:url(data:font/woff;base64,d09GRgABAAAAAATMAAsAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIGBGNtYXAAAAFoAAAAVAAAAFQWfNQ7Z2FzcAAAAbwAAAAIAAAACAAAABBnbHlmAAABxAAAAMQAAADE9iu5ZGhlYWQAAAKIAAAANgAAADYfdnyraGhlYQAAAsAAAAAkAAAAJAfCA8ZobXR4AAAC5AAAABQAAAAUCgAAAGxvY2EAAAL4AAAADAAAAAwAKAB2bWF4cAAAAwQAAAAgAAAAIAAHACxuYW1lAAADJAAAAYYAAAGGmUoJ+3Bvc3QAAASsAAAAIAAAACAAAwAAAAMDAAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA6doDwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADgAAAAKAAgAAgACAAEAIOna//3//wAAAAAAIOna//3//wAB/+MWKgADAAEAAAAAAAAAAAAAAAEAAf//AA8AAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAA/8wEAAOAACkAAAEiBw4BBwYHJicuAScmIyIHDgEHBhUUFx4BFxYXNjc+ATc2NTQnLgEnJgLzKCUlPxkZEBAZGT8lJSg4MTFJFRUzM5lZWk5KWVmbNTQVFUkxMQOADw8yICEiIiEgMg8PFRVJMTE4cU5Pjk5NcG9PT5BOT204MTFJFRUAAAEAAAAAAABxV9/FXw889QALBAAAAAAA3iwcMQAAAADeLBwxAAD/zAQAA4AAAAAIAAIAAAAAAAAAAQAAA8D/wAAABAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAAUEAAAAAAAAAAAAAAACAAAABAAAAAAAAAAACgAUAB4AYgABAAAABQAqAAEAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEABwAAAAEAAAAAAAIABwBgAAEAAAAAAAMABwA2AAEAAAAAAAQABwB1AAEAAAAAAAUACwAVAAEAAAAAAAYABwBLAAEAAAAAAAoAGgCKAAMAAQQJAAEADgAHAAMAAQQJAAIADgBnAAMAAQQJAAMADgA9AAMAAQQJAAQADgB8AAMAAQQJAAUAFgAgAAMAAQQJAAYADgBSAAMAAQQJAAoANACkaWNvbW9vbgBpAGMAbwBtAG8AbwBuVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwaWNvbW9vbgBpAGMAbwBtAG8AbwBuaWNvbW9vbgBpAGMAbwBtAG8AbwBuUmVndWxhcgBSAGUAZwB1AGwAYQByaWNvbW9vbgBpAGMAbwBtAG8AbwBuRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==)}[class^=icon-],[class*=" icon-"]{font-family:myfont!important}.icon-heart:before{content:"\e9da"}.global-example{color:red}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_DefinePropsToOptions<{
|
|
2
|
+
msg: string;
|
|
3
|
+
}>, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_DefinePropsToOptions<{
|
|
4
|
+
msg: string;
|
|
5
|
+
}>>>, {}>;
|
|
6
|
+
export default _default;
|
|
7
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
8
|
+
declare type __VLS_DefinePropsToOptions<T> = {
|
|
9
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
10
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
11
|
+
} : {
|
|
12
|
+
type: import('vue').PropType<T[K]>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MAGIC_NUM = 100;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { App } from "vue";
|
|
2
|
+
declare function install(app: App): void;
|
|
3
|
+
import "./assets/main.scss";
|
|
4
|
+
declare const _default: {
|
|
5
|
+
install: typeof install;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export * from "./components";
|
|
9
|
+
export * from "./constants";
|
|
10
|
+
export * from "./utils";
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cja-phoenix",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build:lib": "rimraf dist && vue-tsc && vite build",
|
|
6
|
+
"publish:lib": "npm run build:lib && npm publish",
|
|
7
|
+
"docs:dev": "vitepress dev docs",
|
|
8
|
+
"docs:build": "vitepress build docs",
|
|
9
|
+
"docs:serve": "vitepress serve docs"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"vue": "^3.2.25"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^17.0.14",
|
|
16
|
+
"@vitejs/plugin-vue": "^2.0.0",
|
|
17
|
+
"rimraf": "^3.0.2",
|
|
18
|
+
"sass": "^1.49.7",
|
|
19
|
+
"typescript": "^4.4.4",
|
|
20
|
+
"vite": "^2.7.2",
|
|
21
|
+
"vitepress": "^0.21.6",
|
|
22
|
+
"vue": "^3.2.25",
|
|
23
|
+
"vue-tsc": "^0.29.8"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"module": "./dist/cja-phoenix.es.js",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/cja-phoenix.es.js"
|
|
34
|
+
},
|
|
35
|
+
"./dist/style.css": "./dist/style.css"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: 'myfont';
|
|
3
|
+
src: url('fonts/myfont.woff');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[class^='icon-'],
|
|
7
|
+
[class*=' icon-'] {
|
|
8
|
+
font-family: 'myfont' !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.icon-heart:before {
|
|
12
|
+
content: '\e9da';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.global-example {
|
|
16
|
+
color: red;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="component-a-container">
|
|
3
|
+
Hello {{ msg }}! <span class="icon-heart"></span>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
msg: string;
|
|
10
|
+
}>();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<style lang="scss" scoped>
|
|
14
|
+
.icon-heart {
|
|
15
|
+
color: tomato;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
const count = ref(0);
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<div class="flex align-content-center flex-wrap counter">
|
|
8
|
+
<label class="flex align-items-center justify-content-center"
|
|
9
|
+
>Counter:</label
|
|
10
|
+
>
|
|
11
|
+
<button
|
|
12
|
+
icon="pi pi-plus"
|
|
13
|
+
class="p-button-sm flex align-items-center justify-content-center"
|
|
14
|
+
@click="count++"
|
|
15
|
+
></button>
|
|
16
|
+
<span class="flex align-items-center justify-content-center count">{{
|
|
17
|
+
count
|
|
18
|
+
}}</span>
|
|
19
|
+
<button
|
|
20
|
+
icon="pi pi-minus"
|
|
21
|
+
class="p-button-sm flex align-items-center justify-content-center"
|
|
22
|
+
@click="count--"
|
|
23
|
+
></button>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style lang="scss" scoped>
|
|
28
|
+
.counter {
|
|
29
|
+
label {
|
|
30
|
+
padding-right: 10px;
|
|
31
|
+
font-weight: bold;
|
|
32
|
+
}
|
|
33
|
+
.count {
|
|
34
|
+
padding: 0 10px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MAGIC_NUM = 100
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import { DefineComponent } from 'vue'
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
6
|
+
const component: DefineComponent<{}, {}, any>
|
|
7
|
+
export default component
|
|
8
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { App } from "vue";
|
|
2
|
+
import * as components from "./components";
|
|
3
|
+
|
|
4
|
+
function install(app: App) {
|
|
5
|
+
for (const key in components) {
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
app.component(key, components[key]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
import "./assets/main.scss";
|
|
12
|
+
|
|
13
|
+
export default { install };
|
|
14
|
+
|
|
15
|
+
export * from "./components";
|
|
16
|
+
export * from "./constants";
|
|
17
|
+
export * from "./utils";
|