@naptics/vue-collection 0.1.8 → 0.1.10

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.
@@ -62,22 +63,14 @@ export declare const nInputSelectProps: {
62
63
  };
63
64
  readonly tooltipMaxWidth: {
64
65
  readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
65
- readonly default: "max-w-xs"; /**
66
- * @see {@link nValInputProps.optional}
67
- */
66
+ readonly default: "max-w-xs";
68
67
  };
69
68
  readonly tooltipWrapperAddClass: StringConstructor;
70
69
  readonly tooltipContentAddClass: StringConstructor;
71
70
  readonly name: StringConstructor;
72
71
  readonly placeholder: StringConstructor;
73
72
  readonly autocomplete: {
74
- readonly type: StringConstructor; /**
75
- * This is called with the newly selected id when the selection has changed.
76
- * This happens, when an item from the suggestion list is selected or the
77
- * input matches a selection option exactly.
78
- * If no id is selected, the empty string is passed, in order to
79
- * match the API of all other inputs who never pass `undefined`.
80
- */
73
+ readonly type: StringConstructor;
81
74
  readonly default: "off";
82
75
  };
83
76
  readonly type: {
@@ -96,7 +89,7 @@ export declare const nInputSelectProps: {
96
89
  };
97
90
  export type InputSelectOption = Identifiable & {
98
91
  label: string;
99
- } & Record<string, unknown>;
92
+ } & AnyObject;
100
93
  /**
101
94
  * The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
102
95
  * The user is forced to use a value from the specified options of the input.
@@ -164,22 +157,14 @@ declare const _default: import("vue").DefineComponent<{
164
157
  };
165
158
  readonly tooltipMaxWidth: {
166
159
  readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
167
- readonly default: "max-w-xs"; /**
168
- * @see {@link nValInputProps.optional}
169
- */
160
+ readonly default: "max-w-xs";
170
161
  };
171
162
  readonly tooltipWrapperAddClass: StringConstructor;
172
163
  readonly tooltipContentAddClass: StringConstructor;
173
164
  readonly name: StringConstructor;
174
165
  readonly placeholder: StringConstructor;
175
166
  readonly autocomplete: {
176
- readonly type: StringConstructor; /**
177
- * This is called with the newly selected id when the selection has changed.
178
- * This happens, when an item from the suggestion list is selected or the
179
- * input matches a selection option exactly.
180
- * If no id is selected, the empty string is passed, in order to
181
- * match the API of all other inputs who never pass `undefined`.
182
- */
167
+ readonly type: StringConstructor;
183
168
  readonly default: "off";
184
169
  };
