@teammodlr/ui-kit 2.1.8 → 2.1.10

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 (159) hide show
  1. package/lib/components/avatargroup/symbol.d.ts +2 -2
  2. package/lib/components/breadcrumb/style/index.d.ts +1 -1
  3. package/lib/components/breadcrumb/symbol.d.ts +1 -1
  4. package/lib/components/buttongroup/symbol.d.ts +2 -2
  5. package/lib/components/colorpicker/ColorPicker.vue.d.ts +1 -1
  6. package/lib/components/dropdown/Dropdown.vue.d.ts +1 -1
  7. package/lib/components/dropdown/symbol.d.ts +1 -1
  8. package/lib/components/form/symbol.d.ts +1 -1
  9. package/lib/components/messageprovider/style/index.d.ts +1 -1
  10. package/lib/components/modal/Modal.vue.d.ts +6 -3
  11. package/lib/components/modal/style/Modal.css.d.ts +3 -0
  12. package/lib/components/radiobuttongroup/symbol.d.ts +2 -2
  13. package/lib/components/tooltip/Tooltip.vue.d.ts +1 -1
  14. package/lib/components/tree/props.d.ts +4 -4
  15. package/lib/components/tree/types.d.ts +10 -10
  16. package/lib/composables/element.d.ts +1 -1
  17. package/lib/composables/useInteractive.d.ts +1 -1
  18. package/lib/composables/useMount.d.ts +1 -1
  19. package/lib/composables/usePopper.d.ts +2 -2
  20. package/lib/composables/useZIndex.d.ts +1 -1
  21. package/lib/index.cjs.js +9 -9
  22. package/lib/index.es.js +2256 -2213
  23. package/lib/install.d.ts +1 -1
  24. package/lib/nuxt.js +17 -15
  25. package/lib/nuxt.plugin.js +6 -6
  26. package/lib/style.css +1 -1
  27. package/package.json +89 -79
  28. package/src/__storybook__/argTypes.ts +5 -13
  29. package/src/__storybook__/createStory.ts +10 -10
  30. package/src/call.ts +14 -14
  31. package/src/components/avatar/Avatar.vue +1 -1
  32. package/src/components/avatar/examples/index.stories.ts +4 -7
  33. package/src/components/avatar/style/Avatar.css.ts +17 -17
  34. package/src/components/avatargroup/examples/index.stories.ts +5 -10
  35. package/src/components/avatargroup/style/AvatarGroup.css.ts +9 -4
  36. package/src/components/avatargroup/symbol.ts +5 -5
  37. package/src/components/badge/examples/index.stories.ts +4 -6
  38. package/src/components/badge/style/Badge.css.ts +36 -36
  39. package/src/components/breadcrumb/examples/index.stories.ts +6 -10
  40. package/src/components/breadcrumb/style/Breadcrumb.css.ts +17 -17
  41. package/src/components/breadcrumb/style/index.ts +1 -1
  42. package/src/components/breadcrumb/symbol.ts +4 -3
  43. package/src/components/button/examples/index.stories.ts +4 -4
  44. package/src/components/button/style/Button.css.ts +143 -133
  45. package/src/components/buttongroup/examples/index.stories.ts +6 -12
  46. package/src/components/buttongroup/style/ButtonGroup.css.ts +13 -11
  47. package/src/components/buttongroup/symbol.ts +5 -4
  48. package/src/components/checkbox/Checkbox.vue +8 -8
  49. package/src/components/checkbox/examples/index.stories.ts +4 -9
  50. package/src/components/checkbox/examples/index.ts +0 -1
  51. package/src/components/checkbox/style/Checkbox.css.ts +31 -27
  52. package/src/components/checkbox/style/index.ts +1 -1
  53. package/src/components/colorpicker/examples/index.stories.ts +5 -10
  54. package/src/components/colorpicker/examples/index.ts +1 -1
  55. package/src/components/colorpicker/style/ColorPicker.css.ts +22 -14
  56. package/src/components/colorpicker/utils.ts +46 -28
  57. package/src/components/confirm/examples/index.stories.ts +5 -8
  58. package/src/components/confirm/props.ts +2 -2
  59. package/src/components/confirm/providerProps.ts +1 -2
  60. package/src/components/confirm/types.ts +15 -16
  61. package/src/components/confirm/useConfirm.ts +3 -1
  62. package/src/components/dialog/examples/index.stories.ts +5 -9
  63. package/src/components/dialog/style/Dialog.css.ts +38 -37
  64. package/src/components/dropdown/examples/index.stories.ts +3 -7
  65. package/src/components/dropdown/hooks.ts +20 -20
  66. package/src/components/dropdown/style/Dropdown.css.ts +24 -24
  67. package/src/components/dropdown/symbol.ts +3 -2
  68. package/src/components/form/Form.vue +1 -1
  69. package/src/components/form/examples/index.stories.ts +2 -4
  70. package/src/components/form/style/Form.css.ts +13 -8
  71. package/src/components/form/style/index.ts +2 -2
  72. package/src/components/form/symbol.ts +10 -5
  73. package/src/components/image/examples/index.stories.ts +5 -7
  74. package/src/components/input/Input.vue +8 -9
  75. package/src/components/input/examples/index.stories.ts +5 -7
  76. package/src/components/input/style/Input.css.ts +40 -43
  77. package/src/components/link/examples/index.stories.ts +4 -9
  78. package/src/components/messageprovider/examples/index.stories.ts +5 -8
  79. package/src/components/messageprovider/style/Message.css.ts +31 -31
  80. package/src/components/messageprovider/style/index.ts +1 -1
  81. package/src/components/messageprovider/types.ts +31 -22
  82. package/src/components/messageprovider/useMessage.ts +6 -4
  83. package/src/components/modal/Modal.vue +72 -54
  84. package/src/components/modal/examples/index.stories.ts +6 -10
  85. package/src/components/modal/examples/index.ts +1 -0
  86. package/src/components/modal/examples/sidebar.vue +75 -0
  87. package/src/components/modal/style/Modal.css.ts +91 -72
  88. package/src/components/pagination/examples/index.stories.ts +5 -9
  89. package/src/components/pagination/examples/index.ts +1 -1
  90. package/src/components/pagination/style/Pagination.css.ts +41 -37
  91. package/src/components/radio/Radio.vue +7 -7
  92. package/src/components/radio/examples/index.stories.ts +4 -9
  93. package/src/components/radio/examples/index.ts +0 -1
  94. package/src/components/radio/style/Checkbox.css.ts +30 -31
  95. package/src/components/radio/style/index.ts +1 -1
  96. package/src/components/radiobutton/RadioButton.vue +3 -3
  97. package/src/components/radiobutton/style/RadioButton.css.ts +41 -36
  98. package/src/components/radiobuttongroup/examples/index.stories.ts +6 -10
  99. package/src/components/radiobuttongroup/examples/index.ts +0 -1
  100. package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +14 -14
  101. package/src/components/radiobuttongroup/style/index.ts +1 -1
  102. package/src/components/radiobuttongroup/symbol.ts +8 -7
  103. package/src/components/renderer/examlpes/index.stories.ts +4 -8
  104. package/src/components/renderer/props.ts +2 -3
  105. package/src/components/renderer/renderer.ts +3 -3
  106. package/src/components/select/Select.vue +3 -4
  107. package/src/components/select/examples/index.stories.ts +4 -10
  108. package/src/components/select/style/Select.css.ts +62 -61
  109. package/src/components/skeleton/examples/index.stories.ts +5 -9
  110. package/src/components/skeleton/style/Skeleton.css.ts +16 -16
  111. package/src/components/skeleton/style/index.ts +2 -2
  112. package/src/components/slider/style/Slider.css.ts +12 -5
  113. package/src/components/switch/Switch.vue +4 -4
  114. package/src/components/switch/examples/index.stories.ts +4 -9
  115. package/src/components/switch/examples/index.ts +0 -1
  116. package/src/components/switch/style/Switch.css.ts +56 -57
  117. package/src/components/switch/style/index.ts +1 -1
  118. package/src/components/tab/examples/index.stories.ts +5 -11
  119. package/src/components/table/examples/index.stories.ts +6 -12
  120. package/src/components/table/style/Table.css.ts +22 -17
  121. package/src/components/table/style/index.ts +1 -1
  122. package/src/components/table/types/index.ts +1 -1
  123. package/src/components/tag/examples/index.stories.ts +4 -10
  124. package/src/components/tag/style/Tag.css.ts +14 -9
  125. package/src/components/textarea/Textarea.vue +7 -8
  126. package/src/components/textarea/examples/index.stories.ts +4 -8
  127. package/src/components/textarea/style/Textarea.css.ts +33 -33
  128. package/src/components/tooltip/examples/index.stories.ts +5 -10
  129. package/src/components/tooltip/examples/index.ts +2 -2
  130. package/src/components/tooltip/style/Tooltip.css.ts +24 -25
  131. package/src/components/transfer/examples/index.stories.ts +5 -9
  132. package/src/components/transfer/style/Transfer.css.ts +41 -40
  133. package/src/components/tree/examples/index.stories.ts +6 -10
  134. package/src/components/tree/props.ts +20 -18
  135. package/src/components/tree/style/Tree.css.ts +36 -31
  136. package/src/components/tree/types.ts +60 -62
  137. package/src/components/virtualscroll/examples/index.stories.ts +4 -8
  138. package/src/components/virtualscroll/style/VirtualScroll.css.ts +1 -2
  139. package/src/composables/element.ts +4 -4
  140. package/src/composables/useCachedUid.ts +7 -6
  141. package/src/composables/useEventListener.ts +11 -6
  142. package/src/composables/useInput.ts +63 -41
  143. package/src/composables/useInteractive.ts +10 -11
  144. package/src/composables/useMergedState.ts +7 -7
  145. package/src/composables/useMount.ts +11 -11
  146. package/src/composables/usePopper.ts +57 -36
  147. package/src/composables/useZIndex.ts +5 -5
  148. package/src/create.ts +10 -6
  149. package/src/examples/cards/cards.stories.ts +3 -3
  150. package/src/examples/modal/modal.stories.ts +3 -3
  151. package/src/exports/nuxt.js +17 -15
  152. package/src/exports/nuxt.plugin.js +6 -6
  153. package/src/index.ts +0 -2
  154. package/src/install.ts +5 -5
  155. package/src/shims-vue.d.ts +3 -3
  156. package/src/styles/theme.css.ts +51 -43
  157. package/src/styles/transitions.css.ts +26 -28
  158. package/src/types/props.ts +16 -2
  159. package/src/utils/injection.ts +3 -3
