@type-dom/ui 0.0.7 → 0.0.9

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.
Files changed (225) hide show
  1. package/package.json +1 -2
  2. package/src/aria.d.ts +0 -17
  3. package/src/aria.js +0 -18
  4. package/src/components/basic/td-button/td-button.abstract.d.ts +2 -3
  5. package/src/components/basic/td-button/td-button.abstract.js +30 -26
  6. package/src/components/basic/td-button/td-button.interface.d.ts +0 -1
  7. package/src/components/basic/td-button-group/td-button-group.class.d.ts +2 -3
  8. package/src/components/basic/td-button-group/td-button-group.class.js +14 -16
  9. package/src/components/basic/td-container/td-aside/td-aside.class.js +2 -2
  10. package/src/components/basic/td-container/td-container.class.js +5 -5
  11. package/src/components/basic/td-container/td-container.js +1 -1
  12. package/src/components/basic/td-container/td-footer/td-footer.class.js +2 -2
  13. package/src/components/basic/td-container/td-header/td-header.class.js +3 -4
  14. package/src/components/basic/td-container/td-main/td-main.class.js +2 -2
  15. package/src/components/basic/td-icon/td-icon.class.js +9 -9
  16. package/src/components/basic/td-layout/td-col/td-col.class.d.ts +5 -2
  17. package/src/components/basic/td-layout/td-col/td-col.class.js +80 -80
  18. package/src/components/basic/td-layout/td-row/td-row.class.js +13 -13
  19. package/src/components/basic/td-link/td-link.class.d.ts +0 -1
  20. package/src/components/basic/td-link/td-link.class.js +17 -19
  21. package/src/components/basic/td-scrollbar/bar/bar.class.js +3 -3
  22. package/src/components/basic/td-scrollbar/td-scrollbar.class.js +5 -5
  23. package/src/components/basic/td-scrollbar/thumb/thumb.class.js +3 -3
  24. package/src/components/basic/td-space/td-space.class.js +10 -10
  25. package/src/components/basic/td-text/td-text.class.js +12 -9
  26. package/src/components/data/td-avatar/td-avatar.class.js +12 -13
  27. package/src/components/data/td-badge/td-badge.class.d.ts +1 -0
  28. package/src/components/data/td-badge/td-badge.class.js +15 -11
  29. package/src/components/data/td-card/td-card.class.js +7 -7
  30. package/src/components/data/td-check-tag/td-check-tag.class.d.ts +0 -1
  31. package/src/components/data/td-check-tag/td-check-tag.class.js +9 -11
  32. package/src/components/data/td-collapse/td-collapse.class.js +2 -3
  33. package/src/components/data/td-collapse/td-collapse.interface.d.ts +1 -0
  34. package/src/components/data/td-collapse-item/td-collapse-item.class.js +8 -8
  35. package/src/components/data/td-collapse-transition/td-collapse-transition.util.js +14 -14
  36. package/src/components/data/td-count-down/td-count-down.class.js +1 -1
  37. package/src/components/data/td-descriptions/td-descriptions-row.js +2 -2
  38. package/src/components/data/td-descriptions/td-descriptions.class.js +8 -8
  39. package/src/components/data/td-descriptions/td-descritions-cell.js +14 -14
  40. package/src/components/data/td-descriptions-item/td-descriptions-item.class.js +1 -1
  41. package/src/components/data/td-empty/img-empty.class.js +3 -3
  42. package/src/components/data/td-empty/td-empty.class.js +4 -4
  43. package/src/components/data/td-image/td-image.class.js +6 -6
  44. package/src/components/data/td-image-viewer/td-image-viewer.class.d.ts +2 -1
  45. package/src/components/data/td-image-viewer/td-image-viewer.class.js +14 -10
  46. package/src/components/data/td-result/td-result.class.js +3 -3
  47. package/src/components/data/td-segmented/td-segmented.class.js +26 -30
  48. package/src/components/data/td-statistic/td-statistic.abstract.js +2 -2
  49. package/src/components/data/td-tag/td-tag.class.js +10 -10
  50. package/src/components/feedback/index.d.ts +0 -2
  51. package/src/components/feedback/index.js +3 -5
  52. package/src/components/feedback/td-alert/td-alert.class.js +9 -9
  53. package/src/components/feedback/td-dialog/td-dialog.class.js +4 -4
  54. package/src/components/feedback/td-dialog-content/td-dialog-content.class.js +4 -4
  55. package/src/components/feedback/td-drawer/td-drawer.class.js +1 -1
  56. package/src/components/feedback/td-focus-trap/td-focus-trap.class.d.ts +19 -1
  57. package/src/components/feedback/td-focus-trap/td-focus-trap.class.js +223 -48
  58. package/src/components/feedback/td-focus-trap/tokens.d.ts +2 -1
  59. package/src/components/feedback/td-focus-trap/utils.d.ts +1 -1
  60. package/src/components/feedback/td-focus-trap/utils.js +9 -11
  61. package/src/components/feedback/td-loading/td-loading.class.js +1 -1
  62. package/src/components/feedback/td-message/td-message.class.d.ts +4 -2
  63. package/src/components/feedback/td-message/td-message.class.js +34 -27
  64. package/src/components/feedback/td-message/td-message.style.js +2 -1
  65. package/src/components/feedback/td-message-box/td-message-box.class.d.ts +3 -1
  66. package/src/components/feedback/td-message-box/td-message-box.class.js +79 -75
  67. package/src/components/feedback/td-message-box/td-message-box.interface.d.ts +2 -1
  68. package/src/components/feedback/td-notification/td-notification.class.d.ts +3 -2
  69. package/src/components/feedback/td-notification/td-notification.class.js +29 -29
  70. package/src/components/feedback/td-only-child/td-only-child.class.d.ts +7 -0
  71. package/src/components/feedback/td-only-child/td-only-child.class.js +74 -0
  72. package/src/components/feedback/td-overlay/td-overlay.class.d.ts +1 -1
  73. package/src/components/feedback/td-overlay/td-overlay.class.js +5 -5
  74. package/src/components/feedback/td-popper/arrow/arrow.class.d.ts +6 -0
  75. package/src/components/feedback/td-popper/arrow/arrow.class.js +22 -3
  76. package/src/components/feedback/td-popper/composable/use-focus-trap.d.ts +0 -0
  77. package/src/components/feedback/td-popper/composable/use-focus-trap.js +1 -0
  78. package/src/components/feedback/td-popper/content/content.class.d.ts +1 -0
  79. package/src/components/feedback/td-popper/content/content.class.js +25 -4
  80. package/src/components/feedback/td-popper/content/content.const.d.ts +3 -0
  81. package/src/components/feedback/td-popper/content/content.const.js +29 -0
  82. package/src/components/feedback/td-popper/content/content.interface.d.ts +9 -0
  83. package/src/components/feedback/td-popper/td-popper.class.d.ts +1 -1
  84. package/src/components/feedback/td-popper/td-popper.class.js +35 -2
  85. package/src/components/feedback/td-popper/td-popper.const.d.ts +21 -0
  86. package/src/components/feedback/td-popper/td-popper.const.js +5 -0
  87. package/src/components/feedback/td-popper/trigger/trigger.class.d.ts +11 -0
  88. package/src/components/feedback/td-popper/trigger/trigger.class.js +96 -1
  89. package/src/components/feedback/td-popper/trigger/trigger.const.d.ts +1 -0
  90. package/src/components/feedback/td-popper/trigger/trigger.const.js +12 -0
  91. package/src/components/feedback/td-popper/trigger/trigger.interface.d.ts +1 -0
  92. package/src/components/feedback/td-tooltip/content/content.class.js +1 -1
  93. package/src/components/feedback/td-tooltip/td-tooltip.class.js +1 -1
  94. package/src/components/feedback/td-tooltip/trigger/trigger.class.js +1 -1
  95. package/src/components/form/checkbox-group/checkbox-group.class.js +6 -7
  96. package/src/components/form/checkbox-group/checkbox-option/checkbox-option.class.d.ts +1 -1
  97. package/src/components/form/checkbox-group/checkbox-option/checkbox-option.class.js +21 -20
  98. package/src/components/form/field-item/cascade/field-cascade.abstract.d.ts +1 -1
  99. package/src/components/form/field-item/cascade/field-cascade.abstract.js +48 -43
  100. package/src/components/form/field-item/field-item.abstract.js +3 -3
  101. package/src/components/form/field-item/input/field-input.abstract.d.ts +1 -1
  102. package/src/components/form/field-item/input/field-input.abstract.js +15 -14
  103. package/src/components/form/field-item/options/field-options.abstract.d.ts +1 -3
  104. package/src/components/form/field-item/options/field-options.abstract.js +49 -46
  105. package/src/components/form/field-item/radio/field-radio.abstract.d.ts +1 -1
  106. package/src/components/form/field-item/radio/field-radio.abstract.js +32 -36
  107. package/src/components/form/field-item/select/field-select.abstract.d.ts +1 -1
  108. package/src/components/form/field-item/select/field-select.abstract.js +19 -19
  109. package/src/components/form/field-item/span/field-span.abstract.js +5 -5
  110. package/src/components/form/field-item/textarea/field-textarea.abstract.js +5 -5
  111. package/src/components/form/field-select/field-select.class.d.ts +1 -1
  112. package/src/components/form/field-select/field-select.class.js +23 -24
  113. package/src/components/form/field-select/option/option.class.js +1 -3
  114. package/src/components/form/radio-group/radio-group.class.js +6 -7
  115. package/src/components/form/radio-group/radio-option/radio-option.class.d.ts +0 -1
  116. package/src/components/form/radio-group/radio-option/radio-option.class.js +14 -15
  117. package/src/components/form/select/select.class.d.ts +1 -1
  118. package/src/components/form/select/select.class.js +19 -18
  119. package/src/components/form/td-checkbox/td-checkbox.class.js +3 -3
  120. package/src/components/form/td-checkbox-button/td-checkbox-button.class.js +3 -3
  121. package/src/components/form/td-checkbox-group/td-checkbox-group.class.js +3 -3
  122. package/src/components/form/td-form/td-form.class.js +5 -3
  123. package/src/components/form/td-form-item/td-form-item.class.js +16 -16
  124. package/src/components/form/td-input/td-input-field.class.js +8 -8
  125. package/src/components/form/td-input/td-input.class.d.ts +0 -1
  126. package/src/components/form/td-input/td-input.class.js +9 -11
  127. package/src/components/form/td-input/widget/prefix.js +1 -1
  128. package/src/components/form/td-input/widget/suffix.js +3 -3
  129. package/src/components/form/td-input/widget/td-input-wrapper.class.js +12 -11
  130. package/src/components/form/td-input/widget/td-textarea-wrapper.js +3 -3
  131. package/src/components/form/td-option/td-option.class.js +3 -3
  132. package/src/components/form/td-option-group/td-option-group.class.js +3 -3
  133. package/src/components/form/td-radio/td-radio.class.d.ts +0 -1
  134. package/src/components/form/td-radio/td-radio.class.js +50 -54
  135. package/src/components/form/td-radio-button/td-radio-button.class.d.ts +0 -1
  136. package/src/components/form/td-radio-button/td-radio-button.class.js +46 -50
  137. package/src/components/form/td-radio-group/td-radio-group.class.js +3 -4
  138. package/src/components/form/td-select/dropdown/dropdown.class.js +2 -2
  139. package/src/components/form/td-select/td-select.class.js +2 -2
  140. package/src/components/form/td-switch/td-switch.class.d.ts +1 -1
  141. package/src/components/form/td-switch/td-switch.class.js +27 -28
  142. package/src/components/form/td-switch/widget/td-switch-core.js +6 -6
  143. package/src/components/form/td-switch/widget/td-switch-left.js +3 -3
  144. package/src/components/form/td-switch/widget/td-switch-right.js +2 -2
  145. package/src/components/navigation/td-affix/td-affix.class.d.ts +3 -0
  146. package/src/components/navigation/td-affix/td-affix.class.js +22 -20
  147. package/src/components/navigation/td-anchor/td-anchor-link/td-anchor-link.class.js +1 -1
  148. package/src/components/navigation/td-anchor/td-anchor.class.js +10 -10
  149. package/src/components/navigation/td-backtop/td-backtop.class.d.ts +5 -3
  150. package/src/components/navigation/td-backtop/td-backtop.class.js +42 -34
  151. package/src/components/navigation/td-backtop/td-backtop.interface.d.ts +3 -0
  152. package/src/components/navigation/td-backtop/use-backtop.d.ts +7 -0
  153. package/src/components/navigation/td-backtop/use-backtop.js +44 -0
  154. package/src/components/navigation/td-breadcrumb/td-breadcrumb.class.js +4 -4
  155. package/src/components/navigation/td-breadcrumb-item/td-breadcrumb-item.class.js +3 -3
  156. package/src/components/navigation/td-menu/td-menu.class.js +5 -5
  157. package/src/components/navigation/td-menu/td-menu.interface.d.ts +2 -1
  158. package/src/components/navigation/td-tabs/td-tab-bar.class.js +5 -5
  159. package/src/components/navigation/td-tabs/td-tab-nav.class.js +14 -14
  160. package/src/components/navigation/td-tabs/td-tab-pane.class.js +3 -3
  161. package/src/components/navigation/td-tabs/td-tabs.class.js +22 -25
  162. package/src/components/others/collapsible-box/collapsible-box.js +2 -2
  163. package/src/components/others/collapsible-box/contents/contents.js +2 -2
  164. package/src/components/others/collapsible-box/heading/expand-heading.d.ts +1 -1
  165. package/src/components/others/collapsible-box/heading/expand-heading.js +27 -26
  166. package/src/components/others/custom-block/custom-block.d.ts +11 -0
  167. package/src/components/others/custom-block/custom-block.js +58 -0
  168. package/src/components/others/example/example-float-control.d.ts +8 -0
  169. package/src/components/others/example/example-float-control.js +63 -0
  170. package/src/components/others/example/example-showcase.d.ts +7 -0
  171. package/src/components/others/example/example-showcase.js +20 -0
  172. package/src/components/others/example/example-source-wrapper.d.ts +9 -0
  173. package/src/components/others/example/example-source-wrapper.js +30 -0
  174. package/src/components/others/example/example.d.ts +14 -0
  175. package/src/components/others/example/example.js +77 -0
  176. package/src/components/others/example/index.d.ts +5 -0
  177. package/src/components/others/example/index.js +13 -0
  178. package/src/components/others/example/op-btns.d.ts +7 -0
  179. package/src/components/others/example/op-btns.js +95 -0
  180. package/src/components/others/index.d.ts +4 -0
  181. package/src/components/others/index.js +9 -1
  182. package/src/components/others/menus/menu.d.ts +21 -0
  183. package/src/components/others/menus/menu.js +125 -0
  184. package/src/components/others/menus/menus.d.ts +15 -0
  185. package/src/components/others/menus/menus.js +101 -0
  186. package/src/components/others/td-divider/td-divider.class.js +8 -8
  187. package/src/hooks/index.d.ts +3 -0
  188. package/src/hooks/index.js +6 -0
  189. package/src/hooks/use-cursor.d.ts +1 -0
  190. package/src/hooks/use-cursor.js +56 -0
  191. package/src/hooks/use-escape-keydown.d.ts +4 -0
  192. package/src/hooks/use-escape-keydown.js +31 -0
  193. package/src/hooks/use-forward-ref.d.ts +13 -0
  194. package/src/hooks/use-forward-ref.js +27 -0
  195. package/src/index.d.ts +1 -0
  196. package/src/index.js +1 -0
  197. package/src/ui/ui.abstract.d.ts +1 -1
  198. package/src/ui/ui.abstract.js +3 -3
  199. package/src/ui/ui.interface.d.ts +3 -3
  200. package/src/components/feedback/dialog/dialog.class.d.ts +0 -7
  201. package/src/components/feedback/dialog/dialog.class.js +0 -21
  202. package/src/components/feedback/dialog/dialog.interface.d.ts +0 -4
  203. package/src/components/feedback/dialog/dialog.interface.js +0 -2
  204. package/src/components/feedback/message-box/message-box.d.ts +0 -9
  205. package/src/components/feedback/message-box/message-box.interface.d.ts +0 -4
  206. package/src/components/feedback/message-box/message-box.interface.js +0 -2
  207. package/src/components/feedback/message-box/message-box.js +0 -33
  208. package/src/components/feedback/overlay/container/body/body.d.ts +0 -7
  209. package/src/components/feedback/overlay/container/body/body.js +0 -17
  210. package/src/components/feedback/overlay/container/container.d.ts +0 -15
  211. package/src/components/feedback/overlay/container/container.js +0 -37
  212. package/src/components/feedback/overlay/container/footer/cancel-button/cancel-button.d.ts +0 -8
  213. package/src/components/feedback/overlay/container/footer/cancel-button/cancel-button.js +0 -31
  214. package/src/components/feedback/overlay/container/footer/confirm-button/confirm-button.d.ts +0 -9
  215. package/src/components/feedback/overlay/container/footer/confirm-button/confirm-button.js +0 -31
  216. package/src/components/feedback/overlay/container/footer/footer.d.ts +0 -10
  217. package/src/components/feedback/overlay/container/footer/footer.js +0 -47
  218. package/src/components/feedback/overlay/container/header/close-button/close-button.d.ts +0 -11
  219. package/src/components/feedback/overlay/container/header/close-button/close-button.js +0 -33
  220. package/src/components/feedback/overlay/container/header/header.d.ts +0 -12
  221. package/src/components/feedback/overlay/container/header/header.js +0 -25
  222. package/src/components/feedback/overlay/container/header/title/title.d.ts +0 -9
  223. package/src/components/feedback/overlay/container/header/title/title.js +0 -19
  224. package/src/components/feedback/overlay/overlay.abstract.d.ts +0 -13
  225. package/src/components/feedback/overlay/overlay.abstract.js +0 -59
