@naptics/vue-collection 0.1.7 → 0.1.9

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.
@@ -1,5 +1,6 @@
1
1
  import { type Identifiable } from '../utils/identifiable';
2
2
  import { type PropType } from 'vue';
3
+ import type { AnyObject } from '../utils/utils';
3
4
  export declare const nInputSelectProps: {
4
5
  /**
5
6
  * The id of the currently selected option of this input.
@@ -88,7 +89,7 @@ export declare const nInputSelectProps: {
88
89
  };
89
90
  export type InputSelectOption = Identifiable & {
90
91
  label: string;
91
- } & Record<string, unknown>;
92
+ } & AnyObject;
92
93
  /**
93
94
  * The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
94
95
  * The user is forced to use a value from the specified options of the input.
@@ -1,5 +1,5 @@
1
1
  import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
2
- import { createComponent } from '../utils/component';
2
+ import { createComponentWithSlots } from '../utils/component';
3
3
  import { Id } from '../utils/identifiable';
4
4
  import { option } from '../utils/validation';
5
5
  import { vModelForRef } from '../utils/vModel';
@@ -64,7 +64,7 @@ export const nInputSelectProps = {
64
64
  * The user is forced to use a value from the specified options of the input.
65
65
  * While they type, the list of options is shown to them and filtered based on their input.
66
66
  */
67
- export default createComponent('NInputSelect', nInputSelectProps, props => {
67
+ export default createComponentWithSlots('NInputSelect', nInputSelectProps, ['listItem'], props => {
68
68
  const inputRef = ref();
69
69
  const inputValue = ref('');
70
70
  watch(() => props.value, newValue => {
@@ -1,13 +1,13 @@
1
1
  import type { PropType } from 'vue';
2
2
  export type ListItem = {
3
3
  /**
4
- * The title of the item.
4
+ * The title of the item. Accepts either string or a function returning a JSX element.
5
5
  */
6
- title: string;
6
+ title: string | (() => JSX.Element);
7
7
  /**
8
- * The text of the item.
8
+ * The text of the item. Accepts either string or a function returning a JSX element.
9
9
  */
10
- text?: string;
10
+ text?: string | (() => JSX.Element);
11
11
  };
12
12
  export declare const nListProps: {
13
13
  /**
@@ -1,4 +1,4 @@
1
- import { createVNode as _createVNode } from "vue";
1
+ import { Fragment as _Fragment, createVNode as _createVNode } from "vue";
2
2
  import { createComponent } from '../utils/component';
3
3
  export const nListProps = {
4
4
  /**
@@ -24,7 +24,10 @@ export default createComponent('NList', nListProps, props => {
24
24
  "class": ['py-5 px-4 sm:grid sm:grid-cols-3 sm:gap-4', index % 2 === 1 ? 'bg-white' : 'bg-default-50']
25
25
  }, [_createVNode("dt", {
26
26
  "class": "text-sm font-medium text-default-500"
27
- }, [item.title]), _createVNode("dd", {
27
+ }, [buildElement(item.title)]), _createVNode("dd", {
28
28
  "class": "mt-1 text-sm sm:mt-0 sm:col-span-2"
29
- }, [item.text])]))]);
30
- });
29
+ }, [buildElement(item.text)])]))]);
30
+ });
31
+ function buildElement(element) {
32
+ if (typeof element === 'function') return element();else return _createVNode(_Fragment, null, [element]);
33
+ }
@@ -18,9 +18,7 @@ export declare const nSearchbarListProps: {
18
18
  readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
19
19
  readonly items: {
20
20
  readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
21
- readonly default: () => never[]; /**
22
- * Adds the classes directly to the input (e.g. for shadow).
23
- */
21
+ readonly default: () => never[];
24
22
  };
25
23
  readonly maxItems: {
26
24
  readonly type: NumberConstructor;
@@ -55,9 +53,7 @@ declare const _default: import("vue").DefineComponent<{
55
53
  readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
56
54
  readonly items: {
57
55
  readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
58
- readonly default: () => never[]; /**
59
- * Adds the classes directly to the input (e.g. for shadow).
60
- */
56
+ readonly default: () => never[];
61
57
  };
62
58
  readonly maxItems: {
63
59
  readonly type: NumberConstructor;
@@ -88,9 +84,7 @@ declare const _default: import("vue").DefineComponent<{
88
84
  readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
89
85
  readonly items: {
90
86
  readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
91
- readonly default: () => never[]; /**
92
- * Adds the classes directly to the input (e.g. for shadow).
93
- */
87
+ readonly default: () => never[];
94
88
  };
95
89
  readonly maxItems: {
96
90
  readonly type: NumberConstructor;
@@ -1,5 +1,5 @@
1
1
  import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
2
- import { createComponent } from '../utils/component';
2
+ import { createComponentWithSlots } from '../utils/component';
3
3
  import { ref } from 'vue';
4
4
  import { vModelProps } from '../utils/vModel';
5
5
  import NSearchbar, { nSearchbarProps } from './NSearchbar';
@@ -23,7 +23,7 @@ export const nSearchbarListProps = {
23
23
  /**
24
24
  * The `NSearchbarList` is a {@link NSearchbar} with a {@link NSuggestionList}.
25
25
  */
26
- export default createComponent('NSearchbarList', nSearchbarListProps, props => {
26
+ export default createComponentWithSlots('NSearchbarList', nSearchbarListProps, ['listItem'], props => {
27
27
  const searchbarRef = ref();
28
28
  return () => _createVNode(NSuggestionList, _mergeProps(props, {
29
29
  "inputValue": props.value || '',
@@ -1,5 +1,6 @@
1
1
  import type { Identifiable } from '../utils/identifiable';
2
2
  import { type PropType } from 'vue';
3
+ import type { AnyObject } from '../utils/utils';
3
4
  export declare const nSuggestionListPropsForConfig: {
4
5
  /**
5
6
  * The items which are available to show in the list. The first `maxItems` will be displayed.
@@ -144,7 +145,7 @@ export type ItemSlotProps<T extends Identifiable = SuggestionItem> = {
144
145
  };
145
146
  export type SuggestionItem = Identifiable & {
146
147
  label?: string;
147
- } & Record<string, unknown>;
148
+ } & AnyObject;
148
149
  /**
149
150
  * The `NSuggestionList` can be added to an input and adds a list below it which is shown when the input is focused.
150
151
  */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@naptics/vue-collection",
3
3
  "author": "Timo Siegenthaler",
4
4
  "description": "Vue Collection is a collection of styled and fully functional Vue components which can easily be integrated into our projects.",
5
- "version": "0.1.7",
5
+ "version": "0.1.9",
6
6
  "main": "./index.js",
7
7
  "repository": {
8
8
  "type": "git",
package/utils/utils.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare function isNullish(value: Nullish<unknown>): value is null | unde
22
22
  */
23
23
  export declare function notNullishRef<T>(ref: Ref<T>): ref is Ref<NonNullable<T>>;
24
24
  export type AnyObject = Record<string | number | symbol, unknown>;
25
- export type EmptyObject = Record<string, never>;
25
+ export type EmptyObject = Record<string | number | symbol, never>;
26
26
  export declare function isAnyObject(object: unknown): object is AnyObject;
27
27
  /**
28
28
  * Marks all properties of an object (including sub-objects) as readonly.