@naptics/vue-collection 0.0.6 → 0.1.0

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.
Files changed (77) hide show
  1. package/README.md +8 -6
  2. package/components/NAlert.d.ts +20 -20
  3. package/components/NAlert.js +3 -3
  4. package/components/NBadge.d.ts +87 -87
  5. package/components/NBadge.js +3 -3
  6. package/components/NBreadcrub.d.ts +57 -57
  7. package/components/NBreadcrub.js +3 -3
  8. package/components/NButton.d.ts +69 -69
  9. package/components/NButton.js +3 -3
  10. package/components/NCheckbox.d.ts +20 -20
  11. package/components/NCheckbox.js +3 -3
  12. package/components/NCheckboxLabel.d.ts +30 -30
  13. package/components/NCheckboxLabel.js +3 -3
  14. package/components/NCrudModal.d.ts +238 -203
  15. package/components/NCrudModal.js +17 -4
  16. package/components/NDialog.d.ts +1 -1
  17. package/components/NDialog.js +3 -3
  18. package/components/NDropdown.d.ts +25 -25
  19. package/components/NDropdown.js +3 -3
  20. package/components/NDropzone.d.ts +52 -52
  21. package/components/NDropzone.js +3 -3
  22. package/components/NForm.d.ts +6 -6
  23. package/components/NForm.js +3 -3
  24. package/components/NFormModal.d.ts +136 -136
  25. package/components/NFormModal.js +3 -3
  26. package/components/NIconButton.d.ts +100 -94
  27. package/components/NIconButton.js +3 -3
  28. package/components/NIconCircle.d.ts +46 -46
  29. package/components/NIconCircle.js +3 -3
  30. package/components/NInput.d.ts +94 -94
  31. package/components/NInput.js +3 -3
  32. package/components/NInputPhone.d.ts +125 -125
  33. package/components/NInputPhone.js +2 -2
  34. package/components/NInputSelect.d.ts +131 -131
  35. package/components/NInputSelect.js +3 -3
  36. package/components/NInputSuggestion.d.ts +179 -167
  37. package/components/NInputSuggestion.js +3 -3
  38. package/components/NLink.d.ts +32 -32
  39. package/components/NLink.js +3 -3
  40. package/components/NList.d.ts +10 -10
  41. package/components/NList.js +3 -3
  42. package/components/NLoadingIndicator.d.ts +30 -30
  43. package/components/NLoadingIndicator.js +3 -3
  44. package/components/NModal.d.ts +118 -118
  45. package/components/NModal.js +3 -3
  46. package/components/NPagination.d.ts +30 -30
  47. package/components/NPagination.js +3 -3
  48. package/components/NSearchbar.d.ts +29 -29
  49. package/components/NSearchbar.js +3 -3
  50. package/components/NSearchbarList.d.ts +53 -62
  51. package/components/NSearchbarList.js +3 -3
  52. package/components/NSelect.d.ts +64 -64
  53. package/components/NSelect.js +3 -3
  54. package/components/NSuggestionList.d.ts +84 -84
  55. package/components/NSuggestionList.js +7 -7
  56. package/components/NTable.d.ts +29 -29
  57. package/components/NTable.js +3 -3
  58. package/components/NTableAction.d.ts +19 -19
  59. package/components/NTableAction.js +3 -3
  60. package/components/NTextArea.d.ts +118 -124
  61. package/components/NTextArea.js +5 -5
  62. package/components/NTooltip.d.ts +44 -44
  63. package/components/NTooltip.js +4 -4
  64. package/components/NValInput.d.ts +134 -134
  65. package/components/NValInput.js +5 -5
  66. package/index.d.ts +2 -2
  67. package/index.js +2 -2
  68. package/package.json +3 -1
  69. package/utils/breakpoints.d.ts +3 -0
  70. package/utils/breakpoints.js +3 -0
  71. package/utils/component.d.ts +0 -8
  72. package/utils/component.js +0 -10
  73. package/utils/identifiable.d.ts +8 -8
  74. package/utils/identifiable.js +4 -2
  75. package/utils/tailwind.d.ts +2 -0
  76. package/utils/utils.d.ts +25 -12
  77. package/utils/utils.js +30 -9
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { createComponent, createView, createProps } from './utils/component';
2
- export { createComponent, createView, createProps };
1
+ import { createComponent, createView } from './utils/component';
2
+ export { createComponent, createView };
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { createComponent, createView, createProps } from './utils/component';
2
- export { createComponent, createView, createProps };
1
+ import { createComponent, createView } from './utils/component';
2
+ export { createComponent, createView };
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@naptics/vue-collection",
3
- "version": "0.0.6",
3
+ "author": "Timo Siegenthaler",
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.0",
4
6
  "main": "./index.js",