185
170
  readonly type: {
@@ -257,22 +242,14 @@ declare const _default: import("vue").DefineComponent<{
257
242
  };
258
243
  readonly tooltipMaxWidth: {
259
244
  readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
260
- readonly default: "max-w-xs"; /**
261
- * @see {@link nValInputProps.optional}
262
- */
245
+ readonly default: "max-w-xs";
263
246
  };
264
247
  readonly tooltipWrapperAddClass: StringConstructor;
265
248
  readonly tooltipContentAddClass: StringConstructor;
266
249
  readonly name: StringConstructor;
267
250
  readonly placeholder: StringConstructor;
268
251
  readonly autocomplete: {
269
- readonly type: StringConstructor; /**
270
- * This is called with the newly selected id when the selection has changed.
271
- * This happens, when an item from the suggestion list is selected or the
272
- * input matches a selection option exactly.
273
- * If no id is selected, the empty string is passed, in order to
274
- * match the API of all other inputs who never pass `undefined`.
275
- */
252
+ readonly type: StringConstructor;
276
253
  readonly default: "off";
277
254
  };
278
255
  readonly type: {
@@ -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
  /**
@@ -17,6 +17,14 @@ export declare const nListProps: {
17
17
  readonly type: PropType<ListItem[]>;
18
18
  readonly default: () => never[];
19
19
  };
20
+ /**
21
+ * Adds the classes to all title elements (on the left side).
22
+ */
23
+ readonly titleClass: StringConstructor;
24
+ /**
25
+ * Adds the classese to all text elements (on the right side).
26
+ */
27
+ readonly textClass: StringConstructor;
20
28
  /**
21
29
  * Adds the classes to the top-level element.
22
30
  */
@@ -33,6 +41,14 @@ declare const _default: import("vue").DefineComponent<{
33
41
  readonly type: PropType<ListItem[]>;
34
42
  readonly default: () => never[];
35
43
  };
44
+ /**
45
+ * Adds the classes to all title elements (on the left side).
46
+ */
47
+ readonly titleClass: StringConstructor;
48
+ /**
49
+ * Adds the classese to all text elements (on the right side).
50
+ */
51
+ readonly textClass: StringConstructor;
36
52
  /**
37
53
  * Adds the classes to the top-level element.
38
54
  */
@@ -45,6 +61,14 @@ declare const _default: import("vue").DefineComponent<{
45
61
  readonly type: PropType<ListItem[]>;
46
62
  readonly default: () => never[];
47
63
  };
64
+ /**
65
+ * Adds the classes to all title elements (on the left side).
66
+ */
67
+ readonly titleClass: StringConstructor;
68
+ /**
69
+ * Adds the classese to all text elements (on the right side).
70
+ */
71
+ readonly textClass: StringConstructor;
48
72
  /**
49
73
  * Adds the classes to the top-level element.
50
74
  */
@@ -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
  /**
@@ -8,6 +8,14 @@ export const nListProps = {
8
8
  type: Array,
9
9
  default: () => []
10
10
  },
11
+ /**
12
+ * Adds the classes to all title elements (on the left side).
13
+ */
14
+ titleClass: String,
15
+ /**
16
+ * Adds the classese to all text elements (on the right side).
17
+ */
18
+ textClass: String,
11
19
  /**
12
20
  * Adds the classes to the top-level element.
13
21
  */
@@ -23,8 +31,11 @@ export default createComponent('NList', nListProps, props => {
23
31
  "key": index,
24
32
  "class": ['py-5 px-4 sm:grid sm:grid-cols-3 sm:gap-4', index % 2 === 1 ? 'bg-white' : 'bg-default-50']
25
33
  }, [_createVNode("dt", {
26
- "class": "text-sm font-medium text-default-500"
27
- }, [item.title]), _createVNode("dd", {
28
- "class": "mt-1 text-sm sm:mt-0 sm:col-span-2"
29
- }, [item.text])]))]);
30
- });
34
+ "class": `text-sm font-medium text-default-500 ${props.titleClass}`
35
+ }, [buildElement(item.title)]), _createVNode("dd", {
36
+ "class": `mt-1 text-sm sm:mt-0 sm:col-span-2 ${props.textClass}`
37
+ }, [buildElement(item.text)])]))]);
38
+ });
39
+ function buildElement(element) {
40
+ if (typeof element === 'function') return element();else return _createVNode(_Fragment, null, [element]);
41
+ }
@@ -19,9 +19,7 @@ export declare const nSearchbarListProps: {
19
19
  readonly items: {
20
20
  readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
21
21
  readonly default: () => never[];
22
- }; /**
23
- * Adds the classes directly to the input (e.g. for shadow).
24
- */
22
+ };
25
23
  readonly maxItems: {
26
24
  readonly type: NumberConstructor;
27
25
  readonly default: () => number;
@@ -56,9 +54,7 @@ declare const _default: import("vue").DefineComponent<{
56
54
  readonly items: {
57
55
  readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
58
56
  readonly default: () => never[];
59
- }; /**
60
- * Adds the classes directly to the input (e.g. for shadow).
61
- */
57
+ };
62
58
  readonly maxItems: {
63
59
  readonly type: NumberConstructor;
64
60
  readonly default: () => number;
@@ -89,9 +85,7 @@ declare const _default: import("vue").DefineComponent<{
89
85
  readonly items: {
90
86
  readonly type: import("vue").PropType<import("./NSuggestionList").SuggestionItem[]>;
91
87
  readonly default: () => never[];
92
- }; /**
93
- * Adds the classes directly to the input (e.g. for shadow).
94
- */
88
+ };
95
89
  readonly maxItems: {
96
90
  readonly type: NumberConstructor;
97
91
  readonly default: () => number;
@@ -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.8",
5
+ "version": "0.1.10",
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.