@squirkle-ui/nuxt 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KheangLov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,19 @@
1
- # Temporary Holding Version
1
+ # @squirkle-ui/nuxt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Nuxt 2, 3 and 4 module for Squirkle UI.
4
+
5
+ ```bash
6
+ npm i @squirkle-ui/nuxt @squirkle-ui/ui
7
+ ```
8
+ ```ts
9
+ // nuxt.config.ts (Nuxt 3 / 4)
10
+ export default defineNuxtConfig({
11
+ modules: ['@squirkle-ui/nuxt'],
12
+ squirkle: { addons: ['datagrid', 'map'], theme: { defaultTheme: 'light' } },
13
+ })
14
+
15
+ // Nuxt 2: buildModules: [['@squirkle-ui/nuxt/nuxt2', { addons: ['datagrid'] }]]
16
+ ```
17
+ Install each add-on you list in `addons` (`@squirkle-ui/datagrid`, `@squirkle-ui/map`, …). With `map`, the module also registers MapLibre's worker for you.
18
+
19
+ Part of [Squirkle UI](https://github.com/KheangLov/squirkle-ui) · MIT License
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@squirkle-ui/nuxt",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Nuxt 2, 3 and 4 module for Squirkle UI",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/KheangLov/squirkle-ui.git",
9
+ "directory": "packages/nuxt"
10
+ },
11
+ "homepage": "https://github.com/KheangLov/squirkle-ui#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/KheangLov/squirkle-ui/issues"
14
+ },
15
+ "keywords": [
16
+ "nuxt",
17
+ "nuxt-module",
18
+ "vue",
19
+ "squircle"
20
+ ],
21
+ "type": "module",
22
+ "files": [
23
+ "src"
24
+ ],
25
+ "main": "./src/nuxt2.cjs",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./src/module.mjs"
29
+ },
30
+ "./nuxt2": "./src/nuxt2.cjs"
31
+ },
32
+ "dependencies": {
33
+ "@nuxt/kit": "^4.0.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@squirkle-ui/ui": "^0.1.0"
37
+ },
38
+ "module": "./src/module.mjs",
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
6
42
  }
