idea-react 3.0.0-rc.3 → 3.0.0-rc.4
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/AGENTS.md +93 -5
- package/dist/index.d.mts +98 -33
- package/dist/index.d.ts +98 -33
- package/dist/index.js +13 -13
- package/dist/index.mjs +12 -12
- package/package.json +10 -10
- package/source/Base/Carousel/index.tsx +98 -78
- package/source/Base/Carousel/model.ts +245 -65
- package/source/Base/Carousel/scroll.ts +174 -28
- package/source/Extension/PageNav.tsx +8 -7
package/AGENTS.md
CHANGED
|
@@ -150,14 +150,96 @@ export class MyComponent extends ObservedComponent<MyComponentProps> {
|
|
|
150
150
|
- 多个同前缀的文件归入同名文件夹,文件使用 `index.tsx`、`model.ts`、
|
|
151
151
|
`style.module.css` 等短名,并同步调整所有引用。
|
|
152
152
|
|
|
153
|
-
##
|
|
153
|
+
## 复杂组件架构
|
|
154
|
+
|
|
155
|
+
### 职责与单向流
|
|
154
156
|
|
|
155
157
|
- 遵循 AOP、单一职责与关注点分离,优先复用现有模型和框架组合机制,避免过度抽象。
|
|
158
|
+
- 按实际需要参考 MVC、MVVM、MVP 范式,以 View Model 作为业务统筹中枢,不为套用范式增加无必要的类或抽象层。
|
|
159
|
+
少量、仅供单个组件使用的状态可以直接写为类组件实例成员,不必独立状态类。
|
|
160
|
+
|
|
161
|
+
| 职责 | 负责 | 不负责 |
|
|
162
|
+
| ------------------- | -------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
163
|
+
| View(组件) | 根据 Props 初始化与同步模型,绘制界面,转发交互和浏览器事件,管理生命周期 | 业务策略、分页或目标选择、异步业务流程 |
|
|
164
|
+
| View Model(Store) | 统筹业务规则、异步流程、数值计算、可观察状态和执行计划,处理完成或中断反馈 | 访问 DOM、测量布局、注册浏览器事件 |
|
|
165
|
+
| DOM 适配器 | 提供数值化布局快照,执行模型状态要求的 DOM 副作用,反馈测量和执行事实 | 反向查询整个模型,替模型决定业务策略或选中状态 |
|
|
166
|
+
|
|
167
|
+
- 业务行为、异步流程和状态集中在内聚的模型类中,不集中到 React hooks 或零散工具函数里;
|
|
168
|
+
真正无状态、聚焦的数值转换可以使用纯函数。
|
|
169
|
+
- 组件重绘和命令式 DOM 副作用均由模型的可观察状态驱动:`observer` 消费展示状态,
|
|
170
|
+
`reaction` 观察执行计划,CSS 响应渲染后的类名或样式,不建立两套业务控制器。
|
|
171
|
+
执行器通过明确的回调反馈事实,而不是获取整个 Store 再作决策。
|
|
172
|
+
- 测量与 DOM 执行可以共用一个普通类,以接口和方法区分职责,不为每项职责机械增加文件或类。
|
|
173
|
+
动画帧可由状态触发的执行器或 CSS 完成,不为逐帧数值强制触发 React 重绘。
|
|
174
|
+
|
|
175
|
+
```mermaid
|
|
176
|
+
flowchart LR
|
|
177
|
+
Events["用户交互 / Props / 浏览器事件"] --> Model["View Model"]
|
|
178
|
+
Measure["DOM 测量"] -->|数值快照| Model
|
|
179
|
+
Model --> State["可观察状态 / 执行计划"]
|
|
180
|
+
State --> View["View 渲染"]
|
|
181
|
+
State --> Effects["DOM 执行器 / CSS"]
|
|
182
|
+
View -->|挂载 / 布局失效| Measure
|
|
183
|
+
Effects -->|完成 / 中断事实| Model
|
|
184
|
+
Effects -->|布局失效| Measure
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
图中的反馈是下一次模型输入,仍遵循“输入 → 模型决策与状态 → 渲染或执行 → 事实反馈”的单向数据或操作流;
|
|
188
|
+
不是 View 与执行器相互调用业务逻辑的双向控制。
|
|
189
|
+
|
|
190
|
+
### 测量与生命周期
|
|
191
|
+
|
|
192
|
+
- 测量优先在挂载后、转场前或布局失效时进行并复用快照;必要时先中断动画再重测,避免逐帧交错读写布局。
|
|
193
|
+
- 充分利用类属性初始化状态、恢复 Promise 和订阅 disposer,不将可声明的初始化集中到 `initialize()` 中。
|
|
194
|
+
DOM 测量、事件监听与其它浏览器副作用只在客户端挂载后启动,卸载时释放观察、监听、计时器和动画资源。
|
|
195
|
+
- 替换模型或切换模式时,清理旧副作用并按需恢复选中状态、播放意图等业务状态;
|
|
196
|
+
无关 Props 更新不重建模型或重置仍有效的订阅与计时器。
|
|
197
|
+
- 异步恢复或执行完成后,核对实例及当前操作是否仍有效,避免已销毁实例重新绑定监听,或旧结果覆盖新状态。
|
|
198
|
+
- 按职责而非文件数量划分结构,优先删除重复决策与转发;模型规则用数值输入验证,真实布局仍按“测试与验证”章节进行浏览器验证。
|
|
199
|
+
|
|
200
|
+
### 接线示例
|
|
201
|
+
|
|
202
|
+
以下用现有 Carousel 类展示最小接线:组件先创建 Store、取得挂载后的 DOM,再建立状态观察与事实反馈;
|
|
203
|
+
JSX 通过 `observer` 消费同一个 Store。示例函数只为展示挂载/卸载两阶段,实际组件可直接放入生命周期方法,不必新增绑定层。
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { reaction } from 'mobx';
|
|
207
|
+
|
|
208
|
+
import { ScrollCarouselModel } from './source/Base/Carousel/model';
|
|
209
|
+
import { CarouselScroll } from './source/Base/Carousel/scroll';
|
|
210
|
+
|
|
211
|
+
function mountEffects(
|
|
212
|
+
store: ScrollCarouselModel,
|
|
213
|
+
scroller: CarouselScroll,
|
|
214
|
+
root: HTMLElement,
|
|
215
|
+
track: HTMLElement
|
|
216
|
+
) {
|
|
217
|
+
const stopMotion = reaction(() => store.motion, scroller.apply);
|
|
218
|
+
const onResize = () => {
|
|
219
|
+
store.interrupt();
|
|
220
|
+
|
|
221
|
+
scroller.refresh(true);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
scroller.mount(root, track, {
|
|
225
|
+
onLayout: store.refresh,
|
|
226
|
+
onScroll: store.syncScroll,
|
|
227
|
+
onComplete: store.complete,
|
|
228
|
+
onResize
|
|
229
|
+
});
|
|
230
|
+
store.mount();
|
|
231
|
+
|
|
232
|
+
return () => {
|
|
233
|
+
stopMotion();
|
|
234
|
+
scroller.dispose();
|
|
235
|
+
store.dispose();
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 状态与回调
|
|
241
|
+
|
|
156
242
|
- 仅依赖 props 的展示组件使用函数组件;需要状态、行为或生命周期时使用类组件与 MobX。
|
|
157
|
-
- 业务行为、异步流程和状态集中在内聚的模型类中;组件负责展示、生命周期和事件转发,
|
|
158
|
-
不要把这些逻辑集中到 React hooks 或零散工具函数里。
|
|
159
|
-
- 少量、仅供单个组件使用的状态直接写为类组件实例成员,不必独立状态类。
|
|
160
|
-
- 充分利用类属性初始化状态、恢复 Promise 和订阅 disposer,不将可声明的初始化集中到 `initialize()` 中。浏览器副作用应在客户端挂载后启动,卸载时释放订阅,并防止异步恢复完成后给已销毁实例重新绑定监听。
|
|
161
243
|
- 使用 MobX stage-3 装饰器(如 `@observable accessor`、`@computed`、`@action`)。
|
|
162
244
|
- 已有 action 边界(`@action` 或 `action()`)时不要再套 `runInAction()`。异步方法的 `await` 之后不继承 action 边界,后续状态更新应调用独立的 action(`@action` 方法或 `action()` 包装的实例方法),不能直接删除包装后裸写状态。
|
|
163
245
|
- 仅把调用转发给模型 action 的事件方法不再加 `@action`,action 边界由模型方法负责。
|
|
@@ -207,13 +289,18 @@ export class MyComponent extends ObservedComponent<MyComponentProps> {
|
|
|
207
289
|
## 文档站、样式与文案
|
|
208
290
|
|
|
209
291
|
- 文档站使用 ViNext,保留 MDX 支持并以纯 SSG 导出;部署静态文件,不依赖运行时服务器。
|
|
292
|
+
- 文档站编译插件按职责拆分到 `document/plugin/` 的独立模块,共享类型单独定义;`document/vite.config.ts` 只负责导入与配置编排。
|
|
293
|
+
- 通用编译插件不耦合特定框架的 CSS 类名;通用样式通过参数传入,或用标准 `style` 属性表达。
|
|
294
|
+
- 文档中的 `mermaid` 围栏使用 `beautiful-mermaid` 在 MDX 编译期生成 SVG,不引入客户端渲染器或 Headless Browser;保留无障碍说明并用 CSS 变量适配主题。
|
|
210
295
|
- 文档站页面参考上游设计,但品牌使用 **Idea React**,版本、许可证、安装命令、链接及其它文案
|
|
211
296
|
均以本项目实际情况为准;保留必要的上游版权和许可证声明。
|
|
212
297
|
- 同步上游文档时保留正文主题、章节顺序、示例覆盖与必要资源;逐段将说明和示例改写为本项目真实 API,仅删除确实不适用的内容,不将完整指南大幅缩写成 quick start。文档示例只使用本库实际导出的包路径、组件能力和已验证的官方链接。
|
|
213
298
|
- 文案中的缩写使用全大写形式(如 NPM、CSS)。
|
|
299
|
+
- 通用社区入口统一指向本仓库的 GitHub Discussions;问题上报、Pull Request 与贡献者等专用链接保留其语义。
|
|
214
300
|
- 修改导航分类或路由命名时,同步更新页面标题、导航、页脚、站点链接和所有引用;确认新路由真实存在,并全局清理旧名称及失效路径。
|
|
215
301
|
- 页面格式以简洁、可读为准:文档可用 MDX,非文档页(包括首页)在能减少缩进时也可用
|
|
216
302
|
MDX,不强制非文档页只能使用 TSX 或 MDX。
|
|
303
|
+
- 文档说明优先简短、分点组织;将不同配置项、行为或注意事项分别列出,避免多个主题挤在长段落中。
|
|
217
304
|
- 跨页面共享的导航栏等结构放在公共布局中,不重复写入单个页面。
|
|
218
305
|
- 上游来源与版权许可说明集中在网站公共页脚,不在各篇组件文档重复,也不添加指向上游单页源码的链接。
|
|
219
306
|
- MDX 中的大段静态文本优先使用 Markdown,而非嵌套的 JSX 文本块。
|
|
@@ -225,6 +312,7 @@ export class MyComponent extends ObservedComponent<MyComponentProps> {
|
|
|
225
312
|
- JSX/MDX 元素没有子节点时使用自闭合标签。
|
|
226
313
|
- 能用 [Bootstrap 6 CSS 工具类][4] 的样式不写自定义 CSS,剩余样式使用 CSS modules;必须保留原始类名的页面专属样式可用 `*.less` 全局导入,且仅由对应页面引用;需要嵌套的模块样式使用 LESS modules。
|
|
227
314
|
- LESS 样式优先将伪类、伪元素、后代选择器及媒体查询嵌套在最近的相关选择器中,避免重复书写父选择器。
|
|
315
|
+
- 本库使用 LESS,不使用 SASS,也不提供面向使用者的 LESS 定制接口,新增外观定制能力优先开放 CSS 变量。
|
|
228
316
|
- 可由 CSS 或 Bootstrap 工具类静态表达的布局、状态与堆叠关系优先用 CSS,避免为此引入客户端状态或 Context、Model。
|
|
229
317
|
- 样式模块的类型声明合入已有的 `source/types.d.ts`,不要另建重复声明文件。
|
|
230
318
|
- 文档示例使用文档专用 Demo 组件时,为 `CodeExample` 提供源码路径;仓库内路径相对于仓库根目录且不以 `/` 开头,外部源码可传绝对 URL。
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, CSSProperties, Component, ComponentPropsWithRef, ComponentPropsWithoutRef, DetailedHTMLProps, DialogHTMLAttributes, ElementType, FC, FocusEvent, HTMLAttributes, KeyboardEvent, KeyboardEventHandler, MouseEvent as MouseEvent$1, PropsWithChildren, PropsWithoutRef, PureComponent, ReactElement, ReactNode, Ref, RefCallback, SyntheticEvent, TimeHTMLAttributes, TransitionEvent } from "react";
|
|
1
|
+
import { ButtonHTMLAttributes, CSSProperties, Component, ComponentPropsWithRef, ComponentPropsWithoutRef, DetailedHTMLProps, DialogHTMLAttributes, ElementType, FC, FocusEvent, HTMLAttributes, KeyboardEvent, KeyboardEventHandler, MouseEvent as MouseEvent$1, PointerEvent as PointerEvent$1, PropsWithChildren, PropsWithoutRef, PureComponent, ReactElement, ReactNode, Ref, RefCallback, SyntheticEvent, TimeHTMLAttributes, TransitionEvent, WheelEvent } from "react";
|
|
2
2
|
import { TimeData, Timestamp } from "web-utility";
|
|
3
3
|
import { ObservedComponent } from "mobx-react-helper";
|
|
4
4
|
import { Defer } from "iterable-observer";
|
|
@@ -179,42 +179,104 @@ export declare const CardFooter: PolymorphicComponent<import("react").DetailedHT
|
|
|
179
179
|
export declare const CardTitle: PolymorphicComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
180
180
|
export declare const CardText: PolymorphicComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>>;
|
|
181
181
|
type CarouselEnds = 'loop' | 'wrap' | 'stop';
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
interface CarouselModelOptions {
|
|
183
|
+
intervals: number[];
|
|
184
|
+
ends: CarouselEnds;
|
|
185
|
+
onChange?: (index: number) => unknown;
|
|
186
|
+
}
|
|
187
|
+
interface CarouselMotion {
|
|
188
|
+
index: number;
|
|
189
|
+
from: number;
|
|
190
|
+
left: number;
|
|
191
|
+
smooth: boolean;
|
|
192
|
+
loop?: -1 | 1;
|
|
193
|
+
}
|
|
194
|
+
interface CarouselLayout {
|
|
195
|
+
positions: number[];
|
|
196
|
+
widths: number[];
|
|
197
|
+
viewport: number;
|
|
198
|
+
maximum: number;
|
|
199
|
+
rtl: boolean;
|
|
200
|
+
items: number;
|
|
201
|
+
peek: number;
|
|
202
|
+
center: boolean;
|
|
203
|
+
variableWidth: boolean;
|
|
204
|
+
reducedMotion: boolean;
|
|
205
|
+
}
|
|
206
|
+
declare abstract class CarouselModel {
|
|
207
|
+
abstract readonly fade: boolean;
|
|
208
|
+
get navigating(): boolean;
|
|
209
|
+
accessor motion: CarouselMotion | undefined;
|
|
186
210
|
accessor activeIndex: number;
|
|
187
211
|
accessor playing: boolean;
|
|
212
|
+
accessor indexes: number[];
|
|
213
|
+
get atStart(): boolean;
|
|
214
|
+
get atEnd(): boolean;
|
|
215
|
+
get canPrevious(): boolean;
|
|
216
|
+
get canNext(): boolean;
|
|
217
|
+
get interval(): number;
|
|
218
|
+
protected accessor options: CarouselModelOptions;
|
|
219
|
+
protected layout?: CarouselLayout;
|
|
220
|
+
protected positions: number[];
|
|
188
221
|
private timer?;
|
|
222
|
+
private stopPlayback?;
|
|
189
223
|
private accessor hovering;
|
|
190
224
|
private accessor visible;
|
|
191
225
|
get cycling(): boolean;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
226
|
+
constructor(options: CarouselModelOptions);
|
|
227
|
+
mount(): void;
|
|
228
|
+
restore(previous: CarouselModel): void;
|
|
195
229
|
setIndex: (index: number, userInitiated?: boolean, direction?: -1 | 1, fromScroll?: boolean) => void;
|
|
196
230
|
next: (userInitiated?: boolean) => void;
|
|
197
231
|
previous: (userInitiated?: boolean) => void;
|
|
198
|
-
play: () =>
|
|
199
|
-
pause: () =>
|
|
200
|
-
toggle: () =>
|
|
201
|
-
setHovering: (hovering: boolean) =>
|
|
202
|
-
setVisible: (visible: boolean) =>
|
|
203
|
-
update
|
|
204
|
-
|
|
232
|
+
play: () => boolean;
|
|
233
|
+
pause: () => boolean;
|
|
234
|
+
toggle: () => boolean;
|
|
235
|
+
setHovering: (hovering: boolean) => boolean;
|
|
236
|
+
setVisible: (visible: boolean) => boolean;
|
|
237
|
+
update(options: CarouselModelOptions): void;
|
|
238
|
+
refresh: (layout?: CarouselLayout, align?: boolean) => void;
|
|
239
|
+
syncScroll: (left: number) => void;
|
|
240
|
+
complete: (motion: CarouselMotion) => void;
|
|
241
|
+
interrupt: () => undefined;
|
|
242
|
+
dispose(): void;
|
|
243
|
+
protected readIndexes(positions?: number[]): number[];
|
|
244
|
+
protected createMotion?: (index: number, from: number, direction?: -1 | 1) => CarouselMotion | undefined;
|
|
245
|
+
private advance;
|
|
205
246
|
private schedule;
|
|
247
|
+
private move;
|
|
206
248
|
private clearTimer;
|
|
207
249
|
}
|
|
250
|
+
interface CarouselScrollEvents {
|
|
251
|
+
onLayout: (layout: CarouselLayout, align?: boolean) => unknown;
|
|
252
|
+
onScroll: (left: number) => unknown;
|
|
253
|
+
onComplete: (motion: CarouselMotion) => unknown;
|
|
254
|
+
onResize: () => unknown;
|
|
255
|
+
}
|
|
208
256
|
declare class CarouselScroll {
|
|
257
|
+
private root?;
|
|
258
|
+
private track?;
|
|
259
|
+
private center;
|
|
209
260
|
private frame?;
|
|
210
261
|
private clone?;
|
|
211
|
-
private
|
|
212
|
-
private
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
262
|
+
private snap?;
|
|
263
|
+
private events?;
|
|
264
|
+
private media?;
|
|
265
|
+
private resizeObserver?;
|
|
266
|
+
private observedSlides;
|
|
267
|
+
get navigating(): boolean;
|
|
268
|
+
mount(root: HTMLElement, track: HTMLElement, events: CarouselScrollEvents, center?: boolean): void;
|
|
269
|
+
refresh: (align?: boolean) => void;
|
|
270
|
+
dispose(): void;
|
|
271
|
+
apply: (motion?: CarouselMotion) => void;
|
|
272
|
+
interrupt: () => void;
|
|
273
|
+
private observeLayout;
|
|
274
|
+
private handleResize;
|
|
275
|
+
private handleScroll;
|
|
276
|
+
private position;
|
|
277
|
+
private navigate;
|
|
278
|
+
private loop;
|
|
216
279
|
private animate;
|
|
217
|
-
dispose: () => void;
|
|
218
280
|
}
|
|
219
281
|
export interface CarouselSlideProps extends ComponentPropsWithRef<'div'> {
|
|
220
282
|
interval?: number;
|
|
@@ -249,23 +311,26 @@ export declare class Carousel<T extends ElementType | undefined = 'div'> extends
|
|
|
249
311
|
static displayName: string;
|
|
250
312
|
root: import("react").RefObject<HTMLDivElement | null>;
|
|
251
313
|
track: import("react").RefObject<HTMLDivElement | null>;
|
|
252
|
-
store: CarouselModel;
|
|
253
314
|
scroller: CarouselScroll;
|
|
315
|
+
accessor store: CarouselModel;
|
|
316
|
+
private stopMotion?;
|
|
254
317
|
componentDidMount(): void;
|
|
255
318
|
componentDidUpdate(): void;
|
|
256
319
|
componentWillUnmount(): void;
|
|
257
320
|
private getSlides;
|
|
258
|
-
private
|
|
321
|
+
private get modelOptions();
|
|
322
|
+
private createStore;
|
|
259
323
|
private updateStore;
|
|
260
|
-
handleVisibilityChange
|
|
324
|
+
private handleVisibilityChange;
|
|
325
|
+
private handleResize;
|
|
326
|
+
handlePointerDown: (event: PointerEvent$1<HTMLDivElement>) => void;
|
|
327
|
+
handleWheel: (event: WheelEvent<HTMLDivElement>) => void;
|
|
261
328
|
handleMouseEnter: () => void;
|
|
262
|
-
handleMouseLeave: () =>
|
|
329
|
+
handleMouseLeave: () => boolean;
|
|
263
330
|
handleFocusCapture: () => void;
|
|
264
331
|
handleBlurCapture: ({ currentTarget, relatedTarget }: React.FocusEvent<HTMLDivElement>) => void;
|
|
265
|
-
handleScroll: () => void;
|
|
266
332
|
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
267
333
|
handleClick: (event: MouseEvent$1<HTMLDivElement>) => void;
|
|
268
|
-
scrollToActive: (index: number, from: number, direction?: -1 | 1) => void;
|
|
269
334
|
renderSlide: (slide: ReactNode, index: number) => import("react").JSX.Element;
|
|
270
335
|
renderControl: (direction: "previous" | "next") => import("react").JSX.Element | null;
|
|
271
336
|
renderIndicators: () => import("react").JSX.Element | null;
|
|
@@ -718,7 +783,7 @@ declare class ScrollSpyModel {
|
|
|
718
783
|
accessor guides: (Record<'top' | 'left' | 'width' | 'height' | 'line', number> & {
|
|
719
784
|
atBottom: boolean;
|
|
720
785
|
}) | undefined;
|
|
721
|
-
setGuides: (guides: ScrollSpyModel["guides"]) => (Record<"line" | "
|
|
786
|
+
setGuides: (guides: ScrollSpyModel["guides"]) => (Record<"line" | "height" | "width" | "left" | "top", number> & {
|
|
722
787
|
atBottom: boolean;
|
|
723
788
|
}) | undefined;
|
|
724
789
|
setActiveId: (id: string) => string;
|
|
@@ -752,7 +817,7 @@ export declare class ScrollSpy<T extends ElementType | undefined = 'div'> extend
|
|
|
752
817
|
componentWillUnmount(): void;
|
|
753
818
|
refresh: () => void;
|
|
754
819
|
handleResize: () => void;
|
|
755
|
-
handleScroll: () => (Record<"line" | "
|
|
820
|
+
handleScroll: () => (Record<"line" | "height" | "width" | "left" | "top", number> & {
|
|
756
821
|
atBottom: boolean;
|
|
757
822
|
}) | undefined;
|
|
758
823
|
private getRootHeight;
|
|
@@ -1102,8 +1167,8 @@ export declare class PageNav<T extends ElementType | undefined = 'nav'> extends
|
|
|
1102
1167
|
static slugOf(text: string): string;
|
|
1103
1168
|
initList(): void;
|
|
1104
1169
|
componentWillUnmount(): void;
|
|
1105
|
-
|
|
1106
|
-
renderLink: ({ id, level, text
|
|
1170
|
+
handleItemClick: ({ currentTarget }: MouseEvent$1<HTMLAnchorElement>) => void;
|
|
1171
|
+
renderLink: ({ id, level, text }: HeadingMeta) => false | import("react").JSX.Element;
|
|
1107
1172
|
render(): import("react").JSX.Element;
|
|
1108
1173
|
}
|
|
1109
1174
|
export type ScrollNavProps = NavProps & {
|
|
@@ -1244,7 +1309,7 @@ export type CheckboxProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'si
|
|
|
1244
1309
|
theme?: ComponentTheme;
|
|
1245
1310
|
indeterminate?: boolean;
|
|
1246
1311
|
};
|
|
1247
|
-
export declare const Checkbox: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "
|
|
1312
|
+
export declare const Checkbox: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "type" | "size"> & FormValidationProps & {
|
|
1248
1313
|
size?: "sm" | "lg";
|
|
1249
1314
|
theme?: ComponentTheme;
|
|
1250
1315
|
indeterminate?: boolean;
|
|
@@ -1440,7 +1505,7 @@ export type OTPInputProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'ma
|
|
|
1440
1505
|
onComplete?: (value: string) => unknown;
|
|
1441
1506
|
onValueChange?: (value: string) => unknown;
|
|
1442
1507
|
};
|
|
1443
|
-
export declare const OTPInput: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "
|
|
1508
|
+
export declare const OTPInput: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "type" | "size" | "maxLength"> & FormValidationProps & {
|
|
1444
1509
|
length: number;
|
|
1445
1510
|
type?: "numeric" | "alphanumeric" | "alpha";
|
|
1446
1511
|
mask?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, CSSProperties, Component, ComponentPropsWithRef, ComponentPropsWithoutRef, DetailedHTMLProps, DialogHTMLAttributes, ElementType, FC, FocusEvent, HTMLAttributes, KeyboardEvent, KeyboardEventHandler, MouseEvent as MouseEvent$1, PropsWithChildren, PropsWithoutRef, PureComponent, ReactElement, ReactNode, Ref, RefCallback, SyntheticEvent, TimeHTMLAttributes, TransitionEvent } from "react";
|
|
1
|
+
import { ButtonHTMLAttributes, CSSProperties, Component, ComponentPropsWithRef, ComponentPropsWithoutRef, DetailedHTMLProps, DialogHTMLAttributes, ElementType, FC, FocusEvent, HTMLAttributes, KeyboardEvent, KeyboardEventHandler, MouseEvent as MouseEvent$1, PointerEvent as PointerEvent$1, PropsWithChildren, PropsWithoutRef, PureComponent, ReactElement, ReactNode, Ref, RefCallback, SyntheticEvent, TimeHTMLAttributes, TransitionEvent, WheelEvent } from "react";
|
|
2
2
|
import { TimeData, Timestamp } from "web-utility";
|
|
3
3
|
import { ObservedComponent } from "mobx-react-helper";
|
|
4
4
|
import { Defer } from "iterable-observer";
|
|
@@ -179,42 +179,104 @@ export declare const CardFooter: PolymorphicComponent<import("react").DetailedHT
|
|
|
179
179
|
export declare const CardTitle: PolymorphicComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
180
180
|
export declare const CardText: PolymorphicComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>>;
|
|
181
181
|
type CarouselEnds = 'loop' | 'wrap' | 'stop';
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
interface CarouselModelOptions {
|
|
183
|
+
intervals: number[];
|
|
184
|
+
ends: CarouselEnds;
|
|
185
|
+
onChange?: (index: number) => unknown;
|
|
186
|
+
}
|
|
187
|
+
interface CarouselMotion {
|
|
188
|
+
index: number;
|
|
189
|
+
from: number;
|
|
190
|
+
left: number;
|
|
191
|
+
smooth: boolean;
|
|
192
|
+
loop?: -1 | 1;
|
|
193
|
+
}
|
|
194
|
+
interface CarouselLayout {
|
|
195
|
+
positions: number[];
|
|
196
|
+
widths: number[];
|
|
197
|
+
viewport: number;
|
|
198
|
+
maximum: number;
|
|
199
|
+
rtl: boolean;
|
|
200
|
+
items: number;
|
|
201
|
+
peek: number;
|
|
202
|
+
center: boolean;
|
|
203
|
+
variableWidth: boolean;
|
|
204
|
+
reducedMotion: boolean;
|
|
205
|
+
}
|
|
206
|
+
declare abstract class CarouselModel {
|
|
207
|
+
abstract readonly fade: boolean;
|
|
208
|
+
get navigating(): boolean;
|
|
209
|
+
accessor motion: CarouselMotion | undefined;
|
|
186
210
|
accessor activeIndex: number;
|
|
187
211
|
accessor playing: boolean;
|
|
212
|
+
accessor indexes: number[];
|
|
213
|
+
get atStart(): boolean;
|
|
214
|
+
get atEnd(): boolean;
|
|
215
|
+
get canPrevious(): boolean;
|
|
216
|
+
get canNext(): boolean;
|
|
217
|
+
get interval(): number;
|
|
218
|
+
protected accessor options: CarouselModelOptions;
|
|
219
|
+
protected layout?: CarouselLayout;
|
|
220
|
+
protected positions: number[];
|
|
188
221
|
private timer?;
|
|
222
|
+
private stopPlayback?;
|
|
189
223
|
private accessor hovering;
|
|
190
224
|
private accessor visible;
|
|
191
225
|
get cycling(): boolean;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
226
|
+
constructor(options: CarouselModelOptions);
|
|
227
|
+
mount(): void;
|
|
228
|
+
restore(previous: CarouselModel): void;
|
|
195
229
|
setIndex: (index: number, userInitiated?: boolean, direction?: -1 | 1, fromScroll?: boolean) => void;
|
|
196
230
|
next: (userInitiated?: boolean) => void;
|
|
197
231
|
previous: (userInitiated?: boolean) => void;
|
|
198
|
-
play: () =>
|
|
199
|
-
pause: () =>
|
|
200
|
-
toggle: () =>
|
|
201
|
-
setHovering: (hovering: boolean) =>
|
|
202
|
-
setVisible: (visible: boolean) =>
|
|
203
|
-
update
|
|
204
|
-
|
|
232
|
+
play: () => boolean;
|
|
233
|
+
pause: () => boolean;
|
|
234
|
+
toggle: () => boolean;
|
|
235
|
+
setHovering: (hovering: boolean) => boolean;
|
|
236
|
+
setVisible: (visible: boolean) => boolean;
|
|
237
|
+
update(options: CarouselModelOptions): void;
|
|
238
|
+
refresh: (layout?: CarouselLayout, align?: boolean) => void;
|
|
239
|
+
syncScroll: (left: number) => void;
|
|
240
|
+
complete: (motion: CarouselMotion) => void;
|
|
241
|
+
interrupt: () => undefined;
|
|
242
|
+
dispose(): void;
|
|
243
|
+
protected readIndexes(positions?: number[]): number[];
|
|
244
|
+
protected createMotion?: (index: number, from: number, direction?: -1 | 1) => CarouselMotion | undefined;
|
|
245
|
+
private advance;
|
|
205
246
|
private schedule;
|
|
247
|
+
private move;
|
|
206
248
|
private clearTimer;
|
|
207
249
|
}
|
|
250
|
+
interface CarouselScrollEvents {
|
|
251
|
+
onLayout: (layout: CarouselLayout, align?: boolean) => unknown;
|
|
252
|
+
onScroll: (left: number) => unknown;
|
|
253
|
+
onComplete: (motion: CarouselMotion) => unknown;
|
|
254
|
+
onResize: () => unknown;
|
|
255
|
+
}
|
|
208
256
|
declare class CarouselScroll {
|
|
257
|
+
private root?;
|
|
258
|
+
private track?;
|
|
259
|
+
private center;
|
|
209
260
|
private frame?;
|
|
210
261
|
private clone?;
|
|
211
|
-
private
|
|
212
|
-
private
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
262
|
+
private snap?;
|
|
263
|
+
private events?;
|
|
264
|
+
private media?;
|
|
265
|
+
private resizeObserver?;
|
|
266
|
+
private observedSlides;
|
|
267
|
+
get navigating(): boolean;
|
|
268
|
+
mount(root: HTMLElement, track: HTMLElement, events: CarouselScrollEvents, center?: boolean): void;
|
|
269
|
+
refresh: (align?: boolean) => void;
|
|
270
|
+
dispose(): void;
|
|
271
|
+
apply: (motion?: CarouselMotion) => void;
|
|
272
|
+
interrupt: () => void;
|
|
273
|
+
private observeLayout;
|
|
274
|
+
private handleResize;
|
|
275
|
+
private handleScroll;
|
|
276
|
+
private position;
|
|
277
|
+
private navigate;
|
|
278
|
+
private loop;
|
|
216
279
|
private animate;
|
|
217
|
-
dispose: () => void;
|
|
218
280
|
}
|
|
219
281
|
export interface CarouselSlideProps extends ComponentPropsWithRef<'div'> {
|
|
220
282
|
interval?: number;
|
|
@@ -249,23 +311,26 @@ export declare class Carousel<T extends ElementType | undefined = 'div'> extends
|
|
|
249
311
|
static displayName: string;
|
|
250
312
|
root: import("react").RefObject<HTMLDivElement | null>;
|
|
251
313
|
track: import("react").RefObject<HTMLDivElement | null>;
|
|
252
|
-
store: CarouselModel;
|
|
253
314
|
scroller: CarouselScroll;
|
|
315
|
+
accessor store: CarouselModel;
|
|
316
|
+
private stopMotion?;
|
|
254
317
|
componentDidMount(): void;
|
|
255
318
|
componentDidUpdate(): void;
|
|
256
319
|
componentWillUnmount(): void;
|
|
257
320
|
private getSlides;
|
|
258
|
-
private
|
|
321
|
+
private get modelOptions();
|
|
322
|
+
private createStore;
|
|
259
323
|
private updateStore;
|
|
260
|
-
handleVisibilityChange
|
|
324
|
+
private handleVisibilityChange;
|
|
325
|
+
private handleResize;
|
|
326
|
+
handlePointerDown: (event: PointerEvent$1<HTMLDivElement>) => void;
|
|
327
|
+
handleWheel: (event: WheelEvent<HTMLDivElement>) => void;
|
|
261
328
|
handleMouseEnter: () => void;
|
|
262
|
-
handleMouseLeave: () =>
|
|
329
|
+
handleMouseLeave: () => boolean;
|
|
263
330
|
handleFocusCapture: () => void;
|
|
264
331
|
handleBlurCapture: ({ currentTarget, relatedTarget }: React.FocusEvent<HTMLDivElement>) => void;
|
|
265
|
-
handleScroll: () => void;
|
|
266
332
|
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
267
333
|
handleClick: (event: MouseEvent$1<HTMLDivElement>) => void;
|
|
268
|
-
scrollToActive: (index: number, from: number, direction?: -1 | 1) => void;
|
|
269
334
|
renderSlide: (slide: ReactNode, index: number) => import("react").JSX.Element;
|
|
270
335
|
renderControl: (direction: "previous" | "next") => import("react").JSX.Element | null;
|
|
271
336
|
renderIndicators: () => import("react").JSX.Element | null;
|
|
@@ -718,7 +783,7 @@ declare class ScrollSpyModel {
|
|
|
718
783
|
accessor guides: (Record<'top' | 'left' | 'width' | 'height' | 'line', number> & {
|
|
719
784
|
atBottom: boolean;
|
|
720
785
|
}) | undefined;
|
|
721
|
-
setGuides: (guides: ScrollSpyModel["guides"]) => (Record<"line" | "
|
|
786
|
+
setGuides: (guides: ScrollSpyModel["guides"]) => (Record<"line" | "height" | "width" | "left" | "top", number> & {
|
|
722
787
|
atBottom: boolean;
|
|
723
788
|
}) | undefined;
|
|
724
789
|
setActiveId: (id: string) => string;
|
|
@@ -752,7 +817,7 @@ export declare class ScrollSpy<T extends ElementType | undefined = 'div'> extend
|
|
|
752
817
|
componentWillUnmount(): void;
|
|
753
818
|
refresh: () => void;
|
|
754
819
|
handleResize: () => void;
|
|
755
|
-
handleScroll: () => (Record<"line" | "
|
|
820
|
+
handleScroll: () => (Record<"line" | "height" | "width" | "left" | "top", number> & {
|
|
756
821
|
atBottom: boolean;
|
|
757
822
|
}) | undefined;
|
|
758
823
|
private getRootHeight;
|
|
@@ -1102,8 +1167,8 @@ export declare class PageNav<T extends ElementType | undefined = 'nav'> extends
|
|
|
1102
1167
|
static slugOf(text: string): string;
|
|
1103
1168
|
initList(): void;
|
|
1104
1169
|
componentWillUnmount(): void;
|
|
1105
|
-
|
|
1106
|
-
renderLink: ({ id, level, text
|
|
1170
|
+
handleItemClick: ({ currentTarget }: MouseEvent$1<HTMLAnchorElement>) => void;
|
|
1171
|
+
renderLink: ({ id, level, text }: HeadingMeta) => false | import("react").JSX.Element;
|
|
1107
1172
|
render(): import("react").JSX.Element;
|
|
1108
1173
|
}
|
|
1109
1174
|
export type ScrollNavProps = NavProps & {
|
|
@@ -1244,7 +1309,7 @@ export type CheckboxProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'si
|
|
|
1244
1309
|
theme?: ComponentTheme;
|
|
1245
1310
|
indeterminate?: boolean;
|
|
1246
1311
|
};
|
|
1247
|
-
export declare const Checkbox: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "
|
|
1312
|
+
export declare const Checkbox: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "type" | "size"> & FormValidationProps & {
|
|
1248
1313
|
size?: "sm" | "lg";
|
|
1249
1314
|
theme?: ComponentTheme;
|
|
1250
1315
|
indeterminate?: boolean;
|
|
@@ -1440,7 +1505,7 @@ export type OTPInputProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'ma
|
|
|
1440
1505
|
onComplete?: (value: string) => unknown;
|
|
1441
1506
|
onValueChange?: (value: string) => unknown;
|
|
1442
1507
|
};
|
|
1443
|
-
export declare const OTPInput: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "
|
|
1508
|
+
export declare const OTPInput: PolymorphicComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "type" | "size" | "maxLength"> & FormValidationProps & {
|
|
1444
1509
|
length: number;
|
|
1445
1510
|
type?: "numeric" | "alphanumeric" | "alpha";
|
|
1446
1511
|
mask?: boolean;
|