@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/utils/vModel.js CHANGED
@@ -8,54 +8,54 @@
8
8
  * @returns An object containing the value-property and the update-function.
9
9
  */
10
10
  export function vModelProps(propType) {
11
- return {
12
- /**
13
- * The value of the component.
14
- */
15
- value: propType,
16
- /**
17
- * This will be called, when the value of the component has changed.
18
- */
19
- onUpdateValue: Function
20
- };
11
+ return {
12
+ /**
13
+ * The value of the component.
14
+ */
15
+ value: propType,
16
+ /**
17
+ * This will be called, when the value of the component has changed.
18
+ */
19
+ onUpdateValue: Function,
20
+ };
21
21
  }
22
22
  /**
23
23
  * Creates props for a required `v-model` of the given type.
24
24
  * @see {@link vModelProps}
25
25
  */
26
26
  export function vModelRequiredProps(propType) {
27
- return {
28
- /**
29
- * The value of the component.
30
- */
31
- value: {
32
- type: propType,
33
- required: true
34
- },
35
- /**
36
- * This will be called, when the value of the component has changed.
37
- */
38
- onUpdateValue: Function
39
- };
27
+ return {
28
+ /**
29
+ * The value of the component.
30
+ */
31
+ value: {
32
+ type: propType,
33
+ required: true,
34
+ },
35
+ /**
36
+ * This will be called, when the value of the component has changed.
37
+ */
38
+ onUpdateValue: Function,
39
+ };
40
40
  }
41
41
  /**
42
42
  * Creates props for a `v-model` of the given type with a default value.
43
43
  * @see {@link vModelProps}
44
44
  */
45
45
  export function vModelDefaultProps(propType, defaultValue) {
46
- return {
47
- /**
48
- * The value of the component.
49
- */
50
- value: {
51
- type: propType,
52
- default: defaultValue
53
- },
54
- /**
55
- * This will be called, when the value of the component has changed.
56
- */
57
- onUpdateValue: Function
58
- };
46
+ return {
47
+ /**
48
+ * The value of the component.
49
+ */
50
+ value: {
51
+ type: propType,
52
+ default: defaultValue,
53
+ },
54
+ /**
55
+ * This will be called, when the value of the component has changed.
56
+ */
57
+ onUpdateValue: Function,
58
+ };
59
59
  }
60
60
  /**
61
61
  * Uses the given `ref` as a `v-model`, to create a two-way binding with the `ref`.
@@ -63,12 +63,12 @@ export function vModelDefaultProps(propType, defaultValue) {
63
63
  * @returns An object of type {@link VModel}, which connects the `ref` to the `v-model`.
64
64
  */
65
65
  export function vModelForRef(ref) {
66
- return {
67
- value: ref.value,
68
- onUpdateValue: newValue => {
69
- ref.value = newValue;
70
- }
71
- };
66
+ return {
67
+ value: ref.value,
68
+ onUpdateValue: (newValue) => {
69
+ ref.value = newValue;
70
+ },
71
+ };
72
72
  }
73
73
  /**
74
74
  * This creates a `v-model` for a property of an object. The property of the object is taken as the
@@ -93,15 +93,12 @@ export function vModelForRef(ref) {
93
93
  * ```
94
94
  */
95
95
  export function vModelForObjectProperty(object, key, onUpdate) {
96
- return {
97
- value: object[key],
98
- onUpdateValue: newValue => {
99
- onUpdate?.({
100
- ...object,
101
- [key]: newValue
102
- });
103
- }
104
- };
96
+ return {
97
+ value: object[key],
98
+ onUpdateValue: (newValue) => {
99
+ onUpdate?.({ ...object, [key]: newValue });
100
+ },
101
+ };
105
102
  }
106
103
  /**
107
104
  * This creates a `v-model` which operates on one property of a parent `v-model`. It takes the value of
@@ -133,15 +130,12 @@ export function vModelForObjectProperty(object, key, onUpdate) {
133
130
  * ```
134
131
  */