5
7
  "repository": {
6
8
  "type": "git",
@@ -7,6 +7,9 @@ export declare const bodyWidth: import("vue").Ref<number>;
7
7
  * It sets a `window.onresize` listener.
8
8
  */
9
9
  export declare function addDocumentResizeEventListener(): void;
10
+ /**
11
+ * Returns a ref whose value is `true` as long as the `document.body.clientWitdh` is above the specified breakpoint.
12
+ */
10
13
  export declare function isWidthBreakpoint(breakpoint: TWBreakpoint): ComputedRef<boolean>;
11
14
  export declare const isWidth2xl: ComputedRef<boolean>;
12
15
  export declare const isWidthXl: ComputedRef<boolean>;
@@ -16,6 +16,9 @@ export function addDocumentResizeEventListener() {
16
16
  bodyWidth.value = document.body.clientWidth;
17
17
  };
18
18
  }
19
+ /**
20
+ * Returns a ref whose value is `true` as long as the `document.body.clientWitdh` is above the specified breakpoint.
21
+ */
19
22
  export function isWidthBreakpoint(breakpoint) {
20
23
  switch (breakpoint) {
21
24
  case 'sm':
@@ -28,14 +28,6 @@ export declare function createComponent<T extends Props>(name: string, props: T,
28
28
  * @returns the created vue-component.
29
29
  */
30
30
  export declare function createView(name: string, setup: (context: SetupContext<never[]>) => RenderFunction | Promise<RenderFunction>): import("vue").DefineComponent<{}, RenderFunction, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{}>> & {}, {}>;
31
- /**
32
- * If props are specified outside of the {@link createComponent}
33
- * function - e.g. to export them or for better code style -
34
- * this helper function can be used to ensure strict typing.
35
- * @param props the props which should be created.
36
- * @returns the created props, with correct typing.
37
- */
38
- export declare function createProps<T extends Props>(props: T): T;
39
31
  /**
40
32
  * Extracts props from another prop object and returns a reactive object with the specified props.
41
33
  * @param props the props to extract from
@@ -23,16 +23,6 @@ export function createComponent(name, props, setup) {
23
23
  export function createView(name, setup) {
24
24
  return defineComponent({ name, emits: [], setup: (props, context) => setup(context) });
25
25
  }
26
- /**
27
- * If props are specified outside of the {@link createComponent}
28
- * function - e.g. to export them or for better code style -
29
- * this helper function can be used to ensure strict typing.
30
- * @param props the props which should be created.
31
- * @returns the created props, with correct typing.
32
- */
33
- export function createProps(props) {
34
- return props;
35
- }
36
26
  /**
37
27
  * Extracts props from another prop object and returns a reactive object with the specified props.
38
28
  * @param props the props to extract from
@@ -12,7 +12,7 @@ export type MaybeIdentifiable = Readonly<{
12
12
  * @param id The `id` of the desired item.
13
13
  * @returns The first item with the specified `id` or `undefined` if none exists.
14
14
  */
15
- declare function find<T extends Identifiable>(array: T[], id: IdType): T | undefined;
15
+ declare function find<T extends Identifiable>(array: Nullish<T[]>, id: IdType): T | undefined;
16
16
  /**
17
17
  * Checks if the given array contains an item with the `id`.
18
18
  * @param array The array to search the item in.
@@ -47,11 +47,11 @@ declare function areSameArrays(first: Identifiable[], second: Identifiable[]): b
47
47
  /**
48
48
  * This object contains utility functions to deal with {@link Identifiable} objects.
49
49
  */
50
- export declare const Id: import("./utils").ReadonlyObject<{
51
- find: typeof find;
52
- contains: typeof contains;
53
- insert: typeof insert;
54
- remove: typeof remove;
55
- areSameArrays: typeof areSameArrays;
56
- }>;
50
+ export declare const Id: {
51
+ readonly find: typeof find;
52
+ readonly contains: typeof contains;
53
+ readonly insert: typeof insert;
54
+ readonly remove: typeof remove;
55
+ readonly areSameArrays: typeof areSameArrays;
56
+ };
57
57
  export {};
@@ -1,4 +1,4 @@
1
- import { markReadonly } from './utils';
1
+ import { isNullish } from './utils';
2
2
  /**
3
3
  * Looks for the `id` in the given array of `Identifiables`.
4
4
  * @param array The array to search the item in.
@@ -6,6 +6,8 @@ import { markReadonly } from './utils';
6
6
  * @returns The first item with the specified `id` or `undefined` if none exists.
7
7
  */
8
8
  function find(array, id) {
9
+ if (isNullish(array))
10
+ return undefined;
9
11
  const filtered = array.filter(item => item.id === id);
10
12
  if (filtered.length > 0)
11
13
  return filtered[0];
@@ -75,4 +77,4 @@ function areSameArrays(first, second) {
75
77
  /**
76
78
  * This object contains utility functions to deal with {@link Identifiable} objects.
77
79
  */
78
- export const Id = markReadonly({ find, contains, insert, remove, areSameArrays });
80
+ export const Id = { find, contains, insert, remove, areSameArrays };
@@ -1,2 +1,4 @@
1
+ import type { FunctionalComponent, HTMLAttributes, VNodeProps } from 'vue';
1
2
  export type TWTextSize = 'text-xs' | 'text-sm' | 'text-base' | 'text-lg' | 'text-xl' | 'text-2xl' | 'text-3xl' | 'text-4xl' | 'text-5xl' | 'text-6xl' | 'text-7xl' | 'text-8xl' | 'text-9xl';
2
3
  export type TWMaxWidth = 'max-w-xs' | 'max-w-sm' | 'max-w-md' | 'max-w-lg' | 'max-w-xl' | 'max-w-2xl' | 'max-w-3xl' | 'max-w-4xl' | 'max-w-5xl' | 'max-w-6xl' | 'max-w-7xl' | 'max-w-full' | 'max-w-min' | 'max-w-max' | 'max-w-fit' | 'max-w-prose' | 'max-w-screen-sm' | 'max-w-screen-md' | 'max-w-screen-lg' | 'max-w-screen-xl' | 'max-w-screen-2xl';
4
+ export type HeroIcon = FunctionalComponent<HTMLAttributes & VNodeProps>;
package/utils/utils.d.ts CHANGED
@@ -1,18 +1,7 @@
1
- import type { FunctionalComponent, HTMLAttributes, VNodeProps } from 'vue';
2
- export type AnyObject = Record<string | number | symbol, unknown>;
3
- export type EmptyObject = Record<string, never>;
1
+ import type { Ref } from 'vue';
4
2
  export type Optional<T> = T | undefined;
5
3
  export type Nullable<T> = T | null;
6
4
  export type Nullish<T> = T | null | undefined;
7
- export type HeroIcon = FunctionalComponent<HTMLAttributes & VNodeProps>;
8
- export type ReadonlyObject<T extends AnyObject> = {
9
- readonly [P in keyof T]: T[P] extends ReadonlyObject<infer _U> ? T[P] : T[P] extends AnyObject ? ReadonlyObject<T[P]> : T[P];
10
- };
11
- export declare function markReadonly<T extends AnyObject>(object: T): ReadonlyObject<T>;
12
- /**
13
- * Generates and returns a non random but unique id.
14
- */
15
- export declare function uniqueId(): number;
16
5
  /**
17
6
  * Determines if a value is not null or undefined.
18
7
  * @param value the value to check
@@ -25,3 +14,27 @@ export declare function notNullish<T>(value: Nullish<T>): value is T;
25
14
  * @returns `true` if the value is `null` or `undefined`.
26
15
  */
27
16
  export declare function isNullish(value: Nullish<unknown>): value is null | undefined;
17
+ /**
18
+ * Determines if the value of a ref is not nullish.
19
+ * @param ref the ref to check
20
+ * @returns `true` if the value of the ref is not nullish.
21
+ * @see notNullish
22
+ */
23
+ export declare function notNullishRef<T>(ref: Ref<T>): ref is Ref<NonNullable<T>>;
24
+ export type AnyObject = Record<string | number | symbol, unknown>;
25
+ export type EmptyObject = Record<string, never>;
26
+ export declare function isAnyObject(object: unknown): object is AnyObject;
27
+ /**
28
+ * Marks all properties of an object (including sub-objects) as readonly.
29
+ */
30
+ export type ReadonlyObject<T extends AnyObject> = {
31
+ readonly [P in keyof T]: T[P] extends ReadonlyObject<infer _U> ? T[P] : T[P] extends AnyObject ? ReadonlyObject<T[P]> : T[P];
32
+ };
33
+ /**
34
+ * Returns the same object casted to a {@link ReadonlyObject}.
35
+ */
36
+ export declare function readonlyObject<T extends AnyObject>(object: T): ReadonlyObject<T>;
37
+ /**
38
+ * Generates and returns a non random but unique id.
39
+ */
40
+ export declare function uniqueId(): number;
package/utils/utils.js CHANGED
@@ -1,13 +1,6 @@
1
- export function markReadonly(object) {
2
- return object;
3
- }
4
- let currentId = 1;
5
- /**
6
- * Generates and returns a non random but unique id.
1
+ /*
2
+ * ---------- Null and Undefined ----------
7
3
  */
8
- export function uniqueId() {
9
- return currentId++;
10
- }
11
4
  /**
12
5
  * Determines if a value is not null or undefined.
13
6
  * @param value the value to check
@@ -24,3 +17,31 @@ export function notNullish(value) {
24
17
  export function isNullish(value) {
25
18
  return value === null || value === undefined;
26
19
  }
20
+ /**
21
+ * Determines if the value of a ref is not nullish.
22
+ * @param ref the ref to check
23
+ * @returns `true` if the value of the ref is not nullish.
24
+ * @see notNullish
25
+ */
26
+ export function notNullishRef(ref) {
27
+ return notNullish(ref.value);
28
+ }
29
+ export function isAnyObject(object) {
30
+ return typeof object === 'object' && !Array.isArray(object);
31
+ }
32
+ /**
33
+ * Returns the same object casted to a {@link ReadonlyObject}.
34
+ */
35
+ export function readonlyObject(object) {
36
+ return object;
37
+ }
38
+ /*
39
+ * ---------- Unique Id ----------
40
+ */
41
+ let currentId = 1;
42
+ /**
43
+ * Generates and returns a non random but unique id.
44
+ */
45
+ export function uniqueId() {
46
+ return currentId++;
47
+ }