@hoci/core 0.9.0 → 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/LICENSE +1 -1
- package/README.md +67 -0
- package/README.zh-CN.md +67 -0
- package/dist/{chunk-DzK395Rf.js → chunk-zc3tnsvq.js} +3 -3
- package/dist/index.d.ts +75 -73
- package/dist/index.js +9 -6
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @hoci/core
|
|
2
|
+
|
|
3
|
+
[中文](README.zh-CN.md) | English
|
|
4
|
+
|
|
5
|
+
Core composables, props, emits, and types for [hoci](../hoci/README.md). **No Vue components** — use [@hoci/components](../components/README.md) for ready-made components. Built on Vue 3 and [@vueuse/core](https://vueuse.org/).
|
|
6
|
+
|
|
7
|
+
> **💡 Recommendation:** For most use cases, we recommend using the **hoci** package instead of directly installing `@hoci/core`. The **hoci** package provides a unified entry point with components, composables, and auto-import resolver.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @hoci/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Peer dependencies:** Vue 3.3+, [@vueuse/core](https://vueuse.org/) 10.5+.
|
|
16
|
+
|
|
17
|
+
## Composables API
|
|
18
|
+
|
|
19
|
+
| Composable | Returns | Description |
|
|
20
|
+
|------------|---------|-------------|
|
|
21
|
+
| **useAffix** | `{ className, wrapperRef, isFixed, placeholderStyle, fixedStyle, updatePosition }` | Pin content to viewport or target while scrolling. Returns fixed state, styles, and refs. |
|
|
22
|
+
| **useFileUpload** | `{ inputRef, files, handleChange, handleDrop, handleDragOver }` | File input with drag-and-drop. Returns file list and handlers. |
|
|
23
|
+
| **useIcon** | `{ style }` | Icon logic (size, color, mask). Returns computed styles. |
|
|
24
|
+
| **useSelectionItem** | `{ isActive, activate, reject, className }` | Selectable list item logic. Returns active state and handlers. |
|
|
25
|
+
| **usePopover** | `{ visible, show, close, popupRef, triggerRef, placement, offset }` | Floating panel with placement control. Returns visibility state and refs. |
|
|
26
|
+
| **useSelectionList** | `{ options, actives, isActive, changeActive, renderItem, render }` | Single/multi selection state management. Returns selection state and render function. |
|
|
27
|
+
| **useSelectionContext** | `HiSelectionContext` | Inject selection context from parent HiSelection. Returns context with activate, isActive, etc. |
|
|
28
|
+
| **useSwitch** | `{ toggle, modelValue, className, isDisabled, activateEvent }` | Toggle switch logic. Returns state and toggle handler. |
|
|
29
|
+
| **useVirtualList** | `{ virtualizer, scrollToIndex, scrollToOffset }` | Virtualized list for large data. Returns virtualizer instance and scroll methods. |
|
|
30
|
+
|
|
31
|
+
## Props & Emits
|
|
32
|
+
|
|
33
|
+
| Area | Props | Emits | Description |
|
|
34
|
+
|------|-------|-------|-------------|
|
|
35
|
+
| **Affix** | `affixProps` | `affixEmits` | Fixed positioning props (offset, position, target, zIndex) and events (scroll, change) |
|
|
36
|
+
| **ConfigProvider** | `configProviderProps` | - | Global config props (icon, activateEvent) |
|
|
37
|
+
| **FileUpload** | `fileUploadProps` | `fileUploadEmits` | File selection props (modelValue, multiple) and events (update:modelValue, change) |
|
|
38
|
+
| **Icon** | `iconProps` | - | Icon props (src, size, width, height, color, mask) |
|
|
39
|
+
| **Item** | `itemProps` | `itemEmits` | Selection item props (value, disabled) and events (reject) |
|
|
40
|
+
| **Popover** | `popoverProps` | `popoverEmits` | Popover props (placement, triggerEvent, offset, visible) and events (update:visible, change) |
|
|
41
|
+
| **Selection** | `selectionProps` | `selectionEmits` | Selection props (modelValue, multiple, activeClass, itemClass) and events (update:modelValue, change) |
|
|
42
|
+
| **Switch** | `switchProps` | `switchEmits` | Switch props (modelValue, activeClass, disabled) and events (update:modelValue, change, reject) |
|
|
43
|
+
| **VirtualList** | `virtualListProps` | `virtualListEmits` | Virtual list props (count, estimateSize, options) and events (scroll, scrollStart, scrollEnd) |
|
|
44
|
+
|
|
45
|
+
## Utilities
|
|
46
|
+
|
|
47
|
+
| Export | Description |
|
|
48
|
+
|--------|-------------|
|
|
49
|
+
| **provideAffixTarget** | Provide affix target element for child components |
|
|
50
|
+
| **AFFIX_TARGET_KEY** | Injection key for affix target context |
|
|
51
|
+
|
|
52
|
+
Shared types, composables (e.g. `useShowable`), and utilities are re-exported from [@hoci/shared](../shared/README.md).
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
Use composables to build your own templates; for pre-built Vue components, use **@hoci/components** or **hoci**.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { selectionEmits, selectionProps, useSelectionList } from "@hoci/core";
|
|
60
|
+
|
|
61
|
+
// Use in your own component
|
|
62
|
+
const { isActive, changeActive, render } = useSelectionList(props, { emit, slots });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @hoci/core
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
[hoci](../hoci/README.zh-CN.md) 的核心组合式函数、props、emits 与类型。**不提供 Vue 组件** — 即用型组件请使用 [@hoci/components](../components/README.zh-CN.md)。基于 Vue 3 与 [@vueuse/core](https://vueuse.org/)。
|
|
6
|
+
|
|
7
|
+
> **💡 推荐:** 大多数场景下,我们推荐使用 **hoci** 主包,而不是直接安装 `@hoci/core`。**hoci** 包提供了统一的入口,包含组件、组合式函数和自动导入解析器。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @hoci/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**依赖要求:** Vue 3.3+、[@vueuse/core](https://vueuse.org/) 10.5+。
|
|
16
|
+
|
|
17
|
+
## 组合式函数 API
|
|
18
|
+
|
|
19
|
+
| 组合式函数 | 返回值 | 说明 |
|
|
20
|
+
|------------|--------|------|
|
|
21
|
+
| **useAffix** | `{ className, wrapperRef, isFixed, placeholderStyle, fixedStyle, updatePosition }` | 滚动时将内容固定在视口或目标。返回固定状态、样式和引用。 |
|
|
22
|
+
| **useFileUpload** | `{ inputRef, files, handleChange, handleDrop, handleDragOver }` | 支持拖拽的文件上传。返回文件列表和处理函数。 |
|
|
23
|
+
| **useIcon** | `{ style }` | 图标逻辑(尺寸、颜色、遮罩)。返回计算后的样式。 |
|
|
24
|
+
| **useSelectionItem** | `{ isActive, activate, reject, className }` | 可选项逻辑。返回激活状态和处理函数。 |
|
|
25
|
+
| **usePopover** | `{ visible, show, close, popupRef, triggerRef, placement, offset }` | 可控制位置的浮动面板。返回可见性状态和引用。 |
|
|
26
|
+
| **useSelectionList** | `{ options, actives, isActive, changeActive, renderItem, render }` | 单选/多选状态管理。返回选择状态和渲染函数。 |
|
|
27
|
+
| **useSelectionContext** | `HiSelectionContext` | 从父级 HiSelection 注入选择上下文。返回包含 activate、isActive 等的上下文。 |
|
|
28
|
+
| **useSwitch** | `{ toggle, modelValue, className, isDisabled, activateEvent }` | 开关逻辑。返回状态和切换处理函数。 |
|
|
29
|
+
| **useVirtualList** | `{ virtualizer, scrollToIndex, scrollToOffset }` | 大列表虚拟滚动。返回虚拟化实例和滚动方法。 |
|
|
30
|
+
|
|
31
|
+
## Props 与 Emits
|
|
32
|
+
|
|
33
|
+
| 模块 | Props | Emits | 说明 |
|
|
34
|
+
|------|-------|-------|------|
|
|
35
|
+
| **Affix** | `affixProps` | `affixEmits` | 固定定位属性(offset、position、target、zIndex)和事件(scroll、change) |
|
|
36
|
+
| **ConfigProvider** | `configProviderProps` | - | 全局配置属性(icon、activateEvent) |
|
|
37
|
+
| **FileUpload** | `fileUploadProps` | `fileUploadEmits` | 文件选择属性(modelValue、multiple)和事件(update:modelValue、change) |
|
|
38
|
+
| **Icon** | `iconProps` | - | 图标属性(src、size、width、height、color、mask) |
|
|
39
|
+
| **Item** | `itemProps` | `itemEmits` | 选择项属性(value、disabled)和事件(reject) |
|
|
40
|
+
| **Popover** | `popoverProps` | `popoverEmits` | 浮动面板属性(placement、triggerEvent、offset、visible)和事件(update:visible、change) |
|
|
41
|
+
| **Selection** | `selectionProps` | `selectionEmits` | 选择属性(modelValue、multiple、activeClass、itemClass)和事件(update:modelValue、change) |
|
|
42
|
+
| **Switch** | `switchProps` | `switchEmits` | 开关属性(modelValue、activeClass、disabled)和事件(update:modelValue、change、reject) |
|
|
43
|
+
| **VirtualList** | `virtualListProps` | `virtualListEmits` | 虚拟列表属性(count、estimateSize、options)和事件(scroll、scrollStart、scrollEnd) |
|
|
44
|
+
|
|
45
|
+
## 工具函数
|
|
46
|
+
|
|
47
|
+
| 导出 | 说明 |
|
|
48
|
+
|------|------|
|
|
49
|
+
| **provideAffixTarget** | 为子组件提供 affix 目标元素 |
|
|
50
|
+
| **AFFIX_TARGET_KEY** | Affix 目标上下文的注入键 |
|
|
51
|
+
|
|
52
|
+
类型、组合式函数(如 `useShowable`)与工具由 [@hoci/shared](../shared/README.zh-CN.md) 重新导出。
|
|
53
|
+
|
|
54
|
+
## 使用方式
|
|
55
|
+
|
|
56
|
+
基于组合式函数进行二次组件开发;若需要现成 Vue 组件,请使用 **@hoci/components** 或 **hoci**。
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { selectionEmits, selectionProps, useSelectionList } from "@hoci/core";
|
|
60
|
+
|
|
61
|
+
// 在你自己的组件中使用
|
|
62
|
+
const { isActive, changeActive, render } = useSelectionList(props, { emit, slots });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 许可
|
|
66
|
+
|
|
67
|
+
MIT
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __exportAll = (all,
|
|
6
|
+
var __exportAll = (all, no_symbols) => {
|
|
7
7
|
let target = {};
|
|
8
8
|
for (var name in all) {
|
|
9
9
|
__defProp(target, name, {
|
|
@@ -11,7 +11,7 @@ var __exportAll = (all, symbols) => {
|
|
|
11
11
|
enumerable: true
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
if (
|
|
14
|
+
if (!no_symbols) {
|
|
15
15
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
16
|
}
|
|
17
17
|
return target;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./chunk-
|
|
2
|
-
import * as
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-zc3tnsvq.js";
|
|
2
|
+
import * as _hoci_shared0 from "@hoci/shared";
|
|
3
3
|
import { ActivateEvent, ElementLike, SharedConfig } from "@hoci/shared";
|
|
4
4
|
import { CSSProperties } from "tslx";
|
|
5
|
-
import * as
|
|
5
|
+
import * as vue from "vue";
|
|
6
6
|
import { CSSProperties as CSSProperties$1, InjectionKey, MaybeRefOrGetter, PropType, Ref } from "vue";
|
|
7
7
|
import { PartialKeys, ScrollToOptions, VirtualItem, Virtualizer, VirtualizerOptions as VirtualizerOptions$1 } from "@tanstack/virtual-core";
|
|
8
8
|
export * from "@hoci/shared";
|
|
@@ -47,15 +47,15 @@ declare const affixProps: {
|
|
|
47
47
|
type AffixProps = typeof affixProps;
|
|
48
48
|
declare const affixEmits: ("scroll" | "change")[];
|
|
49
49
|
declare const AFFIX_TARGET_KEY: InjectionKey<MaybeRefOrGetter<Element | null | undefined>>;
|
|
50
|
-
declare const useAffix:
|
|
51
|
-
className:
|
|
52
|
-
wrapperRef:
|
|
53
|
-
containerRef:
|
|
50
|
+
declare const useAffix: _hoci_shared0.HookComponent<{
|
|
51
|
+
className: vue.ComputedRef<string>;
|
|
52
|
+
wrapperRef: _hoci_shared0.ElementRef<HTMLElement>;
|
|
53
|
+
containerRef: vue.ComputedRef<Element | (Window & typeof globalThis) | null>;
|
|
54
54
|
isFixed: Ref<boolean, boolean>;
|
|
55
55
|
placeholderStyle: Ref<CSSProperties, CSSProperties>;
|
|
56
56
|
fixedStyle: Ref<CSSProperties, CSSProperties>;
|
|
57
|
-
updatePosition:
|
|
58
|
-
},
|
|
57
|
+
updatePosition: _hoci_shared0.ThrottledCancelableFn<[]>;
|
|
58
|
+
}, vue.EmitsOptions, {
|
|
59
59
|
fixedClass: {
|
|
60
60
|
type: StringConstructor;
|
|
61
61
|
default: string;
|
|
@@ -90,7 +90,7 @@ declare const useAffix: _hoci_shared10.HookComponent<{
|
|
|
90
90
|
type: NumberConstructor;
|
|
91
91
|
default: number;
|
|
92
92
|
};
|
|
93
|
-
},
|
|
93
|
+
}, vue.ExtractPropTypes<{
|
|
94
94
|
fixedClass: {
|
|
95
95
|
type: StringConstructor;
|
|
96
96
|
default: string;
|
|
@@ -126,10 +126,10 @@ declare const useAffix: _hoci_shared10.HookComponent<{
|
|
|
126
126
|
default: number;
|
|
127
127
|
};
|
|
128
128
|
}>, {
|
|
129
|
-
position: "bottom" | "top";
|
|
130
|
-
zIndex: number;
|
|
131
|
-
offset: number;
|
|
132
129
|
fixedClass: string;
|
|
130
|
+
offset: number;
|
|
131
|
+
position: "top" | "bottom";
|
|
132
|
+
zIndex: number;
|
|
133
133
|
}>;
|
|
134
134
|
declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
|
|
135
135
|
//#endregion
|
|
@@ -154,14 +154,14 @@ declare const fileUploadProps: {
|
|
|
154
154
|
default: boolean;
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
|
-
declare const fileUploadEmits: ("
|
|
157
|
+
declare const fileUploadEmits: ("change" | "update:modelValue")[];
|
|
158
158
|
type HiFileUploadProps = typeof fileUploadProps;
|
|
159
159
|
interface HiFileUploadSlotData {
|
|
160
160
|
files: File[];
|
|
161
161
|
}
|
|
162
|
-
declare const useFileUpload:
|
|
163
|
-
fileInputRef:
|
|
164
|
-
files:
|
|
162
|
+
declare const useFileUpload: _hoci_shared0.HookComponent<{
|
|
163
|
+
fileInputRef: _hoci_shared0.ElementRef<HTMLInputElement>;
|
|
164
|
+
files: vue.Ref<{
|
|
165
165
|
readonly lastModified: number;
|
|
166
166
|
readonly name: string;
|
|
167
167
|
readonly webkitRelativePath: string;
|
|
@@ -185,7 +185,7 @@ declare const useFileUpload: _hoci_shared10.HookComponent<{
|
|
|
185
185
|
text: () => Promise<string>;
|
|
186
186
|
}[]>;
|
|
187
187
|
openFileInput: () => void;
|
|
188
|
-
}, ("
|
|
188
|
+
}, ("change" | "update:modelValue")[], {
|
|
189
189
|
modelValue: {
|
|
190
190
|
type: PropType<File | File[]>;
|
|
191
191
|
default: () => never[];
|
|
@@ -194,7 +194,7 @@ declare const useFileUpload: _hoci_shared10.HookComponent<{
|
|
|
194
194
|
type: BooleanConstructor;
|
|
195
195
|
default: boolean;
|
|
196
196
|
};
|
|
197
|
-
},
|
|
197
|
+
}, vue.ExtractPropTypes<{
|
|
198
198
|
modelValue: {
|
|
199
199
|
type: PropType<File | File[]>;
|
|
200
200
|
default: () => never[];
|
|
@@ -204,8 +204,8 @@ declare const useFileUpload: _hoci_shared10.HookComponent<{
|
|
|
204
204
|
default: boolean;
|
|
205
205
|
};
|
|
206
206
|
}>, {
|
|
207
|
-
multiple: boolean;
|
|
208
207
|
modelValue: File | File[];
|
|
208
|
+
multiple: boolean;
|
|
209
209
|
}>;
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region src/icon/index.d.ts
|
|
@@ -215,13 +215,13 @@ declare const iconProps: {
|
|
|
215
215
|
required: true;
|
|
216
216
|
};
|
|
217
217
|
size: {
|
|
218
|
-
type: (
|
|
218
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
219
219
|
};
|
|
220
220
|
width: {
|
|
221
|
-
type: (
|
|
221
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
222
222
|
};
|
|
223
223
|
height: {
|
|
224
|
-
type: (
|
|
224
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
225
225
|
};
|
|
226
226
|
color: {
|
|
227
227
|
type: StringConstructor;
|
|
@@ -233,21 +233,21 @@ declare const iconProps: {
|
|
|
233
233
|
};
|
|
234
234
|
};
|
|
235
235
|
type HiIconProps = typeof iconProps;
|
|
236
|
-
declare const useIcon:
|
|
237
|
-
style:
|
|
238
|
-
},
|
|
236
|
+
declare const useIcon: _hoci_shared0.HookComponent<{
|
|
237
|
+
style: vue.ComputedRef<CSSProperties$1>;
|
|
238
|
+
}, vue.EmitsOptions, {
|
|
239
239
|
src: {
|
|
240
240
|
type: StringConstructor;
|
|
241
241
|
required: true;
|
|
242
242
|
};
|
|
243
243
|
size: {
|
|
244
|
-
type: (
|
|
244
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
245
245
|
};
|
|
246
246
|
width: {
|
|
247
|
-
type: (
|
|
247
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
248
248
|
};
|
|
249
249
|
height: {
|
|
250
|
-
type: (
|
|
250
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
251
251
|
};
|
|
252
252
|
color: {
|
|
253
253
|
type: StringConstructor;
|
|
@@ -257,19 +257,19 @@ declare const useIcon: _hoci_shared10.HookComponent<{
|
|
|
257
257
|
type: PropType<boolean | "auto">;
|
|
258
258
|
default: () => "auto";
|
|
259
259
|
};
|
|
260
|
-
},
|
|
260
|
+
}, vue.ExtractPropTypes<{
|
|
261
261
|
src: {
|
|
262
262
|
type: StringConstructor;
|
|
263
263
|
required: true;
|
|
264
264
|
};
|
|
265
265
|
size: {
|
|
266
|
-
type: (
|
|
266
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
267
267
|
};
|
|
268
268
|
width: {
|
|
269
|
-
type: (
|
|
269
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
270
270
|
};
|
|
271
271
|
height: {
|
|
272
|
-
type: (
|
|
272
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
273
273
|
};
|
|
274
274
|
color: {
|
|
275
275
|
type: StringConstructor;
|
|
@@ -306,14 +306,14 @@ declare const itemProps: {
|
|
|
306
306
|
};
|
|
307
307
|
};
|
|
308
308
|
declare const itemEmits: "reject"[];
|
|
309
|
-
declare const useSelectionItem:
|
|
309
|
+
declare const useSelectionItem: _hoci_shared0.HookComponent<{
|
|
310
310
|
activate: () => void;
|
|
311
311
|
render: () => ElementLike;
|
|
312
|
-
isActive:
|
|
313
|
-
isDisabled:
|
|
314
|
-
className:
|
|
315
|
-
activateEvent:
|
|
316
|
-
label:
|
|
312
|
+
isActive: vue.ComputedRef<boolean>;
|
|
313
|
+
isDisabled: vue.ComputedRef<boolean>;
|
|
314
|
+
className: vue.ComputedRef<string>;
|
|
315
|
+
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
316
|
+
label: vue.ComputedRef<ElementLike[] | (string | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
317
317
|
[key: string]: any;
|
|
318
318
|
}> | null | undefined)[]>;
|
|
319
319
|
}, "reject"[], {
|
|
@@ -335,7 +335,7 @@ declare const useSelectionItem: _hoci_shared10.HookComponent<{
|
|
|
335
335
|
type: BooleanConstructor;
|
|
336
336
|
default: boolean;
|
|
337
337
|
};
|
|
338
|
-
},
|
|
338
|
+
}, vue.ExtractPropTypes<{
|
|
339
339
|
value: {
|
|
340
340
|
type: PropType<any>;
|
|
341
341
|
default(): string;
|
|
@@ -355,9 +355,9 @@ declare const useSelectionItem: _hoci_shared10.HookComponent<{
|
|
|
355
355
|
default: boolean;
|
|
356
356
|
};
|
|
357
357
|
}>, {
|
|
358
|
-
disabled: boolean;
|
|
359
358
|
value: any;
|
|
360
359
|
keepAlive: boolean;
|
|
360
|
+
disabled: boolean;
|
|
361
361
|
}>;
|
|
362
362
|
interface HiItemSlotsData {
|
|
363
363
|
active: boolean;
|
|
@@ -401,7 +401,9 @@ declare const popoverProps: {
|
|
|
401
401
|
};
|
|
402
402
|
};
|
|
403
403
|
declare const popoverEmits: ("change" | "update:visible")[];
|
|
404
|
-
declare const usePopover:
|
|
404
|
+
declare const usePopover: _hoci_shared0.HookComponent<{
|
|
405
|
+
show: (data?: any) => void;
|
|
406
|
+
close: (resultStatus?: _hoci_shared0.ShowableStatus) => void;
|
|
405
407
|
events: {
|
|
406
408
|
onMouseover: () => void;
|
|
407
409
|
onMouseout: () => void;
|
|
@@ -418,10 +420,10 @@ declare const usePopover: _hoci_shared10.HookComponent<{
|
|
|
418
420
|
x: number;
|
|
419
421
|
y: number;
|
|
420
422
|
};
|
|
421
|
-
triggerRef:
|
|
422
|
-
popupRef:
|
|
423
|
-
popupClass:
|
|
424
|
-
popupStyle:
|
|
423
|
+
triggerRef: _hoci_shared0.ElementRef<HTMLElement>;
|
|
424
|
+
popupRef: _hoci_shared0.ElementRef<HTMLElement>;
|
|
425
|
+
popupClass: vue.ComputedRef<string | undefined>;
|
|
426
|
+
popupStyle: vue.ComputedRef<{
|
|
425
427
|
left: string;
|
|
426
428
|
top: string;
|
|
427
429
|
visibility: string;
|
|
@@ -459,7 +461,7 @@ declare const usePopover: _hoci_shared10.HookComponent<{
|
|
|
459
461
|
type: PropType<string | HTMLElement | boolean>;
|
|
460
462
|
default: () => true;
|
|
461
463
|
};
|
|
462
|
-
},
|
|
464
|
+
}, vue.ExtractPropTypes<{
|
|
463
465
|
popupClass: {
|
|
464
466
|
type: StringConstructor;
|
|
465
467
|
};
|
|
@@ -492,12 +494,12 @@ declare const usePopover: _hoci_shared10.HookComponent<{
|
|
|
492
494
|
default: () => true;
|
|
493
495
|
};
|
|
494
496
|
}>, {
|
|
495
|
-
visible: boolean;
|
|
496
|
-
disabled: boolean;
|
|
497
497
|
offset: number;
|
|
498
|
+
disabled: boolean;
|
|
498
499
|
placement: Placement;
|
|
499
500
|
triggerEvent: TriggerEvent;
|
|
500
501
|
lazy: boolean;
|
|
502
|
+
visible: boolean;
|
|
501
503
|
teleport: string | boolean | HTMLElement;
|
|
502
504
|
}>;
|
|
503
505
|
//#endregion
|
|
@@ -580,18 +582,18 @@ declare const selectionProps: {
|
|
|
580
582
|
};
|
|
581
583
|
};
|
|
582
584
|
type SelectionProps = typeof selectionProps;
|
|
583
|
-
declare const selectionEmits: ("
|
|
585
|
+
declare const selectionEmits: ("change" | "reject" | "update:modelValue" | "load" | "unload")[];
|
|
584
586
|
declare function useSelectionContext(): HiSelectionContext;
|
|
585
|
-
declare const useSelectionList:
|
|
586
|
-
options:
|
|
587
|
+
declare const useSelectionList: _hoci_shared0.HookComponent<{
|
|
588
|
+
options: vue.Reactive<Option[]>;
|
|
587
589
|
actives: any[];
|
|
588
590
|
isActive: (value: any) => boolean;
|
|
589
591
|
changeActive: (value: any) => void;
|
|
590
592
|
renderItem: () => ElementLike;
|
|
591
|
-
render: () =>
|
|
593
|
+
render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
592
594
|
[key: string]: any;
|
|
593
595
|
}>;
|
|
594
|
-
}, ("
|
|
596
|
+
}, ("change" | "reject" | "update:modelValue" | "load" | "unload")[], {
|
|
595
597
|
modelValue: {
|
|
596
598
|
type: PropType<any>;
|
|
597
599
|
default: () => null;
|
|
@@ -641,7 +643,7 @@ declare const useSelectionList: _hoci_shared10.HookComponent<{
|
|
|
641
643
|
activateEvent: {
|
|
642
644
|
type: PropType<ActivateEvent>;
|
|
643
645
|
};
|
|
644
|
-
},
|
|
646
|
+
}, vue.ExtractPropTypes<{
|
|
645
647
|
modelValue: {
|
|
646
648
|
type: PropType<any>;
|
|
647
649
|
default: () => null;
|
|
@@ -692,14 +694,14 @@ declare const useSelectionList: _hoci_shared10.HookComponent<{
|
|
|
692
694
|
type: PropType<ActivateEvent>;
|
|
693
695
|
};
|
|
694
696
|
}>, {
|
|
695
|
-
multiple: number | boolean | [number, (number | undefined)?];
|
|
696
697
|
modelValue: any;
|
|
698
|
+
multiple: number | boolean | [number, (number | undefined)?];
|
|
697
699
|
activeClass: string | string[] | Record<string, boolean>;
|
|
698
|
-
itemClass: string | string[] | Record<string, boolean>;
|
|
699
|
-
disabledClass: string | string[] | Record<string, boolean>;
|
|
700
700
|
unactiveClass: string | string[] | Record<string, boolean>;
|
|
701
|
-
|
|
701
|
+
disabledClass: string | string[] | Record<string, boolean>;
|
|
702
702
|
defaultValue: any;
|
|
703
|
+
itemClass: string | string[] | Record<string, boolean>;
|
|
704
|
+
clearable: boolean;
|
|
703
705
|
}>;
|
|
704
706
|
interface HiSelectionSlotData extends Record<string, unknown> {
|
|
705
707
|
isActive: (value: any) => boolean;
|
|
@@ -734,14 +736,14 @@ declare const switchProps: {
|
|
|
734
736
|
};
|
|
735
737
|
};
|
|
736
738
|
type HiSwitchProps = typeof switchProps;
|
|
737
|
-
declare const switchEmits: ("
|
|
738
|
-
declare const useSwitch:
|
|
739
|
+
declare const switchEmits: ("change" | "reject" | "update:modelValue")[];
|
|
740
|
+
declare const useSwitch: _hoci_shared0.HookComponent<{
|
|
739
741
|
toggle: (value?: any) => void;
|
|
740
|
-
modelValue:
|
|
741
|
-
className:
|
|
742
|
-
isDisabled:
|
|
743
|
-
activateEvent:
|
|
744
|
-
}, ("
|
|
742
|
+
modelValue: vue.Ref<boolean, boolean>;
|
|
743
|
+
className: vue.ComputedRef<string>;
|
|
744
|
+
isDisabled: vue.ComputedRef<boolean>;
|
|
745
|
+
activateEvent: vue.ComputedRef<ActivateEvent>;
|
|
746
|
+
}, ("change" | "reject" | "update:modelValue")[], {
|
|
745
747
|
modelValue: {
|
|
746
748
|
type: BooleanConstructor;
|
|
747
749
|
default: () => false;
|
|
@@ -765,7 +767,7 @@ declare const useSwitch: _hoci_shared10.HookComponent<{
|
|
|
765
767
|
disabledClass: {
|
|
766
768
|
type: PropType<string | string[] | Record<string, boolean>>;
|
|
767
769
|
};
|
|
768
|
-
},
|
|
770
|
+
}, vue.ExtractPropTypes<{
|
|
769
771
|
modelValue: {
|
|
770
772
|
type: BooleanConstructor;
|
|
771
773
|
default: () => false;
|
|
@@ -822,12 +824,12 @@ declare const virtualListEmits: {
|
|
|
822
824
|
interface VirtualListSlotData extends VirtualItem, Record<string, unknown> {
|
|
823
825
|
style: CSSProperties$1;
|
|
824
826
|
}
|
|
825
|
-
declare const useVirtualList:
|
|
827
|
+
declare const useVirtualList: _hoci_shared0.HookComponent<{
|
|
826
828
|
virtualizer: Virtualizer<HTMLElement, HTMLElement>;
|
|
827
|
-
virtualItems:
|
|
828
|
-
virtualIndexes:
|
|
829
|
-
totalSize:
|
|
830
|
-
scrollElementRef:
|
|
829
|
+
virtualItems: vue.ComputedRef<VirtualItem[]>;
|
|
830
|
+
virtualIndexes: vue.ComputedRef<number[]>;
|
|
831
|
+
totalSize: vue.ComputedRef<number>;
|
|
832
|
+
scrollElementRef: _hoci_shared0.ElementRef<HTMLElement>;
|
|
831
833
|
measureElement: (el: HTMLElement | null) => void;
|
|
832
834
|
scrollToIndex: (index: number, options?: ScrollToOptions) => void;
|
|
833
835
|
scrollToStart: (options?: ScrollToOptions) => void;
|
|
@@ -853,7 +855,7 @@ declare const useVirtualList: _hoci_shared10.HookComponent<{
|
|
|
853
855
|
type: BooleanConstructor;
|
|
854
856
|
default: () => false;
|
|
855
857
|
};
|
|
856
|
-
},
|
|
858
|
+
}, vue.ExtractPropTypes<{
|
|
857
859
|
options: {
|
|
858
860
|
type: PropType<PartialKeys<VirtualizerOptions<HTMLElement, HTMLElement>, "observeElementRect" | "observeElementOffset" | "scrollToFn" | "getScrollElement">>;
|
|
859
861
|
default: () => {};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./chunk-
|
|
2
|
-
import { classPropType, defineHookComponent, defineHookEmits, defineHookProps, elementRef, getFirstChilld, isWindow, labelPropType, throttleByRaf, toArray,
|
|
3
|
-
import { isDefined, onClickOutside, syncRef, tryOnScopeDispose, useElementBounding, useElementVisibility, useEventListener, useVModel } from "@vueuse/core";
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-zc3tnsvq.js";
|
|
2
|
+
import { classPropType, defineHookComponent, defineHookEmits, defineHookProps, elementRef, getFirstChilld, isWindow, labelPropType, throttleByRaf, toArray, useElement, useSharedConfig, useShowableContextProvider, valuePropType } from "@hoci/shared";
|
|
3
|
+
import { isDefined, onClickOutside, syncRef, toReactive, tryOnScopeDispose, useElementBounding, useElementVisibility, useEventListener, useVModel } from "@vueuse/core";
|
|
4
4
|
import { cls, createUnitFormat, px } from "tslx";
|
|
5
5
|
import { computed, inject, nextTick, provide, reactive, ref, renderSlot, shallowRef, triggerRef, watch, watchPostEffect } from "vue";
|
|
6
6
|
import { Virtualizer, elementScroll, observeElementOffset, observeElementRect } from "@tanstack/virtual-core";
|
|
@@ -538,8 +538,9 @@ const popoverEmits = defineHookEmits(["update:visible", "change"]);
|
|
|
538
538
|
const usePopover = defineHookComponent({
|
|
539
539
|
props: popoverProps,
|
|
540
540
|
emits: popoverEmits,
|
|
541
|
-
setup(props,
|
|
542
|
-
const
|
|
541
|
+
setup(props, { emit }) {
|
|
542
|
+
const { show, close, visible } = useShowableContextProvider();
|
|
543
|
+
syncRef(visible, useVModel(props, "visible", emit, { passive: true }));
|
|
543
544
|
const triggerRef = elementRef();
|
|
544
545
|
const popupRef = elementRef();
|
|
545
546
|
const validate = (event) => {
|
|
@@ -550,7 +551,7 @@ const usePopover = defineHookComponent({
|
|
|
550
551
|
const toggle = (_value) => {
|
|
551
552
|
const value = _value ?? !visible.value;
|
|
552
553
|
visible.value = value;
|
|
553
|
-
|
|
554
|
+
emit("change", value);
|
|
554
555
|
};
|
|
555
556
|
function onMouseover() {
|
|
556
557
|
if (!validate("hover")) return;
|
|
@@ -696,6 +697,8 @@ const usePopover = defineHookComponent({
|
|
|
696
697
|
nextTick(resize);
|
|
697
698
|
});
|
|
698
699
|
return {
|
|
700
|
+
show,
|
|
701
|
+
close,
|
|
699
702
|
events,
|
|
700
703
|
dropdownPosition,
|
|
701
704
|
triggerRef,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoci/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Chizuki <chizukicn@outlook.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@vueuse/core": ">=
|
|
22
|
+
"@vueuse/core": ">=10.5.0",
|
|
23
23
|
"vue": ">=3.3.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@tanstack/virtual-core": "^3.13.18",
|
|
27
27
|
"maybe-types": "^0.2.0",
|
|
28
28
|
"tslx": "^0.3.0",
|
|
29
|
-
"@hoci/shared": "0.
|
|
29
|
+
"@hoci/shared": "1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsdown"
|