135
132
  export function vModelForVModelProperty(vModel, key) {
136
- return {
137
- value: vModel.value[key],
138
- onUpdateValue: newValue => {
139
- vModel.onUpdateValue?.({
140
- ...vModel.value,
141
- [key]: newValue
142
- });
143
- }
144
- };
133
+ return {
134
+ value: vModel.value[key],
135
+ onUpdateValue: (newValue) => {
136
+ vModel.onUpdateValue?.({ ...vModel.value, [key]: newValue });
137
+ },
138
+ };
145
139
  }
146
140
  /**
147
141
  * This function does the same thing as {@link vModelForVModelProperty},
@@ -174,15 +168,12 @@ export function vModelForVModelProperty(vModel, key) {
174
168
  * ```
175
169
  */
176
170
  export function vModelForVModelPropertyMapType(vModel, key, mapType) {
177
- return {
178
- value: vModel.value[key],
179
- onUpdateValue: newValue => {
180
- vModel.onUpdateValue?.({
181
- ...vModel.value,
182
- [key]: mapType(newValue)
183
- });
184
- }
185
- };
171
+ return {
172
+ value: vModel.value[key],
173
+ onUpdateValue: (newValue) => {
174
+ vModel.onUpdateValue?.({ ...vModel.value, [key]: mapType(newValue) });
175
+ },
176
+ };
186
177
  }
187
178
  /**
188
179
  * Creates an array of `v-models`, one for every element of an array. All changes in
@@ -209,16 +200,16 @@ export function vModelForVModelPropertyMapType(vModel, key, mapType) {
209
200
  * ```
210
201
  */
211
202
  export function vModelsForArray(array, onUpdate) {
212
- return array.map((entry, index) => ({
213
- value: entry,
214
- onUpdateValue: entry => {
215
- const newArray = [...array];
216
- newArray[index] = entry;
217
- onUpdate?.(newArray);
218
- },
219
- remove: () => {
220
- const newArray = [...array.slice(0, index), ...array.slice(index + 1)];
221
- onUpdate?.(newArray);
222
- }
223
- }));
224
- }
203
+ return array.map((entry, index) => ({
204
+ value: entry,
205
+ onUpdateValue: (entry) => {
206
+ const newArray = [...array];
207
+ newArray[index] = entry;
208
+ onUpdate?.(newArray);
209
+ },
210
+ remove: () => {
211
+ const newArray = [...array.slice(0, index), ...array.slice(index + 1)];
212
+ onUpdate?.(newArray);
213
+ },
214
+ }));
215
+ }
@@ -3,22 +3,17 @@ import { trsl } from '../i18n';
3
3
  * Creates a valid result.
4
4
  */
5
5
  export function validResult() {
6
- return {
7
- isValid: true
8
- };
6
+ return { isValid: true };
9
7
  }
10
8
  /**
11
9
  * Creates an invalid result with the provided error message.
12
10
  */
13
11
  export function invalidResult(errorMessage) {
14
- return {
15
- isValid: false,
16
- errorMessage
17
- };
12
+ return { isValid: false, errorMessage };
18
13
  }
19
14
  const TRANSLATION_KEY_BASE = 'vue-collection.validation.rules';
20
15
  function invalidResultInternal(key, params) {
21
- return invalidResult(trsl(`${TRANSLATION_KEY_BASE}.${key}`, params));
16
+ return invalidResult(trsl(`${TRANSLATION_KEY_BASE}.${key}`, params));
22
17
  }
23
18
  /**
24
19
  * Validates a given input with the specified rules.
@@ -30,11 +25,12 @@ function invalidResultInternal(key, params) {
30
25
  * @returns an object containing the result of the validation.
31
26
  */
32
27
  export function validate(input, rules) {
33
- for (const rule of rules) {
34
- const validationResult = rule(input);
35
- if (!validationResult.isValid) return validationResult;
36
- }
37
- return validResult();
28
+ for (const rule of rules) {
29
+ const validationResult = rule(input);
30
+ if (!validationResult.isValid)
31
+ return validationResult;
32
+ }
33
+ return validResult();
38
34
  }
