@v1nt1248/3nclient-lib 0.2.90 → 0.2.91

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.
@@ -3,6 +3,7 @@ export interface Ui3nListProps<T> {
3
3
  title?: string;
4
4
  sticky?: boolean;
5
5
  items: T[];
6
+ keyField?: keyof T;
6
7
  disabled?: boolean;
7
8
  }
8
9
  export interface Ui3nListEmits<T> {
@@ -1,7 +1,5 @@
1
1
  import { Ui3nListEmits, Ui3nListProps, Ui3nListSlots } from './types';
2
- declare const _default: <T extends {
3
- id?: string;
4
- }>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
2
+ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
6
4
  readonly onSelect?: ((value: {
7
5
  value: T;
@@ -16902,6 +16902,7 @@ const qJ = /* @__PURE__ */ Bg({
16902
16902
  title: { default: "" },
16903
16903
  sticky: { type: Boolean, default: !0 },
16904
16904
  items: {},
16905
+ keyField: { default: "id" },
16905
16906
  disabled: { type: Boolean, default: !1 }
16906
16907
  },
16907
16908
  emits: ["select"],
@@ -16925,15 +16926,18 @@ const qJ = /* @__PURE__ */ Bg({
16925
16926
  class: IA(B.$style.ui3nListContent)
16926
16927
  }, [
16927
16928
  (oA(!0), aA(cI, null, zI(I.items, (E, t) => (oA(), aA("div", {
16928
- key: E.id ?? t,
16929
- class: IA(B.$style.item)
16929
+ key: E[I.keyField],
16930
+ class: IA(B.$style.ui3nListItem)
16930
16931
  }, [
16931
16932
  _A(B.$slots, "item", {
16932
16933
  item: E,
16933
16934
  index: t
16934
16935
  }, () => [
16935
16936
  FA("div", {
16936
- class: IA([B.$style.ui3nListItemContent, I.disabled && B.$style.ui3nListItemContentDisabled]),
16937
+ class: IA([
16938
+ B.$style.ui3nListItemContent,
16939
+ I.disabled && B.$style.ui3nListItemContentDisabled
16940
+ ]),
16937
16941
  onClick: Hg((a) => Q("select", { value: E, index: t }), ["stop"])
16938
16942
  }, Dg(E), 11, XJ)
16939
16943
  ])
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.2.90",
5
+ "version": "0.2.91",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -4,6 +4,7 @@ export interface Ui3nListProps<T> {
4
4
  title?: string;
5
5
  sticky?: boolean;
6
6
  items: T[];
7
+ keyField?: keyof T;
7
8
  disabled?: boolean;
8
9
  }
9
10
 
@@ -1,9 +1,10 @@
1
- <script lang="ts" setup generic="T extends { id?: string }">
1
+ <script lang="ts" setup generic="T">
2
2
  import type { Ui3nListEmits, Ui3nListProps, Ui3nListSlots } from './types';
3
3
 
4
4
  withDefaults(defineProps<Ui3nListProps<T>>(), {
5
5
  title: '',
6
6
  sticky: true,
7
+ keyField: 'id' as keyof T,
7
8
  disabled: false,
8
9
  });
9
10
 
@@ -30,8 +31,8 @@
30
31
  <div :class="$style.ui3nListContent">
31
32
  <div
32
33
  v-for="(item, index) in items"
33
- :key="item.id ?? index"
34
- :class="$style.item"
34
+ :key="item[keyField as keyof T] as PropertyKey"
35
+ :class="$style.ui3nListItem "
35
36
  >
36
37
  <slot
37
38
  name="item"
@@ -39,7 +40,10 @@
39
40
  :index="index"
40
41
  >
41
42
  <div
42
- :class="[$style.ui3nListItemContent, disabled && $style.ui3nListItemContentDisabled]"
43
+ :class="[
44
+ $style.ui3nListItemContent,
45
+ disabled && $style.ui3nListItemContentDisabled,
46
+ ]"
43
47
  @click.stop="emits('select', { value: item, index })"
44
48
  >
45
49
  {{ item }}