@@ -68,24 +68,21 @@ class TdMessageBox extends ui_abstract_1.UI {
68
68
  };
69
69
  // Object.assign(this.state, params); // todo this.state params 关系???
70
70
  this.to = this.getAppendToElement(params);
71
- this.transition = new framework_1.Transition({
72
- name: 'fade-in-linear',
73
- emits: {
74
- afterLeave: () => {
75
- // params?.emits?.vanish?.();
76
- this.emit('vanish');
71
+ this.messageBox = new framework_1.Div({
72
+ name: 'message-box',
73
+ attrObj: {
74
+ tabindex: '-1',
75
+ },
76
+ styleObj: td_message_box_style_1.$messageBoxStyle,
77
+ events: {
78
+ click: (evt) => {
79
+ evt === null || evt === void 0 ? void 0 : evt.stopPropagation();
77
80
  },
78
81
  },
79
82
  });
80
- this.addChild(this.transition);
81
- this.overlay = new td_overlay_class_1.TdOverlay({
82
- name: 'overlay',
83
- // styleObj: $messageBoxStyle,
84
- });
85
- this.overlayEvent = (0, framework_1.useSameTarget)(this.handleWrapperClick);
86
- this.transition.addSlot(this.overlay);
87
83
  this.dialog = new framework_1.Div({
88
84
  name: 'message-box-overlay',
85
+ childNodes: [this.messageBox], // 有问题, Div 不能直接用slot
89
86
  attrObj: {
90
87
  role: 'dialog',
91
88
  'aria-modal': 'true',
@@ -96,26 +93,28 @@ class TdMessageBox extends ui_abstract_1.UI {
96
93
  styleObj: Object.assign(Object.assign({}, td_message_box_style_1.$messageBoxOverlayStyle), { display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }),
97
94
  events: {
98
95
  click: (evt) => this.overlayEvent.onClick(evt),
99
- keydown: (evt) => this.overlayEvent.onMousedown(evt),
100
- mouseup: (evt) => {
101
- this.overlayEvent.onMouseup(evt);
102
- },
96
+ mousedown: (evt) => this.overlayEvent.onMousedown(evt),
97
+ mouseup: (evt) => this.overlayEvent.onMouseup(evt),
103
98
  },
104
99
  });
105
- this.overlay.addSlot(this.dialog);
106
- this.messageBox = new framework_1.Div({
107
- name: 'message-box',
108
- attrObj: {
109
- tabindex: '-1',
110
- },
111
- styleObj: td_message_box_style_1.$messageBoxStyle,
112
- events: {
113
- click: (evt) => {
114
- evt === null || evt === void 0 ? void 0 : evt.stopPropagation();
100
+ // this.dialog.addChild(this.messageBox);
101
+ this.overlay = new td_overlay_class_1.TdOverlay({
102
+ name: 'overlay',
103
+ // styleObj: $messageBoxStyle,
104
+ slot: this.dialog,
105
+ });
106
+ this.overlayEvent = (0, framework_1.useSameTarget)(this.handleWrapperClick);
107
+ this.transition = new framework_1.Transition({
108
+ name: 'fade-in-linear',
109
+ emits: {
110
+ afterLeave: () => {
111
+ // params?.emits?.vanish?.();
112
+ this.emit('vanish');
115
113
  },
116
114
  },
115
+ slot: this.overlay,
117
116
  });
118
- this.dialog.addChild(this.messageBox);
117
+ this.addChild(this.transition);
119
118
  let iconComponent;
120
119
  if (params === null || params === void 0 ? void 0 : params.icon) {
121
120
  iconComponent = params.icon;
@@ -194,6 +193,7 @@ class TdMessageBox extends ui_abstract_1.UI {
194
193
  this.container.addChild(this.msgDiv);
195
194
  this.msgDiv.addChild(this.getSlotNode());
196
195
  if (params === null || params === void 0 ? void 0 : params.slot) {
196
+ //
197
197
  }
198
198
  else {
199
199
  if (!(params === null || params === void 0 ? void 0 : params.dangerouslyUseHTMLString)) {
@@ -298,16 +298,16 @@ class TdMessageBox extends ui_abstract_1.UI {
298
298
  round: params.roundButton,
299
299
  // styleObj: $messageBoxCancelBtnStyle,
300
300
  events: {
301
- // click: () => { // todo
302
- // console.log('this.cancelBtn click . ');
303
- // this.handleAction('cancel');
304
- // },
305
- // keydown: (evt) => {
306
- // evt?.preventDefault();
307
- // if ((evt as KeyboardEvent).key === 'Enter') {
308
- // this.handleAction('cancel');
309
- // }
310
- // }
301
+ click: () => {
302
+ console.log('this.cancelBtn click . ');
303
+ this.handleAction('cancel');
304
+ },
305
+ keydown: (evt) => {
306
+ evt === null || evt === void 0 ? void 0 : evt.preventDefault();
307
+ if (evt.key === 'Enter') {
308
+ this.handleAction('cancel');
309
+ }
310
+ }
311
311
  },
312
312
  });
313
313
  this.btns.addChild(this.cancelBtn);
@@ -336,7 +336,7 @@ class TdMessageBox extends ui_abstract_1.UI {
336
336
  },
337
337
  });
338
338
  this.btns.addChild(this.confirmBtn);
339
- this.props = this.setParams(params);
339
+ this.props = this.useParams(params);
340
340
  const draggable = params === null || params === void 0 ? void 0 : params.draggable;
341
341
  const overflow = params === null || params === void 0 ? void 0 : params.overflow;
342
342
  const { onDraggable, offDraggable } = (0, framework_1.useDraggable)(this.messageBox.dom, (_b = this.header) === null || _b === void 0 ? void 0 : _b.dom, draggable, overflow);
@@ -369,48 +369,52 @@ class TdMessageBox extends ui_abstract_1.UI {
369
369
  // onBeforeUnmount(() => {
370
370
  // offDraggable()
371
371
  // })
372
+ // 普通显示
373
+ static show(params) {
374
+ console.log('TdMessageBox show params is ', params);
375
+ const msgBox = new TdMessageBox(params);
376
+ return msgBox.promise();
377
+ }
372
378
  // 用 callback
373
379
  static alert(message, title, params) {
374
380
  new TdMessageBox(Object.assign({ boxType: 'alert', message,
375
381
  title }, params));
376
382
  }
377
383
  static confirm(message, title, params) {
378
- return new TdMessageBox(Object.assign({ boxType: 'confirm', message,
379
- title, showCancelButton: true }, params)).promise();
384
+ const msgBox = new TdMessageBox(Object.assign({ boxType: 'confirm', message,
385
+ title, showCancelButton: true }, params));
386
+ return msgBox.promise();
380
387
  }
388
+ // todo 多次提交时,不触发返回操作。
381
389
  static prompt(message, title, params) {
382
- var _a;
383
- const msg = new TdMessageBox(Object.assign({ boxType: 'prompt', message,
390
+ const msgBox = new TdMessageBox(Object.assign({ boxType: 'prompt', message,
384
391
  title, showCancelButton: true, showInput: true }, params));
385
- const value = (_a = msg.input) === null || _a === void 0 ? void 0 : _a.value;
386
- return msg.promise(value); // todo why not prompt
392
+ const input = msgBox.input;
393
+ return msgBox.promise(input);
387
394
  }
388
- promise(value) {
395
+ promise(input) {
389
396
  return new Promise((resolve, reject) => {
390
397
  var _a;
391
- this.confirmBtn.addEvent('click', this.confirmBtn.dom, () => {
392
- console.log('confirm . then resolve . ');
393
- resolve({ action: 'confirm', value });
398
+ this.confirmBtn.setEvent('click', () => {
399
+ console.log('confirm click . then resolve . ');
400
+ resolve({ action: 'confirm', input });
401
+ });
402
+ // this.cancelBtn.removeEvent('click', this.cancelBtn.dom);
403
+ (_a = this.cancelBtn) === null || _a === void 0 ? void 0 : _a.setEvents({
404
+ click: () => {
405
+ // todo
406
+ console.log('this.cancelBtn click . ');
407
+ // this.handleAction('cancel');
408
+ resolve({ action: 'cancel' }); // todo why must add catch(...) .otherwise it will not be resolved
409
+ },
410
+ keydown: (evt) => {
411
+ // evt?.preventDefault();
412
+ if ((evt === null || evt === void 0 ? void 0 : evt.key) === 'Enter') {
413
+ // this.handleAction('cancel');
414
+ resolve({ action: 'cancel' });
415
+ }
416
+ },
394
417
  });
395
- if ((_a = this.cancelBtn) === null || _a === void 0 ? void 0 : _a.dom) {
396
- console.log('this.cancelBtn.subscriptions is ', this.cancelBtn.subscriptions);
397
- // this.cancelBtn.removeEvent('click', this.cancelBtn.dom);
398
- this.cancelBtn.addEvents({
399
- click: () => {
400
- // todo
401
- console.log('this.cancelBtn click . ');
402
- this.handleAction('cancel');
403
- resolve({ action: 'cancel' }); // todo why must add catch(...) .otherwise it will not be resolved
404
- },
405
- keydown: (evt) => {
406
- evt === null || evt === void 0 ? void 0 : evt.preventDefault();
407
- if (evt.key === 'Enter') {
408
- this.handleAction('cancel');
409
- resolve({ action: 'cancel' });
410
- }
411
- },
412
- });
413
- }
414
418
  });
415
419
  }
416
420
  doClose() {
@@ -418,7 +422,7 @@ class TdMessageBox extends ui_abstract_1.UI {
418
422
  if (!this.visible)
419
423
  return;
420
424
  this.visible = false;
421
- this.messageBox.ctrl.hide();
425
+ this.messageBox.style.hide();
422
426
  (0, framework_1.nextTick)(() => {
423
427
  if (this.state.action) {
424
428
  this.emit('action', this.state.action);
@@ -433,17 +437,17 @@ class TdMessageBox extends ui_abstract_1.UI {
433
437
  }
434
438
  }
435
439
  handleAction(action) {
436
- var _a, _b, _c, _d;
440
+ var _a, _b, _c;
437
441
  console.log('handleAction', action);
438
442
  if (this.props.boxType === 'prompt' &&
439
443
  action === 'confirm' &&
440
444
  !this.validate()) {
441
445
  return;
442
446
  }
443
- (_b = (_a = this.props).callback) === null || _b === void 0 ? void 0 : _b.call(_a, action);
447
+ ((_a = this.props) === null || _a === void 0 ? void 0 : _a.callback) && this.props.callback(action);
444
448
  this.state.action = action;
445
449
  if (this.state.beforeClose) {
446
- (_d = (_c = this.state).beforeClose) === null || _d === void 0 ? void 0 : _d.call(_c, action, this.state, this.doClose);
450
+ (_c = (_b = this.state).beforeClose) === null || _c === void 0 ? void 0 : _c.call(_b, action, this.state, this.doClose);
447
451
  }
448
452
  else {
449
453
  this.doClose();
@@ -457,7 +461,7 @@ class TdMessageBox extends ui_abstract_1.UI {
457
461
  if (inputPattern && !inputPattern.test(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '')) {
458
462
  this.state.editorErrorMessage = this.props.inputErrorMessage; // || t('el.messagebox.error') todo t 是国际化翻译的全局方法
459
463
  this.state.validateError = true;
460
- (_b = this.errorMsg) === null || _b === void 0 ? void 0 : _b.ctrl.setStyleObj({
464
+ (_b = this.errorMsg) === null || _b === void 0 ? void 0 : _b.style.setObj({
461
465
  visibility: this.state.editorErrorMessage ? 'visible' : 'hidden',
462
466
  });
463
467
  (_d = (_c = this.errorMsg) === null || _c === void 0 ? void 0 : _c.textNode) === null || _d === void 0 ? void 0 : _d.setText(this.state.editorErrorMessage || '');
@@ -469,7 +473,7 @@ class TdMessageBox extends ui_abstract_1.UI {
469
473
  if (validateResult === false) {
470
474
  this.state.editorErrorMessage = this.props.inputErrorMessage; // || t('el.messagebox.error')
471
475
  this.state.validateError = true;
472
- (_f = this.errorMsg) === null || _f === void 0 ? void 0 : _f.ctrl.setStyleObj({
476
+ (_f = this.errorMsg) === null || _f === void 0 ? void 0 : _f.style.setObj({
473
477
  visibility: this.state.editorErrorMessage ? 'visible' : 'hidden',
474
478
  });
475
479
  (_h = (_g = this.errorMsg) === null || _g === void 0 ? void 0 : _g.textNode) === null || _h === void 0 ? void 0 : _h.setText(this.state.editorErrorMessage || '');
@@ -478,7 +482,7 @@ class TdMessageBox extends ui_abstract_1.UI {
478
482
  if (typeof validateResult === 'string') {
479
483
  this.state.editorErrorMessage = validateResult;
480
484
  this.state.validateError = true;
481
- (_j = this.errorMsg) === null || _j === void 0 ? void 0 : _j.ctrl.setStyleObj({
485
+ (_j = this.errorMsg) === null || _j === void 0 ? void 0 : _j.style.setObj({
482
486
  visibility: this.state.editorErrorMessage ? 'visible' : 'hidden',
483
487
  });
484
488
  (_l = (_k = this.errorMsg) === null || _k === void 0 ? void 0 : _k.textNode) === null || _l === void 0 ? void 0 : _l.setText(this.state.editorErrorMessage || '');
@@ -2,6 +2,7 @@ import { InputEnum, TypeElement, TypeSvgSvg } from '@type-dom/framework';
2
2
  import { IStyle } from '@type-dom/css-type';
3
3
  import { IUI, IUIConfig } from '../../../ui/ui.interface';
4
4
  import { ISize } from '../../../styles/size';
5
+ import { TdInput } from '../../form';
5
6
  export interface ITdMessageBox extends IUI {
6
7
  className: 'TdMessageBox';
7
8
  }
@@ -10,7 +11,7 @@ export type IMessageBoxType = '' | 'prompt' | 'alert' | 'confirm';
10
11
  export type MessageBoxData = IMessageBoxInputData & IAction;
11
12
  export type IAction = 'confirm' | 'close' | 'cancel';
12
13
  export interface IMessageBoxInputData {
13
- value?: string;
14
+ input?: TdInput;
14
15
  action?: IAction;
15
16
  }
16
17
  export interface MessageBoxInputValidator {
@@ -1,3 +1,4 @@
1
+ import { TypeNode } from '@type-dom/framework';
1
2
  import { UI } from '../../../ui/ui.abstract';
2
3
  import { INotificationPosition, ITdNotification, ITdNotificationConfig } from './td-notification.interface';
3
4
  export declare class TdNotification extends UI<undefined> implements ITdNotification {
@@ -18,7 +19,7 @@ export declare class TdNotification extends UI<undefined> implements ITdNotifica
18
19
  private verticalProperty;
19
20
  constructor(option?: string | ITdNotificationConfig);
20
21
  mounted(): void;
21
- initEvents(): void;
22
+ destroy(root?: TypeNode): void;
22
23
  static success(params?: ITdNotificationConfig): void;
23
24
  static warning(params?: ITdNotificationConfig): void;
24
25
  static error(params?: ITdNotificationConfig): void;
@@ -26,5 +27,5 @@ export declare class TdNotification extends UI<undefined> implements ITdNotifica
26
27
  startTimer(): void;
27
28
  clearTimer(): void;
28
29
  close(): void;
29
- onKeydown({ code }: KeyboardEvent): void;
30
+ onKeydown: ({ code }: KeyboardEvent) => void;
30
31
  }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdNotification = void 0;
4
+ const utils_1 = require("@type-dom/utils");
4
5
  const framework_1 = require("@type-dom/framework");
5
6
  const svgs_1 = require("@type-dom/svgs");
6
7
  const ui_abstract_1 = require("../../../ui/ui.abstract");
7
- const aria_1 = require("../../../aria");
8
- const td_notification_style_1 = require("./td-notification.style");
9
8
  const td_icon_class_1 = require("../../basic/td-icon/td-icon.class");
9
+ const td_notification_style_1 = require("./td-notification.style");
10
10
  class TdNotification extends ui_abstract_1.UI {
11
11
  constructor(option) {
12
12
  let params;
@@ -22,6 +22,21 @@ class TdNotification extends ui_abstract_1.UI {
22
22
  this.GAP_SIZE = 16;
23
23
  this.seed = 1;
24
24
  this.timer = undefined;
25
+ this.onKeydown = ({ code }) => {
26
+ console.log('onKeydown ', code);
27
+ if (code === utils_1.EVENT_CODE.delete || code === utils_1.EVENT_CODE.backspace) {
28
+ this.clearTimer(); // press delete/backspace clear timer
29
+ }
30
+ else if (code === utils_1.EVENT_CODE.esc) {
31
+ // press esc to close the notification
32
+ if (this.visible) {
33
+ this.close();
34
+ }
35
+ }
36
+ else {
37
+ this.startTimer(); // resume timer
38
+ }
39
+ };
25
40
  this.className = 'TdNotification';
26
41
  (0, td_notification_style_1.useStyle)(params);
27
42
  this.to = document.body;
@@ -57,7 +72,7 @@ class TdNotification extends ui_abstract_1.UI {
57
72
  },
58
73
  },
59
74
  });
60
- this.transition.addSlot(this.notification);
75
+ this.transition.addChild(this.notification);
61
76
  let iconComponent;
62
77
  if ((params === null || params === void 0 ? void 0 : params.type) && svgs_1.TypeComponentsMap[params.type]) {
63
78
  console.log('params.type is ', params.type);
@@ -135,7 +150,7 @@ class TdNotification extends ui_abstract_1.UI {
135
150
  this.notification.addChild(this.group);
136
151
  const position = (params === null || params === void 0 ? void 0 : params.position) || 'top-right';
137
152
  const horizontal = position.endsWith('right') ? 'right' : 'left';
138
- this.notification.ctrl.addStyleObj({ [horizontal]: '16px' });
153
+ this.notification.style.addObj({ [horizontal]: '16px' });
139
154
  this.verticalProperty = position.startsWith('top') ? 'top' : 'bottom';
140
155
  let verticalOffset = (params === null || params === void 0 ? void 0 : params.offset) || 0;
141
156
  console.log('verticalOffset is ', verticalOffset);
@@ -147,21 +162,21 @@ class TdNotification extends ui_abstract_1.UI {
147
162
  [this.verticalProperty]: `${verticalOffset}px`,
148
163
  zIndex: 9999, // params?.zIndex ?? currentZIndex,
149
164
  };
150
- this.notification.ctrl.addStyleObj(positionStyle);
165
+ this.notification.style.addObj(positionStyle);
151
166
  TdNotification.notifyId = TdNotification.notifyId + 1;
152
167
  TdNotification.notifications[position].push(this);
153
- this.props = this.setParams(params);
168
+ this.props = this.useParams(params);
154
169
  this.mount(this.to);
155
170
  }
156
171
  mounted() {
157
172
  this.startTimer();
158
173
  // nextZIndex()
159
174
  this.visible = true;
175
+ document.addEventListener('keydown', this.onKeydown);
160
176
  }
161
- initEvents() {
162
- this.addEvent('keydown', document, (evt) => {
163
- this.onKeydown(evt);
164
- });
177
+ destroy(root) {
178
+ document.removeEventListener('keydown', this.onKeydown);
179
+ super.destroy(root);
165
180
  }
166
181
  static success(params) {
167
182
  new TdNotification(Object.assign({ type: 'success' }, params));
@@ -176,9 +191,9 @@ class TdNotification extends ui_abstract_1.UI {
176
191
  new TdNotification(Object.assign({ type: 'info' }, params));
177
192
  }
178
193
  startTimer() {
179
- var _a;
194
+ var _a, _b;
180
195
  console.log('startTimer . ');
181
- const duration = (_a = this.props.duration) !== null && _a !== void 0 ? _a : 4500;
196
+ const duration = (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 4500;
182
197
  if (duration > 0) {
183
198
  ({ stop: this.timer } = (0, framework_1.useTimeoutFn)(() => {
184
199
  if (this.visible)
@@ -192,7 +207,7 @@ class TdNotification extends ui_abstract_1.UI {
192
207
  }
193
208
  close() {
194
209
  this.visible = false;
195
- this.notification.ctrl.hide();
210
+ this.notification.style.hide();
196
211
  const position = this.props.position || 'top-right';
197
212
  TdNotification.notifications[position] = TdNotification.notifications[position].filter((notification) => notification !== this);
198
213
  TdNotification.notifyId = TdNotification.notifyId - 1;
@@ -200,28 +215,13 @@ class TdNotification extends ui_abstract_1.UI {
200
215
  console.log('height is ', verticalOffset);
201
216
  TdNotification.notifications[position].forEach((item, index) => {
202
217
  verticalOffset = verticalOffset + this.GAP_SIZE;
203
- item.notification.ctrl.setStyleObj({
218
+ item.notification.style.setObj({
204
219
  [this.verticalProperty]: `${verticalOffset}px`,
205
220
  });
206
221
  verticalOffset += item.notification.dom.offsetHeight; // + this.GAP_SIZE;
207
222
  });
208
223
  this.destroy(); // todo 应该是 Transition 的 afterLeave 触发 destroy; 会删除props
209
224
  }
210
- onKeydown({ code }) {
211
- console.log('onKeydown ', code);
212
- if (code === aria_1.EVENT_CODE.delete || code === aria_1.EVENT_CODE.backspace) {
213
- this.clearTimer(); // press delete/backspace clear timer
214
- }
215
- else if (code === aria_1.EVENT_CODE.esc) {
216
- // press esc to close the notification
217
- if (this.visible) {
218
- this.close();
219
- }
220
- }
221
- else {
222
- this.startTimer(); // resume timer
223
- }
224
- }
225
225
  }
226
226
  exports.TdNotification = TdNotification;
227
227
  TdNotification.notifyId = 0;
@@ -0,0 +1,7 @@
1
+ import { ITypeConfig } from '@type-dom/framework';
2
+ import { UI } from '../../../ui/ui.abstract';
3
+ export declare class TdOnlyChild extends UI {
4
+ className: 'TdOnlyChild';
5
+ constructor(params?: ITypeConfig);
6
+ setup(): null;
7
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TdOnlyChild = void 0;
4
+ const framework_1 = require("@type-dom/framework");
5
+ const utils_1 = require("@type-dom/utils");
6
+ const use_forward_ref_1 = require("../../../hooks/use-forward-ref");
7
+ const ui_abstract_1 = require("../../../ui/ui.abstract");
8
+ class TdOnlyChild extends ui_abstract_1.UI {
9
+ constructor(params = {}) {
10
+ super(params);
11
+ this.className = 'TdOnlyChild';
12
+ this.props = this.useParams(params);
13
+ }
14
+ setup() {
15
+ var _a;
16
+ const forwardRefInjection = this.inject(use_forward_ref_1.FORWARD_REF_INJECTION_KEY);
17
+ const forwardRefDirective = (0, use_forward_ref_1.useForwardRefDirective)((_a = forwardRefInjection === null || forwardRefInjection === void 0 ? void 0 : forwardRefInjection.setForwardRef) !== null && _a !== void 0 ? _a : utils_1.NOOP);
18
+ const defaultSlot = this.slotNodes['default'];
19
+ if (!defaultSlot)
20
+ return null;
21
+ // if (defaultSlot.length > 1) {
22
+ // // debugWarn('TdOnlyChild', 'requires exact only one valid child.')
23
+ // return null
24
+ // }
25
+ // const firstLegitNode = findFirstLegitChild(defaultSlot!)
26
+ // if (!firstLegitNode) {
27
+ // // debugWarn(NAME, 'no valid child node found')
28
+ // return null
29
+ // }
30
+ // return withDirectives(cloneVNode(firstLegitNode!, attrs), [
31
+ // [forwardRefDirective],
32
+ // ])
33
+ return null; // add by me todo
34
+ }
35
+ }
36
+ exports.TdOnlyChild = TdOnlyChild;
37
+ function findFirstLegitChild(node) {
38
+ if (!node)
39
+ return null;
40
+ const children = node;
41
+ for (const child of children) {
42
+ /**
43
+ * when user uses h(Fragment, [text]) to render plain string,
44
+ * this switch case just cannot handle, when the value is primitives
45
+ * we should just return the wrapped string
46
+ */
47
+ if ((0, utils_1.isObject)(child)) {
48
+ // switch (child.dom) { // todo
49
+ // case Comment:
50
+ // continue
51
+ // case Text:
52
+ // case SVGElement:
53
+ // return wrapTextContent(child)
54
+ // case undefined:
55
+ // return findFirstLegitChild(child.children as TypeNode[])
56
+ // default:
57
+ // return child
58
+ // }
59
+ }
60
+ return wrapTextContent(child);
61
+ }
62
+ return null;
63
+ }
64
+ function wrapTextContent(slot) {
65
+ // const ns = 'only-child';
66
+ // return `<span class=${ns + '-content'}>${s}</span>`;
67
+ return new framework_1.Span({
68
+ // text: s,
69
+ attrObj: {
70
+ class: 'only-child-content',
71
+ },
72
+ childNodes: typeof slot === 'string' ? [new framework_1.TextNode(slot)] : [slot],
73
+ });
74
+ }
@@ -1,6 +1,6 @@
1
+ import { TypeElement } from '@type-dom/framework';
1
2
  import { UI } from '../../../ui/ui.abstract';
2
3
  import { ITdOverlay, ITdOverlayConfig } from './td-overlay.interface';
3
- import { TypeElement } from '@type-dom/framework';
4
4
  export declare let overlayZIndex: number;
5
5
  export declare class TdOverlay extends UI implements ITdOverlay {
6
6
  className: 'TdOverlay';
@@ -9,14 +9,14 @@ class TdOverlay extends ui_abstract_1.UI {
9
9
  super(params);
10
10
  exports.overlayZIndex = exports.overlayZIndex + 1;
11
11
  this.className = 'TdOverlay';
12
- this.ctrl.addStyleObj(td_overlay_style_1.$tdOverlayStyle);
12
+ this.style.addObj(td_overlay_style_1.$tdOverlayStyle);
13
13
  if (params === null || params === void 0 ? void 0 : params.mask) {
14
- this.ctrl.addStyleObj({
14
+ this.style.addObj({
15
15
  zIndex: (params === null || params === void 0 ? void 0 : params.zIndex) || exports.overlayZIndex,
16
16
  });
17
17
  }
18
18
  else {
19
- this.ctrl.addStyleObj({
19
+ this.style.addObj({
20
20
  zIndex: (params === null || params === void 0 ? void 0 : params.zIndex) || exports.overlayZIndex,
21
21
  position: 'fixed',
22
22
  top: '0px',
@@ -26,10 +26,10 @@ class TdOverlay extends ui_abstract_1.UI {
26
26
  });
27
27
  }
28
28
  this.addChild(this.getSlotNode());
29
- this.props = this.setParams(params);
29
+ this.props = this.useParams(params);
30
30
  }
31
31
  addSlot(slot) {
32
- this.getSlotNode('default').resetSlot(slot);
32
+ this.getSlotNode().resetSlot(slot);
33
33
  }
34
34
  }
35
35
  exports.TdOverlay = TdOverlay;
@@ -3,5 +3,11 @@ import { ITdPopperArrow, ITdPopperArrowConfig } from './arrow.interface';
3
3
  export declare class TdPopperArrow extends UI implements ITdPopperArrow {
4
4
  className: 'TdPopperArrow';
5
5
  props: ITdPopperArrowConfig;
6
+ private arrowOffset?;
7
+ arrowRef?: HTMLElement;
8
+ private arrowStyle?;
6
9
  constructor(params?: ITdPopperArrowConfig);
10
+ setup(): void;
11
+ beforeDestroy(): void;
12
+ setArrowOffset(offset: number): void;
7
13
  }
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdPopperArrow = void 0;
4
4
  const var_1 = require("../../../../styles/var");
5
5
  const ui_abstract_1 = require("../../../../ui/ui.abstract");
6
+ const td_popper_const_1 = require("../td-popper.const");
6
7
  class TdPopperArrow extends ui_abstract_1.UI {
7
8
  constructor(params = {}) {
8
9
  super(params, 'span');
9
10
  this.className = 'TdPopperArrow';
10
- this.ctrl.addAttrName('td-popper-arrow');
11
- this.ctrl.addStyleObj({
11
+ this.attr.addName('td-popper-arrow');
12
+ this.style.addObj({
12
13
  position: 'absolute',
13
14
  width: '10px',
14
15
  height: '10px',
@@ -26,7 +27,25 @@ class TdPopperArrow extends ui_abstract_1.UI {
26
27
  boxSizing: 'border-box'
27
28
  // }
28
29
  });
29
- this.props = this.setParams(params);
30
+ this.buildProps({
31
+ arrowOffset: 5,
32
+ });
33
+ this.props = this.useParams(params);
34
+ }
35
+ setup() {
36
+ const { arrowOffset, arrowRef, arrowStyle } = this.inject(td_popper_const_1.POPPER_CONTENT_INJECTION_KEY, undefined);
37
+ this.arrowOffset = arrowOffset;
38
+ this.arrowRef = arrowRef;
39
+ this.arrowStyle = arrowStyle;
40
+ }
41
+ beforeDestroy() {
42
+ this.arrowRef = undefined;
43
+ }
44
+ setArrowOffset(offset) {
45
+ this.setProp('arrowOffset', offset);
46
+ if (offset) {
47
+ this.arrowOffset = offset;
48
+ }
30
49
  }
31
50
  }
32
51
  exports.TdPopperArrow = TdPopperArrow;
@@ -5,4 +5,5 @@ export declare class TdPopperContent extends UI implements ITdPopperContent {
5
5
  props: ITdPopperContentConfig;
6
6
  private focusTrap;
7
7
  constructor(params?: ITdPopperContentConfig);
8
+ setup(): void;
8
9
  }