@maas/vue-equipment 0.32.1 → 0.32.3

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.32.0",
4
+ "version": "0.32.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.1",
7
7
  "unbuild": "unknown"
@@ -1,7 +1,8 @@
1
1
  <template>
2
- <div :class="['magic-accordion-content', { '-active': isActive }]">
2
+ <div :class="['magic-accordion-content', { '-active': view?.active }]">
3
3
  <magic-auto-size :immediate="true" :width="false">
4
4
  <transition
5
+ mode="out-in"
5
6
  :name="state.options.transition"
6
7
  :on-before-enter="onBeforeEnter"
7
8
  :on-enter="onEnter"
@@ -10,8 +11,8 @@
10
11
  :on-leave="onLeave"
11
12
  :on-after-leave="onAfterLeave"
12
13
  >
13
- <primitive :as-child="asChild" v-if="isActive">
14
- <slot />
14
+ <primitive :as-child="asChild" v-show="view?.active">
15
+ <slot :is-active="view?.active" />
15
16
  </primitive>
16
17
  </transition>
17
18
  </magic-auto-size>
@@ -19,7 +20,7 @@
19
20
  </template>
20
21
 
21
22
  <script lang="ts" setup>
22
- import { computed, inject } from 'vue'
23
+ import { inject } from 'vue'
23
24
  import { Primitive } from '@maas/vue-primitive'
24
25
  import { useAccordionView } from '../composables/private/useAccordionView'
25
26
  import { useAccordionState } from '../composables/private/useAccordionState'
@@ -52,8 +53,6 @@ const state = initializeState()
52
53
  const { getView } = useAccordionView(instanceId)
53
54
  const view = getView(viewId)
54
55
 
