lime-elements-vue 1.0.7 → 1.0.8
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 +129 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# lime-elements-vue
|
|
2
|
+
|
|
3
|
+
Vue 3 wrapper for [@limetech/lime-elements](https://github.com/Lundalogik/lime-elements) web components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install lime-elements-vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### 1. Configure Vite (Required)
|
|
14
|
+
|
|
15
|
+
Add this to your `vite.config.ts`:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { defineConfig } from 'vite'
|
|
19
|
+
import vue from '@vitejs/plugin-vue'
|
|
20
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
|
21
|
+
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
plugins: [
|
|
24
|
+
vue({
|
|
25
|
+
template: {
|
|
26
|
+
compilerOptions: {
|
|
27
|
+
// Tell Vue that all tags with a hyphen are custom elements
|
|
28
|
+
isCustomElement: (tag) => tag.includes('-')
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
// Copy lime-elements assets to your public folder
|
|
33
|
+
viteStaticCopy({
|
|
34
|
+
targets: [
|
|
35
|
+
{
|
|
36
|
+
src: 'node_modules/@limetech/lime-elements/dist',
|
|
37
|
+
dest: 'lime-elements'
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
],
|
|
42
|
+
optimizeDeps: {
|
|
43
|
+
// Don't pre-bundle lime-elements to allow dynamic imports to work
|
|
44
|
+
exclude: ['@limetech/lime-elements']
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Install the required plugin:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install -D vite-plugin-static-copy
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. Register the plugin globally
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { createApp } from 'vue'
|
|
59
|
+
import { LimeElementsVue } from 'lime-elements-vue'
|
|
60
|
+
import App from './App.vue'
|
|
61
|
+
|
|
62
|
+
const app = createApp(App)
|
|
63
|
+
// Point to the copied assets
|
|
64
|
+
app.use(LimeElementsVue, {
|
|
65
|
+
resourcesUrl: '/lime-elements/dist/'
|
|
66
|
+
})
|
|
67
|
+
app.mount('#app')
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Use components in your templates
|
|
71
|
+
|
|
72
|
+
```vue
|
|
73
|
+
<template>
|
|
74
|
+
<div>
|
|
75
|
+
<limel-button label="Click me" @click="handleClick" />
|
|
76
|
+
<limel-input-field v-model="value" label="Enter text" />
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<script setup lang="ts">
|
|
81
|
+
import { ref } from 'vue'
|
|
82
|
+
|
|
83
|
+
const value = ref('')
|
|
84
|
+
|
|
85
|
+
const handleClick = () => {
|
|
86
|
+
console.log('Button clicked!')
|
|
87
|
+
}
|
|
88
|
+
</script>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Development vs Production
|
|
92
|
+
|
|
93
|
+
The default `resourcesUrl` is set to `/node_modules/@limetech/lime-elements/dist/` which works in **development mode only**.
|
|
94
|
+
|
|
95
|
+
For production builds, you **must** use `vite-plugin-static-copy` as shown above to copy the assets and configure the `resourcesUrl` option.
|
|
96
|
+
|
|
97
|
+
## Advanced Configuration
|
|
98
|
+
|
|
99
|
+
### Custom Resource URL
|
|
100
|
+
|
|
101
|
+
If you're serving from a CDN:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
app.use(LimeElementsVue, {
|
|
105
|
+
resourcesUrl: 'https://your-cdn.com/lime-elements/dist/'
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Available Components
|
|
110
|
+
|
|
111
|
+
This package provides Vue 3 wrappers for all lime-elements components. For detailed documentation on each component, please refer to the [lime-elements documentation](https://lundalogik.github.io/lime-elements/).
|
|
112
|
+
|
|
113
|
+
## Troubleshooting
|
|
114
|
+
|
|
115
|
+
### 404 errors for component files in development
|
|
116
|
+
|
|
117
|
+
If you see 404 errors like `GET http://localhost:xxxx/limel-checkbox.entry.js 404 (Not Found)` in development:
|
|
118
|
+
|
|
119
|
+
1. The default resourcesUrl should work with Vite's dev server
|
|
120
|
+
2. Ensure `optimizeDeps.exclude: ['@limetech/lime-elements']` is set
|
|
121
|
+
3. Make sure `isCustomElement: (tag) => tag.includes('-')` is configured
|
|
122
|
+
|
|
123
|
+
### 404 errors in production build
|
|
124
|
+
|
|
125
|
+
You must copy the assets using `vite-plugin-static-copy` and configure the `resourcesUrl` option when installing the plugin.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
import type { Plugin } from 'vue';
|
|
3
|
+
export interface LimeElementsVueOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Custom URL for lime-elements resources.
|
|
6
|
+
* If not provided, will attempt to load from node_modules
|
|
7
|
+
*/
|
|
8
|
+
resourcesUrl?: string;
|
|
9
|
+
}
|
|
3
10
|
export declare const LimeElementsVue: Plugin;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
import { applyPolyfills, defineCustomElements } from '@limetech/lime-elements/dist/loader';
|
|
3
3
|
export const LimeElementsVue = {
|
|
4
|
-
async install() {
|
|
4
|
+
async install(_app, options) {
|
|
5
5
|
applyPolyfills().then(() => {
|
|
6
|
-
|
|
6
|
+
// Set a default resourcesUrl that points to node_modules
|
|
7
|
+
// This works in dev mode with Vite
|
|
8
|
+
const resourcesUrl = options?.resourcesUrl || '/node_modules/@limetech/lime-elements/dist/';
|
|
9
|
+
defineCustomElements(window, {
|
|
10
|
+
resourcesUrl
|
|
11
|
+
});
|
|
7
12
|
});
|
|
8
13
|
},
|
|
9
14
|
};
|