@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.
- package/lib/components/avatargroup/symbol.d.ts +2 -2
- package/lib/components/breadcrumb/style/index.d.ts +1 -1
- package/lib/components/breadcrumb/symbol.d.ts +1 -1
- package/lib/components/buttongroup/symbol.d.ts +2 -2
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +1 -1
- package/lib/components/dropdown/Dropdown.vue.d.ts +1 -1
- package/lib/components/dropdown/symbol.d.ts +1 -1
- package/lib/components/form/symbol.d.ts +1 -1
- package/lib/components/messageprovider/style/index.d.ts +1 -1
- package/lib/components/modal/Modal.vue.d.ts +6 -3
- package/lib/components/modal/style/Modal.css.d.ts +3 -0
- package/lib/components/radiobuttongroup/symbol.d.ts +2 -2
- package/lib/components/tooltip/Tooltip.vue.d.ts +1 -1
- package/lib/components/tree/props.d.ts +4 -4
- package/lib/components/tree/types.d.ts +10 -10
- package/lib/composables/element.d.ts +1 -1
- package/lib/composables/useInteractive.d.ts +1 -1
- package/lib/composables/useMount.d.ts +1 -1
- package/lib/composables/usePopper.d.ts +2 -2
- package/lib/composables/useZIndex.d.ts +1 -1
- package/lib/index.cjs.js +9 -9
- package/lib/index.es.js +2256 -2213
- package/lib/install.d.ts +1 -1
- package/lib/nuxt.js +17 -15
- package/lib/nuxt.plugin.js +6 -6
- package/lib/style.css +1 -1
- package/package.json +89 -79
- package/src/__storybook__/argTypes.ts +5 -13
- package/src/__storybook__/createStory.ts +10 -10
- package/src/call.ts +14 -14
- package/src/components/avatar/Avatar.vue +1 -1
- package/src/components/avatar/examples/index.stories.ts +4 -7
- package/src/components/avatar/style/Avatar.css.ts +17 -17
- package/src/components/avatargroup/examples/index.stories.ts +5 -10
- package/src/components/avatargroup/style/AvatarGroup.css.ts +9 -4
- package/src/components/avatargroup/symbol.ts +5 -5
- package/src/components/badge/examples/index.stories.ts +4 -6
- package/src/components/badge/style/Badge.css.ts +36 -36
- package/src/components/breadcrumb/examples/index.stories.ts +6 -10
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +17 -17
- package/src/components/breadcrumb/style/index.ts +1 -1
- package/src/components/breadcrumb/symbol.ts +4 -3
- package/src/components/button/examples/index.stories.ts +4 -4
- package/src/components/button/style/Button.css.ts +143 -133
- package/src/components/buttongroup/examples/index.stories.ts +6 -12
- package/src/components/buttongroup/style/ButtonGroup.css.ts +13 -11
- package/src/components/buttongroup/symbol.ts +5 -4
- package/src/components/checkbox/Checkbox.vue +8 -8
- package/src/components/checkbox/examples/index.stories.ts +4 -9
- package/src/components/checkbox/examples/index.ts +0 -1
- package/src/components/checkbox/style/Checkbox.css.ts +31 -27
- package/src/components/checkbox/style/index.ts +1 -1
- package/src/components/colorpicker/examples/index.stories.ts +5 -10
- package/src/components/colorpicker/examples/index.ts +1 -1
- package/src/components/colorpicker/style/ColorPicker.css.ts +22 -14
- package/src/components/colorpicker/utils.ts +46 -28
- package/src/components/confirm/examples/index.stories.ts +5 -8
- package/src/components/confirm/props.ts +2 -2
- package/src/components/confirm/providerProps.ts +1 -2
- package/src/components/confirm/types.ts +15 -16
- package/src/components/confirm/useConfirm.ts +3 -1
- package/src/components/dialog/examples/index.stories.ts +5 -9
- package/src/components/dialog/style/Dialog.css.ts +38 -37
- package/src/components/dropdown/examples/index.stories.ts +3 -7
- package/src/components/dropdown/hooks.ts +20 -20
- package/src/components/dropdown/style/Dropdown.css.ts +24 -24
- package/src/components/dropdown/symbol.ts +3 -2
- package/src/components/form/Form.vue +1 -1
- package/src/components/form/examples/index.stories.ts +2 -4
- package/src/components/form/style/Form.css.ts +13 -8
- package/src/components/form/style/index.ts +2 -2
- package/src/components/form/symbol.ts +10 -5
- package/src/components/image/examples/index.stories.ts +5 -7
- package/src/components/input/Input.vue +8 -9
- package/src/components/input/examples/index.stories.ts +5 -7
- package/src/components/input/style/Input.css.ts +40 -43
- package/src/components/link/examples/index.stories.ts +4 -9
- package/src/components/messageprovider/examples/index.stories.ts +5 -8
- package/src/components/messageprovider/style/Message.css.ts +31 -31
- package/src/components/messageprovider/style/index.ts +1 -1
- package/src/components/messageprovider/types.ts +31 -22
- package/src/components/messageprovider/useMessage.ts +6 -4
- package/src/components/modal/Modal.vue +72 -54
- package/src/components/modal/examples/index.stories.ts +6 -10
- package/src/components/modal/examples/index.ts +1 -0
- package/src/components/modal/examples/sidebar.vue +75 -0
- package/src/components/modal/style/Modal.css.ts +91 -72
- package/src/components/pagination/examples/index.stories.ts +5 -9
- package/src/components/pagination/examples/index.ts +1 -1
- package/src/components/pagination/style/Pagination.css.ts +41 -37
- package/src/components/radio/Radio.vue +7 -7
- package/src/components/radio/examples/index.stories.ts +4 -9
- package/src/components/radio/examples/index.ts +0 -1
- package/src/components/radio/style/Checkbox.css.ts +30 -31
- package/src/components/radio/style/index.ts +1 -1
- package/src/components/radiobutton/RadioButton.vue +3 -3
- package/src/components/radiobutton/style/RadioButton.css.ts +41 -36
- package/src/components/radiobuttongroup/examples/index.stories.ts +6 -10
- package/src/components/radiobuttongroup/examples/index.ts +0 -1
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +14 -14
- package/src/components/radiobuttongroup/style/index.ts +1 -1
- package/src/components/radiobuttongroup/symbol.ts +8 -7
- package/src/components/renderer/examlpes/index.stories.ts +4 -8
- package/src/components/renderer/props.ts +2 -3
- package/src/components/renderer/renderer.ts +3 -3
- package/src/components/select/Select.vue +3 -4
- package/src/components/select/examples/index.stories.ts +4 -10
- package/src/components/select/style/Select.css.ts +62 -61
- package/src/components/skeleton/examples/index.stories.ts +5 -9
- package/src/components/skeleton/style/Skeleton.css.ts +16 -16
- package/src/components/skeleton/style/index.ts +2 -2
- package/src/components/slider/style/Slider.css.ts +12 -5
- package/src/components/switch/Switch.vue +4 -4
- package/src/components/switch/examples/index.stories.ts +4 -9
- package/src/components/switch/examples/index.ts +0 -1
- package/src/components/switch/style/Switch.css.ts +56 -57
- package/src/components/switch/style/index.ts +1 -1
- package/src/components/tab/examples/index.stories.ts +5 -11
- package/src/components/table/examples/index.stories.ts +6 -12
- package/src/components/table/style/Table.css.ts +22 -17
- package/src/components/table/style/index.ts +1 -1
- package/src/components/table/types/index.ts +1 -1
- package/src/components/tag/examples/index.stories.ts +4 -10
- package/src/components/tag/style/Tag.css.ts +14 -9
- package/src/components/textarea/Textarea.vue +7 -8
- package/src/components/textarea/examples/index.stories.ts +4 -8
- package/src/components/textarea/style/Textarea.css.ts +33 -33
- package/src/components/tooltip/examples/index.stories.ts +5 -10
- package/src/components/tooltip/examples/index.ts +2 -2
- package/src/components/tooltip/style/Tooltip.css.ts +24 -25
- package/src/components/transfer/examples/index.stories.ts +5 -9
- package/src/components/transfer/style/Transfer.css.ts +41 -40
- package/src/components/tree/examples/index.stories.ts +6 -10
- package/src/components/tree/props.ts +20 -18
- package/src/components/tree/style/Tree.css.ts +36 -31
- package/src/components/tree/types.ts +60 -62
- package/src/components/virtualscroll/examples/index.stories.ts +4 -8
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +1 -2
- package/src/composables/element.ts +4 -4
- package/src/composables/useCachedUid.ts +7 -6
- package/src/composables/useEventListener.ts +11 -6
- package/src/composables/useInput.ts +63 -41
- package/src/composables/useInteractive.ts +10 -11
- package/src/composables/useMergedState.ts +7 -7
- package/src/composables/useMount.ts +11 -11
- package/src/composables/usePopper.ts +57 -36
- package/src/composables/useZIndex.ts +5 -5
- package/src/create.ts +10 -6
- package/src/examples/cards/cards.stories.ts +3 -3
- package/src/examples/modal/modal.stories.ts +3 -3
- package/src/exports/nuxt.js +17 -15
- package/src/exports/nuxt.plugin.js +6 -6
- package/src/index.ts +0 -2
- package/src/install.ts +5 -5
- package/src/shims-vue.d.ts +3 -3
- package/src/styles/theme.css.ts +51 -43
- package/src/styles/transitions.css.ts +26 -28
- package/src/types/props.ts +16 -2
- package/src/utils/injection.ts +3 -3
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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:
|
|
7
|
-
display:
|
|
11
|
+
cursor: 'pointer',
|
|
12
|
+
display: 'inline-flex',
|
|
8
13
|
flexShrink: 0,
|
|
9
14
|
height: `24px`,
|
|
10
15
|
width: `24px`,
|
|
11
|
-
alignItems:
|
|
12
|
-
justifyContent:
|
|
13
|
-
verticalAlign:
|
|
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:
|
|
22
|
+
position: 'relative',
|
|
18
23
|
height: `14px`,
|
|
19
24
|
width: `14px`,
|
|
20
|
-
display:
|
|
25
|
+
display: 'flex',
|
|
21
26
|
fontSize: `14px`,
|
|
22
|
-
fill:
|
|
23
|
-
color: themeVars.color.gray[
|
|
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:
|
|
34
|
-
padding: `${themeVars.space[
|
|
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:
|
|
40
|
-
display:
|
|
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[
|
|
50
|
+
backgroundColor: themeVars.color.gray['150']
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
|
-
})
|
|
53
|
+
});
|
|
49
54
|
|
|
50
55
|
export const nodeContent = style({
|
|
51
|
-
cursor:
|
|
52
|
-
position:
|
|
53
|
-
display:
|
|
54
|
-
alignItems:
|
|
56
|
+
cursor: 'pointer',
|
|
57
|
+
position: 'relative',
|
|
58
|
+
display: 'inline-flex',
|
|
59
|
+
alignItems: 'center',
|
|
55
60
|
minHeight: `24px`,
|
|
56
|
-
boxSizing:
|
|
57
|
-
verticalAlign:
|
|
58
|
-
padding: `0 ${themeVars.space[
|
|
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:
|
|
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[
|
|
70
|
-
})
|
|
74
|
+
color: themeVars.color.gray['700']
|
|
75
|
+
});
|
|
@@ -1,105 +1,103 @@
|
|
|
1
|
-
import type {HTMLAttributes, Ref, InjectionKey} from
|
|
2
|
-
import type {TreeNode} from
|
|
3
|
-
import {createInjectionKey} from
|
|
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:
|
|
42
|
-
option:
|
|
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:
|
|
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:
|
|
58
|
-
option:
|
|
59
|
-
) => void
|
|
55
|
+
value: (string & number)[],
|
|
56
|
+
option: (TreeOption | null)[]
|
|
57
|
+
) => void;
|
|
60
58
|
export type OnUpdateIndeterminateKeysImpl = (
|
|
61
59
|
value: Key[],
|
|
62
|
-
option:
|
|
63
|
-
) => void
|
|
60
|
+
option: (TreeOption | null)[]
|
|
61
|
+
) => void;
|
|
64
62
|
export type OnUpdateSelectedKeys = (
|
|
65
|
-
value:
|
|
66
|
-
option:
|
|
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:
|
|
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:
|
|
82
|
-
option:
|
|
79
|
+
value: (string & number)[],
|
|
80
|
+
option: (TreeOption | null)[],
|
|
83
81
|
meta:
|
|
84
82
|
| {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
node: TreeOption;
|
|
84
|
+
action: 'expand' | 'collapse';
|
|
85
|
+
}
|
|
88
86
|
| {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
) => void
|
|
87
|
+
node: null;
|
|
88
|
+
action: 'filter';
|
|
89
|
+
}
|
|
90
|
+
) => void;
|
|
93
91
|
export type OnUpdateExpandedKeysImpl = (
|
|
94
92
|
value: Key[],
|
|
95
|
-
option:
|
|
93
|
+
option: (TreeOption | null)[],
|
|
96
94
|
meta:
|
|
97
95
|
| {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
node: TreeOption;
|
|
97
|
+
action: 'expand' | 'collapse';
|
|
98
|
+
}
|
|
101
99
|
| {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
) => void
|
|
100
|
+
node: null;
|
|
101
|
+
action: 'filter';
|
|
102
|
+
}
|
|
103
|
+
) => void;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import MVirtualScroll from
|
|
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
|
|
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
|
|
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
|
|
12
|
-
const id =
|
|
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
|
-
|
|
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
|
|
1
|
+
import { watchEffect } from 'vue';
|
|
2
2
|
|
|
3
|
-
export function useEventListener<
|
|
4
|
-
|
|
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(
|
|
11
|
+
watchEffect(onInvalidate => {
|
|
9
12
|
element = element ?? window;
|
|
10
13
|
|
|
11
14
|
element.addEventListener(type, listener, options);
|
|
12
|
-
onInvalidate(() =>
|
|
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
|
|
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 = (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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(
|
|
26
|
-
|
|
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
|
|
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
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
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
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
2
|
-
import type { App, Component } from
|
|
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
|
}
|