package/src/module.mjs ADDED
@@ -0,0 +1,80 @@
1
+ // Nuxt 3 / Nuxt 4 module: auto-imports every Squirkle component, adds CSS and SSR theme variables.
2
+ import { createRequire } from 'node:module'
3
+ import { join } from 'node:path'
4
+ import { addComponent, addPluginTemplate, defineNuxtModule, extendViteConfig } from '@nuxt/kit'
5
+
6
+ // Add-on component names are listed statically so the module never has to load add-ons (or Leaflet CSS) in Node.
7
+ const ADDON_COMPONENTS = {
8
+ datagrid: ['SqDataGrid'],
9
+ charts: ['SqLineChart', 'SqBarChart', 'SqDonutChart', 'SqSparkline'],
10
+ swiper: ['SqSwiper'],
11
+ calendar: ['SqCalendar'],
12
+ map: ['SqMap'],
13
+ icons: ['SqIconPicker'],
14
+ }
15
+
16
+ export default defineNuxtModule({
17
+ meta: { name: '@squirkle-ui/nuxt', configKey: 'squirkle', compatibility: { nuxt: '>=3.0.0' } },
18
+ defaults: { addons: [], prefix: 'Sq', css: true, theme: undefined, squircle: undefined, appearance: undefined, icons: undefined, locale: undefined },
19
+ async setup(options, nuxt) {
20
+ const addons = (options.addons ?? []).filter((a) => a in ADDON_COMPONENTS)
21
+ const pkgs = ['ui', ...addons]
22
+ const { componentNames: uiNames } = await import('@squirkle-ui/ui')
23
+ for (const pkg of pkgs) {
24
+ for (const name of pkg === 'ui' ? uiNames : ADDON_COMPONENTS[pkg]) {
25
+ addComponent({ name: name.replace(/^Sq/, options.prefix), export: name, filePath: `@squirkle-ui/${pkg}`, mode: pkg === 'map' ? 'client' : 'all' })
26
+ }
27
+ }
28
+ if (options.css) for (const pkg of pkgs) nuxt.options.css.push(`@squirkle-ui/${pkg}/styles.css`)
29
+ nuxt.options.build.transpile.push(...pkgs.map((p) => `@squirkle-ui/${p}`), '@squirkle-ui/core')
30
+ if (addons.includes('map')) addMapSupport(nuxt.options.rootDir)
31
+
32
+ const runtimeOptions = { theme: options.theme, squircle: options.squircle, appearance: options.appearance, icons: options.icons, locale: options.locale }
33
+ addPluginTemplate({
34
+ filename: 'squirkle.plugin.mjs',
35
+ getContents: () => `import { defineNuxtPlugin, useHead } from '#imports'
36
+ import { createSquirkle, getThemeCss, config } from '@squirkle-ui/ui'
37
+
38
+ export default defineNuxtPlugin((nuxtApp) => {
39
+ nuxtApp.vueApp.use(createSquirkle({ ...${JSON.stringify(runtimeOptions)}, components: false }))
40
+ // Theme variables are generated from the app's own config (not user input).
41
+ useHead({
42
+ style: [{ id: 'sq-theme-vars', innerHTML: getThemeCss() }],
43
+ htmlAttrs: { class: 'sq-theme--' + config.theme.name },
44
+ })
45
+ })
46
+ `,
47
+ })
48
+ },
49
+ })
50
+
51
+ /**
52
+ * MapLibre starts its worker from `new URL('./maplibre-gl-worker.mjs', import.meta.url)`, a file no bundler copies:
53
+ * a client plugin passes a Vite `?url` of the worker to `setMapWorkerUrl` (served in dev, emitted on build).
54
+ * Dep pre-bundling would also move MapLibre into `.vite/deps`, so it stays excluded. The map's other deps are
55
+ * pre-bundled up front so Vite does not discover them at runtime and reload the page.
56
+ */
57
+ function addMapSupport(rootDir) {
58
+ const require = createRequire(join(rootDir, 'package.json'))
59
+ const resolve = (id) => { try { return require.resolve(id) } catch { return null } }
60
+ const worker = resolve('maplibre-gl/dist/maplibre-gl-worker.mjs') // optional peers: maplibre-gl (vector), leaflet (raster)
61
+ const hasLeaflet = !!resolve('leaflet/package.json')
62
+ if (worker) {
63
+ addPluginTemplate({
64
+ filename: 'squirkle.map-worker.client.mjs',
65
+ mode: 'client',
66
+ getContents: () => `import { defineNuxtPlugin } from '#imports'
67
+ import { setMapWorkerUrl } from '@squirkle-ui/map'
68
+ import workerUrl from ${JSON.stringify(worker.replace(/\\/g, '/') + '?url')}
69
+
70
+ export default defineNuxtPlugin(() => setMapWorkerUrl(workerUrl))
71
+ `,
72
+ })
73
+ }
74
+ const add = (list = [], items) => [...list, ...items.filter((i) => !list.includes(i))]
75
+ extendViteConfig((config) => {
76
+ config.optimizeDeps = config.optimizeDeps || {}
77
+ config.optimizeDeps.exclude = add(config.optimizeDeps.exclude, ['maplibre-gl'])
78
+ config.optimizeDeps.include = add(config.optimizeDeps.include, ['@squirkle-ui/map > supercluster', ...(hasLeaflet ? ['leaflet'] : [])])
79
+ })
80
+ }
package/src/nuxt2.cjs ADDED
@@ -0,0 +1,18 @@
1
+ // Nuxt 2.17 (Vue 2.7) module: `buildModules: [['@squirkle-ui/nuxt/nuxt2', { addons: ['datagrid'] }]]`
2
+ const path = require('path')
3
+
4
+ const ADDONS = ['datagrid', 'charts', 'swiper', 'calendar', 'map', 'icons']
5
+
6
+ module.exports = function squirkleNuxt2(moduleOptions) {
7
+ const options = { addons: [], css: true, ...(this.options.squirkle || {}), ...(moduleOptions || {}) }
8
+ const addons = (options.addons || []).filter((a) => ADDONS.includes(a))
9
+ const pkgs = ['ui'].concat(addons)
10
+ if (options.css) for (const pkg of pkgs) this.options.css.push(`@squirkle-ui/${pkg}/styles.css`)
11
+ this.options.build.transpile.push(/@squirkle-ui\//)
12
+ this.addPlugin({
13
+ src: path.resolve(__dirname, 'runtime/nuxt2-plugin.js'),
14
+ fileName: 'squirkle.js',
15
+ options: { addons, runtime: { theme: options.theme, squircle: options.squircle, appearance: options.appearance, icons: options.icons, locale: options.locale } },
16
+ })
17
+ }
18
+ module.exports.meta = { name: '@squirkle-ui/nuxt' }
@@ -0,0 +1,14 @@
1
+ import Vue from 'vue'
2
+ import { createSquirkle, getThemeCss, config } from '@squirkle-ui/ui/vue2'
3
+ <% options.addons.forEach(function (a) { %>import * as addon_<%= a %> from '@squirkle-ui/<%= a %>/vue2'
4
+ <% }) %>
5
+ Vue.use(createSquirkle(<%= JSON.stringify(options.runtime) %>))
6
+ <% options.addons.forEach(function (a) { %>for (const name of addon_<%= a %>.componentNames || []) Vue.component(name, addon_<%= a %>[name])
7
+ <% }) %>
8
+ export default ({ app }) => {
9
+ const head = (app.head = app.head || {})
10
+ head.style = (head.style || []).concat({ hid: 'sq-theme-vars', innerHTML: getThemeCss() })
11
+ // Theme CSS is generated from the app's own config (not user input), so it may skip vue-meta's sanitizer.
12
+ head.__dangerouslyDisableSanitizersByTagID = Object.assign({}, head.__dangerouslyDisableSanitizersByTagID, { 'sq-theme-vars': ['innerHTML'] })
13
+ head.htmlAttrs = Object.assign({}, head.htmlAttrs, { class: 'sq-theme--' + config.theme.name })
14
+ }