@myparcel-dev/pdk-admin-preset-default 1.13.0
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/CHANGELOG.md +420 -0
- package/dist/components/DefaultBadge.vue.d.ts +13 -0
- package/dist/components/DefaultBox.vue.d.ts +44 -0
- package/dist/components/DefaultButton.vue.d.ts +38 -0
- package/dist/components/DefaultButtonGroup.vue.d.ts +13 -0
- package/dist/components/DefaultCheckboxGroup.vue.d.ts +39 -0
- package/dist/components/DefaultCheckboxInput.vue.d.ts +39 -0
- package/dist/components/DefaultCodeEditor.vue.d.ts +16 -0
- package/dist/components/DefaultCol.vue.d.ts +13 -0
- package/dist/components/DefaultCurrencyInput.vue.d.ts +16 -0
- package/dist/components/DefaultDropOffInput.vue.d.ts +16 -0
- package/dist/components/DefaultDropdownButton.vue.d.ts +17 -0
- package/dist/components/DefaultFormGroup.vue.d.ts +21 -0
- package/dist/components/DefaultHeading.vue.d.ts +31 -0
- package/dist/components/DefaultIcon.vue.d.ts +12 -0
- package/dist/components/DefaultImage.vue.d.ts +12 -0
- package/dist/components/DefaultLink.vue.d.ts +35 -0
- package/dist/components/DefaultLoader.vue.d.ts +26 -0
- package/dist/components/DefaultModal.vue.d.ts +34 -0
- package/dist/components/DefaultMultiDateInput.vue.d.ts +17 -0
- package/dist/components/DefaultMultiSelectInput.vue.d.ts +39 -0
- package/dist/components/DefaultNotification.vue.d.ts +12 -0
- package/dist/components/DefaultNumberInput.vue.d.ts +16 -0
- package/dist/components/DefaultRadioGroup.vue.d.ts +39 -0
- package/dist/components/DefaultRadioInput.vue.d.ts +16 -0
- package/dist/components/DefaultRow.vue.d.ts +13 -0
- package/dist/components/DefaultSelectInput.vue.d.ts +39 -0
- package/dist/components/DefaultSettingsDivider.vue.d.ts +12 -0
- package/dist/components/DefaultShippingMethodsInput.vue.d.ts +16 -0
- package/dist/components/DefaultTabNavButton.vue.d.ts +23 -0
- package/dist/components/DefaultTable.vue.d.ts +23 -0
- package/dist/components/DefaultTableCol.vue.d.ts +31 -0
- package/dist/components/DefaultTableRow.vue.d.ts +31 -0
- package/dist/components/DefaultTextArea.vue.d.ts +16 -0
- package/dist/components/DefaultTextInput.vue.d.ts +16 -0
- package/dist/components/DefaultTimeInput.vue.d.ts +16 -0
- package/dist/components/DefaultToggleInput.vue.d.ts +16 -0
- package/dist/components/DefaultTriStateInput.vue.d.ts +16 -0
- package/dist/components/index.d.ts +37 -0
- package/dist/index.d.ts +1 -0
- package/package.json +54 -0
- package/src/__tests__/__snapshots__/exports.spec.ts.snap +43 -0
- package/src/__tests__/exports.spec.ts +8 -0
- package/src/__tests__/testComponents.spec.ts +82 -0
- package/src/assets/icons/magnifying-glass-solid-full.svg +1 -0
- package/src/components/DefaultBadge.vue +10 -0
- package/src/components/DefaultBox.vue +40 -0
- package/src/components/DefaultButton.vue +36 -0
- package/src/components/DefaultButtonGroup.vue +12 -0
- package/src/components/DefaultCheckboxGroup.vue +29 -0
- package/src/components/DefaultCheckboxInput.vue +29 -0
- package/src/components/DefaultCodeEditor.vue +17 -0
- package/src/components/DefaultCol.vue +12 -0
- package/src/components/DefaultCurrencyInput.vue +18 -0
- package/src/components/DefaultDropOffInput.vue +38 -0
- package/src/components/DefaultDropdownButton.vue +58 -0
- package/src/components/DefaultFormGroup.vue +54 -0
- package/src/components/DefaultHeading.vue +16 -0
- package/src/components/DefaultIcon.vue +11 -0
- package/src/components/DefaultImage.vue +12 -0
- package/src/components/DefaultLink.vue +65 -0
- package/src/components/DefaultLoader.vue +17 -0
- package/src/components/DefaultModal.vue +70 -0
- package/src/components/DefaultMultiDateInput.vue +34 -0
- package/src/components/DefaultMultiSelectInput.vue +23 -0
- package/src/components/DefaultNotification.vue +28 -0
- package/src/components/DefaultNumberInput.vue +18 -0
- package/src/components/DefaultRadioGroup.vue +28 -0
- package/src/components/DefaultRadioInput.vue +44 -0
- package/src/components/DefaultRow.vue +12 -0
- package/src/components/DefaultSelectInput.vue +31 -0
- package/src/components/DefaultSettingsDivider.vue +22 -0
- package/src/components/DefaultShippingMethodsInput.vue +267 -0
- package/src/components/DefaultTabNavButton.vue +16 -0
- package/src/components/DefaultTable.vue +33 -0
- package/src/components/DefaultTableCol.vue +14 -0
- package/src/components/DefaultTableRow.vue +14 -0
- package/src/components/DefaultTextArea.vue +19 -0
- package/src/components/DefaultTextInput.vue +19 -0
- package/src/components/DefaultTimeInput.vue +18 -0
- package/src/components/DefaultToggleInput.vue +41 -0
- package/src/components/DefaultTriStateInput.vue +30 -0
- package/src/components/index.ts +73 -0
- package/src/index.ts +1 -0
- package/src/vue.shims.d.ts +7 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<img
|
|
3
|
+
v-test="AdminComponent.Image"
|
|
4
|
+
v-bind="$props" />
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
/* eslint-disable vue/no-unused-properties */
|
|
9
|
+
import {AdminComponent, type ImageProps} from '@myparcel-dev/pdk-admin';
|
|
10
|
+
|
|
11
|
+
defineProps<ImageProps>();
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a
|
|
3
|
+
v-test="`${AdminComponent.Link}${action ? `-${action.id}` : ''}`"
|
|
4
|
+
v-bind="linkAttributes">
|
|
5
|
+
<PdkIcon
|
|
6
|
+
v-if="action?.icon"
|
|
7
|
+
:icon="action?.icon" />
|
|
8
|
+
<slot v-if="!hideText">
|
|
9
|
+
{{ translate(action?.label) }}
|
|
10
|
+
</slot>
|
|
11
|
+
</a>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import {type AnchorHTMLAttributes, computed} from 'vue';
|
|
16
|
+
import {
|
|
17
|
+
AdminComponent,
|
|
18
|
+
getActionIdentifier,
|
|
19
|
+
type LinkEmits,
|
|
20
|
+
type LinkProps,
|
|
21
|
+
type LinkSlots,
|
|
22
|
+
useActionStore,
|
|
23
|
+
useLanguage,
|
|
24
|
+
} from '@myparcel-dev/pdk-admin';
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<LinkProps>(), {
|
|
27
|
+
href: '#',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits<LinkEmits>();
|
|
31
|
+
|
|
32
|
+
defineSlots<LinkSlots>();
|
|
33
|
+
|
|
34
|
+
const actionStore = useActionStore();
|
|
35
|
+
|
|
36
|
+
const actionIdentifier = computed<string>(() => getActionIdentifier(props.action));
|
|
37
|
+
|
|
38
|
+
const onClick = (event: MouseEvent): void => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
emit('click', event);
|
|
41
|
+
|
|
42
|
+
if (!actionIdentifier.value) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void actionStore.dispatch(actionIdentifier.value, props.action?.parameters);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const linkAttributes = computed(() => {
|
|
50
|
+
const attributes: AnchorHTMLAttributes = {
|
|
51
|
+
href: props.href,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (attributes.href?.startsWith('http')) {
|
|
55
|
+
attributes.rel = 'noopener noreferrer';
|
|
56
|
+
attributes.target = '_blank';
|
|
57
|
+
} else {
|
|
58
|
+
attributes.onClick = onClick;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return attributes;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const {translate} = useLanguage();
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="tag"
|
|
4
|
+
v-test="AdminComponent.Loader">
|
|
5
|
+
{{ translate('loading') }}
|
|
6
|
+
</component>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import {AdminComponent, type LoaderProps, useLanguage} from '@myparcel-dev/pdk-admin';
|
|
11
|
+
|
|
12
|
+
withDefaults(defineProps<LoaderProps>(), {
|
|
13
|
+
tag: 'div',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const {translate} = useLanguage();
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-test="AdminComponent.Modal"
|
|
4
|
+
:aria-hidden="!isOpen"
|
|
5
|
+
tabindex="-1"
|
|
6
|
+
@keydown.esc="close">
|
|
7
|
+
<div
|
|
8
|
+
v-show="isOpen"
|
|
9
|
+
@click="close" />
|
|
10
|
+
|
|
11
|
+
<Transition name="slide-up">
|
|
12
|
+
<div v-show="isOpen">
|
|
13
|
+
<NotificationContainer category="modal" />
|
|
14
|
+
|
|
15
|
+
<div>
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
@click="close">
|
|
19
|
+
<svg
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
viewBox="0 0 20 20"
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
24
|
+
<path
|
|
25
|
+
clip-rule="evenodd"
|
|
26
|
+
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
|
27
|
+
fill-rule="evenodd" />
|
|
28
|
+
</svg>
|
|
29
|
+
<span>Close modal</span>
|
|
30
|
+
</button>
|
|
31
|
+
|
|
32
|
+
<div>
|
|
33
|
+
<PdkHeading level="2">{{ translate(title) }}</PdkHeading>
|
|
34
|
+
|
|
35
|
+
<slot :context="context" />
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<ActionButton
|
|
39
|
+
v-for="(action, index) in actions"
|
|
40
|
+
:key="`action_${action.id}_${index}`"
|
|
41
|
+
:action="action" />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</Transition>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script lang="ts" setup>
|
|
49
|
+
import {toRefs} from 'vue';
|
|
50
|
+
import {
|
|
51
|
+
ActionButton,
|
|
52
|
+
AdminComponent,
|
|
53
|
+
type ModalProps,
|
|
54
|
+
type ModalSlots,
|
|
55
|
+
NotificationContainer,
|
|
56
|
+
useLanguage,
|
|
57
|
+
useModalElementContext,
|
|
58
|
+
} from '@myparcel-dev/pdk-admin';
|
|
59
|
+
|
|
60
|
+
const props = withDefaults(defineProps<ModalProps>(), {
|
|
61
|
+
actions: () => [],
|
|
62
|
+
title: '',
|
|
63
|
+
});
|
|
64
|
+
defineSlots<ModalSlots>();
|
|
65
|
+
|
|
66
|
+
const propRefs = toRefs(props);
|
|
67
|
+
|
|
68
|
+
const {isOpen, context, close} = useModalElementContext(propRefs.modalKey);
|
|
69
|
+
const {translate} = useLanguage();
|
|
70
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-test="AdminComponent.MultiDateInput">
|
|
3
|
+
<Datepicker
|
|
4
|
+
v-model="model"
|
|
5
|
+
class="datepicker"
|
|
6
|
+
multi-dates
|
|
7
|
+
:enable-time-picker="false"
|
|
8
|
+
:disabled-dates="disablePastAndToday"></Datepicker>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import {useVModel} from '@vueuse/core';
|
|
14
|
+
import Datepicker from '@vuepic/vue-datepicker';
|
|
15
|
+
import '@vuepic/vue-datepicker/dist/main.css';
|
|
16
|
+
import {AdminComponent, type MultiDateInputEmits, type MultiDateInputProps} from '@myparcel-dev/pdk-admin';
|
|
17
|
+
|
|
18
|
+
const props = defineProps<MultiDateInputProps>();
|
|
19
|
+
const emit = defineEmits<MultiDateInputEmits>();
|
|
20
|
+
|
|
21
|
+
const model = useVModel(props, 'modelValue', emit);
|
|
22
|
+
|
|
23
|
+
const disablePastAndToday = (date: Date) => {
|
|
24
|
+
const today = new Date();
|
|
25
|
+
today.setHours(0, 0, 0, 0);
|
|
26
|
+
return date <= today;
|
|
27
|
+
};
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.datepicker {
|
|
32
|
+
max-width: 400px;
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PdkSelectInput
|
|
3
|
+
v-model="model"
|
|
4
|
+
v-test="AdminComponent.MultiSelectInput"
|
|
5
|
+
:element="element"
|
|
6
|
+
multiple />
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script generic="T extends MultiSelectInputModelValue" lang="ts" setup>
|
|
10
|
+
import {
|
|
11
|
+
AdminComponent,
|
|
12
|
+
type MultiSelectInputEmits,
|
|
13
|
+
type MultiSelectInputModelValue,
|
|
14
|
+
type MultiSelectInputProps,
|
|
15
|
+
useMultiSelectInputContext,
|
|
16
|
+
} from '@myparcel-dev/pdk-admin';
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
19
|
+
const props = defineProps<MultiSelectInputProps<T>>();
|
|
20
|
+
const emit = defineEmits<MultiSelectInputEmits<T>>();
|
|
21
|
+
|
|
22
|
+
const {model} = useMultiSelectInputContext(props, emit);
|
|
23
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-test="AdminComponent.Notification">
|
|
3
|
+
<b
|
|
4
|
+
v-if="notification.title"
|
|
5
|
+
v-text="notification.title" />
|
|
6
|
+
|
|
7
|
+
<ul v-if="contentArray.length > 1">
|
|
8
|
+
<li
|
|
9
|
+
v-for="item in contentArray"
|
|
10
|
+
:key="item"
|
|
11
|
+
v-text="item" />
|
|
12
|
+
</ul>
|
|
13
|
+
|
|
14
|
+
<p
|
|
15
|
+
v-else
|
|
16
|
+
v-text="contentArray[0]" />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import {computed} from 'vue';
|
|
22
|
+
import {AdminComponent, type NotificationProps} from '@myparcel-dev/pdk-admin';
|
|
23
|
+
import {toArray} from '@myparcel-dev/ts-utils';
|
|
24
|
+
|
|
25
|
+
const props = defineProps<NotificationProps>();
|
|
26
|
+
|
|
27
|
+
const contentArray = computed(() => toArray(props.notification.content));
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PdkTextInput
|
|
3
|
+
v-model.number="model"
|
|
4
|
+
v-test="AdminComponent.NumberInput"
|
|
5
|
+
:element="element"
|
|
6
|
+
type="number" />
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script generic="" lang="ts" setup>
|
|
10
|
+
import {useVModel} from '@vueuse/core';
|
|
11
|
+
import {AdminComponent, type NumberInputEmits, type NumberInputProps} from '@myparcel-dev/pdk-admin';
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
14
|
+
const props = defineProps<NumberInputProps>();
|
|
15
|
+
const emit = defineEmits<NumberInputEmits>();
|
|
16
|
+
|
|
17
|
+
const model = useVModel(props, undefined, emit);
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-test="AdminComponent.RadioGroup">
|
|
3
|
+
<PdkRadioInput
|
|
4
|
+
v-for="option in options"
|
|
5
|
+
:key="option.value"
|
|
6
|
+
v-model="model"
|
|
7
|
+
:disabled="element.isDisabled || element.isSuspended || options.length <= 1"
|
|
8
|
+
:readonly="element.isReadOnly"
|
|
9
|
+
:element="elements[option.value]"
|
|
10
|
+
:name="id" />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script generic="T extends RadioGroupModelValue" lang="ts" setup>
|
|
15
|
+
import {
|
|
16
|
+
AdminComponent,
|
|
17
|
+
type RadioGroupEmits,
|
|
18
|
+
type RadioGroupModelValue,
|
|
19
|
+
type RadioGroupProps,
|
|
20
|
+
useRadioGroupContext,
|
|
21
|
+
} from '@myparcel-dev/pdk-admin';
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
24
|
+
const props = defineProps<RadioGroupProps<T>>();
|
|
25
|
+
const emit = defineEmits<RadioGroupEmits<T>>();
|
|
26
|
+
|
|
27
|
+
const {options, id, model, elements} = useRadioGroupContext(props, emit);
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-test="AdminComponent.RadioInput">
|
|
3
|
+
<input
|
|
4
|
+
:id="id"
|
|
5
|
+
v-model="model"
|
|
6
|
+
:class="{
|
|
7
|
+
'form-required': !element.isValid,
|
|
8
|
+
}"
|
|
9
|
+
:disabled="element.isDisabled || element.isSuspended"
|
|
10
|
+
:name="id"
|
|
11
|
+
:readonly="element.isReadOnly"
|
|
12
|
+
:value="element.props?.value"
|
|
13
|
+
type="radio"
|
|
14
|
+
v-bind="$attrs" />
|
|
15
|
+
|
|
16
|
+
<label :for="id">
|
|
17
|
+
<PdkIcon
|
|
18
|
+
v-if="element.props?.icon"
|
|
19
|
+
:icon="element.props.icon" />
|
|
20
|
+
|
|
21
|
+
<PdkImage
|
|
22
|
+
v-if="element.props?.image"
|
|
23
|
+
:alt="element.label ?? ''"
|
|
24
|
+
:src="element.props.image"
|
|
25
|
+
width="24" />
|
|
26
|
+
|
|
27
|
+
{{ element.label }}
|
|
28
|
+
</label>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
export default {inheritAttrs: false};
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<script lang="ts" setup>
|
|
37
|
+
import {AdminComponent, type RadioInputEmits, type RadioInputProps, useElementContext} from '@myparcel-dev/pdk-admin';
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
40
|
+
const props = defineProps<RadioInputProps>();
|
|
41
|
+
const emit = defineEmits<RadioInputEmits>();
|
|
42
|
+
|
|
43
|
+
const {id, model} = useElementContext(props, emit);
|
|
44
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-test="AdminComponent.Row">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import {AdminComponent, type RowProps, type RowSlots} from '@myparcel-dev/pdk-admin';
|
|
9
|
+
|
|
10
|
+
defineProps<RowProps>();
|
|
11
|
+
defineSlots<RowSlots>();
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<select
|
|
3
|
+
:id="id"
|
|
4
|
+
v-model="model"
|
|
5
|
+
v-test="AdminComponent.SelectInput"
|
|
6
|
+
:disabled="options.length === 1 || element.isDisabled || element.isSuspended"
|
|
7
|
+
:name="id">
|
|
8
|
+
<option
|
|
9
|
+
v-for="(item, index) in options"
|
|
10
|
+
:key="index"
|
|
11
|
+
:disabled="item.disabled"
|
|
12
|
+
:value="item.value"
|
|
13
|
+
v-text="item.label" />
|
|
14
|
+
</select>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script generic="T extends SelectInputModelValue" lang="ts" setup>
|
|
18
|
+
import {
|
|
19
|
+
AdminComponent,
|
|
20
|
+
type SelectInputEmits,
|
|
21
|
+
type SelectInputModelValue,
|
|
22
|
+
type SelectInputProps,
|
|
23
|
+
useSelectInputContext,
|
|
24
|
+
} from '@myparcel-dev/pdk-admin';
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
27
|
+
const props = defineProps<SelectInputProps<T>>();
|
|
28
|
+
const emit = defineEmits<SelectInputEmits<T>>();
|
|
29
|
+
|
|
30
|
+
const {options, id, model} = useSelectInputContext(props, emit);
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-test="AdminComponent.SettingsDivider">
|
|
3
|
+
<PdkHeading
|
|
4
|
+
v-if="element.props.heading"
|
|
5
|
+
:level="element.props.level">
|
|
6
|
+
{{ translate(element.props.heading) }}
|
|
7
|
+
</PdkHeading>
|
|
8
|
+
|
|
9
|
+
<p
|
|
10
|
+
v-if="element.props.content && has(element.props.content)"
|
|
11
|
+
v-text="translate(element.props.content)" />
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import {AdminComponent, type SettingsDividerProps, useLanguage} from '@myparcel-dev/pdk-admin';
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
19
|
+
defineProps<SettingsDividerProps>();
|
|
20
|
+
|
|
21
|
+
const {translate, has} = useLanguage();
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-test="AdminComponent.ShippingMethodsInput"
|
|
4
|
+
class="shipping-methods">
|
|
5
|
+
<div class="shipping-method-types">
|
|
6
|
+
<PdkTabNavButton
|
|
7
|
+
v-for="shippingMethodType in shippingMethodTypes"
|
|
8
|
+
:key="shippingMethodType.value"
|
|
9
|
+
class="tab-nav-button"
|
|
10
|
+
:active="shippingMethodType.value === selectedShippingMethodType.value"
|
|
11
|
+
type="button"
|
|
12
|
+
@click="selectShippingMethodType(shippingMethodType)">
|
|
13
|
+
<PackageType
|
|
14
|
+
v-if="isEnumValue(shippingMethodType.value, PackageTypeName)"
|
|
15
|
+
:package-type="shippingMethodType.value" />
|
|
16
|
+
|
|
17
|
+
<span
|
|
18
|
+
v-else
|
|
19
|
+
v-text="translate(shippingMethodType.label)" />
|
|
20
|
+
</PdkTabNavButton>
|
|
21
|
+
</div>
|
|
22
|
+
<PdkBox class="shipping-method-details">
|
|
23
|
+
<div class="shipping-method-details-header">
|
|
24
|
+
<h1>
|
|
25
|
+
<PackageType
|
|
26
|
+
v-if="isEnumValue(selectedShippingMethodType.value, PackageTypeName)"
|
|
27
|
+
:package-type="selectedShippingMethodType.value"></PackageType>
|
|
28
|
+
<span
|
|
29
|
+
v-else
|
|
30
|
+
v-text="translate(selectedShippingMethodType.label)"></span>
|
|
31
|
+
</h1>
|
|
32
|
+
<label class="filter-checkbox">
|
|
33
|
+
<PdkCheckboxInput
|
|
34
|
+
v-model="showAssigned"
|
|
35
|
+
:element="element"
|
|
36
|
+
type="checkbox"
|
|
37
|
+
class="filter-checkbox-input" />
|
|
38
|
+
<span class="filter-checkbox-label">{{ translate('show_assigned') }}</span>
|
|
39
|
+
</label>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="search-box">
|
|
43
|
+
<span class="icon"></span>
|
|
44
|
+
<PdkTextInput
|
|
45
|
+
v-model="searchQuery"
|
|
46
|
+
class="search-input"
|
|
47
|
+
:element="element"
|
|
48
|
+
type="text"
|
|
49
|
+
:placeholder="translate('search_shipping_method')" />
|
|
50
|
+
</div>
|
|
51
|
+
<label
|
|
52
|
+
v-for="shippingMethod in filteredShippingMethods"
|
|
53
|
+
:key="shippingMethod.value"
|
|
54
|
+
:class="['shipping-method']">
|
|
55
|
+
<PdkToggleInput
|
|
56
|
+
v-model="elements[shippingMethod.value][selectedShippingMethodType.value].ref"
|
|
57
|
+
:element="elements[shippingMethod.value][selectedShippingMethodType.value]" />
|
|
58
|
+
<span class="shipping-method-value">
|
|
59
|
+
<p>
|
|
60
|
+
<b>{{ shippingMethod.label }}</b>
|
|
61
|
+
</p>
|
|
62
|
+
<p>{{ shippingMethod.description }}</p>
|
|
63
|
+
<p
|
|
64
|
+
v-if="refs[shippingMethod.value] && refs[shippingMethod.value] !== selectedShippingMethodType.value"
|
|
65
|
+
class="already-selected-note">
|
|
66
|
+
{{ translate('already_selected_under') }}
|
|
67
|
+
{{ getShippingMethodTypeLabel(refs[shippingMethod.value]) }}
|
|
68
|
+
</p>
|
|
69
|
+
</span>
|
|
70
|
+
</label>
|
|
71
|
+
</PdkBox>
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|
|
74
|
+
|
|
75
|
+
<script lang="ts" setup>
|
|
76
|
+
import {ref, computed} from 'vue';
|
|
77
|
+
import {TriState} from '@myparcel-dev/pdk-common';
|
|
78
|
+
import {
|
|
79
|
+
AdminComponent,
|
|
80
|
+
PackageType,
|
|
81
|
+
type SelectOptionWithLabel,
|
|
82
|
+
type ShippingMethodsInputEmits,
|
|
83
|
+
type ShippingMethodsInputProps,
|
|
84
|
+
type ShippingMethodType,
|
|
85
|
+
useLanguage,
|
|
86
|
+
useShippingMethodsInputContext,
|
|
87
|
+
} from '@myparcel-dev/pdk-admin';
|
|
88
|
+
import {isEnumValue} from '@myparcel-dev/ts-utils';
|
|
89
|
+
import {PackageTypeName} from '@myparcel-dev/constants';
|
|
90
|
+
|
|
91
|
+
// eslint-disable-next-line vue/no-unused-properties
|
|
92
|
+
const props = defineProps<ShippingMethodsInputProps>();
|
|
93
|
+
const emit = defineEmits<ShippingMethodsInputEmits>();
|
|
94
|
+
|
|
95
|
+
const {translate} = useLanguage();
|
|
96
|
+
|
|
97
|
+
const {shippingMethods, elements, shippingMethodTypes, refs} = useShippingMethodsInputContext(props, emit);
|
|
98
|
+
|
|
99
|
+
const selectedShippingMethodType = ref<SelectOptionWithLabel<ShippingMethodType>>(shippingMethodTypes[0]);
|
|
100
|
+
const searchQuery = ref('');
|
|
101
|
+
const showAssigned = ref(true);
|
|
102
|
+
|
|
103
|
+
// Filter shipping methods based on search query and unassigned filter
|
|
104
|
+
const filteredShippingMethods = computed(() => {
|
|
105
|
+
let filtered = shippingMethods.value;
|
|
106
|
+
|
|
107
|
+
// Filter by search query
|
|
108
|
+
if (searchQuery.value.trim()) {
|
|
109
|
+
const query = searchQuery.value.toLowerCase().trim();
|
|
110
|
+
filtered = filtered.filter((shippingMethod) => {
|
|
111
|
+
const label = String(shippingMethod.label).toLowerCase();
|
|
112
|
+
const description = shippingMethod.description ? String(shippingMethod.description).toLowerCase() : '';
|
|
113
|
+
const value = shippingMethod.value.toString().toLowerCase();
|
|
114
|
+
|
|
115
|
+
return label.includes(query) || description.includes(query) || value.includes(query);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Filter by assigned status (hide unassigned methods when showAssigned is false)
|
|
120
|
+
if (!showAssigned.value) {
|
|
121
|
+
filtered = filtered.filter((shippingMethod) => {
|
|
122
|
+
const shippingMethodId = shippingMethod.value.toString();
|
|
123
|
+
// Show unassigned methods OR methods assigned to the current selected shipping method type
|
|
124
|
+
return (
|
|
125
|
+
refs[shippingMethodId] === TriState.Off || refs[shippingMethodId] === selectedShippingMethodType.value.value
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return filtered;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
function selectShippingMethodType(selected: SelectOptionWithLabel<ShippingMethodType>): void {
|
|
134
|
+
selectedShippingMethodType.value = selected;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function getShippingMethodTypeLabel(type: ShippingMethodType): string {
|
|
138
|
+
const typeOption = shippingMethodTypes.find((t) => t.value === type);
|
|
139
|
+
return typeOption
|
|
140
|
+
? isEnumValue(typeOption.value, PackageTypeName)
|
|
141
|
+
? translate(`package_type_${typeOption.label}`)
|
|
142
|
+
: translate(typeOption.label)
|
|
143
|
+
: String(type);
|
|
144
|
+
}
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<style>
|
|
148
|
+
.shipping-methods {
|
|
149
|
+
display: flex;
|
|
150
|
+
gap: 16px;
|
|
151
|
+
|
|
152
|
+
.shipping-method-types {
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
gap: 8px;
|
|
156
|
+
flex-shrink: 0;
|
|
157
|
+
|
|
158
|
+
.tab-nav-button {
|
|
159
|
+
border-bottom: 1px solid #c3c4c7;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.shipping-method-details {
|
|
164
|
+
margin-left: 0;
|
|
165
|
+
width: 100%;
|
|
166
|
+
overflow-y: auto;
|
|
167
|
+
height: 360px;
|
|
168
|
+
max-width: 800px;
|
|
169
|
+
|
|
170
|
+
.shipping-method-details-header {
|
|
171
|
+
display: flex;
|
|
172
|
+
justify-content: space-between;
|
|
173
|
+
align-items: center;
|
|
174
|
+
|
|
175
|
+
h1 {
|
|
176
|
+
padding: 0;
|
|
177
|
+
margin: 0 0 16px 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.filter-checkbox {
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
gap: 8px;
|
|
184
|
+
cursor: pointer;
|
|
185
|
+
font-size: 14px;
|
|
186
|
+
color: #666;
|
|
187
|
+
margin-bottom: 16px;
|
|
188
|
+
|
|
189
|
+
label {
|
|
190
|
+
display: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.filter-checkbox-input {
|
|
194
|
+
margin: 0;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.filter-checkbox-label {
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
user-select: none;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&:hover {
|
|
204
|
+
color: #333;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.search-box {
|
|
210
|
+
display: flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
margin-bottom: 16px;
|
|
213
|
+
position: relative;
|
|
214
|
+
|
|
215
|
+
.icon {
|
|
216
|
+
width: 16px;
|
|
217
|
+
height: 16px;
|
|
218
|
+
background: url('../assets/icons/magnifying-glass-solid-full.svg') no-repeat center;
|
|
219
|
+
background-size: contain;
|
|
220
|
+
position: absolute;
|
|
221
|
+
left: 8px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.search-input {
|
|
225
|
+
padding-left: 32px !important;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.shipping-method {
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
gap: 12px;
|
|
233
|
+
padding: 12px 0;
|
|
234
|
+
border-top: 1px solid #f0f0f0;
|
|
235
|
+
|
|
236
|
+
&:hover {
|
|
237
|
+
cursor: pointer;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
input[type='checkbox'] {
|
|
241
|
+
margin-top: 2px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.shipping-method-value {
|
|
245
|
+
flex: 1;
|
|
246
|
+
|
|
247
|
+
p {
|
|
248
|
+
margin: 0 0 4px 0;
|
|
249
|
+
|
|
250
|
+
&:last-child {
|
|
251
|
+
margin-bottom: 0;
|
|
252
|
+
color: #666;
|
|
253
|
+
font-size: 14px;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.already-selected-note {
|
|
258
|
+
color: #999;
|
|
259
|
+
font-size: 12px;
|
|
260
|
+
font-style: italic;
|
|
261
|
+
margin-top: 2px;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
</style>
|