@antcde/component-library 0.1.15 → 0.1.16-rc.99b70a1

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.
@@ -0,0 +1,26 @@
1
+ import type { UserConfig } from 'unocss';
2
+ /**
3
+ * Creates a UnoCSS config pre-configured for the ANT platform with Vuetify 4.
4
+ *
5
+ * Includes:
6
+ * - Correct `outputToCssLayers` with `uno-` prefix (required for Vuetify 4 layer compatibility)
7
+ * - `presetWind4` with Vuetify dark mode selector (`.v-theme--dark`)
8
+ * - `presetRemToPx` for pixel-based design
9
+ * - Vuetify breakpoints matching Vuetify's built-in breakpoints
10
+ * - ANT design tokens (`bg-ant-surface`, `text-muted`, `border-ant`, etc.)
11
+ * - Standard transformers (directives + variant group)
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // uno.config.ts — zero-arg default (most apps)
16
+ * import { createAntUnoConfig } from '@antcde/component-library/build/uno'
17
+ * export default createAntUnoConfig()
18
+ *
19
+ * // With overrides
20
+ * export default createAntUnoConfig({
21
+ * rules: [['my-rule', { color: 'red' }]],
22
+ * theme: { colors: { primary: '#009688' } },
23
+ * })
24
+ * ```
25
+ */
26
+ export declare function createAntUnoConfig(overrides?: Partial<UserConfig>): UserConfig;
@@ -0,0 +1,110 @@
1
+ import presetRemToPx from '@unocss/preset-rem-to-px';
2
+ import presetWind4 from '@unocss/preset-wind4';
3
+ import { defineConfig, transformerDirectives, transformerVariantGroup } from 'unocss';
4
+ const antColors = {
5
+ primary: '#125CFF',
6
+ secondary: '#64748B',
7
+ info: '#2196F3',
8
+ success: '#4CAF50',
9
+ warning: '#FB8C00',
10
+ };
11
+ const vuetifyBreakpoints = {
12
+ xs: '0px',
13
+ sm: '600px',
14
+ md: '960px',
15
+ lg: '1280px',
16
+ xl: '1920px',
17
+ xxl: '2560px',
18
+ };
19
+ // ANT design-system tokens built on Vuetify CSS custom properties. These
20
+ // exist because UnoCSS shortcuts can only expand to UnoCSS-generated
21
+ // utilities — Vuetify's own classes (bg-surface, etc.) are invisible to the
22
+ // shortcut resolver. Text tokens use unprefixed names (text-heading,
23
+ // text-muted) since they have no Vuetify namesake. Background and border
24
+ // tokens use the `ant-` prefix to avoid shadowing Vuetify's own bg-surface.
25
+ const antDesignTokens = [
26
+ ['bg-ant-surface', { 'background-color': 'rgb(var(--v-theme-surface))' }],
27
+ ['bg-ant-panel', { 'background-color': 'rgba(var(--v-theme-on-surface), 0.03)' }],
28
+ ['bg-ant-inset', { 'background-color': 'rgba(var(--v-border-color), 0.08)' }],
29
+ ['bg-ant-hover', { 'background-color': 'rgba(var(--v-border-color), 0.04)' }],
30
+ ['text-heading', { color: 'rgb(var(--v-theme-on-surface))' }],
31
+ ['text-body', { color: 'rgba(var(--v-theme-on-surface), 0.7)' }],
32
+ ['text-muted', { color: 'rgba(var(--v-theme-on-surface), 0.5)' }],
33
+ ['text-disabled', { color: 'rgba(var(--v-theme-on-surface), 0.38)' }],
34
+ ['border-ant', { 'border-color': 'rgba(var(--v-border-color), var(--v-border-opacity))' }],
35
+ ];
36
+ /**
37
+ * Normalizes shortcuts from either array or object form to array form.
38
+ *
39
+ * UnoCSS accepts shortcuts as either:
40
+ * - Array: `[['pattern', 'replacement'], ...]`
41
+ * - Object: `{ 'pattern': 'replacement', ... }`
42
+ *
43
+ * This helper ensures both forms are supported in overrides.
44
+ */
45
+ function normalizeShortcuts(shortcuts) {
46
+ if (Array.isArray(shortcuts))
47
+ return shortcuts;
48
+ if (shortcuts != null && typeof shortcuts === 'object')
49
+ return Object.entries(shortcuts);
50
+ return [];
51
+ }
52
+ /**
53
+ * Creates a UnoCSS config pre-configured for the ANT platform with Vuetify 4.
54
+ *
55
+ * Includes:
56
+ * - Correct `outputToCssLayers` with `uno-` prefix (required for Vuetify 4 layer compatibility)
57
+ * - `presetWind4` with Vuetify dark mode selector (`.v-theme--dark`)
58
+ * - `presetRemToPx` for pixel-based design
59
+ * - Vuetify breakpoints matching Vuetify's built-in breakpoints
60
+ * - ANT design tokens (`bg-ant-surface`, `text-muted`, `border-ant`, etc.)
61
+ * - Standard transformers (directives + variant group)
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * // uno.config.ts — zero-arg default (most apps)
66
+ * import { createAntUnoConfig } from '@antcde/component-library/build/uno'
67
+ * export default createAntUnoConfig()
68
+ *
69
+ * // With overrides
70
+ * export default createAntUnoConfig({
71
+ * rules: [['my-rule', { color: 'red' }]],
72
+ * theme: { colors: { primary: '#009688' } },
73
+ * })
74
+ * ```
75
+ */
76
+ export function createAntUnoConfig(overrides = {}) {
77
+ const { rules, presets, transformers, theme, shortcuts, preflights, ...rest } = overrides;
78
+ // UnoCSS types `theme` as `object` on `UserConfig`, so destructured fields
79
+ // lose their shape. Cast to a loose record to access `colors`/`breakpoints`/`radius`.
80
+ const overrideTheme = theme;
81
+ const overrideRules = (rules ?? []);
82
+ return defineConfig({
83
+ outputToCssLayers: {
84
+ cssLayerName: (layer) => layer === 'properties' ? null : `uno-${layer}`,
85
+ },
86
+ preflights: preflights ?? [],
87
+ rules: [
88
+ ...antDesignTokens,
89
+ ...overrideRules,
90
+ ],
91
+ theme: {
92
+ ...overrideTheme,
93
+ colors: { ...antColors, ...(overrideTheme?.colors ?? {}) },
94
+ breakpoints: { ...vuetifyBreakpoints, ...(overrideTheme?.breakpoints ?? {}) },
95
+ radius: { sm: '2px', xl: '24px', ...(overrideTheme?.radius ?? {}) },
96
+ },
97
+ presets: presets ?? [
98
+ presetRemToPx,
99
+ presetWind4({ dark: { dark: '.v-theme--dark' } }),
100
+ ],
101
+ shortcuts: [
102
+ ...normalizeShortcuts(shortcuts),
103
+ ],
104
+ transformers: transformers ?? [
105
+ transformerDirectives(),
106
+ transformerVariantGroup(),
107
+ ],
108
+ ...rest,
109
+ });
110
+ }
@@ -0,0 +1,28 @@
1
+ import type { UserConfig } from 'vite';
2
+ import { URL } from 'node:url';
3
+ /** Canonical CSS layer order declaration — single source of truth for Vuetify 4 + UnoCSS cascade. */
4
+ export declare const CSS_LAYER_ORDER = "@layer uno-base, uno-theme, vuetify-core, vuetify-components, vuetify-overrides, vuetify-utilities, uno-shortcuts, uno-default, vuetify-final;";
5
+ /**
6
+ * Creates a Vite config pre-configured for ANT platform apps.
7
+ *
8
+ * Includes: vue, UnoCSS, Vuetify auto-import, AutoImport, Components,
9
+ * Icons, VueI18nPlugin, and sensible defaults for optimizeDeps, resolve, and build.
10
+ *
11
+ * @param appRoot - Pass `import.meta.url` from your vite.config.ts.
12
+ * Used to resolve relative paths (i18n translations, `@` alias) correctly.
13
+ * @param overrides - Additional Vite config merged via `mergeConfig()`.
14
+ * Plugins are appended, objects are deep-merged.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // vite.config.ts — zero-override default (most apps)
19
+ * import { createAntViteConfig } from '@antcde/component-library/build/vite'
20
+ * export default createAntViteConfig(import.meta.url)
21
+ *
22
+ * // With overrides
23
+ * export default createAntViteConfig(import.meta.url, {
24
+ * server: { port: 5174 },
25
+ * })
26
+ * ```
27
+ */
28
+ export declare function createAntViteConfig(appRoot: string | URL, overrides?: UserConfig): UserConfig;
@@ -0,0 +1,98 @@
1
+ import { fileURLToPath, URL } from 'node:url';
2
+ import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
3
+ import vue from '@vitejs/plugin-vue';
4
+ import UnoCSS from 'unocss/vite';
5
+ import AutoImport from 'unplugin-auto-import/rolldown';
6
+ import IconsResolver from 'unplugin-icons/resolver';
7
+ import Icons from 'unplugin-icons/rolldown';
8
+ import Components from 'unplugin-vue-components/rolldown';
9
+ import { defineConfig, mergeConfig } from 'vite';
10
+ import vuetify from 'vite-plugin-vuetify';
11
+ const RE_DIST = /dist/;
12
+ const RE_VUETIFY_PLUGIN = /src\/plugins\/vuetify\.ts$/;
13
+ const RE_NODE_MODULES = /\bnode_modules\b/;
14
+ /** Canonical CSS layer order declaration — single source of truth for Vuetify 4 + UnoCSS cascade. */
15
+ export const CSS_LAYER_ORDER = '@layer uno-base, uno-theme, vuetify-core, vuetify-components, vuetify-overrides, vuetify-utilities, uno-shortcuts, uno-default, vuetify-final;';
16
+ /**
17
+ * Creates a Vite config pre-configured for ANT platform apps.
18
+ *
19
+ * Includes: vue, UnoCSS, Vuetify auto-import, AutoImport, Components,
20
+ * Icons, VueI18nPlugin, and sensible defaults for optimizeDeps, resolve, and build.
21
+ *
22
+ * @param appRoot - Pass `import.meta.url` from your vite.config.ts.
23
+ * Used to resolve relative paths (i18n translations, `@` alias) correctly.
24
+ * @param overrides - Additional Vite config merged via `mergeConfig()`.
25
+ * Plugins are appended, objects are deep-merged.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // vite.config.ts — zero-override default (most apps)
30
+ * import { createAntViteConfig } from '@antcde/component-library/build/vite'
31
+ * export default createAntViteConfig(import.meta.url)
32
+ *
33
+ * // With overrides
34
+ * export default createAntViteConfig(import.meta.url, {
35
+ * server: { port: 5174 },
36
+ * })
37
+ * ```
38
+ */
39
+ export function createAntViteConfig(appRoot, overrides = {}) {
40
+ const resolve = (relative) => fileURLToPath(new URL(relative, appRoot));
41
+ const baseConfig = defineConfig({
42
+ base: '/__APP_URL__/',
43
+ optimizeDeps: { exclude: ['vuetify'] },
44
+ plugins: [
45
+ // Inject CSS layer order into <head> before any JS-loaded CSS.
46
+ // This guarantees the cascade order is set before vite-plugin-vuetify
47
+ // auto-imports component CSS — no manual import ordering required.
48
+ {
49
+ name: 'ant-css-layer-order',
50
+ transformIndexHtml() {
51
+ return [{ tag: 'style', children: CSS_LAYER_ORDER, injectTo: 'head-prepend' }];
52
+ },
53
+ },
54
+ vue(),
55
+ UnoCSS('uno.config.ts'),
56
+ vuetify({ autoImport: { labs: true } }),
57
+ Icons({ autoInstall: true }),
58
+ AutoImport({
59
+ imports: [
60
+ 'vue',
61
+ '@vueuse/core',
62
+ '@vueuse/math',
63
+ { vuetify: ['useDisplay'] },
64
+ ],
65
+ dirs: ['src/composables', 'src/stores', 'src/plugins'],
66
+ dts: true,
67
+ eslintrc: { enabled: true },
68
+ exclude: [RE_DIST, RE_VUETIFY_PLUGIN, RE_NODE_MODULES],
69
+ }),
70
+ Components({
71
+ dirs: ['src/components'],
72
+ extensions: ['vue'],
73
+ globs: [
74
+ 'src/components/**/*.vue',
75
+ '!src/components/**/_*/**',
76
+ '!src/components/**/_*.vue',
77
+ '!src/components/**/components/**',
78
+ ],
79
+ resolvers: [IconsResolver()],
80
+ }),
81
+ VueI18nPlugin({
82
+ include: resolve('./src/lang/translations/**'),
83
+ strictMessage: false,
84
+ }),
85
+ ],
86
+ resolve: {
87
+ dedupe: ['vue', 'vuetify'],
88
+ extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue'],
89
+ alias: {
90
+ '@': resolve('./src'),
91
+ },
92
+ },
93
+ build: {
94
+ cssMinify: 'esbuild',
95
+ },
96
+ });
97
+ return mergeConfig(baseConfig, overrides);
98
+ }
@@ -0,0 +1,19 @@
1
+ import { URL } from 'node:url';
2
+ /**
3
+ * Creates a Vitest config pre-configured for ANT platform packages.
4
+ *
5
+ * Includes: vue plugin, vuetify auto-import, happy-dom environment,
6
+ * vuetify dep inlining, path alias resolution, and the shared setup file
7
+ * that registers Vuetify + i18n on `config.global.plugins` and mocks
8
+ * `@antcde/vue-utils`.
9
+ *
10
+ * @param appRoot - Pass `import.meta.url` from your vitest.config.ts.
11
+ * @param overrides - Additional config merged via `mergeConfig()`.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { createAntVitestConfig } from '@antcde/component-library/test/vitest'
16
+ * export default createAntVitestConfig(import.meta.url)
17
+ * ```
18
+ */
19
+ export declare function createAntVitestConfig(appRoot: string | URL, overrides?: Record<string, any>): Record<string, any>;
@@ -0,0 +1,79 @@
1
+ import { fileURLToPath, URL } from 'node:url';
2
+ import vue from '@vitejs/plugin-vue';
3
+ import vuetify from 'vite-plugin-vuetify';
4
+ import { defineConfig, mergeConfig } from 'vitest/config';
5
+ /**
6
+ * Creates a Vitest config pre-configured for ANT platform packages.
7
+ *
8
+ * Includes: vue plugin, vuetify auto-import, happy-dom environment,
9
+ * vuetify dep inlining, path alias resolution, and the shared setup file
10
+ * that registers Vuetify + i18n on `config.global.plugins` and mocks
11
+ * `@antcde/vue-utils`.
12
+ *
13
+ * @param appRoot - Pass `import.meta.url` from your vitest.config.ts.
14
+ * @param overrides - Additional config merged via `mergeConfig()`.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { createAntVitestConfig } from '@antcde/component-library/test/vitest'
19
+ * export default createAntVitestConfig(import.meta.url)
20
+ * ```
21
+ */
22
+ export function createAntVitestConfig(appRoot, overrides = {}) {
23
+ const rootDir = fileURLToPath(new URL('.', appRoot));
24
+ const base = defineConfig({
25
+ plugins: [
26
+ vue(),
27
+ vuetify({ autoImport: true }),
28
+ ],
29
+ resolve: {
30
+ extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue'],
31
+ alias: {
32
+ '@': fileURLToPath(new URL('./src', appRoot)),
33
+ },
34
+ },
35
+ test: {
36
+ globals: true,
37
+ environment: 'happy-dom',
38
+ environmentOptions: {
39
+ happyDOM: {
40
+ settings: {
41
+ navigator: {
42
+ maxTouchPoints: 0,
43
+ },
44
+ disableCSSFileLoading: true,
45
+ disableJavaScriptFileLoading: true,
46
+ handleDisabledFileLoadingAsSuccess: true,
47
+ },
48
+ },
49
+ },
50
+ root: rootDir,
51
+ include: [
52
+ 'src/**/*.{test,spec}.ts',
53
+ 'tests/**/*.{test,spec}.ts',
54
+ ],
55
+ exclude: ['node_modules'],
56
+ server: {
57
+ deps: {
58
+ // Inline the ANT packages so Vite transforms them, instead of Node
59
+ // externalizing their bundler-oriented published artifacts:
60
+ // - component-library test helpers ship as raw .ts (would hit
61
+ // ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING under Node ESM);
62
+ // - connect-ts/vue-utils ship builds with extensionless imports + CJS
63
+ // deps (e.g. post-robot) that only resolve through a bundler.
64
+ inline: [
65
+ 'vuetify',
66
+ /@antcde\/component-library\/lib\/test\//,
67
+ '@antcde/connect-ts',
68
+ '@antcde/vue-utils',
69
+ ],
70
+ },
71
+ },
72
+ // Resolved in the consumer's context as @antcde/component-library/test/setup
73
+ // (lib/test/setup.ts) — works whether this config runs as raw .ts (monorepo)
74
+ // or compiled dist/test/vitest.js (published).
75
+ setupFiles: ['@antcde/component-library/test/setup'],
76
+ },
77
+ });
78
+ return mergeConfig(base, overrides);
79
+ }
@@ -22,7 +22,6 @@ import { defineConfig, mergeConfig } from 'vitest/config'
22
22
  */
