@mythpe/quasar-ui-qui 0.0.47 → 0.0.49

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.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/src/components/datatable/MDatatable.vue +66 -70
  3. package/src/components/datatable/MDtBtn.vue +13 -13
  4. package/src/components/form/MBtn.vue +8 -155
  5. package/src/components/form/MCkeditor.vue +2 -2
  6. package/src/components/form/MEditor.vue +2 -4
  7. package/src/components/form/MField.vue +2 -6
  8. package/src/components/form/MFile.vue +6 -4
  9. package/src/components/form/MMobile.vue +3 -3
  10. package/src/components/form/MOptions.vue +1 -3
  11. package/src/components/form/MOtp.vue +1 -3
  12. package/src/components/form/MPicker.vue +8 -11
  13. package/src/components/form/MRadio.vue +4 -7
  14. package/src/components/form/MSelect.vue +3 -5
  15. package/src/components/form/MToggle.vue +3 -6
  16. package/src/components/form/MUploader.vue +8 -10
  17. package/src/components/grid/MBlock.vue +14 -4
  18. package/src/components/grid/MContainer.vue +10 -5
  19. package/src/components/grid/MRow.vue +5 -4
  20. package/src/components/modal/MDialog.vue +2 -2
  21. package/src/components/modal/MModalMenu.vue +4 -5
  22. package/src/components/modal/MTooltip.vue +2 -2
  23. package/src/components/parials/MUploaderItem.vue +5 -6
  24. package/src/composable/useBindInput.ts +12 -11
  25. package/src/composable/useMyth.ts +7 -16
  26. package/src/types/components.d.ts +5 -2
  27. package/src/types/index.d.ts +1 -4
  28. package/src/types/install-options.d.ts +15 -5
  29. package/src/types/myth-api.ts +36 -0
  30. package/src/types/plugin-props-option.d.ts +1 -11
  31. package/src/types/theme.d.ts +47 -0
  32. package/src/utils/const.ts +1 -0
  33. package/src/utils/createMyth.ts +42 -0
  34. package/src/utils/index.ts +3 -2
  35. package/src/utils/vue-plugin.ts +7 -3
  36. package/src/plugin/defineOptions.ts +0 -38
  37. package/src/utils/myth.ts +0 -112
@@ -11,28 +11,33 @@
11
11
  setup
12
12
  >
13
13
  import type { MContainerProps } from '../../types'
14
- import { myth } from '../../utils'
15
14
  import { computed } from 'vue'
15
+ import { useMyth } from '../../composable'
16
16
 
17
17
  const props = withDefaults(defineProps<MContainerProps>(), {
18
18
  size: undefined,
19
19
  dense: !1,
20
20
  fluid: undefined
21
21
  })