@@ -1,64 +1,69 @@
1
- import {createVar, globalKeyframes, globalStyle, style, styleVariants} from "@vanilla-extract/css";
2
- import {themeVars} from "../../../styles/theme.css";
3
-
1
+ import {
2
+ createVar,
3
+ globalKeyframes,
4
+ globalStyle,
5
+ style,
6
+ styleVariants
7
+ } from '@vanilla-extract/css';
8
+ import { themeVars } from '../../../styles/theme.css';
4
9
 
5
10
  export const toggle = style({
6
- cursor: "pointer",
7
- display: "inline-flex",
11
+ cursor: 'pointer',
12
+ display: 'inline-flex',
8
13
  flexShrink: 0,
9
14
  height: `24px`,
10
15
  width: `24px`,
11
- alignItems: "center",
12
- justifyContent: "center",
13
- verticalAlign: "bottom",
16
+ alignItems: 'center',
17
+ justifyContent: 'center',
18
+ verticalAlign: 'bottom',
14
19
  transition: `transform .15s ${themeVars.transition.default}`
15
- })
20
+ });
16
21
  export const icon = style({
17
- position: "relative",
22
+ position: 'relative',
18
23
  height: `14px`,
19
24
  width: `14px`,
20
- display: "flex",
25
+ display: 'flex',
21
26
  fontSize: `14px`,
22
- fill: "currentColor",
23
- color: themeVars.color.gray["600"],
27
+ fill: 'currentColor',
28
+ color: themeVars.color.gray['600']
24
29
  });
