@fastkit/vui 0.7.54 → 0.7.57

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.
@@ -100,8 +100,12 @@ export const VWysiwygEditor = defineComponent({
100
100
  () => props.modelValue,
101
101
  (modelValue) => {
102
102
  const $editor = editor.value;
103
- if (!$editor) return;
104
- $editor.commands.setContent(modelValue == null ? '' : modelValue);
103
+ if (!$editor || $editor.getHTML() === modelValue) return;
104
+
105
+ $editor.commands.setContent(
106
+ modelValue == null ? '' : modelValue,
107
+ false,
108
+ );
105
109
  textRef.value = $editor.getText();
106
110
  },
107
111
  );
@@ -255,6 +259,7 @@ export const VWysiwygEditor = defineComponent({
255
259
  autoHeight
256
260
  startAdornment={this.startAdornment}
257
261
  endAdornment={this.endAdornment}
262
+ size={this.size}
258
263
  // onClickHost={(ev) => {
259
264
  // this.focus();
260
265
  // }}
@@ -27,6 +27,7 @@ export function createControlProps() {
27
27
  return CONTROL_SIZES.includes(value);
28
28
  },
29
29
  },
30
+ loading: Boolean,
30
31
  });
31
32
  }
32
33
 
@@ -3,6 +3,19 @@
3
3
  display: block;
4
4
  }
5
5
 
6
+ &__placeholder {
7
+ display: flex;
8
+ align-items: center;
9
+ margin-top: 8px;
10
+ font-style: italic;
11
+ opacity: 0.5;
12
+
13
+ &--error {
14
+ color: var(--main-color);
15
+ opacity: 1;
16
+ }
17
+ }
18
+
6
19
  &--stacked &__body {
7
20
  display: flex;
8
21
  flex-direction: column;
@@ -1,5 +1,5 @@
1
1
  import './form-selector.scss';
2
- import { VNodeChild, defineComponent } from 'vue';
2
+ import { VNodeChild, defineComponent, PropType, computed } from 'vue';
3
3
  import {
4
4
  defineSlotsProps,
5
5
  TypedSlot,
@@ -11,9 +11,14 @@ import {
11
11
  ResolvedFormSelectorItemData,
12
12
  FormNodeControl,
13
13
  renderSlotOrEmpty,
14
+ VNodeChildOrSlot,
15
+ resolveVNodeChildOrSlots,
14
16
  } from '@fastkit/vue-kit';
15
17
  import { createControlProps, useControl } from './control';
16
18
  import { VFormControl } from '../components/VFormControl';
19
+ import { useVui } from '../injections';
20
+ import { VProgressCircular } from '../components/loading';
21
+ import { CONTROL_LOADING_SPINNER_SIZES } from '../schemes';
17
22
 
18
23
  export interface DefineFormSelectorComponentOptions {
19
24
  name: string;
@@ -51,6 +56,10 @@ export function defineFormSelectorComponent(
51
56
  type: Boolean,
52
57
  default: true,
53
58
  },
59
+ // eslint-disable-next-line vue/require-prop-types
60
+ loadingMessage: {} as PropType<VNodeChildOrSlot>,
61
+ // eslint-disable-next-line vue/require-prop-types
62
+ failedToLoadItemsMessage: {} as PropType<VNodeChildOrSlot>,
54
63
  ...defineSlotsProps<FormControlSlots>(),
55
64
  },
56
65
  emits,
@@ -60,9 +69,28 @@ export function defineFormSelectorComponent(
60
69
  defaultMultiple,
61
70
  });
62
71
  const control = useControl(props);
72
+ const vui = useVui();
73
+ const loadingMessageRef = computed(() => {
74
+ const slot = resolveVNodeChildOrSlots(
75
+ props.loadingMessage,
76
+ vui.setting('loadingMessage'),
77
+ 'Loading...',
78
+ );
79
+ return slot && slot(vui);
80
+ });
81
+ const failedToLoadItemsMessageRef = computed(() => {
82
+ const slot = resolveVNodeChildOrSlots(
83
+ props.failedToLoadItemsMessage,
84
+ vui.setting('failedToLoadDataMessage'),
85
+ 'Failed to load data.',
86
+ );
87
+ return slot && slot(vui);
88
+ });
63
89
  return {
64
90
  ...selectorControl.expose(),
65
91
  ...control,
92
+ loadingMessageRef,
93
+ failedToLoadItemsMessageRef,
66
94
  };
67
95
  },
