@fastkit/vui 0.7.19 → 0.7.23

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.
@@ -126,6 +126,11 @@ export const VDataTable = defineComponent({
126
126
  default: () => DATA_TABLE_DEFAULTS.orderQuery,
127
127
  },
128
128
 
129
+ /**
130
+ * 検索クエリ名
131
+ */
132
+ searchQuery: [String, Array] as PropType<string | string[]>,
133
+
129
134
  /**
130
135
  * リミット件数クエリ名
131
136
  */
@@ -172,6 +177,10 @@ export const VDataTable = defineComponent({
172
177
  selectable: Boolean,
173
178
  fixedHeader: Boolean,
174
179
  maxHeight: [Number, String],
180
+ // eslint-disable-next-line vue/require-prop-types
181
+ noDataMessage: {} as PropType<VNodeChild | (() => VNodeChild)>,
182
+ // eslint-disable-next-line vue/require-prop-types
183
+ noResultsMessage: {} as PropType<VNodeChild | (() => VNodeChild)>,
175
184
  },
176
185
  emits: {
177
186
  input: (selecteds: string[]) => true,
@@ -196,6 +205,45 @@ export const VDataTable = defineComponent({
196
205
  ret.push(...headers.filter((h) => !h.hidden));
197
206
  return ret;
198
207
  });
208
+
209
+ const searchQueryValues = computed<string[]>(() => {
210
+ let { searchQuery } = props;
211
+ if (!searchQuery) {
212
+ return [];
213
+ }
214
+ if (!Array.isArray(searchQuery)) {
215
+ searchQuery = [searchQuery];
216
+ }
217
+ const values: string[] = [];
218
+ searchQuery.forEach((query) => {
219
+ const value = vui.location.getQuery(query);
220
+ if (value == null || value === '') {
221
+ return;
222
+ }
223
+ if (typeof value === 'object' && !Object.keys(value).length) {
224
+ return;
225
+ }
226
+ values.push(value);
227
+ });
228
+ return values;
229
+ });
230
+
231
+ const emptyMessage = computed(() => {
232
+ let message: VNodeChild | (() => VNodeChild);
233
+ if (searchQueryValues.value.length) {
234
+ message =
235
+ props.noResultsMessage ||
236
+ vui.setting('noResultsMessage') ||
237
+ 'No search results found.'; // 検索結果が見つかりませんでした。
238
+ } else {
239
+ message =
240
+ props.noDataMessage ||
241
+ vui.setting('noDataMessage') ||
242
+ 'No data was available.'; // データはありませんでした。
243
+ }
244
+ return typeof message === 'function' ? message() : message;
245
+ });
246
+
199
247
  const classesRef = computed(() => [
200
248
  {
201
249
  'v-data-table--fixed-header': props.fixedHeader,
@@ -724,7 +772,7 @@ export const VDataTable = defineComponent({
724
772
  <div class="v-data-table__body container-pull">
725
773
  {isEmpty ? (
726
774
  <div class="v-data-table__empty--message">
727
- {/* {this.computedEmptyMessage} */}
775
+ {emptyMessage.value}
728
776
  </div>
729
777
  ) : (
730
778
  <VPaper
@@ -25,6 +25,7 @@ import { VUI_SELECT_SYMBOL, useVui } from '../../injections';
25
25
  import { VIcon } from '../VIcon';
26
26
  import { VMenu } from '../kits';
27
27
  import { VOption } from '../VOption';
28
+ import { VButton } from '..';
28
29
 
29
30
  const { props, emits } = createFormSelectorSettings();
30
31
 
@@ -184,11 +185,24 @@ export const VSelect = defineComponent({
184
185
  </div>
185
186
  </div>,
186
187
  ],
187
- endAdornment: () => (
188
- <VIcon
189
- name={this.iconName}
190
- rotate={this.menuOpened ? 180 : 0}></VIcon>
191
- ),
188
+ endAdornment: () =>
189
+ (this.clearable && this.nodeControl.value != null && (
190
+ <VButton
191
+ key="clear"
192
+ icon={this.$vui.icon('clear')}
193
+ rounded
194
+ onClick={(ev) => {
195
+ ev.stopPropagation();
196
+ this.nodeControl.clear();
197
+ }}
198
+ />
199
+ )) || (
200
+ <VIcon
201
+ key="icon"
202
+ name={this.iconName}
203
+ rotate={this.menuOpened ? 180 : 0}
204
+ />
205
+ ),
192
206
  }}
193
207
  />,
194
208
  ],
package/src/plugin.tsx CHANGED
@@ -1,5 +1,11 @@
1
1
  import { App } from 'vue';
2
- import { VuiService, VuiServiceOptions, VuiInjectionKey } from './service';
2
+ import {
3
+ VuiService,
4
+ VuiServiceOptions,
5
+ RawVuiServiceOptions,
6
+ mergeVuiServiceOptions,
7
+ VuiInjectionKey,
8
+ } from './service';
3
9
  import {
4
10
  installVueStackPlugin,
5
11
  VueStackServiceOptions,
@@ -14,6 +20,25 @@ export interface VuiPluginOptions extends VuiServiceOptions {
14
20
  stack?: VuiPluginStackOptions;
15
21
  }
16
22
 
23
+ export interface RawVuiPluginOptions extends RawVuiServiceOptions {
24
+ stack?: VuiPluginStackOptions;
25
+ }
26
+
27
+ export function mergeVuiPluginOptions(
28
+ base: VuiPluginOptions,
29
+ override?: RawVuiPluginOptions,
30
+ ): VuiPluginOptions {
31
+ if (!override) return base;
32
+ const merged: VuiPluginOptions = mergeVuiServiceOptions(base, override);
33
+ if (override.stack) {
34
+ merged.stack = {
35
+ ...merged.stack,
36
+ ...override.stack,
37
+ };
38
+ }
39
+ return merged;
40
+ }
41
+
17
42
  declare module '@vue/runtime-core' {
18
43
  export interface ComponentCustomProperties {
19
44
  $vui: VuiService;
package/src/service.tsx CHANGED
@@ -50,6 +50,28 @@ export interface VuiServiceUISettings {
50
50
  color?: ScopeName;
51
51
  variant?: ColorVariant;
52
52
  };
53
+ noDataMessage?: VNodeChild | (() => VNodeChild);
54
+ noResultsMessage?: VNodeChild | (() => VNodeChild);
55
+ }
56
+
57
+ export type RawVuiServiceUISettings = Partial<VuiServiceUISettings>;
58
+
59
+ export function mergeVuiServiceUISettings(
60
+ base: VuiServiceUISettings,
61
+ overrides?: RawVuiServiceUISettings,
62
+ ): VuiServiceUISettings {
63
+ if (!overrides) {
64
+ return base;
65
+ }
66
+ const merged: VuiServiceUISettings = {
67
+ ...base,
68
+ };
69
+ Object.entries(overrides).forEach(([key, value]) => {
70
+ if (value) {
71
+ (merged as any)[key] = value;
72
+ }
73
+ });
74
+ return merged;
53
75
  }
54
76
 
55
77
  export interface VuiServiceIconSettings {
@@ -69,6 +91,27 @@ export interface VuiServiceIconSettings {
69
91
  editorUndo: IconName;
70
92
  editorRedo: IconName;
71
93
  hinttip: IconName;
94
+ clear: IconName;
95
+ }
96
+
97
+ export type RawVuiServiceIconSettings = Partial<VuiServiceIconSettings>;
98
+
99
+ export function mergeVuiServiceIconSettings(
100
+ base: VuiServiceIconSettings,
101
+ overrides?: RawVuiServiceIconSettings,
102
+ ): VuiServiceIconSettings {
103
+ if (!overrides) {
104
+ return base;
105
+ }
106
+ const merged: VuiServiceIconSettings = {
107
+ ...base,
108
+ };
109
+ Object.entries(overrides).forEach(([key, value]) => {
110
+ if (value) {
111
+ (merged as any)[key] = value;
112
+ }
113
+ });
114
+ return merged;
72
115
  }
73
116
 
74
117
  export type VuiVNodeResolver = () => VNodeChild;
@@ -85,6 +128,36 @@ export interface VuiServiceOptions {
85
128
  requiredChip?: VuiVNodeResolver;
86
129
  }
87
130
 
131
+ export interface RawVuiServiceOptions
132
+ extends Omit<Partial<VuiServiceOptions>, 'uiSettings' | 'icons'> {
133
+ uiSettings?: RawVuiServiceUISettings;
134
+ icons?: RawVuiServiceIconSettings;
135
+ }
136
+
137
+ export function mergeVuiServiceOptions(
138
+ base: VuiServiceOptions,
139
+ overrides?: RawVuiServiceOptions,
140
+ ): VuiServiceOptions {
141
+ if (!overrides) {
142
+ return base;
143
+ }
144
+ const merged: VuiServiceOptions = {
145
+ ...base,
146
+ uiSettings: mergeVuiServiceUISettings(
147
+ base.uiSettings,
148
+ overrides.uiSettings,
149
+ ),
150
+ icons: mergeVuiServiceIconSettings(base.icons, overrides.icons),
151
+ };
152
+ const excludes = ['uiSettings', 'icons'];
153
+ Object.entries(overrides).forEach(([key, value]) => {
154
+ if (value && !excludes.includes(key)) {
155
+ (merged as any)[key] = value;
156
+ }
157
+ });
158
+ return merged;
159
+ }
160
+
88
161
  export class VuiService {
89
162
  readonly options: VuiServiceOptions;
90
163
 
@@ -30,20 +30,21 @@ import './setup.scss';
30
30
  import type { App } from 'vue';
31
31
  import type { Router } from 'vue-router';
32
32
  import { VPageLink } from '@fastkit/vue-page';
33
- import { installVuiPlugin as _installVuiPlugin, VuiPluginOptions } from '@fastkit/vui';
33
+ import { installVuiPlugin as _installVuiPlugin, RawVuiPluginOptions, mergeVuiPluginOptions } from '@fastkit/vui';
34
34
  import { colorScheme } from '<%~ it.colorScheme %>';
35
35
  import '<%~ it.mediaMatch %>';
36
36
  import './icon-font';
37
37
  import '${STYLE_AFTER_EFFECTS_PATH}';
38
38
 
39
- export function installVui(settings: { app: App, router: Router }) {
40
- _installVuiPlugin(settings.app, {
39
+ export function installVui(settings: { app: App, router: Router }, options?: RawVuiPluginOptions) {
40
+ const merged = mergeVuiPluginOptions({
41
41
  RouterLink: VPageLink,
42
42
  colorScheme,
43
43
  uiSettings: <%~ it.uiSettings %>,
44
44
  icons: <%~ it.icons %>,
45
45
  ...settings,
46
- });
46
+ }, options);
47
+ _installVuiPlugin(settings.app, merged);
47
48
  }
48
49
 
49
50
  export default installVui;
@@ -171,6 +172,7 @@ export function viteVuiPlugin(
171
172
  editorUndo: 'mdi-undo-variant' as any,
172
173
  editorRedo: 'mdi-redo-variant' as any,
173
174
  hinttip: 'mdi-help-circle-outline' as any,
175
+ clear: 'mdi-close' as any,
174
176
  // navigationExpand: (gen, active) => {
175
177
  // return gen({
176
178
  // name: 'mdi-menu-down' as any,