25
30
 
26
31
  export const iconRotate = styleVariants({
27
32
  90: {
28
- transform: `rotate(90deg)`,
33
+ transform: `rotate(90deg)`
29
34
  }
30
35
  });
31
36
 
32
37
  export const nodeWrapper = style({
33
- boxSizing: "border-box",
34
- padding: `${themeVars.space["0.5"]} 0`,
35
- })
38
+ boxSizing: 'border-box',
39
+ padding: `${themeVars.space['0.5']} 0`
40
+ });
36
41
 
37
42
  export const node = style({
38
43
  transform: `translate3d(0, 0, 0)`,
39
- position: "relative",
40
- display: "flex",
44
+ position: 'relative',
45
+ display: 'flex',
41
46
  borderRadius: themeVars.rounded.small,
42
47
  transition: `background-color .3s ${themeVars.transition.default}`,
43
48
  selectors: {
44
49
  [`&:hover`]: {
45
- backgroundColor: themeVars.color.gray["150"]
50
+ backgroundColor: themeVars.color.gray['150']
46
51
  }
47
52
  }
48
- })
53
+ });
49
54
 
50
55
  export const nodeContent = style({
51
- cursor: "pointer",
52
- position: "relative",
53
- display: "inline-flex",
54
- alignItems: "center",
56
+ cursor: 'pointer',
57
+ position: 'relative',
58
+ display: 'inline-flex',
59
+ alignItems: 'center',
55
60
  minHeight: `24px`,
56
- boxSizing: "border-box",
57
- verticalAlign: "bottom",
58
- padding: `0 ${themeVars.space["1"]} 0 ${themeVars.space["1"]}`,
61
+ boxSizing: 'border-box',
62
+ verticalAlign: 'bottom',
63
+ padding: `0 ${themeVars.space['1']} 0 ${themeVars.space['1']}`,
59
64
  borderRadius: themeVars.rounded.default,
60
65
  lineHeight: 1.5,
61
- userSelect: "none",
66
+ userSelect: 'none',
62
67
  flexGrow: 1
63
68
  });
