@fastkit/vui 0.18.31 → 0.18.32

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.
Files changed (50) hide show
  1. package/dist/vui.d.ts +214 -214
  2. package/dist/vui.mjs +400 -482
  3. package/dist/vui.mjs.map +1 -1
  4. package/package.json +25 -25
  5. package/src/components/VApp/VApp.tsx +5 -7
  6. package/src/components/VAvatar/VAvatar.tsx +1 -0
  7. package/src/components/VBreadcrumbs/VBreadcrumbs.tsx +8 -7
  8. package/src/components/VButton/VButton.tsx +27 -28
  9. package/src/components/VButton/VButtonGroup.tsx +2 -2
  10. package/src/components/VCard/VCard.tsx +2 -13
  11. package/src/components/VCard/VCardActions.tsx +1 -3
  12. package/src/components/VCard/VCardContent.tsx +1 -3
  13. package/src/components/VCheckable/VCheckable.tsx +12 -14
  14. package/src/components/VCheckbox/VCheckbox.tsx +11 -12
  15. package/src/components/VChip/VChip.tsx +1 -0
  16. package/src/components/VContentSwitcher/VContentSwitcher.tsx +5 -7
  17. package/src/components/VControlField/VControlField.tsx +19 -20
  18. package/src/components/VDataTable/VDataTable.tsx +20 -23
  19. package/src/components/VDialog/VDialog.tsx +1 -2
  20. package/src/components/VForm/VForm.tsx +12 -13
  21. package/src/components/VFormControl/VFormControl.tsx +7 -2
  22. package/src/components/VFormGroup/VFormGroup.tsx +1 -0
  23. package/src/components/VGrid/schemes.ts +7 -5
  24. package/src/components/VListTile/VListTile.tsx +3 -1
  25. package/src/components/VMenu/VMenu.tsx +5 -7
  26. package/src/components/VNavigation/VNavigation.tsx +5 -3
  27. package/src/components/VNavigation/VNavigationItem.tsx +13 -66
  28. package/src/components/VNumberField/VNumberField.tsx +13 -14
  29. package/src/components/VOption/VOption.tsx +20 -23
  30. package/src/components/VOptionGroup/VOptionGroup.tsx +9 -11
  31. package/src/components/VPagination/VPagination.tsx +21 -20
  32. package/src/components/VPaper/VPaper.tsx +1 -1
  33. package/src/components/VRadio/VRadio.tsx +11 -12
  34. package/src/components/VSelect/VSelect.tsx +85 -95
  35. package/src/components/VSheetModal/VSheetModal.tsx +20 -36
  36. package/src/components/VSnackbar/VSnackbar.tsx +2 -4
  37. package/src/components/VSwitch/VSwitch.tsx +11 -12
  38. package/src/components/VTabs/VTab.tsx +13 -20
  39. package/src/components/VTabs/VTabs.tsx +12 -15
  40. package/src/components/VTextField/VTextField.tsx +34 -37
  41. package/src/components/VTextarea/VTextarea.tsx +36 -43
  42. package/src/components/VToolbar/VToolbar.tsx +11 -15
  43. package/src/components/VToolbar/VToolbarMenu.tsx +1 -0
  44. package/src/components/VTooltip/VTooltip.tsx +3 -7
  45. package/src/composables/control.ts +9 -16
  46. package/src/composables/form-selector.tsx +61 -67
  47. package/src/composables/vui.ts +2 -1
  48. package/src/injections.ts +5 -5
  49. package/src/plugin.tsx +8 -7
  50. package/src/service.tsx +42 -32
