@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
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
|
|
2
|
-
import { createComponent } from '../utils/component';
|
|
3
|
-
import NCheckbox, { nCheckboxProps } from './NCheckbox';
|
|
4
|
-
export const nCheckboxLabelProps = {
|
|
5
|
-
...nCheckboxProps,
|
|
6
|
-
/**
|
|
7
|
-
* The title of the checkbox.
|
|
8
|
-
*/
|
|
9
|
-
title: String,
|
|
10
|
-
/**
|
|
11
|
-
* The description of the checkbox.
|
|
12
|
-
*/
|
|
13
|
-
description: String,
|
|
14
|
-
/**
|
|
15
|
-
* If set to `true`, a smaller margin is applied between the label and the checkbox.
|
|
16
|
-
*/
|
|
17
|
-
compact: Boolean
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* The `NCheckboxLabel` is a checkbox with a title and a description.
|
|
21
|
-
*/
|
|
22
|
-
const Component = createComponent('NCheckboxLabel', nCheckboxLabelProps, props => {
|
|
23
|
-
const toggleValue = () => {
|
|
24
|
-
if (!props.disabled) props.onUpdateValue?.(!props.value);
|
|
25
|
-
};
|
|
26
|
-
return () => _createVNode("div", {
|
|
27
|
-
"class": `flex ${props.description ? 'items-start' : 'items-center'}`
|
|
28
|
-
}, [_createVNode(NCheckbox, _mergeProps(props, {
|
|
29
|
-
"class": props.description ? 'mt-1' : ''
|
|
30
|
-
}), null), _createVNode("div", {
|
|
31
|
-
"class": `${props.compact ? 'ml-2' : 'ml-3'} text-sm`
|
|
32
|
-
}, [_createVNode("label", {
|
|
33
|
-
"onClick": toggleValue,
|
|
34
|
-
"class": ['font-medium select-none', props.disabled ? 'text-default-300' : 'text-default-700 cursor-pointer']
|
|
35
|
-
}, [props.title]), _createVNode("p", {
|
|
36
|
-
"class": props.disabled ? 'text-default-300' : 'text-default-500'
|
|
37
|
-
}, [_createVNode("span", {
|
|
38
|
-
"onClick": toggleValue,
|
|
39
|
-
"class": ['select-none', props.disabled ? '' : 'cursor-pointer']
|
|
40
|
-
}, [props.description])])])]);
|
|
41
|
-
});
|
|
42
|
-
export { Component as NCheckboxLabel, Component as default };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { type PropType } from 'vue';
|
|
2
|
-
import type { DialogVariant } from './NDialog';
|
|
3
|
-
export declare const nCrudModalProps: {
|
|
4
|
-
/**
|
|
5
|
-
* The text of the remove-button.
|
|
6
|
-
*/
|
|
7
|
-
readonly removeText: {
|
|
8
|
-
readonly type: StringConstructor;
|
|
9
|
-
readonly default: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* The color of the remove-button.
|
|
13
|
-
*/
|
|
14
|
-
readonly removeColor: {
|
|
15
|
-
readonly type: StringConstructor;
|
|
16
|
-
readonly default: "red";
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* If set to `true` the remove-button is disabled.
|
|
20
|
-
*/
|
|
21
|
-
readonly removeDisabled: BooleanConstructor;
|
|
22
|
-
/**
|
|
23
|
-
* If set to `true` the ok-button is hidden.
|
|
24
|
-
*/
|
|
25
|
-
readonly hideRemove: BooleanConstructor;
|
|
26
|
-
/**
|
|
27
|
-
* If set to `true` the ok-button is disabled.
|
|
28
|
-
*/
|
|
29
|
-
readonly okDisabled: BooleanConstructor;
|
|
30
|
-
/**
|
|
31
|
-
* The title of the dialog which appears when clicking on the remove-button.
|
|
32
|
-
*/
|
|
33
|
-
readonly removeDialogTitle: StringConstructor;
|
|
34
|
-
/**
|
|
35
|
-
* The text of the dialog which appears when clicking on the remove-button.
|
|
36
|
-
*/
|
|
37
|
-
readonly removeDialogText: StringConstructor;
|
|
38
|
-
/**
|
|
39
|
-
* The variant of the dialog which appears when clicking on the remove-button. Default is `remove`.
|
|
40
|
-
*/
|
|
41
|
-
readonly removeDialogVariant: {
|
|
42
|
-
readonly type: PropType<DialogVariant>;
|
|
43
|
-
readonly default: "remove";
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The text of the dialog's ok-button. Is already set by the `removeDialogVariant` but can be overridden.
|
|
47
|
-
*/
|
|
48
|
-
readonly removeDialogOkText: StringConstructor;
|
|
49
|
-
/**
|
|
50
|
-
* If set to `true` the modal will close itself when `onRemove` is called.
|
|
51
|
-
*/
|
|
52
|
-
readonly closeOnRemove: {
|
|
53
|
-
readonly type: BooleanConstructor;
|
|
54
|
-
readonly default: true;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* This is called, when the remove-button has been clicked and the dialog has been accepted.
|
|
58
|
-
*/
|
|
59
|
-
readonly onRemove: PropType<() => void>;
|
|
60
|
-
readonly maxWidth: {
|
|
61
|
-
readonly type: PropType<import("../utils/tailwind").TWMaxWidth>;
|
|
62
|
-
readonly default: "max-w-lg";
|
|
63
|
-
};
|
|
64
|
-
readonly closeOnBackground: {
|
|
65
|
-
readonly type: BooleanConstructor;
|
|
66
|
-
readonly default: false;
|
|
67
|
-
};
|
|
68
|
-
readonly form: PropType<import("./ValidatedForm").ValidatedForm>;
|
|
69
|
-
readonly hideHeader: BooleanConstructor;
|
|
70
|
-
readonly hideFooter: BooleanConstructor;
|
|
71
|
-
readonly hideX: BooleanConstructor;
|
|
72
|
-
readonly verticalPosition: {
|
|
73
|
-
readonly type: PropType<"start" | "center" | "end">;
|
|
74
|
-
readonly default: "center";
|
|
75
|
-
};
|
|
76
|
-
readonly horizontalPosition: {
|
|
77
|
-
readonly type: PropType<"start" | "center" | "end">;
|
|
78
|
-
readonly default: "center";
|
|
79
|
-
};
|
|
80
|
-
readonly title: StringConstructor;
|
|
81
|
-
readonly okText: {
|
|
82
|
-
readonly type: StringConstructor;
|
|
83
|
-
readonly default: string;
|
|
84
|
-
};
|
|
85
|
-
readonly okColor: {
|
|
86
|
-
readonly type: StringConstructor;
|
|
87
|
-
readonly default: "primary";
|
|
88
|
-
};
|
|
89
|
-
readonly closeOnOk: {
|
|
90
|
-
readonly type: BooleanConstructor;
|
|
91
|
-
readonly default: true;
|
|
92
|
-
};
|
|
93
|
-
readonly hideOk: BooleanConstructor;
|
|
94
|
-
readonly cancelText: {
|
|
95
|
-
readonly type: StringConstructor;
|
|
96
|
-
readonly default: string;
|
|
97
|
-
};
|
|
98
|
-
readonly cancelColor: {
|
|
99
|
-
readonly type: StringConstructor;
|
|
100
|
-
readonly default: "default";
|
|
101
|
-
};
|
|
102
|
-
readonly hideCancel: BooleanConstructor;
|
|
103
|
-
readonly onOk: PropType<() => void>;
|
|
104
|
-
readonly onCancel: PropType<() => void>;
|
|
105
|
-
readonly modal: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
106
|
-
readonly content: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
107
|
-
readonly header: PropType<() => JSX.Element>;
|
|
108
|
-
readonly footer: PropType<(props: import("./NModal").ModalSlotProps) => JSX.Element>;
|
|
109
|
-
readonly value: PropType<boolean>;
|
|
110
|
-
readonly onUpdateValue: PropType<(newValue: boolean) => void>;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* The `NCrudModal` is a {@link NFormModal} which has some convenience features for a CRUD-scenario.
|
|
114
|
-
* It has an integrated remove-button with a user-dialog to remove the editing element.
|
|
115
|
-
* When the dialog is accepted `onRemove` is called.
|
|
116
|
-
*/
|
|
117
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
118
|
-
export { Component as NCrudModal, Component as default };
|
package/components/NCrudModal.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
2
|
-
import { trsl } from '../i18n';
|
|
3
|
-
import { createComponentWithSlots } from '../utils/component';
|
|
4
|
-
import { ref } from 'vue';
|
|
5
|
-
import NButton from './NButton';
|
|
6
|
-
import NDialog from './NDialog';
|
|
7
|
-
import NFormModal, { nFormModalProps } from './NFormModal';
|
|
8
|
-
export const nCrudModalProps = {
|
|
9
|
-
...nFormModalProps,
|
|
10
|
-
/**
|
|
11
|
-
* The text of the remove-button.
|
|
12
|
-
*/
|
|
13
|
-
removeText: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: trsl('vue-collection.action.remove')
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* The color of the remove-button.
|
|
19
|
-
*/
|
|
20
|
-
removeColor: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: 'red'
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* If set to `true` the remove-button is disabled.
|
|
26
|
-
*/
|
|
27
|
-
removeDisabled: Boolean,
|
|
28
|
-
/**
|
|
29
|
-
* If set to `true` the ok-button is hidden.
|
|
30
|
-
*/
|
|
31
|
-
hideRemove: Boolean,
|
|
32
|
-
/**
|
|
33
|
-
* If set to `true` the ok-button is disabled.
|
|
34
|
-
*/
|
|
35
|
-
okDisabled: Boolean,
|
|
36
|
-
/**
|
|
37
|
-
* The title of the dialog which appears when clicking on the remove-button.
|
|
38
|
-
*/
|
|
39
|
-
removeDialogTitle: String,
|
|
40
|
-
/**
|
|
41
|
-
* The text of the dialog which appears when clicking on the remove-button.
|
|
42
|
-
*/
|
|
43
|
-
removeDialogText: String,
|
|
44
|
-
/**
|
|
45
|
-
* The variant of the dialog which appears when clicking on the remove-button. Default is `remove`.
|
|
46
|
-
*/
|
|
47
|
-
removeDialogVariant: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: 'remove'
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* The text of the dialog's ok-button. Is already set by the `removeDialogVariant` but can be overridden.
|
|
53
|
-
*/
|
|
54
|
-
removeDialogOkText: String,
|
|
55
|
-
/**
|
|
56
|
-
* If set to `true` the modal will close itself when `onRemove` is called.
|
|
57
|
-
*/
|
|
58
|
-
closeOnRemove: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
default: true
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* This is called, when the remove-button has been clicked and the dialog has been accepted.
|
|
64
|
-
*/
|
|
65
|
-
onRemove: Function
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* The `NCrudModal` is a {@link NFormModal} which has some convenience features for a CRUD-scenario.
|
|
69
|
-
* It has an integrated remove-button with a user-dialog to remove the editing element.
|
|
70
|
-
* When the dialog is accepted `onRemove` is called.
|
|
71
|
-
*/
|
|
72
|
-
const Component = createComponentWithSlots('NCrudModal', nCrudModalProps, ['modal', 'footer', 'header'], (props, {
|
|
73
|
-
slots
|
|
74
|
-
}) => {
|
|
75
|
-
const removeDialog = ref();
|
|
76
|
-
const remove = () => {
|
|
77
|
-
removeDialog.value?.show().then(result => {
|
|
78
|
-
if (result) {
|
|
79
|
-
props.onRemove?.();
|
|
80
|
-
if (props.closeOnRemove) props.onUpdateValue?.(false);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return () => _createVNode(NFormModal, _mergeProps(props, {
|
|
85
|
-
"footer": props.footer || (({
|
|
86
|
-
ok,
|
|
87
|
-
cancel
|
|
88
|
-
}) => _createVNode("div", {
|
|
89
|
-
"class": "flex justify-between"
|
|
90
|
-
}, [_createVNode("div", null, [!props.hideRemove && _createVNode(NButton, {
|
|
91
|
-
"color": props.removeColor,
|
|
92
|
-
"onClick": remove,
|
|
93
|
-
"disabled": props.removeDisabled
|
|
94
|
-
}, {
|
|
95
|
-
default: () => [props.removeText]
|
|
96
|
-
})]), _createVNode("div", {
|
|
97
|
-
"class": "flex justify-end space-x-2"
|
|
98
|
-
}, [!props.hideCancel && _createVNode(NButton, {
|
|
99
|
-
"color": props.cancelColor,
|
|
100
|
-
"onClick": cancel
|
|
101
|
-
}, {
|
|
102
|
-
default: () => [props.cancelText]
|
|
103
|
-
}), !props.hideOk && _createVNode(NButton, {
|
|
104
|
-
"color": props.okColor,
|
|
105
|
-
"onClick": ok,
|
|
106
|
-
"disabled": props.okDisabled
|
|
107
|
-
}, {
|
|
108
|
-
default: () => [props.okText]
|
|
109
|
-
})])]))
|
|
110
|
-
}), {
|
|
111
|
-
default: () => [slots.default?.(), _createVNode(NDialog, {
|
|
112
|
-
"ref": removeDialog,
|
|
113
|
-
"variant": props.removeDialogVariant,
|
|
114
|
-
"title": props.removeDialogTitle,
|
|
115
|
-
"text": props.removeDialogText,
|
|
116
|
-
"okText": props.removeDialogOkText
|
|
117
|
-
}, null)]
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
export { Component as NCrudModal, Component as default };
|
package/components/NDialog.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { type PropType } from 'vue';
|
|
2
|
-
import type { HeroIcon } from '../utils/tailwind';
|
|
3
|
-
export type DialogVariant = 'success' | 'info' | 'warning' | 'danger' | 'remove';
|
|
4
|
-
export declare const nDialogProps: {
|
|
5
|
-
/**
|
|
6
|
-
* The title of the dialog.
|
|
7
|
-
*/
|
|
8
|
-
title: StringConstructor;
|
|
9
|
-
/**
|
|
10
|
-
* The text of the dialog.
|
|
11
|
-
*/
|
|
12
|
-
text: StringConstructor;
|
|
13
|
-
/**
|
|
14
|
-
* The variant of the dialog.
|
|
15
|
-
* This determines the default icon and its color
|
|
16
|
-
* as well as the default text and color of the ok-button.
|
|
17
|
-
*/
|
|
18
|
-
variant: {
|
|
19
|
-
type: PropType<DialogVariant>;
|
|
20
|
-
default: string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* The icon of the alert. This overrides the `icon` of the `variant`.
|
|
24
|
-
*/
|
|
25
|
-
icon: PropType<HeroIcon>;
|
|
26
|
-
/**
|
|
27
|
-
* The color of the alert's icon. This overrides the `iconColor` of the `variant`.
|
|
28
|
-
*/
|
|
29
|
-
iconColor: StringConstructor;
|
|
30
|
-
/**
|
|
31
|
-
* The text of the ok-button. This overrides the `okText` of the `variant`.
|
|
32
|
-
*/
|
|
33
|
-
okText: StringConstructor;
|
|
34
|
-
/**
|
|
35
|
-
* The color of the ok-button. This overrides the `okColor` of the `variant`.
|
|
36
|
-
*/
|
|
37
|
-
okColor: StringConstructor;
|
|
38
|
-
/**
|
|
39
|
-
* The text of the cancel-button.
|
|
40
|
-
*/
|
|
41
|
-
cancelText: {
|
|
42
|
-
type: StringConstructor;
|
|
43
|
-
default: string;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The color of the cancel-button.
|
|
47
|
-
*/
|
|
48
|
-
cancelColor: {
|
|
49
|
-
type: StringConstructor;
|
|
50
|
-
default: string;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* If set to `true` the cancel-button is hidden.
|
|
54
|
-
*/
|
|
55
|
-
hideCancel: BooleanConstructor;
|
|
56
|
-
};
|
|
57
|
-
export type NDialogExposed = {
|
|
58
|
-
/**
|
|
59
|
-
* Shows the alert and returns a promise.
|
|
60
|
-
* When the user interaction occurs the promise is resolved.
|
|
61
|
-
* It is resolved to `true` if the okButton was clicked, `false` if the dialog was cancelled.
|
|
62
|
-
*/
|
|
63
|
-
show(): Promise<boolean>;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* A `NDialog` is an element to interact directly with the user.
|
|
67
|
-
* It can be controlled via a ref to prompt the user and to receive their answer.
|
|
68
|
-
* @example
|
|
69
|
-
* const dialogRef = ref<NDialogExposed>()
|
|
70
|
-
* ...
|
|
71
|
-
* const onShowDialog = () => {
|
|
72
|
-
* dialofRef.value?.show().then(result => {
|
|
73
|
-
* if (result) // dialog accepted
|
|
74
|
-
* else // dialog cancelled
|
|
75
|
-
* })
|
|
76
|
-
* }
|
|
77
|
-
* ...
|
|
78
|
-
* <NDialog ref={dialogRef} />
|
|
79
|
-
*/
|
|
80
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
81
|
-
export { Component as NDialog, Component as default };
|
package/components/NDialog.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
2
|
-
import { deferred } from '../utils/deferred';
|
|
3
|
-
import { createComponent, extractProps } from '../utils/component';
|
|
4
|
-
import { CheckIcon, ExclamationTriangleIcon, LightBulbIcon, TrashIcon } from '@heroicons/vue/24/outline';
|
|
5
|
-
import { computed, ref } from 'vue';
|
|
6
|
-
import NIconCircle from './NIconCircle';
|
|
7
|
-
import NModal from './NModal';
|
|
8
|
-
import { DialogTitle } from '@headlessui/vue';
|
|
9
|
-
import { trsl } from '../i18n';
|
|
10
|
-
import { vModelForRef } from '../utils/vModel';
|
|
11
|
-
export const nDialogProps = {
|
|
12
|
-
/**
|
|
13
|
-
* The title of the dialog.
|
|
14
|
-
*/
|
|
15
|
-
title: String,
|
|
16
|
-
/**
|
|
17
|
-
* The text of the dialog.
|
|
18
|
-
*/
|
|
19
|
-
text: String,
|
|
20
|
-
/**
|
|
21
|
-
* The variant of the dialog.
|
|
22
|
-
* This determines the default icon and its color
|
|
23
|
-
* as well as the default text and color of the ok-button.
|
|
24
|
-
*/
|
|
25
|
-
variant: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: 'warning'
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* The icon of the alert. This overrides the `icon` of the `variant`.
|
|
31
|
-
*/
|
|
32
|
-
icon: Function,
|
|
33
|
-
/**
|
|
34
|
-
* The color of the alert's icon. This overrides the `iconColor` of the `variant`.
|
|
35
|
-
*/
|
|
36
|
-
iconColor: String,
|
|
37
|
-
/**
|
|
38
|
-
* The text of the ok-button. This overrides the `okText` of the `variant`.
|
|
39
|
-
*/
|
|
40
|
-
okText: String,
|
|
41
|
-
/**
|
|
42
|
-
* The color of the ok-button. This overrides the `okColor` of the `variant`.
|
|
43
|
-
*/
|
|
44
|
-
okColor: String,
|
|
45
|
-
/**
|
|
46
|
-
* The text of the cancel-button.
|
|
47
|
-
*/
|
|
48
|
-
cancelText: {
|
|
49
|
-
type: String,
|
|
50
|
-
default: trsl('vue-collection.action.cancel')
|
|
51
|
-
},
|
|
52
|
-
/**
|
|
53
|
-
* The color of the cancel-button.
|
|
54
|
-
*/
|
|
55
|
-
cancelColor: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: 'default'
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* If set to `true` the cancel-button is hidden.
|
|
61
|
-
*/
|
|
62
|
-
hideCancel: Boolean
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* A `NDialog` is an element to interact directly with the user.
|
|
66
|
-
* It can be controlled via a ref to prompt the user and to receive their answer.
|
|
67
|
-
* @example
|
|
68
|
-
* const dialogRef = ref<NDialogExposed>()
|
|
69
|
-
* ...
|
|
70
|
-
* const onShowDialog = () => {
|
|
71
|
-
* dialofRef.value?.show().then(result => {
|
|
72
|
-
* if (result) // dialog accepted
|
|
73
|
-
* else // dialog cancelled
|
|
74
|
-
* })
|
|
75
|
-
* }
|
|
76
|
-
* ...
|
|
77
|
-
* <NDialog ref={dialogRef} />
|
|
78
|
-
*/
|
|
79
|
-
const Component = createComponent('NDialog', nDialogProps, (props, context) => {
|
|
80
|
-
const showDialog = ref(false);
|
|
81
|
-
let deferredPromise = null;
|
|
82
|
-
const show = () => {
|
|
83
|
-
if (deferredPromise != null) {
|
|
84
|
-
deferredPromise.reject('show() was called on the open dialog.');
|
|
85
|
-
deferredPromise = null;
|
|
86
|
-
}
|
|
87
|
-
showDialog.value = true;
|
|
88
|
-
deferredPromise = deferred();
|
|
89
|
-
return deferredPromise.promise;
|
|
90
|
-
};
|
|
91
|
-
context.expose({
|
|
92
|
-
show
|
|
93
|
-
});
|
|
94
|
-
const resolveWith = result => {
|
|
95
|
-
deferredPromise?.resolve(result);
|
|
96
|
-
deferredPromise = null;
|
|
97
|
-
};
|
|
98
|
-
const ok = () => resolveWith(true);
|
|
99
|
-
const cancel = () => resolveWith(false);
|
|
100
|
-
const defaults = computed(() => VARIANT_DEFAULTS[props.variant]);
|
|
101
|
-
return () => _createVNode(NModal, _mergeProps(vModelForRef(showDialog), extractProps(props, 'cancelColor', 'cancelText', 'hideCancel'), {
|
|
102
|
-
"onOk": ok,
|
|
103
|
-
"onCancel": cancel,
|
|
104
|
-
"okColor": props.okColor || defaults.value.okColor,
|
|
105
|
-
"okText": props.okText || defaults.value.okText,
|
|
106
|
-
"hideX": true,
|
|
107
|
-
"hideHeader": true
|
|
108
|
-
}), {
|
|
109
|
-
default: () => [_createVNode("div", {
|
|
110
|
-
"class": "flex space-x-4 py-2"
|
|
111
|
-
}, [_createVNode("div", {
|
|
112
|
-
"class": "flex-grow-0"
|
|
113
|
-
}, [_createVNode(NIconCircle, {
|
|
114
|
-
"icon": props.icon || defaults.value.icon,
|
|
115
|
-
"iconSize": 6,
|
|
116
|
-
"color": props.iconColor || defaults.value.iconColor
|
|
117
|
-
}, null)]), _createVNode("div", {
|
|
118
|
-
"class": "flex-grow"
|
|
119
|
-
}, [_createVNode(DialogTitle, {
|
|
120
|
-
"as": "h4",
|
|
121
|
-
"class": "font-medium text-lg text-default-700 mb-1"
|
|
122
|
-
}, {
|
|
123
|
-
default: () => [props.title]
|
|
124
|
-
}), context.slots.default?.() || _createVNode("p", {
|
|
125
|
-
"class": "text-sm text-default-500"
|
|
126
|
-
}, [props.text])])])]
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
const VARIANT_DEFAULTS = {
|
|
130
|
-
success: {
|
|
131
|
-
icon: CheckIcon,
|
|
132
|
-
iconColor: 'green',
|
|
133
|
-
okText: trsl('vue-collection.action.all-right'),
|
|
134
|
-
okColor: 'green'
|
|
135
|
-
},
|
|
136
|
-
info: {
|
|
137
|
-
icon: LightBulbIcon,
|
|
138
|
-
iconColor: 'blue',
|
|
139
|
-
okText: trsl('vue-collection.action.all-right'),
|
|
140
|
-
okColor: 'blue'
|
|
141
|
-
},
|
|
142
|
-
warning: {
|
|
143
|
-
icon: ExclamationTriangleIcon,
|
|
144
|
-
iconColor: 'yellow',
|
|
145
|
-
okText: trsl('vue-collection.action.proceed'),
|
|
146
|
-
okColor: 'yellow'
|
|
147
|
-
},
|
|
148
|
-
danger: {
|
|
149
|
-
icon: ExclamationTriangleIcon,
|
|
150
|
-
iconColor: 'red',
|
|
151
|
-
okText: trsl('vue-collection.action.proceed'),
|
|
152
|
-
okColor: 'red'
|
|
153
|
-
},
|
|
154
|
-
remove: {
|
|
155
|
-
icon: TrashIcon,
|
|
156
|
-
iconColor: 'red',
|
|
157
|
-
okText: trsl('vue-collection.action.remove'),
|
|
158
|
-
okColor: 'red'
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
export { Component as NDialog, Component as default };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type PropType } from 'vue';
|
|
2
|
-
import { type RouteLocationRaw } from 'vue-router';
|
|
3
|
-
import { MenuButton } from '@headlessui/vue';
|
|
4
|
-
import type { HeroIcon } from '../utils/tailwind';
|
|
5
|
-
export declare const nDropdownProps: {
|
|
6
|
-
/**
|
|
7
|
-
* The title of the dropdown-button.
|
|
8
|
-
*/
|
|
9
|
-
readonly title: StringConstructor;
|
|
10
|
-
/**
|
|
11
|
-
* The items of the dropdown.
|
|
12
|
-
* The second dimension of the array is used
|
|
13
|
-
* to create groups of items, which are visually seperated.
|
|
14
|
-
*/
|
|
15
|
-
readonly items: {
|
|
16
|
-
readonly type: PropType<DropdownItem[] | DropdownItem[][]>;
|
|
17
|
-
readonly default: () => never[];
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* If set to `true` the panel is right-aligned to the button.
|
|
21
|
-
*/
|
|
22
|
-
readonly right: BooleanConstructor;
|
|
23
|
-
/**
|
|
24
|
-
* If set to `true` the dropdown-button is disabled and no interaction is possible.
|
|
25
|
-
*/
|
|
26
|
-
readonly disabled: BooleanConstructor;
|
|
27
|
-
/**
|
|
28
|
-
* Adds the classes to the Button of the dropdown.
|
|
29
|
-
*/
|
|
30
|
-
readonly buttonClass: StringConstructor;
|
|
31
|
-
/**
|
|
32
|
-
* A slot to replace the button of the dropdown.
|
|
33
|
-
* The passed parameter is the HeadlessUI `MenuButton` which should be
|
|
34
|
-
* used to create the button for the Dropdown to work properly.
|
|
35
|
-
*/
|
|
36
|
-
readonly button: PropType<(button: typeof MenuButton) => JSX.Element>;
|
|
37
|
-
};
|
|
38
|
-
export type DropdownItem = {
|
|
39
|
-
/**
|
|
40
|
-
* The label of the dropdown-item.
|
|
41
|
-
*/
|
|
42
|
-
label: string;
|
|
43
|
-
/**
|
|
44
|
-
* The icon of the dropdown-item. Is displayed to the left of the text.
|
|
45
|
-
*/
|
|
46
|
-
icon?: HeroIcon;
|
|
47
|
-
/**
|
|
48
|
-
* The route of the dropdown-item. If this is set, the dropdown-item is a {@link RouterLink}.
|
|
49
|
-
*/
|
|
50
|
-
route?: RouteLocationRaw;
|
|
51
|
-
/**
|
|
52
|
-
* If set to `true` the dropdown-item is disabled and no interaction is possible.
|
|
53
|
-
* The other dropdown-items can still be clicked.
|
|
54
|
-
*/
|
|
55
|
-
disabled?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* This is called when the dropdown-item is clicked.
|
|
58
|
-
* It is only called when the `route` option is not set on the item.
|
|
59
|
-
*/
|
|
60
|
-
onClick?: () => void;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* The `NDropdown` consists of a button and a panel with multiple actions.
|
|
64
|
-
* It is useful to group multiple actions together in one place.
|
|
65
|
-
*/
|
|
66
|
-
declare const Component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
67
|
-
export { Component as NDropdown, Component as default };
|