64
69
 
@@ -66,5 +71,5 @@ export const nodeContentText = style({
66
71
  flexGrow: 1,
67
72
  maxWidth: `100%`,
68
73
  fontSize: themeVars.fontSize.base,
69
- color: themeVars.color.gray["700"],
70
- })
74
+ color: themeVars.color.gray['700']
75
+ });
@@ -1,105 +1,103 @@
1
- import type {HTMLAttributes, Ref, InjectionKey} from "vue";
2
- import type {TreeNode} from "treemate";
3
- import {createInjectionKey} from "../../utils/injection";
1
+ import type { HTMLAttributes, Ref, InjectionKey } from 'vue';
2
+ import type { TreeNode } from 'treemate';
3
+ import { createInjectionKey } from '../../utils/injection';
4
4
 
5
- export type Key = string | number
5
+ export type Key = string | number;
6
6
 
7
7
  export interface TreeOptionBase {
8
- key?: Key,
9
- label?: string,
10
- children?: TreeOption[]
8
+ key?: Key;
9
+ label?: string;
10
+ children?: TreeOption[];
11
11
  }
12
12
 
13
13
  export type TreeOption = TreeOptionBase & Record<string, unknown>;
14
14
  export type TreeOptions = TreeOption[];
15
15
 
16
16
  export type TreeNodeProps = (
17
- node: TreeOption,
17
+ node: TreeOption
18
18
  ) => HTMLAttributes & Record<string, unknown>;
19
19
 
20
- export type TreeNodeDoubleClick = (info: {
21
- option: TreeOption,
22
- }) => void;
20
+ export type TreeNodeDoubleClick = (info: { option: TreeOption }) => void;
23
21
 
24
22
  export interface TreeInjection {
25
- mergedExpandedKeysRef: Ref<Key[]>,
26
- indentRef: Ref<number>,
27
- expandOnClickRef: Ref<boolean>,
28
- nodePropsRef: Ref<TreeNodeProps | undefined>,
29
- labelFieldRef: Ref<string>,
30
- keyFieldRef: Ref<string>,
31
- childrenFieldRef: Ref<string>,
32
- handleToggleClick: (node: TreeNode<TreeOption>) => void,
33
- handleDoubleClick: (node: TreeOption) => void,
23
+ mergedExpandedKeysRef: Ref<Key[]>;
24
+ indentRef: Ref<number>;
25
+ expandOnClickRef: Ref<boolean>;
26
+ nodePropsRef: Ref<TreeNodeProps | undefined>;
27
+ labelFieldRef: Ref<string>;
28
+ keyFieldRef: Ref<string>;
29
+ childrenFieldRef: Ref<string>;
30
+ handleToggleClick: (node: TreeNode<TreeOption>) => void;
31
+ handleDoubleClick: (node: TreeOption) => void;
34
32
  }
35
33
 
36
- export const treeInjectionKey = createInjectionKey<TreeInjection>('tree')
34
+ export const treeInjectionKey = createInjectionKey<TreeInjection>('tree');
37
35
 