@@ -37,6 +37,7 @@ export const VTextarea = defineComponent({
37
37
  ...slots(),
38
38
  },
39
39
  emits,
40
+ // eslint-disable-next-line no-shadow
40
41
  setup(props, ctx) {
41
42
  const vui = useVui();
42
43
  const inputControl = useTextareaNodeControl(props, ctx, {
@@ -50,27 +51,22 @@ export const VTextarea = defineComponent({
50
51
  control: inputControl,
51
52
  });
52
53
 
53
- const defaultSlot = () => {
54
- return (
55
- <VControlField
56
- class="v-textarea__input"
57
- size={control.size.value}
58
- autoHeight
59
- startAdornment={props.startAdornment}
60
- endAdornment={props.endAdornment}
61
- // onClickHost={(ev) => {
62
- // this.focus();
63
- // }}
64
- v-slots={{
65
- ...ctx.slots,
66
- default: () =>
67
- inputControl.createInputElement({
68
- class: 'v-textarea__input__element',
69
- }),
70
- }}
71
- />
72
- );
73
- };
54
+ const defaultSlot = () => (
55
+ <VControlField
56
+ class="v-textarea__input"
57
+ size={control.size.value}
58
+ autoHeight
59
+ startAdornment={props.startAdornment}
60
+ endAdornment={props.endAdornment}
61
+ v-slots={{
62
+ ...ctx.slots,
63
+ default: () =>
64
+ inputControl.createInputElement({
65
+ class: 'v-textarea__input__element',
66
+ }),
67
+ }}
68
+ />
69
+ );
74
70
 
75
71
  const infoAppendsSlot = () => {
76
72
  const { counterResult } = inputControl;
@@ -78,27 +74,24 @@ export const VTextarea = defineComponent({
78
74
  return <VTextCounter {...counterResult} />;
79
75
  };
80
76
 
81
- return () => {
82
- return (
83
- <VFormControl
84
- nodeControl={inputControl}
85
- // focused={inputControl.focused}
86
- class={['v-textarea', control.classes.value]}
87
- label={props.label}
88
- hint={props.hint}
89
- hinttip={props.hinttip}
90
- hiddenInfo={props.hiddenInfo}
91
- requiredChip={props.requiredChip}
92
- onClickLabel={(ev) => {
93
- inputControl.focus();
94
- }}
95
- v-slots={{
96
- ...ctx.slots,
97
- default: defaultSlot,
98
- infoAppends: infoAppendsSlot,
99
- }}
100
- />
101
- );
102
- };
77
+ return () => (
78
+ <VFormControl
79
+ nodeControl={inputControl}
80
+ class={['v-textarea', control.classes.value]}
81
+ label={props.label}
82
+ hint={props.hint}
83
+ hinttip={props.hinttip}
84
+ hiddenInfo={props.hiddenInfo}
85
+ requiredChip={props.requiredChip}
86
+ onClickLabel={(ev) => {
87
+ inputControl.focus();
88
+ }}
89
+ v-slots={{
90
+ ...ctx.slots,
91
+ default: defaultSlot,
92
+ infoAppends: infoAppendsSlot,
93
+ }}
94
+ />
95
+ );
103
96
  },
104
97
  });
@@ -21,21 +21,17 @@ export const VToolbar = defineComponent({
21
21
  variant: () => props.variant || vui.setting('containedVariant'),
22
22
  });
23
23
 
24
- const classes = computed(() => {
25
- return [
26
- elevation.elevationClassName.value,
27
- color.colorClasses.value,
28
- {
29
- 'v-toolbar--plain': !color.color.value.value,
30
- 'v-toolbar--dense': dense.value,
31
- },
32
- ];
33
- });
24
+ const classes = computed(() => [
25
+ elevation.elevationClassName.value,
26
+ color.colorClasses.value,
27
+ {
28
+ 'v-toolbar--plain': !color.color.value.value,
29
+ 'v-toolbar--dense': dense.value,
30
+ },
31
+ ]);
34
32
 
35
- return () => {
36
- return (
37
- <div class={['v-toolbar', classes.value]}>{ctx.slots.default?.()}</div>
38
- );
39
- };
33
+ return () => (
34
+ <div class={['v-toolbar', classes.value]}>{ctx.slots.default?.()}</div>
35
+ );
40
36
  },
41
37
  });
@@ -6,6 +6,7 @@ import { useVui } from '../../injections';
6
6
  // @TODO Unable to resolve dts for `navigationableInheritProps`.
7
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
8
  // @ts-ignore
9
+ // eslint-disable-next-line import/order
9
10
  import { RouteLocationRaw } from 'vue-router';
10
11
 
11
12
  export type VToolbarMenuEdge = 'start' | 'end';