22
+ const { theme, props: pluginOptions } = useMyth()
23
+
22
24
  const sizeProp = computed(() => {
23
25
  if (props.size !== undefined) {
24
26
  return props.size
25
27
  }
26
- if (myth.props.value.container?.size !== undefined) {
27
- return myth.props.value.container?.size
28
+ if (pluginOptions.value.container?.size !== undefined) {
29
+ return pluginOptions.value.container?.size
28
30
  }
29
- return myth.size.value
31
+ return theme.value.size
30
32
  })
31
33
  const fluidProp = computed(() => {
32
34
  if (props.fluid !== undefined) {
33
35
  return props.fluid
34
36
  }
35
- return myth.fluid.value === !0
37
+ if (pluginOptions.value.container?.fluid !== undefined) {
38
+ return pluginOptions.value.container?.fluid
39
+ }
40
+ return theme.value.fluid === !0
36
41
  })
37
42
  defineOptions({
38
43
  name: 'MContainer',
@@ -12,20 +12,21 @@
12
12
  >
13
13
  import type { MRowProps } from '../../types'
14
14
  import { computed } from 'vue'
15
- import { myth } from '../../utils'
15
+ import { useMyth } from '../../composable'
16
16
 
17
17
  const props = withDefaults(defineProps<MRowProps>(), {
18
18
  gutter: undefined,
19
19
  col: undefined
20
20
  })
21
- const defSize = 'md'
21
+ const { theme } = useMyth()
22
+ // const defSize = 'md'
22
23
  const gutterSize = computed<string>(() => {
23
24
  if (props.gutter !== undefined) {
24
25
  if (typeof props.gutter === 'string' && props.gutter?.length > 0) {
25
26
  return props.gutter
26
27
  }
27
28
  }
28
- return myth.size.value || defSize
29
+ return theme.value.size
29
30
  })
30
31
  const colSize = computed<string>(() => {
31
32
  if (props.col !== undefined) {
@@ -33,7 +34,7 @@ const colSize = computed<string>(() => {
33
34
  return props.col
34
35
  }
35
36
  }
36
- return myth.size.value || defSize
37
+ return theme.value.size
37
38
  })
38
39
  // const colSize = computed<string>(() => props.gutter === !0 ? defSize.value : (props.gutter || defSize.value))
39
40
  defineOptions({
@@ -34,7 +34,7 @@ const map = {
34
34
 
35
35
  const slideHide = computed<string>(() => 'slide-' + props.from)
36
36
  const slideShow = computed<string>(() => 'slide-' + map[props.from])
37
- const { mOptions } = reactive(useMyth())
37
+ const { props: pluginOptions } = useMyth()
38
38
  defineOptions({
39
39
  name: 'MDialog',
40
40
  inheritAttrs: !1
@@ -51,7 +51,7 @@ defineOptions({
51
51
  no-esc-dismiss
52
52
  no-shake
53
53
  persistent
54
- v-bind="{...mOptions.dialog,...$attrs}"
54
+ v-bind="{...pluginOptions.dialog,...$attrs}"
55
55
  >
56
56
  <slot />
57
57
  </q-dialog>
@@ -12,14 +12,13 @@
12
12
 
13
13
  import type { MModalMenuProps } from '../../types'
14
14
  import { useMyth } from '../../composable'
15
- import { reactive } from 'vue'
16
15
 
17
16
  interface Props {
18
17
  noCloseBtn?: MModalMenuProps['noCloseBtn'];
19
18
  position?: MModalMenuProps['position'];
20
19
  }
21
20
 
22
- const { mOptions, __ } = reactive(useMyth())
21
+ const { props: pluginOptions, __ } = useMyth()
23
22
  withDefaults(defineProps<Props>(), {
24
23
  noCloseBtn: () => !1,
25
24
  position: () => 'bottom'
@@ -38,9 +37,9 @@ defineOptions({
38
37
  maximized
39
38
  no-backdrop-dismiss
40
39
  no-shake
41
- v-bind="{...mOptions.modalMenu,...$attrs}"
40
+ v-bind="{...pluginOptions.modalMenu,...$attrs}"
42
41
  >
43
- <q-card v-bind="mOptions.modalMenuOptions?.card">
42
+ <q-card v-bind="pluginOptions.modalMenuOptions?.card">
44
43
  <slot />
45
44
  <template v-if="!noCloseBtn">
46
45
  <q-separator class="lt-md" />
@@ -48,7 +47,7 @@ defineOptions({
48
47
  v-close-popup
49
48
  class="lt-md"
50
49
  clickable
51
- v-bind="mOptions.modalMenuOptions?.closeBtn"
50
+ v-bind="pluginOptions.modalMenuOptions?.closeBtn"
52
51
  >
53
52
  <q-item-section>
54
53
  <q-item-label header>
@@ -24,7 +24,7 @@ defineOptions({
24
24
  name: 'MTooltip',
25
25
  inheritAttrs: !1
26
26
  })
27
- const { mOptions } = useMyth()
27
+ const { props: pluginOptions } = useMyth()
28
28
  </script>
29
29
 
30
30
  <template>
@@ -32,7 +32,7 @@ const { mOptions } = useMyth()
32
32
  class="m--dt-btn-tooltip"
33
33
  transition-hide="scale"
34
34
  transition-show="scale"
35
- v-bind="{...mOptions.tooltip,...$attrs}"
35
+ v-bind="{...pluginOptions.tooltip,...$attrs}"
36
36
  >
37
37
  <slot />
38
38
  </q-tooltip>
@@ -11,7 +11,7 @@
11
11
  setup
12
12
  >
13
13
 
14
- import { computed, nextTick, reactive, ref } from 'vue'
14
+ import { computed, nextTick, ref } from 'vue'
15
15
  import type { MUploaderMediaItem, MUploaderProps as Props, MUploaderServiceType } from '../../types'
16
16
  import type { QUploader } from 'quasar'
17
17
  import { useQuasar } from 'quasar'
@@ -75,9 +75,8 @@ const emit = defineEmits<Emits>()
75
75
 
76
76
  const q = useQuasar()
77
77
  const { te } = useI18n({ useScope: 'global' })
78
- const $myth = useMyth()
79
- const { alertError, alertSuccess, confirmMessage, __ } = $myth
80
- const { api, mOptions } = reactive($myth)
78
+ const { alertError, alertSuccess, confirmMessage, __, props: pluginOptions, api: mApi } = useMyth()
79
+ const api = computed(() => mApi.value.services)
81
80
  const setModelValue = (value: Props['modelValue']) => emit('values', value)
82
81
  const deleting = ref(!1)
83
82
  const onClickDeleteAttachment = () => {
@@ -274,7 +273,7 @@ defineOptions({ name: 'MUploaderItem' })
274
273
  dense
275
274
  flat
276
275
  target="_blank"
277
- v-bind="mOptions.uploaderOptions?.downloadBtnProps"
276
+ v-bind="pluginOptions.uploaderOptions?.downloadBtnProps"
278
277
  >
279
278
  <q-tooltip class="m--dt-btn-tooltip">
280
279
  {{ __('myth.titles.download') }}
@@ -286,7 +285,7 @@ defineOptions({ name: 'MUploaderItem' })
286
285
  :icon="deleteMediaIcon"
287
286
  dense
288
287
  flat
289
- v-bind="mOptions.uploaderOptions?.removeBtnProps"
288
+ v-bind="pluginOptions.uploaderOptions?.removeBtnProps"
290
289
  @click="onClickDeleteAttachment()"
291
290
  >
292
291
  <q-tooltip class="m--dt-btn-tooltip">
@@ -2,16 +2,18 @@ import type { MaybeRefOrGetter } from 'vue'
2
2
  import { computed, ref, toValue, useAttrs } from 'vue'
3
3
  import { useI18n } from 'vue-i18n'
4
4
  import { useMyth } from './useMyth'
5
- import { myth } from '../utils'
6
5
  import { camelCase, kebabCase, snakeCase, uniq } from 'lodash'
7
- import type { PropsContext as UiOpt } from '../types/plugin-props-option'
6
+ import type { MythComponentsProps as UiOpt } from '../types/plugin-props-option'
8
7
 
9
8
  type G = { name: string; [k: string]: any };
10
9
  type OptsContext = { choose?: boolean; };
11
10
  export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key: keyof UiOpt, Opts: MaybeRefOrGetter<OptsContext> = {}) => {
12
11
  const { messages, locale } = useI18n({ useScope: 'global' })
13
- const { __ } = useMyth()
14
- // const { attributes } = useSplitAttrs()
12
+ const {
13
+ __, theme: mTheme,
14
+ props: pluginProps,
15
+ rules: mRules
16
+ } = useMyth()
15
17
  const attributes = useAttrs()
16
18
  const props = toValue<P>(Props)
17
19
  const opts = toValue<OptsContext>(Opts)
@@ -22,17 +24,16 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
22
24
  return pluginProps.value[key]?.[k]
23
25
  })
24
26
 
25
- const { themeBtn, themeInput, props: pluginProps } = myth
26
- // console.log(themeInput.value)
27
- const themeStyle = computed(() => (key === 'btn' ? themeBtn.value : themeInput.value) ?? {})
27
+ const themeStyle = computed(() => (key === 'btn' ? mTheme.value.buttons : mTheme.value.inputs) ?? {})
28
28
  const theme = ref({})
29
29
  for (const k in themeStyle.value) {
30
30
  theme.value[k] = props[k] !== undefined ? props[k] : themeStyle.value[k]
31
31
  }
32
- /**
33
- * Top Label Style.
34
- */
32
+
35
33
  const hasTopLabel = computed(() => {
34
+ /**
35
+ * Top Label Style.
36
+ */
36
37
  if (props.topLabel !== undefined) {
37
38
  return props.topLabel !== !1
38
39
  }
@@ -167,7 +168,7 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
167
168
  return {}
168
169
  }
169
170
  const rules: any = { ...convertRules(toValue(props.rules)) }
170
- const keys = uniq<string>([...publicRules, ...(myth.rules.value ?? []), ...Object.keys(validations)])
171
+ const keys = uniq<string>([...publicRules, ...(mRules.value ?? []), ...Object.keys(validations)])
171
172
  for (const k of keys) {
172
173
  if (['mobile', '_default', 'default'].includes(k)) {
173
174
  continue
@@ -11,13 +11,15 @@ import { useI18n } from 'vue-i18n'
11
11
  import type { RouteLocationNormalizedLoaded } from 'vue-router'
12
12
  import type { QDialogOptions, QNotifyCreateOptions } from 'quasar'
13
13
  import { copyToClipboard, extend, useQuasar } from 'quasar'
14
- import { Helpers, myth, Str, veeRules } from '../utils'
14
+ import { Helpers, type MythType, Str, veeRules } from '../utils'
15
15
  import type { MDtColumn, MDtHeadersParameter, ParseHeaderOptions, Vue3MAlertMessage, Vue3MAlertMessageOptions, Vue3MConfirmMessage } from '../types'
16
- import { computed } from 'vue'
16
+ import { computed, inject } from 'vue'
17
+ import { MythKey } from '../utils/const'
17
18
 
18
19
  export const useMyth = () => {
20
+ const plugin = inject(MythKey) as MythType
19
21
  const { t, te } = useI18n({ useScope: 'global' })
20
- const { props: pluginOptions } = myth
22
+ const pluginOptions = computed(() => plugin.props.value)
21
23
  const q = useQuasar()
22
24
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
25
  // @ts-ignore
@@ -281,20 +283,8 @@ export const useMyth = () => {
281
283
  ...opts as any
282
284
  })
283
285
  }
284
- const api = computed(() => myth.api.value)
285
- const baseUrl = computed(() => myth.baseUrl.value)
286
- const mAxios = computed(() => myth.mAxios.value)
287
- const mOptions = computed(() => myth.props.value)
288
286
  const isSmall = computed(() => q.screen.lt.md)
289
- const themeInput = computed(() => myth.themeInput.value)
290
- const themeBtn = computed(() => myth.themeBtn.value)
291
287
  return {
292
- api,
293
- baseUrl,
294
- mAxios,
295
- mOptions,
296
- themeInput,
297
- themeBtn,
298
288
  __,
299
289
  getPageTitle,
300
290
  parseHeaders,
@@ -307,6 +297,7 @@ export const useMyth = () => {
307
297
  ...Helpers,
308
298
  ...Str,
309
299
  veeRules,
310
- isSmall
300
+ isSmall,
301
+ ...plugin
311
302
  }
312
303
  }
@@ -14,6 +14,7 @@ import type {
14
14
  QBtnSlots,
15
15
  QCheckboxProps,
16
16
  QDateProps,
17
+ QDialogProps,
17
18
  QEditorProps,
18
19
  QEditorSlots,
19
20
  QFieldSlots,
@@ -23,15 +24,17 @@ import type {
23
24
  QInputProps,
24
25
  QInputSlots,
25
26
  QItemProps,
27
+ QMenuProps,
26
28
  QOptionGroupProps,
27
29
  QOptionGroupSlots,
30
+ QPopupProxyProps,
28
31
  QRadioProps,
29
32
  QSelectProps,
30
33
  QTimeProps,
31
34
  QToggleProps,
35
+ QTooltipProps,
32
36
  QUploaderProps,
33
37
  QUploaderSlots
34
- , QDialogProps, QMenuProps, QPopupProxyProps, QTooltipProps
35
38
  } from 'quasar'
36
39
  import type {
37
40
  ComputedRef,
@@ -73,7 +76,7 @@ export interface MTransitionsSlots {
73
76
  }
74
77
 
75
78
  export interface MBtnProps extends QBtnProps {
76
- //
79
+ native?: boolean;
77
80
  }
78
81
 
79
82
  export interface MBtnSlots extends QBtnSlots {
@@ -6,16 +6,13 @@
6
6
  * Github: https://github.com/mythpe
7
7
  */
8
8
 
9
- import type { myth } from '../utils'
10
-
11
- export type MythContext = typeof myth;
12
-
13
9
  export * from './api-helpers'
14
10
  export * from './components'
15
11
  export * from './install-options'
16
12
  export * from './lodash'
17
13
  export * from './m-datatable'
18
14
  export * from './m-geolocation'
15
+ export * from './myth-api'
19
16
  export * from './plugin-props-option'
20
17
  export * from './m-helpers'
21
18
  export * from './quasar-helpers'
@@ -1,20 +1,30 @@
1
- import type { ThemeBtn, ThemeFluid, ThemeInput, ThemeRounded, ThemeShadow, ThemeSize } from './theme'
2
- import type { BtnLoading, PropsContext } from './plugin-props-option'
1
+ import type { ButtonLoadingOptions, Theme, ThemeBtn, ThemeContext, ThemeFluid, ThemeInput, ThemeRounded, ThemeShadow, ThemeSize } from './theme'
2
+ import type { MythComponentsProps } from './plugin-props-option'
3
3
  import type { HelpersStubSchema } from './api-helpers'
4
4
  import type { AxiosInstance } from 'axios'
5
+ import type { ApiContext, MythApi } from './myth-api'
5
6
 
6
- export interface InstallOptions {
7
+ export interface InstallOptions2 {
7
8
  asyncComponents?: boolean | undefined;
9
+ theme?: Theme;
8
10
  size?: ThemeSize;
9
11
  rounded?: ThemeRounded;
10
12
  shadow?: ThemeShadow;
11
13
  fluid?: ThemeFluid;
12
14
  rules?: string[];
13
- btnLoading?: BtnLoading;
14
- props?: PropsContext;
15
+ btnLoading?: ButtonLoadingOptions;
16
+ props?: MythComponentsProps;
15
17
  themeInput?: ThemeInput;
16
18
  themeBtn?: ThemeBtn;
17
19
  baseUrl?: string;
18
20
  api?: HelpersStubSchema;
19
21
  mAxios?: AxiosInstance;
20
22
  }
23
+
24
+ export interface InstallOptions extends MythApi {
25
+ api: ApiContext;
26
+ asyncComponents?: boolean;
27
+ props?: Partial<MythComponentsProps>;
28
+ theme?: Partial<ThemeContext>;
29
+ rules?: string[];
30
+ }
@@ -0,0 +1,36 @@
1
+ import type { AxiosInstance } from 'axios'
2
+ import type { HelpersStubSchema } from './api-helpers'
3
+ import type { ThemeContext } from './theme'
4
+ import type { MythComponentsProps } from './plugin-props-option'
5
+
6
+ export interface ApiContext {
7
+ url: string;
8
+ services: HelpersStubSchema;
9
+ axios: AxiosInstance;
10
+ }
11
+
12
+ /**
13
+ * Main useMyth API.
14
+ */
15
+ export interface MythApi {
16
+ /**
17
+ * Define how the components should be loaded.
18
+ */
19
+ asyncComponents: boolean;
20
+ /**
21
+ * Api Object.
22
+ */
23
+ api: ApiContext;
24
+ /**
25
+ * Theme Object.
26
+ */
27
+ theme: ThemeContext;
28
+ /**
29
+ * Components Props.
30
+ */
31
+ props: MythComponentsProps;
32
+ /**
33
+ * Add custom rules of vee-validate.
34
+ */
35
+ rules: string[];
36
+ }
@@ -45,7 +45,7 @@ import type {
45
45
  } from 'quasar'
46
46
  import type { MDatatableProps, MDtBtnProps } from './m-datatable'
47
47
 
48
- export interface PropsContext {
48
+ export interface MythComponentsProps {
49
49
  // Grid.
50
50
  /**
51
51
  * MBlock component.
@@ -299,13 +299,3 @@ export interface PropsContext {
299
299
  };
300
300
  };
301
301
  }
302
-
303
- /**
304
- * Default loading q-btn loading slot.
305
- */
306
- export type BtnLoading = {
307
- type: 'audio' | 'ball' | 'bars' | 'box' | 'clock' | 'comment' | 'cube' | 'dots' | 'facebook' | 'gears' | 'grid' | 'hearts' | 'hourglass' | 'infinity' | 'ios' | 'orbit' | 'oval' | 'pie' | 'puff' | 'radio' | 'rings' | 'tail' | 'spinner';
308
- color?: string | undefined;
309
- size?: string | undefined;
310
- noLabel?: boolean;
311
- }
@@ -39,3 +39,50 @@ export type ThemeBtn = Partial<Pick<QBtnProps, 'flat'
39
39
  | 'color'
40
40
  | 'textColor'
41
41
  >>
42
+
43
+ export type Theme = {
44
+ size: ThemeSize;
45
+ rounded: ThemeRounded;
46
+ shadow: ThemeShadow;
47
+ fluid: ThemeFluid;
48
+ button: ThemeBtn;
49
+ input: ThemeInput;
50
+ };
51
+
52
+ export type ButtonLoadingOptions = {
53
+ type: 'audio' | 'ball' | 'bars' | 'box' | 'clock' | 'comment' | 'cube' | 'dots' | 'facebook' | 'gears' | 'grid' | 'hearts' | 'hourglass' | 'infinity' | 'ios' | 'orbit' | 'oval' | 'pie' | 'puff' | 'radio' | 'rings' | 'tail' | 'spinner';
54
+ color?: string | undefined;
55
+ size?: string | undefined;
56
+ noLabel?: boolean;
57
+ }
58
+
59
+ export interface ThemeContext {
60
+ /**
61
+ * Default size of theme.
62
+ */
63
+ size: ThemeSize;
64
+ /**
65
+ * Theme rounded.
66
+ */
67
+ rounded: ThemeRounded;
68
+ /**
69
+ * Theme shadow.
70
+ */
71
+ shadow: ThemeShadow;
72
+ /**
73
+ * Theme fluid.
74
+ */
75
+ fluid: ThemeFluid;
76
+ /**
77
+ * Default buttons style.
78
+ */
79
+ buttons: ThemeBtn;
80
+ /**
81
+ * Default inputs style.
82
+ */
83
+ inputs: ThemeInput;
84
+ /**
85
+ * Default of loading slot of q-btn.
86
+ */
87
+ buttonLoading: ButtonLoadingOptions | false;
88
+ }
@@ -0,0 +1 @@
1
+ export const MythKey = 'MyThKey'
@@ -0,0 +1,42 @@
1
+ import type { InstallOptions, MythApi } from '../types'
2
+ import { reactive, toRefs } from 'vue'
3
+ import type { AxiosInstance } from 'axios'
4
+ import { extend } from 'quasar'
5
+
6
+ export const createMyth = (options: InstallOptions) => {
7
+ const defaultOptions: MythApi = {
8
+ asyncComponents: !1,
9
+ api: {
10
+ url: '',
11
+ services: {},
12
+ axios: {} as AxiosInstance
13
+ },
14
+ props: {},
15
+ rules: [],
16
+ theme: {
17
+ size: 'md',
18
+ rounded: !0,
19
+ shadow: 2,
20
+ fluid: !0,
21
+ buttons: {},
22
+ inputs: {},
23
+ buttonLoading: {
24
+ type: 'spinner',
25
+ color: undefined,
26
+ size: undefined
27
+ } as MythApi['theme']['buttonLoading']
28
+ }
29
+ } as MythApi
30
+ const opts = reactive<MythApi>(extend<MythApi>(!0, { ...defaultOptions }, options))
31
+ const functions = {
32
+ btnStyle (value: MythApi['theme']['buttons']) {
33
+ opts.theme.buttons = value
34
+ }
35
+ }
36
+
37
+ return {
38
+ ...toRefs(opts),
39
+ ...functions
40
+ }
41
+ }
42
+ export type MythType = ReturnType<typeof createMyth>
@@ -6,8 +6,9 @@
6
6
  * Github: https://github.com/mythpe
7
7
  */
8
8
 
9
- export * from './myth'
10
- export * from './Str'
9
+ export * from './const'
10
+ export * from './createMyth'
11
11
  export * from './Helpers'
12
+ export * from './Str'
12
13
  export * from './vee-rules'
13
14
  export * from './vue-plugin'
@@ -10,12 +10,16 @@ import type { App } from 'vue'
10
10
  import { name, version } from '../../package.json'
11
11
 
12
12
  import type { InstallOptions } from '../types'
13
- import { defineOptions } from '../plugin/defineOptions'
14
13
  import { defineAsyncComponents } from '../plugin/defineAsyncComponents'
15
14
  import { defineComponents } from '../plugin/defineComponents'
16
15
 
17
- function install (app: App, options: InstallOptions = {}) {
18
- defineOptions(options)
16
+ import { createMyth } from './createMyth'
17
+ import { MythKey } from './const'
18
+
19
+ function install (app: App, options: InstallOptions) {
20
+ const myth = createMyth(options)
21
+ app.provide(MythKey, myth)
22
+ // defineOptions(options)
19
23
  if (options?.asyncComponents) {
20
24
  defineAsyncComponents(app)
21
25
  } else {
@@ -1,38 +0,0 @@
1
- import { myth } from '../utils'
2
- import type { InstallOptions } from '../types'
3
-
4
- export const defineOptions = (options: InstallOptions) => {
5
- if (options.rounded !== undefined) {
6
- myth.rounded.value = options.rounded
7
- }
8
- if (options.shadow !== undefined) {
9
- myth.shadow.value = options.shadow
10
- }
11
- if (options.fluid !== undefined) {
12
- myth.setFluid(options.fluid)
13
- }
14
- if (options.size !== undefined) {
15
- myth.setSize(options.size)
16
- }
17
- if (options.props !== undefined) {
18
- myth.withProps(options.props)
19
- }
20
- if (options.rules !== undefined) {
21
- myth.withRules(options.rules)
22
- }
23
- if (options.themeBtn !== undefined) {
24
- myth.themeBtn.value = options.themeBtn
25
- }
26
- if (options.themeInput !== undefined) {
27
- myth.setThemeInput(options.themeInput)
28
- }
29
- if (options.baseUrl !== undefined) {
30
- myth.baseUrl.value = options.baseUrl
31
- }
32
- if (options.api !== undefined) {
33
- myth.setApi(options.api)
34
- }
35
- if (options.mAxios !== undefined) {
36
- myth.mAxios.value = options.mAxios
37
- }
38
- }