snail.vue 1.0.32 → 1.0.35

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.
@@ -1,8 +1,8 @@
1
1
  import * as snail_view from 'snail.view';
2
- import { BaseStyle, WidthStyle, FlexBoxStyle, HeightStyle, BorderStyle, PaddingStyle } from 'snail.view';
2
+ import { BaseStyle, WidthStyle, FlexBoxStyle, HeightStyle, BorderStyle, PaddingStyle, MarginStyle } from 'snail.view';
3
3
  import * as vue from 'vue';
4
- import { Component, ShallowRef, Ref, App } from 'vue';
5
- import { IScope, IAsyncScope } from 'snail.core';
4
+ import { Component, ShallowRef, Ref, WatchSource, App } from 'vue';
5
+ import { IScope, RunResult, IAsyncScope } from 'snail.core';
6
6
 
7
7
  /**
8
8
  * loading提示框的配置选项
@@ -135,6 +135,109 @@ type InputEvents = {
135
135
  change: [value: string];
136
136
  };
137
137
 
138
+ /**
139
+ * 树组件配置选项
140
+ */
141
+ type TreeOptions<T> = {
142
+ /**
143
+ * 树节点
144
+ */
145
+ nodes: TreeNode<T>[];
146
+ /**
147
+ * 树节点的扩展配置
148
+ * - 用于对树节点做进一步控制
149
+ */
150
+ nodeExtend?: TreeNodeExtendOptions;
151
+ };
152
+ /**
153
+ * 树组件事件
154
+ */
155
+ type TreeEvents<T> = {};
156
+ /**
157
+ * 树节点
158
+ */
159
+ type TreeNode<T> = {
160
+ /**
161
+ * 树节点 文本
162
+ */
163
+ text: string;
164
+ /**
165
+ * 节点类型
166
+ * - 用于外部构建插槽时做区分使用
167
+ */
168
+ type?: string;
169
+ /**
170
+ * 树节点附加数据
171
+ */
172
+ data?: T;
173
+ /**
174
+ * 是否可点击
175
+ * - true 此节点可点击,点击时触发 click 事件
176
+ * - false 此节点不可点击
177
+ */
178
+ clickable?: boolean;
179
+ /**
180
+ * 是否禁用
181
+ * - true:禁用此节点 禁用时不显示此节点及其子节点
182
+ */
183
+ disabled?: boolean;
184
+ /**
185
+ * 子节点 数据
186
+ */
187
+ children?: TreeNode<T>[];
188
+ };
189
+ /**
190
+ * 树节点 组件配置选项
191
+ */
192
+ type TreeNodeOptions<T> = {
193
+ /**
194
+ * 树节点
195
+ */
196
+ node: TreeNode<T>;
197
+ /**
198
+ * 父节点
199
+ */
200
+ parent?: TreeNode<T>;
201
+ /**
202
+ * 节点层级
203
+ * - 从1开始
204
+ */
205
+ level: number;
206
+ /**
207
+ * 节点的扩展配置
208
+ * - 用于对树节点做进一步控制
209
+ */
210
+ extend?: TreeNodeExtendOptions;
211
+ };
212
+ /**
213
+ * 树节点事件
214
+ */
215
+ type TreeNodeEvents<T> = {
216
+ /**
217
+ * 点击树节点
218
+ * - 节点 clickable 为 true 时,点击此节点时触发
219
+ * @param node 点击的树节点
220
+ * @param parent node 所属 父节点
221
+ */
222
+ click: [node: TreeNode<T>, parent?: TreeNode<T>];
223
+ };
224
+ /**
225
+ * 树节点扩展配置选项
226
+ */
227
+ type TreeNodeExtendOptions = {
228
+ /**
229
+ * 是否禁用【折叠】子节点操作
230
+ * - true 时禁用 折叠操作
231
+ */
232
+ foldDisabled?: boolean;
233
+ /**
234
+ * 重写树节点
235
+ * - true 时,插槽作为完整树节点对象;
236
+ * - false 时,插槽仅作为扩展元素,如自定义操作等
237
+ */
238
+ rewrite?: boolean;
239
+ };
240
+
138
241
  /**
139
242
  * 滚动视图配置选项
140
243
  */
@@ -300,6 +403,30 @@ type SwitchEvents = {
300
403
  change: [value: boolean];
301
404
  };
302
405
 