39
35
  /*
40
36
  * ---------- Validation Rules ----------
@@ -43,14 +39,20 @@ export function validate(input, rules) {
43
39
  * This rule expects the trimmed input-value to be truthy.
44
40
  */
45
41
  export const required = input => {
46
- const trimmed = input?.trim();
47
- if (trimmed) return validResult();else return invalidResultInternal('required');
42
+ const trimmed = input?.trim();
43
+ if (trimmed)
44
+ return validResult();
45
+ else
46
+ return invalidResultInternal('required');
48
47
  };
49
48
  /**
50
49
  * This rule expects the input to be an integer.
51
50
  */
52
51
  export const integer = input => {
53
- if (!input || Number.isInteger(+input)) return validResult();else return invalidResultInternal('integer');
52
+ if (!input || Number.isInteger(+input))
53
+ return validResult();
54
+ else
55
+ return invalidResultInternal('integer');
54
56
  };
55
57
  /**
56
58
  * This rule expects the input to be in the specified length range. An empty input
@@ -59,18 +61,17 @@ export const integer = input => {
59
61
  * @param max The maximum length of the string.
60
62
  */
61
63
  export function length(min, max) {
62
- return input => {
63
- if (!input) return validResult();
64
- if (min !== undefined && max !== undefined && !(min <= input.length && input.length <= max)) return invalidResultInternal('length.min-max', {
65
- min,
66
- max
67
- });else if (min !== undefined && !(min <= input.length)) return invalidResultInternal('length.min', {
68
- min
69
- });else if (max !== undefined && !(input.length <= max)) return invalidResultInternal('length.max', {
70
- max
71
- });
72
- return validResult();
73
- };
64
+ return input => {
65
+ if (!input)
66
+ return validResult();
67
+ if (min !== undefined && max !== undefined && !(min <= input.length && input.length <= max))
68
+ return invalidResultInternal('length.min-max', { min, max });
69
+ else if (min !== undefined && !(min <= input.length))
70
+ return invalidResultInternal('length.min', { min });
71
+ else if (max !== undefined && !(input.length <= max))
72
+ return invalidResultInternal('length.max', { max });
73
+ return validResult();
74
+ };
74
75
  }
75
76
  /**
76
77
  * This rule expects the input to be a number in the specified range.
@@ -78,34 +79,50 @@ export function length(min, max) {
78
79
  * @param max the upper bound, if `undefined` there is no upper bound.
79
80
  */
80
81
  export function numberRange(min, max) {
81
- return input => {
82
- if (!input) return validResult();
83
- const parsed = Number.parseFloat(input);
84
- if (Number.isNaN(parsed)) return invalidResultInternal('number-range.nan');
85
- if (min !== undefined && max !== undefined && !(min <= parsed && parsed <= max)) return invalidResultInternal('number-range.min-max', {
86
- min,
87
- max
88
- });else if (min !== undefined && !(min <= parsed)) return invalidResultInternal('number-range.min', {
89
- min
90
- });else if (max !== undefined && !(parsed <= max)) return invalidResultInternal('number-range.max', {
91
- max
92
- });
93
- return validResult();
94
- };
82
+ return input => {
83
+ if (!input)
84
+ return validResult();
85
+ const parsed = Number.parseFloat(input);
86
+ if (Number.isNaN(parsed))
87
+ return invalidResultInternal('number-range.nan');
88
+ if (min !== undefined && max !== undefined && !(min <= parsed && parsed <= max))
89
+ return invalidResultInternal('number-range.min-max', { min, max });
90
+ else if (min !== undefined && !(min <= parsed))
91
+ return invalidResultInternal('number-range.min', { min });
92
+ else if (max !== undefined && !(parsed <= max))
93
+ return invalidResultInternal('number-range.max', { max });
94
+ return validResult();
95
+ };
95
96
  }
