@bobbykim/manguito-theme 0.17.0 → 0.18.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 CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.18.0](https://github.com/bobbykim89/manguito-component-library/compare/@bobbykim/manguito-theme@0.17.0...@bobbykim/manguito-theme@0.18.0) (2024-04-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * **manguito-theme:** update alert component event, update readme files, update story files ([99d4a7e](https://github.com/bobbykim89/manguito-component-library/commit/99d4a7ef192dfb628cf5b37b1cce34bb33aeb4c1))
12
+ * **manguito-theme:** update observeVisibleAttr composable, add alert component ([1629762](https://github.com/bobbykim89/manguito-component-library/commit/16297624b667066bd7076b02001f0ca8db65630d))
13
+ * ready for production ([4e2fc04](https://github.com/bobbykim89/manguito-component-library/commit/4e2fc048edd67791b4e917e0a764f301d4c610cb))
14
+
15
+
16
+
17
+
18
+
6
19
  # [0.17.0](https://github.com/bobbykim89/manguito-component-library/compare/@bobbykim/manguito-theme@0.15.0...@bobbykim/manguito-theme@0.17.0) (2024-03-24)
7
20
 
8
21
 
package/README.md CHANGED
@@ -8,6 +8,7 @@ manguito-theme includes basic config for MCL, including type definitions for the
8
8
 
9
9
  - [Installation](https://manguito-component-library.vercel.app/?path=/docs/introduction-installation--docs)
10
10
  - Base Components
11
+ - [Alert](https://manguito-component-library.vercel.app/?path=/docs/base-base-component-alert-component--alert)
11
12
  - [Collapse](https://manguito-component-library.vercel.app/?path=/docs/base-base-component-collapse-component--collapse)
12
13
  - [Dropdown](https://manguito-component-library.vercel.app/?path=/docs/base-base-component-dropdown-component--dropdown)
13
14
  - [Modal](https://manguito-component-library.vercel.app/?path=/docs/base-base-component-modal-component--modal)
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { generateClass } from './lib/theme/generateClass';
2
+ import Alert from './lib/alert/Alert.vue';
2
3
  import Collapse from './lib/collapse/Collapse.vue';
3
4
  import DropdownContainer from './lib/dropdown/DropdownContainer.vue';
4
5
  import DropdownContent from './lib/dropdown/DropdownContent.vue';
@@ -9,5 +10,5 @@ import Sidebar from './lib/sidebar/Sidebar.vue';
9
10
  export * from './lib/directives';
10
11
  export * from './lib/header/index.types';
11
12
  export * from './lib/theme/theme.types';
12
- export { Collapse, DropdownContainer, DropdownContent, HeaderHorizontal, HeaderVertical, Modal, Sidebar, };
13
+ export { Alert, Collapse, DropdownContainer, DropdownContent, HeaderHorizontal, HeaderVertical, Modal, Sidebar, };
13
14
  export default generateClass;
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // generate class function
2
2
  import { generateClass } from './lib/theme/generateClass';
3
3
  // base components
4
+ import Alert from './lib/alert/Alert.vue';
4
5
  import Collapse from './lib/collapse/Collapse.vue';
5
6
  import DropdownContainer from './lib/dropdown/DropdownContainer.vue';
6
7
  import DropdownContent from './lib/dropdown/DropdownContent.vue';
@@ -14,5 +15,5 @@ export * from './lib/directives';
14
15
  export * from './lib/header/index.types';
15
16
  export * from './lib/theme/theme.types';
16
17
  // export components
17
- export { Collapse, DropdownContainer, DropdownContent, HeaderHorizontal, HeaderVertical, Modal, Sidebar, };
18
+ export { Alert, Collapse, DropdownContainer, DropdownContent, HeaderHorizontal, HeaderVertical, Modal, Sidebar, };
18
19
  export default generateClass;
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // generate class function
2
2
  import { generateClass } from './lib/theme/generateClass'
3
3
  // base components
4
+ import Alert from './lib/alert/Alert.vue'
4
5
  import Collapse from './lib/collapse/Collapse.vue'
5
6
  import DropdownContainer from './lib/dropdown/DropdownContainer.vue'
6
7
  import DropdownContent from './lib/dropdown/DropdownContent.vue'
@@ -17,6 +18,7 @@ export * from './lib/theme/theme.types'
17
18
 
18
19
  // export components
19
20
  export {
21
+ Alert,
20
22
  Collapse,
21
23
  DropdownContainer,
22
24
  DropdownContent,
@@ -0,0 +1,92 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, watch } from 'vue'
3
+ import type { ColorPalette } from '../../'
4
+ import generateClass from '../../'
5
+ const props = withDefaults(
6
+ defineProps<{
7
+ color?: ColorPalette
8
+ rounded?: boolean
9
+ shadow?: boolean
10
+ show?: boolean
11
+ dismissible?: boolean
12
+ }>(),
13
+ {
14
+ color: 'danger',
15
+ rounded: true,
16
+ shadow: true,
17
+ show: false,
18
+ dismissible: false,
19
+ }
20
+ )
21
+
22
+ const slots = defineSlots<{
23
+ default: any
24
+ }>()
25
+
26
+ const emit = defineEmits<{
27
+ (e: 'close', event: Event): void
28
+ }>()
29
+
30
+ const showAlert = ref<boolean>(props.show)
31
+ const componentClass = computed<string>(() => {
32
+ const { color, rounded, shadow } = props
33
+ const classArray: string[] = [generateClass('BGCOLOR', color)]
34
+ if (rounded) {
35
+ classArray.push('rounded-md')
36
+ }
37
+ if (shadow) {
38
+ classArray.push('drop-shadow-md')
39
+ }
40
+ return classArray.join(' ')
41
+ })
42
+ const handleClose = (e: Event) => {
43
+ showAlert.value = false
44
+ emit('close', e)
45
+ }
46
+ const closeAlert = () => {
47
+ showAlert.value = false
48
+ }
49
+ watch(
50
+ () => props.show,
51
+ (newValue) => {
52
+ showAlert.value = newValue
53
+ }
54
+ )
55
+ defineExpose({
56
+ close: closeAlert,
57
+ })
58
+ </script>
59
+
60
+ <template>
61
+ <div
62
+ v-if="showAlert"
63
+ role="alert"
64
+ aria-live="polite"
65
+ aria-atomic="true"
66
+ class="py-[0.75rem] px-[1.25rem] relative"
67
+ :class="[componentClass]"
68
+ >
69
+ <div class="w-full flex justify-between gap-2xs">
70
+ <div class="w-full">
71
+ <slot></slot>
72
+ </div>
73
+ <button
74
+ v-if="dismissible"
75
+ @click="handleClose"
76
+ class="flex items-center opacity-60 hover:opacity-40 transition-opacity duration-300 ease-linear"
77
+ >
78
+ <svg
79
+ xmlns="http://www.w3.org/2000/svg"
80
+ viewBox="0 0 384 512"
81
+ fill="currentColor"
82
+ class="h-xs"
83
+ >
84
+ <!-- !Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc. -->
85
+ <path
86
+ d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"
87
+ />
88
+ </svg>
89
+ </button>
90
+ </div>
91
+ </div>
92
+ </template>
@@ -0,0 +1,65 @@
1
+ import type { ColorPalette } from '../../';
2
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ color?: ColorPalette | undefined;
4
+ rounded?: boolean | undefined;
5
+ shadow?: boolean | undefined;
6
+ show?: boolean | undefined;
7
+ dismissible?: boolean | undefined;
8
+ }>, {
9
+ color: string;
10
+ rounded: boolean;
11
+ shadow: boolean;
12
+ show: boolean;
13
+ dismissible: boolean;
14
+ }>, {
15
+ close: () => void;
16
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
+ close: (event: Event) => void;
18
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
19
+ color?: ColorPalette | undefined;
20
+ rounded?: boolean | undefined;
21
+ shadow?: boolean | undefined;
22
+ show?: boolean | undefined;
23
+ dismissible?: boolean | undefined;
24
+ }>, {
25
+ color: string;
26
+ rounded: boolean;
27
+ shadow: boolean;
28
+ show: boolean;
29
+ dismissible: boolean;
30
+ }>>> & {
31
+ onClose?: ((event: Event) => any) | undefined;
32
+ }, {
33
+ color: ColorPalette;
34
+ shadow: boolean;
35
+ rounded: boolean;
36
+ show: boolean;
37
+ dismissible: boolean;
38
+ }, {}>, Readonly<{
39
+ default: any;
40
+ }> & {
41
+ default: any;
42
+ }>;
43
+ export default _default;
44
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
45
+ type __VLS_TypePropsToRuntimeProps<T> = {
46
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
47
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
48
+ } : {
49
+ type: import('vue').PropType<T[K]>;
50
+ required: true;
51
+ };
52
+ };
53
+ type __VLS_WithDefaults<P, D> = {
54
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
55
+ default: D[K];
56
+ }> : P[K];
57
+ };
58
+ type __VLS_Prettify<T> = {
59
+ [K in keyof T]: T[K];
60
+ } & {};
61
+ type __VLS_WithTemplateSlots<T, S> = T & {
62
+ new (): {
63
+ $slots: S;
64
+ };
65
+ };
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { Transition, onBeforeUnmount, onMounted, ref, watch } from 'vue'
2
+ import { Transition, ref, watch } from 'vue'
3
3
  import { observeVisibleAttr } from '../composables'
4
4
 
5
5
  const props = withDefaults(
@@ -67,7 +67,7 @@ const onLeave = (el: any) => {
67
67
  const handleVisibility = (visible: boolean = false) => {
68
68
  toggle.value = visible
69
69
  }
70
- const observer = observeVisibleAttr(handleVisibility)
70
+ observeVisibleAttr(collapseRef, handleVisibility)
71
71
 
72
72
  watch(
73
73
  () => props.visible,
@@ -87,14 +87,6 @@ defineExpose({
87
87
  close: closeCollapse,
88
88
  open: openCollapse,
89
89
  })
90
- onMounted(() => {
91
- if (collapseRef.value) {
92
- observer.observe(collapseRef.value, { attributes: true })
93
- }
94
- })
95
- onBeforeUnmount(() => {
96
- observer.disconnect()
97
- })
98
90
  </script>
99
91
 
100
92
  <template>
@@ -1 +1,6 @@
1
- export declare const observeVisibleAttr: (fn: (...args: any[]) => void) => MutationObserver;
1
+ import type { Ref } from 'vue';
2
+ export declare const observeVisibleAttr: (el: Ref, fn: (...args: any[]) => void) => {
3
+ isSupported: import("vue").ComputedRef<boolean>;
4
+ stop: () => void;
5
+ takeRecords: () => MutationRecord[] | undefined;
6
+ };
@@ -1,15 +1,16 @@
1
- export const observeVisibleAttr = (fn) => {
2
- const observer = new MutationObserver((mutations) => {
1
+ import { useMutationObserver } from '@vueuse/core';
2
+ export const observeVisibleAttr = (el, fn) => {
3
+ return useMutationObserver(el, (mutations) => {
3
4
  let changed = false;
4
5
  for (let i = 0; i < mutations.length && !changed; i++) {
5
6
  const mutation = mutations[i];
6
7
  const mutationType = mutation.type;
7
- const mutationAttribute = mutation.attributeName;
8
+ const mutationAttr = mutation.attributeName;
8
9
  const mutationTarget = mutation.target;
9
10
  if (mutationType === 'attributes') {
10
11
  changed = true;
11
12
  }
12
- else if (mutationAttribute === 'visible') {
13
+ else if (mutationAttr === 'visible') {
13
14
  changed = true;
14
15
  }
15
16
  if (changed) {
@@ -19,6 +20,5 @@ export const observeVisibleAttr = (fn) => {
19
20
  fn(visibleAttr);
20
21
  }
21
22
  }
22
- });
23
- return observer;
23
+ }, { attributes: true });
24
24
  };
@@ -1,24 +1,30 @@
1
- export const observeVisibleAttr = (fn: (...args: any[]) => void) => {
2
- const observer = new MutationObserver((mutations) => {
3
- let changed = false
4
- for (let i = 0; i < mutations.length && !changed; i++) {
5
- const mutation = mutations[i]
6
- const mutationType = mutation.type
7
- const mutationAttribute = mutation.attributeName
8
- const mutationTarget = mutation.target
9
- if (mutationType === 'attributes') {
10
- changed = true
11
- } else if (mutationAttribute === 'visible') {
12
- changed = true
1
+ import { useMutationObserver } from '@vueuse/core'
2
+ import type { Ref } from 'vue'
3
+
4
+ export const observeVisibleAttr = (el: Ref, fn: (...args: any[]) => void) => {
5
+ return useMutationObserver(
6
+ el,
7
+ (mutations) => {
8
+ let changed: boolean = false
9
+ for (let i = 0; i < mutations.length && !changed; i++) {
10
+ const mutation = mutations[i]
11
+ const mutationType = mutation.type
12
+ const mutationAttr = mutation.attributeName
13
+ const mutationTarget = mutation.target
14
+ if (mutationType === 'attributes') {
15
+ changed = true
16
+ } else if (mutationAttr === 'visible') {
17
+ changed = true
18
+ }
19
+ if (changed) {
20
+ const visibleAttr =
21
+ (mutationTarget as HTMLElement).getAttribute('visible') === 'true'
22
+ ? true
23
+ : false
24
+ fn(visibleAttr)
25
+ }
13
26
  }
14
- if (changed) {
15
- const visibleAttr =
16
- (mutationTarget as HTMLElement).getAttribute('visible') === 'true'
17
- ? true
18
- : false
19
- fn(visibleAttr)
20
- }
21
- }
22
- })
23
- return observer
27
+ },
28
+ { attributes: true }
29
+ )
24
30
  }
@@ -1,12 +1,5 @@
1
1
  <script setup lang="ts">
2
- import {
3
- Transition,
4
- computed,
5
- onBeforeUnmount,
6
- onMounted,
7
- ref,
8
- watch,
9
- } from 'vue'
2
+ import { Transition, computed, ref, watch } from 'vue'
10
3
  import type { ColorPalette, VerticalAlignment } from '../../'
11
4
  import generateClass, { vClickOutside } from '../../'
12
5
  import { observeVisibleAttr } from '../composables'
@@ -92,7 +85,8 @@ const onAfterLeave = () => {
92
85
  const handleVisibility = (visible: boolean = false) => {
93
86
  toggle.value = visible
94
87
  }
95
- const observer = observeVisibleAttr(handleVisibility)
88
+
89
+ observeVisibleAttr(modalRef, handleVisibility)
96
90
 
97
91
  watch(
98
92
  () => props.visible,
@@ -112,14 +106,6 @@ defineExpose({
112
106
  close: closeModal,
113
107
  open: openModal,
114
108
  })
115
- onMounted(() => {
116
- if (modalRef.value) {
117
- observer.observe(modalRef.value, { attributes: true })
118
- }
119
- })
120
- onBeforeUnmount(() => {
121
- observer.disconnect()
122
- })
123
109
  </script>
124
110
 
125
111
  <template>
@@ -1,12 +1,5 @@
1
1
  <script setup lang="ts">
2
- import {
3
- Transition,
4
- computed,
5
- onBeforeUnmount,
6
- onMounted,
7
- ref,
8
- watch,
9
- } from 'vue'
2
+ import { Transition, computed, ref, watch } from 'vue'
10
3
  import type { ColorPalette, DirectionX } from '../../'
11
4
  import generateClass, { vClickOutside } from '../../'
12
5
  import { observeVisibleAttr } from '../composables'
@@ -101,7 +94,8 @@ const onAfterLeave = () => {
101
94
  const handleVisibility = (visible: boolean = false) => {
102
95
  toggle.value = visible
103
96
  }
104
- const observer = observeVisibleAttr(handleVisibility)
97
+
98
+ observeVisibleAttr(sidebarRef, handleVisibility)
105
99
 
106
100
  watch(
107
101
  () => props.visible,
@@ -121,14 +115,6 @@ defineExpose({
121
115
  open: openSidebar,
122
116
  close: closeSidebar,
123
117
  })
124
- onMounted(() => {
125
- if (sidebarRef.value) {
126
- observer.observe(sidebarRef.value, { attributes: true })
127
- }
128
- })
129
- onBeforeUnmount(() => {
130
- observer.disconnect()
131
- })
132
118
  </script>
133
119
 
134
120
  <template>
@@ -55,12 +55,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
55
55
  visible: boolean;
56
56
  className: string;
57
57
  color: ColorPalette;
58
+ width: string | number;
58
59
  titleColor: ColorPalette;
59
60
  noBackdrop: boolean;
60
61
  noHeader: boolean;
61
62
  backdropColor: ColorPalette;
62
63
  placement: DirectionX;
63
- width: string | number;
64
64
  }, {}>, Readonly<{
65
65
  header(props: {
66
66
  close: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobbykim/manguito-theme",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "main theme file for manguito components library. Other MCL components will need to import this file to run.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -30,5 +30,5 @@
30
30
  "url": "https://github.com/bobbykim89/manguito-component-library.git"
31
31
  },
32
32
  "license": "MIT",
33
- "gitHead": "f4be01699f747aba1f831a1f796f8e41e6fcd676"
33
+ "gitHead": "969800695a9a902bc9d0c19ad6ab002caace8061"
34
34
  }