@naptics/vue-collection 0.3.2 → 1.0.0-beta.1

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 (129) hide show
  1. package/eslint.config.cjs +0 -2
  2. package/package.json +31 -30
  3. package/postcss.config.js +1 -4
  4. package/src/demo/App.css +47 -3
  5. package/src/demo/components/ComponentSection.tsx +1 -1
  6. package/src/demo/views/NavigationView.tsx +1 -1
  7. package/src/demo/views/presentation/TooltipView.tsx +1 -1
  8. package/src/lib/components/NAlert.tsx +3 -3
  9. package/src/lib/components/NBadge.tsx +1 -1
  10. package/src/lib/components/NButton.tsx +6 -4
  11. package/src/lib/components/NCheckbox.tsx +2 -2
  12. package/src/lib/components/NDialog.tsx +2 -2
  13. package/src/lib/components/NDropdown.tsx +11 -9
  14. package/src/lib/components/NDropzone.tsx +4 -4
  15. package/src/lib/components/NIconButton.tsx +2 -2
  16. package/src/lib/components/NInput.tsx +1 -1
  17. package/src/lib/components/NLink.tsx +1 -1
  18. package/src/lib/components/NModal.tsx +4 -4
  19. package/src/lib/components/NPagination.css +4 -2
  20. package/src/lib/components/NPagination.tsx +1 -1
  21. package/src/lib/components/NSearchbar.tsx +1 -1
  22. package/src/lib/components/NSelect.tsx +1 -1
  23. package/src/lib/components/NSuggestionList.tsx +1 -1
  24. package/src/lib/components/NTable.css +2 -0
  25. package/src/lib/components/NTableAction.tsx +1 -1
  26. package/src/lib/components/NTextArea.tsx +1 -1
  27. package/src/lib/components/NTooltip.css +2 -0
  28. package/src/lib/components/NTooltip.tsx +1 -1
  29. package/src/lib/utils/component.tsx +1 -1
  30. package/tsconfig.lib.json +1 -0
  31. package/vite.config.ts +2 -0
  32. package/components/NAlert.d.ts +0 -29
  33. package/components/NAlert.js +0 -84
  34. package/components/NBadge.d.ts +0 -73
  35. package/components/NBadge.js +0 -64
  36. package/components/NBreadcrub.d.ts +0 -69
  37. package/components/NBreadcrub.js +0 -71
  38. package/components/NButton.d.ts +0 -64
  39. package/components/NButton.js +0 -72
  40. package/components/NCheckbox.d.ts +0 -20
  41. package/components/NCheckbox.js +0 -43
  42. package/components/NCheckboxLabel.d.ts +0 -26
  43. package/components/NCheckboxLabel.js +0 -42
  44. package/components/NCrudModal.d.ts +0 -118
  45. package/components/NCrudModal.js +0 -120
  46. package/components/NDialog.d.ts +0 -81
  47. package/components/NDialog.js +0 -161
  48. package/components/NDropdown.d.ts +0 -67
  49. package/components/NDropdown.js +0 -115
  50. package/components/NDropzone.d.ts +0 -61
  51. package/components/NDropzone.js +0 -218
  52. package/components/NForm.d.ts +0 -21
  53. package/components/NForm.js +0 -29
  54. package/components/NFormModal.d.ts +0 -75
  55. package/components/NFormModal.js +0 -59
  56. package/components/NIconButton.d.ts +0 -83
  57. package/components/NIconButton.js +0 -88
  58. package/components/NIconCircle.d.ts +0 -49
  59. package/components/NIconCircle.js +0 -67
  60. package/components/NInput.css +0 -11
  61. package/components/NInput.d.ts +0 -94
  62. package/components/NInput.js +0 -110
  63. package/components/NInputPhone.d.ts +0 -58
  64. package/components/NInputPhone.js +0 -47
  65. package/components/NInputSelect.d.ts +0 -103
  66. package/components/NInputSelect.js +0 -115
  67. package/components/NInputSuggestion.d.ts +0 -79
  68. package/components/NInputSuggestion.js +0 -64
  69. package/components/NLink.d.ts +0 -47
  70. package/components/NLink.js +0 -67
  71. package/components/NList.d.ts +0 -37
  72. package/components/NList.js +0 -40
  73. package/components/NLoadingIndicator.css +0 -46
  74. package/components/NLoadingIndicator.d.ts +0 -29
  75. package/components/NLoadingIndicator.js +0 -54
  76. package/components/NModal.d.ts +0 -133
  77. package/components/NModal.js +0 -232
  78. package/components/NPagination.css +0 -15
  79. package/components/NPagination.d.ts +0 -37
  80. package/components/NPagination.js +0 -105
  81. package/components/NSearchbar.d.ts +0 -39
  82. package/components/NSearchbar.js +0 -64
  83. package/components/NSearchbarList.d.ts +0 -33
  84. package/components/NSearchbarList.js +0 -41
  85. package/components/NSelect.d.ts +0 -82
  86. package/components/NSelect.js +0 -101
  87. package/components/NSuggestionList.d.ts +0 -153
  88. package/components/NSuggestionList.js +0 -160
  89. package/components/NTable.css +0 -3
  90. package/components/NTable.d.ts +0 -97
  91. package/components/NTable.js +0 -128
  92. package/components/NTableAction.d.ts +0 -30
  93. package/components/NTableAction.js +0 -50
  94. package/components/NTextArea.d.ts +0 -96
  95. package/components/NTextArea.js +0 -133
  96. package/components/NTooltip.css +0 -37
  97. package/components/NTooltip.d.ts +0 -152
  98. package/components/NTooltip.js +0 -241
  99. package/components/NValInput.d.ts +0 -159
  100. package/components/NValInput.js +0 -113
  101. package/components/ValidatedForm.d.ts +0 -39
  102. package/components/ValidatedForm.js +0 -35
  103. package/i18n/de/vue-collection.json +0 -58
  104. package/i18n/en/vue-collection.json +0 -58
  105. package/i18n/index.d.ts +0 -40
  106. package/i18n/index.js +0 -31
  107. package/index.d.ts +0 -2
  108. package/index.js +0 -2
  109. package/tailwind.config.js +0 -38
  110. package/utils/breakpoints.d.ts +0 -18
  111. package/utils/breakpoints.js +0 -40
  112. package/utils/component.d.ts +0 -57
  113. package/utils/component.js +0 -79
  114. package/utils/deferred.d.ts +0 -13
  115. package/utils/deferred.js +0 -17
  116. package/utils/identifiable.d.ts +0 -56
  117. package/utils/identifiable.js +0 -81
  118. package/utils/stringMaxLength.d.ts +0 -14
  119. package/utils/stringMaxLength.js +0 -23
  120. package/utils/tailwind.d.ts +0 -4
  121. package/utils/tailwind.js +0 -1
  122. package/utils/utils.d.ts +0 -47
  123. package/utils/utils.js +0 -56
  124. package/utils/vModel.d.ts +0 -182
  125. package/utils/vModel.js +0 -224
  126. package/utils/validation.d.ts +0 -90
  127. package/utils/validation.js +0 -147
  128. package/utils/vue.d.ts +0 -13
  129. package/utils/vue.js +0 -21
