@teammodlr/ui-kit 2.3.23 → 3.0.0-beta.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/avatar/Avatar.vue.d.ts +2 -2
- package/lib/components/badge/style/Badge.css.d.ts +2 -2
- package/lib/components/button/Button.vue.d.ts +7 -4
- package/lib/components/button/style/Button.css.d.ts +3 -3
- package/lib/components/cardcontextmenu/CardContextMenu.vue.d.ts +5 -8
- package/lib/components/cardcontextmenu/CardContextMenuItem.vue.d.ts +11 -2
- package/lib/components/cardcontextmenu/CardContextMenuTriggerProvider.vue.d.ts +2 -0
- package/lib/components/cardcontextmenu/style/Dropdown.css.d.ts +2 -1
- package/lib/components/cardcontextmenu/symbol.d.ts +1 -0
- package/lib/components/checkbox/Checkbox.vue.d.ts +15 -4
- package/lib/components/collapse/CollapseItem.vue.d.ts +3 -2
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +8 -9
- package/lib/components/confirm/Confirm.vue.d.ts +9 -0
- package/lib/components/confirm/props.d.ts +4 -0
- package/lib/components/dialog/Dialog.vue.d.ts +13 -5
- package/lib/components/dialogprovider/DialogProvider.vue.d.ts +1 -0
- package/lib/components/dialogprovider/types.d.ts +1 -0
- package/lib/components/dropdown/Dropdown.vue.d.ts +3 -1
- package/lib/components/dropdown/DropdownItem.vue.d.ts +11 -1
- package/lib/components/dropdown/DropdownSeperator.vue.d.ts +1 -0
- package/lib/components/dropdown/DropdownTriggerProvider.vue.d.ts +2 -0
- package/lib/components/dropdown/style/Dropdown.css.d.ts +2 -1
- package/lib/components/dropdown/symbol.d.ts +2 -0
- package/lib/components/image/Image.vue.d.ts +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/messageprovider/Message.vue.d.ts +1 -1
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +24 -24
- package/lib/components/messageprovider/style/Message.css.d.ts +1 -1
- package/lib/components/messageprovider/style/Toaster.css.d.ts +1 -0
- package/lib/components/messageprovider/types.d.ts +5 -0
- package/lib/components/modal/Modal.vue.d.ts +18 -6
- package/lib/components/popover/Popover.vue.d.ts +113 -0
- package/lib/components/popover/style/Popover.css.d.ts +4 -0
- package/lib/components/popover/style/index.d.ts +1 -0
- package/lib/components/radio/Radio.vue.d.ts +2 -0
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +1 -0
- package/lib/components/select/Select.vue.d.ts +20 -11
- package/lib/components/switch/Switch.vue.d.ts +2 -0
- package/lib/components/tab/Tab.vue.d.ts +5 -2
- package/lib/components/tab/TabGroup.vue.d.ts +8 -3
- package/lib/components/textarea/Textarea.vue.d.ts +2 -1
- package/lib/components/tooltip/Tooltip.vue.d.ts +5 -20
- package/lib/components/tooltip/TooltipTrigger.vue.d.ts +1 -10
- package/lib/components/tree/Tree.vue.d.ts +3 -3
- package/lib/components/tree/TreeNode.vue.d.ts +26 -12
- package/lib/components/tree/types.d.ts +5 -5
- package/lib/index.cjs.js +5 -14
- package/lib/index.es.js +16907 -12199
- package/lib/style.css +1 -1
- package/package.json +12 -6
- package/src/components/avatar/Avatar.vue +32 -24
- package/src/components/button/Button.vue +24 -5
- package/src/components/cardcontextmenu/CardContextMenu.vue +68 -95
- package/src/components/cardcontextmenu/CardContextMenuItem.vue +40 -50
- package/src/components/cardcontextmenu/CardContextMenuSeperator.vue +9 -7
- package/src/components/cardcontextmenu/CardContextMenuTriggerProvider.vue +15 -0
- package/src/components/cardcontextmenu/style/Dropdown.css.ts +155 -2
- package/src/components/cardcontextmenu/symbol.ts +3 -0
- package/src/components/checkbox/Checkbox.vue +37 -12
- package/src/components/checkbox/style/Checkbox.css.ts +6 -6
- package/src/components/collapse/CollapseItem.vue +46 -21
- package/src/components/collapse/style/Collapse.css.ts +5 -1
- package/src/components/colorpicker/ColorPicker.vue +76 -45
- package/src/components/confirm/Confirm.vue +15 -8
- package/src/components/confirm/props.ts +4 -0
- package/src/components/dialog/Dialog.vue +183 -37
- package/src/components/dialog/style/Dialog.css.ts +15 -1
- package/src/components/dialogprovider/types.ts +1 -0
- package/src/components/dropdown/Dropdown.vue +46 -3
- package/src/components/dropdown/DropdownItem.vue +55 -25
- package/src/components/dropdown/DropdownSeperator.vue +19 -11
- package/src/components/dropdown/DropdownTriggerProvider.vue +15 -0
- package/src/components/dropdown/examples/context.vue +2 -2
- package/src/components/dropdown/style/Dropdown.css.ts +173 -4
- package/src/components/dropdown/symbol.ts +4 -0
- package/src/components/form/examples/basic.vue +19 -8
- package/src/components/index.ts +1 -0
- package/src/components/messageprovider/MessageProvider.vue +139 -90
- package/src/components/messageprovider/examples/basic.vue +3 -1
- package/src/components/messageprovider/examples/index.stories.ts +37 -1
- package/src/components/messageprovider/style/Toaster.css.ts +24 -0
- package/src/components/messageprovider/types.ts +10 -0
- package/src/components/modal/Modal.vue +142 -67
- package/src/components/modal/style/Modal.css.ts +26 -2
- package/src/components/popover/Popover.vue +155 -0
- package/src/components/popover/examples/arrow.vue +47 -0
- package/src/components/popover/examples/basic.vue +15 -0
- package/src/components/popover/examples/index.stories.ts +19 -0
- package/src/components/popover/examples/index.ts +4 -0
- package/src/components/popover/examples/placement.vue +59 -0
- package/src/components/popover/examples/variant.vue +30 -0
- package/src/components/popover/style/Popover.css.ts +203 -0
- package/src/components/popover/style/index.ts +1 -0
- package/src/components/radio/Radio.vue +31 -17
- package/src/components/radiobutton/RadioButton.vue +15 -2
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +11 -4
- package/src/components/select/Select.vue +301 -153
- package/src/components/select/examples/basic.vue +1 -1
- package/src/components/slider/Slider.vue +1 -1
- package/src/components/switch/Switch.vue +30 -10
- package/src/components/switch/style/Switch.css.ts +3 -5
- package/src/components/tab/Tab.vue +29 -20
- package/src/components/tab/TabGroup.vue +29 -38
- package/src/components/textarea/Textarea.vue +8 -4
- package/src/components/tooltip/Tooltip.vue +52 -141
- package/src/components/tooltip/TooltipTrigger.vue +14 -17
- package/src/components/tooltip/style/Tooltip.css.ts +148 -29
- package/src/components/tree/Tree.vue +138 -100
- package/src/components/tree/TreeNode.vue +105 -98
- package/src/components/tree/types.ts +4 -4
- package/src/styles/transitions.css.ts +36 -16
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<label :class="style.base">
|
|
4
|
-
<
|
|
4
|
+
<CheckboxRoot
|
|
5
5
|
:id="name"
|
|
6
6
|
v-model="toggle"
|
|
7
7
|
:name="name"
|
|
8
8
|
:required="required"
|
|
9
|
-
:value="
|
|
9
|
+
:value="checkboxValue"
|
|
10
10
|
:disabled="disabled"
|
|
11
|
-
:checked="checked"
|
|
12
|
-
:indeterminate="indeterminate"
|
|
13
|
-
type="checkbox"
|
|
14
11
|
:aria-disabled="disabled || loading ? 'true' : 'false'"
|
|
15
12
|
:aria-labelledby="`${id}-label`"
|
|
16
13
|
v-bind="$attrs"
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
:class="classes"
|
|
15
|
+
@blur="onBlur"
|
|
16
|
+
@focus="onFocus"
|
|
17
|
+
@update:model-value="onChange" />
|
|
19
18
|
<span :class="style.label" :id="`${id}-label`">
|
|
20
19
|
<template v-if="hasSlot">
|
|
21
20
|
<slot/>
|
|
@@ -31,6 +30,7 @@
|
|
|
31
30
|
|
|
32
31
|
<script lang="ts">
|
|
33
32
|
import {computed, defineComponent, type PropType, ref, toRef} from 'vue';
|
|
33
|
+
import { CheckboxRoot, type AcceptableValue } from 'reka-ui';
|
|
34
34
|
import {useInput} from '../../composables/useInput';
|
|
35
35
|
import {useInteractive} from '../../composables/useInteractive';
|
|
36
36
|
import type {Size} from '../../types/props';
|
|
@@ -38,6 +38,9 @@ import * as style from './style';
|
|
|
38
38
|
|
|
39
39
|
export default defineComponent({
|
|
40
40
|
name: 'Checkbox',
|
|
41
|
+
components: {
|
|
42
|
+
CheckboxRoot
|
|
43
|
+
},
|
|
41
44
|
emits: [...useInput.emits(), 'change'],
|
|
42
45
|
props: {
|
|
43
46
|
...useInput.props(),
|
|
@@ -65,7 +68,10 @@ export default defineComponent({
|
|
|
65
68
|
type: Boolean,
|
|
66
69
|
default: false
|
|
67
70
|
},
|
|
68
|
-
value: {
|
|
71
|
+
value: {
|
|
72
|
+
type: [String, Number, Boolean, Object, Array] as PropType<any>,
|
|
73
|
+
default: undefined
|
|
74
|
+
}
|
|
69
75
|
},
|
|
70
76
|
setup(props, {slots, emit, expose}) {
|
|
71
77
|
const checkboxRef = ref<HTMLElement | null>(null);
|
|
@@ -82,7 +88,7 @@ export default defineComponent({
|
|
|
82
88
|
formDisabled,
|
|
83
89
|
formLoading,
|
|
84
90
|
inputListeners
|
|
85
|
-
} = useInput(props, {focus, emit});
|
|
91
|
+
} = useInput(props, {focus, emit, withListeners: false});
|
|
86
92
|
|
|
87
93
|
const disabled = computed(
|
|
88
94
|
() => formDisabled || props.disabled || props.loading
|
|
@@ -105,17 +111,33 @@ export default defineComponent({
|
|
|
105
111
|
return formError.value || props.error;
|
|
106
112
|
});
|
|
107
113
|
|
|
114
|
+
const checkboxValue = computed(() => {
|
|
115
|
+
return props.value as AcceptableValue | undefined;
|
|
116
|
+
});
|
|
117
|
+
|
|
108
118
|
const toggle = computed({
|
|
109
119
|
get() {
|
|
110
|
-
|
|
120
|
+
if (props.indeterminate) {
|
|
121
|
+
return 'indeterminate';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return props.modelValue ?? props.checked;
|
|
111
125
|
},
|
|
112
126
|
set(value) {
|
|
113
127
|
emit('update:modelValue', value);
|
|
114
128
|
}
|
|
115
129
|
});
|
|
116
130
|
|
|
117
|
-
const onChange = (
|
|
118
|
-
emit('change',
|
|
131
|
+
const onChange = (value: unknown) => {
|
|
132
|
+
emit('change', value);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const onFocus = (event: FocusEvent) => {
|
|
136
|
+
emit('focus', event);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const onBlur = (event: FocusEvent) => {
|
|
140
|
+
emit('blur', event);
|
|
119
141
|
};
|
|
120
142
|
|
|
121
143
|
expose({
|
|
@@ -131,9 +153,12 @@ export default defineComponent({
|
|
|
131
153
|
validate,
|
|
132
154
|
setError,
|
|
133
155
|
onChange,
|
|
156
|
+
onFocus,
|
|
157
|
+
onBlur,
|
|
134
158
|
disabled,
|
|
135
159
|
name,
|
|
136
160
|
checkboxRef,
|
|
161
|
+
checkboxValue,
|
|
137
162
|
inputError,
|
|
138
163
|
toggle,
|
|
139
164
|
style,
|
|
@@ -56,14 +56,14 @@ export const checkbox = style({
|
|
|
56
56
|
outline: 'none',
|
|
57
57
|
|
|
58
58
|
selectors: {
|
|
59
|
-
['&:focus']: {
|
|
59
|
+
['&:focus-visible']: {
|
|
60
60
|
vars: {
|
|
61
61
|
[vars.borderColor]: themeVars.color.blue[500],
|
|
62
62
|
[vars.color]: '#FFF'
|
|
63
63
|
},
|
|
64
64
|
boxShadow: `0 0 0 2px ${themeVars.color.blue[200]}`
|
|
65
65
|
},
|
|
66
|
-
['
|
|
66
|
+
['&[data-state="checked"]']: {
|
|
67
67
|
vars: {
|
|
68
68
|
[vars.borderColor]: themeVars.color.blue[500],
|
|
69
69
|
[vars.color]: themeVars.color.blue[500]
|
|
@@ -76,14 +76,14 @@ export const checkbox = style({
|
|
|
76
76
|
color: vars.color,
|
|
77
77
|
backgroundImage: `url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E")`
|
|
78
78
|
},
|
|
79
|
-
['
|
|
79
|
+
['&[data-state="checked"]:focus-visible']: {
|
|
80
80
|
vars: {
|
|
81
81
|
[vars.borderColor]: themeVars.color.blue[500],
|
|
82
82
|
[vars.color]: themeVars.color.blue[500]
|
|
83
83
|
},
|
|
84
84
|
color: vars.color
|
|
85
85
|
},
|
|
86
|
-
['
|
|
86
|
+
['&[data-state="indeterminate"]']: {
|
|
87
87
|
vars: {
|
|
88
88
|
[vars.borderColor]: themeVars.color.blue[500],
|
|
89
89
|
[vars.color]: themeVars.color.blue[500]
|
|
@@ -101,14 +101,14 @@ export const checkbox = style({
|
|
|
101
101
|
[vars.borderColor]: themeVars.color.gray[400]
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
|
-
['
|
|
104
|
+
['&[data-disabled]']: {
|
|
105
105
|
vars: {
|
|
106
106
|
[vars.borderColor]: themeVars.color.gray[300],
|
|
107
107
|
[vars.color]: themeVars.color.gray[200]
|
|
108
108
|
},
|
|
109
109
|
cursor: 'not-allowed'
|
|
110
110
|
},
|
|
111
|
-
['
|
|
111
|
+
['&[data-disabled][data-state="checked"]']: {
|
|
112
112
|
vars: {
|
|
113
113
|
[vars.borderColor]: themeVars.color.gray[400],
|
|
114
114
|
[vars.color]: themeVars.color.gray[400]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { CollapsibleContent, CollapsibleRoot, CollapsibleTrigger } from 'reka-ui';
|
|
2
3
|
import { useMemo } from 'vooks';
|
|
3
4
|
import { computed, defineComponent, inject } from 'vue'
|
|
4
|
-
import type { ExtractPublicPropTypes, PropType } from 'vue';
|
|
5
|
+
import type { CSSProperties, ExtractPublicPropTypes, PropType } from 'vue';
|
|
5
6
|
import { collapseInjectionKey } from './Collapse.vue';
|
|
6
7
|
import MCollapseItemContent from './CollapseItemContent.vue';
|
|
7
8
|
import * as style from './style';
|
|
@@ -16,6 +17,12 @@ export type CollapseItemProps = ExtractPublicPropTypes<typeof collapseItemProps>
|
|
|
16
17
|
|
|
17
18
|
export default defineComponent({
|
|
18
19
|
name: 'CollapseItem',
|
|
20
|
+
components: {
|
|
21
|
+
CollapsibleContent,
|
|
22
|
+
CollapsibleRoot,
|
|
23
|
+
CollapsibleTrigger,
|
|
24
|
+
MCollapseItemContent
|
|
25
|
+
},
|
|
19
26
|
props: collapseItemProps,
|
|
20
27
|
setup(props) {
|
|
21
28
|
const randomName = Math.random().toString(36).substring(7);
|
|
@@ -67,6 +74,12 @@ export default defineComponent({
|
|
|
67
74
|
}
|
|
68
75
|
});
|
|
69
76
|
|
|
77
|
+
const computedHeaderMainStyles = computed<CSSProperties | undefined>(() => {
|
|
78
|
+
return collapseProps.arrowPlacement === 'right'
|
|
79
|
+
? { flexDirection: 'row-reverse' }
|
|
80
|
+
: undefined;
|
|
81
|
+
});
|
|
82
|
+
|
|
70
83
|
const computedIconClasses = computed(() => {
|
|
71
84
|
return {
|
|
72
85
|
[style.collapseItemHeaderArrow]: true,
|
|
@@ -93,32 +106,44 @@ export default defineComponent({
|
|
|
93
106
|
arrowPlacement: computed<'left' | 'right'>(() => {
|
|
94
107
|
return collapseProps.arrowPlacement;
|
|
95
108
|
}),
|
|
96
|
-
|
|
97
|
-
if (collapse && !props.disabled) {
|
|
98
|
-
collapse.toggleItem(collapsedRef.value, mergedNameRef.value,
|
|
109
|
+
handleOpenChange(open: boolean) {
|
|
110
|
+
if (open !== !collapsedRef.value && collapse && !props.disabled) {
|
|
111
|
+
collapse.toggleItem(collapsedRef.value, mergedNameRef.value, new MouseEvent('click'))
|
|
99
112
|
}
|
|
100
|
-
}
|
|
113
|
+
},
|
|
114
|
+
computedHeaderMainStyles
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
});
|
|
104
118
|
</script>
|
|
105
119
|
|
|
106
120
|
<template>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
<CollapsibleRoot
|
|
122
|
+
:open="!collapsed"
|
|
123
|
+
:disabled="disabled"
|
|
124
|
+
:unmount-on-hide="mergedDisplayDirective === 'if'"
|
|
125
|
+
@update:open="handleOpenChange"
|
|
126
|
+
>
|
|
127
|
+
<div :class="computedContentClasses">
|
|
128
|
+
<CollapsibleTrigger as-child>
|
|
129
|
+
<button type="button" :class="computedHeaderClasses">
|
|
130
|
+
<div :class="computedHeaderMainClasses" :style="computedHeaderMainStyles">
|
|
131
|
+
<svg :class="computedIconClasses" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
|
132
|
+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
133
|
+
class="lucide lucide-chevron-right">
|
|
134
|
+
<path d="m9 18 6-6-6-6" />
|
|
135
|
+
</svg>
|
|
136
|
+
<slot name="header">
|
|
137
|
+
{{ title }}
|
|
138
|
+
</slot>
|
|
139
|
+
</div>
|
|
140
|
+
</button>
|
|
141
|
+
</CollapsibleTrigger>
|
|
142
|
+
<CollapsibleContent as-child :force-mount="mergedDisplayDirective === 'show'">
|
|
143
|
+
<MCollapseItemContent :displayDirective="mergedDisplayDirective" :show="!collapsed">
|
|
144
|
+
<slot />
|
|
145
|
+
</MCollapseItemContent>
|
|
146
|
+
</CollapsibleContent>
|
|
119
147
|
</div>
|
|
120
|
-
|
|
121
|
-
<slot />
|
|
122
|
-
</MCollapseItemContent>
|
|
123
|
-
</div>
|
|
148
|
+
</CollapsibleRoot>
|
|
124
149
|
</template>
|
|
@@ -46,7 +46,11 @@ export const collapseItemHeader = style({
|
|
|
46
46
|
alignItems: 'center',
|
|
47
47
|
position: 'relative',
|
|
48
48
|
color: vars.fontColor,
|
|
49
|
-
padding: vars.headerPadding
|
|
49
|
+
padding: vars.headerPadding,
|
|
50
|
+
width: '100%',
|
|
51
|
+
border: 'none',
|
|
52
|
+
background: 'transparent',
|
|
53
|
+
textAlign: 'left'
|
|
50
54
|
});
|
|
51
55
|
|
|
52
56
|
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="wrapper" class="m-color-picker">
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<div :
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
<PopoverRoot v-model:open="isOpen" @update:open="handleOpenChange">
|
|
4
|
+
<PopoverTrigger as-child>
|
|
5
|
+
<div ref="referenceRef">
|
|
6
|
+
<slot :r="finalColor.r" :g="finalColor.g" :b="finalColor.b" :a="finalColor.a" :hex="hexInput"
|
|
7
|
+
:transparent="style.transparent">
|
|
8
|
+
<div :class="style.reference">
|
|
9
|
+
<template v-if="modelValue === 'inherit'">
|
|
10
|
+
<div :style="{ border: '1px dashed #999', padding: '8px', textAlign: 'center' }">Inherit</div>
|
|
11
|
+
</template>
|
|
12
|
+
<template v-else>
|
|
13
|
+
<div :class="style.referenceColor"
|
|
14
|
+
:style="{ backgroundColor: `rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a})` }">
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
13
17
|
</div>
|
|
14
|
-
</
|
|
18
|
+
</slot>
|
|
15
19
|
</div>
|
|
16
|
-
</
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
</PopoverTrigger>
|
|
21
|
+
<PopoverPortal :disabled="!transfer">
|
|
22
|
+
<PopoverContent
|
|
23
|
+
v-if="isOpen"
|
|
24
|
+
ref="popper"
|
|
25
|
+
:class="style.container"
|
|
26
|
+
:style="{ zIndex: zIndex }"
|
|
27
|
+
:side="resolvedSide"
|
|
28
|
+
:align="resolvedAlign"
|
|
29
|
+
:side-offset="4"
|
|
30
|
+
:collision-padding="8"
|
|
31
|
+
@open-auto-focus.prevent
|
|
32
|
+
@close-auto-focus.prevent
|
|
33
|
+
>
|
|
22
34
|
<div ref="picker" @mousedown="handleMouseDown" :class="style.colours"
|
|
23
35
|
:style="`background: rgb(${mainColor.r}, ${mainColor.g}, ${mainColor.b});`">
|
|
24
36
|
<div :class="style.whiteGradient"></div>
|
|
@@ -97,20 +109,22 @@
|
|
|
97
109
|
</svg>
|
|
98
110
|
</MButton>
|
|
99
111
|
</div>
|
|
100
|
-
</
|
|
101
|
-
</
|
|
102
|
-
</
|
|
112
|
+
</PopoverContent>
|
|
113
|
+
</PopoverPortal>
|
|
114
|
+
</PopoverRoot>
|
|
103
115
|
</div>
|
|
104
116
|
</template>
|
|
105
117
|
|
|
106
118
|
<script lang="ts">
|
|
107
|
-
import {
|
|
119
|
+
import { useEyeDropper, useMouseInElement, useMousePressed } from '@vueuse/core';
|
|
108
120
|
import { computed, defineComponent, onMounted, type PropType, reactive, ref, toRef, watch } from "vue";
|
|
121
|
+
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, type PopoverContentProps } from 'reka-ui';
|
|
109
122
|
import * as style from './style';
|
|
110
|
-
import { scale } from "../../styles/transitions.css";
|
|
111
123
|
import { hexToRGB, type HSV, HSVToRGBA, HueToRGBA, RGBAToHex, RGBToHSV } from './utils';
|
|
112
|
-
import {
|
|
113
|
-
|
|
124
|
+
import {
|
|
125
|
+
type Placement,
|
|
126
|
+
placementWhileList
|
|
127
|
+
} from '../../composables/usePopper';
|
|
114
128
|
import { useZIndex } from "../../composables/useZIndex";
|
|
115
129
|
import MSlider from "../../components/slider/Slider.vue";
|
|
116
130
|
import MButton from "../../components/button/Button.vue";
|
|
@@ -137,7 +151,8 @@ export default defineComponent({
|
|
|
137
151
|
},
|
|
138
152
|
placement: {
|
|
139
153
|
type: String as PropType<Placement>,
|
|
140
|
-
default: "bottom-start"
|
|
154
|
+
default: "bottom-start",
|
|
155
|
+
validator: (value: Placement) => placementWhileList.includes(value)
|
|
141
156
|
},
|
|
142
157
|
zIndex: {
|
|
143
158
|
type: Number
|
|
@@ -151,7 +166,11 @@ export default defineComponent({
|
|
|
151
166
|
components: {
|
|
152
167
|
MSlider,
|
|
153
168
|
MInput,
|
|
154
|
-
MButton
|
|
169
|
+
MButton,
|
|
170
|
+
PopoverContent,
|
|
171
|
+
PopoverPortal,
|
|
172
|
+
PopoverRoot,
|
|
173
|
+
PopoverTrigger
|
|
155
174
|
},
|
|
156
175
|
setup(props, { emit }) {
|
|
157
176
|
const modelModifiers = props.modelModifiers;
|
|
@@ -170,7 +189,6 @@ export default defineComponent({
|
|
|
170
189
|
const wrapper = ref<HTMLElement>();
|
|
171
190
|
const referenceRef = ref<HTMLElement>();
|
|
172
191
|
const transfer = toRef(props, 'transfer');
|
|
173
|
-
const placement = toRef(props, 'placement');
|
|
174
192
|
const hexInputElement = ref();
|
|
175
193
|
const hueSlider = ref(0);
|
|
176
194
|
const opacitySlider = ref(100);
|
|
@@ -181,16 +199,25 @@ export default defineComponent({
|
|
|
181
199
|
});
|
|
182
200
|
const zIndex = ref(props.zIndex ?? nextZIndex());
|
|
183
201
|
|
|
202
|
+
const resolvedPlacement = computed(() => {
|
|
203
|
+
const [side, align] = props.placement.split('-');
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
side: side === 'top' || side === 'right' || side === 'bottom' || side === 'left'
|
|
207
|
+
? side
|
|
208
|
+
: 'bottom',
|
|
209
|
+
align: align === 'start' || align === 'center' || align === 'end'
|
|
210
|
+
? align
|
|
211
|
+
: 'start'
|
|
212
|
+
} as {
|
|
213
|
+
side: PopoverContentProps['side'];
|
|
214
|
+
align: PopoverContentProps['align'];
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
|
|
184
218
|
const { elementX, elementY } = useMouseInElement(picker);
|
|
185
219
|
const { pressed } = useMousePressed();
|
|
186
|
-
const
|
|
187
|
-
reference: referenceRef,
|
|
188
|
-
placement,
|
|
189
|
-
transfer,
|
|
190
|
-
wrapper,
|
|
191
|
-
isDrop: false,
|
|
192
|
-
offset: [-2, 2]
|
|
193
|
-
});
|
|
220
|
+
const popper = ref<HTMLElement>();
|
|
194
221
|
const brightness = computed(() => {
|
|
195
222
|
return 1 - position.y;
|
|
196
223
|
})
|
|
@@ -374,14 +401,6 @@ export default defineComponent({
|
|
|
374
401
|
|
|
375
402
|
updateFromHex(false);
|
|
376
403
|
});
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
onClickOutside(popper, (e) => {
|
|
380
|
-
isOpen.value = false;
|
|
381
|
-
emit('onColorChange', hexInput.value);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
|
|
385
404
|
watch(() => eyeDropColor.value, () => {
|
|
386
405
|
if (eyeDropColor.value) {
|
|
387
406
|
hexInput.value = eyeDropColor.value;
|
|
@@ -422,11 +441,20 @@ export default defineComponent({
|
|
|
422
441
|
updateFromHex();
|
|
423
442
|
};
|
|
424
443
|
|
|
444
|
+
const handleOpenChange = (value: boolean) => {
|
|
445
|
+
const wasOpen = isOpen.value;
|
|
446
|
+
|
|
447
|
+
isOpen.value = value;
|
|
448
|
+
|
|
449
|
+
if (wasOpen && !value) {
|
|
450
|
+
emit('onColorChange', hexInput.value);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
425
454
|
|
|
426
455
|
return {
|
|
427
456
|
isOpen,
|
|
428
457
|
popper,
|
|
429
|
-
transferTo,
|
|
430
458
|
wrapper,
|
|
431
459
|
referenceRef,
|
|
432
460
|
updateFromRGB,
|
|
@@ -452,9 +480,12 @@ export default defineComponent({
|
|
|
452
480
|
style,
|
|
453
481
|
mainColor,
|
|
454
482
|
zIndex,
|
|
483
|
+
resolvedSide: computed(() => resolvedPlacement.value.side),
|
|
484
|
+
resolvedAlign: computed(() => resolvedPlacement.value.align),
|
|
485
|
+
transfer,
|
|
455
486
|
canPickColor,
|
|
456
487
|
openEyeDropper,
|
|
457
|
-
|
|
488
|
+
handleOpenChange,
|
|
458
489
|
onSliderChangeComplete,
|
|
459
490
|
hexInputUser,
|
|
460
491
|
toggleInherit,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
ref="modal"
|
|
5
5
|
:title="title"
|
|
6
6
|
:canClickOutside="false"
|
|
7
|
+
:focusTrap="focusTrap"
|
|
7
8
|
:onClose="onClose">
|
|
8
9
|
<template #body>
|
|
9
10
|
{{ content }}
|
|
@@ -51,15 +52,21 @@ export default defineComponent({
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
onMounted(async () => {
|
|
54
|
-
modal.value?.open(null);
|
|
55
55
|
await nextTick();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
|
|
57
|
+
requestAnimationFrame(() => {
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
modal.value?.open(null);
|
|
60
|
+
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
if (props.focusAction) {
|
|
63
|
+
actionButton.value.$el.focus();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
cancelButton.value.$el.focus();
|
|
67
|
+
}, 100);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
63
70
|
});
|
|
64
71
|
return {
|
|
65
72
|
modal,
|