23
23
  export function createAntVitestConfig(appRoot: string | URL, overrides: Record<string, any> = {}) {
24
24
  const rootDir = fileURLToPath(new URL('.', appRoot))
25
- const sharedSetup = fileURLToPath(new URL('./setup.ts', import.meta.url))
26
25
 
27
26
  const base = defineConfig({
28
27
  plugins: [
@@ -58,10 +57,24 @@ export function createAntVitestConfig(appRoot: string | URL, overrides: Record<s
58
57
  exclude: ['node_modules'],
59
58
  server: {
60
59
  deps: {
61
- inline: ['vuetify'],
60
+ // Inline the ANT packages so Vite transforms them, instead of Node
61
+ // externalizing their bundler-oriented published artifacts:
62
+ // - component-library test helpers ship as raw .ts (would hit
63
+ // ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING under Node ESM);
64
+ // - connect-ts/vue-utils ship builds with extensionless imports + CJS
65
+ // deps (e.g. post-robot) that only resolve through a bundler.
66
+ inline: [
67
+ 'vuetify',
68
+ /@antcde\/component-library\/lib\/test\//,
69
+ '@antcde/connect-ts',
70
+ '@antcde/vue-utils',
71
+ ],
62
72
  },
63
73
  },
64
- setupFiles: [sharedSetup],
74
+ // Resolved in the consumer's context as @antcde/component-library/test/setup
75
+ // (lib/test/setup.ts) — works whether this config runs as raw .ts (monorepo)
76
+ // or compiled dist/test/vitest.js (published).
77
+ setupFiles: ['@antcde/component-library/test/setup'],
65
78
  },
66
79
  })
67
80
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antcde/component-library",
3
3
  "type": "module",
4
- "version": "0.1.15",
4
+ "version": "0.1.16-rc.99b70a1",
5
5
  "description": "Helper to use ant components in Vue 3",
6
6
  "author": "CollaborAll",
7
7
  "exports": {
@@ -30,6 +30,9 @@
30
30
  "./test/vitest": {
31
31
  "import": "./lib/test/vitest.ts"
32
32
  },
33
+ "./test/setup": {
34
+ "import": "./lib/test/setup.ts"
35
+ },
33
36
  "./test/mocks": {
34
37
  "import": "./lib/test/mocks/index.ts"
35
38
  },
@@ -79,12 +82,87 @@
79
82
  "README.md",
80
83
  "package.json"
81
84
  ],
85
+ "publishConfig": {
86
+ "exports": {
87
+ ".": {
88
+ "types": "./dist/types/src/index.d.ts",
89
+ "import": "./dist/index.js",
90
+ "require": "./dist/index.cjs.js"
91
+ },
92
+ "./composables/*": {
93
+ "types": "./dist/types/src/composables/*.d.ts"
94
+ },
95
+ "./build/uno": {
96
+ "types": "./dist/build/uno.d.ts",
97
+ "import": "./dist/build/uno.js",
98
+ "default": "./dist/build/uno.js"
99
+ },
100
+ "./build/vite": {
101
+ "types": "./dist/build/vite.d.ts",
102
+ "import": "./dist/build/vite.js"
103
+ },
104
+ "./build/vuetify": {
105
+ "import": "./lib/build/vuetify.ts"
106
+ },
107
+ "./build/layer-order.css": "./lib/build/layer-order.css",
108
+ "./test": {
109
+ "import": "./lib/test/index.ts"
110
+ },
111
+ "./test/vitest": {
112
+ "types": "./dist/test/vitest.d.ts",
113
+ "import": "./dist/test/vitest.js"
114
+ },
115
+ "./test/setup": {
116
+ "import": "./lib/test/setup.ts"
117
+ },
118
+ "./test/mocks": {
119
+ "import": "./lib/test/mocks/index.ts"
120
+ },
121
+ "./test/mount": {
122
+ "import": "./lib/test/mountWithContext.ts"
123
+ },
124
+ "./test/mockVueRouter": {
125
+ "import": "./lib/test/mockVueRouter.ts"
126
+ },
127
+ "./test/createTestPinia": {
128
+ "import": "./lib/test/createTestPinia.ts"
129
+ },
130
+ "./test/createTestRouter": {
131
+ "import": "./lib/test/createTestRouter.ts"
132
+ },
133
+ "./lib/ForgeViewer": {
134
+ "import": "./lib/ForgeViewer/index.ts"
135
+ },
136
+ "./lib/ForgeViewer/*": {
137
+ "import": "./lib/ForgeViewer/*"
138
+ },
139
+ "./lib/GisViewer": {
140
+ "import": "./lib/GisViewer/index.ts"
141
+ },
142
+ "./lib/GisViewer/*": {
143
+ "import": "./lib/GisViewer/*"
144
+ },
145
+ "./lib/TableViewer": {
146
+ "import": "./lib/TableViewer/index.ts"
147
+ },
148
+ "./lib/TableViewer/*": {
149
+ "import": "./lib/TableViewer/*"
150
+ },
151
+ "./lib/DocumentManager": {
152
+ "import": "./lib/DocumentManager/index.ts"
153
+ },
154
+ "./lib/DocumentManager/*": {
155
+ "import": "./lib/DocumentManager/*"
156
+ }
157
+ }
158
+ },
82
159
  "scripts": {
83
160
  "dev": "vite",
84
- "build": "vite build",
161
+ "build": "vite build && tsc -p tsconfig.factories.json",
162
+ "build:factories": "tsc -p tsconfig.factories.json",
85
163
  "preview": "vite preview",
86
164
  "test:unit": "vitest",
87
- "build-only": "rm -rf ./dist && vite build",
165
+ "build-only": "rm -rf ./dist && vite build && tsc -p tsconfig.factories.json",
88
166
  "build-watch": "vite build --watch",
89
167
  "clear": "pnpm dlx shx rm -rf dist",
90
168
  "type-check": "vue-tsc --build --force",
@@ -166,8 +244,8 @@
166
244
  }
167
245
  },
168
246
  "dependencies": {
169
- "@antcde/connect-ts": "0.4.18",
170
- "@antcde/vue-utils": "0.2.14",
247
+ "@antcde/connect-ts": "0.4.18-rc.99b70a1",
248
+ "@antcde/vue-utils": "0.2.14-rc.99b70a1",
171
249
  "@arcgis/core": "^4.34.8",
172
250
  "@mdi/font": "^7.4.47",
173
251
  "@tiptap/extension-link": "^3.26.1",