@varlet/ui 2.18.0-alpha.1697511280107 → 2.18.0-alpha.1697555377370
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/es/floating-panel/FloatingPanel.mjs +179 -0
- package/es/floating-panel/FloatingPanelSfc.css +0 -0
- package/es/floating-panel/floatingPanel.css +1 -0
- package/es/floating-panel/index.mjs +9 -0
- package/es/floating-panel/props.mjs +27 -0
- package/es/floating-panel/style/index.mjs +4 -0
- package/es/index.bundle.mjs +7 -1
- package/es/index.mjs +6 -1
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/style.mjs +1 -0
- package/es/themes/dark/floatingPanel.mjs +6 -0
- package/es/themes/dark/index.mjs +3 -2
- package/es/varlet.esm.js +4695 -4509
- package/highlight/web-types.en-US.json +81 -1
- package/highlight/web-types.zh-CN.json +81 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +1385 -1153
- package/package.json +7 -7
- package/types/floatingPanel.d.ts +24 -0
- package/types/index.d.ts +2 -0
- package/umd/varlet.js +6 -6
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, watch } from "vue";
|
|
2
|
+
import { props } from "./props.mjs";
|
|
3
|
+
import { useLock } from "../context/lock.mjs";
|
|
4
|
+
import { call, createNamespace, useVModel, formatElevation, useTeleport } from "../utils/components.mjs";
|
|
5
|
+
import { toSizeUnit } from "../utils/elements.mjs";
|
|
6
|
+
import { useTouch, useWindowSize } from "@varlet/use";
|
|
7
|
+
import { toNumber, isEmpty, preventDefault } from "@varlet/shared";
|
|
8
|
+
const { name, n, classes } = createNamespace("floating-panel");
|
|
9
|
+
const DEFAULT_START_ANCHOR = 100;
|
|
10
|
+
const OVERFLOW_REDUCE_RATIO = 0.2;
|
|
11
|
+
import { normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderSlot as _renderSlot, normalizeStyle as _normalizeStyle, Teleport as _Teleport, openBlock as _openBlock, createBlock as _createBlock } from "vue";
|
|
12
|
+
function __render__(_ctx, _cache) {
|
|
13
|
+
return _openBlock(), _createBlock(_Teleport, {
|
|
14
|
+
to: _ctx.teleport === false ? void 0 : _ctx.teleport,
|
|
15
|
+
disabled: _ctx.teleportDisabled || _ctx.teleport === false
|
|
16
|
+
}, [
|
|
17
|
+
_createElementVNode(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.safeArea, _ctx.n("--safe-area")], _ctx.formatElevation(_ctx.elevation, 2))),
|
|
21
|
+
style: _normalizeStyle({
|
|
22
|
+
height: `${_ctx.toSizeUnit(_ctx.maxAnchor)}`,
|
|
23
|
+
transform: `translateY(calc(100% - ${_ctx.toSizeUnit(_ctx.visibleHeight)}))`,
|
|
24
|
+
transition: _ctx.touching ? "none" : `transform ${_ctx.toNumber(_ctx.duration)}ms var(--floating-panel-transition-timing-function)`
|
|
25
|
+
}),
|
|
26
|
+
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
|
|
27
|
+
onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchmove && _ctx.handleTouchmove(...args)),
|
|
28
|
+
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.handleTouchend && _ctx.handleTouchend(...args)),
|
|
29
|
+
onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.handleTouchend && _ctx.handleTouchend(...args))
|
|
30
|
+
},
|
|
31
|
+
[
|
|
32
|
+
_createElementVNode(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
class: _normalizeClass(_ctx.n("header"))
|
|
36
|
+
},
|
|
37
|
+
[
|
|
38
|
+
_createElementVNode(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
class: _normalizeClass(_ctx.n("header-toolbar"))
|
|
42
|
+
},
|
|
43
|
+
null,
|
|
44
|
+
2
|
|
45
|
+
/* CLASS */
|
|
46
|
+
)
|
|
47
|
+
],
|
|
48
|
+
2
|
|
49
|
+
/* CLASS */
|
|
50
|
+
),
|
|
51
|
+
_createElementVNode(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
class: _normalizeClass(_ctx.n("content")),
|
|
55
|
+
ref: "contentRef"
|
|
56
|
+
},
|
|
57
|
+
[
|
|
58
|
+
_renderSlot(_ctx.$slots, "default")
|
|
59
|
+
],
|
|
60
|
+
2
|
|
61
|
+
/* CLASS */
|
|
62
|
+
)
|
|
63
|
+
],
|
|
64
|
+
38
|
|
65
|
+
/* CLASS, STYLE, HYDRATE_EVENTS */
|
|
66
|
+
)
|
|
67
|
+
], 8, ["to", "disabled"]);
|
|
68
|
+
}
|
|
69
|
+
const __sfc__ = defineComponent({
|
|
70
|
+
name,
|
|
71
|
+
props,
|
|
72
|
+
setup(props2) {
|
|
73
|
+
const visibleHeight = ref(0);
|
|
74
|
+
const contentRef = ref(null);
|
|
75
|
+
const { height: windowHeight } = useWindowSize();
|
|
76
|
+
const defaultEndAnchor = computed(() => windowHeight.value * 0.6);
|
|
77
|
+
const anchor = useVModel(props2, "anchor");
|
|
78
|
+
const anchors = computed(() => {
|
|
79
|
+
const defaultAnchors = [DEFAULT_START_ANCHOR, defaultEndAnchor.value];
|
|
80
|
+
const { anchors: anchors2 } = props2;
|
|
81
|
+
return isEmpty(anchors2) ? defaultAnchors : anchors2;
|
|
82
|
+
});
|
|
83
|
+
const minAnchor = computed(() => Math.min(...anchors.value));
|
|
84
|
+
const maxAnchor = computed(() => Math.max(...anchors.value));
|
|
85
|
+
const { disabled: teleportDisabled } = useTeleport();
|
|
86
|
+
const { deltaY, touching, startTouch, moveTouch, endTouch, isReachTop, isReachBottom } = useTouch();
|
|
87
|
+
let startVisibleHeight;
|
|
88
|
+
useLock(() => touching.value);
|
|
89
|
+
watch(() => anchor.value, matchAnchor, { immediate: true });
|
|
90
|
+
watch(
|
|
91
|
+
() => anchors.value,
|
|
92
|
+
() => {
|
|
93
|
+
matchAnchor(anchor.value);
|
|
94
|
+
},
|
|
95
|
+
{ immediate: true }
|
|
96
|
+
);
|
|
97
|
+
function matchAnchor(anchor2) {
|
|
98
|
+
setVisibleHeight(anchor2 != null ? anchor2 : minAnchor.value);
|
|
99
|
+
}
|
|
100
|
+
function handleTouchstart(event) {
|
|
101
|
+
startTouch(event);
|
|
102
|
+
startVisibleHeight = visibleHeight.value;
|
|
103
|
+
}
|
|
104
|
+
function handleTouchmove(event) {
|
|
105
|
+
var _a;
|
|
106
|
+
moveTouch(event);
|
|
107
|
+
const target = event.target;
|
|
108
|
+
const eventFromContent = contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target));
|
|
109
|
+
if (eventFromContent && !props2.contentDraggable) {
|
|
110
|
+
if (isReachTop(contentRef.value) || isReachBottom(contentRef.value)) {
|
|
111
|
+
preventDefault(event);
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const targetVisibleHeight = startVisibleHeight - deltaY.value;
|
|
116
|
+
setVisibleHeight(clampVisibleHeight(targetVisibleHeight));
|
|
117
|
+
preventDefault(event);
|
|
118
|
+
}
|
|
119
|
+
function handleTouchend() {
|
|
120
|
+
endTouch();
|
|
121
|
+
const oldAnchor = anchor.value;
|
|
122
|
+
setVisibleHeight(visibleHeight.value);
|
|
123
|
+
anchor.value = visibleHeight.value;
|
|
124
|
+
if (anchor.value !== oldAnchor) {
|
|
125
|
+
call(props2.onAnchorChange, visibleHeight.value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function setVisibleHeight(targetVisibleHeight) {
|
|
129
|
+
visibleHeight.value = touching.value ? targetVisibleHeight : findNearestAnchor(targetVisibleHeight);
|
|
130
|
+
}
|
|
131
|
+
function clampVisibleHeight(visibleHeight2) {
|
|
132
|
+
if (visibleHeight2 > maxAnchor.value) {
|
|
133
|
+
const overflowHeight = visibleHeight2 - maxAnchor.value;
|
|
134
|
+
return maxAnchor.value + overflowHeight * OVERFLOW_REDUCE_RATIO;
|
|
135
|
+
}
|
|
136
|
+
if (visibleHeight2 < minAnchor.value) {
|
|
137
|
+
const overflowHeight = minAnchor.value - visibleHeight2;
|
|
138
|
+
return minAnchor.value - overflowHeight * OVERFLOW_REDUCE_RATIO;
|
|
139
|
+
}
|
|
140
|
+
return visibleHeight2;
|
|
141
|
+
}
|
|
142
|
+
function findNearestAnchor(targetAnchor) {
|
|
143
|
+
if (anchors.value.includes(targetAnchor)) {
|
|
144
|
+
return targetAnchor;
|
|
145
|
+
}
|
|
146
|
+
let minDifference = Infinity;
|
|
147
|
+
let nearestAnchor = 0;
|
|
148
|
+
anchors.value.forEach((anchor2) => {
|
|
149
|
+
const difference = Math.abs(anchor2 - targetAnchor);
|
|
150
|
+
if (difference < minDifference) {
|
|
151
|
+
minDifference = difference;
|
|
152
|
+
nearestAnchor = anchor2;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return nearestAnchor;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
contentRef,
|
|
159
|
+
teleportDisabled,
|
|
160
|
+
touching,
|
|
161
|
+
minAnchor,
|
|
162
|
+
maxAnchor,
|
|
163
|
+
visibleHeight,
|
|
164
|
+
n,
|
|
165
|
+
classes,
|
|
166
|
+
toSizeUnit,
|
|
167
|
+
toNumber,
|
|
168
|
+
formatElevation,
|
|
169
|
+
handleTouchstart,
|
|
170
|
+
handleTouchmove,
|
|
171
|
+
handleTouchend
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
__sfc__.render = __render__;
|
|
176
|
+
var stdin_default = __sfc__;
|
|
177
|
+
export {
|
|
178
|
+
stdin_default as default
|
|
179
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root { --floating-panel-z-index: 999; --floating-panel-border-top: none; --floating-panel-border-radius: 0; --floating-panel-background: #fff; --floating-panel-header-height: 40px; --floating-panel-toolbar-width: 20px; --floating-panel-toolbar-height: 3px; --floating-panel-toolbar-border-radius: 10px; --floating-panel-toolbar-background: #ddd; --floating-panel-transition-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);}.var-floating-panel { position: fixed; left: 0; bottom: 0; width: 100%; display: flex; flex-direction: column; z-index: var(--floating-panel-z-index); border-top: var(--floating-panel-border-top); border-top-left-radius: var(--floating-panel-border-radius); border-top-right-radius: var(--floating-panel-border-radius); border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: var(--floating-panel-background); will-change: transform; touch-action: none;}.var-floating-panel::after { content: ''; display: block; position: absolute; bottom: -100vh; height: 100vh; width: 100vw; background-color: inherit;}.var-floating-panel__header { height: var(--floating-panel-header-height); display: flex; justify-content: center; align-items: center; cursor: grab; user-select: none;}.var-floating-panel__header-toolbar { width: var(--floating-panel-toolbar-width); height: var(--floating-panel-toolbar-height); border-radius: var(--floating-panel-toolbar-border-radius); background: var(--floating-panel-toolbar-background);}.var-floating-panel__content { flex: 1; overflow-y: auto;}.var-floating-panel--safe-area { padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom);}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import FloatingPanel from "./FloatingPanel.mjs";
|
|
2
|
+
import { withInstall } from "../utils/components.mjs";
|
|
3
|
+
withInstall(FloatingPanel);
|
|
4
|
+
const _FloatingPanelComponent = FloatingPanel;
|
|
5
|
+
var stdin_default = FloatingPanel;
|
|
6
|
+
export {
|
|
7
|
+
_FloatingPanelComponent,
|
|
8
|
+
stdin_default as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineListenerProp } from "../utils/components.mjs";
|
|
2
|
+
const props = {
|
|
3
|
+
anchor: Number,
|
|
4
|
+
anchors: Array,
|
|
5
|
+
contentDraggable: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: true
|
|
8
|
+
},
|
|
9
|
+
duration: {
|
|
10
|
+
type: [Number, String],
|
|
11
|
+
default: 300
|
|
12
|
+
},
|
|
13
|
+
elevation: {
|
|
14
|
+
type: [Boolean, Number, String],
|
|
15
|
+
default: true
|
|
16
|
+
},
|
|
17
|
+
teleport: {
|
|
18
|
+
type: [String, Object, Boolean],
|
|
19
|
+
default: "body"
|
|
20
|
+
},
|
|
21
|
+
safeArea: Boolean,
|
|
22
|
+
"onUpdate:anchor": defineListenerProp(),
|
|
23
|
+
onAnchorChange: defineListenerProp()
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
props
|
|
27
|
+
};
|
package/es/index.bundle.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import Drag from './drag/index.mjs'
|
|
|
28
28
|
import Ellipsis from './ellipsis/index.mjs'
|
|
29
29
|
import Fab from './fab/index.mjs'
|
|
30
30
|
import FieldDecorator from './field-decorator/index.mjs'
|
|
31
|
+
import FloatingPanel from './floating-panel/index.mjs'
|
|
31
32
|
import Form from './form/index.mjs'
|
|
32
33
|
import FormDetails from './form-details/index.mjs'
|
|
33
34
|
import Hover from './hover/index.mjs'
|
|
@@ -114,6 +115,7 @@ export * from './drag/index.mjs'
|
|
|
114
115
|
export * from './ellipsis/index.mjs'
|
|
115
116
|
export * from './fab/index.mjs'
|
|
116
117
|
export * from './field-decorator/index.mjs'
|
|
118
|
+
export * from './floating-panel/index.mjs'
|
|
117
119
|
export * from './form/index.mjs'
|
|
118
120
|
export * from './form-details/index.mjs'
|
|
119
121
|
export * from './hover/index.mjs'
|
|
@@ -200,6 +202,7 @@ import './drag/style/index.mjs'
|
|
|
200
202
|
import './ellipsis/style/index.mjs'
|
|
201
203
|
import './fab/style/index.mjs'
|
|
202
204
|
import './field-decorator/style/index.mjs'
|
|
205
|
+
import './floating-panel/style/index.mjs'
|
|
203
206
|
import './form/style/index.mjs'
|
|
204
207
|
import './form-details/style/index.mjs'
|
|
205
208
|
import './hover/style/index.mjs'
|
|
@@ -256,7 +259,7 @@ import './tooltip/style/index.mjs'
|
|
|
256
259
|
import './uploader/style/index.mjs'
|
|
257
260
|
import './watermark/style/index.mjs'
|
|
258
261
|
|
|
259
|
-
const version = '2.18.0-alpha.
|
|
262
|
+
const version = '2.18.0-alpha.1697555377370'
|
|
260
263
|
|
|
261
264
|
function install(app) {
|
|
262
265
|
ActionSheet.install && app.use(ActionSheet)
|
|
@@ -289,6 +292,7 @@ function install(app) {
|
|
|
289
292
|
Ellipsis.install && app.use(Ellipsis)
|
|
290
293
|
Fab.install && app.use(Fab)
|
|
291
294
|
FieldDecorator.install && app.use(FieldDecorator)
|
|
295
|
+
FloatingPanel.install && app.use(FloatingPanel)
|
|
292
296
|
Form.install && app.use(Form)
|
|
293
297
|
FormDetails.install && app.use(FormDetails)
|
|
294
298
|
Hover.install && app.use(Hover)
|
|
@@ -379,6 +383,7 @@ export {
|
|
|
379
383
|
Ellipsis,
|
|
380
384
|
Fab,
|
|
381
385
|
FieldDecorator,
|
|
386
|
+
FloatingPanel,
|
|
382
387
|
Form,
|
|
383
388
|
FormDetails,
|
|
384
389
|
Hover,
|
|
@@ -469,6 +474,7 @@ export default {
|
|
|
469
474
|
Ellipsis,
|
|
470
475
|
Fab,
|
|
471
476
|
FieldDecorator,
|
|
477
|
+
FloatingPanel,
|
|
472
478
|
Form,
|
|
473
479
|
FormDetails,
|
|
474
480
|
Hover,
|
package/es/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import Drag from './drag/index.mjs'
|
|
|
28
28
|
import Ellipsis from './ellipsis/index.mjs'
|
|
29
29
|
import Fab from './fab/index.mjs'
|
|
30
30
|
import FieldDecorator from './field-decorator/index.mjs'
|
|
31
|
+
import FloatingPanel from './floating-panel/index.mjs'
|
|
31
32
|
import Form from './form/index.mjs'
|
|
32
33
|
import FormDetails from './form-details/index.mjs'
|
|
33
34
|
import Hover from './hover/index.mjs'
|
|
@@ -114,6 +115,7 @@ export * from './drag/index.mjs'
|
|
|
114
115
|
export * from './ellipsis/index.mjs'
|
|
115
116
|
export * from './fab/index.mjs'
|
|
116
117
|
export * from './field-decorator/index.mjs'
|
|
118
|
+
export * from './floating-panel/index.mjs'
|
|
117
119
|
export * from './form/index.mjs'
|
|
118
120
|
export * from './form-details/index.mjs'
|
|
119
121
|
export * from './hover/index.mjs'
|
|
@@ -170,7 +172,7 @@ export * from './tooltip/index.mjs'
|
|
|
170
172
|
export * from './uploader/index.mjs'
|
|
171
173
|
export * from './watermark/index.mjs'
|
|
172
174
|
|
|
173
|
-
const version = '2.18.0-alpha.
|
|
175
|
+
const version = '2.18.0-alpha.1697555377370'
|
|
174
176
|
|
|
175
177
|
function install(app) {
|
|
176
178
|
ActionSheet.install && app.use(ActionSheet)
|
|
@@ -203,6 +205,7 @@ function install(app) {
|
|
|
203
205
|
Ellipsis.install && app.use(Ellipsis)
|
|
204
206
|
Fab.install && app.use(Fab)
|
|
205
207
|
FieldDecorator.install && app.use(FieldDecorator)
|
|
208
|
+
FloatingPanel.install && app.use(FloatingPanel)
|
|
206
209
|
Form.install && app.use(Form)
|
|
207
210
|
FormDetails.install && app.use(FormDetails)
|
|
208
211
|
Hover.install && app.use(Hover)
|
|
@@ -293,6 +296,7 @@ export {
|
|
|
293
296
|
Ellipsis,
|
|
294
297
|
Fab,
|
|
295
298
|
FieldDecorator,
|
|
299
|
+
FloatingPanel,
|
|
296
300
|
Form,
|
|
297
301
|
FormDetails,
|
|
298
302
|
Hover,
|
|
@@ -383,6 +387,7 @@ export default {
|
|
|
383
387
|
Ellipsis,
|
|
384
388
|
Fab,
|
|
385
389
|
FieldDecorator,
|
|
390
|
+
FloatingPanel,
|
|
386
391
|
Form,
|
|
387
392
|
FormDetails,
|
|
388
393
|
Hover,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../styles/common.css'
|
|
2
|
-
import '../SnackbarSfc.css'
|
|
3
2
|
import '../../styles/elevation.css'
|
|
4
3
|
import '../../loading/loading.css'
|
|
5
4
|
import '../../button/button.css'
|
|
6
5
|
import '../../icon/icon.css'
|
|
7
6
|
import '../snackbar.css'
|
|
8
7
|
import '../coreSfc.css'
|
|
8
|
+
import '../SnackbarSfc.css'
|