38
- export type TmNode = TreeNode<TreeOption>
36
+ export type TmNode = TreeNode<TreeOption>;
39
37
 
40
38
  export type OnUpdateCheckedKeys = (
41
- value: Array<string & number>,
42
- option: Array<TreeOption | null>,
39
+ value: (string & number)[],
40
+ option: (TreeOption | null)[],
43
41
  meta: {
44
- node: TreeOption | null
45
- action: 'check' | 'uncheck'
42
+ node: TreeOption | null;
43
+ action: 'check' | 'uncheck';
46
44
  }
47
- ) => void
45
+ ) => void;
48
46
  export type OnUpdateCheckedKeysImpl = (
49
47
  value: Key[],
50
- option: Array<TreeOption | null>,
48
+ option: (TreeOption | null)[],
51
49
  meta: {
52
- node: TreeOption | null
53
- action: 'check' | 'uncheck'
50
+ node: TreeOption | null;
51
+ action: 'check' | 'uncheck';
54
52
  }
55
- ) => void
53
+ ) => void;
56
54
  export type OnUpdateIndeterminateKeys = (
57
- value: Array<string & number>,
58
- option: Array<TreeOption | null>
59
- ) => void
55
+ value: (string & number)[],
56
+ option: (TreeOption | null)[]
57
+ ) => void;
60
58
  export type OnUpdateIndeterminateKeysImpl = (
61
59
  value: Key[],
62
- option: Array<TreeOption | null>
63
- ) => void
60
+ option: (TreeOption | null)[]
61
+ ) => void;
64
62
  export type OnUpdateSelectedKeys = (
65
- value: Array<string & number>,
66
- option: Array<TreeOption | null>,
63
+ value: (string & number)[],
64
+ option: (TreeOption | null)[],
67
65
  meta: {
68
- node: TreeOption | null
69
- action: 'select' | 'unselect'
66
+ node: TreeOption | null;
67
+ action: 'select' | 'unselect';
70
68
  }
71
- ) => void
69
+ ) => void;
72
70
  export type OnUpdateSelectedKeysImpl = (
73
71
  value: Key[],
74
- option: Array<TreeOption | null>,
72
+ option: (TreeOption | null)[],
75
73
  meta: {
76
- node: TreeOption | null
77
- action: 'select' | 'unselect'
74
+ node: TreeOption | null;
75
+ action: 'select' | 'unselect';
78
76
  }
79
- ) => void
77
+ ) => void;
80
78
  export type onUpdateExpandedKeys = (
81
- value: Array<string & number>,
82
- option: Array<TreeOption | null>,
79
+ value: (string & number)[],
80
+ option: (TreeOption | null)[],
83
81
  meta:
84
82
  | {
85
- node: TreeOption
86
- action: 'expand' | 'collapse'
87
- }
83
+ node: TreeOption;
84
+ action: 'expand' | 'collapse';
85
+ }
88
86
  | {
89
- node: null
90
- action: 'filter'
91
- }
92
- ) => void
87
+ node: null;
88
+ action: 'filter';
89
+ }
90
+ ) => void;
93
91
  export type OnUpdateExpandedKeysImpl = (
94
92
  value: Key[],
95
- option: Array<TreeOption | null>,
93
+ option: (TreeOption | null)[],
96
94
  meta:
97
95
  | {
98
- node: TreeOption
99
- action: 'expand' | 'collapse'
100
- }
96
+ node: TreeOption;
97
+ action: 'expand' | 'collapse';
98
+ }
101
99
  | {
102
- node: null
103
- action: 'filter'
104
- }
105
- ) => void
100
+ node: null;
101
+ action: 'filter';
102
+ }
103
+ ) => void;
@@ -1,15 +1,11 @@
1
- import MVirtualScroll from "../VirtualScroll.vue";
2
- import {
3
- MVirtualScrollBasic
4
- } from "./index";
1
+ import MVirtualScroll from '../VirtualScroll.vue';
2
+ import { MVirtualScrollBasic } from './index';
5
3
 
6
- import {
7
- createStory
8
- } from "../../../__storybook__";
4
+ import { createStory } from '../../../__storybook__';
9
5
 
10
6
  export default {
11
7
  component: MVirtualScroll,
12
8
  title: 'Components/VirtualScroll'
13
- }
9
+ };
14
10
 
