@nxgt/material-vue 0.2.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { Dc as e, Rf as t } from "./components-Cd9cMyAH.js";
1
+ import { Dc as e, Rf as t } from "./components-Cbdud8WI.js";
2
2
  import { t as n } from "./utils-Cy-ByIEo.js";
3
3
  import { n as r } from "./i18n-DXZMN9FA.js";
4
4
  import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, defineComponent as u, normalizeClass as d, normalizeStyle as f, openBlock as p, ref as m, renderList as h, toDisplayString as g, unref as _, withCtx as v } from "vue";
@@ -1,5 +1,5 @@
1
- import { Dc as e, Rf as t } from "./components-Cd9cMyAH.js";
2
- import { t as n } from "./pdf-page-DzmRPuT_.js";
1
+ import { Dc as e, Rf as t } from "./components-Cbdud8WI.js";
2
+ import { t as n } from "./pdf-page-rGTgfSly.js";
3
3
  import { Fragment as r, createBlock as i, createElementBlock as a, createElementVNode as o, defineComponent as s, openBlock as c, renderList as l, withCtx as u } from "vue";
4
4
  //#region lib/components/ui/pdf-viewer/partials/pdf-page-list.vue?vue&type=script&setup=true&lang.ts
5
5
  var d = { class: "flex flex-col items-center gap-4 px-4 py-4" }, f = /*@__PURE__*/ s({
@@ -1,4 +1,4 @@
1
- import { gl as e } from "./components-Cd9cMyAH.js";
1
+ import { gl as e } from "./components-Cbdud8WI.js";
2
2
  import { t } from "./utils-Cy-ByIEo.js";
3
3
  import { createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, nextTick as s, normalizeClass as c, normalizeStyle as l, onBeforeUnmount as u, openBlock as d, ref as f, unref as p, watch as m } from "vue";
4
4
  //#region lib/components/ui/pdf-viewer/pdf-escape.ts
@@ -1,11 +1,11 @@
1
- import { Dd as e, ct as t } from "./components-Cd9cMyAH.js";
1
+ import { Dd as e, ct as t } from "./components-Cbdud8WI.js";
2
2
  import { t as n } from "./utils-Cy-ByIEo.js";
3
3
  import { r } from "./icon-button-Ghucx7Ah.js";
4
4
  import { n as i } from "./i18n-DXZMN9FA.js";
5
- import { i as a, n as o, r as s } from "./pdf-page-DzmRPuT_.js";
6
- import { t as c } from "./pdf-page-list-CqRIdpm7.js";
7
- import { t as l } from "./pdf-sidebar-BPfizuMa.js";
8
- import { t as u } from "./pdf-toolbar-B8YdJxDq.js";
5
+ import { i as a, n as o, r as s } from "./pdf-page-rGTgfSly.js";
6
+ import { t as c } from "./pdf-page-list-61J-y1Jy.js";
7
+ import { t as l } from "./pdf-sidebar-Qo-cHfYv.js";
8
+ import { t as u } from "./pdf-toolbar-UbBVdrBX.js";
9
9
  import { createBlock as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createTextVNode as h, createVNode as g, defineComponent as _, normalizeClass as v, onBeforeUnmount as y, onMounted as b, openBlock as x, reactive as S, ref as C, shallowRef as w, toDisplayString as T, toRef as E, unref as D, watch as O, withCtx as k } from "vue";
10
10
  import { AlertCircle as A, FileX2 as j, KeyRound as M, Loader2 as N } from "lucide-vue-next";
11
11
  //#region lib/components/ui/pdf-viewer/pdf-download.ts
@@ -1,8 +1,8 @@
1
- import { Rf as e } from "./components-Cd9cMyAH.js";
1
+ import { Rf as e } from "./components-Cbdud8WI.js";
2
2
  import { t } from "./utils-Cy-ByIEo.js";
3
3
  import { n } from "./i18n-DXZMN9FA.js";
4
- import { t as r } from "./pdf-outline-sidebar-DhZqpRoO.js";
5
- import { t as i } from "./pdf-thumbnail-sidebar-Ca3LhKTL.js";
4
+ import { t as r } from "./pdf-outline-sidebar-h9_YREnD.js";
5
+ import { t as i } from "./pdf-thumbnail-sidebar-CojlsV6q.js";
6
6
  import { createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, normalizeClass as l, openBlock as u, toDisplayString as d, unref as f, useId as p, useTemplateRef as m } from "vue";
7
7
  //#region lib/components/ui/pdf-viewer/partials/pdf-sidebar.vue?vue&type=script&setup=true&lang.ts
8
8
  var h = ["aria-label"], g = ["aria-label"], _ = [
@@ -1,7 +1,7 @@
1
- import { Dc as e, Rf as t } from "./components-Cd9cMyAH.js";
1
+ import { Dc as e, Rf as t } from "./components-Cbdud8WI.js";
2
2
  import { t as n } from "./utils-Cy-ByIEo.js";
3
3
  import { n as r } from "./i18n-DXZMN9FA.js";
4
- import { t as i } from "./pdf-page-DzmRPuT_.js";
4
+ import { t as i } from "./pdf-page-rGTgfSly.js";
5
5
  import { Fragment as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, normalizeClass as d, openBlock as f, renderList as p, toDisplayString as m, unref as h, withCtx as g } from "vue";
6
6
  //#region lib/components/ui/pdf-viewer/partials/pdf-thumbnail-sidebar.vue?vue&type=script&setup=true&lang.ts
7
7
  var _ = ["aria-label"], v = {
@@ -1,4 +1,4 @@
1
- import { Dd as e, Rf as t } from "./components-Cd9cMyAH.js";
1
+ import { Dd as e, Rf as t } from "./components-Cbdud8WI.js";
2
2
  import { t as n } from "./utils-Cy-ByIEo.js";
3
3
  import { t as r } from "./icon-button-Ghucx7Ah.js";
4
4
  import { n as i } from "./i18n-DXZMN9FA.js";
@@ -1,4 +1,4 @@
1
- import { _ as e, f as t, g as n, iu as r, m as i, p as a, v as o, y as s } from "./components-Cd9cMyAH.js";
1
+ import { _ as e, f as t, g as n, iu as r, m as i, p as a, v as o, y as s } from "./components-Cbdud8WI.js";
2
2
  import { t as c } from "./utils-Cy-ByIEo.js";
3
3
  import { createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createTextVNode as p, createVNode as m, defineComponent as h, normalizeClass as g, openBlock as _, toDisplayString as v, unref as y, withCtx as b } from "vue";
4
4
  //#region lib/components/ui/stx-player/partials/stx-player-frame.vue?vue&type=script&setup=true&lang.ts
package/dist/styles.css CHANGED
@@ -1,7 +1,8 @@
1
1
  @import "tailwindcss";
2
2
  @import "tw-animate-css";
3
3
  @import "./components/ui/code/code-moonlight.css";
4
- @source "./components";
4
+ /* Consumers' Tailwind skips node_modules: scan the compiled components. */
5
+ @source "../dist";
5
6
 
6
7
  @custom-variant dark (
7
8
  &:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *)
@@ -2,28 +2,28 @@ import {
2
2
  addComponent,
3
3
  addImports,
4
4
  addPlugin,
5
- addTemplate,
6
- addVitePlugin,
7
5
  createResolver,
8
6
  defineNuxtModule,
7
+ extendViteConfig,
9
8
  } from '@nuxt/kit';
10
9
  import { COMPONENT_NAMES } from './component-names';
11
- import { injectMaterialVueStyles, isAppCssId } from './inject-css';
12
10
 
13
11
  export type ModuleOptions = {
14
12
  /** Prepended to auto-imported component names. Empty by default. */
15
13
  prefix?: string;
16
- /**
17
- * Inject `@nxgt/material-vue/styles.css` into the app Tailwind CSS entry.
18
- * Default true. Set false if you `@import` it yourself.
19
- */
20
- css?: boolean;
21
14
  /** Auto-import PascalCase components. Default true. */
22
15
  components?: boolean;
23
16
  /** Auto-import composables and i18n helpers. Default true. */
24
17
  imports?: boolean;
25
18
  };
26
19
 
20
+ /**
21
+ * CommonJS-only dependencies. The package is transpiled, so Vite does not
22
+ * pre-bundle its imports; without this the browser receives the raw CJS file
23
+ * and `import x from 'jsbarcode'` has no default export.
24
+ */
25
+ const CJS_DEPENDENCIES = ['jsbarcode'] as const;
26
+
27
27
  export default defineNuxtModule<ModuleOptions>({
28
28
  meta: {
29
29
  name: '@nxgt/material-vue',
@@ -32,40 +32,24 @@ export default defineNuxtModule<ModuleOptions>({
32
32
  },
33
33
  defaults: {
34
34
  prefix: '',
35
- css: true,
36
35
  components: true,
37
36
  imports: true,
38
37
  },
39
38
  setup(
40
39
  options: ModuleOptions,
41
- nuxt: { options: { build: { transpile: string[] }; css: string[] } },
40
+ nuxt: { options: { build: { transpile: string[] } } },
42
41
  ) {
43
42
  const resolver = createResolver(import.meta.url);
44
43
 
45
44
  nuxt.options.build.transpile.push('@nxgt/material-vue');
46
45
 
47
- if (options.css !== false) {
48
- addVitePlugin({
49
- name: 'nxgt-material-vue:css',
50
- enforce: 'pre',
51
- transform(code, id) {
52
- if (!isAppCssId(id)) return;
53
- const next = injectMaterialVueStyles(code);
54
- if (next == null) return;
55
- return { code: next, map: null };
56
- },
57
- });
58
-
59
- if (nuxt.options.css.length === 0) {
60
- const file = addTemplate({
61
- filename: 'nxgt-material-vue.css',
62
- getContents: () =>
63
- '@import "tailwindcss";\n@import "@nxgt/material-vue/styles.css";\n',
64
- write: true,
65
- });
66
- nuxt.options.css.unshift(file.dst);
46
+ extendViteConfig((config) => {
47
+ config.optimizeDeps ??= {};
48
+ config.optimizeDeps.include ??= [];
49
+ for (const dependency of CJS_DEPENDENCIES) {
50
+ config.optimizeDeps.include.push(`@nxgt/material-vue > ${dependency}`);
67
51
  }
68
- }
52
+ });
69
53
 
70
54
  if (options.components !== false) {
71
55
  for (const name of COMPONENT_NAMES) {
package/lib/styles.css CHANGED
@@ -1,7 +1,8 @@
1
1
  @import "tailwindcss";
2
2
  @import "tw-animate-css";
3
3
  @import "./components/ui/code/code-moonlight.css";
4
- @source "./components";
4
+ /* Consumers' Tailwind skips node_modules: scan the compiled components. */
5
+ @source "../dist";
5
6
 
6
7
  @custom-variant dark (
7
8
  &:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/material-vue",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -149,7 +149,7 @@
149
149
  "@storybook/vue3-vite": "10.6.0",
150
150
  "@tailwindcss/vite": "^4.3.3",
151
151
  "@tanstack/vue-table": "^9.1.2",
152
- "@types/bun": "^1.4.0",
152
+ "@types/bun": "^1.4.2",
153
153
  "@types/jsbarcode": "^3.11.4",
154
154
  "@types/lodash-es": "^4.17.12",
155
155
  "@types/node": "^26.1.1",
@@ -1,10 +0,0 @@
1
- export declare const MATERIAL_VUE_STYLES = "@nxgt/material-vue/styles.css";
2
- /**
3
- * Tailwind v4 only applies `@theme` / `@utility` in the same CSS graph as
4
- * `@import "tailwindcss"`. Pushing `styles.css` as a separate Nuxt `css[]`
5
- * entry creates a second pipeline, so tokens never reach the app.
6
- *
7
- * Insert the library import immediately after the Tailwind import.
8
- */
9
- export declare function injectMaterialVueStyles(code: string): string | null;
10
- export declare function isAppCssId(id: string): boolean;
@@ -1,41 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { injectMaterialVueStyles, isAppCssId } from './inject-css';
3
-
4
- describe('injectMaterialVueStyles', () => {
5
- it('inserts the library import after @import "tailwindcss"', () => {
6
- const input = '@import "tailwindcss";\n\nbody { margin: 0; }\n';
7
- expect(injectMaterialVueStyles(input)).toBe(
8
- '@import "tailwindcss";\n@import "@nxgt/material-vue/styles.css";\n\nbody { margin: 0; }\n',
9
- );
10
- });
11
-
12
- it('handles @import "tailwindcss" source(...)', () => {
13
- const input = '@import "tailwindcss" source("../app");\n';
14
- expect(injectMaterialVueStyles(input)).toContain(
15
- '@import "@nxgt/material-vue/styles.css";',
16
- );
17
- });
18
-
19
- it('is a no-op when already imported', () => {
20
- const input =
21
- '@import "tailwindcss";\n@import "@nxgt/material-vue/styles.css";\n';
22
- expect(injectMaterialVueStyles(input)).toBeNull();
23
- });
24
-
25
- it('is a no-op without a Tailwind import', () => {
26
- expect(injectMaterialVueStyles('body { margin: 0; }')).toBeNull();
27
- });
28
- });
29
-
30
- describe('isAppCssId', () => {
31
- it('accepts app CSS', () => {
32
- expect(isAppCssId('/app/assets/css/main.css')).toBe(true);
33
- expect(isAppCssId('/app/assets/css/main.css?direct')).toBe(true);
34
- });
35
-
36
- it('rejects node_modules', () => {
37
- expect(isAppCssId('/node_modules/@nxgt/material-vue/lib/styles.css')).toBe(
38
- false,
39
- );
40
- });
41
- });
@@ -1,24 +0,0 @@
1
- export const MATERIAL_VUE_STYLES = '@nxgt/material-vue/styles.css';
2
-
3
- const TAILWIND_IMPORT = /@import\s+["']tailwindcss(?:[^"']*)["']\s*;?/;
4
-
5
- /**
6
- * Tailwind v4 only applies `@theme` / `@utility` in the same CSS graph as
7
- * `@import "tailwindcss"`. Pushing `styles.css` as a separate Nuxt `css[]`
8
- * entry creates a second pipeline, so tokens never reach the app.
9
- *
10
- * Insert the library import immediately after the Tailwind import.
11
- */
12
- export function injectMaterialVueStyles(code: string): string | null {
13
- if (code.includes(MATERIAL_VUE_STYLES)) return null;
14
- const match = code.match(TAILWIND_IMPORT);
15
- if (!match || match.index === undefined) return null;
16
- const at = match.index + match[0].length;
17
- return `${code.slice(0, at)}\n@import "${MATERIAL_VUE_STYLES}";${code.slice(at)}`;
18
- }
19
-
20
- export function isAppCssId(id: string): boolean {
21
- const path = id.split('?')[0] ?? id;
22
- if (!path.endsWith('.css')) return false;
23
- return !path.includes('node_modules');
24
- }