55
- const isActive = computed(() => view?.active)
56
-
57
56
  const {
58
57
  onBeforeEnter,
59
58
  onEnter,
@@ -68,5 +67,5 @@ const {
68
67
  </script>
69
68
 
70
69
  <style>
71
- :root{--magic-accordion-enter-animation:fade-in 150ms var(--ease-in-out);--magic-accordion-leave-animation:none 200ms var(--ease-in-out-sharp);--magic-accordion-size-transition:all 200ms var(--ease-in-out-sharp);--magic-accordion-content-clip-path:inset(0)}.magic-accordion-content{--magic-auto-size-transition:var(--magic-accordion-size-transition);clip-path:var(--magic-accordion-content-clip-path)}.magic-accordion-enter-active{animation:var(--magic-accordion-enter-animation);position:relative}.magic-accordion-leave-active{animation:var(--magic-accordion-leave-animation)}
70
+ :root{--magic-accordion-enter-transition:fade-in 150ms var(--ease-in-out);--magic-accordion-leave-transition:all 200ms var(--ease-in-out-sharp);--magic-accordion-size-transition:all 200ms var(--ease-in-out-sharp);--magic-accordion-content-clip-path:inset(0)}.magic-accordion-content{--magic-auto-size-transition:var(--magic-accordion-size-transition);clip-path:var(--magic-accordion-content-clip-path)}.magic-accordion-enter-active{position:relative;transition:var(--magic-accordion-enter-transition)}.magic-accordion-leave-active{height:0;transition:var(--magic-accordion-leave-transition)}
72
71
  </style>
@@ -4,7 +4,9 @@ interface MagicAccordionContentProps {
4
4
  asChild?: boolean;
5
5
  }
6
6
  declare function __VLS_template(): {
7
- default?(_: {}): any;
7
+ default?(_: {
8
+ isActive: any;
9
+ }): any;
8
10
  };
9
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_TypePropsToOption<MagicAccordionContentProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicAccordionContentProps>>>, {}, {}>;
10
12
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <primitive :as-child="asChild" class="magic-accordion-provider">
2
+ <primitive :as-child="asChild" :id="id" class="magic-accordion-provider">
3
3
  <slot />
4
4
  </primitive>
5
5
  </template>
@@ -20,7 +20,7 @@ interface MagicAccordionProviderProps {
20
20
  const props = defineProps<MagicAccordionProviderProps>()
21
21
 
22
22
  const { deleteState, initializeState } = useAccordionState(props.id)
23
- initializeState()
23
+ initializeState(props.options)
24
24
 
25
25
  // Lifecycle
26
26
  onBeforeUnmount(() => {
@@ -7,7 +7,7 @@
7
7
  @mouseeenter="onMouseenter"
8
8
  @click="onClick"
9
9
  >
10
- <slot />
10
+ <slot :is-active="view?.active" />
11
11
  </primitive>
12
12
  </template>
13
13
 
@@ -19,6 +19,7 @@ import { useAccordionTrigger } from '../composables/private/useAccordionTrigger'
19
19
  import { MagicAccordionInstanceId, MagicAccordionViewId } from '../symbols'
20
20
  import type { Interaction } from '../types'
21
21
  import { useAccordionState } from '../composables/private/useAccordionState'
22
+ import { useAccordionView } from '../composables/private/useAccordionView'
22
23
 
23
24
  interface MagicAccordionTriggerProps {
24
25
  disabled?: MaybeRef<boolean>
@@ -51,6 +52,9 @@ if (!viewId) {
51
52
  const { initializeState } = useAccordionState(instanceId)
52
53
  const state = initializeState()
53
54
 
55
+ const { getView } = useAccordionView(instanceId)
56
+ const view = getView(viewId)
57
+
54
58
  const mappedDisabled = computed(
55
59
  () => toValue(props.disabled) || state.options.disabled
56
60
  )
@@ -6,7 +6,9 @@ interface MagicAccordionTriggerProps {
6
6
  asChild?: boolean;
7
7
  }
8
8
  declare function __VLS_template(): {
9
- default?(_: {}): any;
9
+ default?(_: {
10
+ isActive: any;
11
+ }): any;
10
12
  };
11
13
  declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicAccordionTriggerProps>, {
12
14
  disabled: boolean;
@@ -3,7 +3,7 @@
3
3
  :as-child="asChild"
4
4
  :class="['magic-accordion-view', { '-active': view.active }]"
5
5
  >
6
- <slot />
6
+ <slot :is-active="view?.active" />
7
7
  </primitive>
8
8
  </template>
9
9
 
@@ -4,7 +4,9 @@ interface MagicAccordionViewProps {
4
4
  activeOnMounted?: boolean;
5
5
  }
6
6
  declare function __VLS_template(): {
7
- default?(_: {}): any;
7
+ default?(_: {
8
+ isActive: any;
9
+ }): any;
8
10
  };
9
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_TypePropsToOption<MagicAccordionViewProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicAccordionViewProps>>>, {}, {}>;
10
12
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
@@ -24,7 +24,11 @@ export function useAccordionTrigger(args) {
24
24
  if (focused.value && !toValue(disabled) && !view?.active) {
25
25
  e.preventDefault();
26
26
  e.stopPropagation();
27
- selectView(viewId);
27
+ if (view?.active) {
28
+ unselectView(viewId);
29
+ } else {
30
+ selectView(viewId);
31
+ }
28
32
  }
29
33
  }
30
34
  return {
@@ -78,7 +78,6 @@ const child = computed(() => {
78
78
  useMutationObserver(
79
79
  elRef,
80
80
  (mutations) => {
81
- console.log('mutations:', mutations)
82
81
  const addedNode = mutations
83
82
  .flatMap((m) => [...m.addedNodes])
84
83
  .find((n) => n instanceof HTMLElement)
@@ -127,12 +126,13 @@ useResizeObserver(content, () => {
127
126
 
128
127
  onMounted(() => {
129
128
  if (elRef.value) {
130
- const content = elRef.value.querySelectorAll('*')
131
- const filtered = Array.from(content).find(
129
+ const elements = elRef.value.querySelectorAll('*')
130
+ const filtered = Array.from(elements).find(
132
131
  (node) => node instanceof HTMLElement
133
132
  )
134
133
 
135
134
  if (!!filtered && filtered instanceof HTMLElement) {
135
+ content.value = filtered
136
136
  size.value = {
137
137
  width: filtered.offsetWidth + padding.value.x,
138
138
  height: filtered.offsetHeight + padding.value.y,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.32.1",
4
+ "version": "0.32.3",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "type": "module",
7
7
  "devDependencies": {