@v-c/overflow 0.0.1 → 1.0.0
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/dist/Item.cjs +89 -108
- package/dist/Item.js +85 -106
- package/dist/Overflow.cjs +266 -314
- package/dist/Overflow.js +262 -312
- package/dist/RawItem.cjs +29 -46
- package/dist/RawItem.js +27 -45
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/context.cjs +12 -19
- package/dist/context.js +11 -20
- package/dist/hooks/channelUpdate.cjs +9 -10
- package/dist/hooks/channelUpdate.js +7 -10
- package/dist/hooks/useEffectState.cjs +26 -31
- package/dist/hooks/useEffectState.js +24 -32
- package/dist/index.cjs +6 -6
- package/dist/index.js +3 -5
- package/package.json +5 -4
package/dist/RawItem.cjs
CHANGED
|
@@ -1,47 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
className: contextClassName,
|
|
30
|
-
...restContext
|
|
31
|
-
} = context$1.value;
|
|
32
|
-
const {
|
|
33
|
-
class: classAttr,
|
|
34
|
-
...restAttrs
|
|
35
|
-
} = attrs;
|
|
36
|
-
return vue.createVNode(context.OverflowContextProvider, {
|
|
37
|
-
"value": null
|
|
38
|
-
}, {
|
|
39
|
-
default: () => [vue.createVNode(Item.default, vue.mergeProps(restContext, restAttrs, {
|
|
40
|
-
"class": util.classNames(contextClassName, classAttr),
|
|
41
|
-
"component": props.component
|
|
42
|
-
}), slots)]
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
}
|
|
1
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
2
|
+
const require_context = require("./context.cjs");
|
|
3
|
+
const require_Item = require("./Item.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
let __v_c_util = require("@v-c/util");
|
|
6
|
+
var RawItem_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
7
|
+
name: "OverflowRawItem",
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: { component: {
|
|
10
|
+
type: [
|
|
11
|
+
String,
|
|
12
|
+
Object,
|
|
13
|
+
Function
|
|
14
|
+
],
|
|
15
|
+
default: "div"
|
|
16
|
+
} },
|
|
17
|
+
setup(props, { slots, attrs }) {
|
|
18
|
+
const context = require_context.useInjectOverflowContext();
|
|
19
|
+
return () => {
|
|
20
|
+
if (!context?.value) return (0, vue.createVNode)(props.component ?? "div", attrs, { default: () => [slots.default?.()] });
|
|
21
|
+
const { className: contextClassName,...restContext } = context.value;
|
|
22
|
+
const { class: classAttr,...restAttrs } = attrs;
|
|
23
|
+
return (0, vue.createVNode)(require_context.OverflowContextProvider, { "value": null }, { default: () => [(0, vue.createVNode)(require_Item.default, (0, vue.mergeProps)(restContext, restAttrs, {
|
|
24
|
+
"class": (0, __v_c_util.classNames)(contextClassName, classAttr),
|
|
25
|
+
"component": props.component
|
|
26
|
+
}), slots)] });
|
|
27
|
+
};
|
|
28
|
+
}
|
|
46
29
|
});
|
|
47
|
-
exports.default =
|
|
30
|
+
exports.default = RawItem_default;
|
package/dist/RawItem.js
CHANGED
|
@@ -1,47 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OverflowContextProvider, useInjectOverflowContext } from "./context.js";
|
|
2
|
+
import Item_default from "./Item.js";
|
|
3
|
+
import { createVNode, defineComponent, mergeProps } from "vue";
|
|
2
4
|
import { classNames } from "@v-c/util";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
className: contextClassName,
|
|
28
|
-
...restContext
|
|
29
|
-
} = context.value;
|
|
30
|
-
const {
|
|
31
|
-
class: classAttr,
|
|
32
|
-
...restAttrs
|
|
33
|
-
} = attrs;
|
|
34
|
-
return createVNode(OverflowContextProvider, {
|
|
35
|
-
"value": null
|
|
36
|
-
}, {
|
|
37
|
-
default: () => [createVNode(Item, mergeProps(restContext, restAttrs, {
|
|
38
|
-
"class": classNames(contextClassName, classAttr),
|
|
39
|
-
"component": props.component
|
|
40
|
-
}), slots)]
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
}
|
|
5
|
+
var RawItem_default = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "OverflowRawItem",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: { component: {
|
|
9
|
+
type: [
|
|
10
|
+
String,
|
|
11
|
+
Object,
|
|
12
|
+
Function
|
|
13
|
+
],
|
|
14
|
+
default: "div"
|
|
15
|
+
} },
|
|
16
|
+
setup(props, { slots, attrs }) {
|
|
17
|
+
const context = useInjectOverflowContext();
|
|
18
|
+
return () => {
|
|
19
|
+
if (!context?.value) return createVNode(props.component ?? "div", attrs, { default: () => [slots.default?.()] });
|
|
20
|
+
const { className: contextClassName,...restContext } = context.value;
|
|
21
|
+
const { class: classAttr,...restAttrs } = attrs;
|
|
22
|
+
return createVNode(OverflowContextProvider, { "value": null }, { default: () => [createVNode(Item_default, mergeProps(restContext, restAttrs, {
|
|
23
|
+
"class": classNames(contextClassName, classAttr),
|
|
24
|
+
"component": props.component
|
|
25
|
+
}), slots)] });
|
|
26
|
+
};
|
|
27
|
+
}
|
|
44
28
|
});
|
|
45
|
-
export {
|
|
46
|
-
RawItem as default
|
|
47
|
-
};
|
|
29
|
+
export { RawItem_default as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
9
|
+
key = keys[i];
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: ((k) => from[k]).bind(null, key),
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
value: mod,
|
|
19
|
+
enumerable: true
|
|
20
|
+
}) : target, mod));
|
|
21
|
+
exports.__toESM = __toESM;
|
package/dist/context.cjs
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
setup(props, {
|
|
14
|
-
slots
|
|
15
|
-
}) {
|
|
16
|
-
vue.provide(OverflowContextKey, vue.computed(() => props.value));
|
|
17
|
-
return () => slots.default?.();
|
|
18
|
-
}
|
|
1
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
var OverflowContextKey = Symbol("OverflowContext");
|
|
4
|
+
const OverflowContextProvider = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
5
|
+
name: "OverflowContextProvider",
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
props: { value: { type: Object } },
|
|
8
|
+
setup(props, { slots }) {
|
|
9
|
+
(0, vue.provide)(OverflowContextKey, (0, vue.computed)(() => props.value));
|
|
10
|
+
return () => slots.default?.();
|
|
11
|
+
}
|
|
19
12
|
});
|
|
20
13
|
function useInjectOverflowContext() {
|
|
21
|
-
|
|
14
|
+
return (0, vue.inject)(OverflowContextKey, null);
|
|
22
15
|
}
|
|
23
16
|
exports.OverflowContextProvider = OverflowContextProvider;
|
|
24
17
|
exports.useInjectOverflowContext = useInjectOverflowContext;
|
package/dist/context.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import { defineComponent, inject, provide
|
|
2
|
-
|
|
1
|
+
import { computed, defineComponent, inject, provide } from "vue";
|
|
2
|
+
var OverflowContextKey = Symbol("OverflowContext");
|
|
3
3
|
const OverflowContextProvider = /* @__PURE__ */ defineComponent({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
setup(props, {
|
|
12
|
-
slots
|
|
13
|
-
}) {
|
|
14
|
-
provide(OverflowContextKey, computed(() => props.value));
|
|
15
|
-
return () => slots.default?.();
|
|
16
|
-
}
|
|
4
|
+
name: "OverflowContextProvider",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: { value: { type: Object } },
|
|
7
|
+
setup(props, { slots }) {
|
|
8
|
+
provide(OverflowContextKey, computed(() => props.value));
|
|
9
|
+
return () => slots.default?.();
|
|
10
|
+
}
|
|
17
11
|
});
|
|
18
12
|
function useInjectOverflowContext() {
|
|
19
|
-
|
|
13
|
+
return inject(OverflowContextKey, null);
|
|
20
14
|
}
|
|
21
|
-
export {
|
|
22
|
-
OverflowContextProvider,
|
|
23
|
-
useInjectOverflowContext
|
|
24
|
-
};
|
|
15
|
+
export { OverflowContextProvider, useInjectOverflowContext };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
2
|
+
let __v_c_util_dist_raf = require("@v-c/util/dist/raf");
|
|
3
|
+
__v_c_util_dist_raf = require_rolldown_runtime.__toESM(__v_c_util_dist_raf);
|
|
4
4
|
function channelUpdate(callback) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
5
|
+
if (typeof MessageChannel === "undefined") (0, __v_c_util_dist_raf.default)(callback);
|
|
6
|
+
else {
|
|
7
|
+
const channel = new MessageChannel();
|
|
8
|
+
channel.port1.onmessage = () => callback();
|
|
9
|
+
channel.port2.postMessage(void 0);
|
|
10
|
+
}
|
|
12
11
|
}
|
|
13
12
|
exports.default = channelUpdate;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import raf from "@v-c/util/dist/raf";
|
|
2
2
|
function channelUpdate(callback) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
3
|
+
if (typeof MessageChannel === "undefined") raf(callback);
|
|
4
|
+
else {
|
|
5
|
+
const channel = new MessageChannel();
|
|
6
|
+
channel.port1.onmessage = () => callback();
|
|
7
|
+
channel.port2.postMessage(void 0);
|
|
8
|
+
}
|
|
10
9
|
}
|
|
11
|
-
export {
|
|
12
|
-
channelUpdate as default
|
|
13
|
-
};
|
|
10
|
+
export { channelUpdate as default };
|
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
2
|
+
const require_channelUpdate = require("./channelUpdate.cjs");
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
let __v_c_util_dist_hooks_useEvent = require("@v-c/util/dist/hooks/useEvent");
|
|
5
|
+
__v_c_util_dist_hooks_useEvent = require_rolldown_runtime.__toESM(__v_c_util_dist_hooks_useEvent);
|
|
6
6
|
function useBatcher() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const updateFuncRef = (0, vue.ref)(null);
|
|
8
|
+
const notifyEffectUpdate = (callback) => {
|
|
9
|
+
if (!updateFuncRef.value) {
|
|
10
|
+
updateFuncRef.value = [];
|
|
11
|
+
require_channelUpdate.default(() => {
|
|
12
|
+
updateFuncRef.value.forEach((fn) => {
|
|
13
|
+
fn();
|
|
14
|
+
});
|
|
15
|
+
updateFuncRef.value = null;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
updateFuncRef.value.push(callback);
|
|
19
|
+
};
|
|
20
|
+
return notifyEffectUpdate;
|
|
21
21
|
}
|
|
22
22
|
function useEffectState(notifyEffectUpdate, defaultValue) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
stateValue.value = nextValue;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
return [stateValue, setEffectVal];
|
|
23
|
+
const stateValue = (0, vue.ref)(defaultValue);
|
|
24
|
+
return [stateValue, (0, __v_c_util_dist_hooks_useEvent.default)((nextValue) => {
|
|
25
|
+
notifyEffectUpdate(() => {
|
|
26
|
+
if (typeof nextValue === "function") stateValue.value = nextValue(stateValue.value);
|
|
27
|
+
else stateValue.value = nextValue;
|
|
28
|
+
});
|
|
29
|
+
})];
|
|
35
30
|
}
|
|
36
31
|
exports.default = useEffectState;
|
|
37
32
|
exports.useBatcher = useBatcher;
|
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
import useEvent from "@v-c/util/dist/hooks/useEvent";
|
|
2
|
-
import { ref } from "vue";
|
|
3
1
|
import channelUpdate from "./channelUpdate.js";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import useEvent from "@v-c/util/dist/hooks/useEvent";
|
|
4
4
|
function useBatcher() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const updateFuncRef = ref(null);
|
|
6
|
+
const notifyEffectUpdate = (callback) => {
|
|
7
|
+
if (!updateFuncRef.value) {
|
|
8
|
+
updateFuncRef.value = [];
|
|
9
|
+
channelUpdate(() => {
|
|
10
|
+
updateFuncRef.value.forEach((fn) => {
|
|
11
|
+
fn();
|
|
12
|
+
});
|
|
13
|
+
updateFuncRef.value = null;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
updateFuncRef.value.push(callback);
|
|
17
|
+
};
|
|
18
|
+
return notifyEffectUpdate;
|
|
19
19
|
}
|
|
20
20
|
function useEffectState(notifyEffectUpdate, defaultValue) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
stateValue.value = nextValue;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
return [stateValue, setEffectVal];
|
|
21
|
+
const stateValue = ref(defaultValue);
|
|
22
|
+
return [stateValue, useEvent((nextValue) => {
|
|
23
|
+
notifyEffectUpdate(() => {
|
|
24
|
+
if (typeof nextValue === "function") stateValue.value = nextValue(stateValue.value);
|
|
25
|
+
else stateValue.value = nextValue;
|
|
26
|
+
});
|
|
27
|
+
})];
|
|
33
28
|
}
|
|
34
|
-
export {
|
|
35
|
-
useEffectState as default,
|
|
36
|
-
useBatcher
|
|
37
|
-
};
|
|
29
|
+
export { useEffectState as default, useBatcher };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_context = require("./context.cjs");
|
|
3
|
+
const require_Overflow = require("./Overflow.cjs");
|
|
4
|
+
var src_default = require_Overflow.default;
|
|
5
|
+
exports.OverflowContextProvider = require_context.OverflowContextProvider;
|
|
6
|
+
exports.default = src_default;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import Overflow from "./Overflow.js";
|
|
2
1
|
import { OverflowContextProvider } from "./context.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
2
|
+
import Overflow_default from "./Overflow.js";
|
|
3
|
+
var src_default = Overflow_default;
|
|
4
|
+
export { OverflowContextProvider, src_default as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/overflow",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "overflow",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -24,13 +24,14 @@
|
|
|
24
24
|
"vue": "^3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@v-c/resize-observer": "0.0
|
|
28
|
-
"@v-c/util": "0.0
|
|
27
|
+
"@v-c/resize-observer": "^1.0.0",
|
|
28
|
+
"@v-c/util": "^1.0.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "vite build",
|
|
32
32
|
"prepublish": "pnpm build",
|
|
33
33
|
"test": "vitest run",
|
|
34
|
-
"bump": "bumpp
|
|
34
|
+
"bump": "bumpp",
|
|
35
|
+
"bump:patch": "bumpp --release patch"
|
|
35
36
|
}
|
|
36
37
|
}
|