406
+ /**
407
+ * 搜索组件配置选项
408
+ */
409
+ type SearchOptions = {
410
+ /**
411
+ * 是否为只读模式
412
+ */
413
+ readonly?: boolean;
414
+ /**
415
+ * 搜索提示语
416
+ */
417
+ placeholder?: string;
418
+ };
419
+ /**
420
+ * 搜索组件事件
421
+ */
422
+ type SearchEvents = {
423
+ /**
424
+ * 事件:执行搜索
425
+ * @param value 为搜索文本
426
+ */
427
+ search: [value: string];
428
+ };
429
+
303
430
  /**
304
431
  * 图标配置选项
305
432
  * - 后续支持外部直接传入svg路径,这样实现更细粒度的控制
@@ -309,10 +436,18 @@ type IconOptions = {
309
436
  * 图标类型
310
437
  */
311
438
  type: IconType;
439
+ /**
440
+ * 标题,鼠标移上去时的提示
441
+ */
442
+ title?: string;
312
443
  /**
313
444
  * 图标颜色
314
445
  */
315
446
  color?: string;
447
+ /**
448
+ * 鼠标移入时的图标颜色
449
+ */
450
+ hoverColor?: string;
316
451
  /**
317
452
  * 图标大小:默认24
318
453
  */
@@ -321,8 +456,9 @@ type IconOptions = {
321
456
  * 图标绘制路径
322
457
  * - 等效 svg-path的d属性
323
458
  * - 仅在type为 custom 时生效
459
+ * - 若为数组,则表示多条绘制路径
324
460
  */
325
- draw?: string;
461
+ draw?: string | string[];
326
462
  };
327
463
  /**
328
464
  * 图标类型
@@ -330,22 +466,11 @@ type IconOptions = {
330
466
  * - close 关闭 用作数据删除,弹窗关闭
331
467
  * - error 错误
332
468
  * - warn 警告图标
469
+ * - trash 垃圾桶图标,常用于【删除】操作
470
+ * - grip 紧握图标,垂直方向,一般用于拖动句柄
333
471
  * - custom 自定义图标:此时IconOptions.draw属性传入绘制路径
334
472
  */
335
- type IconType = "success" | "close" | "error" | "warn" | "custom";
336
- /**
337
- * 图标路径配置选项
338
- */
339
- type IconPathOptions = {
340
- /**
341
- * 绘制路径
342
- */
343
- d: string;
344
- /**
345
- * 填充颜色
346
- */
347
- fill?: string;
348
- };
473
+ type IconType = "success" | "close" | "error" | "warn" | "trash" | "grip" | "custom";
349
474
 
350
475
  /**
351
476
  * 头部配置选项
@@ -435,6 +560,65 @@ type FooterEvents = {
435
560
  confirm: [];
436
561
  };
437
562
 
563
+ /**
564
+ * 检查选项 数据结构
565
+ */
566
+
567
+ /**
568
+ * 选择 组件配置选项
569
+ */
570
+ type ChooseOptions<T> = {
571
+ /**
572
+ * 是否为多选模式
573
+ * - true 多选模式,可以选中items中多个选项
574
+ * - false 单选模式,只能选中items中的一个选项
575
+ */
576
+ multi?: boolean;
577
+ /**
578
+ * 选项类型
579
+ * - radio: 单选框样式
580
+ * - checkbox: 多选框样式
581
+ */
582
+ type: "checkbox" | "radio";
583
+ /**
584
+ * 是否是只读模式
585
+ */
586
+ readonly?: boolean;
587
+ /**
588
+ * 待选项目
589
+ * text 可不传入
590
+ */
591
+ items: ChooseItem<T>[];
592
+ /**
593
+ * 选项自定义样式
594
+ * - 可指定选项宽度、高度、外边距
595
+ */
596
+ itemStyle?: WidthStyle & HeightStyle & MarginStyle;
597
+ };
598
+ /**
599
+ * 选择项
600
+ */
601
+ type ChooseItem<T> = {
602
+ /**
603
+ * 选项文本
604
+ */
605
+ text?: string;
606
+ /**
607
+ * 选项值
608
+ */
609
+ value: any;
610
+ };
611
+ /**
612
+ * 选择 组件事件
613
+ */
614
+ type ChooseEvents<T> = {
615
+ /**
616
+ * 值改变 事件
617
+ * - values 为当前选中值;单选时为单个值,多选时为值数组
618
+ */
619
+ change: [values: T | T[]];
620
+ };
621
+
438
622
  /**
439
623
  * 按钮配置选项
440
624
  */
