@naptics/vue-collection 0.0.4 → 0.0.6

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 (46) hide show
  1. package/i18n/index.js +4 -4
  2. package/index.d.ts +0 -64
  3. package/index.js +1 -66
  4. package/package.json +1 -1
  5. package/utils/breakpoints.js +21 -21
  6. package/utils/component.js +9 -17
  7. package/utils/deferred.js +12 -12
  8. package/utils/identifiable.js +29 -27
  9. package/utils/stringMaxLength.js +13 -8
  10. package/utils/tailwind.js +1 -1
  11. package/utils/utils.js +5 -5
  12. package/utils/vModel.js +73 -82
  13. package/utils/validation.js +81 -55
  14. package/utils/vue.js +5 -7
  15. package/components/NAlert.jsx +0 -69
  16. package/components/NBadge.jsx +0 -58
  17. package/components/NBreadcrub.jsx +0 -64
  18. package/components/NButton.jsx +0 -58
  19. package/components/NCheckbox.jsx +0 -38
  20. package/components/NCheckboxLabel.jsx +0 -42
  21. package/components/NCrudModal.jsx +0 -89
  22. package/components/NDialog.jsx +0 -144
  23. package/components/NDropdown.jsx +0 -92
  24. package/components/NDropzone.jsx +0 -211
  25. package/components/NForm.jsx +0 -26
  26. package/components/NFormModal.jsx +0 -48
  27. package/components/NIconButton.jsx +0 -71
  28. package/components/NIconCircle.jsx +0 -67
  29. package/components/NInput.jsx +0 -97
  30. package/components/NInputPhone.jsx +0 -32
  31. package/components/NInputSelect.jsx +0 -89
  32. package/components/NInputSuggestion.jsx +0 -48
  33. package/components/NLink.jsx +0 -58
  34. package/components/NList.jsx +0 -24
  35. package/components/NLoadingIndicator.jsx +0 -42
  36. package/components/NModal.jsx +0 -170
  37. package/components/NPagination.jsx +0 -104
  38. package/components/NSearchbar.jsx +0 -58
  39. package/components/NSearchbarList.jsx +0 -20
  40. package/components/NSelect.jsx +0 -81
  41. package/components/NSuggestionList.jsx +0 -157
  42. package/components/NTable.jsx +0 -146
  43. package/components/NTableAction.jsx +0 -35
  44. package/components/NTextArea.jsx +0 -108
  45. package/components/NTooltip.jsx +0 -161
  46. package/components/NValInput.jsx +0 -101
package/i18n/index.js CHANGED
@@ -6,7 +6,7 @@ let provider = undefined;
6
6
  * @param newProvider
7
7
  */
8
8
  export function registerTranslationProvider(newProvider) {
9
- provider = newProvider;
9
+ provider = newProvider;
10
10
  }
11
11
  /**
12
12
  * Translates the specified key with the according message.
@@ -15,7 +15,7 @@ export function registerTranslationProvider(newProvider) {
15
15
  * @returns the translated message.
16
16
  */
17
17
  export function trsl(key, params) {
18
- return provider?.trsl(key, params) ?? key;
18
+ return provider?.trsl(key, params) ?? key;
19
19
  }
20
20
  /**
21
21
  * Translates the specified key using pluralization.
@@ -27,5 +27,5 @@ export function trsl(key, params) {
27
27
  * @see trsl
28
28
  */