15
11
  export const Basic = createStory(MVirtualScrollBasic);
@@ -1,4 +1,4 @@
1
- import {globalStyle, style} from '@vanilla-extract/css';
1
+ import { globalStyle, style } from '@vanilla-extract/css';
2
2
 
3
3
  export const container = style({
4
4
  overflow: 'auto',
@@ -15,4 +15,3 @@ globalStyle(`${container} > div > div`, {
15
15
  willChange: 'transform',
16
16
  backfaceVisibility: 'hidden'
17
17
  });
18
-
@@ -1,13 +1,13 @@
1
- import type { Ref } from "vue";
1
+ import type { Ref } from 'vue';
2
2
 
3
3
  export function getElement(ref: Ref) {
4
- if(ref === null) {
4
+ if (ref === null) {
5
5
  return null;
6
6
  }
7
7
 
8
- if(ref.value === null) {
8
+ if (ref.value === null) {
9
9
  return null;
10
10
  }
11
11
 
12
- return "$el" in ref.value ? ref.value.$el : ref.value;
12
+ return '$el' in ref.value ? ref.value.$el : ref.value;
13
13
  }
@@ -8,8 +8,9 @@ const UID_CACHE_ATTR = 'data-modlr-ssr-uid';
8
8
  // @ts-nocheck
9
9
  type CacheElement = HTMLElement | SVGElement | ComponentPublicInstance | null;
10
10
 
11
- export function uid(prefix: string = ''): string {
12
- const id = Date.now().toString(36) + Math.random().toString(36).substring(2);
11
+ export function uid(prefix = ''): string {
12
+ const id =
13
+ Date.now().toString(36) + Math.random().toString(36).substring(2);
13
14
  return prefix ? `${prefix}-${id}` : id;
14
15
  }
15
16
 
@@ -22,15 +23,15 @@ export interface IUseCacheUid {
22
23
  }
23
24
 
24
25
  export function useCachedUid(prefix?: string): IUseCacheUid {
25
- let id = ref(uid(prefix));
26
+ const id = ref(uid(prefix));
26
27
  const cacheElement = ref<CacheElement>(null);
27
28
 
28
29
  onMounted(() => {
29
- if(cacheElement.value) {
30
+ if (cacheElement.value) {
30
31
  const element = getElement(cacheElement);
31
32
  const serverId = element?.getAttribute(UID_CACHE_ATTR);
32
33
 
33
- if(serverId) {
34
+ if (serverId) {
34
35
  id.value = serverId;
35
36
  }
36
37
 
@@ -44,5 +45,5 @@ export function useCachedUid(prefix?: string): IUseCacheUid {
44
45
  ref: cacheElement,
45
46
  [UID_CACHE_ATTR]: typeof window === undefined ? id.value : undefined
46
47
  }
47
- }
48
+ };
48
49
  }
@@ -1,14 +1,19 @@
1
- import { watchEffect } from "vue";
1
+ import { watchEffect } from 'vue';
2
2
 
3
- export function useEventListener<T extends EventTarget | HTMLElement, E extends EventListener>(element: T, type: string, listener: E, options: boolean) {
4
- if(typeof window === undefined) {
3
+ export function useEventListener<
4
+ T extends EventTarget | HTMLElement,
5
+ E extends EventListener
6
+ >(element: T, type: string, listener: E, options: boolean) {
7
+ if (typeof window === undefined) {
5
8
  return;
6
9
  }
7
10
 
8
- watchEffect((onInvalidate) => {
11
+ watchEffect(onInvalidate => {
9
12
  element = element ?? window;
10
13
 
11
14
  element.addEventListener(type, listener, options);
12
- onInvalidate(() => element.removeEventListener(type, listener, options));
13
- })
15
+ onInvalidate(() =>
16
+ element.removeEventListener(type, listener, options)
17
+ );
18
+ });
14
19
  }
@@ -2,7 +2,7 @@
2
2
  import type { PropType } from 'vue';
3
3
  import { ref, watch, inject, computed, onMounted, onUnmounted } from 'vue';
4
4
  import { useCachedUid } from './useCachedUid';
5
- import {FORM_STATE} from "../components/form/symbol";
5
+ import { FORM_STATE } from '../components/form/symbol';
6
6
 
7
7
  export interface FormInput {
8
8
  focus: () => void;
@@ -10,20 +10,33 @@ export interface FormInput {
10
10
  setError: (value: string) => void;
11
11
  }
12
12
 
13
- export const useInput = (props: any, { focus, emit, withListeners = true }: {
14
- focus: () => void,
15
- emit: any,
16
- withListeners?: boolean
17
- }) => {
13
+ export const useInput = (
14
+ props: any,
15
+ {
16
+ focus,
17
+ emit,
18
+ withListeners = true
19
+ }: {
20
+ focus: () => void;
21
+ emit: any;
22
+ withListeners?: boolean;
23
+ }
24
+ ) => {
18
25
  const isFirstValidation = ref(true);
19
26
  const formError = ref(props.error);
20
27
 
21
28
  const { id } = useCachedUid('input');
22
29
  const name = props.name ? props.name : id.value;
23
30
  const _name = ref(name);
24
-
25
- watch(() => props.error, (value) => formError.value = value);
26
- watch(() => props.name, (value) => name.value = value);
31
+
32
+ watch(
33
+ () => props.error,
34
+ value => (formError.value = value)
35
+ );
36
+ watch(
37
+ () => props.name,
38
+ value => (name.value = value)
39
+ );
27
40
 
28
41
  const form = inject(FORM_STATE, null);
29
42
 
@@ -33,7 +46,7 @@ export const useInput = (props: any, { focus, emit, withListeners = true }: {
33
46
  emit('update:modelValue', '');
34
47
  };
35
48
 
36
- const setError = (value: string) => {
49
+ const setError = (value: string) => {
37
50
  formError.value = value;
38
51
  };
39
52
 
@@ -49,7 +62,7 @@ export const useInput = (props: any, { focus, emit, withListeners = true }: {
49
62
 
50
63
  if (typeof item === 'function') {
51
64
  valid = item(value);
52
- } else if(Array.isArray(item) && item.length === 2) {
65
+ } else if (Array.isArray(item) && item.length === 2) {
53
66
  const { 0: rule, 1: options } = item;
54
67
  valid = rule(value, options);
55
68
  } else {
@@ -69,26 +82,32 @@ export const useInput = (props: any, { focus, emit, withListeners = true }: {
69
82
  return true;
70
83
  };
71
84
 
72
- const inputListeners = withListeners ? computed(() => {
73
- return {
74
- blur: (event: Event) => emit('blur', event),
75
- focus: (event: Event) => emit('focus', event),
76
- input: (event: Event) => {
77
- emit('update:modelValue', (event.target as HTMLInputElement).value);
78
- },
79
- change: (event: Event) => emit('change', event)
80
- }
81
- }) : {};
85
+ const inputListeners = withListeners
86
+ ? computed(() => {
87
+ return {
88
+ blur: (event: Event) => emit('blur', event),
89
+ focus: (event: Event) => emit('focus', event),
90
+ input: (event: Event) => {
91
+ emit(
92
+ 'update:modelValue',
93
+ (event.target as HTMLInputElement).value
94
+ );
95
+ },
96
+ change: (event: Event) => emit('change', event)
97
+ };
98
+ })
99
+ : {};
82
100
 
83
101
  onMounted(() => {
84
- form?.add(_name.value,
102
+ form?.add(
103
+ _name.value,
85
104
  focus,
86
105
  // @ts-ignore
87
106
  validate,
88
107
  // @ts-ignore
89
108
  setError
90
109
  );
91
- })
110
+ });
92
111
 
93
112
  onUnmounted(() => {
94
113
  form?.remove(_name.value);
@@ -106,24 +125,27 @@ export const useInput = (props: any, { focus, emit, withListeners = true }: {
106
125
  //@ts-ignore
107
126
  formDisabled: form?.disabled.value || false,
108
127
  //@ts-ignore
109
- formLoading: form?.loading.value || false,
110
- }
128
+ formLoading: form?.loading.value || false
129
+ };
111
130
  };
112
131
 
113
- useInput.emits = (withListeners: boolean = true): string[] => {
114
- return withListeners ?
115
- ['update:modelValue', 'blur', 'focus', 'input', 'change'] :
116
- ['update:modelValue'];
117
- }
132
+ useInput.emits = (withListeners = true): string[] => {
133
+ return withListeners
134
+ ? ['update:modelValue', 'blur', 'focus', 'input', 'change']
135
+ : ['update:modelValue'];
136
+ };
118
137
 
119
- useInput.props = () => ({
120
- modelValue: [String, Number, Boolean, Object, Array] as PropType<string | number | boolean | object | Array<any> | any[] | undefined>,
121
- name: String,
122
- readonly: Boolean,
123
- required: Boolean,
124
- error: String,
125
- rules: {
126
- type: Array,
127
- default: () => [],
128
- }
129
- } as const);
138
+ useInput.props = () =>
139
+ ({
140
+ modelValue: [String, Number, Boolean, Object, Array] as PropType<
141
+ string | number | boolean | object | any[] | any[] | undefined
142
+ >,
143
+ name: String,
144
+ readonly: Boolean,
145
+ required: Boolean,
146
+ error: String,
147
+ rules: {
148
+ type: Array,
149
+ default: () => []
150
+ }
151
+ }) as const;
@@ -1,20 +1,19 @@
1
- import type { Ref } from "vue";
1
+ import type { Ref } from 'vue';
2
2
 
3
3
  export interface InteractiveProps {
4
4
  disabled?: boolean;
5
5
  loading?: boolean;
6
6
  }
7
7
 
8
- export const useInteractive = (
9
- el: Ref<HTMLElement | null>,
10
- ) => {
8
+ export const useInteractive = (el: Ref<HTMLElement | null>) => {
11
9
  return {
12
10
  focus: () => el.value?.focus?.(),
13
- blur: () => el.value?.blur?.(),
14
- }
15
- }
11
+ blur: () => el.value?.blur?.()
12
+ };
13
+ };
16
14
 
17
- useInteractive.props = () => ({
18
- disabled: Boolean,
19
- loading: Boolean,
20
- } as const);
15
+ useInteractive.props = () =>
16
+ ({
17
+ disabled: Boolean,
18
+ loading: Boolean
19
+ }) as const;
@@ -1,18 +1,18 @@
1
- import { type Ref, watch, type ComputedRef, computed } from 'vue'
1
+ import { type Ref, watch, type ComputedRef, computed } from 'vue';
2
2
 
3
- export default function useMergedState<T> (
3
+ export default function useMergedState<T>(
4
4
  controlledStateRef: Ref<T | undefined>,
5
5
  uncontrolledStateRef: Ref<T>
6
6
  ): ComputedRef<T> {
7
7
  watch(controlledStateRef, value => {
8
8
  if (value !== undefined) {
9
- uncontrolledStateRef.value = value
9
+ uncontrolledStateRef.value = value;
10
10
  }
11
- })
11
+ });
12
12
  return computed(() => {
13
13
  if (controlledStateRef.value === undefined) {
14
- return uncontrolledStateRef.value
14
+ return uncontrolledStateRef.value;
15
15
  }
16
- return controlledStateRef.value
17
- })
16
+ return controlledStateRef.value;
17
+ });
18
18
  }
@@ -1,5 +1,5 @@
1
- import { createVNode, render } from "vue";
2
- import type { App, Component } from "vue";
1
+ import { createVNode, render } from 'vue';
2
+ import type { App, Component } from 'vue';
3
3
 
4
4
  export function mount(
5
5
  component: Component,
@@ -9,10 +9,10 @@ export function mount(
9
9
  element,
10
10
  app
11
11
  }: {
12
- props?: Record<string, unknown>,
13
- children?: unknown,
14
- app?: App,
15
- element?: HTMLElement
12
+ props?: Record<string, unknown>;
13
+ children?: unknown;
14
+ app?: App;
15
+ element?: HTMLElement;
16
16
  } = {}
17
17
  ) {
18
18
  let el = element;
@@ -25,19 +25,19 @@ export function mount(
25
25
 
26
26
  if (el) {
27
27
  render(vNode, el);
28
- } else if(typeof document !== 'undefined') {
29
- render(vNode, (el = document.createElement('div')))
28
+ } else if (typeof document !== 'undefined') {
29
+ render(vNode, (el = document.createElement('div')));
30
30
  }
31
31
 
32
32
  const destroy = () => {
33
33
  if (el) {
34
34
  render(null, el);
35
35
  }
36
- }
36
+ };
37
37
 
38
38
  return {
39
39
  el,
40
40
  vNode,
41
- destroy,
42
- }
41
+ destroy
42
+ };
43
43
  }