@type-dom/ui 0.0.8 → 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 (215) 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 -3
  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.js +9 -8
  28. package/src/components/data/td-card/td-card.class.js +7 -7
  29. package/src/components/data/td-check-tag/td-check-tag.class.d.ts +0 -1
  30. package/src/components/data/td-check-tag/td-check-tag.class.js +9 -11
  31. package/src/components/data/td-collapse/td-collapse.class.js +2 -2
  32. package/src/components/data/td-collapse-item/td-collapse-item.class.js +7 -7
  33. package/src/components/data/td-collapse-transition/td-collapse-transition.util.js +14 -14
  34. package/src/components/data/td-count-down/td-count-down.class.js +1 -1
  35. package/src/components/data/td-descriptions/td-descriptions-row.js +2 -2
  36. package/src/components/data/td-descriptions/td-descriptions.class.js +8 -8
  37. package/src/components/data/td-descriptions/td-descritions-cell.js +14 -14
  38. package/src/components/data/td-descriptions-item/td-descriptions-item.class.js +1 -1
  39. package/src/components/data/td-empty/img-empty.class.js +3 -3
  40. package/src/components/data/td-empty/td-empty.class.js +4 -4
  41. package/src/components/data/td-image/td-image.class.js +6 -6
  42. package/src/components/data/td-image-viewer/td-image-viewer.class.d.ts +2 -1
  43. package/src/components/data/td-image-viewer/td-image-viewer.class.js +13 -10
  44. package/src/components/data/td-result/td-result.class.js +3 -3
  45. package/src/components/data/td-segmented/td-segmented.class.js +14 -17
  46. package/src/components/data/td-statistic/td-statistic.abstract.js +2 -2
  47. package/src/components/data/td-tag/td-tag.class.js +9 -9
  48. package/src/components/feedback/index.d.ts +0 -2
  49. package/src/components/feedback/index.js +3 -5
  50. package/src/components/feedback/td-alert/td-alert.class.js +9 -9
  51. package/src/components/feedback/td-dialog/td-dialog.class.js +5 -5
  52. package/src/components/feedback/td-dialog-content/td-dialog-content.class.js +4 -4
  53. package/src/components/feedback/td-drawer/td-drawer.class.js +10 -12
  54. package/src/components/feedback/td-focus-trap/td-focus-trap.class.d.ts +19 -1
  55. package/src/components/feedback/td-focus-trap/td-focus-trap.class.js +223 -48
  56. package/src/components/feedback/td-focus-trap/tokens.d.ts +2 -1
  57. package/src/components/feedback/td-focus-trap/utils.d.ts +1 -1
  58. package/src/components/feedback/td-focus-trap/utils.js +9 -11
  59. package/src/components/feedback/td-loading/td-loading.class.js +1 -1
  60. package/src/components/feedback/td-message/td-message.class.d.ts +3 -2
  61. package/src/components/feedback/td-message/td-message.class.js +18 -18
  62. package/src/components/feedback/td-message/td-message.style.js +2 -1
  63. package/src/components/feedback/td-message-box/td-message-box.class.d.ts +3 -1
  64. package/src/components/feedback/td-message-box/td-message-box.class.js +79 -74
  65. package/src/components/feedback/td-message-box/td-message-box.interface.d.ts +2 -1
  66. package/src/components/feedback/td-notification/td-notification.class.d.ts +3 -2
  67. package/src/components/feedback/td-notification/td-notification.class.js +26 -26
  68. package/src/components/feedback/td-only-child/td-only-child.class.d.ts +7 -0
  69. package/src/components/feedback/td-only-child/td-only-child.class.js +74 -0
  70. package/src/components/feedback/td-overlay/td-overlay.class.d.ts +1 -1
  71. package/src/components/feedback/td-overlay/td-overlay.class.js +5 -5
  72. package/src/components/feedback/td-popper/arrow/arrow.class.d.ts +6 -0
  73. package/src/components/feedback/td-popper/arrow/arrow.class.js +22 -3
  74. package/src/components/feedback/td-popper/composable/use-focus-trap.d.ts +0 -0
  75. package/src/components/feedback/td-popper/composable/use-focus-trap.js +1 -0
  76. package/src/components/feedback/td-popper/content/content.class.d.ts +1 -0
  77. package/src/components/feedback/td-popper/content/content.class.js +25 -4
  78. package/src/components/feedback/td-popper/content/content.const.d.ts +3 -0
  79. package/src/components/feedback/td-popper/content/content.const.js +29 -0
  80. package/src/components/feedback/td-popper/content/content.interface.d.ts +9 -0
  81. package/src/components/feedback/td-popper/td-popper.class.d.ts +1 -1
  82. package/src/components/feedback/td-popper/td-popper.class.js +35 -2
  83. package/src/components/feedback/td-popper/td-popper.const.d.ts +21 -0
  84. package/src/components/feedback/td-popper/td-popper.const.js +5 -0
  85. package/src/components/feedback/td-popper/trigger/trigger.class.d.ts +11 -0
  86. package/src/components/feedback/td-popper/trigger/trigger.class.js +96 -1
  87. package/src/components/feedback/td-popper/trigger/trigger.const.d.ts +1 -0
  88. package/src/components/feedback/td-popper/trigger/trigger.const.js +12 -0
  89. package/src/components/feedback/td-popper/trigger/trigger.interface.d.ts +1 -0
  90. package/src/components/feedback/td-tooltip/content/content.class.js +1 -1
  91. package/src/components/feedback/td-tooltip/td-tooltip.class.js +1 -1
  92. package/src/components/feedback/td-tooltip/trigger/trigger.class.js +1 -1
  93. package/src/components/form/checkbox-group/checkbox-group.class.js +6 -7
  94. package/src/components/form/checkbox-group/checkbox-option/checkbox-option.class.d.ts +1 -1
  95. package/src/components/form/checkbox-group/checkbox-option/checkbox-option.class.js +4 -4
  96. package/src/components/form/field-item/cascade/field-cascade.abstract.d.ts +1 -1
  97. package/src/components/form/field-item/cascade/field-cascade.abstract.js +8 -8
  98. package/src/components/form/field-item/field-item.abstract.js +3 -3
  99. package/src/components/form/field-item/input/field-input.abstract.d.ts +1 -1
  100. package/src/components/form/field-item/input/field-input.abstract.js +8 -8
  101. package/src/components/form/field-item/options/field-options.abstract.d.ts +1 -3
  102. package/src/components/form/field-item/options/field-options.abstract.js +32 -30
  103. package/src/components/form/field-item/radio/field-radio.abstract.d.ts +1 -1
  104. package/src/components/form/field-item/radio/field-radio.abstract.js +32 -35
  105. package/src/components/form/field-item/select/field-select.abstract.d.ts +1 -1
  106. package/src/components/form/field-item/select/field-select.abstract.js +5 -5
  107. package/src/components/form/field-item/span/field-span.abstract.js +5 -5
  108. package/src/components/form/field-item/textarea/field-textarea.abstract.js +5 -5
  109. package/src/components/form/field-select/field-select.class.d.ts +1 -1
  110. package/src/components/form/field-select/field-select.class.js +7 -8
  111. package/src/components/form/field-select/option/option.class.js +1 -3
  112. package/src/components/form/radio-group/radio-group.class.js +6 -7
  113. package/src/components/form/radio-group/radio-option/radio-option.class.d.ts +0 -1
  114. package/src/components/form/radio-group/radio-option/radio-option.class.js +6 -8
  115. package/src/components/form/select/select.class.d.ts +1 -1
  116. package/src/components/form/select/select.class.js +4 -4
  117. package/src/components/form/td-checkbox/td-checkbox.class.js +3 -3
  118. package/src/components/form/td-checkbox-button/td-checkbox-button.class.js +3 -3
  119. package/src/components/form/td-checkbox-group/td-checkbox-group.class.js +3 -3
  120. package/src/components/form/td-form/td-form.class.js +5 -3
  121. package/src/components/form/td-form-item/td-form-item.class.js +16 -16
  122. package/src/components/form/td-input/td-input-field.class.js +8 -8
  123. package/src/components/form/td-input/td-input.class.d.ts +0 -1
  124. package/src/components/form/td-input/td-input.class.js +9 -11
  125. package/src/components/form/td-input/widget/prefix.js +1 -1
  126. package/src/components/form/td-input/widget/suffix.js +3 -3
  127. package/src/components/form/td-input/widget/td-input-wrapper.class.js +12 -11
  128. package/src/components/form/td-input/widget/td-textarea-wrapper.js +3 -3
  129. package/src/components/form/td-option/td-option.class.js +3 -3
  130. package/src/components/form/td-option-group/td-option-group.class.js +3 -3
  131. package/src/components/form/td-radio/td-radio.class.d.ts +0 -1
  132. package/src/components/form/td-radio/td-radio.class.js +50 -53
  133. package/src/components/form/td-radio-button/td-radio-button.class.d.ts +0 -1
  134. package/src/components/form/td-radio-button/td-radio-button.class.js +46 -49
  135. package/src/components/form/td-radio-group/td-radio-group.class.js +3 -4
  136. package/src/components/form/td-select/dropdown/dropdown.class.js +2 -2
  137. package/src/components/form/td-select/td-select.class.js +2 -2
  138. package/src/components/form/td-switch/td-switch.class.d.ts +1 -1
  139. package/src/components/form/td-switch/td-switch.class.js +21 -21
  140. package/src/components/form/td-switch/widget/td-switch-core.js +6 -6
  141. package/src/components/form/td-switch/widget/td-switch-left.js +3 -3
  142. package/src/components/form/td-switch/widget/td-switch-right.js +2 -2
  143. package/src/components/navigation/td-affix/td-affix.class.d.ts +3 -0
  144. package/src/components/navigation/td-affix/td-affix.class.js +22 -20
  145. package/src/components/navigation/td-anchor/td-anchor-link/td-anchor-link.class.js +1 -1
  146. package/src/components/navigation/td-anchor/td-anchor.class.js +10 -10
  147. package/src/components/navigation/td-backtop/td-backtop.class.d.ts +5 -3
  148. package/src/components/navigation/td-backtop/td-backtop.class.js +41 -32
  149. package/src/components/navigation/td-backtop/td-backtop.interface.d.ts +3 -0
  150. package/src/components/navigation/td-backtop/use-backtop.d.ts +7 -0
  151. package/src/components/navigation/td-backtop/use-backtop.js +44 -0
  152. package/src/components/navigation/td-breadcrumb/td-breadcrumb.class.js +4 -4
  153. package/src/components/navigation/td-breadcrumb-item/td-breadcrumb-item.class.js +3 -3
  154. package/src/components/navigation/td-menu/td-menu.class.js +5 -5
  155. package/src/components/navigation/td-menu/td-menu.interface.d.ts +2 -1
  156. package/src/components/navigation/td-tabs/td-tab-bar.class.js +5 -5
  157. package/src/components/navigation/td-tabs/td-tab-nav.class.js +14 -14
  158. package/src/components/navigation/td-tabs/td-tab-pane.class.js +3 -3
  159. package/src/components/navigation/td-tabs/td-tabs.class.js +4 -4
  160. package/src/components/others/collapsible-box/collapsible-box.js +2 -2
  161. package/src/components/others/collapsible-box/contents/contents.js +2 -2
  162. package/src/components/others/collapsible-box/heading/expand-heading.d.ts +1 -1
  163. package/src/components/others/collapsible-box/heading/expand-heading.js +11 -11
  164. package/src/components/others/custom-block/custom-block.js +2 -2
  165. package/src/components/others/example/example-float-control.d.ts +1 -1
  166. package/src/components/others/example/example-float-control.js +8 -8
  167. package/src/components/others/example/example-showcase.js +3 -3
  168. package/src/components/others/example/example-source-wrapper.d.ts +6 -2
  169. package/src/components/others/example/example-source-wrapper.js +3 -3
  170. package/src/components/others/example/example.d.ts +1 -2
  171. package/src/components/others/example/example.js +4 -4
  172. package/src/components/others/example/op-btns.js +9 -10
  173. package/src/components/others/menus/menu.d.ts +10 -5
  174. package/src/components/others/menus/menu.js +35 -33
  175. package/src/components/others/menus/menus.d.ts +6 -1
  176. package/src/components/others/menus/menus.js +46 -24
  177. package/src/components/others/td-divider/td-divider.class.js +8 -8
  178. package/src/hooks/index.d.ts +3 -0
  179. package/src/hooks/index.js +6 -0
  180. package/src/hooks/use-cursor.d.ts +1 -0
  181. package/src/hooks/use-cursor.js +56 -0
  182. package/src/hooks/use-escape-keydown.d.ts +4 -0
  183. package/src/hooks/use-escape-keydown.js +31 -0
  184. package/src/hooks/use-forward-ref.d.ts +13 -0
  185. package/src/hooks/use-forward-ref.js +27 -0
  186. package/src/index.d.ts +1 -0
  187. package/src/index.js +1 -0
  188. package/src/ui/ui.abstract.d.ts +1 -1
  189. package/src/ui/ui.abstract.js +2 -2
  190. package/src/components/feedback/dialog/dialog.class.d.ts +0 -7
  191. package/src/components/feedback/dialog/dialog.class.js +0 -21
  192. package/src/components/feedback/dialog/dialog.interface.d.ts +0 -4
  193. package/src/components/feedback/dialog/dialog.interface.js +0 -2
  194. package/src/components/feedback/message-box/message-box.d.ts +0 -9
  195. package/src/components/feedback/message-box/message-box.interface.d.ts +0 -4
  196. package/src/components/feedback/message-box/message-box.interface.js +0 -2
  197. package/src/components/feedback/message-box/message-box.js +0 -33
  198. package/src/components/feedback/overlay/container/body/body.d.ts +0 -7
  199. package/src/components/feedback/overlay/container/body/body.js +0 -17
  200. package/src/components/feedback/overlay/container/container.d.ts +0 -15
  201. package/src/components/feedback/overlay/container/container.js +0 -38
  202. package/src/components/feedback/overlay/container/footer/cancel-button/cancel-button.d.ts +0 -8
  203. package/src/components/feedback/overlay/container/footer/cancel-button/cancel-button.js +0 -32
  204. package/src/components/feedback/overlay/container/footer/confirm-button/confirm-button.d.ts +0 -9
  205. package/src/components/feedback/overlay/container/footer/confirm-button/confirm-button.js +0 -32
  206. package/src/components/feedback/overlay/container/footer/footer.d.ts +0 -10
  207. package/src/components/feedback/overlay/container/footer/footer.js +0 -47
  208. package/src/components/feedback/overlay/container/header/close-button/close-button.d.ts +0 -11
  209. package/src/components/feedback/overlay/container/header/close-button/close-button.js +0 -34
  210. package/src/components/feedback/overlay/container/header/header.d.ts +0 -12
  211. package/src/components/feedback/overlay/container/header/header.js +0 -25
  212. package/src/components/feedback/overlay/container/header/title/title.d.ts +0 -9
  213. package/src/components/feedback/overlay/container/header/title/title.js +0 -19
  214. package/src/components/feedback/overlay/overlay.abstract.d.ts +0 -13
  215. package/src/components/feedback/overlay/overlay.abstract.js +0 -60