29
29
  export function trslc(key, count, params) {
30
- return provider?.trslc(key, count, params) ?? key;
31
- }
30
+ return provider?.trslc(key, count, params) ?? key;
31
+ }
package/index.d.ts CHANGED
@@ -1,66 +1,2 @@
1
- import NAlert from './components/NAlert';
2
- export { NAlert };
3
- import NBadge from './components/NBadge';
4
- export { NBadge };
5
- import NBreadcrumb from './components/NBreadcrub';
6
- export { NBreadcrumb };
7
- import NButton from './components/NButton';
8
- export { NButton };
9
- import NCheckbox from './components/NCheckbox';
10
- export { NCheckbox };
11
- import NCheckboxLabel from './components/NCheckboxLabel';
12
- export { NCheckboxLabel };
13
- import NCrudModal from './components/NCrudModal';
14
- export { NCrudModal };
15
- import NDialog from './components/NDialog';
16
- export { NDialog };
17
- import NDropdown from './components/NDropdown';
18
- export { NDropdown };
19
- import NDropzone from './components/NDropzone';
20
- export { NDropzone };
21
- import NForm from './components/NForm';
22
- export { NForm };
23
- import NFormModal from './components/NFormModal';
24
- export { NFormModal };
25
- import NIconButton from './components/NIconButton';
26
- export { NIconButton };
27
- import NInput from './components/NInput';
28
- export { NInput };
29
- import NInputPhone from './components/NInputPhone';
30
- export { NInputPhone };
31
- import NInputSelect from './components/NInputSelect';
32
- export { NInputSelect };
33
- import NInputSuggestion from './components/NInputSuggestion';
34
- export { NInputSuggestion };
35
- import NLink from './components/NLink';
36
- export { NLink };
37
- import NList from './components/NList';
38
- export { NList };
39
- import NLoadingIndicator from './components/NLoadingIndicator';
40
- export { NLoadingIndicator };
41
- import NModal from './components/NModal';
42
- export { NModal };
43
- import NPagination from './components/NPagination';
44
- export { NPagination };
45
- import NSearchbar from './components/NSearchbar';
46
- export { NSearchbar };
47
- import NSearchbarList from './components/NSearchbarList';
48
- export { NSearchbarList };
49
- import NSelect from './components/NSelect';
50
- export { NSelect };
51
- import NSuggestionList from './components/NSuggestionList';
52
- export { NSuggestionList };
53
- import NTable from './components/NTable';
54
- export { NTable };
55
- import NTableAction from './components/NTableAction';
56
- export { NTableAction };
57
- import NTextArea from './components/NTextArea';
58
- export { NTextArea };
59
- import NTooltip from './components/NTooltip';
60
- export { NTooltip };
61
- import NValInput from './components/NValInput';
62
- export { NValInput };
63
- import { type ValidatedForm, createValidatedForm } from './components/ValidatedForm';
64
- export { ValidatedForm, createValidatedForm };
65
1
  import { createComponent, createView, createProps } from './utils/component';
66
2
  export { createComponent, createView, createProps };
package/index.js CHANGED
@@ -1,67 +1,2 @@
1
- // All components are directly available via the entry point
2
- import NAlert from './components/NAlert';
3
- export { NAlert };
4
- import NBadge from './components/NBadge';
5
- export { NBadge };
6
- import NBreadcrumb from './components/NBreadcrub';
7
- export { NBreadcrumb };
8
- import NButton from './components/NButton';
9
- export { NButton };
10
- import NCheckbox from './components/NCheckbox';
11
- export { NCheckbox };
12
- import NCheckboxLabel from './components/NCheckboxLabel';
13
- export { NCheckboxLabel };
14
- import NCrudModal from './components/NCrudModal';
15
- export { NCrudModal };
16
- import NDialog from './components/NDialog';
17
- export { NDialog };
18
- import NDropdown from './components/NDropdown';
19
- export { NDropdown };
20
- import NDropzone from './components/NDropzone';
21
- export { NDropzone };
22
- import NForm from './components/NForm';
23
- export { NForm };
24
- import NFormModal from './components/NFormModal';
25
- export { NFormModal };
26
- import NIconButton from './components/NIconButton';
27
- export { NIconButton };
28
- import NInput from './components/NInput';
29
- export { NInput };
30
- import NInputPhone from './components/NInputPhone';
31
- export { NInputPhone };
32
- import NInputSelect from './components/NInputSelect';
33
- export { NInputSelect };
34
- import NInputSuggestion from './components/NInputSuggestion';
35
- export { NInputSuggestion };
36
- import NLink from './components/NLink';
37
- export { NLink };
38
- import NList from './components/NList';
39
- export { NList };
40
- import NLoadingIndicator from './components/NLoadingIndicator';
41
- export { NLoadingIndicator };
42
- import NModal from './components/NModal';
43
- export { NModal };
44
- import NPagination from './components/NPagination';
45
- export { NPagination };
46
- import NSearchbar from './components/NSearchbar';
47
- export { NSearchbar };
48
- import NSearchbarList from './components/NSearchbarList';
49
- export { NSearchbarList };
50
- import NSelect from './components/NSelect';
51
- export { NSelect };
52
- import NSuggestionList from './components/NSuggestionList';
53
- export { NSuggestionList };
54
- import NTable from './components/NTable';
55
- export { NTable };
56
- import NTableAction from './components/NTableAction';
57
- export { NTableAction };
58
- import NTextArea from './components/NTextArea';
59
- export { NTextArea };
60
- import NTooltip from './components/NTooltip';
61
- export { NTooltip };
62
- import NValInput from './components/NValInput';
63
- export { NValInput };
64
- import { createValidatedForm } from './components/ValidatedForm';
65
- export { createValidatedForm };
66
1
  import { createComponent, createView, createProps } from './utils/component';