@@ -27,13 +27,9 @@ export const VTooltip = defineComponent({
27
27
  class="v-tooltip"
28
28
  v-slots={{
29
29
  ...ctx.slots,
30
- default: (payload) => {
31
- return [
32
- <span class="v-tooltip__inner">
33
- {defaultSlot && defaultSlot(payload)}
34
- </span>,
35
- ];
36
- },
30
+ default: (payload) => [
31
+ <span class="v-tooltip__inner">{defaultSlot?.(payload)}</span>,
32
+ ],
37
33
  }}
38
34
  />
39
35
  );
@@ -6,13 +6,13 @@ import {
6
6
  provide,
7
7
  inject,
8
8
  } from 'vue';
9
+ import { createPropsOptions } from '@fastkit/vue-utils';
9
10
  import {
10
11
  ControlSize,
11
12
  CONTROL_SIZES,
12
13
  ControlFieldVariant,
13
14
  CONTROL_FIELD_VARIANTS,
14
15
  } from '../schemes';
15
- import { createPropsOptions } from '@fastkit/vue-utils';
16
16
  import {
17
17
  VuiControlInjectionKey,
18
18
  VuiControlFieldInjectionKey,
@@ -52,16 +52,10 @@ export function useControl(
52
52
  const { defaultSize = 'md' } = opts;
53
53
  const parentControl = inject(VuiControlInjectionKey, null);
54
54
  const size = computed(() => {
55
- const psize = props.size;
56
- return psize
57
- ? psize
58
- : parentControl
59
- ? parentControl.size.value
60
- : defaultSize;
61
- });
62
- const classes = computed(() => {
63
- return ['v-control', `v-control--${size.value}`];
55
+ const propSize = props.size;
56
+ return propSize || (parentControl ? parentControl.size.value : defaultSize);
64
57
  });
58
+ const classes = computed(() => ['v-control', `v-control--${size.value}`]);
65
59
  const provider: ControlProvider = {
66
60
  parentControl,
67
61
  size,
@@ -103,12 +97,11 @@ export function useControlField(
103
97
  const { defaultVariant = 'flat' } = opts;
104
98
  const parentControlField = inject(VuiControlFieldInjectionKey, null);
105
99
  const variant = computed(() => {
106
- const pvariant = props.variant;
107
- return pvariant
108
- ? pvariant
109
- : parentControlField
110
- ? parentControlField.variant.value
111
- : defaultVariant;
100
+ const propVariant = props.variant;
101
+ return (
102
+ propVariant ||
103
+ (parentControlField ? parentControlField.variant.value : defaultVariant)
104
+ );
112
105
  });
113
106
  const provider: ControlFieldProvider = {
114
107
  parentControlField,
@@ -71,6 +71,7 @@ export function defineFormSelectorComponent(
71
71
  },
72
72
  slots,
73
73
  emits,
74
+ // eslint-disable-next-line no-shadow
74
75
  setup(props, ctx) {
75
76
  const selectorControl = useFormSelectorControl(props, ctx, {
76
77
  nodeType,
@@ -103,79 +104,72 @@ export function defineFormSelectorComponent(
103
104
  return slot && slot(vui);
104
105
  });
105
106
 
106
- const defaultSlot = () => {
107
- return (
108
- <div class="v-form-selector__body">
109
- {selectorControl.itemsLoadFailed && (
110
- <div
111
- key="failed"
112
- class="v-form-selector__placeholder v-form-selector__placeholder--error">
113
- {failedToLoadItemsMessageRef.value}
114
- </div>
115
- )}
116
- {selectorControl.itemsLoading && (
117
- <div key="loading" class="v-form-selector__placeholder">
118
- <VProgressCircular
119
- indeterminate
120
- class="mr-1"
121
- size={
122
- CONTROL_LOADING_SPINNER_SIZES[control.size.value || 'md']
123
- }
124
- />
107
+ const defaultSlot = () => (
108
+ <div class="v-form-selector__body">
109
+ {selectorControl.itemsLoadFailed && (
110
+ <div
111
+ key="failed"
112
+ class="v-form-selector__placeholder v-form-selector__placeholder--error">
113
+ {failedToLoadItemsMessageRef.value}
114
+ </div>
115
+ )}
116
+ {selectorControl.itemsLoading && (
117
+ <div key="loading" class="v-form-selector__placeholder">
118
+ <VProgressCircular
119
+ indeterminate
120
+ class="mr-1"
121
+ size={CONTROL_LOADING_SPINNER_SIZES[control.size.value || 'md']}
122
+ />
125
123
 
126
- {loadingMessageRef.value}
127
- </div>
128
- )}
129
- {selectorControl.propGroups.map((group) => {
130
- const { items } = group;
131
- return (
132
- <>
133
- {items.map((attrs) => {
134
- const selected = selectorControl.isSelected(attrs.value);
135
- return itemRenderer({
136
- selected,
137
- control: selectorControl,
138
- attrs: {
139
- ...attrs,
140
- modelValue: selected,
141
- key: attrs.value,
142
- },
143
- slots: {
144
- default: () => attrs.label(selectorControl),
145
- },
146
- });
147
- })}
148
- </>
149
- );
150
- })}
151
- {ctx.slots.default?.()}
152
- </div>
153
- );
154
- };
124
+ {loadingMessageRef.value}
125
+ </div>
126
+ )}
127
+ {selectorControl.propGroups.map((group) => {
128
+ const { items } = group;
129
+ return (
130
+ <>
131
+ {items.map((attrs) => {
132
+ const selected = selectorControl.isSelected(attrs.value);
133
+ return itemRenderer({
134
+ selected,
135
+ control: selectorControl,
136
+ attrs: {
137
+ ...attrs,
138
+ modelValue: selected,
139
+ key: attrs.value,
140
+ },
141
+ slots: {
142
+ default: () => attrs.label(selectorControl),
143
+ },
144
+ });
145
+ })}
146
+ </>
147
+ );
148
+ })}
149
+ {ctx.slots.default?.()}
150
+ </div>
151
+ );
155
152
 
156
153
  ctx.expose({
157
154
  control: selectorControl,
158
155
  });
159
156
 
160
- return () => {
161
- return (
162
- <VFormControl
163
- nodeControl={selectorControl}
164
- // focused={selectorControl.focused}
165
- hiddenInfo={props.hiddenInfo}
166
- class={classes.value}
167
- label={props.label}
168
- hint={props.hint}
169
- hinttip={props.hinttip}
170
- requiredChip={props.requiredChip}
171
- error={selectorControl.itemsLoadFailed}
172
- v-slots={{
173
- ...ctx.slots,
174
- default: defaultSlot,
175
- }}
176
- />
177
- );
178
- };
157
+ return () => (
158
+ <VFormControl
159
+ nodeControl={selectorControl}
160
+ hiddenInfo={props.hiddenInfo}
161
+ class={classes.value}
162
+ label={props.label}
163
+ hint={props.hint}
164
+ hinttip={props.hinttip}
165
+ requiredChip={props.requiredChip}
166
+ error={selectorControl.itemsLoadFailed}
167
+ v-slots={{
168
+ ...ctx.slots,
169
+ default: defaultSlot,
170
+ }}
171
+ />
172
+ );
179
173
  },
180
174
  });
181
175
  }
@@ -1,7 +1,8 @@
1
1
  import { ComputedRef } from 'vue';
2
- export type { VuiService } from '../service';
3
2
  import { ScopeName } from '@fastkit/color-scheme';
4
3
 
4
+ export type { VuiService } from '../service';
5
+
5
6
  export interface VuiColorProvider {
6
7
  primary: ComputedRef<ScopeName>;
7
8
  error: ComputedRef<ScopeName>;
package/src/injections.ts CHANGED
@@ -6,19 +6,19 @@ import type {
6
6
  VuiColorProvider,
7
7
  } from './composables';
8
8
 
9
- export const VuiInjectionKey: InjectionKey<VuiService> = Symbol();
9
+ export const VuiInjectionKey: InjectionKey<VuiService> = Symbol('Vui');
10
10
 
11
- export const VuiControlInjectionKey: InjectionKey<ControlProvider> = Symbol();
11
+ export const VuiControlInjectionKey: InjectionKey<ControlProvider> =
12
+ Symbol('VuiControl');
12
13
 
13
14
  export const VuiControlFieldInjectionKey: InjectionKey<ControlFieldProvider> =
14
- Symbol();
15
+ Symbol('VuiControlField');
15
16
 
16
17
  export const VuiColorProviderInjectionKey: InjectionKey<VuiColorProvider> =
17
- Symbol();
18
+ Symbol('VuiColorProvider');
18
19
 
19
20
  export const VUI_TEXT_FIELD_SYMBOL = 'vui-text-field';
20
21
  export const VUI_TEXTAREA_SYMBOL = 'vui-textarea';
21
- // export const VUI_WYSIWYG_EDITOR_SYMBOL = 'vui-wysiwyg-editor';
22
22
  export const VUI_SELECT_SYMBOL = 'vui-select';
23
23
  export const VUI_OPTION_SYMBOL = 'vui-option';
24
24
  export const VUI_CHECKBOX_GROUP_SYMBOL = 'vui-checkbox-group';
package/src/plugin.tsx CHANGED
@@ -1,11 +1,4 @@
1
1
  import { App } from 'vue';
2
- import {
3
- VuiService,
4
- VuiServiceOptions,
5
- RawVuiServiceOptions,
6
- mergeVuiServiceOptions,
7
- VuiInjectionKey,
8
- } from './service';
9
2
  import {
10
3
  installVueStackPlugin,
11
4
  VueStackServiceOptions,
@@ -21,6 +14,13 @@ import { VueColorSchemePlugin } from '@fastkit/vue-color-scheme';
21
14
  import { installVueAppLayout } from '@fastkit/vue-app-layout';
22
15
  import { onAppUnmount } from '@fastkit/vue-utils';
23
16
  import { getDocumentScroller } from '@fastkit/vue-scroller';
17
+ import {
18
+ VuiService,
19
+ VuiServiceOptions,
20
+ RawVuiServiceOptions,
21
+ mergeVuiServiceOptions,
22
+ VuiInjectionKey,
23
+ } from './service';
24
24
 
25
25
  const scroller = getDocumentScroller();
26
26
 
@@ -78,6 +78,7 @@ export class VuiPlugin {
78
78
  options: {
79
79
  behavior: 'smooth',
80
80
  },
81
+ // eslint-disable-next-line no-shadow
81
82
  fn: (el, opts) => {
82
83
  const duration = opts?.behavior === 'smooth' ? undefined : 0;
83
84
  return scroller.toElement(el, {
package/src/service.tsx CHANGED
@@ -1,8 +1,5 @@
1
- export { VuiInjectionKey } from './injections';
2
-
3
1
  import { VNodeChild, reactive, UnwrapNestedRefs } from 'vue';
4
2
  import { ScopeName, ColorVariant } from '@fastkit/color-scheme';
5
- import type { IconName, RawIconProp } from './components/VIcon';
6
3
  import {
7
4
  type VueStackService,
8
5
  type VStackControl,
@@ -18,13 +15,14 @@ import type { Router } from 'vue-router';
18
15
  import { RouterLink, useLink, UseLinkOptions } from 'vue-router';
19
16
  import { setDefaultRouterLink } from '@fastkit/vue-action';
20
17
  import { LocationService } from '@fastkit/vue-location';
21
- import { VForm } from './components/VForm';
22
- import { VTextField, TextFieldInput } from './components/VTextField';
23
18
  import {
24
19
  VueForm,
25
20
  FormNodeWrapperHinttipDelay,
26
21
  } from '@fastkit/vue-form-control';
27
22
  import { getDocumentScroller, UseScroller } from '@fastkit/vue-scroller';
23
+ import { VForm } from './components/VForm';
24
+ import { VTextField, TextFieldInput } from './components/VTextField';
25
+ import type { IconName, RawIconProp } from './components/VIcon';
28
26
  import { ControlSize } from './schemes';
29
27
  import { VButton } from './components/VButton';
30
28
  import { VDialog } from './components/VDialog';
@@ -32,6 +30,8 @@ import { VSnackbar } from './components/VSnackbar';
32
30
  import { VMenu } from './components/VMenu';
33
31
  import { VSheetModal } from './components/VSheetModal';
34
32
 
33
+ export { VuiInjectionKey } from './injections';
34
+
35
35
  export type UseLinkResult = ReturnType<typeof useLink>;
36
36
 
37
37
  type VDialogProps = InstanceType<typeof VDialog>['$props'];
@@ -198,19 +198,33 @@ export class VuiService {
198
198
  readonly options: VuiServiceOptions;
199
199
 
200
200
  readonly selectionSeparator: VuiVNodeResolver;
201
+
201
202
  readonly autoScrollToElementOffsetTop?: number | (() => number | undefined);
203
+
202
204
  readonly textareaRows?: number;
205
+
203
206
  readonly requiredChip?: VuiVNodeResolver;
207
+
204
208
  readonly router: Router;
209
+
205
210
  readonly location: LocationService;
211
+
206
212
  readonly stack: VueStackService;
213
+
207
214
  readonly useLink: typeof useLink;
215
+
208
216
  readonly stackActions: VStackBuiltinActions;
217
+
209
218
  readonly dialog: StackableLauncher<typeof VDialog>;
219
+
210
220
  readonly alert: StackableLauncher<typeof VDialog>;
221
+
211
222
  readonly confirm: StackableLauncher<typeof VDialog, boolean>;
223
+
212
224
  readonly snackbar: StackableLauncher<typeof VSnackbar>;
225
+
213
226
  readonly menu: StackableLauncher<typeof VMenu>;
227
+
214
228
  readonly sheet: StackableLauncher<typeof VSheetModal>;
215
229
 
216
230
  get scroller(): UseScroller {
@@ -353,29 +367,27 @@ export class VuiService {
353
367
  }),
354
368
  ];
355
369
 
356
- return this.dialog(options, (stack) => {
357
- return (
358
- <VForm
359
- disableAutoScroll
360
- size={size}
361
- // onVnodeMounted={(vnode) => {
362
- // form = (vnode.component as any).ctx.form as VueForm;
363
- // }}
364
- onVnodeBeforeUnmount={() => {
365
- form = undefined;
366
- }}
367
- onSubmit={(ev) => {
368
- stack.resolve(_state);
369
- }}
370
- v-slots={{
371
- default: (_form) => {
372
- form = _form;
373
- return slot(_state, { form, stack });
374
- },
375
- }}
376
- />
377
- );
378
- });
370
+ return this.dialog(options, (stack) => (
371
+ <VForm
372
+ disableAutoScroll
373
+ size={size}
374
+ // onVnodeMounted={(vnode) => {
375
+ // form = (vnode.component as any).ctx.form as VueForm;
376
+ // }}
377
+ onVnodeBeforeUnmount={() => {
378
+ form = undefined;
379
+ }}
380
+ onSubmit={(ev) => {
381
+ stack.resolve(_state);
382
+ }}
383
+ v-slots={{
384
+ default: (_form) => {
385
+ form = _form;
386
+ return slot(_state, { form, stack });
387
+ },
388
+ }}
389
+ />
390
+ ));
379
391
  }
380
392
 
381
393
  prompt(rawOptions: RawVuiPromptOptions = {}) {
@@ -410,9 +422,7 @@ export class VuiService {
410
422
  },
411
423
  },
412
424
  (state) => <VTextField {...options.input} v-model={state.input} />,
413
- ).then((result) => {
414
- return result ? result.input : result;
415
- });
425
+ ).then((result) => (result ? result.input : result));
416
426
  }
417
427
 
418
428
  stackAction(
@@ -424,9 +434,9 @@ export class VuiService {
424
434
  const _onClick = BUILTIN_ACTION_HANDLERS[key];
425
435
  const action: VStackAction = {
426
436
  key,
437
+ // eslint-disable-next-line no-shadow
427
438
  content: ({ control, key }) => {
428
439
  const onClick = (ev: MouseEvent) => _onClick(control, ev);
429
- control.guardInProgress;
430
440
 
431
441
  const _attrs: any = {
432
442
  disabled: control.guardInProgress,