@fastkit/vui 0.12.7 → 0.12.9
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 +1 -1
- package/dist/vui.css +2786 -2716
- package/dist/vui.css.map +1 -0
- package/dist/vui.d.ts +9072 -10160
- package/dist/vui.mjs +2158 -1968
- package/dist/vui.mjs.map +1 -0
- package/package.json +89 -59
- package/src/components/VApp/VApp.tsx +3 -1
- package/src/components/VAvatar/VAvatar.scss +62 -60
- package/src/components/VAvatar/VAvatar.tsx +6 -1
- package/src/components/VBreadcrumbs/VBreadcrumbs.scss +53 -51
- package/src/components/VBusyImage/VBusyImage.scss +50 -51
- package/src/components/VButton/VButton.scss +120 -118
- package/src/components/VButton/VButton.tsx +6 -1
- package/src/components/VButton/VButtonGroup.scss +21 -19
- package/src/components/VCard/VCard.scss +41 -42
- package/src/components/VCard/VCard.tsx +5 -0
- package/src/components/VCard/VCardActions.scss +9 -7
- package/src/components/VCard/VCardContent.scss +4 -2
- package/src/components/VCheckable/VCheckable.scss +79 -80
- package/src/components/VCheckable/VCheckable.tsx +1 -1
- package/src/components/VCheckbox/VCheckbox.scss +50 -48
- package/src/components/VCheckbox/VCheckbox.tsx +2 -2
- package/src/components/VChip/VChip.scss +61 -59
- package/src/components/VChip/VChip.tsx +6 -1
- package/src/components/VContentSwitcher/VContentSwitcher.scss +52 -50
- package/src/components/VControlField/VControlField.scss +148 -146
- package/src/components/VControlField/VControlField.tsx +3 -3
- package/src/components/VDataTable/VDataTable.scss +167 -168
- package/src/components/VDataTable/VDataTable.tsx +39 -8
- package/src/components/VDrawerLayout/VDrawerLayout.scss +27 -25
- package/src/components/VForm/VForm.tsx +3 -4
- package/src/components/VFormControl/VFormControl.scss +84 -82
- package/src/components/VFormControl/VFormControl.tsx +2 -3
- package/src/components/VGrid/VGridContainer.scss +5 -3
- package/src/components/VGrid/VGridItem.scss +4 -2
- package/src/components/VHero/VHero.scss +23 -21
- package/src/components/VIcon/VIcon.scss +19 -17
- package/src/components/VListTile/VListTile.scss +60 -58
- package/src/components/VListTile/VListTile.tsx +5 -0
- package/src/components/VNavigation/VNavigation.scss +12 -10
- package/src/components/VNavigation/VNavigationItem.scss +21 -19
- package/src/components/VNavigation/VNavigationItem.tsx +5 -0
- package/src/components/VOption/VOption.scss +55 -56
- package/src/components/VOption/VOption.tsx +2 -2
- package/src/components/VOptionGroup/VOptionGroup.scss +14 -12
- package/src/components/VOptionGroup/VOptionGroup.tsx +3 -1
- package/src/components/VPagination/VPagination.scss +81 -79
- package/src/components/VPagination/VPagination.tsx +1 -1
- package/src/components/VPaper/VPaper.scss +43 -41
- package/src/components/VRadio/VRadio.scss +52 -53
- package/src/components/VRadio/VRadio.tsx +2 -2
- package/src/components/VSelect/VSelect.scss +77 -75
- package/src/components/VSelect/VSelect.tsx +5 -2
- package/src/components/VSkeltonLoader/VSkeltonLoaderBone.scss +24 -22
- package/src/components/VSwitch/VSwitch.scss +96 -94
- package/src/components/VSwitch/VSwitch.tsx +2 -2
- package/src/components/VTabs/VTab.scss +59 -57
- package/src/components/VTabs/VTabs.scss +41 -39
- package/src/components/VTabs/VTabs.tsx +5 -2
- package/src/components/VTextCounter/VTextCounter.scss +4 -2
- package/src/components/VTextField/VTextField.scss +37 -35
- package/src/components/VTextField/VTextField.tsx +2 -2
- package/src/components/VTextarea/VTextarea.scss +33 -31
- package/src/components/VTextarea/VTextarea.tsx +2 -2
- package/src/components/VToolbar/VToolbar.scss +19 -17
- package/src/components/VToolbar/VToolbarEdge.scss +21 -19
- package/src/components/VToolbar/VToolbarMenu.scss +6 -4
- package/src/components/VToolbar/VToolbarMenu.tsx +5 -0
- package/src/components/VToolbar/VToolbarTitle.scss +19 -17
- package/src/components/VWysiwygEditor/VWysiwygEditor.scss +52 -50
- package/src/components/VWysiwygEditor/VWysiwygEditor.tsx +2 -2
- package/src/components/VWysiwygEditor/extensions/linter/Linter.scss +108 -109
- package/src/components/VWysiwygEditor/schemes.ts +1 -1
- package/src/components/VWysiwygEditor/tools/color.scss +106 -112
- package/src/components/kits.ts +1 -1
- package/src/composables/control.ts +1 -1
- package/src/composables/form-selector.scss +20 -18
- package/src/composables/form-selector.tsx +5 -3
- package/src/index.ts +13 -2
- package/src/plugin.tsx +4 -4
- package/src/schemes/control.ts +2 -2
- package/src/service.tsx +5 -5
- package/src/styles/core/functions.scss +2 -2
- package/src/styles/index.scss +23 -9
- package/dist/tool/index.d.ts +0 -2
- package/dist/tool/index.d.ts.map +0 -1
- package/dist/tool/index.mjs +0 -193
- package/dist/tool/vite-plugin.d.ts +0 -25
- package/dist/tool/vite-plugin.d.ts.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/assets/builtins/color-scheme.ts +0 -9
- package/src/assets/builtins/media-match.ts +0 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/VAvatar/.DS_Store +0 -0
- package/src/components/VChip/.DS_Store +0 -0
- package/src/components/VSkeltonLoader/.DS_Store +0 -0
- package/src/components/VTextField/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/extensions/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/extensions/linter/.DS_Store +0 -0
- package/src/tool/index.ts +0 -2
- package/src/tool/vite-plugin.ts +0 -266
- /package/{src/styles → dist}/after-effects/display-flow.scss +0 -0
- /package/{src/styles → dist}/after-effects/spacing.scss +0 -0
- /package/{src/styles → dist}/after-effects/text.scss +0 -0
- /package/{src/styles → dist}/after-effects.scss +0 -0
- /package/dist/{assets/builtins → builtins}/color-scheme.ts +0 -0
- /package/dist/{assets/builtins → builtins}/media-match.ts +0 -0
package/src/styles/index.scss
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
@
|
|
4
|
-
|
|
5
|
-
@
|
|
6
|
-
@
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
@use 'sass:meta';
|
|
2
|
+
|
|
3
|
+
@layer vui-normalize, vui-color-scheme, vui;
|
|
4
|
+
|
|
5
|
+
@layer vui-normalize {
|
|
6
|
+
@include meta.load-css('@fastkit/stylebase/normalize.css');
|
|
7
|
+
|
|
8
|
+
button {
|
|
9
|
+
background-color: transparent;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@layer vui {
|
|
14
|
+
// @include meta.load-css('@fastkit/stylebase/normalize.css');
|
|
15
|
+
|
|
16
|
+
@include meta.load-css('./variables.scss');
|
|
17
|
+
@include meta.load-css('./base.scss');
|
|
18
|
+
@include meta.load-css('./typo.scss');
|
|
19
|
+
@include meta.load-css('./elevation.scss');
|
|
20
|
+
@include meta.load-css('./group.scss');
|
|
21
|
+
@include meta.load-css('./control.scss');
|
|
22
|
+
@include meta.load-css('./wysiwyg.scss');
|
|
23
|
+
}
|
package/dist/tool/index.d.ts
DELETED
package/dist/tool/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/vui/src/tool/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/dist/tool/index.mjs
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { dynamicSrcVitePlugin } from '@fastkit/vite-kit';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import { getDirname, findPackageDirSync } from '@fastkit/node-util';
|
|
5
|
-
import { render } from 'eta';
|
|
6
|
-
import { TinyLogger, createTinyError } from '@fastkit/tiny-logger';
|
|
7
|
-
|
|
8
|
-
const name = 'vui';
|
|
9
|
-
new TinyLogger(name);
|
|
10
|
-
const VuiError = createTinyError(name);
|
|
11
|
-
|
|
12
|
-
const VUI_PACKAGE_DIR = path.resolve(getDirname(import.meta.url), '../..');
|
|
13
|
-
const STYLE_AFTER_EFFECTS_PATH = path.join(VUI_PACKAGE_DIR, 'src/styles/after-effects.scss');
|
|
14
|
-
const COLOR_DUMP_STYLE = `@include dump-color-scheme(true);`;
|
|
15
|
-
const TEMPLATE = `
|
|
16
|
-
/* eslint-disable */
|
|
17
|
-
// @ts-nocheck
|
|
18
|
-
<% if (!it.__dev) { %>
|
|
19
|
-
import '@fastkit/vue-stack/vue-stack.css';
|
|
20
|
-
import '@fastkit/vue-app-layout/vue-app-layout.css';
|
|
21
|
-
import '@fastkit/vue-loading/vue-loading.css';
|
|
22
|
-
import '@fastkit/vue-scroller/vue-scroller.css';
|
|
23
|
-
import '@fastkit/vui/vui.css';
|
|
24
|
-
<% } %>
|
|
25
|
-
import './setup.scss';
|
|
26
|
-
import type { App } from 'vue';
|
|
27
|
-
import type { Router } from 'vue-router';
|
|
28
|
-
import { VPageLink } from '@fastkit/vue-page';
|
|
29
|
-
import { installVuiPlugin as _installVuiPlugin, RawVuiPluginOptions, mergeVuiPluginOptions } from '@fastkit/vui';
|
|
30
|
-
import { colorScheme } from '<%~ it.colorScheme %>';
|
|
31
|
-
import '<%~ it.mediaMatch %>';
|
|
32
|
-
import './icon-font';
|
|
33
|
-
import '${STYLE_AFTER_EFFECTS_PATH}';
|
|
34
|
-
|
|
35
|
-
export function installVui(settings: { app: App, router: Router }, options?: RawVuiPluginOptions) {
|
|
36
|
-
const merged = mergeVuiPluginOptions({
|
|
37
|
-
RouterLink: VPageLink,
|
|
38
|
-
colorScheme,
|
|
39
|
-
uiSettings: <%~ it.uiSettings %>,
|
|
40
|
-
icons: <%~ it.icons %>,
|
|
41
|
-
...settings,
|
|
42
|
-
}, options);
|
|
43
|
-
_installVuiPlugin(settings.app, merged);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default installVui;
|
|
47
|
-
`.trim();
|
|
48
|
-
async function renderTemplate({ colorScheme, mediaMatch, uiSettings, icons, __dev, }) {
|
|
49
|
-
const result = await render(TEMPLATE, {
|
|
50
|
-
colorScheme,
|
|
51
|
-
mediaMatch,
|
|
52
|
-
uiSettings: JSON.stringify(uiSettings),
|
|
53
|
-
icons: JSON.stringify(icons),
|
|
54
|
-
__dev,
|
|
55
|
-
}, { async: true });
|
|
56
|
-
if (!result) {
|
|
57
|
-
throw new VuiError('template render error.');
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
function defaultDynamicDest() {
|
|
62
|
-
return path.resolve('.vui');
|
|
63
|
-
}
|
|
64
|
-
function getBuiltinsDir() {
|
|
65
|
-
const pkgDir = findPackageDirSync(undefined, true);
|
|
66
|
-
if (!pkgDir) {
|
|
67
|
-
throw new Error(`missing package directory`);
|
|
68
|
-
}
|
|
69
|
-
return path.join(pkgDir, 'node_modules/@fastkit/vui/dist/assets/builtins');
|
|
70
|
-
}
|
|
71
|
-
function viteVuiPlugin(options = {}) {
|
|
72
|
-
const plugins = [];
|
|
73
|
-
const builtinsDir = getBuiltinsDir();
|
|
74
|
-
const { colorScheme = path.join(builtinsDir, 'color-scheme'), mediaMatch = path.join(builtinsDir, 'media-match'), iconFont, iconFontDefaults, onBooted, onBootError, uiSettings = {
|
|
75
|
-
primaryScope: 'primary',
|
|
76
|
-
plainVariant: 'plain',
|
|
77
|
-
containedVariant: 'contained',
|
|
78
|
-
warningScope: 'warning',
|
|
79
|
-
errorScope: 'error',
|
|
80
|
-
buttonDefault: {
|
|
81
|
-
color: 'base',
|
|
82
|
-
variant: 'contained',
|
|
83
|
-
},
|
|
84
|
-
tabDefault: {
|
|
85
|
-
color: 'accent',
|
|
86
|
-
},
|
|
87
|
-
dialogOk: {
|
|
88
|
-
color: 'primary',
|
|
89
|
-
},
|
|
90
|
-
}, icons = {
|
|
91
|
-
menuDown: 'mdi-menu-down',
|
|
92
|
-
navigationExpand: 'mdi-menu-down',
|
|
93
|
-
prev: 'mdi-chevron-left',
|
|
94
|
-
next: 'mdi-chevron-right',
|
|
95
|
-
sort: 'mdi-chevron-down',
|
|
96
|
-
editorTextColor: 'mdi-format-color-text',
|
|
97
|
-
editorformatBold: 'mdi-format-bold',
|
|
98
|
-
editorformatUnderline: 'mdi-format-underline',
|
|
99
|
-
editorformatItalic: 'mdi-format-italic',
|
|
100
|
-
editorformatListBulleted: 'mdi-format-list-bulleted',
|
|
101
|
-
editorformatListNumbered: 'mdi-format-list-numbered',
|
|
102
|
-
editorLink: 'mdi-link',
|
|
103
|
-
editorLinkOff: 'mdi-link-off',
|
|
104
|
-
editorUndo: 'mdi-undo-variant',
|
|
105
|
-
editorRedo: 'mdi-redo-variant',
|
|
106
|
-
hinttip: 'mdi-help-circle-outline',
|
|
107
|
-
clear: 'mdi-close',
|
|
108
|
-
reload: 'mdi-reload',
|
|
109
|
-
// navigationExpand: (gen, active) => {
|
|
110
|
-
// return gen({
|
|
111
|
-
// name: 'mdi-menu-down' as any,
|
|
112
|
-
// rotate: active ? 180 : 0,
|
|
113
|
-
// });
|
|
114
|
-
// },
|
|
115
|
-
...options.icons,
|
|
116
|
-
}, __dev, } = options;
|
|
117
|
-
let dynamicDest;
|
|
118
|
-
const { dynamicDest: _dynamicDest } = options;
|
|
119
|
-
if (!_dynamicDest) {
|
|
120
|
-
dynamicDest = defaultDynamicDest();
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
dynamicDest = _dynamicDest;
|
|
124
|
-
}
|
|
125
|
-
const colorSchemeSrc = path.resolve(colorScheme);
|
|
126
|
-
const colorSchemeDest = path.join(dynamicDest, 'color-scheme');
|
|
127
|
-
const mediaMatchDest = path.join(dynamicDest, 'media-match');
|
|
128
|
-
const dts = `
|
|
129
|
-
/// <reference path="./color-scheme/color-scheme.info.ts" />
|
|
130
|
-
/// <reference path="./icon-font/index.ts" />
|
|
131
|
-
/// <reference path="./media-match/media-match.ts" />
|
|
132
|
-
export {};
|
|
133
|
-
`.trim();
|
|
134
|
-
fs.ensureDirSync(dynamicDest);
|
|
135
|
-
fs.writeFileSync(path.join(dynamicDest, 'setup.scss'), COLOR_DUMP_STYLE);
|
|
136
|
-
fs.writeFileSync(path.join(dynamicDest, 'vui.d.ts'), dts);
|
|
137
|
-
let iconFontEntries = iconFont || [
|
|
138
|
-
{
|
|
139
|
-
src: '@mdi',
|
|
140
|
-
},
|
|
141
|
-
];
|
|
142
|
-
if (iconFontDefaults) {
|
|
143
|
-
iconFontEntries = iconFontEntries.map((entry) => {
|
|
144
|
-
return {
|
|
145
|
-
...iconFontDefaults,
|
|
146
|
-
...entry,
|
|
147
|
-
};
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
plugins.push(dynamicSrcVitePlugin({
|
|
151
|
-
colorScheme: {
|
|
152
|
-
src: colorSchemeSrc,
|
|
153
|
-
dest: colorSchemeDest,
|
|
154
|
-
},
|
|
155
|
-
mediaMatch: {
|
|
156
|
-
src: path.resolve(mediaMatch),
|
|
157
|
-
dest: mediaMatchDest,
|
|
158
|
-
},
|
|
159
|
-
iconFont: {
|
|
160
|
-
entries: iconFontEntries,
|
|
161
|
-
dest: path.join(dynamicDest, 'icon-font'),
|
|
162
|
-
},
|
|
163
|
-
onBooted,
|
|
164
|
-
onBootError,
|
|
165
|
-
}));
|
|
166
|
-
const plugin = {
|
|
167
|
-
name: 'vite:vui',
|
|
168
|
-
enforce: 'pre',
|
|
169
|
-
async config(config) {
|
|
170
|
-
await fs.writeFile(path.join(dynamicDest, 'installer.ts'), await renderTemplate(settings));
|
|
171
|
-
const ssr = config.ssr || {};
|
|
172
|
-
ssr.noExternal = ssr.noExternal || [];
|
|
173
|
-
ssr.noExternal.push(/\/vui\/dist\/assets\//);
|
|
174
|
-
config.ssr = ssr;
|
|
175
|
-
return config;
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
plugins.push(plugin);
|
|
179
|
-
const settings = {
|
|
180
|
-
colorScheme: path.join(colorSchemeDest, 'color-scheme.info'),
|
|
181
|
-
mediaMatch: path.join(mediaMatchDest, 'media-match'),
|
|
182
|
-
uiSettings,
|
|
183
|
-
icons,
|
|
184
|
-
__dev,
|
|
185
|
-
};
|
|
186
|
-
return {
|
|
187
|
-
plugins,
|
|
188
|
-
dest: dynamicDest,
|
|
189
|
-
settings,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export { viteVuiPlugin };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
import { RawIconFontEntry, IconFontSettings } from '@fastkit/icon-font-gen';
|
|
3
|
-
import { VuiServiceOptions } from '../service';
|
|
4
|
-
export interface ViteVuiPluginOptions extends Partial<Pick<VuiServiceOptions, 'uiSettings' | 'icons'>> {
|
|
5
|
-
dynamicDest?: string;
|
|
6
|
-
colorScheme?: string;
|
|
7
|
-
mediaMatch?: string;
|
|
8
|
-
iconFont?: RawIconFontEntry[];
|
|
9
|
-
iconFontDefaults?: IconFontSettings;
|
|
10
|
-
onBooted?: (() => any) | (() => Promise<any>);
|
|
11
|
-
onBootError?: ((err: unknown) => any) | ((err: unknown) => Promise<any>);
|
|
12
|
-
__dev?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface ViteVuiPluginResultSettings extends Pick<VuiServiceOptions, 'uiSettings' | 'icons'> {
|
|
15
|
-
colorScheme: string;
|
|
16
|
-
mediaMatch: string;
|
|
17
|
-
__dev?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface ViteVuiPluginResult {
|
|
20
|
-
settings: ViteVuiPluginResultSettings;
|
|
21
|
-
plugins: (Plugin | Plugin[])[];
|
|
22
|
-
dest: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function viteVuiPlugin(options?: ViteVuiPluginOptions): ViteVuiPluginResult;
|
|
25
|
-
//# sourceMappingURL=vite-plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../../../../../packages/vui/src/tool/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAK9B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAmF/C,MAAM,WAAW,oBACf,SAAQ,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,2BACf,SAAQ,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,OAAO,CAAC;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,aAAa,CAC3B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAqJrB"}
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/components/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/tool/index.ts
DELETED
package/src/tool/vite-plugin.ts
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
import { dynamicSrcVitePlugin } from '@fastkit/vite-kit';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
|
-
import { findPackageDirSync, getDirname } from '@fastkit/node-util';
|
|
6
|
-
import { RawIconFontEntry, IconFontSettings } from '@fastkit/icon-font-gen';
|
|
7
|
-
import { VuiServiceOptions } from '../service';
|
|
8
|
-
import { render } from 'eta';
|
|
9
|
-
import { VuiError } from '../logger';
|
|
10
|
-
|
|
11
|
-
const VUI_PACKAGE_DIR = path.resolve(getDirname(import.meta.url), '../..');
|
|
12
|
-
const STYLE_AFTER_EFFECTS_PATH = path.join(
|
|
13
|
-
VUI_PACKAGE_DIR,
|
|
14
|
-
'src/styles/after-effects.scss',
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const COLOR_DUMP_STYLE = `@include dump-color-scheme(true);`;
|
|
18
|
-
|
|
19
|
-
const TEMPLATE = `
|
|
20
|
-
/* eslint-disable */
|
|
21
|
-
// @ts-nocheck
|
|
22
|
-
<% if (!it.__dev) { %>
|
|
23
|
-
import '@fastkit/vue-stack/vue-stack.css';
|
|
24
|
-
import '@fastkit/vue-app-layout/vue-app-layout.css';
|
|
25
|
-
import '@fastkit/vue-loading/vue-loading.css';
|
|
26
|
-
import '@fastkit/vue-scroller/vue-scroller.css';
|
|
27
|
-
import '@fastkit/vui/vui.css';
|
|
28
|
-
<% } %>
|
|
29
|
-
import './setup.scss';
|
|
30
|
-
import type { App } from 'vue';
|
|
31
|
-
import type { Router } from 'vue-router';
|
|
32
|
-
import { VPageLink } from '@fastkit/vue-page';
|
|
33
|
-
import { installVuiPlugin as _installVuiPlugin, RawVuiPluginOptions, mergeVuiPluginOptions } from '@fastkit/vui';
|
|
34
|
-
import { colorScheme } from '<%~ it.colorScheme %>';
|
|
35
|
-
import '<%~ it.mediaMatch %>';
|
|
36
|
-
import './icon-font';
|
|
37
|
-
import '${STYLE_AFTER_EFFECTS_PATH}';
|
|
38
|
-
|
|
39
|
-
export function installVui(settings: { app: App, router: Router }, options?: RawVuiPluginOptions) {
|
|
40
|
-
const merged = mergeVuiPluginOptions({
|
|
41
|
-
RouterLink: VPageLink,
|
|
42
|
-
colorScheme,
|
|
43
|
-
uiSettings: <%~ it.uiSettings %>,
|
|
44
|
-
icons: <%~ it.icons %>,
|
|
45
|
-
...settings,
|
|
46
|
-
}, options);
|
|
47
|
-
_installVuiPlugin(settings.app, merged);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default installVui;
|
|
51
|
-
`.trim();
|
|
52
|
-
|
|
53
|
-
async function renderTemplate({
|
|
54
|
-
colorScheme,
|
|
55
|
-
mediaMatch,
|
|
56
|
-
uiSettings,
|
|
57
|
-
icons,
|
|
58
|
-
__dev,
|
|
59
|
-
}: ViteVuiPluginResultSettings) {
|
|
60
|
-
const result = await render(
|
|
61
|
-
TEMPLATE,
|
|
62
|
-
{
|
|
63
|
-
colorScheme,
|
|
64
|
-
mediaMatch,
|
|
65
|
-
uiSettings: JSON.stringify(uiSettings),
|
|
66
|
-
icons: JSON.stringify(icons),
|
|
67
|
-
__dev,
|
|
68
|
-
},
|
|
69
|
-
{ async: true },
|
|
70
|
-
);
|
|
71
|
-
if (!result) {
|
|
72
|
-
throw new VuiError('template render error.');
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function defaultDynamicDest() {
|
|
78
|
-
return path.resolve('.vui');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function getBuiltinsDir() {
|
|
82
|
-
const pkgDir = findPackageDirSync(undefined, true);
|
|
83
|
-
if (!pkgDir) {
|
|
84
|
-
throw new Error(`missing package directory`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return path.join(pkgDir, 'node_modules/@fastkit/vui/dist/assets/builtins');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface ViteVuiPluginOptions
|
|
91
|
-
extends Partial<Pick<VuiServiceOptions, 'uiSettings' | 'icons'>> {
|
|
92
|
-
dynamicDest?: string;
|
|
93
|
-
colorScheme?: string;
|
|
94
|
-
mediaMatch?: string;
|
|
95
|
-
iconFont?: RawIconFontEntry[];
|
|
96
|
-
iconFontDefaults?: IconFontSettings;
|
|
97
|
-
onBooted?: (() => any) | (() => Promise<any>);
|
|
98
|
-
onBootError?: ((err: unknown) => any) | ((err: unknown) => Promise<any>);
|
|
99
|
-
__dev?: boolean;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface ViteVuiPluginResultSettings
|
|
103
|
-
extends Pick<VuiServiceOptions, 'uiSettings' | 'icons'> {
|
|
104
|
-
colorScheme: string;
|
|
105
|
-
mediaMatch: string;
|
|
106
|
-
__dev?: boolean;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface ViteVuiPluginResult {
|
|
110
|
-
settings: ViteVuiPluginResultSettings;
|
|
111
|
-
plugins: (Plugin | Plugin[])[];
|
|
112
|
-
dest: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function viteVuiPlugin(
|
|
116
|
-
options: ViteVuiPluginOptions = {},
|
|
117
|
-
): ViteVuiPluginResult {
|
|
118
|
-
const plugins: (Plugin | Plugin[])[] = [];
|
|
119
|
-
|
|
120
|
-
const builtinsDir = getBuiltinsDir();
|
|
121
|
-
const {
|
|
122
|
-
colorScheme = path.join(builtinsDir, 'color-scheme'),
|
|
123
|
-
mediaMatch = path.join(builtinsDir, 'media-match'),
|
|
124
|
-
iconFont,
|
|
125
|
-
iconFontDefaults,
|
|
126
|
-
onBooted,
|
|
127
|
-
onBootError,
|
|
128
|
-
uiSettings = {
|
|
129
|
-
primaryScope: 'primary' as any,
|
|
130
|
-
plainVariant: 'plain' as any,
|
|
131
|
-
containedVariant: 'contained' as any,
|
|
132
|
-
warningScope: 'warning' as any,
|
|
133
|
-
errorScope: 'error' as any,
|
|
134
|
-
buttonDefault: {
|
|
135
|
-
color: 'base' as any,
|
|
136
|
-
variant: 'contained' as any,
|
|
137
|
-
},
|
|
138
|
-
tabDefault: {
|
|
139
|
-
color: 'accent' as any,
|
|
140
|
-
},
|
|
141
|
-
dialogOk: {
|
|
142
|
-
color: 'primary' as any,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
icons = {
|
|
146
|
-
menuDown: 'mdi-menu-down' as any,
|
|
147
|
-
navigationExpand: 'mdi-menu-down' as any,
|
|
148
|
-
prev: 'mdi-chevron-left' as any,
|
|
149
|
-
next: 'mdi-chevron-right' as any,
|
|
150
|
-
sort: 'mdi-chevron-down' as any,
|
|
151
|
-
editorTextColor: 'mdi-format-color-text' as any,
|
|
152
|
-
editorformatBold: 'mdi-format-bold' as any,
|
|
153
|
-
editorformatUnderline: 'mdi-format-underline' as any,
|
|
154
|
-
editorformatItalic: 'mdi-format-italic' as any,
|
|
155
|
-
editorformatListBulleted: 'mdi-format-list-bulleted' as any,
|
|
156
|
-
editorformatListNumbered: 'mdi-format-list-numbered' as any,
|
|
157
|
-
editorLink: 'mdi-link' as any,
|
|
158
|
-
editorLinkOff: 'mdi-link-off' as any,
|
|
159
|
-
editorUndo: 'mdi-undo-variant' as any,
|
|
160
|
-
editorRedo: 'mdi-redo-variant' as any,
|
|
161
|
-
hinttip: 'mdi-help-circle-outline' as any,
|
|
162
|
-
clear: 'mdi-close' as any,
|
|
163
|
-
reload: 'mdi-reload' as any,
|
|
164
|
-
// navigationExpand: (gen, active) => {
|
|
165
|
-
// return gen({
|
|
166
|
-
// name: 'mdi-menu-down' as any,
|
|
167
|
-
// rotate: active ? 180 : 0,
|
|
168
|
-
// });
|
|
169
|
-
// },
|
|
170
|
-
...options.icons,
|
|
171
|
-
} as VuiServiceOptions['icons'],
|
|
172
|
-
__dev,
|
|
173
|
-
} = options;
|
|
174
|
-
|
|
175
|
-
let dynamicDest: string;
|
|
176
|
-
|
|
177
|
-
const { dynamicDest: _dynamicDest } = options;
|
|
178
|
-
|
|
179
|
-
if (!_dynamicDest) {
|
|
180
|
-
dynamicDest = defaultDynamicDest();
|
|
181
|
-
} else {
|
|
182
|
-
dynamicDest = _dynamicDest;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const colorSchemeSrc = path.resolve(colorScheme);
|
|
186
|
-
const colorSchemeDest = path.join(dynamicDest, 'color-scheme');
|
|
187
|
-
const mediaMatchDest = path.join(dynamicDest, 'media-match');
|
|
188
|
-
const dts = `
|
|
189
|
-
/// <reference path="./color-scheme/color-scheme.info.ts" />
|
|
190
|
-
/// <reference path="./icon-font/index.ts" />
|
|
191
|
-
/// <reference path="./media-match/media-match.ts" />
|
|
192
|
-
export {};
|
|
193
|
-
`.trim();
|
|
194
|
-
|
|
195
|
-
fs.ensureDirSync(dynamicDest);
|
|
196
|
-
fs.writeFileSync(path.join(dynamicDest, 'setup.scss'), COLOR_DUMP_STYLE);
|
|
197
|
-
fs.writeFileSync(path.join(dynamicDest, 'vui.d.ts'), dts);
|
|
198
|
-
|
|
199
|
-
let iconFontEntries: RawIconFontEntry[] = iconFont || [
|
|
200
|
-
{
|
|
201
|
-
src: '@mdi',
|
|
202
|
-
},
|
|
203
|
-
];
|
|
204
|
-
|
|
205
|
-
if (iconFontDefaults) {
|
|
206
|
-
iconFontEntries = iconFontEntries.map((entry) => {
|
|
207
|
-
return {
|
|
208
|
-
...iconFontDefaults,
|
|
209
|
-
...entry,
|
|
210
|
-
};
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
plugins.push(
|
|
215
|
-
dynamicSrcVitePlugin({
|
|
216
|
-
colorScheme: {
|
|
217
|
-
src: colorSchemeSrc,
|
|
218
|
-
dest: colorSchemeDest,
|
|
219
|
-
},
|
|
220
|
-
mediaMatch: {
|
|
221
|
-
src: path.resolve(mediaMatch),
|
|
222
|
-
dest: mediaMatchDest,
|
|
223
|
-
},
|
|
224
|
-
iconFont: {
|
|
225
|
-
entries: iconFontEntries,
|
|
226
|
-
dest: path.join(dynamicDest, 'icon-font'),
|
|
227
|
-
},
|
|
228
|
-
onBooted,
|
|
229
|
-
onBootError,
|
|
230
|
-
}),
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
const plugin: Plugin = {
|
|
234
|
-
name: 'vite:vui',
|
|
235
|
-
enforce: 'pre',
|
|
236
|
-
async config(config) {
|
|
237
|
-
await fs.writeFile(
|
|
238
|
-
path.join(dynamicDest, 'installer.ts'),
|
|
239
|
-
await renderTemplate(settings),
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
const ssr = (config as any).ssr || {};
|
|
243
|
-
ssr.noExternal = ssr.noExternal || [];
|
|
244
|
-
ssr.noExternal.push(/\/vui\/dist\/assets\//);
|
|
245
|
-
|
|
246
|
-
(config as any).ssr = ssr;
|
|
247
|
-
return config;
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
plugins.push(plugin);
|
|
252
|
-
|
|
253
|
-
const settings = {
|
|
254
|
-
colorScheme: path.join(colorSchemeDest, 'color-scheme.info'),
|
|
255
|
-
mediaMatch: path.join(mediaMatchDest, 'media-match'),
|
|
256
|
-
uiSettings,
|
|
257
|
-
icons,
|
|
258
|
-
__dev,
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
plugins,
|
|
263
|
-
dest: dynamicDest,
|
|
264
|
-
settings,
|
|
265
|
-
};
|
|
266
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|