@fastkit/vui 0.12.7 → 0.12.8

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/vui.d.ts CHANGED
@@ -71,6 +71,7 @@ import { ResolveRawSlots as ResolveRawSlots_2 } from '@fastkit/vue-utils';
71
71
  import { RouteLocationRaw } from 'vue-router';
72
72
  import type { Router } from 'vue-router';
73
73
  import { ScopeName } from '@fastkit/color-scheme';
74
+ import { ScopeName as ScopeName_2 } from '@fastkit/vue-color-scheme';
74
75
  import { ShallowRef } from 'vue';
75
76
  import { StyleValue } from 'vue';
76
77
  import { TextableCounterResult } from '@fastkit/vue-kit';
@@ -1148,6 +1149,13 @@ export declare interface DataTableItemSlotPayload<T extends DataTableItem = Data
1148
1149
  selected: boolean;
1149
1150
  }
1150
1151
 
1152
+ export declare interface DataTableRowSettings<T extends DataTableItem = DataTableItem> {
1153
+ color?: ScopeName_2;
1154
+ attrs?: HTMLAttributes;
1155
+ }
1156
+
1157
+ export declare type DataTableRowSettingsFn<T extends DataTableItem = DataTableItem> = (payload: DataTableItemSlotPayload<T>) => DataTableRowSettings<T>;
1158
+
1151
1159
  export declare function defineFormSelectorComponent(opts: DefineFormSelectorComponentOptions): DefineComponent<{
1152
1160
  'v-slots': PropType<ResolveRawSlots<FormControlSlots>>;
1153
1161
  stacked: {
@@ -1523,6 +1531,8 @@ declare type PrefixedEventName<S extends string> = `on${Capitalize<S>}`;
1523
1531
 
1524
1532
  export declare type RawBreadcrumbsItem = string | BreadcrumbsItem;
1525
1533
 
1534
+ export declare type RawDataTableRowSettings<T extends DataTableItem = DataTableItem> = DataTableRowSettingsFn<T> | DataTableRowSettings<T>;
1535
+
1526
1536
  declare type RawGridValue<T extends number | string = number | string> = T | Partial<Record<MediaMatchKey, T>> | undefined;
1527
1537
 
1528
1538
  declare type RawGridValueProp<T extends number | string = number | string> = PropType<RawGridValue<T>>;
@@ -4384,6 +4394,7 @@ export declare const VDataTable: DefineComponent<{
4384
4394
  maxHeight: (StringConstructor | NumberConstructor)[];
4385
4395
  noDataMessage: PropType<VNodeChildOrSlot_2<any>>;
4386
4396
  noResultsMessage: PropType<VNodeChildOrSlot_2<any>>;
4397
+ rowSettings: PropType<RawDataTableRowSettings<DataTableItem>>;
4387
4398
  }, () => JSX.Element, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
4388
4399
  input: (selecteds: string[]) => true;
4389
4400
  }, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
@@ -4472,6 +4483,7 @@ export declare const VDataTable: DefineComponent<{
4472
4483
  maxHeight: (StringConstructor | NumberConstructor)[];
4473
4484
  noDataMessage: PropType<VNodeChildOrSlot_2<any>>;
4474
4485
  noResultsMessage: PropType<VNodeChildOrSlot_2<any>>;
4486
+ rowSettings: PropType<RawDataTableRowSettings<DataTableItem>>;
4475
4487
  }>> & {
4476
4488
  onInput?: ((selecteds: string[]) => any) | undefined;
4477
4489
  }, {
package/dist/vui.mjs CHANGED
@@ -4544,7 +4544,8 @@ const VDataTable = /* @__PURE__ */ defineComponent({
4544
4544
  // eslint-disable-next-line vue/require-prop-types
4545
4545
  noDataMessage: {},
4546
4546
  // eslint-disable-next-line vue/require-prop-types
4547
- noResultsMessage: {}
4547
+ noResultsMessage: {},
4548
+ rowSettings: [Object, Function]
4548
4549
  },
4549
4550
  emits: {
4550
4551
  input: selecteds => true
@@ -4554,6 +4555,14 @@ const VDataTable = /* @__PURE__ */ defineComponent({
4554
4555
  const bootedRef = ref(false);
4555
4556
  const footerHeightRef = ref(0);
4556
4557
  const internalValues = ref(props.modelValue.slice());
4558
+ const rowSettings = computed(() => {
4559
+ const {
4560
+ rowSettings
4561
+ } = props;
4562
+ if (!rowSettings) return () => ({});
4563
+ return typeof rowSettings === 'function' ? rowSettings : () => rowSettings;
4564
+ });
4565
+ const containedVariant = vui.setting('containedVariant');
4557
4566
  const sortedItemKeysRef = computed(() => props.items.map(item => item[props.itemKey]));
4558
4567
  const isEmptyRef = computed(() => props.items.length === 0);
4559
4568
  const headersRef = computed(() => {
@@ -4977,12 +4986,21 @@ const VDataTable = /* @__PURE__ */ defineComponent({
4977
4986
  "key": header.key
4978
4987
  }, [cellChildren]);
4979
4988
  });
4980
- return createVNode("tr", {
4981
- "class": ['v-data-table__table__item', {
4982
- 'v-data-table__table__item--selected': selected
4983
- }],
4989
+ const {
4990
+ color,
4991
+ attrs
4992
+ } = rowSettings.value(payload);
4993
+ const colorClass = color && toScopeColorClass(color);
4994
+ const classes = ['v-data-table__table__item', {
4995
+ 'v-data-table__table__item--selected': selected
4996
+ }];
4997
+ if (colorClass) {
4998
+ classes.push(colorClass, containedVariant);
4999
+ }
5000
+ return createVNode("tr", mergeProps({
5001
+ "class": classes,
4984
5002
  "key": key
4985
- }, [children]);
5003
+ }, attrs), [children]);
4986
5004
  }
4987
5005
  function genBody() {
4988
5006
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastkit/vui",
3
- "version": "0.12.7",
3
+ "version": "0.12.8",
4
4
  "description": "A simple, extensible UI kit for Vue applications.",
5
5
  "buildOptions": {
6
6
  "name": "Vui",
@@ -59,11 +59,11 @@
59
59
  "vue": "^3.2.45"
60
60
  },
61
61
  "dependencies": {
62
- "@fastkit/color-scheme": "0.12.7",
63
- "@fastkit/icon-font": "0.12.7",
64
- "@fastkit/tiny-logger": "0.12.7",
65
- "@fastkit/vite-kit": "0.12.7",
66
- "@fastkit/vue-kit": "0.12.7",
62
+ "@fastkit/color-scheme": "0.12.8",
63
+ "@fastkit/icon-font": "0.12.8",
64
+ "@fastkit/tiny-logger": "0.12.8",
65
+ "@fastkit/vite-kit": "0.12.8",
66
+ "@fastkit/vue-kit": "0.12.8",
67
67
  "@tiptap/extension-link": "^2.0.0-beta.209",
68
68
  "@tiptap/extension-text-style": "^2.0.0-beta.209",
69
69
  "@tiptap/extension-underline": "^2.0.0-beta.209",
@@ -13,6 +13,7 @@ import {
13
13
  withDirectives,
14
14
  Transition,
15
15
  isVNode,
16
+ HTMLAttributes,
16
17
  } from 'vue';
17
18
  import { useVui } from '../../injections';
18
19
  import type { VuiService } from '../../service';
@@ -23,6 +24,7 @@ import { VIcon, resolveRawIconProp } from '../VIcon';
23
24
  import { VProgressCircular } from '../loading';
24
25
  import { resizeDirectiveArgument, VNodeChildOrSlot } from '@fastkit/vue-utils';
25
26
  import { VueAppLayout } from '@fastkit/vue-app-layout';
27
+ import { ScopeName, toScopeColorClass } from '@fastkit/vue-color-scheme';
26
28
  import { VPaper } from '../VPaper';
27
29
 
28
30
  export type DataTableHeaderAlign = 'left' | 'center' | 'right';
@@ -88,6 +90,19 @@ export interface DataTableHeader<T extends DataTableItem = DataTableItem> {
88
90
  cell?: (payload: DataTableCellSlotPayload<T>) => VNodeChild;
89
91
  }
90
92
 
93
+ export interface DataTableRowSettings<T extends DataTableItem = DataTableItem> {
94
+ color?: ScopeName;
95
+ attrs?: HTMLAttributes;
96
+ }
97
+
98
+ export type DataTableRowSettingsFn<T extends DataTableItem = DataTableItem> = (
99
+ payload: DataTableItemSlotPayload<T>,
100
+ ) => DataTableRowSettings<T>;
101
+
102
+ export type RawDataTableRowSettings<T extends DataTableItem = DataTableItem> =
103
+ | DataTableRowSettingsFn<T>
104
+ | DataTableRowSettings<T>;
105
+
91
106
  const SELECTABLE_HEADER_SYMBOL = '__selectable_header__';
92
107
 
93
108
  export const VDataTable = defineComponent({
@@ -186,6 +201,7 @@ export const VDataTable = defineComponent({
186
201
  noDataMessage: {} as PropType<VNodeChildOrSlot>,
187
202
  // eslint-disable-next-line vue/require-prop-types
188
203
  noResultsMessage: {} as PropType<VNodeChildOrSlot>,
204
+ rowSettings: [Object, Function] as PropType<RawDataTableRowSettings>,
189
205
  },
190
206
  emits: {
191
207
  input: (selecteds: string[]) => true,
@@ -195,6 +211,15 @@ export const VDataTable = defineComponent({
195
211
  const bootedRef = ref(false);
196
212
  const footerHeightRef = ref(0);
197
213
  const internalValues = ref<string[]>(props.modelValue.slice());
214
+ const rowSettings = computed<DataTableRowSettingsFn>(() => {
215
+ const { rowSettings } = props;
216
+ if (!rowSettings) return () => ({});
217
+ return typeof rowSettings === 'function'
218
+ ? rowSettings
219
+ : () => rowSettings;
220
+ });
221
+ const containedVariant = vui.setting('containedVariant');
222
+
198
223
  const sortedItemKeysRef = computed(() =>
199
224
  props.items.map((item) => item[props.itemKey]),
200
225
  );
@@ -725,15 +750,21 @@ export const VDataTable = defineComponent({
725
750
  </td>
726
751
  );
727
752
  });
753
+
754
+ const { color, attrs } = rowSettings.value(payload);
755
+ const colorClass = color && toScopeColorClass(color);
756
+ const classes = [
757
+ 'v-data-table__table__item',
758
+ {
759
+ 'v-data-table__table__item--selected': selected,
760
+ },
761
+ ];
762
+ if (colorClass) {
763
+ classes.push(colorClass, containedVariant);
764
+ }
765
+
728
766
  return (
729
- <tr
730
- class={[
731
- 'v-data-table__table__item',
732
- {
733
- 'v-data-table__table__item--selected': selected,
734
- },
735
- ]}
736
- key={key}>
767
+ <tr class={classes} key={key} {...attrs}>
737
768
  {children}
738
769
  </tr>
739
770
  );