@naptics/vue-collection 0.3.1 → 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.
- package/eslint.config.cjs +0 -2
- package/package.json +32 -31
- package/postcss.config.js +1 -4
- package/src/demo/App.css +47 -3
- package/src/demo/components/ComponentSection.tsx +1 -1
- package/src/demo/views/NavigationView.tsx +1 -1
- package/src/demo/views/presentation/TooltipView.tsx +8 -2
- package/src/lib/components/NAlert.tsx +3 -3
- package/src/lib/components/NBadge.tsx +1 -1
- package/src/lib/components/NButton.tsx +6 -4
- package/src/lib/components/NCheckbox.tsx +2 -2
- package/src/lib/components/NDialog.tsx +2 -2
- package/src/lib/components/NDropdown.tsx +11 -9
- package/src/lib/components/NDropzone.tsx +4 -4
- package/src/lib/components/NIconButton.tsx +2 -2
- package/src/lib/components/NInput.tsx +1 -1
- package/src/lib/components/NLink.tsx +1 -1
- package/src/lib/components/NModal.tsx +4 -4
- package/src/lib/components/NPagination.css +4 -2
- package/src/lib/components/NPagination.tsx +1 -1
- package/src/lib/components/NSearchbar.tsx +1 -1
- package/src/lib/components/NSelect.tsx +1 -1
- package/src/lib/components/NSuggestionList.tsx +1 -1
- package/src/lib/components/NTable.css +2 -0
- package/src/lib/components/NTableAction.tsx +1 -1
- package/src/lib/components/NTextArea.tsx +1 -1
- package/src/lib/components/NTooltip.css +2 -0
- package/src/lib/components/NTooltip.tsx +42 -3
- package/src/lib/utils/component.tsx +1 -1
- package/tsconfig.lib.json +1 -0
- package/vite.config.ts +2 -0
- package/components/NAlert.d.ts +0 -29
- package/components/NAlert.js +0 -84
- package/components/NBadge.d.ts +0 -69
- package/components/NBadge.js +0 -64
- package/components/NBreadcrub.d.ts +0 -69
- package/components/NBreadcrub.js +0 -71
- package/components/NButton.d.ts +0 -60
- package/components/NButton.js +0 -72
- package/components/NCheckbox.d.ts +0 -20
- package/components/NCheckbox.js +0 -43
- package/components/NCheckboxLabel.d.ts +0 -26
- package/components/NCheckboxLabel.js +0 -42
- package/components/NCrudModal.d.ts +0 -118
- package/components/NCrudModal.js +0 -120
- package/components/NDialog.d.ts +0 -81
- package/components/NDialog.js +0 -161
- package/components/NDropdown.d.ts +0 -67
- package/components/NDropdown.js +0 -115
- package/components/NDropzone.d.ts +0 -61
- package/components/NDropzone.js +0 -218
- package/components/NForm.d.ts +0 -21
- package/components/NForm.js +0 -29
- package/components/NFormModal.d.ts +0 -75
- package/components/NFormModal.js +0 -59
- package/components/NIconButton.d.ts +0 -79
- package/components/NIconButton.js +0 -88
- package/components/NIconCircle.d.ts +0 -49
- package/components/NIconCircle.js +0 -67
- package/components/NInput.css +0 -11
- package/components/NInput.d.ts +0 -90
- package/components/NInput.js +0 -110
- package/components/NInputPhone.d.ts +0 -54
- package/components/NInputPhone.js +0 -47
- package/components/NInputSelect.d.ts +0 -99
- package/components/NInputSelect.js +0 -115
- package/components/NInputSuggestion.d.ts +0 -75
- package/components/NInputSuggestion.js +0 -64
- package/components/NLink.d.ts +0 -47
- package/components/NLink.js +0 -67
- package/components/NList.d.ts +0 -37
- package/components/NList.js +0 -40
- package/components/NLoadingIndicator.css +0 -46
- package/components/NLoadingIndicator.d.ts +0 -29
- package/components/NLoadingIndicator.js +0 -54
- package/components/NModal.d.ts +0 -133
- package/components/NModal.js +0 -232
- package/components/NPagination.css +0 -15
- package/components/NPagination.d.ts +0 -37
- package/components/NPagination.js +0 -105
- package/components/NSearchbar.d.ts +0 -39
- package/components/NSearchbar.js +0 -64
- package/components/NSearchbarList.d.ts +0 -33
- package/components/NSearchbarList.js +0 -41
- package/components/NSelect.d.ts +0 -78
- package/components/NSelect.js +0 -101
- package/components/NSuggestionList.d.ts +0 -153
- package/components/NSuggestionList.js +0 -160
- package/components/NTable.css +0 -3
- package/components/NTable.d.ts +0 -97
- package/components/NTable.js +0 -128
- package/components/NTableAction.d.ts +0 -30
- package/components/NTableAction.js +0 -50
- package/components/NTextArea.d.ts +0 -92
- package/components/NTextArea.js +0 -133
- package/components/NTooltip.css +0 -37
- package/components/NTooltip.d.ts +0 -136
- package/components/NTooltip.js +0 -207
- package/components/NValInput.d.ts +0 -155
- package/components/NValInput.js +0 -113
- package/components/ValidatedForm.d.ts +0 -39
- package/components/ValidatedForm.js +0 -35
- package/i18n/de/vue-collection.json +0 -58
- package/i18n/en/vue-collection.json +0 -58
- package/i18n/index.d.ts +0 -40
- package/i18n/index.js +0 -31
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/tailwind.config.js +0 -38
- package/utils/breakpoints.d.ts +0 -18
- package/utils/breakpoints.js +0 -40
- package/utils/component.d.ts +0 -57
- package/utils/component.js +0 -79
- package/utils/deferred.d.ts +0 -13
- package/utils/deferred.js +0 -17
- package/utils/identifiable.d.ts +0 -56
- package/utils/identifiable.js +0 -81
- package/utils/stringMaxLength.d.ts +0 -14
- package/utils/stringMaxLength.js +0 -23
- package/utils/tailwind.d.ts +0 -4
- package/utils/tailwind.js +0 -1
- package/utils/utils.d.ts +0 -47
- package/utils/utils.js +0 -56
- package/utils/vModel.d.ts +0 -182
- package/utils/vModel.js +0 -224
- package/utils/validation.d.ts +0 -90
- package/utils/validation.js +0 -147
- package/utils/vue.d.ts +0 -13
- package/utils/vue.js +0 -21
package/components/NTable.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
|
-
import { isWidthBreakpoint } from '../utils/breakpoints';
|
|
3
|
-
import { createComponent } from '../utils/component';
|
|
4
|
-
import { ChevronLeftIcon } from '@heroicons/vue/24/solid';
|
|
5
|
-
import { computed, Fragment, ref, watch } from 'vue';
|
|
6
|
-
import NIconButton from './NIconButton';
|
|
7
|
-
import './NTable.css';
|
|
8
|
-
const N_TABLE_ACTION_KEY = 'action';
|
|
9
|
-
export const nTableProps = {
|
|
10
|
-
/**
|
|
11
|
-
* The headings of the table. These define which columns are shown in the table and in which order.
|
|
12
|
-
*/
|
|
13
|
-
headings: {
|
|
14
|
-
type: Array,
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* Adds the classes to all headings at the top of the table.
|
|
19
|
-
*/
|
|
20
|
-
headingsClass: String,
|
|
21
|
-
/**
|
|
22
|
-
* Adds the classes to all headings in the details of the table.
|
|
23
|
-
*/
|
|
24
|
-
headingDetailsClass: String,
|
|
25
|
-
/**
|
|
26
|
-
* The items of the table. They consist of an array of table rows.
|
|
27
|
-
* Every tablerow is an object containing elements for the heading keys.
|
|
28
|
-
* The elements can either be a primitive value or a function which returns a {@link JSX.Element}.
|
|
29
|
-
* If the item should be treated as an action (e.g. icon-button to display at the end of the row)
|
|
30
|
-
* the dedicated key 'action' can be used.
|
|
31
|
-
* @see TableRow
|
|
32
|
-
* @example
|
|
33
|
-
* // These headings are defined
|
|
34
|
-
* const headings: TableHeading[] = [
|
|
35
|
-
* { key: 'id', label: 'ID' },
|
|
36
|
-
* { key: 'name', label: 'Name' },
|
|
37
|
-
* { key: 'status', label: 'Status' }
|
|
38
|
-
* ]
|
|
39
|
-
*
|
|
40
|
-
* // Appropriate rows for these headings
|
|
41
|
-
* const items: TableRow[] = [
|
|
42
|
-
* { id: 1, name: 'Hubert', status: () => <NBadge ... />, action: ... }, // Row 1
|
|
43
|
-
* { id: 2, name: 'Franzi', status: () => <NBadge ... />, action: ... } // Row 2
|
|
44
|
-
* ]
|
|
45
|
-
*/
|
|
46
|
-
items: {
|
|
47
|
-
type: Array,
|
|
48
|
-
default: () => []
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* The `NTable` is a styled html table which accepts data and displays it appropriately.
|
|
53
|
-
*/
|
|
54
|
-
const Component = createComponent('NTable', nTableProps, props => {
|
|
55
|
-
const headings = computed(() => {
|
|
56
|
-
// filter out details headings
|
|
57
|
-
const headings = props.headings.filter(heading => !isHeadingDetail(heading));
|
|
58
|
-
// The column for actions is shown if there are details
|
|
59
|
-
// or if any of the items contain an element with the action-key.
|
|
60
|
-
if (showDetails.value || props.items.filter(row => row.action != null).length != 0) {
|
|
61
|
-
headings.push({
|
|
62
|
-
key: N_TABLE_ACTION_KEY
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return headings;
|
|
66
|
-
});
|
|
67
|
-
const details = computed(() => props.headings.filter(isHeadingDetail));
|
|
68
|
-
const showDetails = computed(() => details.value.length > 0);
|
|
69
|
-
const detailsOpen = ref([]);
|
|
70
|
-
const isDetailsOpen = index => detailsOpen.value[index] || false;
|
|
71
|
-
const toggleDetailsOpen = index => detailsOpen.value[index] = !detailsOpen.value[index];
|
|
72
|
-
// if the items change, reset all open details to closed
|
|
73
|
-
// and create correct amount of booleans for all items
|
|
74
|
-
watch(() => props.items, newItems => detailsOpen.value = Array({
|
|
75
|
-
length: newItems.length
|
|
76
|
-
}).map(() => false), {
|
|
77
|
-
immediate: true
|
|
78
|
-
});
|
|
79
|
-
return () => _createVNode("div", {
|
|
80
|
-
"class": "overflow-x-auto"
|
|
81
|
-
}, [_createVNode("table", {
|
|
82
|
-
"class": "min-w-full text-default-500 text-sm"
|
|
83
|
-
}, [_createVNode("thead", {
|
|
84
|
-
"class": "bg-default-50 "
|
|
85
|
-
}, [_createVNode("tr", null, [headings.value.map(heading => _createVNode("th", {
|
|
86
|
-
"key": heading.key,
|
|
87
|
-
"scope": "col",
|
|
88
|
-
"class": `p-4 table-heading ${props.headingsClass}`
|
|
89
|
-
}, [buildItem(heading.label)]))])]), props.items.length > 0 && props.items.map((item, itemIndex) => _createVNode(_Fragment, {
|
|
90
|
-
"key": itemIndex
|
|
91
|
-
}, [_createVNode("tbody", {
|
|
92
|
-
"class": ['border-default-200 border-t', itemIndex % 2 === 0 ? 'bg-white' : 'bg-default-50', item.rowClass]
|
|
93
|
-
}, [_createVNode("tr", null, [headings.value.map(heading => _createVNode("td", {
|
|
94
|
-
"key": itemIndex + '-' + heading.key,
|
|
95
|
-
"class": "p-4"
|
|
96
|
-
}, [_createVNode("div", {
|
|
97
|
-
"class": ['flex', heading.emph ? 'font-medium text-default-900' : '', heading.cellClass, heading.key == N_TABLE_ACTION_KEY ? 'justify-end items-center space-x-3' : '']
|
|
98
|
-
}, [item[heading.key] && buildItem(item[heading.key]), heading.key == N_TABLE_ACTION_KEY && showDetails.value && _createVNode("div", {
|
|
99
|
-
"class": "inline-flex transition-transform duration-200",
|
|
100
|
-
"style": {
|
|
101
|
-
transform: isDetailsOpen(itemIndex) ? 'rotate(-90deg)' : 'rotate(0deg)',
|
|
102
|
-
transformOrigin: 'center center'
|
|
103
|
-
}
|
|
104
|
-
}, [_createVNode(NIconButton, {
|
|
105
|
-
"icon": ChevronLeftIcon,
|
|
106
|
-
"onClick": () => toggleDetailsOpen(itemIndex)
|
|
107
|
-
}, null)])])]))])]), showDetails.value && isDetailsOpen(itemIndex) && _createVNode("tbody", {
|
|
108
|
-
"class": [itemIndex % 2 === 0 ? 'bg-white' : 'bg-default-50', item.detailsClass]
|
|
109
|
-
}, [details.value.map((detail, detailIndex) => _createVNode("tr", {
|
|
110
|
-
"key": `detail-${detailIndex}`
|
|
111
|
-
}, [_createVNode("td", {
|
|
112
|
-
"class": ['table-heading px-4 py-1', props.headingDetailsClass, details.value.length - 1 == detailIndex ? 'pb-4' : '']
|
|
113
|
-
}, [buildItem(detail.label)]), _createVNode("td", {
|
|
114
|
-
"class": ['px-4 py-1', details.value[detailIndex]?.detailsClass, details.value.length - 1 == detailIndex ? 'pb-4' : ''],
|
|
115
|
-
"colspan": headings.value.length - 1
|
|
116
|
-
}, [item[detail.key] && buildItem(item[detail.key])])]))])]))])]);
|
|
117
|
-
});
|
|
118
|
-
export { Component as NTable, Component as default };
|
|
119
|
-
/**
|
|
120
|
-
* Builds a JSX-Element out of the item
|
|
121
|
-
*/
|
|
122
|
-
function buildItem(item) {
|
|
123
|
-
if (item === undefined) return undefined;else if (typeof item == 'string' || typeof item == 'number') return _createVNode(_Fragment, null, [item]);else return item();
|
|
124
|
-
}
|
|
125
|
-
function isHeadingDetail(heading) {
|
|
126
|
-
// take all headings which are details or below the breakpoint
|
|
127
|
-
return heading.isDetail || heading.breakpoint !== undefined && !isWidthBreakpoint(heading.breakpoint).value;
|
|
128
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
readonly route: PropType<RouteLocationRaw>;
|
|
8
|
-
/**
|
|
9
|
-
* The text of the action.
|
|
10
|
-
*/
|
|
11
|
-
readonly text: StringConstructor;
|
|
12
|
-
/**
|
|
13
|
-
* The html attribute, which indicates the type of the button.
|
|
14
|
-
*/
|
|
15
|
-
readonly type: {
|
|
16
|
-
readonly type: PropType<"submit" | "button" | "reset">;
|
|
17
|
-
readonly default: "button";
|
|
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
|
-
readonly 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 Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
30
|
-
export { Component as NTableAction, Component as default };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, createVNode as _createVNode, isVNode as _isVNode } from "vue";
|
|
2
|
-
import { createComponent } from '../utils/component';
|
|
3
|
-
import { RouterLink } from 'vue-router';
|
|
4
|
-
import { nButtonProps } from './NButton';
|
|
5
|
-
function _isSlot(s) {
|
|
6
|
-
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
|
7
|
-
}
|
|
8
|
-
export const nTableActionProps = {
|
|
9
|
-
/**
|
|
10
|
-
* The route of the action. If set the component will be a {@link RouterLink}.
|
|
11
|
-
*/
|
|
12
|
-
route: [String, Object],
|
|
13
|
-
/**
|
|
14
|
-
* The text of the action.
|
|
15
|
-
*/
|
|
16
|
-
text: String,
|
|
17
|
-
/**
|
|
18
|
-
* The html attribute, which indicates the type of the button.
|
|
19
|
-
*/
|
|
20
|
-
type: nButtonProps.type,
|
|
21
|
-
/**
|
|
22
|
-
* This is called when the action is clicked.
|
|
23
|
-
* It is only called when the `route` prop is not set on the action.
|
|
24
|
-
*/
|
|
25
|
-
onClick: Function
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The `NTableAction` is a button or {@link RouterLink} which is styled to fit into a table.
|
|
29
|
-
* It is basically styled as an emphasized text in the table.
|
|
30
|
-
*/
|
|
31
|
-
const Component = createComponent('NTableAction', nTableActionProps, (props, {
|
|
32
|
-
slots
|
|
33
|
-
}) => {
|
|
34
|
-
const content = () => slots.default?.() || _createVNode(_Fragment, null, [props.text]);
|
|
35
|
-
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'];
|
|
36
|
-
return () => {
|
|
37
|
-
let _slot;
|
|
38
|
-
return props.route ? _createVNode(RouterLink, {
|
|
39
|
-
"to": props.route,
|
|
40
|
-
"class": classes
|
|
41
|
-
}, _isSlot(_slot = content()) ? _slot : {
|
|
42
|
-
default: () => [_slot]
|
|
43
|
-
}) : _createVNode("button", {
|
|
44
|
-
"type": props.type,
|
|
45
|
-
"class": classes,
|
|
46
|
-
"onClick": props.onClick
|
|
47
|
-
}, [content()]);
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
export { Component as NTableAction, Component as default };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { type PropType } from 'vue';
|
|
2
|
-
export declare const nTextAreaProps: {
|
|
3
|
-
readonly disableValidation: BooleanConstructor;
|
|
4
|
-
readonly optional: BooleanConstructor;
|
|
5
|
-
readonly rules: {
|
|
6
|
-
readonly type: PropType<import("../utils/validation").ValidationRule[] | import("../utils/validation").ValidationRule>;
|
|
7
|
-
readonly default: () => never[];
|
|
8
|
-
};
|
|
9
|
-
readonly form: 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: PropType<() => JSX.Element>;
|
|
16
|
-
readonly tooltipHide: BooleanConstructor;
|
|
17
|
-
readonly tooltipShow: BooleanConstructor;
|
|
18
|
-
readonly tooltipPlacement: {
|
|
19
|
-
readonly type: PropType<import("./NTooltip").TooltipPlacement>;
|
|
20
|
-
readonly default: "auto";
|
|
21
|
-
};
|
|
22
|
-
readonly tooltipMaxWidth: {
|
|
23
|
-
readonly type: 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
|
-
/**
|
|
30
|
-
* The name of the text area. Is displayed as a label above the text area.
|
|
31
|
-
*/
|
|
32
|
-
readonly name: StringConstructor;
|
|
33
|
-
/**
|
|
34
|
-
* The placeholder of the text area.
|
|
35
|
-
*/
|
|
36
|
-
readonly placeholder: StringConstructor;
|
|
37
|
-
/**
|
|
38
|
-
* The html autocomplete attribute of the text area.
|
|
39
|
-
*/
|
|
40
|
-
readonly autocomplete: {
|
|
41
|
-
readonly type: StringConstructor;
|
|
42
|
-
readonly default: "off";
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* If set to `true`, the text area is resizable in y-direction.
|
|
46
|
-
*/
|
|
47
|
-
readonly resizable: {
|
|
48
|
-
readonly type: BooleanConstructor;
|
|
49
|
-
readonly default: true;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* The initial height of the text area in terms of
|
|
53
|
-
* how many text rows fit inside the text area.
|
|
54
|
-
* The height can be change if {@link nTextAreaProps.resizable} is `true`
|
|
55
|
-
*/
|
|
56
|
-
readonly rows: NumberConstructor;
|
|
57
|
-
/**
|
|
58
|
-
* The maximum length of the input string. Entering longer strings are simply
|
|
59
|
-
* prevented, but no error message is shown to the user.
|
|
60
|
-
*/
|
|
61
|
-
readonly maxLength: NumberConstructor;
|
|
62
|
-
/**
|
|
63
|
-
* If set to `true` the text area is disabled and no interaction is possible.
|
|
64
|
-
*/
|
|
65
|
-
readonly disabled: BooleanConstructor;
|
|
66
|
-
/**
|
|
67
|
-
* If set to `true` the text area's label is hidden.
|
|
68
|
-
*/
|
|
69
|
-
readonly hideLabel: BooleanConstructor;
|
|
70
|
-
/**
|
|
71
|
-
* Adds the classes directly to the input (e.g. for shadow).
|
|
72
|
-
*/
|
|
73
|
-
readonly inputClass: StringConstructor;
|
|
74
|
-
/**
|
|
75
|
-
* This is called when the text area reveices focus.
|
|
76
|
-
*/
|
|
77
|
-
readonly onFocus: PropType<() => void>;
|
|
78
|
-
/**
|
|
79
|
-
* This is called when the text area looses focus.
|
|
80
|
-
*/
|
|
81
|
-
readonly onBlur: PropType<() => void>;
|
|
82
|
-
readonly value: PropType<string>;
|
|
83
|
-
readonly onUpdateValue: PropType<(newValue: string) => void>;
|
|
84
|
-
};
|
|
85
|
-
export type NTextAreaExposed = {
|
|
86
|
-
/**
|
|
87
|
-
* Request focus on the text area.
|
|
88
|
-
*/
|
|
89
|
-
focus(): void;
|
|
90
|
-
};
|
|
91
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
92
|
-
export { Component as NTextArea, Component as default };
|
package/components/NTextArea.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { mergeProps as _mergeProps, createVNode as _createVNode, vShow as _vShow, withDirectives as _withDirectives } 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 { vModelProps } from '../utils/vModel';
|
|
7
|
-
import NValInput, { validationProps } from './NValInput';
|
|
8
|
-
const nTextAreaBaseProps = {
|
|
9
|
-
...vModelProps(String),
|
|
10
|
-
/**
|
|
11
|
-
* The name of the text area. Is displayed as a label above the text area.
|
|
12
|
-
*/
|
|
13
|
-
name: String,
|
|
14
|
-
/**
|
|
15
|
-
* The placeholder of the text area.
|
|
16
|
-
*/
|
|
17
|
-
placeholder: String,
|
|
18
|
-
/**
|
|
19
|
-
* The html autocomplete attribute of the text area.
|
|
20
|
-
*/
|
|
21
|
-
autocomplete: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: 'off'
|
|
24
|
-
},
|
|
25
|
-
/**
|
|
26
|
-
* If set to `true`, the text area is resizable in y-direction.
|
|
27
|
-
*/
|
|
28
|
-
resizable: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
default: true
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* The initial height of the text area in terms of
|
|
34
|
-
* how many text rows fit inside the text area.
|
|
35
|
-
* The height can be change if {@link nTextAreaProps.resizable} is `true`
|
|
36
|
-
*/
|
|
37
|
-
rows: Number,
|
|
38
|
-
/**
|
|
39
|
-
* The maximum length of the input string. Entering longer strings are simply
|
|
40
|
-
* prevented, but no error message is shown to the user.
|
|
41
|
-
*/
|
|
42
|
-
maxLength: Number,
|
|
43
|
-
/**
|
|
44
|
-
* If set to `true` the text area is displayed with a red border.
|
|
45
|
-
*/
|
|
46
|
-
error: Boolean,
|
|
47
|
-
/**
|
|
48
|
-
* If set to `true` the text area is disabled and no interaction is possible.
|
|
49
|
-
*/
|
|
50
|
-
disabled: Boolean,
|
|
51
|
-
/**
|
|
52
|
-
* If set to `true` the text area's label is hidden.
|
|
53
|
-
*/
|
|
54
|
-
hideLabel: Boolean,
|
|
55
|
-
/**
|
|
56
|
-
* Adds the classes directly to the input (e.g. for shadow).
|
|
57
|
-
*/
|
|
58
|
-
inputClass: String,
|
|
59
|
-
/**
|
|
60
|
-
* This is called when the text area reveices focus.
|
|
61
|
-
*/
|
|
62
|
-
onFocus: Function,
|
|
63
|
-
/**
|
|
64
|
-
* This is called when the text area looses focus.
|
|
65
|
-
*/
|
|
66
|
-
onBlur: Function,
|
|
67
|
-
...nToolTipPropsForImplementor
|
|
68
|
-
};
|
|
69
|
-
export const nTextAreaProps = {
|
|
70
|
-
...nTextAreaBaseProps,
|
|
71
|
-
...validationProps
|
|
72
|
-
};
|
|
73
|
-
const Component = createComponent('NTextArea', nTextAreaProps, (props, context) => {
|
|
74
|
-
const textAreaRef = ref();
|
|
75
|
-
const exposed = {
|
|
76
|
-
focus: () => textAreaRef.value?.focus()
|
|
77
|
-
};
|
|
78
|
-
context.expose(exposed);
|
|
79
|
-
return () => _createVNode(NValInput, _mergeProps(props, {
|
|
80
|
-
"input": ({
|
|
81
|
-
error,
|
|
82
|
-
onBlur,
|
|
83
|
-
onUpdateValue
|
|
84
|
-
}) => _createVNode(NTextAreaBase, _mergeProps({
|
|
85
|
-
"ref": textAreaRef
|
|
86
|
-
}, {
|
|
87
|
-
...props,
|
|
88
|
-
error,
|
|
89
|
-
onBlur,
|
|
90
|
-
onUpdateValue
|
|
91
|
-
}), null)
|
|
92
|
-
}), null);
|
|
93
|
-
});
|
|
94
|
-
export { Component as NTextArea, Component as default };
|
|
95
|
-
/**
|
|
96
|
-
* The `NTextArea` wraps the html text area with all the features from {@link NInput} and {@link NValInput}.
|
|
97
|
-
*/
|
|
98
|
-
const NTextAreaBase = createComponent('NTextAreaBase', nTextAreaBaseProps, (props, context) => {
|
|
99
|
-
const textAreaRef = ref();
|
|
100
|
-
const exposed = {
|
|
101
|
-
focus: () => textAreaRef.value?.focus()
|
|
102
|
-
};
|
|
103
|
-
context.expose(exposed);
|
|
104
|
-
return () => _createVNode("div", null, [props.name && !props.hideLabel && _createVNode("label", {
|
|
105
|
-
"for": props.name,
|
|
106
|
-
"class": ['block text-sm font-medium mb-1', props.disabled ? 'text-default-300' : 'text-default-700']
|
|
107
|
-
}, [props.name]), _createVNode(NTooltip, _mergeProps({
|
|
108
|
-
"block": true
|
|
109
|
-
}, mapTooltipProps(props)), {
|
|
110
|
-
default: () => [_createVNode("div", {
|
|
111
|
-
"class": "relative"
|
|
112
|
-
}, [_createVNode("textarea", {
|
|
113
|
-
"ref": textAreaRef,
|
|
114
|
-
"name": props.name,
|
|
115
|
-
"value": props.value,
|
|
116
|
-
"onInput": event => props.onUpdateValue?.(event.target.value),
|
|
117
|
-
"placeholder": props.placeholder,
|
|
118
|
-
"autocomplete": props.autocomplete,
|
|
119
|
-
"disabled": props.disabled,
|
|
120
|
-
"rows": props.rows,
|
|
121
|
-
"maxlength": props.maxLength,
|
|
122
|
-
"onFocus": () => props.onFocus?.(),
|
|
123
|
-
"onBlur": () => props.onBlur?.(),
|
|
124
|
-
"onInvalid": event => event.preventDefault(),
|
|
125
|
-
"class": ['block w-full rounded-md border focus:outline-none focus:ring-1 ', 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.resizable ? 'resize-y' : 'resize-none', props.inputClass]
|
|
126
|
-
}, null), _withDirectives(_createVNode("div", {
|
|
127
|
-
"class": "absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none"
|
|
128
|
-
}, [_createVNode(ExclamationCircleIcon, {
|
|
129
|
-
"class": "h-5 w-5 text-red-700",
|
|
130
|
-
"aria-hidden": "true"
|
|
131
|
-
}, null)]), [[_vShow, props.error]])])]
|
|
132
|
-
})]);
|
|
133
|
-
});
|
package/components/NTooltip.css
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|
package/components/NTooltip.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { type ExtractedProps } from '../utils/component';
|
|
2
|
-
import type { TWMaxWidth } from '../utils/tailwind';
|
|
3
|
-
import { type PropType } from 'vue';
|
|
4
|
-
import './NTooltip.css';
|
|
5
|
-
export declare const nTooltipProps: {
|
|
6
|
-
/**
|
|
7
|
-
* The text content of the tooltip.
|
|
8
|
-
*/
|
|
9
|
-
readonly text: StringConstructor;
|
|
10
|
-
/**
|
|
11
|
-
* A slot to replace the content of the tooltip. This will override the `text` prop.
|
|
12
|
-
*/
|
|
13
|
-
readonly content: PropType<() => JSX.Element>;
|
|
14
|
-
/**
|
|
15
|
-
* If set to `true` the tooltip is shown constantly.
|
|
16
|
-
*/
|
|
17
|
-
readonly show: BooleanConstructor;
|
|
18
|
-
/**
|
|
19
|
-
* If set to `true` the tooltip is hidden constantly.
|
|
20
|
-
*/
|
|
21
|
-
readonly hide: BooleanConstructor;
|
|
22
|
-
/**
|
|
23
|
-
* If set to `true` the `block` class is applied to the tooltip.
|
|
24
|
-
* This should be set if the content in the default slot is also block.
|
|
25
|
-
*/
|
|
26
|
-
readonly block: BooleanConstructor;
|
|
27
|
-
/**
|
|
28
|
-
* The placement of the tooltip.
|
|
29
|
-
*/
|
|
30
|
-
readonly placement: {
|
|
31
|
-
readonly type: PropType<TooltipPlacement>;
|
|
32
|
-
readonly default: "auto";
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* The maximum width of the tooltip.
|
|
36
|
-
*/
|
|
37
|
-
readonly maxWidth: {
|
|
38
|
-
readonly type: PropType<TWMaxWidth>;
|
|
39
|
-
readonly default: "max-w-xs";
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Adds the classes to the (invisible) wrapper element.
|
|
43
|
-
*/
|
|
44
|
-
readonly wrapperClass: StringConstructor;
|
|
45
|
-
/**
|
|
46
|
-
* Adds the classes to the container of the tooltips content.
|
|
47
|
-
*/
|
|
48
|
-
readonly contentClass: StringConstructor;
|
|
49
|
-
/**
|
|
50
|
-
* Adds the classes to the tooltip arrow. Make sure to use `before:` classes
|
|
51
|
-
* to target the arrow (which is the before element).
|
|
52
|
-
*/
|
|
53
|
-
readonly arrowClass: StringConstructor;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* These props are made to use on a component which implements the tooltip
|
|
57
|
-
* and wants it to be controllable via the own props.
|
|
58
|
-
* e.g. `text` is now called `tooltipText`.
|
|
59
|
-
* They can be mapped to the normal tooltip props with {@link mapTooltipProps}
|
|
60
|
-
*/
|
|
61
|
-
export declare const nToolTipPropsForImplementor: {
|
|
62
|
-
/**
|
|
63
|
-
* Adds a tooltip to the component with the specified text.
|
|
64
|
-
* @see {@link nTooltipProps.text}
|
|
65
|
-
*/
|
|
66
|
-
tooltipText: StringConstructor;
|
|
67
|
-
/**
|
|
68
|
-
* A slot for the tooltip of this component.
|
|
69
|
-
* If the slot is set, the tooltip with the specified content is added to the component.
|
|
70
|
-
* @see {@link nTooltipProps.content}
|
|
71
|
-
*/
|
|
72
|
-
tooltipContent: PropType<() => JSX.Element>;
|
|
73
|
-
/**
|
|
74
|
-
* @see {@link nTooltipProps.hide}
|
|
75
|
-
*/
|
|
76
|
-
tooltipHide: BooleanConstructor;
|
|
77
|
-
/**
|
|
78
|
-
* @see {@link nTooltipProps.show}
|
|
79
|
-
*/
|
|
80
|
-
tooltipShow: BooleanConstructor;
|
|
81
|
-
/**
|
|
82
|
-
* @see {@link nTooltipProps.placement}
|
|
83
|
-
*/
|
|
84
|
-
tooltipPlacement: {
|
|
85
|
-
readonly type: PropType<TooltipPlacement>;
|
|
86
|
-
readonly default: "auto";
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* @see {@link nTooltipProps.maxWidth}
|
|
90
|
-
*/
|
|
91
|
-
tooltipMaxWidth: {
|
|
92
|
-
readonly type: PropType<TWMaxWidth>;
|
|
93
|
-
readonly default: "max-w-xs";
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* @see {@link nTooltipProps.wrapperClass}
|
|
97
|
-
*/
|
|
98
|
-
tooltipWrapperClass: StringConstructor;
|
|
99
|
-
/**
|
|
100
|
-
* @see {@link nTooltipProps.contentClass}
|
|
101
|
-
*/
|
|
102
|
-
tooltipContentClass: StringConstructor;
|
|
103
|
-
/**
|
|
104
|
-
* @see {@link nTooltipProps.arrowClass}
|
|
105
|
-
*/
|
|
106
|
-
tooltipArrowClass: StringConstructor;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Maps the {@link nToolTipPropsForImplementor} props to normal tooltip props
|
|
110
|
-
* @returns an object containing the normal tooltip props.
|
|
111
|
-
*/
|
|
112
|
-
export declare function mapTooltipProps(props: ExtractedProps<typeof nToolTipPropsForImplementor>): {
|
|
113
|
-
text: string | undefined;
|
|
114
|
-
content: (() => JSX.Element) | undefined;
|
|
115
|
-
hide: boolean;
|
|
116
|
-
show: boolean;
|
|
117
|
-
placement: TooltipPlacement;
|
|
118
|
-
maxWidth: TWMaxWidth;
|
|
119
|
-
wrapperClass: string | undefined;
|
|
120
|
-
contentClass: string | undefined;
|
|
121
|
-
arrowClass: string | undefined;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* The `NTooltip` is a wrapper for any component which adds a tooltip to it.
|
|
125
|
-
* Any component can just be passed in the default slot and a tooltip will be added to it.
|
|
126
|
-
* Note that this component disappears when neither the `text` nor the `content`
|
|
127
|
-
* prop is passed as the tooltip would then be empty.
|
|
128
|
-
* If this is the case, the default slot will just be rendered inside a div.
|
|
129
|
-
* @example
|
|
130
|
-
* <NTooltip text="Hello">
|
|
131
|
-
* <NButton />
|
|
132
|
-
* </NTooltip>
|
|
133
|
-
*/
|
|
134
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
135
|
-
export { Component as NTooltip, Component as default };
|
|
136
|
-
export type TooltipPlacement = 'auto' | 'auto-start' | 'auto-end' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
|