@hardimpactdev/craft-ui 0.0.6 → 0.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/dist/craft-ui.css +1 -1
- package/dist/craft-ui.js +11928 -10977
- package/dist/index.d.ts +5 -1
- package/dist/src/components/InputError.vue.d.ts +5 -0
- package/dist/src/components/TextLink.vue.d.ts +27 -0
- package/dist/src/components/native-select/NativeSelectOptGroup.vue.d.ts +4 -4
- package/dist/src/components/native-select/NativeSelectOption.vue.d.ts +4 -4
- package/dist/src/layouts/auth/AuthCardLayout.vue.d.ts +28 -0
- package/dist/src/layouts/auth/AuthLayout.vue.d.ts +27 -0
- package/dist/src/layouts/auth/AuthSimpleLayout.vue.d.ts +2 -1
- package/dist/src/layouts/auth/AuthSplitLayout.vue.d.ts +29 -0
- package/dist/src/pages/auth/ConfirmPassword.vue.d.ts +38 -0
- package/dist/src/pages/auth/ForgotPassword.vue.d.ts +47 -0
- package/dist/src/pages/auth/Login.vue.d.ts +59 -0
- package/dist/src/pages/auth/Register.vue.d.ts +51 -0
- package/dist/src/pages/auth/ResetPassword.vue.d.ts +47 -0
- package/dist/src/pages/auth/TwoFactorChallenge.vue.d.ts +44 -0
- package/dist/src/pages/auth/VerifyEmail.vue.d.ts +37 -0
- package/dist/src/pages/auth/index.d.ts +8 -0
- package/dist/src/pages/auth/types.d.ts +54 -0
- package/dist/src/vite/aliases.d.ts +13 -0
- package/dist/src/vite/defineCraftConfig.d.ts +6 -21
- package/dist/src/vite/plugins.d.ts +17 -0
- package/dist/src/vite/server.d.ts +10 -0
- package/dist/src/vite/types.d.ts +64 -0
- package/dist/vite/aliases.js +62 -0
- package/dist/vite/defineCraftConfig.js +18 -161
- package/dist/vite/plugins.js +59 -0
- package/dist/vite/server.js +30 -0
- package/dist/vite/ts/aliases.ts +132 -0
- package/dist/vite/ts/defineCraftConfig.ts +23 -212
- package/dist/vite/ts/plugins.ts +86 -0
- package/dist/vite/ts/server.ts +42 -0
- package/dist/vite/ts/types.ts +73 -0
- package/dist/vite/types.js +0 -0
- package/package.json +1 -1
|
@@ -1,213 +1,24 @@
|
|
|
1
|
-
import { defineConfig
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return defineConfig(({ mode }) => {
|
|
25
|
-
const serverConfig = getServerConfig(mode);
|
|
26
|
-
return {
|
|
27
|
-
plugins: [
|
|
28
|
-
...pluginConfig(options),
|
|
29
|
-
...(options.plugins || []),
|
|
30
|
-
// Plugin to enforce allowedHosts after laravel-vite-plugin
|
|
31
|
-
// This bypasses Vite's DNS rebinding protection which conflicts with reverse proxy setups
|
|
32
|
-
{
|
|
33
|
-
name: 'craft-allowed-hosts',
|
|
34
|
-
enforce: 'post' as const,
|
|
35
|
-
config() {
|
|
36
|
-
return {
|
|
37
|
-
server: {
|
|
38
|
-
allowedHosts: true as const,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
resolve: {
|
|
45
|
-
...aliasConfig(options.aliases, options.ui),
|
|
46
|
-
},
|
|
47
|
-
server: serverConfig,
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getServerConfig(mode: string) {
|
|
53
|
-
// Only load VITE_* prefixed env vars (Vite's default secure behavior)
|
|
54
|
-
const env = loadEnv(mode, process.cwd());
|
|
55
|
-
const appUrl = env.VITE_APP_URL;
|
|
56
|
-
|
|
57
|
-
if (!appUrl) {
|
|
58
|
-
return { host: '0.0.0.0' };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const url = new URL(appUrl);
|
|
63
|
-
const isHttps = url.protocol === 'https:';
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
host: '0.0.0.0',
|
|
67
|
-
origin: appUrl,
|
|
68
|
-
allowedHosts: true as const,
|
|
69
|
-
hmr: {
|
|
70
|
-
host: url.hostname,
|
|
71
|
-
protocol: isHttps ? 'wss' : 'ws',
|
|
72
|
-
clientPort: isHttps ? 443 : (parseInt(url.port) || 80),
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
} catch {
|
|
76
|
-
return { host: '0.0.0.0' };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function pluginConfig(options: viteConfigOptions) {
|
|
81
|
-
return [
|
|
82
|
-
craft(),
|
|
83
|
-
laravel({
|
|
84
|
-
input: options.laravel?.input || ['resources/js/app.ts'],
|
|
85
|
-
refresh: options.laravel?.refresh || true,
|
|
86
|
-
}),
|
|
87
|
-
tailwindcss(),
|
|
88
|
-
i18n(),
|
|
89
|
-
vue({
|
|
90
|
-
template: {
|
|
91
|
-
transformAssetUrls: {
|
|
92
|
-
base: null,
|
|
93
|
-
includeAbsolute: false,
|
|
94
|
-
},
|
|
95
|
-
compilerOptions: {
|
|
96
|
-
isCustomElement: (tag) => tag === 'trix-editor',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
}),
|
|
100
|
-
runConfiguration(),
|
|
101
|
-
vueDevTools({
|
|
102
|
-
appendTo: 'virtual:craft',
|
|
103
|
-
launchEditor: import.meta.env?.VITE_EDITOR || 'cursor',
|
|
104
|
-
}),
|
|
105
|
-
].filter(Boolean);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function runConfiguration() {
|
|
109
|
-
if (process.env.NODE_ENV !== 'development') {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return run([
|
|
114
|
-
{
|
|
115
|
-
name: 'waymaker',
|
|
116
|
-
run: ['php', 'artisan', 'waymaker:generate'],
|
|
117
|
-
pattern: ['app/**/Http/**/*.php'],
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: 'wayfinder',
|
|
121
|
-
run: ['php', 'artisan', 'wayfinder:generate'],
|
|
122
|
-
pattern: ['routes/*.php', 'app/**/Http/**/*.php'],
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'typescript',
|
|
126
|
-
run: ['php', 'artisan', 'typescript:transform'],
|
|
127
|
-
pattern: ['app/{Data,Enums}/**/*.php'],
|
|
128
|
-
},
|
|
129
|
-
]);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
interface LocalAlias {
|
|
133
|
-
regex: RegExp;
|
|
134
|
-
replacement: string;
|
|
135
|
-
libraryPath?: string;
|
|
136
|
-
aliasLocalBasePath?: string;
|
|
137
|
-
aliasExternalBasePath?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function aliasConfig(aliases: any[] = [], ui: any = {}) {
|
|
141
|
-
if (!process.argv.includes('build') && ui.localPath) {
|
|
142
|
-
|
|
143
|
-
const absoluteLibraryPath = path.resolve(process.cwd(), ui.localPath);
|
|
144
|
-
|
|
145
|
-
const localAliases = [
|
|
146
|
-
// The following alias will make the @ alias work correctly depending on the importer path.
|
|
147
|
-
{
|
|
148
|
-
regex: /^@\//,
|
|
149
|
-
replacement: "@/",
|
|
150
|
-
libraryPath: absoluteLibraryPath,
|
|
151
|
-
aliasLocalBasePath: "./resources/js",
|
|
152
|
-
aliasExternalBasePath: path.join(ui.localPath, "src"),
|
|
153
|
-
},
|
|
154
|
-
// The following alias config will change all package references like import { Dialog } from '@hardimpactdev/craft-ui';
|
|
155
|
-
// to the library's index.ts file instead.
|
|
156
|
-
{
|
|
157
|
-
regex: /^@hardimpactdev\/craft-ui/,
|
|
158
|
-
replacement: path.join(ui.localPath, "index.ts"),
|
|
159
|
-
},
|
|
160
|
-
];
|
|
161
|
-
|
|
162
|
-
aliases.push(...aliasLocalPackage(localAliases as LocalAlias[]));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
dedupe: ['@inertiajs/vue3', '@tailwindcss/vite'],
|
|
167
|
-
alias: aliases,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface CustomResolverContext {
|
|
172
|
-
resolve: (id: string, importer?: string) => Promise<{ id: string } | null>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function aliasLocalPackage(aliases: Array<LocalAlias>) {
|
|
176
|
-
|
|
177
|
-
return aliases.map((alias) => {
|
|
178
|
-
|
|
179
|
-
// if the alias has no external path, folder name, or local path, use the replacement as the path
|
|
180
|
-
// For example library references like import { Dialog } from '@hardimpactdev/craft-ui'; will be resolved to the library's index.ts file instead.
|
|
181
|
-
// This will make HMR work correctly. Allowing to update the library and see the changes in the target project without hard page reloads.
|
|
182
|
-
if (!alias.libraryPath && !alias.aliasLocalBasePath && !alias.aliasExternalBasePath) {
|
|
183
|
-
return {
|
|
184
|
-
find: alias.regex,
|
|
185
|
-
replacement: path.resolve(process.cwd(), alias.replacement),
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// When using an alias both in a library and the target project, we need to resolve the alias correctly based on the importer path.
|
|
190
|
-
// This allows for example to use the @ alias both in the library and the target project.
|
|
191
|
-
return {
|
|
192
|
-
find: alias.regex,
|
|
193
|
-
replacement: alias.replacement,
|
|
194
|
-
async customResolver(this: CustomResolverContext, source: any, importer: any) {
|
|
195
|
-
let resolvedPath = '';
|
|
196
|
-
|
|
197
|
-
resolvedPath = path.resolve(
|
|
198
|
-
// get the directory name of the importer
|
|
199
|
-
process.cwd(),
|
|
200
|
-
|
|
201
|
-
// if the importer string includes the folder name, use the external path, otherwise use the local path
|
|
202
|
-
importer?.includes(alias.libraryPath) ? alias.aliasExternalBasePath! : alias.aliasLocalBasePath!,
|
|
203
|
-
|
|
204
|
-
// remove the alias replacement from the source path
|
|
205
|
-
source.replace(alias.replacement, ''),
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
// use Vite's (in fact, rollup's) resolution function
|
|
209
|
-
return (await this.resolve(resolvedPath))?.id;
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
});
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { getPlugins } from './plugins.js';
|
|
3
|
+
import { getServerConfig } from './server.js';
|
|
4
|
+
import { getResolveConfig } from './aliases.js';
|
|
5
|
+
import type { CraftConfigOptions } from './types.js';
|
|
6
|
+
|
|
7
|
+
// Re-export types for consumers
|
|
8
|
+
export type { CraftConfigOptions } from './types.js';
|
|
9
|
+
|
|
10
|
+
// Re-export individual modules for advanced customization
|
|
11
|
+
export { getPlugins } from './plugins.js';
|
|
12
|
+
export { getServerConfig } from './server.js';
|
|
13
|
+
export { getResolveConfig } from './aliases.js';
|
|
14
|
+
|
|
15
|
+
export function defineCraftConfig(options: CraftConfigOptions = {}) {
|
|
16
|
+
return defineConfig(({ mode }) => ({
|
|
17
|
+
plugins: [
|
|
18
|
+
...getPlugins(options),
|
|
19
|
+
...(options.plugins || []),
|
|
20
|
+
],
|
|
21
|
+
resolve: getResolveConfig(options),
|
|
22
|
+
server: getServerConfig(mode),
|
|
23
|
+
}));
|
|
213
24
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import laravel from 'laravel-vite-plugin';
|
|
3
|
+
import { run } from 'vite-plugin-run';
|
|
4
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
5
|
+
import i18n from 'laravel-vue-i18n/vite';
|
|
6
|
+
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
7
|
+
import { craft } from './craftPlugin.js';
|
|
8
|
+
import type { CraftConfigOptions } from './types.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Configure all Vite plugins for the Craft stack
|
|
12
|
+
*
|
|
13
|
+
* Includes:
|
|
14
|
+
* - craft: Virtual module for Inertia app initialization
|
|
15
|
+
* - laravel: Laravel Vite integration
|
|
16
|
+
* - tailwindcss: Tailwind CSS v4
|
|
17
|
+
* - i18n: Laravel Vue i18n
|
|
18
|
+
* - vue: Vue 3 SFC support
|
|
19
|
+
* - vueDevTools: Vue DevTools integration
|
|
20
|
+
* - run: Auto-run artisan commands on file changes (dev only)
|
|
21
|
+
*/
|
|
22
|
+
export function getPlugins(options: CraftConfigOptions) {
|
|
23
|
+
return [
|
|
24
|
+
craft(),
|
|
25
|
+
|
|
26
|
+
laravel({
|
|
27
|
+
input: options.laravel?.input || ['resources/js/app.ts'],
|
|
28
|
+
refresh: options.laravel?.refresh ?? true,
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
tailwindcss(),
|
|
32
|
+
|
|
33
|
+
i18n(),
|
|
34
|
+
|
|
35
|
+
vue({
|
|
36
|
+
template: {
|
|
37
|
+
transformAssetUrls: {
|
|
38
|
+
base: null,
|
|
39
|
+
includeAbsolute: false,
|
|
40
|
+
},
|
|
41
|
+
compilerOptions: {
|
|
42
|
+
isCustomElement: (tag) => tag === 'trix-editor',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
|
|
47
|
+
getArtisanRunners(),
|
|
48
|
+
|
|
49
|
+
vueDevTools({
|
|
50
|
+
appendTo: 'virtual:craft',
|
|
51
|
+
launchEditor: import.meta.env?.VITE_EDITOR || 'cursor',
|
|
52
|
+
}),
|
|
53
|
+
].filter(Boolean);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Configure artisan command runners for development
|
|
58
|
+
*
|
|
59
|
+
* Auto-runs:
|
|
60
|
+
* - waymaker:generate on controller changes
|
|
61
|
+
* - wayfinder:generate on route/controller changes
|
|
62
|
+
* - typescript:transform on DTO/Enum changes
|
|
63
|
+
*/
|
|
64
|
+
function getArtisanRunners() {
|
|
65
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return run([
|
|
70
|
+
{
|
|
71
|
+
name: 'waymaker',
|
|
72
|
+
run: ['php', 'artisan', 'waymaker:generate'],
|
|
73
|
+
pattern: ['app/**/Http/**/*.php'],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'wayfinder',
|
|
77
|
+
run: ['php', 'artisan', 'wayfinder:generate'],
|
|
78
|
+
pattern: ['routes/*.php', 'app/**/Http/**/*.php'],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'typescript',
|
|
82
|
+
run: ['php', 'artisan', 'typescript:transform'],
|
|
83
|
+
pattern: ['app/{Data,Enums}/**/*.php'],
|
|
84
|
+
},
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { loadEnv } from 'vite';
|
|
2
|
+
import type { ServerOptions } from 'vite';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configure Vite dev server for Laravel apps behind a reverse proxy (Caddy/nginx)
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - HMR WebSocket connection through the proxy (wss://app.test:443)
|
|
9
|
+
* - Correct origin for CORS and asset URLs
|
|
10
|
+
* - Binding to all interfaces for proxy access
|
|
11
|
+
*/
|
|
12
|
+
export function getServerConfig(mode: string): ServerOptions {
|
|
13
|
+
const env = loadEnv(mode, process.cwd());
|
|
14
|
+
const appUrl = env.VITE_APP_URL;
|
|
15
|
+
|
|
16
|
+
if (!appUrl) {
|
|
17
|
+
return { host: '0.0.0.0' };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(appUrl);
|
|
22
|
+
const isHttps = url.protocol === 'https:';
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
// Accept connections from reverse proxy
|
|
26
|
+
host: '0.0.0.0',
|
|
27
|
+
|
|
28
|
+
// Tell Vite the public origin for asset URLs
|
|
29
|
+
origin: appUrl,
|
|
30
|
+
|
|
31
|
+
// Configure HMR to connect through the reverse proxy
|
|
32
|
+
// Without this, browser would try localhost:5173 directly
|
|
33
|
+
hmr: {
|
|
34
|
+
host: url.hostname,
|
|
35
|
+
protocol: isHttps ? 'wss' : 'ws',
|
|
36
|
+
clientPort: isHttps ? 443 : (parseInt(url.port) || 80),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
} catch {
|
|
40
|
+
return { host: '0.0.0.0' };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Alias } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for defineCraftConfig
|
|
5
|
+
*/
|
|
6
|
+
export interface CraftConfigOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Laravel Vite plugin options
|
|
9
|
+
*/
|
|
10
|
+
laravel?: {
|
|
11
|
+
/** Entry points for the application */
|
|
12
|
+
input?: string[];
|
|
13
|
+
/** Enable file refresh on changes */
|
|
14
|
+
refresh?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Additional Vite plugins to include
|
|
19
|
+
*/
|
|
20
|
+
plugins?: any[];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Additional Vite aliases
|
|
24
|
+
*/
|
|
25
|
+
aliases?: Alias[];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Local UI library configuration for development with symlinked packages
|
|
29
|
+
*/
|
|
30
|
+
ui?: LocalUiOptions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for local UI library development
|
|
35
|
+
*
|
|
36
|
+
* When developing craft-ui alongside an app, this enables HMR by:
|
|
37
|
+
* 1. Redirecting package imports to source files instead of dist/
|
|
38
|
+
* 2. Resolving conflicting aliases (like @/) based on importer location
|
|
39
|
+
*/
|
|
40
|
+
export interface LocalUiOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Relative path from app root to the symlinked craft-ui directory
|
|
43
|
+
* @example '../craft-ui'
|
|
44
|
+
*/
|
|
45
|
+
localPath?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Internal alias configuration for local package resolution
|
|
50
|
+
*/
|
|
51
|
+
export interface LocalAliasConfig {
|
|
52
|
+
/** Regex pattern to match imports */
|
|
53
|
+
pattern: RegExp;
|
|
54
|
+
|
|
55
|
+
/** The replacement path or alias */
|
|
56
|
+
replacement: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Absolute path to the library (for importer detection)
|
|
60
|
+
* If set along with basePaths, enables context-aware resolution
|
|
61
|
+
*/
|
|
62
|
+
libraryPath?: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Base paths for context-aware resolution
|
|
66
|
+
*/
|
|
67
|
+
basePaths?: {
|
|
68
|
+
/** Path to use when import is from the app */
|
|
69
|
+
app: string;
|
|
70
|
+
/** Path to use when import is from the library */
|
|
71
|
+
library: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
File without changes
|