snail.vue 2.0.4 → 2.0.6

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/README.md CHANGED
@@ -54,17 +54,7 @@
54
54
  | [Tree](https://www.yuque.com/snail-devx/js/kaynh9t44gbl6fxc#tKdSd) | **树组件;基于 nodes 渲染树,支持节点自定义,集成节点事件和本地搜索** |
55
55
  | [Wrapper](https://www.yuque.com/snail-devx/js/kaynh9t44gbl6fxc#gita6) | **包裹层组件;作为常用组件的包裹层,自动实现组件在 page 和 popup 中展现,让内容组件关注核心逻辑即可** |
56
56
 
57
- ## 3.3. **form 表单组件**
58
-
59
- **封装表单专属组件,如 input、文件上传等**
60
-
61
- **详细说明:**[https://www.yuque.com/snail-devx/js/wl1q8db0qms764eg](https://www.yuque.com/snail-devx/js/wl1q8db0qms764eg)
62
-
63
- | **组件** | **简介** |
64
- | ------------------------------------------------------------------- | ----------------------------------------------- |
65
- | [Input](https://www.yuque.com/snail-devx/js/wl1q8db0qms764eg#lw7O6) | **输入框组件,对原生 input 做美化,支持标题等** |
66
-
67
- ## 3.4. **popup 弹窗组件**
57
+ ## 3.3. **popup 弹窗组件**
68
58
 
69
59
  **基于 IPopupManager 实现弹窗管理,自动管理弹窗层级、弹窗生命周期;提供基础 popup 弹窗方法;并扩展 dialog、follow、toast、confirm 弹窗方法**
70
60
 
@@ -79,7 +69,7 @@
79
69
  | [toast](https://www.yuque.com/snail-devx/js/byho94c6ms40kdb2#FWNH1) | **消息提示弹窗;模拟 Android 的 Toast 弹窗提示消息** |
80
70
  | [confirm](https://www.yuque.com/snail-devx/js/byho94c6ms40kdb2#wohc0) | **确认弹窗;模拟实现原生 confirm 弹窗** |
81
71
 
82
- ## 3.5. **prompt 提示组件**
72
+ ## 3.4. **prompt 提示组件**
83
73
 
84
74
  **封装一些提示性质的通用组件,如数据加载状态、无数据提醒等等**
85
75
 
@@ -668,6 +668,159 @@ type TableRowOptions = HeightStyle & {};
668
668
  */
669
669
  type TableColOptions = BaseStyle & FlexBoxStyle & WidthStyle & BorderStyle & PaddingStyle;
670
670
 
671
+ /**
672
+ * 排序组件 配置选项
673
+ * - 整理部分SortableJs中的配置,不分逻辑不开放
674
+ */
675
+ type SortOptions<T> = {
676
+ /**
677
+ * 变化器
678
+ * - 在此元素值发生变化时,重新刷新排序面板
679
+ * - 如在增加元素时,改变此值实现 新元素 可拖拽排序
680
+ */
681
+ changer: T;
682
+ /**
683
+ * 拖动哪个元素
684
+ * - 传入类样式选择器;如 .table-row
685
+ */
686
+ draggable: string;
687
+ /**
688
+ * 哪个元素启动拖拽
689
+ * - 传入类样式选择器;如 .sort-handle
690
+ * - 不传入则默认 draggable
691
+ * - 若自定义,则传入 draggable 下的dom元素作为启动拖拽的句柄
692
+ */
693
+ handle?: string;
694
+ /**
695
+ * 拖动的元素上增加的类样式
696
+ * - 执行拖拽时随着鼠标移动元素,脱离文档流了
697
+ * - 可自定义一些样式实现拖动元素的高度、宽度自定义等
698
+ * - 默认:snail-sort-drag
699
+ */
700
+ dragClass?: string;
701
+ /**
702
+ * 幽灵元素类样式名称
703
+ * - 拖动时在面板上占位的元素
704
+ * - 默认:snail-sort-ghost
705
+ */
706
+ ghostClass?: string;
707
+ /**
708
+ * 过滤器,不需要进行拖动的元素
709
+ * - 传入类样式选择器;如 .sort-handle
710
+ * - 实现特定子元素不触发拖动排序功能
711
+ */
712
+ filter?: string;
713
+ /**
714
+ * 排序组
715
+ * - 组相同时,可跨组拖拽排序
716
+ * - 不传入,则内部生成guid
717
+ * - 为
718
+ */
719
+ group?: string | SortGroupOptions;
720
+ /**
721
+ * 动画时间
722
+ * - 单位ms;默认150ms
723
+ */
724
+ animation?: number;
725
+ /**
726
+ * 禁用排序效果
727
+ * - 为true时,此容器内元素不能拖动,此不构建sortable实例
728
+ */
729
+ disabled?: boolean;
730
+ /**
731
+ * 在当前容器内是否禁用拖拽排序
732
+ * - 为true时,此容器内部不能拖拽,但可拖动到其他同名group内
733
+ * - 初期想用sort,但作Vue组件属性时,bool类型不传值会自动默认false,和初衷不符
734
+ */
735
+ sortDisabled?: boolean;
736
+ };
737
+ /**
738
+ * 排序组件的Group属性配置选项
739
+ */
740
+ type SortGroupOptions = {
741
+ /**
742
+ * 排序组名称;
743
+ * - 不传入时自动生成
744
+ */
745
+ name: string;
746
+ /**
747
+ * 定义从这个列表容器移动出去的设置
748
+ * - true:列表容器内的列表单元可以被移出;
749
+ * - false:列表容器内的列表单元不可以被移出;
750
+ * - "clone":列表单元移出,移动的为该元素的副本;
751
+ * - function:用来进行pull的函数判断,可以进行复杂逻辑,在函数中return false/true来判断是否移出;
752
+ * - - 暂时不支持 function
753
+ */
754
+ pull: true | false | "clone";
755
+ /**
756
+ * 用来定义往这个列表容器放置列表单元的的设置
757
+ * - true:列表容器可以从其他列表容器内放入列表单元;
758
+ * - false:与true相反;
759
+ * - string|string[]:代表的是group配置项里定义的name值。如['foo','bar']
760
+ * - function:用来进行put的函数判断,可以进行复杂逻辑,在函数中return false/true来判断是否放入;
761
+ * - - 暂时不支持 function
762
+ */
763
+ put: true | false | string | string[];
764
+ };
765
+ /**
766
+ * 排序组件 事件
767
+ */
768
+ type SortEvents = {
769
+ /**
770
+ * 开始拖拽
771
+ */
772
+ start: [evt: SortEvent];
773
+ /**
774
+ * 移动到新容器时
775
+ */
776
+ add: [evt: SortEvent];
777
+ /**
778
+ * 从当前容器移除时
779
+ */
780
+ remove: [evt: SortEvent];
781
+ /**
782
+ * 结束拖拽
783
+ */
784
+ end: [evt: SortEvent];
785
+ /**
786
+ * 元素排序顺序变化
787
+ * @param oldIndex 旧位置索引值
788
+ * @param newIndex 新顺序索引值
789
+ */
790
+ update: [oldIndex: number, newIndex: number];
791
+ };
792
+ /**
793
+ * 排序事件对象
794
+ */
795
+ type SortEvent = {
796
+ /**
797
+ * 目标容器
798
+ */
799
+ to: HTMLElement;
800
+ /**
801
+ * 来源容器
802
+ */
803
+ from: HTMLElement;
804
+ /**
805
+ * 被移动的元素
806
+ * - 在`group.pull`配置为 clone 时,此值为原始元素,复制元素放到原来位置了
807
+ */
808
+ item: HTMLElement;
809
+ /**
810
+ * 副本的元素
811
+ * - 在`group.pull`配置为 clone 时
812
+ */
813
+ clone: HTMLElement;
814
+ /**
815
+ * 容器中的原序号
816
+ */
817
+ oldIndex: number | undefined;
818
+ /**
819
+ * 容器中的新序号
820
+ */
821
+ newIndex: number | undefined;
822
+ };
823
+
671
824
  /**
672
825
  * 布局组件 数据结构
673
826
  */
@@ -735,6 +888,20 @@ type ComponentOptions = {
735
888
  */
736
889
  url?: string;
737
890
  };
891
+ /**
892
+ * 提取组件的props类型
893
+ * - 有效的 Props 类型:extends Record<string, any>
894
+ * - 有效类型则返回 Props 自身;否则无效,为undefined
895
+ */
896
+ type PropsType<Props> = Props extends Record<string, any> ? Props : undefined;
897
+ /**
898
+ * 事件发射器类型
899
+ * - 将【组件中组件】转换为vue的 defineEmits 类型
900
+ * - 用于将组件的事件发射器包裹传递到其他组件、class中使用
901
+ */
902
+ type EmitterType<Events extends Record<string, any[]>> = {
903
+ <K extends keyof Events>(event: K, ...payload: Events[K]): any;
904
+ };
738
905
  /**
739
906
  * 提取【组件事件】类型
740
907
  * - 将【组件事件】中的key首字母小写,追加上on前缀;key对应的value为监听函数参数
@@ -743,12 +910,6 @@ type ComponentOptions = {
743
910
  type EventsType<Events> = Events extends Record<string, unknown[]> ? ({
744
911
  [key in keyof Events as `on${Capitalize<string & key>}`]?: (...args: Events[key]) => void;
745
912
  }) : never;
746
- /**
747
- * 提取组件的props类型
748
- * - 有效的 Props 类型:extends Record<string, any>
749
- * - 有效类型则返回 Props 自身;否则无效,为undefined
750
- */
751
- type PropsType<Props> = Props extends Record<string, any> ? Props : undefined;
752
913
  /**
753
914
  * 组件绑定 配置选项
754
915
  * - Props、Events、Model 为可选泛型,分别约束 props、events、model 属性
@@ -1320,6 +1481,47 @@ type CloseEvents = {
1320
1481
  close: [];
1321
1482
  };
1322
1483
 
1484
+ /**
1485
+ * 输入框配置选项
1486
+ * - title 将作为 输入框标题区域文本;不传入则不展示 标题区域,仅展示输入框
1487
+ * - 暂不提供 disabled 逻辑
1488
+ */
1489
+ type InputOptions = ReadonlyOptions & /*DisabledOptions & */ PlaceholderOptions & TitleOptions & {
1490
+ /**
1491
+ * 输入框类型
1492
+ * - text: 文本输入框
1493
+ * - number: 数字输入框
1494
+ * - password: 密码输入框
1495
+ */
1496
+ type?: "text" | "number" | "password";
1497
+ /**
1498
+ * 输入框是否必填
1499
+ * - 必填,则验证不通过时,显示错误信息
1500
+ * - 必填时,显示必填标记,红色 * 号
1501
+ */
1502
+ required?: boolean;
1503
+ /**
1504
+ * 标题区域样式
1505
+ * - 对齐方式
1506
+ * - 标题区域宽度
1507
+ */
1508
+ titleStyle?: BaseStyle & WidthStyle & FlexBoxStyle;
1509
+ };
1510
+ /**
1511
+ * 输入框事件
1512
+ */
1513
+ type InputEvents = {
1514
+ /**
1515
+ * 输入框点击时
1516
+ */
1517
+ click: [];
1518
+ /**
1519
+ * 输入框内容发生改变时
1520
+ * @param value 输入框内容
1521
+ */
1522
+ change: [value: string];
1523
+ };
1524
+
1323
1525
  /**
1324
1526
  * 接口:响应式管理器
1325
1527
  */
@@ -1438,73 +1640,6 @@ declare function triggerAppCreated(app: App, type?: AppType): App;
1438
1640
  */
1439
1641
  declare function getSvgDraw(iconType: IconType, draw: string[] | string): string[];
1440
1642
 
1441
- /**
1442
- * 排序组件 配置选项
1443
- * - disabled 禁用排序效果,不能再拖拽元素排序
1444
- * - 整理部分SortableJs中的配置,不分逻辑不开放
1445
- */
1446
- type SortOptions<T> = DisabledOptions & {
1447
- /**
1448
- * 变化器
1449
- * - 在此元素值发生变化时,重新刷新排序面板
1450
- * - 如在增加元素时,改变此值实现 新元素 可拖拽排序
1451
- */
1452
- changer: T;
1453
- /**
1454
- * 拖动哪个元素
1455
- * - 传入类样式选择器;如 .table-row
1456
- */
1457
- draggable: string;
1458
- /**
1459
- * 哪个元素启动拖拽
1460
- * - 传入类样式选择器;如 .sort-handle
1461
- * - 不传入则默认 draggable
1462
- * - 若自定义,则传入 draggable 下的dom元素作为启动拖拽的句柄
1463
- */
1464
- handle?: string;
1465
- /**
1466
- * 拖动的元素上增加的类样式
1467
- * - 执行拖拽时随着鼠标移动元素,脱离文档流了
1468
- * - 可自定义一些样式实现拖动元素的高度、宽度自定义等
1469
- * - 默认:snail-sort-drag
1470
- */
1471
- dragClass?: string;
1472
- /**
1473
- * 幽灵元素类样式名称
1474
- * - 拖动时在面板上占位的元素
1475
- * - 默认:snail-sort-ghost
1476
- */
1477
- ghostClass?: string;
1478
- /**
1479
- * 过滤器,不需要进行拖动的元素
1480
- * - 传入类样式选择器;如 .sort-handle
1481
- * - 实现特定子元素不触发拖动排序功能
1482
- */
1483
- filter?: string;
1484
- /**
1485
- * 排序组
1486
- * - 组相同时,可跨组拖拽排序
1487
- * - 不传入,则内部生成guid
1488
- */
1489
- group?: string;
1490
- /**
1491
- * 动画时间
1492
- * - 单位ms;默认150ms
1493
- */
1494
- animation?: number;
1495
- };
1496
- /**
1497
- * 排序组件 事件
1498
- */
1499
- type SortEvents = {
1500
- /**
1501
- * 元素排序顺序变化
1502
- * @param oldIndex 旧位置索引值
1503
- * @param newIndex 新顺序索引值
1504
- */
1505
- update: [oldIndex: number, newIndex: number];
1506
- };
1507
-
1508
1643
  /**
1509
1644
  * 动态加载组件 组件配置选项
1510
1645
  */
@@ -1520,47 +1655,6 @@ type DynamicOptions<Props = void> = ComponentOptions & Pick<ComponentBindOptions
1520
1655
  */
1521
1656
  declare function mount<Props>(target: HTMLElement, options: DynamicOptions<Props>, onDestroyed?: (fn: () => void) => void): IScope;
1522
1657
 
1523
- /**
1524
- * 输入框配置选项
1525
- * - title 将作为 输入框标题区域文本;不传入则不展示 标题区域,仅展示输入框
1526
- * - 暂不提供 disabled 逻辑
1527
- */
1528
- type InputOptions = ReadonlyOptions & /*DisabledOptions & */ PlaceholderOptions & TitleOptions & {
1529
- /**
1530
- * 输入框类型
1531
- * - text: 文本输入框
1532
- * - number: 数字输入框
1533
- * - password: 密码输入框
1534
- */
1535
- type?: "text" | "number" | "password";
1536
- /**
1537
- * 输入框是否必填
1538
- * - 必填,则验证不通过时,显示错误信息
1539
- * - 必填时,显示必填标记,红色 * 号
1540
- */
1541
- required?: boolean;
1542
- /**
1543
- * 标题区域样式
1544
- * - 对齐方式
1545
- * - 标题区域宽度
1546
- */
1547
- titleStyle?: BaseStyle & WidthStyle & FlexBoxStyle;
1548
- };
1549
- /**
1550
- * 输入框事件
1551
- */
1552
- type InputEvents = {
1553
- /**
1554
- * 输入框点击时
1555
- */
1556
- click: [];
1557
- /**
1558
- * 输入框内容发生改变时
1559
- * @param value 输入框内容
1560
- */
1561
- change: [value: string];
1562
- };
1563
-
1564
1658
  /**
1565
1659
  * 公共通用数据结构:
1566
1660
  * 1、在弹窗、模态弹窗、跟随弹窗的效果下复用
@@ -2262,18 +2356,28 @@ declare const components: {
2262
2356
  };
2263
2357
  });
2264
2358
  Sort: {
2265
- new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<DisabledOptions & {
2359
+ new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{
2266
2360
  changer: any;
2267
2361
  draggable: string;
2268
2362
  handle?: string;
2269
2363
  dragClass?: string;
2270
2364
  ghostClass?: string;
2271
2365
  filter?: string;
2272
- group?: string;
2366
+ group?: string | SortGroupOptions;
2273
2367
  animation?: number;
2368
+ disabled?: boolean;
2369
+ sortDisabled?: boolean;
2274
2370
  }> & Readonly<{
2371
+ onEnd?: (evt: SortEvent) => any;
2372
+ onAdd?: (evt: SortEvent) => any;
2373
+ onStart?: (evt: SortEvent) => any;
2374
+ onRemove?: (evt: SortEvent) => any;
2275
2375
  onUpdate?: (oldIndex: number, newIndex: number) => any;
2276
2376
  }>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
2377
+ end: (evt: SortEvent) => any;
2378
+ add: (evt: SortEvent) => any;
2379
+ start: (evt: SortEvent) => any;
2380
+ remove: (evt: SortEvent) => any;
2277
2381
  update: (oldIndex: number, newIndex: number) => any;
2278
2382
  }, vue.PublicProps, {}, false, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
2279
2383
  P: {};
@@ -2282,33 +2386,49 @@ declare const components: {
2282
2386
  C: {};
2283
2387
  M: {};
2284
2388
  Defaults: {};
2285
- }, Readonly<DisabledOptions & {
2389
+ }, Readonly<{
2286
2390
  changer: any;
2287
2391
  draggable: string;
2288
2392
  handle?: string;
2289
2393
  dragClass?: string;
2290
2394
  ghostClass?: string;
2291
2395
  filter?: string;
2292
- group?: string;
2396
+ group?: string | SortGroupOptions;
2293
2397
  animation?: number;
2398
+ disabled?: boolean;
2399
+ sortDisabled?: boolean;
2294
2400
  }> & Readonly<{
2401
+ onEnd?: (evt: SortEvent) => any;
2402
+ onAdd?: (evt: SortEvent) => any;
2403
+ onStart?: (evt: SortEvent) => any;
2404
+ onRemove?: (evt: SortEvent) => any;
2295
2405
  onUpdate?: (oldIndex: number, newIndex: number) => any;
2296
2406
  }>, {}, {}, {}, {}, {}>;
2297
2407
  __isFragment?: never;
2298
2408
  __isTeleport?: never;
2299
2409
  __isSuspense?: never;
2300
- } & vue.ComponentOptionsBase<Readonly<DisabledOptions & {
2410
+ } & vue.ComponentOptionsBase<Readonly<{
2301
2411
  changer: any;
2302
2412
  draggable: string;
2303
2413
  handle?: string;
2304
2414
  dragClass?: string;
2305
2415
  ghostClass?: string;
2306
2416
  filter?: string;
2307
- group?: string;
2417
+ group?: string | SortGroupOptions;
2308
2418
  animation?: number;
2419
+ disabled?: boolean;
2420
+ sortDisabled?: boolean;
2309
2421
  }> & Readonly<{
2422
+ onEnd?: (evt: SortEvent) => any;
2423
+ onAdd?: (evt: SortEvent) => any;
2424
+ onStart?: (evt: SortEvent) => any;
2425
+ onRemove?: (evt: SortEvent) => any;
2310
2426
  onUpdate?: (oldIndex: number, newIndex: number) => any;
2311
2427
  }>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
2428
+ end: (evt: SortEvent) => any;
2429
+ add: (evt: SortEvent) => any;
2430
+ start: (evt: SortEvent) => any;
2431
+ remove: (evt: SortEvent) => any;
2312
2432
  update: (oldIndex: number, newIndex: number) => any;
2313
2433
  }, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
2314
2434
  $slots: {
@@ -2524,4 +2644,4 @@ declare const components: {
2524
2644
  };
2525
2645
 
2526
2646
  export { components, getSvgDraw, mount, onAppCreated, triggerAppCreated, usePopup, useReactive, useTreeContext };
2527
- export type { ButtonOptions, ChangeEvents, ChooseEvents, ChooseItem, ChooseOptions, ClickEvents, CloseEvents, ComponentBindOptions, ComponentOptions, ConfirmAreaOptions, ConfirmOptions, DatePickerEvents, DatepickerOptions, DeleteEvents, DialogHandle, DialogOptions, DisabledOptions, DragVerifyInfo, DragVerifyOptions, EmptyOptions, EventsType, FoldEvents, FoldOptions, FoldStatus, FollowElectResult, FollowExtend, FollowHandle, FollowOptions, FollowStrategy, FollowStrategyOptions, FooterEvents, FooterOptions, HeaderEvents, HeaderOptions, IPopupManager, IReactiveManager, ISelectContext, ITreeBaseContext, IconOptions, IconType, InputEvents, InputOptions, LayoutOptions, LoadingOptions, MessageOptions, MoveEvents, PlaceholderOptions, PopupDescriptor, PopupHandle, PopupOptions, PopupStatus, PopupStatusOptions, PropsType, ReactiveVar, ReadonlyOptions, ScrollEvents, ScrollOptions, ScrollStatus, SearchEvents, SearchOptions, SelectBaseEvents, SelectBaseOptions, SelectEvents, SelectItem, SelectNodeEvents, SelectNodeOptions, SelectOptions, SelectPopupEvents, SelectPopupExtend, SelectPopupOptions, SelectSlotOptions, SortEvents, SortOptions, SwitchEvents, SwitchOptions, TableColOptions, TableOptions, TableRowOptions, TitleOptions, ToastOptions, TreeEvents, TreeNode, TreeNodeEvents, TreeNodeExtend, TreeNodeModel, TreeNodeOptions, TreeNodeRenderOptions, TreeNodeSlotOptions, TreeOptions, TreeSearchResult, ValueOptions, WrapperEvents, WrapperOptions };
2647
+ export type { ButtonOptions, ChangeEvents, ChooseEvents, ChooseItem, ChooseOptions, ClickEvents, CloseEvents, ComponentBindOptions, ComponentOptions, ConfirmAreaOptions, ConfirmOptions, DatePickerEvents, DatepickerOptions, DeleteEvents, DialogHandle, DialogOptions, DisabledOptions, DragVerifyInfo, DragVerifyOptions, EmitterType, EmptyOptions, EventsType, FoldEvents, FoldOptions, FoldStatus, FollowElectResult, FollowExtend, FollowHandle, FollowOptions, FollowStrategy, FollowStrategyOptions, FooterEvents, FooterOptions, HeaderEvents, HeaderOptions, IPopupManager, IReactiveManager, ISelectContext, ITreeBaseContext, IconOptions, IconType, InputEvents, InputOptions, LayoutOptions, LoadingOptions, MessageOptions, MoveEvents, PlaceholderOptions, PopupDescriptor, PopupHandle, PopupOptions, PopupStatus, PopupStatusOptions, PropsType, ReactiveVar, ReadonlyOptions, ScrollEvents, ScrollOptions, ScrollStatus, SearchEvents, SearchOptions, SelectBaseEvents, SelectBaseOptions, SelectEvents, SelectItem, SelectNodeEvents, SelectNodeOptions, SelectOptions, SelectPopupEvents, SelectPopupExtend, SelectPopupOptions, SelectSlotOptions, SortEvent, SortEvents, SortGroupOptions, SortOptions, SwitchEvents, SwitchOptions, TableColOptions, TableOptions, TableRowOptions, TitleOptions, ToastOptions, TreeEvents, TreeNode, TreeNodeEvents, TreeNodeExtend, TreeNodeModel, TreeNodeOptions, TreeNodeRenderOptions, TreeNodeSlotOptions, TreeOptions, TreeSearchResult, ValueOptions, WrapperEvents, WrapperOptions };