67
- export { createComponent, createView, createProps };
2
+ export { createComponent, createView, createProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naptics/vue-collection",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "main": "./index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,10 +1,10 @@
1
1
  import { computed, ref } from 'vue';
2
2
  export const breakpoints = {
3
- sm: 640,
4
- md: 768,
5
- lg: 1024,
6
- xl: 1280,
7
- '2xl': 1536
3
+ sm: 640,
4
+ md: 768,
5
+ lg: 1024,
6
+ xl: 1280,
7
+ '2xl': 1536,
8
8
  };
9
9
  export const bodyWidth = ref(document.body.clientWidth);
10
10
  /**
@@ -12,26 +12,26 @@ export const bodyWidth = ref(document.body.clientWidth);
12
12
  * It sets a `window.onresize` listener.
13
13
  */
14
14
  export function addDocumentResizeEventListener() {
15
- window.onresize = () => {
16
- bodyWidth.value = document.body.clientWidth;
17
- };
15
+ window.onresize = () => {
16
+ bodyWidth.value = document.body.clientWidth;
17
+ };
18
18
  }
19
19
  export function isWidthBreakpoint(breakpoint) {
20
- switch (breakpoint) {
21
- case 'sm':
22
- return isWidthSm;
23
- case 'md':
24
- return isWidthMd;
25
- case 'lg':
26
- return isWidthLg;
27
- case 'xl':
28
- return isWidthXl;
29
- case '2xl':
30
- return isWidth2xl;
31
- }
20
+ switch (breakpoint) {
21
+ case 'sm':
22
+ return isWidthSm;
23
+ case 'md':
24
+ return isWidthMd;
25
+ case 'lg':
26
+ return isWidthLg;
27
+ case 'xl':
28
+ return isWidthXl;
29
+ case '2xl':
30
+ return isWidth2xl;
31
+ }
32
32
  }
33
33
  export const isWidth2xl = computed(() => bodyWidth.value > breakpoints['2xl']);
34
34
  export const isWidthXl = computed(() => bodyWidth.value > breakpoints.xl);
35
35
  export const isWidthLg = computed(() => bodyWidth.value > breakpoints.lg);
36
36
  export const isWidthMd = computed(() => bodyWidth.value > breakpoints.md);
37
- export const isWidthSm = computed(() => bodyWidth.value > breakpoints.sm);
37
+ export const isWidthSm = computed(() => bodyWidth.value > breakpoints.sm);
@@ -1,4 +1,4 @@
1
- import { defineComponent, reactive, toRef } from 'vue';
1
+ import { defineComponent, reactive, toRef, } from 'vue';
2
2
  /**
3
3
  * Components should be created using this helper function.
4
4
  * It only takes three arguments, the name and the props of the component and the setup function.
@@ -10,12 +10,7 @@ import { defineComponent, reactive, toRef } from 'vue';
10
10
  * @returns the created vue-component.
11
11
  */
12
12
  export function createComponent(name, props, setup) {
13
- return defineComponent({
14
- name,
15
- props,
16
- emits: [],
17
- setup
18
- });
13
+ return defineComponent({ name, props, emits: [], setup });
19
14
  }
20
15
  /**
21
16
  * Views should be created using this helper function. Views are special components, which don't have props.
@@ -26,11 +21,7 @@ export function createComponent(name, props, setup) {
26
21
  * @returns the created vue-component.
27
22
  */
28
23
  export function createView(name, setup) {
29
- return defineComponent({
30
- name,
31
- emits: [],
32
- setup: (props, context) => setup(context)
33
- });
24
+ return defineComponent({ name, emits: [], setup: (props, context) => setup(context) });
34
25
  }
35
26
  /**
36
27
  * If props are specified outside of the {@link createComponent}
@@ -40,7 +31,7 @@ export function createView(name, setup) {
40
31
  * @returns the created props, with correct typing.
41
32
  */
42
33
  export function createProps(props) {
43
- return props;
34
+ return props;
44
35
  }
45
36
  /**
46
37
  * Extracts props from another prop object and returns a reactive object with the specified props.
@@ -53,7 +44,8 @@ export function createProps(props) {
53
44
  * console.log(childProps) // { title: 'hi' }
54
45
  */
55
46
  export function extractProps(props, ...keys) {
56
- const partial = {};
57
- for (const key of keys) partial[key] = toRef(props, key);
58
- return reactive(partial);
59
- }
47
+ const partial = {};
48
+ for (const key of keys)
49
+ partial[key] = toRef(props, key);
50
+ return reactive(partial);
51
+ }
package/utils/deferred.js CHANGED
@@ -3,15 +3,15 @@
3
3
  * @returns promise, resolve and reject
