snail.vue 1.0.33 → 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,7 +1,7 @@
1
1
  import * as snail_view from 'snail.view';
2
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';
4
+ import { Component, ShallowRef, Ref, WatchSource, App } from 'vue';
5
5
  import { IScope, RunResult, IAsyncScope } from 'snail.core';
6
6
 
7
7
  /**
@@ -149,6 +149,10 @@ type TreeOptions<T> = {
149
149
  */
150
150
  nodeExtend?: TreeNodeExtendOptions;
151
151
  };
152
+ /**
153
+ * 树组件事件
154
+ */
155
+ type TreeEvents<T> = {};
152
156
  /**
153
157
  * 树节点
154
158
  */
@@ -166,6 +170,12 @@ type TreeNode<T> = {
166
170
  * 树节点附加数据
167
171
  */
168
172
  data?: T;
173
+ /**
174
+ * 是否可点击
175
+ * - true 此节点可点击,点击时触发 click 事件
176
+ * - false 此节点不可点击
177
+ */
178
+ clickable?: boolean;
169
179
  /**
170
180
  * 是否禁用
171
181
  * - true:禁用此节点 禁用时不显示此节点及其子节点
@@ -184,6 +194,10 @@ type TreeNodeOptions<T> = {
184
194
  * 树节点
185
195
  */
186
196
  node: TreeNode<T>;
197
+ /**
198
+ * 父节点
199
+ */
200
+ parent?: TreeNode<T>;
187
201
  /**
188
202
  * 节点层级
189
203
  * - 从1开始
@@ -195,6 +209,18 @@ type TreeNodeOptions<T> = {
195
209
  */
196
210
  extend?: TreeNodeExtendOptions;
197
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
+ };
198
224
  /**
199
225
  * 树节点扩展配置选项
200
226
  */
@@ -410,6 +436,10 @@ type IconOptions = {
410
436
  * 图标类型
411
437
  */
412
438
  type: IconType;
439
+ /**
440
+ * 标题,鼠标移上去时的提示
441
+ */
442
+ title?: string;
413
443
  /**
414
444
  * 图标颜色
415
445
  */
@@ -641,6 +671,16 @@ interface IReactiveManager {
641
671
  * @returns 任务自身
642
672
  */
643
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;
644
684
  }
645
685
  /**
646
686
  * 响应式变量
@@ -683,6 +723,71 @@ declare function triggerAppCreated(app: App): App;
683
723
  */
684
724
  declare function getSvgDraw(options: IconOptions): string[];
685
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
+ * 排序组件 事件
781
+ */
782
+ type SortEvents = {
783
+ /**
784
+ * 元素排序顺序变化
785
+ * @param oldIndex 旧位置索引值
786
+ * @param newIndex 新顺序索引值
787
+ */
788
+ update: [oldIndex: number, newIndex: number];
789
+ };
790
+
686
791
  /**
687
792
  * 挂载vue组件
688
793
  * - 全新创建一个Vue实例挂载的传入组件
@@ -1152,6 +1257,60 @@ declare const components: {
1152
1257
  default?: (props: {}) => any;
1153
1258
  };
1154
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
+ });
1155
1314
  Table: {
1156
1315
  new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<TableOptions> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, true, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
1157
1316
  P: {};
@@ -1211,7 +1370,11 @@ declare const components: {
1211
1370
  new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{
1212
1371
  nodes: TreeNode<any>[];
1213
1372
  nodeExtend?: TreeNodeExtendOptions;
1214
- }> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, false, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
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, {
1215
1378
  P: {};
1216
1379
  B: {};
1217
1380
  D: {};
@@ -1221,14 +1384,20 @@ declare const components: {
1221
1384
  }, Readonly<{
1222
1385
  nodes: TreeNode<any>[];
1223
1386
  nodeExtend?: TreeNodeExtendOptions;
1224
- }> & Readonly<{}>, {}, {}, {}, {}, {}>;
1387
+ }> & Readonly<{
1388
+ onClick?: (node: TreeNode<any>, parent?: TreeNode<any>) => any;
1389
+ }>, {}, {}, {}, {}, {}>;
1225
1390
  __isFragment?: never;
1226
1391
  __isTeleport?: never;
1227
1392
  __isSuspense?: never;
1228
1393
  } & vue.ComponentOptionsBase<Readonly<{
1229
1394
  nodes: TreeNode<any>[];
1230
1395
  nodeExtend?: TreeNodeExtendOptions;
1231
- }> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
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 () => {
1232
1401
  $slots: {
1233
1402
  default?: (props: any) => any;
1234
1403
  };
@@ -1288,4 +1457,4 @@ declare const components: {
1288
1457
  };
1289
1458
 
1290
1459
  export { components, getSvgDraw, mount, onAppCreated, triggerAppCreated, usePopup, useReactive };
1291
- 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, SwitchEvents, SwitchOptions, TableColOptions, TableOptions, TableRowOptions, ToastOptions, TreeNode, TreeNodeExtendOptions, TreeNodeOptions, TreeOptions };
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 };