@fastkit/vui 0.7.43 → 0.7.47

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.
@@ -19,6 +19,7 @@ import { VTab, VTabRef } from './VTab';
19
19
  import { VScroller, useVScrollerRef } from '@fastkit/vue-kit';
20
20
  import { ScrollResult } from '@fastkit/scroller';
21
21
  import { useScopeColorClass, ScopeName } from '@fastkit/vue-color-scheme';
22
+ import { isPromise } from '@fastkit/helpers';
22
23
 
23
24
  export interface VTabsItemLabelSlotCtx {
24
25
  value: string;
@@ -30,6 +31,11 @@ export type VTabsItemLabelSlot = (ctx: VTabsItemLabelSlotCtx) => VNodeChild;
30
31
 
31
32
  export type VTabsRouterHandler = (value: string) => RouteLocationRaw;
32
33
 
34
+ export type VTabsGuard = (
35
+ nextValue: string,
36
+ oldValue: string,
37
+ ) => boolean | void | undefined | Promise<boolean | void | undefined>;
38
+
33
39
  export interface VTabsItem {
34
40
  value: string;
35
41
  icon?: RawIconProp;
@@ -72,6 +78,7 @@ export const VTabs = defineComponent({
72
78
  }>(),
73
79
 
74
80
  color: String as PropType<ScopeName>,
81
+ onBeforeChange: Function as PropType<VTabsGuard>,
75
82
  },
76
83
  emits: {
77
84
  'update:modelValue': (newValue: string) => true,
@@ -167,7 +174,22 @@ export const VTabs = defineComponent({
167
174
  }
168
175
  }
169
176
 
170
- function to(value: string) {
177
+ async function to(value: string) {
178
+ const { value: currentValue } = currentRef;
179
+ if (currentValue === value) {
180
+ return;
181
+ }
182
+ const { onBeforeChange } = props;
183
+ if (onBeforeChange) {
184
+ let result = onBeforeChange(value, currentRef.value);
185
+ if (isPromise(result)) {
186
+ result = await result;
187
+ }
188
+ console.log(result);
189
+ if (result === false) {
190
+ return;
191
+ }
192
+ }
171
193
  currentRef.value = value;
172
194
  }
173
195
 
@@ -1,7 +1,11 @@
1
1
  export * from './loading';
2
2
  export * from './kits';
3
+ export * from './VSkeltonLoader';
4
+ export * from './VBusyImage';
3
5
  export * from './VGrid';
4
6
  export * from './VPaper';
7
+ export * from './VAvatar';
8
+ export * from './VChip';
5
9
  export * from './VCard';
6
10
  export * from './VIcon';
7
11
  export * from './VButton';
@@ -7,6 +7,7 @@ import {
7
7
  createFormSelectorSettings,
8
8
  FormControlSlots,
9
9
  useFormSelectorControl,
10
+ FormSelectorControl,
10
11
  ResolvedFormSelectorItemData,
11
12
  FormNodeControl,
12
13
  renderSlotOrEmpty,
@@ -20,7 +21,12 @@ export interface DefineFormSelectorComponentOptions {
20
21
  nodeType: string;
21
22
  className: string;
22
23
  itemRenderer: (ctx: {
23
- attrs: ResolvedFormSelectorItemData & { key: string | number };
24
+ control: FormSelectorControl;
25
+ selected: boolean;
26
+ attrs: ResolvedFormSelectorItemData & {
27
+ modelValue: boolean;
28
+ key: string | number;
29
+ };
24
30
  slots: {
25
31
  default: TypedSlot<FormNodeControl>;
26
32
  };
@@ -60,6 +66,7 @@ export function defineFormSelectorComponent(
60
66
  };
61
67
  },
62
68
  render() {
69
+ const { selectorControl } = this;
63
70
  return (
64
71
  <VFormControl
65
72
  nodeControl={this.nodeControl}
@@ -81,17 +88,21 @@ export function defineFormSelectorComponent(
81
88
  ...this.$slots,
82
89
  default: () => (
83
90
  <div class="v-form-selector__body">
84
- {this.propItems.map((attrs) =>
85
- itemRenderer({
91
+ {this.propItems.map((attrs) => {
92
+ const selected = selectorControl.isSelected(attrs.value);
93
+ return itemRenderer({
94
+ selected,
95
+ control: selectorControl,
86
96
  attrs: {
87
97
  ...attrs,
98
+ modelValue: selected,
88
99
  key: attrs.value,
89
100
  },
90
101
  slots: {
91
102
  default: () => attrs.label(this.selectorControl),
92
103
  },
93
- }),
94
- )}
104
+ });
105
+ })}
95
106
  {renderSlotOrEmpty(this.$slots, 'default')}
96
107
  </div>
97
108
  ),
@@ -30,6 +30,9 @@
30
30
  --typo-base-height: 1.5;
31
31
  --typo-base-spacing: 0em;
32
32
 
33
+ // medium
34
+ --typo-medium-weight: 500;
35
+
33
36
  // h1
34
37
  --typo-h1-size: 2.5rem;
35
38
  --typo-h1-weight: 500;
@@ -123,6 +126,22 @@
123
126
  // --typo-overline-height: 2.66;
124
127
  // --typo-overline-spacing: 0.08333em;
125
128
 
129
+ // =============================================
130
+ // chips
131
+ // =============================================
132
+ --chip-padding: 0.875em;
133
+ --chip-font-weight: var(--typo-base-weight);
134
+ --chip-height-xs: 16px;
135
+ --chip-font-size-xs: 10px;
136
+ --chip-height-sm: 24px;
137
+ --chip-font-size-sm: 12px;
138
+ --chip-height-md: 32px;
139
+ --chip-font-size-md: 14px;
140
+ --chip-height-lg: 54px;
141
+ --chip-font-size-lg: 16px;
142
+ --chip-height-xl: 66px;
143
+ --chip-font-size-xl: 18px;
144
+
126
145
  // =============================================
127
146
  // controls
128
147
  // =============================================