4
4
  */
5
5
  export function deferred() {
6
- let resolve;
7
- let reject;
8
- const promise = new Promise((_resolve, _reject) => {
9
- resolve = _resolve;
10
- reject = _reject;
11
- });
12
- return {
13
- promise,
14
- resolve,
15
- reject
16
- };
17
- }
6
+ let resolve;
7
+ let reject;
8
+ const promise = new Promise((_resolve, _reject) => {
9
+ resolve = _resolve;
10
+ reject = _reject;
11
+ });
12
+ return {
13
+ promise,
14
+ resolve,
15
+ reject,
16
+ };
17
+ }
@@ -6,8 +6,11 @@ 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
- const filtered = array.filter(item => item.id === id);
10
- if (filtered.length > 0) return filtered[0];else return undefined;
9
+ const filtered = array.filter(item => item.id === id);
10
+ if (filtered.length > 0)
11
+ return filtered[0];
12
+ else
13
+ return undefined;
11
14
  }
12
15
  /**
13
16
  * Checks if the given array contains an item with the `id`.
@@ -16,11 +19,11 @@ function find(array, id) {
16
19
  * @returns `true` if there is at least one item in the array with the given `id`.
17
20
  */
18
21
  function contains(array, id) {
19
- return find(array, id) !== undefined;
22
+ return find(array, id) !== undefined;
20
23
  }
21
24
  function insertSingle(baseArray, insertItem) {
22
- const index = baseArray.findIndex(item => item.id === insertItem.id);
23
- index === -1 ? baseArray.push(insertItem) : baseArray.splice(index, 1, insertItem);
25
+ const index = baseArray.findIndex(item => item.id === insertItem.id);
26
+ index === -1 ? baseArray.push(insertItem) : baseArray.splice(index, 1, insertItem);
24
27
  }
25
28
  /**
26
29
  * Inserts the items into the given array, replacing items with the same `id`.
@@ -31,8 +34,8 @@ function insertSingle(baseArray, insertItem) {
31
34
  * @returns The reference to the same array, which was passed.
32
35
  */
33
36
  function insert(array, ...insertItems) {
34
- insertItems.forEach(item => insertSingle(array, item));
35
- return array;
37
+ insertItems.forEach(item => insertSingle(array, item));
38
+ return array;
36
39
  }
37
40
  /**
38
41
  * Removes all items with the specified `ids` from the given array.
@@ -41,14 +44,17 @@ function insert(array, ...insertItems) {
41
44
  * @returns The reference to the same array, which was passed.
42
45
  */