96
97
  export const VALIDATION_FORMAT_EMAIL = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/;
97
98
  /**
98
99
  * This rule expects the input-value to be a valid email adress matching {@link VALIDATION_FORMAT_EMAIL}.
99
100
  */
100
101
  export const email = input => {
101
- if (!input || VALIDATION_FORMAT_EMAIL.test(input)) return validResult();else return invalidResultInternal('email');
102
+ if (!input || VALIDATION_FORMAT_EMAIL.test(input))
103
+ return validResult();
104
+ else
105
+ return invalidResultInternal('email');
102
106
  };
103
107
  export const VALIDATION_FORMAT_PASSWORD = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+\-=!*()@%&?]).{8,}$/;
104
108
  /**
105
109
  * This rule expects the input-value to be a password matching {@link VALIDATION_FORMAT_PASSWORD}.
106
110
  */
107
111
  export const password = input => {
108
- if (!input || VALIDATION_FORMAT_PASSWORD.test(input)) return validResult();else if (input.length < 8) return invalidResultInternal('password.to-short');else if (!/[a-z]+/.test(input)) return invalidResultInternal('password.no-lowercase');else if (!/[A-Z]+/.test(input)) return invalidResultInternal('password.no-uppercase');else if (!/\d+/.test(input)) return invalidResultInternal('password.no-digits');else if (!/[#$^+\-=!*()@%&?]+/.test(input)) return invalidResultInternal('password.no-special-chars');else return invalidResultInternal('password.unknown');
112
+ if (!input || VALIDATION_FORMAT_PASSWORD.test(input))
113
+ return validResult();
114
+ else if (input.length < 8)
115
+ return invalidResultInternal('password.to-short');
116
+ else if (!/[a-z]+/.test(input))
117
+ return invalidResultInternal('password.no-lowercase');
118
+ else if (!/[A-Z]+/.test(input))
119
+ return invalidResultInternal('password.no-uppercase');
120
+ else if (!/\d+/.test(input))
121
+ return invalidResultInternal('password.no-digits');
122
+ else if (!/[#$^+\-=!*()@%&?]+/.test(input))
123
+ return invalidResultInternal('password.no-special-chars');
124
+ else
125
+ return invalidResultInternal('password.unknown');
109
126
  };
110
127
  /**
111
128
  * This rule expects the input-value to match another (input-) value.
@@ -114,27 +131,36 @@ export const password = input => {
114
131
  * @param other the other value to match
115
132
  */
116
133
  export function matches(other) {
117
- return input => {
118
- if (input === other) return validResult();else return invalidResultInternal('matches');
119
- };
134
+ return input => {
135
+ if (input === other)
136
+ return validResult();
137
+ else
138
+ return invalidResultInternal('matches');
139
+ };
120
140
  }
121
141
  /**
122
142
  * This rule expects the input-value to match one option in an array.
123
143
  * @param options the options which the input can match
124
144
  */
125
145
  export function option(options) {
126
- return input => {
127
- if (!input || options.includes(input || '')) return validResult();else return invalidResultInternal('option');
128
- };
146
+ return input => {
147
+ if (!input || options.includes(input || ''))
148
+ return validResult();
149
+ else
150
+ return invalidResultInternal('option');
151
+ };
129
152
  }
130
153
  /**
131
154
  * This rule expects the input-value to match the regex pattern
132
155
  * @param pattern the pattern the input should match.
133
156
  */
134
157
  export function regex(pattern) {
135
- return input => {
136
- if (!input || pattern.test(input || '')) return validResult();else return invalidResultInternal('regex');
137
- };
158
+ return input => {
159
+ if (!input || pattern.test(input || ''))
160
+ return validResult();
161
+ else
162
+ return invalidResultInternal('regex');
163
+ };
138
164
  }
139
165
  /**
140
166
  * This rule can be used if the validation logic happens somewhere else.
@@ -143,5 +169,5 @@ export function regex(pattern) {
143
169
  * Like always, a falsy input is always valid to not interefere with the {@link required} rule.
144
170
  */
145
171
  export function external(isValid, errorMessage) {
146
- return input => !input || isValid ? validResult() : invalidResult(errorMessage);
147
- }
172
+ return input => (!input || isValid ? validResult() : invalidResult(errorMessage));
173
+ }
package/utils/vue.js CHANGED
@@ -5,11 +5,9 @@ import { watch } from 'vue';
5
5
  * @param updater the updater funtion which provides the updates
6
6
  */
7
7
  export function updateWith(ref, updater) {
8
- watch(updater, newValue => {
9
- ref.value = newValue;
10
- }, {
11
- immediate: true
12
- });
8
+ watch(updater, newValue => {
9
+ ref.value = newValue;
10
+ }, { immediate: true });
13
11
  }
14
12
  /**
15
13
  * Conveience function to create a watcher for a ref
@@ -17,5 +15,5 @@ export function updateWith(ref, updater) {
17
15
  * @param onChange the function, which is executed on change of a value
18
16
  */
19
17
  export function watchRef(ref, onChange) {
20
- watch(() => ref.value, onChange);
21
- }
18
+ watch(() => ref.value, onChange);
19
+ }
@@ -1,69 +0,0 @@
1
- import { createComponent, createProps } from '../utils/component';
2
- import { CheckCircleIcon, ExclamationCircleIcon, InformationCircleIcon, XMarkIcon } from '@heroicons/vue/24/solid';
3
- import { computed } from 'vue';
4
- import NIconButton from './NIconButton';
5
- import NLoadingIndicator from './NLoadingIndicator';
6
- export const nAlertProps = createProps({
7
- /**
8
- * The variant of the alert. This defines its color and icon.
9
- */
10
- variant: {
11
- type: String,
12
- default: 'success',
13
- },
14
- /**
15
- * The text of the alert.
16
- */
17
- text: String,
18
- /**
19
- * If set to `true` the X-button of the alert is hidden.
20
- */
21
- hideX: Boolean,
22
- /**
23
- * This is called, when the X-button is clicked.
24
- */
25
- onDismiss: Function,
26
- });
27
- /**
28
- * The `NAlert` is a fully styled alert with multiple variants.
29
- * It can be used as a normal blocking element or as part of an alert queue.
30
- */
31
- export default createComponent('NAlert', nAlertProps, props => {
32
- const variant = computed(() => VARIANTS[props.variant]);
33
- return () => (<div class={`rounded-md p-3 shadow-lg bg-${variant.value.color}-50`}>
34
- <div class="flex items-center">
35
- <div class="flex flex-shrink-0 items-center">{variant.value.icon()}</div>
36
-
37
- <div class="ml-3 flex-grow">
38
- <p class={`text-sm font-medium text-${variant.value.color}-900`}>{props.text}</p>
39
- </div>
40
-
41
- {!props.hideX && (<div class="flex items-center flex-shrink-0 ml-3">
42
- <NIconButton color={variant.value.color} size={5} icon={XMarkIcon} onClick={props.onDismiss}/>
43
- </div>)}
44
- </div>
45
- </div>);
46
- });
47
- const icon = (icon, color) => () => <icon class={`h-5 w-5 text-${color}-500`}/>;
48
- const VARIANTS = {
49
- success: {
50
- icon: icon(CheckCircleIcon, 'green'),
51
- color: 'green',
52
- },
53
- info: {
54
- icon: icon(InformationCircleIcon, 'blue'),
55
- color: 'blue',
56
- },
57
- warning: {
58
- icon: icon(ExclamationCircleIcon, 'yellow'),
59
- color: 'yellow',
60
- },
61
- error: {
62
- icon: icon(ExclamationCircleIcon, 'red'),
63
- color: 'red',
64
- },
65
- loading: {
66
- icon: () => <NLoadingIndicator color="blue" size={7} shade={500}/>,
67
- color: 'blue',
68
- },
69
- };
@@ -1,58 +0,0 @@
1
- import { createComponent, createProps } from '../utils/component';
2
- import NTooltip, { mapTooltipProps, nToolTipPropsForImplementor } from './NTooltip';
3
- export const nBadgeProps = createProps({
4
- /**
5
- * The text of the badge. Can alternatively be passed in the default slot.
6
- */
7
- text: String,
8
- /**
9
- * The text size, a standard tailwind text-size class.
10
- */
11
- textSize: {
12
- type: String,
13
- default: 'text-sm',
14
- },
15
- /**
16
- * The color of the badge.
17
- */
18
- color: {
19
- type: String,
20
- default: 'primary',
21
- },
22
- /**
23
- * The background shade of the badge.
24
- */
25
- shade: {
26
- type: Number,
27
- default: 200,
28
- },
29
- /**
30
- * The text shade of the badge.
31
- */
32
- textShade: {
33
- type: Number,
34
- default: 900,
35
- },
36
- /**
37
- * If set to `true` the badges text is all-caps. Default is `true`.
38
- */
39
- allCaps: {
40
- type: Boolean,
41
- default: true,
42
- },
43
- ...nToolTipPropsForImplementor,
44
- });
45
- /**
46
- * The `NBadge` is a styled element to wrap a text.
47
- */
48
- export default createComponent('NBadge', nBadgeProps, (props, { slots }) => {
49
- return () => (<NTooltip {...mapTooltipProps(props)}>
50
- <div class={[
51
- 'px-2 py-1 rounded-md font-semibold shadow',
52
- `${props.textSize} bg-${props.color}-${props.shade} text-${props.color}-${props.textShade}`,
53
- props.allCaps ? 'uppercase' : '',
54
- ]}>
55
- {slots.default?.() || props.text}
56
- </div>
57
- </NTooltip>);
58
- });
@@ -1,64 +0,0 @@
1
- import { createComponent, createProps } from '../utils/component';
2
- import { ChevronRightIcon } from '@heroicons/vue/24/solid';
3
- import NLink from './NLink';
4
- export const nBreadcrumbProps = createProps({
5
- /**
6
- * The items of the breadcrumb.
7
- */
8
- items: {
9
- type: Array,
10
- default: () => [],
11
- },
12
- /**
13
- * The color of the breadcrumbs text and icons.
14
- */
15
- color: {
16
- type: String,
17
- default: 'primary',
18
- },
19
- /**
20
- * The text-size of the breadcrumb labels.
21
- */
22
- textSize: {
23
- type: String,
24
- default: 'text-base',
25
- },
26
- /**
27
- * The icon which is used as a seperator between two breadcrumb items.
28
- */
29
- icon: {
30
- type: Function,
31
- default: ChevronRightIcon,
32
- },
33
- /**
34
- * The size of the icon in tailwind units.
35
- */
36
- iconSize: {
37
- type: Number,
38
- default: 5,
39
- },
40
- /**
41
- * A slot the replace the breadcrumb labels.
42
- */
43
- item: Function,
44
- /**
45
- * A slot to replace the separators between the breadcrumb labels.
46
- * The passsed item is the item before the seperator.
47
- */
48
- seperator: Function,
49
- });
50
- /**
51
- * The `NBreadcrumb` is a styled breadcrumb which can be used as a navigation in hierarchical views.
52
- */
53
- export default createComponent('NBreadcrumb', nBreadcrumbProps, props => {
54
- return () => (<div class="flex flex-wrap items-center">
55
- {props.items.map((item, index) => (<>
56
- {props.item?.(item, index) || (<NLink textSize={props.textSize} route={item.route} color={props.color}>
57
- {item.label}
58
- </NLink>)}
59
-
60
- {index < props.items.length - 1 &&
61
- (props.seperator?.(item, index) || (<props.icon class={`mx-2 w-${props.iconSize} h-${props.iconSize} text-${props.color}-500`}/>))}
62
- </>))}
63
- </div>);
64
- });