@@ -471,7 +655,7 @@ interface IReactiveManager {
471
655
  * @param time 过渡持续时间,到时间后销毁作用域
472
656
  * @returns 作用域对象,可销毁【值过渡】效果
473
657
  */
474
- transition<T>(rv: ShallowRef<T> | Ref<T>, effect: {
658
+ transition<T>(rv: ReactiveVar<T>, effect: {
475
659
  from: T;
476
660
  to: T;
477
661
  }, time: number): IScope;
@@ -486,11 +670,17 @@ interface IReactiveManager {
486
670
  * @param delay 延迟时间,单位ms;不传则不延迟
487
671
  * @returns 任务自身
488
672
  */
489
- load<T, E>(task: Promise<T>, loading: ShallowRef<boolean> | Ref<boolean>, delay: number): Promise<{
490
- success: boolean;
491
- data?: T;
492
- error?: E;
493
- }>;
673
+ load<T>(task: Promise<T>, loading: ReactiveVar<boolean>, delay: number): Promise<RunResult<T>>;
674
+ /**
675
+ * 监听器:监听单个值变化
676
+ * - 内部利用vue的watch逻辑实现
677
+ * - 自动进行生命周期管理,作用域销毁时自动清理watch监听
678
+ * - 仅实现简化版本watch监听;复杂的监听逻辑,自行使用watch方法
679
+ * @param source 监听源
680
+ * @param callback 回调方法:可接收新旧值变化
681
+ * @returns 监听作用域,destroy可销毁监听
682
+ */
683
+ watcher<T>(source: WatchSource<T>, callback: (newValue: T, oldValue: T) => void): IScope;
494
684
  }
495
685
  /**
496
686
  * 响应式变量
@@ -526,12 +716,77 @@ declare function triggerAppCreated(app: App): App;
526
716
  */
527
717
 
528
718
  /**
529
- * 基于类型获取Svg图标信息
719
+ * 基于类型获取Svg图标绘制路径
530
720
  * @param type 图标类型
531
721
  * @param color 填充颜色,不传入则使用默认的
532
- * @returns 图标路径信息
722
+ * @returns 图标路径
723
+ */
724
+ declare function getSvgDraw(options: IconOptions): string[];
725
+
726
+ /**
727
+ * 排序组件 配置选项
728
+ * - 整理部分SortableJs中的配置,不分逻辑不开放
729
+ */
730
+ type SortOptions<T> = {
731
+ /**
732
+ * 变化器
733
+ * - 在此元素值发生变化时,重新刷新排序面板
734
+ * - 如在增加元素时,改变此值实现 新元素 可拖拽排序
735
+ */
736
+ changer: T;
737
+ /**
738
+ * 是否禁用排序
739
+ * - true 不支持排序
740
+ */
741
+ disabled?: boolean;
742
+ /**
743
+ * 拖动哪个元素
744
+ * - 传入类样式选择器;如 .table-row
745
+ */
746
+ draggable: string;
747
+ /**
748
+ * 哪个元素启动拖拽
749
+ * - 传入类样式选择器;如 .sort-handle
750
+ * - 不传入则默认 draggable
751
+ * - 若自定义,则传入 draggable 下的dom元素作为启动拖拽的句柄
752
+ */
753
+ handle?: string;
754
+ /**
755
+ * 拖动的元素上增加的类样式
756
+ * - 执行拖拽时随着鼠标移动元素,脱离文档流了
757
+ * - 可自定义一些样式实现拖动元素的高度、宽度自定义等
758
+ * - 默认:snail-sort-drag
759
+ */
760
+ dragClass?: string;
761
+ /**
762
+ * 幽灵元素类样式名称
763
+ * - 拖动时在面板上占位的元素
764
+ * - 默认:snail-sort-ghost
765
+ */
766
+ ghostClass?: string;
767
+ /**
768
+ * 排序组
769
+ * - 组相同时,可跨组拖拽排序
770
+ * - 不传入,则内部生成guid
771
+ */
772
+ group?: string;
773
+ /**
774
+ * 动画时间
775
+ * - 单位ms;默认150ms
776
+ */
777
+ animation?: number;
778
+ };
779
+ /**
780
+ * 排序组件 事件
533
781
  */
534
- declare function getSvgIcon(options: IconOptions): IconPathOptions;
782
+ type SortEvents = {
783
+ /**
784
+ * 元素排序顺序变化
785
+ * @param oldIndex 旧位置索引值
786
+ * @param newIndex 新顺序索引值
787
+ */
788
+ update: [oldIndex: number, newIndex: number];
789
+ };
535
790
 
536
791
  /**
537
792
  * 挂载vue组件
@@ -822,6 +1077,29 @@ declare const components: {
822
1077
  default?: (props: {}) => any;
823
1078
  };
824
1079
  });
1080
+ Choose: vue.DefineComponent<{
1081
+ multi?: boolean;
1082
+ type: "checkbox" | "radio";
1083
+ readonly?: boolean;
1084
+ items: ChooseItem<any>[];
1085
+ itemStyle?: snail_view.WidthStyle & snail_view.HeightStyle & snail_view.MarginStyle;
1086
+ } & {
1087
+ modelValue?: any | any[];
1088
+ }, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
1089
+ change: (values: any) => any;
1090
+ "update:modelValue": (value: any) => any;
1091
+ }, string, vue.PublicProps, Readonly<{
1092
+ multi?: boolean;
1093
+ type: "checkbox" | "radio";
1094
+ readonly?: boolean;
1095
+ items: ChooseItem<any>[];
1096
+ itemStyle?: snail_view.WidthStyle & snail_view.HeightStyle & snail_view.MarginStyle;
1097
+ } & {
1098
+ modelValue?: any | any[];
1099
+ }> & Readonly<{
1100
+ onChange?: (values: any) => any;
1101
+ "onUpdate:modelValue"?: (value: any) => any;
1102
+ }>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
825
1103
  Footer: {
826
1104
  new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<FooterOptions> & Readonly<{
827
1105
  onCancel?: () => any;
@@ -882,6 +1160,17 @@ declare const components: {
882
1160
  };
883
1161
  });
884
1162
  Icon: vue.DefineComponent<IconOptions, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<IconOptions> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
1163
+ Search: vue.DefineComponent<SearchOptions & {
1164
+ modelValue?: string;
1165
+ }, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
1166
+ search: (value: string) => any;
1167
+ "update:modelValue": (value: string) => any;
1168
+ }, string, vue.PublicProps, Readonly<SearchOptions & {
1169
+ modelValue?: string;
1170
+ }> & Readonly<{
1171
+ onSearch?: (value: string) => any;
1172
+ "onUpdate:modelValue"?: (value: string) => any;
1173
+ }>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
885
1174
  Switch: vue.DefineComponent<SwitchOptions & {
886
1175
  modelValue?: boolean;
887
1176
  }, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
@@ -968,6 +1257,60 @@ declare const components: {
968
1257
  default?: (props: {}) => any;
969
1258
  };
970
1259
  });
1260
+ Sort: {
1261
+ new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{
1262
+ changer: any;
1263
+ disabled?: boolean;
1264
+ draggable: string;
1265
+ handle?: string;
1266
+ dragClass?: string;
1267
+ ghostClass?: string;
1268
+ group?: string;
1269
+ animation?: number;
1270
+ }> & Readonly<{
1271
+ onUpdate?: (oldIndex: number, newIndex: number) => any;
1272
+ }>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
1273
+ update: (oldIndex: number, newIndex: number) => any;
1274
+ }, vue.PublicProps, {}, false, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
1275
+ P: {};
1276
+ B: {};
1277
+ D: {};
1278
+ C: {};
1279
+ M: {};
1280
+ Defaults: {};
1281
+ }, Readonly<{
1282
+ changer: any;
1283
+ disabled?: boolean;
1284
+ draggable: string;
1285
+ handle?: string;
1286
+ dragClass?: string;
1287
+ ghostClass?: string;
1288
+ group?: string;
1289
+ animation?: number;
1290
+ }> & Readonly<{
1291
+ onUpdate?: (oldIndex: number, newIndex: number) => any;
1292
+ }>, {}, {}, {}, {}, {}>;
1293
+ __isFragment?: never;
1294
+ __isTeleport?: never;
1295
+ __isSuspense?: never;
1296
+ } & vue.ComponentOptionsBase<Readonly<{
1297
+ changer: any;
1298
+ disabled?: boolean;
1299
+ draggable: string;
1300
+ handle?: string;
1301
+ dragClass?: string;
1302
+ ghostClass?: string;
1303
+ group?: string;
1304
+ animation?: number;
1305
+ }> & Readonly<{
1306
+ onUpdate?: (oldIndex: number, newIndex: number) => any;
1307
+ }>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
1308
+ update: (oldIndex: number, newIndex: number) => any;
1309
+ }, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1310
+ $slots: {
1311
+ default?: (props: {}) => any;
1312
+ };
1313
+ });
971
1314
  Table: {
972
1315
  new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<TableOptions> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, true, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
973
1316
  P: {};
@@ -1023,6 +1366,42 @@ declare const components: {
1023
1366
  default?: (props: {}) => any;
1024
1367
  };
1025
1368
  });
1369
+ Tree: {
1370
+ new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{
1371
+ nodes: TreeNode<any>[];
1372
+ nodeExtend?: TreeNodeExtendOptions;
1373
+ }> & Readonly<{
1374
+ onClick?: (node: TreeNode<any>, parent?: TreeNode<any>) => any;
1375
+ }>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
1376
+ click: (node: TreeNode<any>, parent?: TreeNode<any>) => any;
1377
+ }, vue.PublicProps, {}, false, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
1378
+ P: {};
1379
+ B: {};
1380
+ D: {};
1381
+ C: {};
1382
+ M: {};
1383
+ Defaults: {};
1384
+ }, Readonly<{
1385
+ nodes: TreeNode<any>[];
1386
+ nodeExtend?: TreeNodeExtendOptions;
1387
+ }> & Readonly<{
1388
+ onClick?: (node: TreeNode<any>, parent?: TreeNode<any>) => any;
1389
+ }>, {}, {}, {}, {}, {}>;
1390
+ __isFragment?: never;
1391
+ __isTeleport?: never;
1392
+ __isSuspense?: never;
1393
+ } & vue.ComponentOptionsBase<Readonly<{
1394
+ nodes: TreeNode<any>[];
1395
+ nodeExtend?: TreeNodeExtendOptions;
1396
+ }> & Readonly<{
1397
+ onClick?: (node: TreeNode<any>, parent?: TreeNode<any>) => any;
1398
+ }>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
1399
+ click: (node: TreeNode<any>, parent?: TreeNode<any>) => any;
1400
+ }, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1401
+ $slots: {
1402
+ default?: (props: any) => any;
1403
+ };
1404
+ });
1026
1405
  Input: vue.DefineComponent<InputOptions & {
1027
1406
  modelValue?: string;
1028
1407
  }, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
@@ -1077,5 +1456,5 @@ declare const components: {
1077
1456
  });
1078
1457
  };
1079
1458
 
1080
- export { components, getSvgIcon, mount, onAppCreated, triggerAppCreated, usePopup, useReactive };
1081
- export type { ButtonOptions, ComponentMountOptions, ComponentOptions, ConfirmOptions, DailogExtend, DialogHandle, DialogOptions, DragVerifyInfo, DragVerifyOptions, EmptyOptions, FoldEvents, FoldOptions, FoldStatus, FooterEvents, FooterOptions, HeaderEvents, HeaderOptions, IPopupManager, IReactiveManager, IconOptions, IconPathOptions, IconType, InputEvents, InputOptions, LoadingOptions, PopupDescriptor, PopupExtend, PopupFlagOptions, PopupHandle, PopupOptions, PopupStatus, ReactiveVar, ScrollEvents, ScrollOptions, ScrollTouchType, SwitchEvents, SwitchOptions, TableColOptions, TableOptions, TableRowOptions, ToastOptions };
1459
+ export { components, getSvgDraw, mount, onAppCreated, triggerAppCreated, usePopup, useReactive };
1460
+ export type { ButtonOptions, ChooseEvents, ChooseItem, ChooseOptions, ComponentMountOptions, ComponentOptions, ConfirmOptions, DailogExtend, DialogHandle, DialogOptions, DragVerifyInfo, DragVerifyOptions, EmptyOptions, FoldEvents, FoldOptions, FoldStatus, FooterEvents, FooterOptions, HeaderEvents, HeaderOptions, IPopupManager, IReactiveManager, IconOptions, IconType, InputEvents, InputOptions, LoadingOptions, PopupDescriptor, PopupExtend, PopupFlagOptions, PopupHandle, PopupOptions, PopupStatus, ReactiveVar, ScrollEvents, ScrollOptions, ScrollTouchType, SearchEvents, SearchOptions, SortEvents, SortOptions, SwitchEvents, SwitchOptions, TableColOptions, TableOptions, TableRowOptions, ToastOptions, TreeEvents, TreeNode, TreeNodeEvents, TreeNodeExtendOptions, TreeNodeOptions, TreeOptions };