68
96
  render() {
@@ -84,10 +112,29 @@ export function defineFormSelectorComponent(
84
112
  hint={this.hint}
85
113
  hinttip={this.hinttip}
86
114
  requiredChip={this.requiredChip}
115
+ error={selectorControl.itemsLoadFailed}
87
116
  v-slots={{
88
117
  ...this.$slots,
89
118
  default: () => (
90
119
  <div class="v-form-selector__body">
120
+ {selectorControl.itemsLoadFailed && (
121
+ <div
122
+ key="failed"
123
+ class="v-form-selector__placeholder v-form-selector__placeholder--error">
124
+ {this.failedToLoadItemsMessageRef}
125
+ </div>
126
+ )}
127
+ {selectorControl.itemsLoading && (
128
+ <div key="loading" class="v-form-selector__placeholder">
129
+ <VProgressCircular
130
+ indeterminate
131
+ class="mr-1"
132
+ size={CONTROL_LOADING_SPINNER_SIZES[this.size || 'md']}
133
+ />
134
+
135
+ {this.loadingMessageRef}
136
+ </div>
137
+ )}
91
138
  {this.propItems.map((attrs) => {
92
139
  const selected = selectorControl.isSelected(attrs.value);
93
140
  return itemRenderer({
@@ -5,3 +5,9 @@ export type ControlSize = typeof CONTROL_SIZES[number];
5
5
  export const CONTROL_FIELD_VARIANTS = ['outlined', 'filled', 'flat'] as const;
6
6
 
7
7
  export type ControlFieldVariant = typeof CONTROL_FIELD_VARIANTS[number];
8
+
9
+ export const CONTROL_LOADING_SPINNER_SIZES: Record<ControlSize, number> = {
10
+ sm: 16,
11
+ md: 20,
12
+ lg: 24,
13
+ };
package/src/service.tsx CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  type VueStackService,
9
9
  type VDialogProps,
10
10
  type VStackControl,
11
+ type VNodeChildOrSlot,
11
12
  resolveVStackDynamicInput,
12
13
  } from '@fastkit/vue-kit';
13
14
  import type { Router } from 'vue-router';
@@ -60,8 +61,10 @@ export interface VuiServiceUISettings {
60
61
  variant?: ColorVariant;
61
62
  };
62
63
  hinttipDelay?: FormControlHinttipDelay;
63
- noDataMessage?: VNodeChild | (() => VNodeChild);
64
- noResultsMessage?: VNodeChild | (() => VNodeChild);
64
+ noDataMessage?: VNodeChildOrSlot;
65
+ noResultsMessage?: VNodeChildOrSlot;
66
+ loadingMessage?: VNodeChildOrSlot;
67
+ failedToLoadDataMessage?: VNodeChildOrSlot;
65
68
  }
66
69
 
67
70
  export type RawVuiServiceUISettings = Partial<VuiServiceUISettings>;
@@ -102,6 +105,7 @@ export interface VuiServiceIconSettings {
102
105
  editorRedo: IconName;
103
106
  hinttip: IconName;
104
107
  clear: IconName;
108
+ reload: IconName;
105
109
  }
106
110
 
107
111
  export type RawVuiServiceIconSettings = Partial<VuiServiceIconSettings>;
@@ -173,6 +173,7 @@ export function viteVuiPlugin(
173
173
  editorRedo: 'mdi-redo-variant' as any,
174
174
  hinttip: 'mdi-help-circle-outline' as any,
175
175
  clear: 'mdi-close' as any,
176
+ reload: 'mdi-reload' as any,
176
177
  // navigationExpand: (gen, active) => {
177
178
  // return gen({
178
179
  // name: 'mdi-menu-down' as any,