@@ -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.addChild(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.setProps(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,47 +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
- // this.cancelBtn.removeEvent('click', this.cancelBtn.dom);
397
- this.cancelBtn.addEvents({
398
- click: () => {
399
- // todo
400
- console.log('this.cancelBtn click . ');
401
- this.handleAction('cancel');
402
- resolve({ action: 'cancel' }); // todo why must add catch(...) .otherwise it will not be resolved
403
- },
404
- keydown: (evt) => {
405
- evt === null || evt === void 0 ? void 0 : evt.preventDefault();
406
- if (evt.key === 'Enter') {
407
- this.handleAction('cancel');
408
- resolve({ action: 'cancel' });
409
- }
410
- },
411
- });
412
- }
413
418
  });
414
419
  }
415
420
  doClose() {
@@ -417,7 +422,7 @@ class TdMessageBox extends ui_abstract_1.UI {
417
422
  if (!this.visible)
418
423
  return;
419
424
  this.visible = false;
420
- this.messageBox.ctrl.hide();
425
+ this.messageBox.style.hide();
421
426
  (0, framework_1.nextTick)(() => {
422
427
  if (this.state.action) {
423
428
  this.emit('action', this.state.action);
@@ -432,17 +437,17 @@ class TdMessageBox extends ui_abstract_1.UI {
432
437
  }
433
438
  }
434
439
  handleAction(action) {
435
- var _a, _b, _c, _d;
440
+ var _a, _b, _c;
436
441
  console.log('handleAction', action);
437
442
  if (this.props.boxType === 'prompt' &&
438
443
  action === 'confirm' &&
439
444
  !this.validate()) {
440
445
  return;
441
446
  }
442
- (_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);
443
448
  this.state.action = action;
444
449
  if (this.state.beforeClose) {
445
- (_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);
446
451
  }
447
452
  else {
448
453
  this.doClose();
@@ -456,7 +461,7 @@ class TdMessageBox extends ui_abstract_1.UI {
456
461
  if (inputPattern && !inputPattern.test(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '')) {
457
462
  this.state.editorErrorMessage = this.props.inputErrorMessage; // || t('el.messagebox.error') todo t 是国际化翻译的全局方法
458
463
  this.state.validateError = true;
459
- (_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({
460
465
  visibility: this.state.editorErrorMessage ? 'visible' : 'hidden',
461
466
  });
462
467
  (_d = (_c = this.errorMsg) === null || _c === void 0 ? void 0 : _c.textNode) === null || _d === void 0 ? void 0 : _d.setText(this.state.editorErrorMessage || '');
@@ -468,7 +473,7 @@ class TdMessageBox extends ui_abstract_1.UI {
468
473
  if (validateResult === false) {
469
474
  this.state.editorErrorMessage = this.props.inputErrorMessage; // || t('el.messagebox.error')
470
475
  this.state.validateError = true;
471
- (_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({
472
477
  visibility: this.state.editorErrorMessage ? 'visible' : 'hidden',
473
478
  });
474
479
  (_h = (_g = this.errorMsg) === null || _g === void 0 ? void 0 : _g.textNode) === null || _h === void 0 ? void 0 : _h.setText(this.state.editorErrorMessage || '');
@@ -477,7 +482,7 @@ class TdMessageBox extends ui_abstract_1.UI {
477
482
  if (typeof validateResult === 'string') {
478
483
  this.state.editorErrorMessage = validateResult;
479
484
  this.state.validateError = true;
480
- (_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({
481
486
  visibility: this.state.editorErrorMessage ? 'visible' : 'hidden',
482
487
  });
483
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;
@@ -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.setProps(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));
@@ -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.setProps(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.setProps(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
  }
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdPopperContent = void 0;
4
+ const utils_1 = require("@type-dom/utils");
4
5
  const ui_abstract_1 = require("../../../../ui/ui.abstract");
5
6
  const td_focus_trap_class_1 = require("../../td-focus-trap/td-focus-trap.class");
7
+ const content_const_1 = require("./content.const");
8
+ const td_form_const_1 = require("../../../form/td-form/td-form.const");
9
+ const td_popper_const_1 = require("../td-popper.const");
6
10
  class TdPopperContent extends ui_abstract_1.UI {
7
11
  constructor(params = {}) {
8
12
  super(params);
9
13
  this.className = 'TdPopperContent';
10
- this.ctrl.addAttrName('td-popper-content');
11
- this.ctrl.addAttrObj({
14
+ this.attr.addName('td-popper-content');
15
+ this.attr.addObj({
12
16
  tabindex: -1
13
17
  });
14
- this.ctrl.addStyleObj({
18
+ this.style.addObj({
15
19
  // padding: '10px',
16
20
  // backgroundColor: $bgColors.default,
17
21
  // borderRadius: $borderRadius.base,
@@ -19,7 +23,24 @@ class TdPopperContent extends ui_abstract_1.UI {
19
23
  });
20
24
  this.focusTrap = new td_focus_trap_class_1.TdFocusTrap();
21
25
  this.addChild(this.focusTrap);
22
- this.props = this.setProps(params);
26
+ if (params.contentStyle) { // todo
27
+ this.style.addObj(params.contentStyle);
28
+ }
29
+ this.buildProps(content_const_1.popperContentProps);
30
+ this.props = this.useParams(params);
31
+ }
32
+ setup() {
33
+ const formItemContext = this.inject(td_form_const_1.formItemContextKey, undefined);
34
+ const arrowOffset = 0;
35
+ this.provide(td_popper_const_1.POPPER_CONTENT_INJECTION_KEY, {
36
+ // arrowStyle,
37
+ // arrowRef,
38
+ arrowOffset,
39
+ });
40
+ if (formItemContext) {
41
+ // disallow auto-id from inside popper content
42
+ this.provide(td_form_const_1.formItemContextKey, Object.assign(Object.assign({}, formItemContext), { addInputId: utils_1.NOOP, removeInputId: utils_1.NOOP }));
43
+ }
23
44
  }
24
45
  }
25
46
  exports.TdPopperContent = TdPopperContent;
@@ -0,0 +1,3 @@
1
+ import { IPopperCoreConfigProps, ITdPopperContentConfig } from './content.interface';
2
+ export declare const popperCoreConfigProps: IPopperCoreConfigProps;
3
+ export declare const popperContentProps: ITdPopperContentConfig;