43
46
  function remove(array, ...ids) {
44
- ids.forEach(id => {
45
- let noMatches = false;
46
- while (!noMatches) {
47
- const index = array.findIndex(item => item.id === id);
48
- if (index != -1) array.splice(index, 1);else noMatches = true;
49
- }
50
- });
51
- return array;
47
+ ids.forEach(id => {
48
+ let noMatches = false;
49
+ while (!noMatches) {
50
+ const index = array.findIndex(item => item.id === id);
51
+ if (index != -1)
52
+ array.splice(index, 1);
53
+ else
54
+ noMatches = true;
55
+ }
56
+ });
57
+ return array;
52
58
  }
53
59
  /**
54
60
  * Compares the two arrays and checks if they both have
@@ -58,19 +64,15 @@ function remove(array, ...ids) {
58
64
  * @returns `true` if the arrays contain item with the same `ids` in the same order.
59
65
  */
60
66
  function areSameArrays(first, second) {
61
- if (first.length != second.length) return false;
62
- for (let i = 0; i < first.length; i++) {
63
- if (first[i]?.id !== second[i]?.id) return false;
64
- }
65
- return true;
67
+ if (first.length != second.length)
68
+ return false;
69
+ for (let i = 0; i < first.length; i++) {
70
+ if (first[i]?.id !== second[i]?.id)
71
+ return false;
72
+ }
73
+ return true;
66
74
  }
67
75
  /**
68
76
  * This object contains utility functions to deal with {@link Identifiable} objects.
69
77
  */
70
- export const Id = markReadonly({
71
- find,
72
- contains,
73
- insert,
74
- remove,
75
- areSameArrays
76
- });
78
+ export const Id = markReadonly({ find, contains, insert, remove, areSameArrays });
@@ -5,7 +5,10 @@
5
5
  * @see maxLengthSplitCenter
6
6
  */
7
7
  export function maxLength(input, maxLength) {
8
- if (input && input.length > maxLength) return `${input.substring(0, maxLength - 3).trim()}...`;else return input || '';
8
+ if (input && input.length > maxLength)
9
+ return `${input.substring(0, maxLength - 3).trim()}...`;
10
+ else
11
+ return input || '';
9
12
  }
10
13
  /**
11
14
  * Returns a shortened string with '...' in the center of the string if it is longer than the given `maxLength`.
@@ -14,10 +17,12 @@ export function maxLength(input, maxLength) {
14
17
  * @see maxLength
15
18
  */
16
19
  export function maxLengthSplitCenter(input, maxLength) {
17
- if (input && input.length > maxLength) {
18
- const chars = maxLength - 3;
19
- const charsAtStart = Math.ceil(chars / 2);
20
- const charsAtEnd = Math.floor(chars / 2);
21
- return `${input.substring(0, charsAtStart).trim()}...${input.substring(input.length - charsAtEnd).trim()}`;
22
- } else return input || '';
23
- }
20
+ if (input && input.length > maxLength) {
21
+ const chars = maxLength - 3;
22
+ const charsAtStart = Math.ceil(chars / 2);
23
+ const charsAtEnd = Math.floor(chars / 2);
24
+ return `${input.substring(0, charsAtStart).trim()}...${input.substring(input.length - charsAtEnd).trim()}`;
25
+ }
26
+ else
27
+ return input || '';
28
+ }
package/utils/tailwind.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/utils/utils.js CHANGED
@@ -1,12 +1,12 @@
1
1
  export function markReadonly(object) {
2
- return object;
2
+ return object;
3
3
  }
4
4
  let currentId = 1;
5
5
  /**
6
6
  * Generates and returns a non random but unique id.
7
7
  */
8
8
  export function uniqueId() {
9
- return currentId++;
9
+ return currentId++;
10
10
  }
11
11
  /**
12
12
  * Determines if a value is not null or undefined.
@@ -14,7 +14,7 @@ export function uniqueId() {
14
14
  * @returns `true` if the value is anything but `null` or `undefined`.
15
15
  */
16
16
  export function notNullish(value) {
17
- return value !== null && value !== undefined;
17
+ return value !== null && value !== undefined;
18
18
  }
19
19
  /**
20
20
  * Determines if a value is null or undefined.
@@ -22,5 +22,5 @@ export function notNullish(value) {
22
22
  * @returns `true` if the value is `null` or `undefined`.
23
23
  */
24
24
  export function isNullish(value) {
25
- return value === null || value === undefined;
26
- }
25
+ return value === null || value === undefined;
26
+ }