@veltra/vite 1.0.11 → 1.0.12

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/index.d.mts CHANGED
@@ -2,6 +2,17 @@ import { ComponentResolver } from "unplugin-vue-components/types";
2
2
 
3
3
  //#region src/resolver.d.ts
4
4
  interface VeltraDesktopUIResolverOptions {
5
+ /**
6
+ * Component style directories to exclude.
7
+ * @example ['button', 'loading']
8
+ */
9
+ exclude?: string[];
10
+ /**
11
+ * Component style directories to include. Empty or omitted means all known
12
+ * desktop components are eligible.
13
+ * @example ['button', 'input', 'dialog']
14
+ */
15
+ include?: string[];
5
16
  /**
6
17
  * Whether to import component styles as side effects.
7
18
  * @default true
package/dist/index.mjs CHANGED
@@ -8,6 +8,7 @@
8
8
  */
9
9
  const SHARED_STYLE_DIR = {
10
10
  "button-group": "button",
11
+ "collapse-item": "collapse",
11
12
  "action-group": "action",
12
13
  "card-header": "card",
13
14
  "card-cover": "card",
@@ -21,6 +22,95 @@ const SHARED_STYLE_DIR = {
21
22
  "tabs-horizontal": "tabs",
22
23
  "tabs-vertical": "tabs"
23
24
  };
25
+ const DESKTOP_COMPONENTS = new Set([
26
+ "UAction",
27
+ "UActionGroup",
28
+ "UAutoComplete",
29
+ "UBadge",
30
+ "UBatchEdit",
31
+ "UBreadcrumb",
32
+ "UButton",
33
+ "UButtonGroup",
34
+ "UCalendar",
35
+ "UCard",
36
+ "UCardAction",
37
+ "UCardContent",
38
+ "UCardCover",
39
+ "UCardHeader",
40
+ "UCascade",
41
+ "UCheckTag",
42
+ "UCheckbox",
43
+ "UCollapse",
44
+ "UCollapseItem",
45
+ "UCheckboxButton",
46
+ "UCheckboxGroup",
47
+ "UCodeEditor",
48
+ "UConditionEditor",
49
+ "UContextMenu",
50
+ "UDatePanel",
51
+ "UDatePicker",
52
+ "UDateRangePicker",
53
+ "UDialog",
54
+ "UDrawer",
55
+ "UDropdown",
56
+ "UEmpty",
57
+ "UExpressionEditor",
58
+ "UFilePicker",
59
+ "UFileViewer",
60
+ "UFloatButton",
61
+ "UForm",
62
+ "UFormItem",
63
+ "UGanttChart",
64
+ "UGrid",
65
+ "UGridInput",
66
+ "UGridItem",
67
+ "UGroupInput",
68
+ "UIcon",
69
+ "UInput",
70
+ "ULayout",
71
+ "UList",
72
+ "UListItem",
73
+ "ULoading",
74
+ "UMenu",
75
+ "UMenuItem",
76
+ "UMenuSub",
77
+ "UMessage",
78
+ "UMessageConfirm",
79
+ "UMultiSelect",
80
+ "UMultiTreeSelect",
81
+ "UNodeRender",
82
+ "UNotification",
83
+ "UNumber",
84
+ "UNumberInput",
85
+ "UNumberRangeInput",
86
+ "UPaginator",
87
+ "UPalette",
88
+ "UPasswordInput",
89
+ "UPopConfirm",
90
+ "UProgress",
91
+ "UProgressNodes",
92
+ "URadio",
93
+ "URadioGroup",
94
+ "URichTextEditor",
95
+ "UScroll",
96
+ "USelect",
97
+ "USlider",
98
+ "USteps",
99
+ "USwitch",
100
+ "UTable",
101
+ "UTableEditor",
102
+ "UTabs",
103
+ "UTabsHorizontal",
104
+ "UTabsVertical",
105
+ "UTag",
106
+ "UText",
107
+ "UTextarea",
108
+ "UTheme",
109
+ "UTip",
110
+ "UTree",
111
+ "UTreeSelect",
112
+ "UWatermark"
113
+ ]);
24
114
  function pascalToKebab(str) {
25
115
  return str.replace(/[A-Z]/g, (char, index) => (index > 0 ? "-" : "") + char.toLowerCase());
26
116
  }
@@ -35,13 +125,17 @@ function pascalToKebab(str) {
35
125
  * (pre-compiled, CSS already injected)
36
126
  */
37
127
  function VeltraDesktopUIResolver(options = {}) {
38
- const { importStyle = true } = options;
128
+ const { exclude = [], importStyle = true, include = [] } = options;
129
+ const excluded = new Set(exclude);
130
+ const included = new Set(include);
39
131
  return {
40
132
  type: "component",
41
133
  resolve(name) {
42
- if (!/^U[A-Z]/.test(name)) return;
134
+ if (!DESKTOP_COMPONENTS.has(name)) return;
43
135
  const kebabName = pascalToKebab(name.slice(1));
44
136
  const styleDir = SHARED_STYLE_DIR[kebabName] ?? kebabName;
137
+ if (excluded.has(styleDir)) return;
138
+ if (included.size > 0 && !included.has(styleDir)) return;
45
139
  return {
46
140
  name,
47
141
  from: "@veltra/desktop",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/vite",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Vite helpers for Veltra UI (e.g. unplugin-vue-components resolver for @veltra/desktop)",
5
5
  "files": [
6
6
  "dist",
@@ -18,10 +18,10 @@
18
18
  "check-types": "tsc -p tsconfig.json --noEmit"
19
19
  },
20
20
  "devDependencies": {
21
- "@veltra/desktop": "workspace:*"
21
+ "@veltra/desktop": "1.0.12"
22
22
  },
23
23
  "peerDependencies": {
24
- "@veltra/desktop": "1.0.11",
24
+ "@veltra/desktop": "1.0.12",
25
25
  "unplugin-vue-components": ">=32.0.0"
26
26
  }
27
27
  }
package/src/resolver.ts CHANGED
@@ -1,6 +1,17 @@
1
1
  import type { ComponentResolver } from 'unplugin-vue-components/types'
2
2
 
3
3
  export interface VeltraDesktopUIResolverOptions {
4
+ /**
5
+ * Component style directories to exclude.
6
+ * @example ['button', 'loading']
7
+ */
8
+ exclude?: string[]
9
+ /**
10
+ * Component style directories to include. Empty or omitted means all known
11
+ * desktop components are eligible.
12
+ * @example ['button', 'input', 'dialog']
13
+ */
14
+ include?: string[]
4
15
  /**
5
16
  * Whether to import component styles as side effects.
6
17
  * @default true
@@ -17,6 +28,7 @@ export interface VeltraDesktopUIResolverOptions {
17
28
  */
18
29
  const SHARED_STYLE_DIR: Record<string, string> = {
19
30
  'button-group': 'button',
31
+ 'collapse-item': 'collapse',
20
32
  'action-group': 'action',
21
33
  'card-header': 'card',
22
34
  'card-cover': 'card',
@@ -31,6 +43,96 @@ const SHARED_STYLE_DIR: Record<string, string> = {
31
43
  'tabs-vertical': 'tabs'
32
44
  }
33
45
 
46
+ const DESKTOP_COMPONENTS = new Set([
47
+ 'UAction',
48
+ 'UActionGroup',
49
+ 'UAutoComplete',
50
+ 'UBadge',
51
+ 'UBatchEdit',
52
+ 'UBreadcrumb',
53
+ 'UButton',
54
+ 'UButtonGroup',
55
+ 'UCalendar',
56
+ 'UCard',
57
+ 'UCardAction',
58
+ 'UCardContent',
59
+ 'UCardCover',
60
+ 'UCardHeader',
61
+ 'UCascade',
62
+ 'UCheckTag',
63
+ 'UCheckbox',
64
+ 'UCollapse',
65
+ 'UCollapseItem',
66
+ 'UCheckboxButton',
67
+ 'UCheckboxGroup',
68
+ 'UCodeEditor',
69
+ 'UConditionEditor',
70
+ 'UContextMenu',
71
+ 'UDatePanel',
72
+ 'UDatePicker',
73
+ 'UDateRangePicker',
74
+ 'UDialog',
75
+ 'UDrawer',
76
+ 'UDropdown',
77
+ 'UEmpty',
78
+ 'UExpressionEditor',
79
+ 'UFilePicker',
80
+ 'UFileViewer',
81
+ 'UFloatButton',
82
+ 'UForm',
83
+ 'UFormItem',
84
+ 'UGanttChart',
85
+ 'UGrid',
86
+ 'UGridInput',
87
+ 'UGridItem',
88
+ 'UGroupInput',
89
+ 'UIcon',
90
+ 'UInput',
91
+ 'ULayout',
92
+ 'UList',
93
+ 'UListItem',
94
+ 'ULoading',
95
+ 'UMenu',
96
+ 'UMenuItem',
97
+ 'UMenuSub',
98
+ 'UMessage',
99
+ 'UMessageConfirm',
100
+ 'UMultiSelect',
101
+ 'UMultiTreeSelect',
102
+ 'UNodeRender',
103
+ 'UNotification',
104
+ 'UNumber',
105
+ 'UNumberInput',
106
+ 'UNumberRangeInput',
107
+ 'UPaginator',
108
+ 'UPalette',
109
+ 'UPasswordInput',
110
+ 'UPopConfirm',
111
+ 'UProgress',
112
+ 'UProgressNodes',
113
+ 'URadio',
114
+ 'URadioGroup',
115
+ 'URichTextEditor',
116
+ 'UScroll',
117
+ 'USelect',
118
+ 'USlider',
119
+ 'USteps',
120
+ 'USwitch',
121
+ 'UTable',
122
+ 'UTableEditor',
123
+ 'UTabs',
124
+ 'UTabsHorizontal',
125
+ 'UTabsVertical',
126
+ 'UTag',
127
+ 'UText',
128
+ 'UTextarea',
129
+ 'UTheme',
130
+ 'UTip',
131
+ 'UTree',
132
+ 'UTreeSelect',
133
+ 'UWatermark'
134
+ ])
135
+
34
136
  function pascalToKebab(str: string): string {
35
137
  return str.replace(/[A-Z]/g, (char, index) => (index > 0 ? '-' : '') + char.toLowerCase())
36
138
  }
@@ -48,15 +150,19 @@ function pascalToKebab(str: string): string {
48
150
  export function VeltraDesktopUIResolver(
49
151
  options: VeltraDesktopUIResolverOptions = {}
50
152
  ): ComponentResolver {
51
- const { importStyle = true } = options
153
+ const { exclude = [], importStyle = true, include = [] } = options
154
+ const excluded = new Set(exclude)
155
+ const included = new Set(include)
52
156
 
53
157
  return {
54
158
  type: 'component',
55
159
  resolve(name: string) {
56
- if (!/^U[A-Z]/.test(name)) return
160
+ if (!DESKTOP_COMPONENTS.has(name)) return
57
161
 
58
162
  const kebabName = pascalToKebab(name.slice(1))
59
163
  const styleDir = SHARED_STYLE_DIR[kebabName] ?? kebabName
164
+ if (excluded.has(styleDir)) return
165
+ if (included.size > 0 && !included.has(styleDir)) return
60
166
 
61
167
  return {
62
168
  name,