@naptics/vue-collection 0.0.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.
- package/README.md +27 -0
- package/lib/components/NAlert.d.ts +72 -0
- package/lib/components/NAlert.jsx +69 -0
- package/lib/components/NBadge.d.ts +174 -0
- package/lib/components/NBadge.jsx +58 -0
- package/lib/components/NBreadcrub.d.ts +161 -0
- package/lib/components/NBreadcrub.jsx +64 -0
- package/lib/components/NButton.d.ts +149 -0
- package/lib/components/NButton.jsx +58 -0
- package/lib/components/NCheckbox.d.ts +51 -0
- package/lib/components/NCheckbox.jsx +38 -0
- package/lib/components/NCheckboxLabel.d.ts +70 -0
- package/lib/components/NCheckboxLabel.jsx +42 -0
- package/lib/components/NCrudModal.d.ts +301 -0
- package/lib/components/NCrudModal.jsx +89 -0
- package/lib/components/NDialog.d.ts +190 -0
- package/lib/components/NDialog.jsx +144 -0
- package/lib/components/NDropdown.d.ts +116 -0
- package/lib/components/NDropdown.jsx +92 -0
- package/lib/components/NDropzone.d.ts +162 -0
- package/lib/components/NDropzone.jsx +211 -0
- package/lib/components/NForm.d.ts +43 -0
- package/lib/components/NForm.jsx +26 -0
- package/lib/components/NFormModal.d.ts +190 -0
- package/lib/components/NFormModal.jsx +48 -0
- package/lib/components/NIconButton.d.ts +202 -0
- package/lib/components/NIconButton.jsx +71 -0
- package/lib/components/NIconCircle.d.ts +135 -0
- package/lib/components/NIconCircle.jsx +67 -0
- package/lib/components/NInput.css +11 -0
- package/lib/components/NInput.d.ts +232 -0
- package/lib/components/NInput.jsx +97 -0
- package/lib/components/NInputPhone.d.ts +150 -0
- package/lib/components/NInputPhone.jsx +31 -0
- package/lib/components/NInputSelect.d.ts +271 -0
- package/lib/components/NInputSelect.jsx +89 -0
- package/lib/components/NInputSuggestion.d.ts +212 -0
- package/lib/components/NInputSuggestion.jsx +48 -0
- package/lib/components/NLink.d.ts +111 -0
- package/lib/components/NLink.jsx +58 -0
- package/lib/components/NList.d.ts +43 -0
- package/lib/components/NList.jsx +24 -0
- package/lib/components/NLoadingIndicator.css +46 -0
- package/lib/components/NLoadingIndicator.d.ts +77 -0
- package/lib/components/NLoadingIndicator.jsx +42 -0
- package/lib/components/NModal.d.ts +333 -0
- package/lib/components/NModal.jsx +170 -0
- package/lib/components/NPagination.css +15 -0
- package/lib/components/NPagination.d.ts +99 -0
- package/lib/components/NPagination.jsx +104 -0
- package/lib/components/NSearchbar.d.ts +94 -0
- package/lib/components/NSearchbar.jsx +58 -0
- package/lib/components/NSearchbarList.d.ts +90 -0
- package/lib/components/NSearchbarList.jsx +20 -0
- package/lib/components/NSelect.d.ts +159 -0
- package/lib/components/NSelect.jsx +81 -0
- package/lib/components/NSuggestionList.d.ts +275 -0
- package/lib/components/NSuggestionList.jsx +157 -0
- package/lib/components/NTable.css +3 -0
- package/lib/components/NTable.d.ts +187 -0
- package/lib/components/NTable.jsx +146 -0
- package/lib/components/NTableAction.d.ts +74 -0
- package/lib/components/NTableAction.jsx +35 -0
- package/lib/components/NTextArea.d.ts +252 -0
- package/lib/components/NTextArea.jsx +108 -0
- package/lib/components/NTooltip.css +37 -0
- package/lib/components/NTooltip.d.ts +186 -0
- package/lib/components/NTooltip.jsx +161 -0
- package/lib/components/NValInput.d.ts +297 -0
- package/lib/components/NValInput.jsx +101 -0
- package/lib/components/ValidatedForm.d.ts +34 -0
- package/lib/components/ValidatedForm.js +25 -0
- package/lib/i18n/de/template.json +10 -0
- package/lib/i18n/de/vue-collection.json +58 -0
- package/lib/i18n/de.d.ts +61 -0
- package/lib/i18n/de.js +5 -0
- package/lib/i18n/en/template.json +10 -0
- package/lib/i18n/en/vue-collection.json +58 -0
- package/lib/i18n/en.d.ts +61 -0
- package/lib/i18n/en.js +5 -0
- package/lib/i18n/index.d.ts +17 -0
- package/lib/i18n/index.js +34 -0
- package/lib/index.d.ts +64 -0
- package/lib/index.js +65 -0
- package/lib/utils/breakpoints.d.ts +15 -0
- package/lib/utils/breakpoints.js +37 -0
- package/lib/utils/component.d.ts +50 -0
- package/lib/utils/component.js +51 -0
- package/lib/utils/deferred.d.ts +13 -0
- package/lib/utils/deferred.js +17 -0
- package/lib/utils/identifiable.d.ts +57 -0
- package/lib/utils/identifiable.js +78 -0
- package/lib/utils/stringMaxLength.d.ts +14 -0
- package/lib/utils/stringMaxLength.js +28 -0
- package/lib/utils/tailwind.d.ts +2 -0
- package/lib/utils/tailwind.js +1 -0
- package/lib/utils/utils.d.ts +27 -0
- package/lib/utils/utils.js +26 -0
- package/lib/utils/vModel.d.ts +182 -0
- package/lib/utils/vModel.js +215 -0
- package/lib/utils/validation.d.ts +84 -0
- package/lib/utils/validation.js +163 -0
- package/lib/utils/vue.d.ts +13 -0
- package/lib/utils/vue.js +19 -0
- package/package.json +56 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { isWidthBreakpoint } from '../utils/breakpoints';
|
|
2
|
+
import { createComponent, createProps } from '../utils/component';
|
|
3
|
+
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/vue/24/solid';
|
|
4
|
+
import { computed, Fragment, ref, watch } from 'vue';
|
|
5
|
+
import NIconButton from './NIconButton';
|
|
6
|
+
import './NTable.css';
|
|
7
|
+
const N_TABLE_ACTION_KEY = 'action';
|
|
8
|
+
export const nTableProps = createProps({
|
|
9
|
+
/**
|
|
10
|
+
* The headings of the table. These define which columns are shown in the table and in which order.
|
|
11
|
+
*/
|
|
12
|
+
headings: {
|
|
13
|
+
type: Array,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Details can be added additionally to headings.
|
|
18
|
+
* If details are set a little chevron icon is displayed at the end of each table row
|
|
19
|
+
* and if clicked on it the data is displayed in a key-value fashion.
|
|
20
|
+
* The values of the entries should be passed via the `items` prop
|
|
21
|
+
* in the same way as if the details were normal headings.
|
|
22
|
+
* Note that details can be added dynamically by adding the `breakpoint` property to the headings.
|
|
23
|
+
*/
|
|
24
|
+
details: {
|
|
25
|
+
type: Array,
|
|
26
|
+
default: () => [],
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* The items of the table. They consist of an array of table rows.
|
|
30
|
+
* Every tablerow is an object containing elements for the heading keys.
|
|
31
|
+
* The elements can either be a primitive value or a function which returns a {@link JSX.Element}.
|
|
32
|
+
* If the item should be treated as an action (e.g. icon-button to display at the end of the row)
|
|
33
|
+
* the dedicated key 'action' can be used.
|
|
34
|
+
* @see TableRow
|
|
35
|
+
* @example
|
|
36
|
+
* // These headings are defined
|
|
37
|
+
* const headings: TableHeading[] = [
|
|
38
|
+
* { key: 'id', label: 'ID' },
|
|
39
|
+
* { key: 'name', label: 'Name' },
|
|
40
|
+
* { key: 'status', label: 'Status' }
|
|
41
|
+
* ]
|
|
42
|
+
*
|
|
43
|
+
* // Appropriate rows for these headings
|
|
44
|
+
* const items: TableRow[] = [
|
|
45
|
+
* { id: 1, name: 'Hubert', status: () => <NBadge ... />, action: ... }, // Row 1
|
|
46
|
+
* { id: 2, name: 'Franzi', status: () => <NBadge ... />, action: ... } // Row 2
|
|
47
|
+
* ]
|
|
48
|
+
*/
|
|
49
|
+
items: {
|
|
50
|
+
type: Array,
|
|
51
|
+
default: () => [],
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* The `NTable` is a styled html table which accepts data and displays it appropriately.
|
|
56
|
+
*/
|
|
57
|
+
export default createComponent('NTable', nTableProps, props => {
|
|
58
|
+
const headings = computed(() => {
|
|
59
|
+
// remove all headings which are below the breakpoint
|
|
60
|
+
const headings = props.headings.filter(heading => !heading.breakpoint || isWidthBreakpoint(heading.breakpoint).value);
|
|
61
|
+
// The column for actions is shown if there are details
|
|
62
|
+
// or if any of the items contain an element with the action-key.
|
|
63
|
+
if (showDetails.value || props.items.filter(row => row.action != null).length != 0) {
|
|
64
|
+
headings.push({ key: N_TABLE_ACTION_KEY });
|
|
65
|
+
}
|
|
66
|
+
return headings;
|
|
67
|
+
});
|
|
68
|
+
const details = computed(() => {
|
|
69
|
+
// take all headings which are below the breakpoint
|
|
70
|
+
const details = props.headings.filter(heading => heading.breakpoint && !isWidthBreakpoint(heading.breakpoint).value);
|
|
71
|
+
details.push(...props.details);
|
|
72
|
+
return details;
|
|
73
|
+
});
|
|
74
|
+
const showDetails = computed(() => details.value.length > 0);
|
|
75
|
+
const detailsOpen = ref([]);
|
|
76
|
+
const isDetailsOpen = (index) => detailsOpen.value[index] || false;
|
|
77
|
+
const toggleDetailsOpen = (index) => (detailsOpen.value[index] = !detailsOpen.value[index]);
|
|
78
|
+
// if the items change, reset all open details to closed
|
|
79
|
+
// and create correct amount of booleans for all items
|
|
80
|
+
watch(() => props.items, newItems => (detailsOpen.value = Array({ length: newItems.length }).map(() => false)), { immediate: true });
|
|
81
|
+
return () => (<div class="overflow-x-auto">
|
|
82
|
+
<table class="min-w-full text-default-500 text-sm">
|
|
83
|
+
<thead class="bg-default-50 ">
|
|
84
|
+
<tr>
|
|
85
|
+
{headings.value.map(heading => (<th key={heading.key} scope="col" class="p-4 table-heading">
|
|
86
|
+
{heading.label}
|
|
87
|
+
</th>))}
|
|
88
|
+
</tr>
|
|
89
|
+
</thead>
|
|
90
|
+
|
|
91
|
+
{props.items.length > 0 &&
|
|
92
|
+
props.items.map((item, itemIndex) => (<Fragment key={itemIndex}>
|
|
93
|
+
{/* First tbody is the actual table-row with the entries */}
|
|
94
|
+
<tbody class={[
|
|
95
|
+
'border-default-200 border-t',
|
|
96
|
+
itemIndex % 2 === 0 ? 'bg-white' : 'bg-default-50',
|
|
97
|
+
]}>
|
|
98
|
+
<tr>
|
|
99
|
+
{headings.value.map(heading => (<td key={itemIndex + '-' + heading.key} class="p-4">
|
|
100
|
+
<div class={[
|
|
101
|
+
'flex',
|
|
102
|
+
heading.emph ? 'font-medium text-default-900' : '',
|
|
103
|
+
heading.cellClass,
|
|
104
|
+
heading.key == N_TABLE_ACTION_KEY
|
|
105
|
+
? 'justify-end items-center space-x-3'
|
|
106
|
+
: '',
|
|
107
|
+
]}>
|
|
108
|
+
{item[heading.key] && buildItem(item[heading.key])}
|
|
109
|
+
|
|
110
|
+
{/* Add the chevron icon-button if details are present */}
|
|
111
|
+
{heading.key == N_TABLE_ACTION_KEY && showDetails.value && (<NIconButton icon={isDetailsOpen(itemIndex) ? ChevronDownIcon : ChevronUpIcon} onClick={() => toggleDetailsOpen(itemIndex)}/>)}
|
|
112
|
+
</div>
|
|
113
|
+
</td>))}
|
|
114
|
+
</tr>
|
|
115
|
+
</tbody>
|
|
116
|
+
|
|
117
|
+
{/* Second tbody are the details (only shown if present and opened) */}
|
|
118
|
+
{showDetails.value && isDetailsOpen(itemIndex) && (<tbody class={itemIndex % 2 === 0 ? 'bg-white' : 'bg-default-50'}>
|
|
119
|
+
{details.value.map((detail, detailIndex) => (<tr key={`detail-${detailIndex}`}>
|
|
120
|
+
<td class={[
|
|
121
|
+
'table-heading px-4 py-1',
|
|
122
|
+
details.value.length - 1 == detailIndex ? 'pb-4' : '',
|
|
123
|
+
]}>
|
|
124
|
+
{detail.label}
|
|
125
|
+
</td>
|
|
126
|
+
<td class={[
|
|
127
|
+
'px-4 py-1',
|
|
128
|
+
details.value.length - 1 == detailIndex ? 'pb-4' : '',
|
|
129
|
+
]} colspan={headings.value.length - 1}>
|
|
130
|
+
{item[detail.key] && buildItem(item[detail.key])}
|
|
131
|
+
</td>
|
|
132
|
+
</tr>))}
|
|
133
|
+
</tbody>)}
|
|
134
|
+
</Fragment>))}
|
|
135
|
+
</table>
|
|
136
|
+
</div>);
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* Builds a JSX-Element out of the item
|
|
140
|
+
*/
|
|
141
|
+
function buildItem(item) {
|
|
142
|
+
if (typeof item == 'string' || typeof item == 'number')
|
|
143
|
+
return <>{item}</>;
|
|
144
|
+
else
|
|
145
|
+
return item();
|
|
146
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import { type RouteLocationRaw } from 'vue-router';
|
|
3
|
+
export declare const nTableActionProps: {
|
|
4
|
+
/**
|
|
5
|
+
* The route of the action. If set the component will be a {@link RouterLink}.
|
|
6
|
+
*/
|
|
7
|
+
route: PropType<RouteLocationRaw>;
|
|
8
|
+
/**
|
|
9
|
+
* The text of the action.
|
|
10
|
+
*/
|
|
11
|
+
text: StringConstructor;
|
|
12
|
+
/**
|
|
13
|
+
* The html attribute, which indicates the type of the button.
|
|
14
|
+
*/
|
|
15
|
+
type: {
|
|
16
|
+
type: PropType<"button" | "submit" | "reset">;
|
|
17
|
+
default: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* This is called when the action is clicked.
|
|
21
|
+
* It is only called when the `route` prop is not set on the action.
|
|
22
|
+
*/
|
|
23
|
+
onClick: PropType<() => void>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The `NTableAction` is a button or {@link RouterLink} which is styled to fit into a table.
|
|
27
|
+
* It is basically styled as an emphasized text in the table.
|
|
28
|
+
*/
|
|
29
|
+
declare const _default: import("vue").DefineComponent<{
|
|
30
|
+
/**
|
|
31
|
+
* The route of the action. If set the component will be a {@link RouterLink}.
|
|
32
|
+
*/
|
|
33
|
+
route: PropType<RouteLocationRaw>;
|
|
34
|
+
/**
|
|
35
|
+
* The text of the action.
|
|
36
|
+
*/
|
|
37
|
+
text: StringConstructor;
|
|
38
|
+
/**
|
|
39
|
+
* The html attribute, which indicates the type of the button.
|
|
40
|
+
*/
|
|
41
|
+
type: {
|
|
42
|
+
type: PropType<"button" | "submit" | "reset">;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* This is called when the action is clicked.
|
|
47
|
+
* It is only called when the `route` prop is not set on the action.
|
|
48
|
+
*/
|
|
49
|
+
onClick: PropType<() => void>;
|
|
50
|
+
}, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
51
|
+
/**
|
|
52
|
+
* The route of the action. If set the component will be a {@link RouterLink}.
|
|
53
|
+
*/
|
|
54
|
+
route: PropType<RouteLocationRaw>;
|
|
55
|
+
/**
|
|
56
|
+
* The text of the action.
|
|
57
|
+
*/
|
|
58
|
+
text: StringConstructor;
|
|
59
|
+
/**
|
|
60
|
+
* The html attribute, which indicates the type of the button.
|
|
61
|
+
*/
|
|
62
|
+
type: {
|
|
63
|
+
type: PropType<"button" | "submit" | "reset">;
|
|
64
|
+
default: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* This is called when the action is clicked.
|
|
68
|
+
* It is only called when the `route` prop is not set on the action.
|
|
69
|
+
*/
|
|
70
|
+
onClick: PropType<() => void>;
|
|
71
|
+
}>> & {}, {
|
|
72
|
+
type: "button" | "submit" | "reset";
|
|
73
|
+
}>;
|
|
74
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { RouterLink } from 'vue-router';
|
|
3
|
+
import { nButtonProps } from './NButton';
|
|
4
|
+
export const nTableActionProps = createProps({
|
|
5
|
+
/**
|
|
6
|
+
* The route of the action. If set the component will be a {@link RouterLink}.
|
|
7
|
+
*/
|
|
8
|
+
route: [String, Object],
|
|
9
|
+
/**
|
|
10
|
+
* The text of the action.
|
|
11
|
+
*/
|
|
12
|
+
text: String,
|
|
13
|
+
/**
|
|
14
|
+
* The html attribute, which indicates the type of the button.
|
|
15
|
+
*/
|
|
16
|
+
type: nButtonProps.type,
|
|
17
|
+
/**
|
|
18
|
+
* This is called when the action is clicked.
|
|
19
|
+
* It is only called when the `route` prop is not set on the action.
|
|
20
|
+
*/
|
|
21
|
+
onClick: Function,
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* The `NTableAction` is a button or {@link RouterLink} which is styled to fit into a table.
|
|
25
|
+
* It is basically styled as an emphasized text in the table.
|
|
26
|
+
*/
|
|
27
|
+
export default createComponent('NTableAction', nTableActionProps, (props, { slots }) => {
|
|
28
|
+
const content = () => slots.default?.() || <>{props.text}</>;
|
|
29
|
+
const classes = 'text-left font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-default-900 rounded-sm ring-offset-2 text-default-900 hover:underline hover:text-default-700';
|
|
30
|
+
return () => props.route ? (<RouterLink to={props.route} class={classes}>
|
|
31
|
+
{content()}
|
|
32
|
+
</RouterLink>) : (<button type={props.type} class={classes} onClick={props.onClick}>
|
|
33
|
+
{content()}
|
|
34
|
+
</button>);
|
|
35
|
+
});
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
export declare const nTextAreaProps: {
|
|
3
|
+
optional: BooleanConstructor;
|
|
4
|
+
rules: {
|
|
5
|
+
type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
6
|
+
default: () => never[];
|
|
7
|
+
};
|
|
8
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
9
|
+
error: BooleanConstructor;
|
|
10
|
+
errorMessage: StringConstructor;
|
|
11
|
+
hideErrorMessage: BooleanConstructor;
|
|
12
|
+
disableBlurValidation: BooleanConstructor;
|
|
13
|
+
tooltipText: StringConstructor;
|
|
14
|
+
tooltipContent: PropType<() => void>;
|
|
15
|
+
tooltipHide: BooleanConstructor;
|
|
16
|
+
tooltipShow: BooleanConstructor;
|
|
17
|
+
tooltipPlacement: {
|
|
18
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
tooltipMaxWidth: {
|
|
22
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>; /**
|
|
23
|
+
* If set to `true` the text area is displayed with a red border.
|
|
24
|
+
*/
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The name of the text area. Is displayed as a label above the text area.
|
|
29
|
+
*/
|
|
30
|
+
name: StringConstructor;
|
|
31
|
+
/**
|
|
32
|
+
* The placeholder of the text area.
|
|
33
|
+
*/
|
|
34
|
+
placeholder: StringConstructor;
|
|
35
|
+
/**
|
|
36
|
+
* The html autocomplete attribute of the text area.
|
|
37
|
+
*/
|
|
38
|
+
autocomplete: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* If set to `true`, the text area is resizable in y-direction.
|
|
44
|
+
*/
|
|
45
|
+
resizable: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The initial height of the text area in terms of
|
|
51
|
+
* how many text rows fit inside the text area.
|
|
52
|
+
* The height can be change if {@link nTextAreaProps.resizable} is `true`
|
|
53
|
+
*/
|
|
54
|
+
rows: NumberConstructor;
|
|
55
|
+
/**
|
|
56
|
+
* The maximum length of the input string. Entering longer strings are simply
|
|
57
|
+
* prevented, but no error message is shown to the user.
|
|
58
|
+
*/
|
|
59
|
+
maxLength: NumberConstructor;
|
|
60
|
+
/**
|
|
61
|
+
* If set to `true` the text area is disabled and no interaction is possible.
|
|
62
|
+
*/
|
|
63
|
+
disabled: BooleanConstructor;
|
|
64
|
+
/**
|
|
65
|
+
* If set to `true` the text area's label is hidden.
|
|
66
|
+
*/
|
|
67
|
+
hideLabel: BooleanConstructor;
|
|
68
|
+
/**
|
|
69
|
+
* This is called when the text area reveices focus.
|
|
70
|
+
*/
|
|
71
|
+
onFocus: PropType<() => void>;
|
|
72
|
+
/**
|
|
73
|
+
* This is called when the text area looses focus.
|
|
74
|
+
*/
|
|
75
|
+
onBlur: PropType<() => void>;
|
|
76
|
+
value: PropType<string>;
|
|
77
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
78
|
+
};
|
|
79
|
+
export type NTextAreaExposed = {
|
|
80
|
+
/**
|
|
81
|
+
* Request focus on the text area.
|
|
82
|
+
*/
|
|
83
|
+
focus(): void;
|
|
84
|
+
};
|
|
85
|
+
declare const _default: import("vue").DefineComponent<{
|
|
86
|
+
optional: BooleanConstructor;
|
|
87
|
+
rules: {
|
|
88
|
+
type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
89
|
+
default: () => never[];
|
|
90
|
+
};
|
|
91
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
92
|
+
error: BooleanConstructor;
|
|
93
|
+
errorMessage: StringConstructor;
|
|
94
|
+
hideErrorMessage: BooleanConstructor;
|
|
95
|
+
disableBlurValidation: BooleanConstructor;
|
|
96
|
+
tooltipText: StringConstructor;
|
|
97
|
+
tooltipContent: PropType<() => void>;
|
|
98
|
+
tooltipHide: BooleanConstructor;
|
|
99
|
+
tooltipShow: BooleanConstructor;
|
|
100
|
+
tooltipPlacement: {
|
|
101
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
102
|
+
default: string;
|
|
103
|
+
};
|
|
104
|
+
tooltipMaxWidth: {
|
|
105
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>; /**
|
|
106
|
+
* If set to `true` the text area is displayed with a red border.
|
|
107
|
+
*/
|
|
108
|
+
default: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The name of the text area. Is displayed as a label above the text area.
|
|
112
|
+
*/
|
|
113
|
+
name: StringConstructor;
|
|
114
|
+
/**
|
|
115
|
+
* The placeholder of the text area.
|
|
116
|
+
*/
|
|
117
|
+
placeholder: StringConstructor;
|
|
118
|
+
/**
|
|
119
|
+
* The html autocomplete attribute of the text area.
|
|
120
|
+
*/
|
|
121
|
+
autocomplete: {
|
|
122
|
+
type: StringConstructor;
|
|
123
|
+
default: string;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* If set to `true`, the text area is resizable in y-direction.
|
|
127
|
+
*/
|
|
128
|
+
resizable: {
|
|
129
|
+
type: BooleanConstructor;
|
|
130
|
+
default: boolean;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The initial height of the text area in terms of
|
|
134
|
+
* how many text rows fit inside the text area.
|
|
135
|
+
* The height can be change if {@link nTextAreaProps.resizable} is `true`
|
|
136
|
+
*/
|
|
137
|
+
rows: NumberConstructor;
|
|
138
|
+
/**
|
|
139
|
+
* The maximum length of the input string. Entering longer strings are simply
|
|
140
|
+
* prevented, but no error message is shown to the user.
|
|
141
|
+
*/
|
|
142
|
+
maxLength: NumberConstructor;
|
|
143
|
+
/**
|
|
144
|
+
* If set to `true` the text area is disabled and no interaction is possible.
|
|
145
|
+
*/
|
|
146
|
+
disabled: BooleanConstructor;
|
|
147
|
+
/**
|
|
148
|
+
* If set to `true` the text area's label is hidden.
|
|
149
|
+
*/
|
|
150
|
+
hideLabel: BooleanConstructor;
|
|
151
|
+
/**
|
|
152
|
+
* This is called when the text area reveices focus.
|
|
153
|
+
*/
|
|
154
|
+
onFocus: PropType<() => void>;
|
|
155
|
+
/**
|
|
156
|
+
* This is called when the text area looses focus.
|
|
157
|
+
*/
|
|
158
|
+
onBlur: PropType<() => void>;
|
|
159
|
+
value: PropType<string>;
|
|
160
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
161
|
+
}, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, never[], never, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
162
|
+
optional: BooleanConstructor;
|
|
163
|
+
rules: {
|
|
164
|
+
type: PropType<import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[]>;
|
|
165
|
+
default: () => never[];
|
|
166
|
+
};
|
|
167
|
+
form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
168
|
+
error: BooleanConstructor;
|
|
169
|
+
errorMessage: StringConstructor;
|
|
170
|
+
hideErrorMessage: BooleanConstructor;
|
|
171
|
+
disableBlurValidation: BooleanConstructor;
|
|
172
|
+
tooltipText: StringConstructor;
|
|
173
|
+
tooltipContent: PropType<() => void>;
|
|
174
|
+
tooltipHide: BooleanConstructor;
|
|
175
|
+
tooltipShow: BooleanConstructor;
|
|
176
|
+
tooltipPlacement: {
|
|
177
|
+
type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
178
|
+
default: string;
|
|
179
|
+
};
|
|
180
|
+
tooltipMaxWidth: {
|
|
181
|
+
type: PropType<import("../utils/tailwind").TWMaxWidth>; /**
|
|
182
|
+
* If set to `true` the text area is displayed with a red border.
|
|
183
|
+
*/
|
|
184
|
+
default: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* The name of the text area. Is displayed as a label above the text area.
|
|
188
|
+
*/
|
|
189
|
+
name: StringConstructor;
|
|
190
|
+
/**
|
|
191
|
+
* The placeholder of the text area.
|
|
192
|
+
*/
|
|
193
|
+
placeholder: StringConstructor;
|
|
194
|
+
/**
|
|
195
|
+
* The html autocomplete attribute of the text area.
|
|
196
|
+
*/
|
|
197
|
+
autocomplete: {
|
|
198
|
+
type: StringConstructor;
|
|
199
|
+
default: string;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* If set to `true`, the text area is resizable in y-direction.
|
|
203
|
+
*/
|
|
204
|
+
resizable: {
|
|
205
|
+
type: BooleanConstructor;
|
|
206
|
+
default: boolean;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* The initial height of the text area in terms of
|
|
210
|
+
* how many text rows fit inside the text area.
|
|
211
|
+
* The height can be change if {@link nTextAreaProps.resizable} is `true`
|
|
212
|
+
*/
|
|
213
|
+
rows: NumberConstructor;
|
|
214
|
+
/**
|
|
215
|
+
* The maximum length of the input string. Entering longer strings are simply
|
|
216
|
+
* prevented, but no error message is shown to the user.
|
|
217
|
+
*/
|
|
218
|
+
maxLength: NumberConstructor;
|
|
219
|
+
/**
|
|
220
|
+
* If set to `true` the text area is disabled and no interaction is possible.
|
|
221
|
+
*/
|
|
222
|
+
disabled: BooleanConstructor;
|
|
223
|
+
/**
|
|
224
|
+
* If set to `true` the text area's label is hidden.
|
|
225
|
+
*/
|
|
226
|
+
hideLabel: BooleanConstructor;
|
|
227
|
+
/**
|
|
228
|
+
* This is called when the text area reveices focus.
|
|
229
|
+
*/
|
|
230
|
+
onFocus: PropType<() => void>;
|
|
231
|
+
/**
|
|
232
|
+
* This is called when the text area looses focus.
|
|
233
|
+
*/
|
|
234
|
+
onBlur: PropType<() => void>;
|
|
235
|
+
value: PropType<string>;
|
|
236
|
+
onUpdateValue: PropType<(newValue: string) => void>;
|
|
237
|
+
}>> & {}, {
|
|
238
|
+
tooltipHide: boolean;
|
|
239
|
+
tooltipShow: boolean;
|
|
240
|
+
tooltipPlacement: import("./NTooltip").TooltipPlacement;
|
|
241
|
+
tooltipMaxWidth: import("../utils/tailwind").TWMaxWidth;
|
|
242
|
+
disabled: boolean;
|
|
243
|
+
error: boolean;
|
|
244
|
+
rules: import("../utils/validation").ValidationRule | import("../utils/validation").ValidationRule[];
|
|
245
|
+
autocomplete: string;
|
|
246
|
+
hideLabel: boolean;
|
|
247
|
+
optional: boolean;
|
|
248
|
+
hideErrorMessage: boolean;
|
|
249
|
+
disableBlurValidation: boolean;
|
|
250
|
+
resizable: boolean;
|
|
251
|
+
}>;
|
|
252
|
+
export default _default;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createComponent, createProps } from '../utils/component';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { ExclamationCircleIcon } from '@heroicons/vue/24/solid';
|
|
4
|
+
import NTooltip, { mapTooltipProps, nToolTipPropsForImplementor } from './NTooltip';
|
|
5
|
+
import { vModelProps } from '../utils/vModel';
|
|
6
|
+
import NValInput, { validationProps } from './NValInput';
|
|
7
|
+
const nTextAreaBaseProps = createProps({
|
|
8
|
+
...vModelProps(String),
|
|
9
|
+
/**
|
|
10
|
+
* The name of the text area. Is displayed as a label above the text area.
|
|
11
|
+
*/
|
|
12
|
+
name: String,
|
|
13
|
+
/**
|
|
14
|
+
* The placeholder of the text area.
|
|
15
|
+
*/
|
|
16
|
+
placeholder: String,
|
|
17
|
+
/**
|
|
18
|
+
* The html autocomplete attribute of the text area.
|
|
19
|
+
*/
|
|
20
|
+
autocomplete: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'off',
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* If set to `true`, the text area is resizable in y-direction.
|
|
26
|
+
*/
|
|
27
|
+
resizable: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: true,
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* The initial height of the text area in terms of
|
|
33
|
+
* how many text rows fit inside the text area.
|
|
34
|
+
* The height can be change if {@link nTextAreaProps.resizable} is `true`
|
|
35
|
+
*/
|
|
36
|
+
rows: Number,
|
|
37
|
+
/**
|
|
38
|
+
* The maximum length of the input string. Entering longer strings are simply
|
|
39
|
+
* prevented, but no error message is shown to the user.
|
|
40
|
+
*/
|
|
41
|
+
maxLength: Number,
|
|
42
|
+
/**
|
|
43
|
+
* If set to `true` the text area is displayed with a red border.
|
|
44
|
+
*/
|
|
45
|
+
error: Boolean,
|
|
46
|
+
/**
|
|
47
|
+
* If set to `true` the text area is disabled and no interaction is possible.
|
|
48
|
+
*/
|
|
49
|
+
disabled: Boolean,
|
|
50
|
+
/**
|
|
51
|
+
* If set to `true` the text area's label is hidden.
|
|
52
|
+
*/
|
|
53
|
+
hideLabel: Boolean,
|
|
54
|
+
/**
|
|
55
|
+
* This is called when the text area reveices focus.
|
|
56
|
+
*/
|
|
57
|
+
onFocus: Function,
|
|
58
|
+
/**
|
|
59
|
+
* This is called when the text area looses focus.
|
|
60
|
+
*/
|
|
61
|
+
onBlur: Function,
|
|
62
|
+
...nToolTipPropsForImplementor,
|
|
63
|
+
});
|
|
64
|
+
export const nTextAreaProps = createProps({
|
|
65
|
+
...nTextAreaBaseProps,
|
|
66
|
+
...validationProps,
|
|
67
|
+
});
|
|
68
|
+
export default createComponent('NTextArea', nTextAreaProps, (props, context) => {
|
|
69
|
+
const textAreaRef = ref();
|
|
70
|
+
const exposed = {
|
|
71
|
+
focus: () => textAreaRef.value?.focus(),
|
|
72
|
+
};
|
|
73
|
+
context.expose(exposed);
|
|
74
|
+
return () => (<NValInput {...props} input={({ error, onBlur, onUpdateValue }) => (<NTextAreaBase ref={textAreaRef} {...{ ...props, error, onBlur, onUpdateValue }}/>)}/>);
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* The `NTextArea` wraps the html text area with all the features from {@link NInput} and {@link NValInput}.
|
|
78
|
+
*/
|
|
79
|
+
const NTextAreaBase = createComponent('NTextAreaBase', nTextAreaBaseProps, (props, context) => {
|
|
80
|
+
const textAreaRef = ref();
|
|
81
|
+
const exposed = {
|
|
82
|
+
focus: () => textAreaRef.value?.focus(),
|
|
83
|
+
};
|
|
84
|
+
context.expose(exposed);
|
|
85
|
+
return () => (<div>
|
|
86
|
+
{props.name && !props.hideLabel && (<label for={props.name} class={['block text-sm font-medium mb-1', props.disabled ? 'text-default-300' : 'text-default-700']}>
|
|
87
|
+
{props.name}
|
|
88
|
+
</label>)}
|
|
89
|
+
<NTooltip block {...mapTooltipProps(props)}>
|
|
90
|
+
<div class="relative">
|
|
91
|
+
<textarea ref={textAreaRef} name={props.name} value={props.value} onInput={event => props.onUpdateValue?.(event.target.value)} placeholder={props.placeholder} autocomplete={props.autocomplete} disabled={props.disabled} rows={props.rows} maxlength={props.maxLength} onFocus={() => props.onFocus?.()} onBlur={() => props.onBlur?.()} onInvalid={event => event.preventDefault()} class={[
|
|
92
|
+
'block w-full rounded-md border focus:outline-none focus:ring-1 ',
|
|
93
|
+
props.disabled
|
|
94
|
+
? 'text-default-500 placeholder-default-300 bg-default-50'
|
|
95
|
+
: 'text-default-900 placeholder-default-400 ',
|
|
96
|
+
props.error
|
|
97
|
+
? 'border-red-500 focus:border-red-500 focus:ring-red-500 pr-10'
|
|
98
|
+
: 'border-default-300 focus:border-primary-500 focus:ring-primary-500',
|
|
99
|
+
props.resizable ? 'resize-y' : 'resize-none',
|
|
100
|
+
]}/>
|
|
101
|
+
|
|
102
|
+
<div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none" v-show={props.error}>
|
|
103
|
+
<ExclamationCircleIcon class="h-5 w-5 text-red-700" aria-hidden="true"/>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</NTooltip>
|
|
107
|
+
</div>);
|
|
108
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.arrow,
|
|
2
|
+
.arrow::before {
|
|
3
|
+
position: absolute;
|
|
4
|
+
width: 8px;
|
|
5
|
+
height: 8px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.arrow {
|
|
9
|
+
visibility: hidden;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.arrow::before {
|
|
13
|
+
visibility: visible;
|
|
14
|
+
content: '';
|
|
15
|
+
transform: rotate(45deg);
|
|
16
|
+
@apply bg-white border border-default-200 border-solid;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tooltip[data-popper-placement^='top'] > .arrow {
|
|
20
|
+
bottom: -3.8px;
|
|
21
|
+
@apply before:border-t-transparent before:border-l-transparent;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.tooltip[data-popper-placement^='bottom'] > .arrow {
|
|
25
|
+
top: -3.8px;
|
|
26
|
+
@apply before:border-b-white before:border-r-white;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tooltip[data-popper-placement^='left'] > .arrow {
|
|
30
|
+
right: -3.8px;
|
|
31
|
+
@apply before:border-b-transparent before:border-l-transparent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tooltip[data-popper-placement^='right'] > .arrow {
|
|
35
|
+
left: -3.8px;
|
|
36
|
+
@apply before:border-t-transparent before:border-r-transparent;
|
|
37
|
+
}
|