@@ -1,67 +0,0 @@
1
- import { createVNode as _createVNode } from "vue";
2
- import { createComponent } from '../utils/component';
3
- export const nIconCircleProps = {
4
- /**
5
- * The icon of the icon-circle.
6
- */
7
- icon: {
8
- type: Function,
9
- required: true
10
- },
11
- /**
12
- * The color of the icon-circle.
13
- */
14
- color: {
15
- type: String,
16
- default: 'primary'
17
- },
18
- /**
19
- * The size of the circle in "tailwind units" (4 px).
20
- * Tailwind classes are used for the size, so any number can be passed.
21
- * If the `iconSize` is not set, it will be adjusted automatically.
22
- */
23
- circleSize: Number,
24
- /**
25
- * The size of the icon in "tailwind units" (4 px).
26
- * No tailwind classes are used for the size, so any number can be passed.
27
- * If the `circleSize` is not set, it will be adjusted automatically.
28
- */
29
- iconSize: Number,
30
- /**
31
- * The shade of the icon.
32
- */
33
- iconShade: {
34
- type: Number,
35
- default: 600
36
- },
37
- /**
38
- * The shade of the background.
39
- */
40
- bgShade: {
41
- type: Number,
42
- default: 100
43
- }
44
- };
45
- const DEFAULT_CIRCLE_SIZE = 16;
46
- const SCALING_FACTOR = 0.55;
47
- /**
48
- * The `NIconCircle` is an icon with a colored circle around it.
49
- */
50
- const Component = createComponent('NIconCircle', nIconCircleProps, props => {
51
- let circleSize = props.circleSize;
52
- let iconSize = props.iconSize;
53
- if (circleSize == null) {
54
- if (iconSize == null) circleSize = DEFAULT_CIRCLE_SIZE;else circleSize = iconSize / SCALING_FACTOR;
55
- }
56
- if (iconSize == null) iconSize = circleSize * SCALING_FACTOR;
57
- circleSize *= 4;
58
- iconSize *= 4;
59
- return () => _createVNode("div", {
60
- "class": ['flex items-center justify-center rounded-full', `bg-${props.color}-${props.bgShade}`],
61
- "style": `width: ${circleSize}px; height: ${circleSize}px`
62
- }, [_createVNode("div", {
63
- "class": `text-${props.color}-${props.iconShade}`,
64
- "style": `width: ${iconSize}px; height: ${iconSize}px`
65
- }, [_createVNode(props.icon, null, null)])]);
66
- });
67
- export { Component as NIconCircle, Component as default };
@@ -1,11 +0,0 @@
1
- /* Chrome, Safari, Edge, Opera */
2
- input::-webkit-outer-spin-button,
3
- input::-webkit-inner-spin-button {
4
- -webkit-appearance: none;
5
- margin: 0;
6
- }
7
-
8
- /* Firefox */
9
- input[type='number'] {
10
- -moz-appearance: textfield;
11
- }
@@ -1,94 +0,0 @@
1
- import { type PropType } from 'vue';
2
- import './NInput.css';
3
- export declare const nInputProps: {
4
- readonly tooltipText: StringConstructor;
5
- readonly tooltipContent: PropType<() => JSX.Element>;
6
- readonly tooltipHide: BooleanConstructor;
7
- readonly tooltipShow: BooleanConstructor;
8
- readonly tooltipPlacement: {
9
- readonly type: PropType<import("./NTooltip").TooltipPlacement>;
10
- readonly default: "auto";
11
- };
12
- readonly tooltipMaxWidth: {
13
- readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
14
- readonly default: "max-w-xs";
15
- };
16
- readonly tooltipWrapperClass: StringConstructor;
17
- readonly tooltipContentClass: StringConstructor;
18
- readonly tooltipArrowClass: StringConstructor;
19
- readonly tooltipDelay: {
20
- readonly type: NumberConstructor;
21
- readonly default: 0;
22
- };
23
- /**
24
- * The name of the input. Is displayed as a label above the input.
25
- */
26
- readonly name: StringConstructor;
27
- /**
28
- * The placeholder of the input.
29
- */
30
- readonly placeholder: StringConstructor;
31
- /**
32
- * The html autocomplete attribute of the input.
33
- */
34
- readonly autocomplete: {
35
- readonly type: StringConstructor;
36
- readonly default: "off";
37
- };
38
- /**
39
- * The html type attribute of the input.
40
- */
41
- readonly type: {
42
- readonly type: StringConstructor;
43
- readonly default: "text";
44
- };
45
- /**
46
- * The maximum value of the input.
47
- */
48
- readonly max: StringConstructor;
49
- /**
50
- * The minimum value of the input.
51
- */
52
- readonly min: StringConstructor;
53
- /**
54
- * If set to `true` the input is displayed with a red border.
55
- */
56
- readonly error: BooleanConstructor;
57
- /**
58
- * If set to `true` the input is disabled and no interaction is possible.
59
- */
60
- readonly disabled: BooleanConstructor;
61
- /**
62
- * If set to `true` the input is displayed smaller.
63
- */
64
- readonly small: BooleanConstructor;
65
- /**
66
- * If set to `true` the input's label is hidden.
67
- */
68
- readonly hideLabel: BooleanConstructor;
69
- /**
70
- * Adds the classes directly to the input (e.g. for shadow).
71
- */
72
- readonly inputClass: StringConstructor;
73
- /**
74
- * This is called when the input reveices focus.
75
- */
76
- readonly onFocus: PropType<() => void>;
77
- /**
78
- * This is called when the input looses focus.
79
- */
80
- readonly onBlur: PropType<() => void>;
81
- readonly value: PropType<string>;
82
- readonly onUpdateValue: PropType<(newValue: string) => void>;
83
- };
84
- export type NInputExposed = {
85
- /**
86
- * Request focus on the input.
87
- */
88
- focus(): void;
89
- };
90
- /**
91
- * The base class of inputs. A styled input with a lot of configuration possibilities but no validation.
92
- */
93
- declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
94
- export { Component as NInput, Component as default };
@@ -1,110 +0,0 @@
1
- import { createVNode as _createVNode, vShow as _vShow, withDirectives as _withDirectives, mergeProps as _mergeProps } from "vue";
2
- import { createComponent } from '../utils/component';
3
- import { ref } from 'vue';
4
- import { ExclamationCircleIcon } from '@heroicons/vue/24/solid';
5
- import NTooltip, { mapTooltipProps, nToolTipPropsForImplementor } from './NTooltip';
6
- import './NInput.css';
7
- import { vModelProps } from '../utils/vModel';
8
- export const nInputProps = {
9
- ...vModelProps(String),
10
- /**
11
- * The name of the input. Is displayed as a label above the input.
12
- */
13
- name: String,
14
- /**
15
- * The placeholder of the input.
16
- */
17
- placeholder: String,
18
- /**
19
- * The html autocomplete attribute of the input.
20
- */
21
- autocomplete: {
22
- type: String,
23
- default: 'off'
24
- },
25
- /**
26
- * The html type attribute of the input.
27
- */
28
- type: {
29
- type: String,
30
- default: 'text'
31
- },
32
- /**
33
- * The maximum value of the input.
34
- */
35
- max: String,
36
- /**
37
- * The minimum value of the input.
38
- */
39
- min: String,
40
- /**
41
- * If set to `true` the input is displayed with a red border.
42
- */
43
- error: Boolean,
44
- /**
45
- * If set to `true` the input is disabled and no interaction is possible.
46
- */
47
- disabled: Boolean,
48
- /**
49
- * If set to `true` the input is displayed smaller.
50
- */
51
- small: Boolean,
52
- /**
53
- * If set to `true` the input's label is hidden.
54
- */
55
- hideLabel: Boolean,
56
- /**
57
- * Adds the classes directly to the input (e.g. for shadow).
58
- */
59
- inputClass: String,
60
- /**
61
- * This is called when the input reveices focus.
62
- */
63
- onFocus: Function,
64
- /**
65
- * This is called when the input looses focus.
66
- */
67
- onBlur: Function,
68
- ...nToolTipPropsForImplementor
69
- };
70
- /**
71
- * The base class of inputs. A styled input with a lot of configuration possibilities but no validation.
72
- */
73
- const Component = createComponent('NInput', nInputProps, (props, context) => {
74
- const inputRef = ref();
75
- const exposed = {
76
- focus: () => inputRef.value?.focus()
77
- };
78
- context.expose(exposed);
79
- return () => _createVNode("div", null, [props.name && !props.hideLabel && _createVNode("label", {
80
- "for": props.name,
81
- "class": ['block text-sm font-medium mb-1', props.disabled ? 'text-default-300' : 'text-default-700']
82
- }, [props.name]), _createVNode(NTooltip, _mergeProps({
83
- "block": true
84
- }, mapTooltipProps(props)), {
85
- default: () => [_createVNode("div", {
86
- "class": "relative"
87
- }, [_createVNode("input", {
88
- "ref": inputRef,
89
- "name": props.name,
90
- "value": props.value,
91
- "onInput": event => props.onUpdateValue?.(event.target.value),
92
- "placeholder": props.placeholder,
93
- "autocomplete": props.autocomplete,
94
- "type": props.type,
95
- "min": props.min,
96
- "max": props.max,
97
- "disabled": props.disabled,
98
- "onFocus": () => props.onFocus?.(),
99
- "onBlur": () => props.onBlur?.(),
100
- "onInvalid": event => event.preventDefault(),
101
- "class": ['block w-full rounded-md border focus:outline-none focus:ring-1 ', props.small ? 'text-xs py-0.5 px-2' : 'py-2 px-4', props.disabled ? 'text-default-500 placeholder-default-300 bg-default-50' : 'text-default-900 placeholder-default-400 ', props.error ? 'border-red-500 focus:border-red-500 focus:ring-red-500 pr-10' : 'border-default-300 focus:border-primary-500 focus:ring-primary-500', props.inputClass]
102
- }, null), _withDirectives(_createVNode("div", {
103
- "class": "absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none"
104
- }, [_createVNode(ExclamationCircleIcon, {
105
- "class": "h-5 w-5 text-red-700",
106
- "aria-hidden": "true"
107
- }, null)]), [[_vShow, props.error && !props.small]])])]
108
- })]);
109
- });
110
- export { Component as NInput, Component as default };
@@ -1,58 +0,0 @@
1
- export declare const nInputPhoneProps: {
2
- readonly input: import("vue").PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
3
- readonly disableValidation: BooleanConstructor;
4
- readonly optional: BooleanConstructor;
5
- readonly rules: {
6
- readonly type: import("vue").PropType<import("../utils/validation").ValidationRule[] | import("../utils/validation").ValidationRule>;
7
- readonly default: () => never[];
8
- };
9
- readonly form: import("vue").PropType<import("./ValidatedForm").ValidatedForm>;
10
- readonly error: BooleanConstructor;
11
- readonly errorMessage: StringConstructor;
12
- readonly hideErrorMessage: BooleanConstructor;
13
- readonly disableBlurValidation: BooleanConstructor;
14
- readonly tooltipText: StringConstructor;
15
- readonly tooltipContent: import("vue").PropType<() => JSX.Element>;
16
- readonly tooltipHide: BooleanConstructor;
17
- readonly tooltipShow: BooleanConstructor;
18
- readonly tooltipPlacement: {
19
- readonly type: import("vue").PropType<import("./NTooltip").TooltipPlacement>;
20
- readonly default: "auto";
21
- };
22
- readonly tooltipMaxWidth: {
23
- readonly type: import("vue").PropType<import("../utils/tailwind").TWMaxWidth>;
24
- readonly default: "max-w-xs";
25
- };
26
- readonly tooltipWrapperClass: StringConstructor;
27
- readonly tooltipContentClass: StringConstructor;
28
- readonly tooltipArrowClass: StringConstructor;
29
- readonly tooltipDelay: {
30
- readonly type: NumberConstructor;
31
- readonly default: 0;
32
- };
33
- readonly name: StringConstructor;
34
- readonly placeholder: StringConstructor;
35
- readonly autocomplete: {
36
- readonly type: StringConstructor;
37
- readonly default: "off";
38
- };
39
- readonly type: {
40
- readonly type: StringConstructor;
41
- readonly default: "text";
42
- };
43
- readonly max: StringConstructor;
44
- readonly min: StringConstructor;
45
- readonly disabled: BooleanConstructor;
46
- readonly small: BooleanConstructor;
47
- readonly hideLabel: BooleanConstructor;
48
- readonly inputClass: StringConstructor;
49
- readonly onFocus: import("vue").PropType<() => void>;
50
- readonly onBlur: import("vue").PropType<() => void>;
51
- readonly value: import("vue").PropType<string>;
52
- readonly onUpdateValue: import("vue").PropType<(newValue: string) => void>;
53
- };
54
- /**
55
- * The `NInputPhone` autoformats phone numbers and checks if they are valid.
56
- */
57
- declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
58
- export { Component as NInputPhone, Component as default };
@@ -1,47 +0,0 @@
1
- import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
2
- import { createComponent } from '../utils/component';
3
- import { external } from '../utils/validation';
4
- import { computed, Suspense } from 'vue';
5
- import NValInput, { nValInputProps } from './NValInput';
6
- import { trsl } from '../i18n';
7
- export const nInputPhoneProps = nValInputProps;
8
- /**
9
- * The `NInputPhone` autoformats phone numbers and checks if they are valid.
10
- */
11
- const Component = createComponent('NInputPhoneSuspended', nInputPhoneProps, props => {
12
- // Async components have to be wrapped in a suspense component.
13
- return () => _createVNode(Suspense, null, {
14
- default: () => [_createVNode(NPhoneInput, props, null)]
15
- });
16
- });
17
- export { Component as NInputPhone, Component as default };
18
- const NPhoneInput = createComponent('NInputPhone', nInputPhoneProps, async props => {
19
- // import dynamically for better codesplitting as the library is pretty large
20
- const {
21
- parsePhoneNumber
22
- } = await import('awesome-phonenumber');
23
- const DEFAULT_COUNTRY_CODE = 'CH';
24
- const formattedToPlain = number => parsePhoneNumber(number, {
25
- regionCode: DEFAULT_COUNTRY_CODE
26
- }).number?.e164;
27
- const plainToFormatted = number => parsePhoneNumber(number, {
28
- regionCode: DEFAULT_COUNTRY_CODE
29
- }).number?.international;
30
- const onUpdateValue = newValue => {
31
- const plain = formattedToPlain(newValue);
32
- props.onUpdateValue?.(plain || newValue);
33
- };
34
- const value = computed(() => {
35
- const formatted = plainToFormatted(props.value || '');
36
- return formatted || props.value;
37
- });
38
- const isValid = computed(() => parsePhoneNumber(props.value || '').valid);
39
- return () => _createVNode(NValInput, _mergeProps({
40
- ...props,
41
- onUpdateValue
42
- }, {
43
- "value": value.value,
44
- "rules": external(isValid.value, trsl('vue-collection.validation.rules.phone')),
45
- "type": "tel"
46
- }), null);
47
- });
@@ -1,103 +0,0 @@
1
- import { type Identifiable } from '../utils/identifiable';
2
- import { type PropType } from 'vue';
3
- import type { AnyObject } from '../utils/utils';
4
- export declare const nInputSelectProps: {
5
- /**
6
- * The id of the currently selected option of this input.
7
- */
8
- readonly value: StringConstructor;
9
- /**
10
- * This is called with the newly selected id when the selection has changed.
11
- * This happens, when an item from the suggestion list is selected or the
12
- * input matches a selection option exactly.
13
- * If no id is selected, the empty string is passed, in order to
14
- * match the API of all other inputs who never pass `undefined`.
15
- */
16
- readonly onUpdateValue: PropType<(newValue: string) => void>;
17
- /**
18
- * The options which are allowed and suggested for this input.
19
- * The options are filtered based on the user input.
20
- */
21
- readonly options: {
22
- readonly type: PropType<InputSelectOption[]>;
23
- readonly default: () => never[];
24
- };
25
- /**
26
- * @see {@link nValInputProps.optional}
27
- */
28
- readonly optional: BooleanConstructor;
29
- /**
30
- * @see {@link nValInputProps.form}
31
- */
32
- readonly form: PropType<import("./ValidatedForm").ValidatedForm>;
33
- /**
34
- * @see {@link nValInputProps.error}
35
- */
36
- readonly error: BooleanConstructor;
37
- /**
38
- * @see {@link nValInputProps.errorMessage}
39
- */
40
- readonly errorMessage: StringConstructor;
41
- /**
42
- * If set to `true` the list is hidden even if there are still matching items in the list.
43
- */
44
- readonly hideList: BooleanConstructor;
45
- /**
46
- * @see {@link nSuggestionListProps.maxItems}
47
- */
48
- readonly maxItems: {
49
- readonly type: NumberConstructor;
50
- readonly default: () => number;
51
- };
52
- /**
53
- * @see {@link nSuggestionListProps.listItem}
54
- */
55
- readonly listItem: PropType<(props: import("./NSuggestionList").ItemSlotProps) => JSX.Element>;
56
- readonly tooltipText: StringConstructor;
57
- readonly tooltipContent: PropType<() => JSX.Element>;
58
- readonly tooltipHide: BooleanConstructor;
59
- readonly tooltipShow: BooleanConstructor;
60
- readonly tooltipPlacement: {
61
- readonly type: PropType<import("./NTooltip").TooltipPlacement>;
62
- readonly default: "auto";
63
- };
64
- readonly tooltipMaxWidth: {
65
- readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
66
- readonly default: "max-w-xs";
67
- };
68
- readonly tooltipWrapperClass: StringConstructor;
69
- readonly tooltipContentClass: StringConstructor;
70
- readonly tooltipArrowClass: StringConstructor;
71
- readonly tooltipDelay: {
72
- readonly type: NumberConstructor;
73
- readonly default: 0;
74
- };
75
- readonly name: StringConstructor;
76
- readonly placeholder: StringConstructor;
77
- readonly autocomplete: {
78
- readonly type: StringConstructor;
79
- readonly default: "off";
80
- };
81
- readonly type: {
82
- readonly type: StringConstructor;
83
- readonly default: "text";
84
- };
85
- readonly max: StringConstructor;
86
- readonly min: StringConstructor;
87
- readonly disabled: BooleanConstructor;
88
- readonly small: BooleanConstructor;
89
- readonly hideLabel: BooleanConstructor;
90
- readonly inputClass: StringConstructor;
91
- readonly onFocus: PropType<() => void>;
92
- readonly onBlur: PropType<() => void>;
93
- };
94
- export type InputSelectOption = Identifiable & {
95
- label: string;
96
- } & AnyObject;
97
- /**
98
- * The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
99
- * The user is forced to use a value from the specified options of the input.
100
- * While they type, the list of options is shown to them and filtered based on their input.
101
- */
102
- declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
103
- export { Component as NInputSelect, Component as default };
@@ -1,115 +0,0 @@
1
- import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
2
- import { createComponentWithSlots } from '../utils/component';
3
- import { Id } from '../utils/identifiable';
4
- import { option } from '../utils/validation';
5
- import { vModelForRef } from '../utils/vModel';
6
- import { watchRef } from '../utils/vue';
7
- import { computed, ref, watch } from 'vue';
8
- import { nInputProps } from './NInput';
9
- import NSuggestionList, { nSuggestionListProps } from './NSuggestionList';
10
- import NValInput, { nValInputProps } from './NValInput';
11
- export const nInputSelectProps = {
12
- ...nInputProps,
13
- /**
14
- * The id of the currently selected option of this input.
15
- */
16
- value: String,
17
- /**
18
- * This is called with the newly selected id when the selection has changed.
19
- * This happens, when an item from the suggestion list is selected or the
20
- * input matches a selection option exactly.
21
- * If no id is selected, the empty string is passed, in order to
22
- * match the API of all other inputs who never pass `undefined`.
23
- */
24
- onUpdateValue: Function,
25
- /**
26
- * The options which are allowed and suggested for this input.
27
- * The options are filtered based on the user input.
28
- */
29
- options: {
30
- type: Array,
31
- default: () => []
32
- },
33
- /**
34
- * @see {@link nValInputProps.optional}
35
- */
36
- optional: nValInputProps.optional,
37
- /**
38
- * @see {@link nValInputProps.form}
39
- */
40
- form: nValInputProps.form,
41
- /**
42
- * @see {@link nValInputProps.error}
43
- */
44
- error: nValInputProps.error,
45
- /**
46
- * @see {@link nValInputProps.errorMessage}
47
- */
48
- errorMessage: nValInputProps.errorMessage,
49
- /**
50
- * If set to `true` the list is hidden even if there are still matching items in the list.
51
- */
52
- hideList: nSuggestionListProps.hideList,
53
- /**
54
- * @see {@link nSuggestionListProps.maxItems}
55
- */
56
- maxItems: nSuggestionListProps.maxItems,
57
- /**
58
- * @see {@link nSuggestionListProps.listItem}
59
- */
60
- listItem: nSuggestionListProps.listItem
61
- };
62
- /**
63
- * The `NInputSelect` is very similar to the {@link NSelect}, but instead of a select input it is a regular input.
64
- * The user is forced to use a value from the specified options of the input.
65
- * While they type, the list of options is shown to them and filtered based on their input.
66
- */
67
- const Component = createComponentWithSlots('NInputSelect', nInputSelectProps, ['listItem'], props => {
68
- const inputRef = ref();
69
- const inputValue = ref('');
70
- watch(() => props.value, newValue => {
71
- if (newValue) {
72
- const chosenOption = Id.find(props.options, newValue);
73
- if (chosenOption) inputValue.value = chosenOption.label;
74
- }
75
- }, {
76
- immediate: true
77
- });
78
- const filteredOptions = computed(() => props.options.filter(option => option.label.includes(inputValue.value || '')));
79
- const matchedOption = computed(() => {
80
- const matches = props.options.filter(option => option.label === inputValue.value);
81
- return matches.length > 0 ? matches[0] : null;
82
- });
83
- watchRef(matchedOption, newOption => props.onUpdateValue?.(newOption?.id || ''));
84
- return () => _createVNode(NSuggestionList, {
85
- "items": filteredOptions.value,
86
- "onSelect": props.onUpdateValue,
87
- "inputValue": inputValue.value,
88
- "hideList": props.hideList || matchedOption.value != null || filteredOptions.value.length == 0,
89
- "maxItems": props.maxItems,
90
- "listItem": props.listItem,
91
- "input": ({
92
- onFocus,
93
- onBlur
94
- }) => _createVNode(NValInput, _mergeProps({
95
- "ref": inputRef
96
- }, {
97
- ...props,
98
- ...vModelForRef(inputValue)
99
- }, {
100
- "rules": option(props.options.map(opt => opt.label)),
101
- "onFocus": () => {
102
- onFocus();
103
- props.onFocus?.();
104
- },
105
- "onBlur": onBlur,
106
- "disableBlurValidation": true
107
- }), null),
108
- "onRequestInputFocus": () => inputRef.value?.focus(),
109
- "onRealBlur": () => {
110
- props.onBlur?.();
111
- inputRef?.value?.validate();
112
- }
113
- }, null);
114
- });
115
- export { Component as NInputSelect, Component as default };
@@ -1,79 +0,0 @@
1
- import { type PropType } from 'vue';
2
- export declare const nInputSuggestionProps: {
3
- /**
4
- * If set to `true` the list is hidden even if there are still matching items in the list.
5
- */
6
- readonly hideList: BooleanConstructor;
7
- /**
8
- * @see {@link nSuggestionListProps.maxItems}
9
- */
10
- readonly maxItems: {
11
- readonly type: NumberConstructor;
12
- readonly default: () => number;
13
- };
14
- /**
15
- * The suggestions which are shown to the user for this input.
16
- * The suggestions are filtered based on the user input.
17
- */
18
- readonly suggestions: {
19
- readonly type: PropType<string[]>;
20
- readonly default: () => never[];
21
- };
22
- readonly input: PropType<(props: import("./NValInput").InputSlotProps) => JSX.Element>;
23
- readonly disableValidation: BooleanConstructor;
24
- readonly optional: BooleanConstructor;
25
- readonly rules: {
26
- readonly type: PropType<import("../utils/validation").ValidationRule[] | import("../utils/validation").ValidationRule>;
27
- readonly default: () => never[];
28
- };
29
- readonly form: PropType<import("./ValidatedForm").ValidatedForm>;
30
- readonly error: BooleanConstructor;
31
- readonly errorMessage: StringConstructor;
32
- readonly hideErrorMessage: BooleanConstructor;
33
- readonly disableBlurValidation: BooleanConstructor;
34
- readonly tooltipText: StringConstructor;
35
- readonly tooltipContent: PropType<() => JSX.Element>;
36
- readonly tooltipHide: BooleanConstructor;
37
- readonly tooltipShow: BooleanConstructor;
38
- readonly tooltipPlacement: {
39
- readonly type: PropType<import("./NTooltip").TooltipPlacement>;
40
- readonly default: "auto";
41
- };
42
- readonly tooltipMaxWidth: {
43
- readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
44
- readonly default: "max-w-xs";
45
- };
46
- readonly tooltipWrapperClass: StringConstructor;
47
- readonly tooltipContentClass: StringConstructor;
48
- readonly tooltipArrowClass: StringConstructor;
49
- readonly tooltipDelay: {
50
- readonly type: NumberConstructor;
51
- readonly default: 0;
52
- };
53
- readonly name: StringConstructor;
54
- readonly placeholder: StringConstructor;
55
- readonly autocomplete: {
56
- readonly type: StringConstructor;
57
- readonly default: "off";
58
- };
59
- readonly type: {
60
- readonly type: StringConstructor;
61
- readonly default: "text";
62
- };
63
- readonly max: StringConstructor;
64
- readonly min: StringConstructor;
65
- readonly disabled: BooleanConstructor;
66
- readonly small: BooleanConstructor;
67
- readonly hideLabel: BooleanConstructor;
68
- readonly inputClass: StringConstructor;
69
- readonly onFocus: PropType<() => void>;
70
- readonly onBlur: PropType<() => void>;
71
- readonly value: PropType<string>;
72
- readonly onUpdateValue: PropType<(newValue: string) => void>;
73
- };
74
- /**
75
- * `NInputSuggestion` is an input, which shows a list of possible suggestions to the user
76
- * which is filtered while typing. Contrary to {@link NInputSelect} the user is not required to choose any of the suggestions.
77
- */
78
- declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
79
- export { Component as NInputSuggestion, Component as default };