adminforth 4.7.1 → 4.7.2
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/dist/auth.d.ts +2 -3
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -10
- package/dist/auth.js.map +1 -1
- package/dist/dataConnectors/baseConnector.d.ts +0 -4
- package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
- package/dist/dataConnectors/baseConnector.js +0 -7
- package/dist/dataConnectors/baseConnector.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -35
- package/dist/index.js.map +1 -1
- package/dist/modules/codeInjector.d.ts +0 -1
- package/dist/modules/codeInjector.d.ts.map +1 -1
- package/dist/modules/codeInjector.js +3 -10
- package/dist/modules/codeInjector.js.map +1 -1
- package/dist/modules/configValidator.d.ts +2 -2
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +63 -103
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +11 -9
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/utils.d.ts +2 -3
- package/dist/modules/utils.d.ts.map +1 -1
- package/dist/modules/utils.js +2 -6
- package/dist/modules/utils.js.map +1 -1
- package/dist/spa/src/adminforth.ts +0 -18
- package/dist/spa/src/afcl/Button.vue +2 -5
- package/dist/spa/src/afcl/CodeInput.vue +2 -1
- package/dist/spa/src/afcl/DatePicker.vue +8 -0
- package/dist/spa/src/afcl/Dialog.vue +2 -19
- package/dist/spa/src/afcl/DropdownMenu.vue +8 -3
- package/dist/spa/src/afcl/Dropzone.vue +3 -2
- package/dist/spa/src/afcl/Modal.vue +4 -2
- package/dist/spa/src/afcl/Select.vue +7 -3
- package/dist/spa/src/afcl/Tooltip.vue +3 -1
- package/dist/spa/src/afcl/shadowRoot.ts +17 -0
- package/dist/spa/src/router/index.ts +0 -1
- package/dist/spa/src/stores/core.ts +5 -12
- package/dist/spa/src/types/Back.ts +58 -248
- package/dist/spa/src/types/Common.ts +2 -9
- package/dist/spa/src/types/FrontendAPI.ts +1 -21
- package/dist/spa/src/types/adapters/StorageAdapter.ts +0 -2
- package/dist/spa/src/views/CreateView.vue +2 -18
- package/dist/spa/src/views/ShowView.vue +3 -7
- package/dist/spa/src/websocket.ts +0 -11
- package/dist/types/Back.d.ts +26 -197
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +2 -8
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/dist/types/FrontendAPI.d.ts +1 -20
- package/dist/types/FrontendAPI.d.ts.map +1 -1
- package/dist/types/FrontendAPI.js.map +1 -1
- package/dist/types/adapters/StorageAdapter.d.ts +0 -2
- package/dist/types/adapters/StorageAdapter.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -34,21 +34,18 @@ const props = withDefaults(defineProps<{
|
|
|
34
34
|
variant?: ButtonVariant;
|
|
35
35
|
size?: ButtonSize;
|
|
36
36
|
iconOnly?: boolean;
|
|
37
|
-
/** @deprecated use variant instead of mode */
|
|
38
|
-
mode?: ButtonVariant;
|
|
39
37
|
shadow?: boolean;
|
|
40
38
|
}>(), {
|
|
39
|
+
variant: 'primary',
|
|
41
40
|
loader: false,
|
|
42
41
|
disabled: false,
|
|
43
42
|
active: false,
|
|
44
43
|
shadow: true,
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
const currentVariant = computed(() => props.variant ?? props.mode ?? 'primary');
|
|
48
|
-
|
|
49
46
|
const buttonClasses = computed(() => getButtonClasses(
|
|
50
47
|
{
|
|
51
|
-
variant:
|
|
48
|
+
variant: props.variant,
|
|
52
49
|
size: props.size,
|
|
53
50
|
iconOnly: props.iconOnly,
|
|
54
51
|
shadow: props.shadow,
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue';
|
|
45
45
|
import { type ClassNameValue } from 'tailwind-merge';
|
|
46
46
|
import { mergeClasses } from './classMerge';
|
|
47
|
+
import { activeElementIn } from './shadowRoot';
|
|
47
48
|
|
|
48
49
|
defineOptions({ inheritAttrs: false });
|
|
49
50
|
|
|
@@ -169,7 +170,7 @@ function onBlur(e: FocusEvent) {
|
|
|
169
170
|
}
|
|
170
171
|
// the clicked button still gets its click, the focus is back before the user types again
|
|
171
172
|
requestAnimationFrame(() => {
|
|
172
|
-
if (inputRef.value?.isConnected && !
|
|
173
|
+
if (inputRef.value?.isConnected && !activeElementIn(inputRef.value)?.matches(EDITABLE_SELECTOR)) {
|
|
173
174
|
focus();
|
|
174
175
|
}
|
|
175
176
|
});
|
|
@@ -47,6 +47,7 @@ import utc from 'dayjs/plugin/utc';
|
|
|
47
47
|
|
|
48
48
|
import {useCoreStore} from '@/stores/core';
|
|
49
49
|
import {FLEXIBLE_DATEPICKER_FORMAT} from '@/utils/dateUtils';
|
|
50
|
+
import { useTeleportTarget } from './shadowRoot';
|
|
50
51
|
|
|
51
52
|
import { IconCalendar, IconChevronDown, IconClock } from '@iconify-prerendered/vue-lucide';
|
|
52
53
|
|
|
@@ -134,6 +135,8 @@ watch(start, () => {
|
|
|
134
135
|
emit('update:valueStart', start.value)
|
|
135
136
|
})
|
|
136
137
|
|
|
138
|
+
const teleportTarget = useTeleportTarget();
|
|
139
|
+
|
|
137
140
|
async function initDatepickers() {
|
|
138
141
|
const LS_LANG_KEY = `afLanguage`;
|
|
139
142
|
const options = {format: FLEXIBLE_DATEPICKER_FORMAT, language: localStorage.getItem(LS_LANG_KEY)};
|
|
@@ -147,6 +150,11 @@ async function initDatepickers() {
|
|
|
147
150
|
);
|
|
148
151
|
|
|
149
152
|
datepickerObject.value = new Datepicker(datepickerStartEl.value, options);
|
|
153
|
+
// the calendar goes to body and takes only a selector of the document for another container
|
|
154
|
+
if (teleportTarget instanceof HTMLElement) {
|
|
155
|
+
datepickerObject.value.config.container = teleportTarget;
|
|
156
|
+
teleportTarget.appendChild(datepickerObject.value.picker.element);
|
|
157
|
+
}
|
|
150
158
|
|
|
151
159
|
addChangeDateListener();
|
|
152
160
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
class="afcl-dialog"
|
|
5
5
|
:aria-labelledby="header ? titleId : undefined"
|
|
6
6
|
v-bind="$attrs"
|
|
7
|
-
:closeByClickOutside="
|
|
8
|
-
:closeByEsc="closeByEsc
|
|
7
|
+
:closeByClickOutside="closeByClickOutside"
|
|
8
|
+
:closeByEsc="closeByEsc"
|
|
9
9
|
:beforeCloseFunction="beforeCloseFunction"
|
|
10
10
|
:beforeCancelFunction="beforeCancelFunction"
|
|
11
11
|
:beforeOpenFunction="beforeOpenFunction"
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
:key="buttonIndex"
|
|
57
57
|
v-bind="button.options"
|
|
58
58
|
@click="button.onclick(dialog)"
|
|
59
|
-
:mode="button.options?.mode || 'primary'"
|
|
60
59
|
>
|
|
61
60
|
{{ button.label }}
|
|
62
61
|
</Button>
|
|
@@ -93,12 +92,10 @@ const props = withDefaults(defineProps<DialogProps>(), {
|
|
|
93
92
|
header: '',
|
|
94
93
|
headerCloseButton: true,
|
|
95
94
|
buttons: () => [],
|
|
96
|
-
clickToCloseOutside: false,
|
|
97
95
|
closeByEsc: true,
|
|
98
96
|
closeByClickOutside: true,
|
|
99
97
|
beforeCloseFunction: null,
|
|
100
98
|
beforeOpenFunction: null,
|
|
101
|
-
closable: false,
|
|
102
99
|
askForCloseConfirmation: false,
|
|
103
100
|
closeConfirmationText: 'Are you sure you want to close this dialog?',
|
|
104
101
|
removeFromDomOnClose: false,
|
|
@@ -159,13 +156,6 @@ interface DialogProps {
|
|
|
159
156
|
*/
|
|
160
157
|
buttons?: DialogButton[]
|
|
161
158
|
|
|
162
|
-
/**
|
|
163
|
-
* If true, clicking outside the dialog will close it. Default is true.
|
|
164
|
-
*
|
|
165
|
-
* @deprecated Use `closeByClickOutside` instead
|
|
166
|
-
*/
|
|
167
|
-
clickToCloseOutside?: boolean
|
|
168
|
-
|
|
169
159
|
/**
|
|
170
160
|
* If true, pressing the Esc key will close the dialog. Default is true.
|
|
171
161
|
*/
|
|
@@ -191,13 +181,6 @@ interface DialogProps {
|
|
|
191
181
|
*/
|
|
192
182
|
beforeCancelFunction?: (() => void | Promise<void | boolean>) | null
|
|
193
183
|
|
|
194
|
-
/**
|
|
195
|
-
* Disables close on Ecs button
|
|
196
|
-
*
|
|
197
|
-
* @deprecated Use `closeByEsc` or instead
|
|
198
|
-
*/
|
|
199
|
-
closable?: boolean
|
|
200
|
-
|
|
201
184
|
/**
|
|
202
185
|
* If true, the dialog will ask for confirmation before closing. Default is false.
|
|
203
186
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="afcl-dropdown-menu-trigger" @click="onTriggerClick">
|
|
4
4
|
<slot name="trigger" :open="isOpen" />
|
|
5
5
|
</div>
|
|
6
|
-
<Teleport to="
|
|
6
|
+
<Teleport :to="teleportTarget" :disabled="!teleportToBody">
|
|
7
7
|
<div
|
|
8
8
|
v-if="keepMounted || isOpen"
|
|
9
9
|
v-show="isOpen"
|
|
@@ -23,6 +23,7 @@ import { computed, inject, nextTick, onBeforeUnmount, provide, ref, useAttrs, wa
|
|
|
23
23
|
import { type ClassNameValue } from 'tailwind-merge';
|
|
24
24
|
import { mergeClasses } from './classMerge';
|
|
25
25
|
import { DROPDOWN_MENU_KEY, type DropdownMenuPlacement } from './dropdownMenuContext';
|
|
26
|
+
import { useTeleportTarget } from './shadowRoot';
|
|
26
27
|
|
|
27
28
|
defineOptions({ inheritAttrs: false });
|
|
28
29
|
|
|
@@ -39,6 +40,8 @@ const props = withDefaults(defineProps<{
|
|
|
39
40
|
teleportToBody: false,
|
|
40
41
|
});
|
|
41
42
|
|
|
43
|
+
const teleportTarget = useTeleportTarget();
|
|
44
|
+
|
|
42
45
|
const isOpen = defineModel<boolean>('open', { default: false });
|
|
43
46
|
|
|
44
47
|
const attrs = useAttrs();
|
|
@@ -148,7 +151,8 @@ function placeFixed() {
|
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
function onDocumentMousedown(e: MouseEvent) {
|
|
151
|
-
|
|
154
|
+
// inside a shadow root e.target is the host, composedPath() starts at the clicked element
|
|
155
|
+
const target = e.composedPath()[0] as Node;
|
|
152
156
|
if (rootRef.value?.contains(target) || contentRef.value?.contains(target)) {
|
|
153
157
|
return;
|
|
154
158
|
}
|
|
@@ -163,7 +167,8 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
163
167
|
|
|
164
168
|
function onViewportChange(e: Event) {
|
|
165
169
|
// scrolling inside the menu itself must not close it
|
|
166
|
-
|
|
170
|
+
const target = e.composedPath()[0];
|
|
171
|
+
if (target instanceof Node && contentRef.value?.contains(target)) {
|
|
167
172
|
return;
|
|
168
173
|
}
|
|
169
174
|
close();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
@dragleave.prevent="dragging = false"
|
|
6
6
|
@drop.prevent="dragging = false; doEmit(($event.dataTransfer as DataTransfer).files)"
|
|
7
7
|
>
|
|
8
|
-
<label :id="id" class="flex flex-col items-center justify-center w-full border border-dashed rounded-lg cursor-pointer transition-colors
|
|
8
|
+
<label ref="labelEl" :id="id" class="flex flex-col items-center justify-center w-full border border-dashed rounded-lg cursor-pointer transition-colors
|
|
9
9
|
hover:bg-lightDropzoneBackgroundHover hover:border-lightDropzoneBorderHover dark:hover:border-darkDropzoneBorderHover dark:hover:bg-darkDropzoneBackgroundHover"
|
|
10
10
|
:class="{
|
|
11
11
|
'border-lightDropzoneBorderDragging dark:border-darkDropzoneBorderDragging': dragging,
|
|
@@ -203,6 +203,7 @@ function doEmit(filesIn: FileList) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
const dragging = ref(false);
|
|
206
|
+
const labelEl = ref<HTMLLabelElement>();
|
|
206
207
|
|
|
207
208
|
function removeFile(index: number) {
|
|
208
209
|
storedFiles.value = storedFiles.value.filter((_, i) => i !== index);
|
|
@@ -214,7 +215,7 @@ function clear() {
|
|
|
214
215
|
selectedFiles.value = [];
|
|
215
216
|
storedFiles.value = [];
|
|
216
217
|
emit('update:modelValue', []);
|
|
217
|
-
const form =
|
|
218
|
+
const form = labelEl.value?.closest('form');
|
|
218
219
|
form?.reset();
|
|
219
220
|
}
|
|
220
221
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
>
|
|
6
6
|
<slot name="trigger"></slot>
|
|
7
7
|
</div>
|
|
8
|
-
<Teleport to="
|
|
8
|
+
<Teleport :to="teleportTarget">
|
|
9
9
|
<Transition
|
|
10
10
|
enter-from-class="af-modal-hidden opacity-0"
|
|
11
11
|
enter-active-class="transition-opacity duration-150 ease-out motion-reduce:transition-none"
|
|
@@ -81,9 +81,11 @@ import Button from "./Button.vue";
|
|
|
81
81
|
import { ref, onMounted, nextTick, onUnmounted, computed, watch, useId, type Ref } from 'vue';
|
|
82
82
|
import { useI18n } from 'vue-i18n';
|
|
83
83
|
import { dialogPanelClasses, dialogFooterClasses } from './dialogStyles';
|
|
84
|
+
import { useTeleportTarget, activeElementIn } from './shadowRoot';
|
|
84
85
|
|
|
85
86
|
const isModalOpen = defineModel<boolean>('open', { default: false });
|
|
86
87
|
const { t } = useI18n();
|
|
88
|
+
const teleportTarget = useTeleportTarget();
|
|
87
89
|
|
|
88
90
|
const removeFromDom = computed(() => {
|
|
89
91
|
return props.removeFromDomOnClose && !isModalOpen.value;
|
|
@@ -126,7 +128,7 @@ watch(isModalOpen, async (open) => {
|
|
|
126
128
|
if (open) {
|
|
127
129
|
focusBeforeOpen = document.activeElement as HTMLElement | null;
|
|
128
130
|
await nextTick();
|
|
129
|
-
if (!panelRef.value!.contains(
|
|
131
|
+
if (!panelRef.value!.contains(activeElementIn(panelRef.value!))) {
|
|
130
132
|
panelRef.value!.focus({ preventScroll: true });
|
|
131
133
|
}
|
|
132
134
|
} else {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
/>
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
|
-
<teleport to="
|
|
47
|
+
<teleport :to="teleportTarget" v-if="(teleportToBody || teleportToTop) && showDropdown">
|
|
48
48
|
<div ref="dropdownEl" :style="getDropdownPosition" :class="{'shadow-none': isTop, 'z-30': teleportToBody, 'z-[1000]': teleportToTop}"
|
|
49
49
|
class="fixed w-full bg-lightDropdownOptionsBackground shadow-popover dark:shadow-darkPopover dark:bg-darkDropdownOptionsBackground
|
|
50
50
|
rounded-lg p-1 text-base overflow-auto focus:outline-none sm:text-sm max-h-60"
|
|
@@ -118,6 +118,7 @@
|
|
|
118
118
|
import { ref, computed, onMounted, onUnmounted, watch, nextTick, useId,type PropType, type Ref } from 'vue';
|
|
119
119
|
import { IconChevronDown, IconX } from '@iconify-prerendered/vue-lucide';
|
|
120
120
|
import { useElementSize } from '@vueuse/core'
|
|
121
|
+
import { useTeleportTarget } from './shadowRoot';
|
|
121
122
|
|
|
122
123
|
type ISingleSelectModelValue = string | number | boolean | null;
|
|
123
124
|
|
|
@@ -310,9 +311,12 @@ const filteredItems: Ref<any[]> = computed(() => {
|
|
|
310
311
|
});
|
|
311
312
|
|
|
312
313
|
|
|
314
|
+
const teleportTarget = useTeleportTarget();
|
|
315
|
+
|
|
313
316
|
const handleClickOutside = (event: MouseEvent) => {
|
|
314
|
-
|
|
315
|
-
const
|
|
317
|
+
// inside a shadow root event.target is the host, composedPath() starts at the clicked element
|
|
318
|
+
const targetEl = event.composedPath()[0] as HTMLElement;
|
|
319
|
+
const closestSelect = targetEl.closest('.afcl-select');
|
|
316
320
|
if (closestSelect !== internalSelect.value)
|
|
317
321
|
showDropdown.value = false;
|
|
318
322
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div ref="triggerEl" class="afcl-tooltip inline-flex items-center" :style="{ anchorName }" @mouseenter="show" @mouseleave="hide">
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</div>
|
|
5
|
-
<teleport to="
|
|
5
|
+
<teleport :to="teleportTarget" v-if="isOpen">
|
|
6
6
|
<div
|
|
7
7
|
ref="tooltipEl"
|
|
8
8
|
popover="manual"
|
|
@@ -19,11 +19,13 @@
|
|
|
19
19
|
|
|
20
20
|
<script setup lang="ts">
|
|
21
21
|
import { ref, nextTick, onBeforeUnmount, useId } from 'vue';
|
|
22
|
+
import { useTeleportTarget } from './shadowRoot';
|
|
22
23
|
|
|
23
24
|
const OFFSET = 8;
|
|
24
25
|
const SUPPORTS_ANCHOR = CSS.supports('anchor-name: --a');
|
|
25
26
|
|
|
26
27
|
const anchorName = `--afcl-tooltip-${useId()}`;
|
|
28
|
+
const teleportTarget = useTeleportTarget();
|
|
27
29
|
const triggerEl = ref<HTMLElement>();
|
|
28
30
|
const tooltipEl = ref<HTMLElement>();
|
|
29
31
|
const isOpen = ref(false);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from 'vue';
|
|
2
|
+
|
|
3
|
+
// AFCL also renders inside a shadow root (the live examples of the docs): popups, modals and tooltips go to an
|
|
4
|
+
// element of that root instead of body, or they lose the styles of the root. The element is positioned,
|
|
5
|
+
// DatePicker places its calendar relative to it
|
|
6
|
+
|
|
7
|
+
export const AFCL_TELEPORT_TARGET: InjectionKey<string | HTMLElement> = Symbol('afclTeleportTarget');
|
|
8
|
+
|
|
9
|
+
export function useTeleportTarget() {
|
|
10
|
+
return inject(AFCL_TELEPORT_TARGET, 'body');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// the focused element as the tree of node sees it: document.activeElement in a page, inside a shadow root the
|
|
14
|
+
// element of that root (document.activeElement there is the shadow host)
|
|
15
|
+
export function activeElementIn(node: Node) {
|
|
16
|
+
return (node.getRootNode() as Document | ShadowRoot).activeElement;
|
|
17
|
+
}
|
|
@@ -118,14 +118,6 @@ export const useCoreStore = defineStore('core', () => {
|
|
|
118
118
|
await fetchConfig();
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
/**
|
|
122
|
-
* @deprecated kept for plugins which were written when public config had own endpoint. Use fetchConfig instead.
|
|
123
|
-
* Old endpoint was noAuth and never redirected to login, so anonymous answer is not redirected here as well.
|
|
124
|
-
*/
|
|
125
|
-
async function getPublicConfig() {
|
|
126
|
-
await fetchConfig({ redirectToLoginIfNotLoggedIn: false });
|
|
127
|
-
}
|
|
128
|
-
|
|
129
121
|
async function refreshMenu() {
|
|
130
122
|
await fetchMenuAndResource();
|
|
131
123
|
await fetchMenuBadges();
|
|
@@ -152,15 +144,17 @@ export const useCoreStore = defineStore('core', () => {
|
|
|
152
144
|
}
|
|
153
145
|
}
|
|
154
146
|
}
|
|
147
|
+
let menuBadgeUnsubscribes: Array<() => void> = [];
|
|
155
148
|
async function subscribeToMenuBadges() {
|
|
149
|
+
menuBadgeUnsubscribes.forEach((unsubscribe) => unsubscribe());
|
|
150
|
+
menuBadgeUnsubscribes = [];
|
|
156
151
|
const processItem = (mi: AdminForthConfigMenuItem) => {
|
|
157
152
|
|
|
158
153
|
// console.log('🔔 subscribeToMenuBadges', mi.badge, JSON.stringify(mi));
|
|
159
154
|
if (mi.badge !== undefined) {
|
|
160
|
-
websocket.
|
|
161
|
-
websocket.subscribe(`/opentopic/update-menu-badge/${mi.itemId}`, ({ badge }) => {
|
|
155
|
+
menuBadgeUnsubscribes.push(websocket.subscribe(`/opentopic/update-menu-badge/${mi.itemId}`, ({ badge }) => {
|
|
162
156
|
mi.badge = badge;
|
|
163
|
-
});
|
|
157
|
+
}));
|
|
164
158
|
}
|
|
165
159
|
}
|
|
166
160
|
|
|
@@ -322,7 +316,6 @@ export const useCoreStore = defineStore('core', () => {
|
|
|
322
316
|
userFullname,
|
|
323
317
|
userAvatarUrl,
|
|
324
318
|
fetchConfig,
|
|
325
|
-
getPublicConfig,
|
|
326
319
|
fetchMenuAndResource,
|
|
327
320
|
refreshMenu,
|
|
328
321
|
getLoginFormConfig,
|