@hoci/core 0.8.1 → 0.10.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Chizuki
3
+ Copyright (c) 2022 Chizuki(chizukicn@outlook.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
@@ -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
@@ -0,0 +1,36 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __exportAll = (all, no_symbols) => {
7
+ let target = {};
8
+ for (var name in all) {
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ }
14
+ if (!no_symbols) {
15
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ }
17
+ return target;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
+ key = keys[i];
23
+ if (!__hasOwnProp.call(to, key) && key !== except) {
24
+ __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ }
30
+ }
31
+ return to;
32
+ };
33
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
34
+
35
+ //#endregion
36
+ export { __reExport as n, __exportAll as t };