@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
@@ -8,7 +8,7 @@ class TdSwitchRight extends framework_1.TypeSpan {
8
8
  constructor(params = {}) {
9
9
  super();
10
10
  this.className = 'TdSwitchRight';
11
- this.ctrl.addStyleObj(Object.assign(Object.assign({}, td_switch_style_1.$switchLabel), { marginLeft: '10px' }));
11
+ this.style.addObj(Object.assign(Object.assign({}, td_switch_style_1.$switchLabel), { marginLeft: '10px' }));
12
12
  if (params === null || params === void 0 ? void 0 : params.activeIcon) {
13
13
  this.addChild(new td_icon_class_1.TdIcon({
14
14
  svgObj: params.activeIcon
@@ -19,7 +19,7 @@ class TdSwitchRight extends framework_1.TypeSpan {
19
19
  text: params.activeText
20
20
  }));
21
21
  }
22
- this.props = this.setProps(params);
22
+ this.props = this.useParams(params);
23
23
  }
24
24
  }
25
25
  exports.TdSwitchRight = TdSwitchRight;
@@ -1,3 +1,4 @@
1
+ import { TypeNode } from '@type-dom/framework';
1
2
  import { UI } from '../../../ui/ui.abstract';
2
3
  import { ITdAffix, ITdAffixConfig } from './td-affix.interface';
3
4
  import { IStyle } from '@type-dom/css-type';
@@ -21,5 +22,7 @@ export declare class TdAffix extends UI implements ITdAffix {
21
22
  get rootStyle(): IStyle;
22
23
  get affixStyle(): IStyle;
23
24
  mounted(): void;
25
+ destroy(root?: TypeNode): void;
26
+ onScroll: () => void;
24
27
  change(): void;
25
28
  }
@@ -1,19 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdAffix = void 0;
4
- const rxjs_1 = require("rxjs");
5
4
  const utils_1 = require("@type-dom/utils");
6
5
  const framework_1 = require("@type-dom/framework");
7
6
  const ui_abstract_1 = require("../../../ui/ui.abstract");
8
7
  class TdAffix extends ui_abstract_1.UI {
9
8
  constructor(params = {}) {
10
9
  super(params);
10
+ this.onScroll = () => {
11
+ console.log('this.scrollContainer scroll . ');
12
+ // if (this.fixed) {
13
+ this.style.setObj(this.rootStyle);
14
+ this.affix.style.setObj(this.affixStyle);
15
+ // }
16
+ this.updateRoot();
17
+ };
11
18
  console.log('TdAffix constructor . ');
12
19
  this.className = 'TdAffix';
13
- this.ctrl.addAttrName('td-affix');
20
+ this.attr.addName('td-affix');
14
21
  this.windowHeight = (0, framework_1.useWindowSize)().height;
15
22
  const { height, width, top, bottom, update } = (0, framework_1.useElementBounding)(this, {
16
- windowScroll: false
23
+ windowScroll: false,
17
24
  });
18
25
  this.rootHeight = height;
19
26
  this.rootWidth = width;
@@ -29,21 +36,21 @@ class TdAffix extends ui_abstract_1.UI {
29
36
  this.scrollTop = 0;
30
37
  this.transform = 0;
31
38
  // todo rootStyle
32
- this.ctrl.addStyleObj(this.rootStyle);
39
+ this.style.addObj(this.rootStyle);
33
40
  this.affix = new framework_1.Div({
34
41
  name: 'fix',
35
- styleObj: this.affixStyle
42
+ styleObj: this.affixStyle,
36
43
  });
37
44
  if (params === null || params === void 0 ? void 0 : params.slot) {
38
45
  this.affix.slotChild(params.slot);
39
46
  }
40
47
  this.addChild(this.affix);
41
- this.props = this.setProps(params);
48
+ this.props = this.useParams(params);
42
49
  }
43
50
  get rootStyle() {
44
51
  return {
45
52
  height: this.fixed ? this.rootHeight : '',
46
- width: this.fixed ? this.rootWidth : ''
53
+ width: this.fixed ? this.rootWidth : '',
47
54
  };
48
55
  }
49
56
  get affixStyle() {
@@ -57,7 +64,7 @@ class TdAffix extends ui_abstract_1.UI {
57
64
  top: position === 'top' ? offset : '',
58
65
  bottom: position === 'bottom' ? offset : '',
59
66
  transform: this.transform ? `translateY(${this.transform}px)` : '',
60
- zIndex: (props === null || props === void 0 ? void 0 : props.zIndex) || 100
67
+ zIndex: (props === null || props === void 0 ? void 0 : props.zIndex) || 100,
61
68
  };
62
69
  }
63
70
  mounted() {
@@ -73,25 +80,20 @@ class TdAffix extends ui_abstract_1.UI {
73
80
  this.target = document.documentElement;
74
81
  }
75
82
  (0, framework_1.nextTick)(() => {
76
- var _a;
77
83
  console.log('nextTick . ');
78
84
  this.scrollContainer = (0, utils_1.getScrollContainer)(this.dom, true);
79
85
  console.log('this.scrollContainer is ', this.scrollContainer);
80
86
  this.updateRoot();
87
+ // todo destroy
81
88
  this.scrollContainer &&
82
- (0, rxjs_1.fromEvent)(this.scrollContainer, 'scroll').subscribe(() => {
83
- console.log('this.scrollContainer scroll . ');
84
- // if (this.fixed) {
85
- this.ctrl.setStyleObj(this.rootStyle);
86
- this.affix.ctrl.setStyleObj(this.affixStyle);
87
- // }
88
- this.updateRoot();
89
- });
90
- (_a = this.scrollContainer) === null || _a === void 0 ? void 0 : _a.addEventListener('scroll', () => {
91
- console.log('this.scrollContent scroll . listener . ');
92
- });
89
+ this.scrollContainer.addEventListener('scroll', this.onScroll);
93
90
  });
94
91
  }
92
+ destroy(root) {
93
+ this.scrollContainer &&
94
+ this.scrollContainer.removeEventListener('scroll', this.onScroll);
95
+ super.destroy(root);
96
+ }
95
97
  change() {
96
98
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
97
99
  if (!this.scrollContainer)
@@ -24,7 +24,7 @@ class TdAnchorLink extends ui_abstract_1.UI {
24
24
  this.list.addChildren(...params.contents);
25
25
  this.addChild(this.list);
26
26
  }
27
- this.setProps(params);
27
+ this.useParams(params);
28
28
  }
29
29
  }
30
30
  exports.TdAnchorLink = TdAnchorLink;
@@ -10,7 +10,7 @@ class TdAnchor extends ui_abstract_1.UI {
10
10
  var _a, _b, _c, _d;
11
11
  super(params);
12
12
  this.className = 'TdAnchor';
13
- this.ctrl.addStyleObj({
13
+ this.style.addObj({
14
14
  position: 'relative',
15
15
  // background-color: getCssVar('anchor-bg-color')
16
16
  backgroundColor: td_anchor_style_1.$anchor.bgColor.default
@@ -38,14 +38,14 @@ class TdAnchor extends ui_abstract_1.UI {
38
38
  const type = (params === null || params === void 0 ? void 0 : params.type) || 'default';
39
39
  const direction = (params === null || params === void 0 ? void 0 : params.direction) || 'vertical';
40
40
  if (direction === 'vertical') {
41
- (_a = this.marker) === null || _a === void 0 ? void 0 : _a.ctrl.addStyleObj({
41
+ (_a = this.marker) === null || _a === void 0 ? void 0 : _a.style.addObj({
42
42
  width: '4px',
43
43
  height: '14px',
44
44
  top: '8px',
45
45
  left: '0',
46
46
  transition: 'top 0.25s ease-in-out, opacity 0.25s'
47
47
  });
48
- this.list.ctrl.addStyleObj({
48
+ this.list.style.addObj({
49
49
  // paddingLeft: getCssVar('anchor-padding-indent'),
50
50
  paddingLeft: td_anchor_style_1.$anchor.paddingIndent
51
51
  });
@@ -60,32 +60,32 @@ class TdAnchor extends ui_abstract_1.UI {
60
60
  content: ''
61
61
  }
62
62
  }));
63
- (_b = this.marker) === null || _b === void 0 ? void 0 : _b.ctrl.addStyleObj({
63
+ (_b = this.marker) === null || _b === void 0 ? void 0 : _b.style.addObj({
64
64
  width: '2px',
65
65
  borderRadius: 'unset'
66
66
  });
67
67
  }
68
68
  }
69
69
  else {
70
- (_c = this.marker) === null || _c === void 0 ? void 0 : _c.ctrl.addStyleObj({
70
+ (_c = this.marker) === null || _c === void 0 ? void 0 : _c.style.addObj({
71
71
  height: '2px',
72
72
  width: '20px',
73
73
  bottom: '0',
74
74
  transition: 'left 0.25s ease-in-out, opacity 0.25s, width 0.25s'
75
75
  });
76
- this.list.ctrl.addStyleObj({
76
+ this.list.style.addObj({
77
77
  display: 'flex',
78
78
  paddingBottom: '4px'
79
79
  });
80
80
  this.list.childNodes.forEach((item, index) => {
81
81
  if (item instanceof framework_1.TypeHtml) {
82
82
  if (index === 0) {
83
- item.ctrl.addStyleObj({
83
+ item.style.addObj({
84
84
  paddingLeft: '0'
85
85
  });
86
86
  }
87
87
  else {
88
- item.ctrl.addStyleObj({
88
+ item.style.addObj({
89
89
  paddingLeft: '16px'
90
90
  });
91
91
  }
@@ -102,13 +102,13 @@ class TdAnchor extends ui_abstract_1.UI {
102
102
  content: ''
103
103
  }
104
104
  }));
105
- (_d = this.marker) === null || _d === void 0 ? void 0 : _d.ctrl.addStyleObj({
105
+ (_d = this.marker) === null || _d === void 0 ? void 0 : _d.style.addObj({
106
106
  height: '2px',
107
107
  borderRadius: 'unset'
108
108
  });
109
109
  }
110
110
  }
111
- this.props = this.setProps(params);
111
+ this.props = this.useParams(params);
112
112
  }
113
113
  handleClick(e, href) {
114
114
  // emit('click', e, href)
@@ -1,3 +1,4 @@
1
+ import { TypeNode } from '@type-dom/framework';
1
2
  import { UI } from '../../../ui/ui.abstract';
2
3
  import { ITdBackTop, ITdBackTopConfig } from './td-backtop.interface';
3
4
  export declare class TdBackTop extends UI implements ITdBackTop {
@@ -11,7 +12,8 @@ export declare class TdBackTop extends UI implements ITdBackTop {
11
12
  private division;
12
13
  constructor(params?: ITdBackTopConfig);
13
14
  mounted(): void;
14
- initEvents(): void;
15
- handleScroll(event?: MouseEvent): void;
16
- handleClick(event?: MouseEvent): void;
15
+ destroy(root?: TypeNode): void;
16
+ throttleScroll: () => void;
17
+ handleScroll: () => void;
18
+ handleClick(): void;
17
19
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdBackTop = void 0;
4
- const rxjs_1 = require("rxjs");
5
4
  const framework_1 = require("@type-dom/framework");
6
5
  const svgs_1 = require("@type-dom/svgs");
7
6
  const utils_1 = require("@type-dom/utils");
@@ -13,6 +12,24 @@ class TdBackTop extends ui_abstract_1.UI {
13
12
  constructor(params = {}) {
14
13
  super(params, 'fragment');
15
14
  this.visible = false;
15
+ this.throttleScroll = () => {
16
+ console.log('throttleScroll .');
17
+ return (0, utils_1.throttle)(this.handleScroll, 300)();
18
+ };
19
+ this.handleScroll = () => {
20
+ var _a;
21
+ console.error('handleScroll . ');
22
+ // console.log('this.el', this.el);
23
+ if (this.el) {
24
+ this.visible =
25
+ this.el.scrollTop >= (((_a = this.props) === null || _a === void 0 ? void 0 : _a.visibilityHeight) || 200);
26
+ console.log('this.visible', this.visible);
27
+ // this.setStyleObj({
28
+ // display: this.visible ? 'flex' : 'none',
29
+ // })
30
+ this.transition.showSlot(this.visible);
31
+ }
32
+ };
16
33
  this.className = 'TdBackTop';
17
34
  this.division = new framework_1.Div({
18
35
  name: 'td-back-top',
@@ -41,20 +58,20 @@ class TdBackTop extends ui_abstract_1.UI {
41
58
  zIndex: 999
42
59
  },
43
60
  events: {
44
- click: (event) => {
45
- this.handleClick(event);
61
+ click: () => {
62
+ this.handleClick();
46
63
  }
47
64
  }
48
65
  });
49
- this.division.ctrl.addAttrObj({
66
+ this.division.attr.addObj({
50
67
  componentId: this.componentId
51
68
  });
52
69
  this.transition = new framework_1.Transition({
53
70
  name: 'fade',
54
- childNodes: [this.division]
71
+ slot: this.division,
55
72
  });
56
73
  this.addChild(this.transition);
57
- // this.ctrl.addAttrName('td-back-top');
74
+ // this.attr.addName('td-back-top');
58
75
  if (!TdBackTop.initCalled) {
59
76
  TdBackTop.initCalled = true;
60
77
  (0, framework_1.createClass)('td-back-top', {
@@ -82,7 +99,6 @@ class TdBackTop extends ui_abstract_1.UI {
82
99
  }
83
100
  this.division.addChild(this.getSlotNode());
84
101
  if (params === null || params === void 0 ? void 0 : params.slot) {
85
- // this.setSlot(this.transition, this.props.slot);
86
102
  // this.division.slotChild(params.slot);
87
103
  }
88
104
  else {
@@ -93,7 +109,12 @@ class TdBackTop extends ui_abstract_1.UI {
93
109
  }
94
110
  this.container = document;
95
111
  this.el = document.documentElement; // todo 监听不生效 ????
96
- this.props = this.setProps(params);
112
+ this.buildProps({
113
+ visibilityHeight: 200,
114
+ right: 40,
115
+ bottom: 40,
116
+ });
117
+ this.props = this.useParams(params);
97
118
  }
98
119
  mounted() {
99
120
  var _a;
@@ -108,33 +129,21 @@ class TdBackTop extends ui_abstract_1.UI {
108
129
  // this.container.style.setProperty('over-flow', 'scroll');
109
130
  // Give visible an initial value, fix #13066
110
131
  this.handleScroll();
111
- }
112
- initEvents() {
113
- console.log('TdBackTop initEvents');
114
- // nextTick(() => {
115
- console.log('TdBackTop initEvents 2');
116
- (0, rxjs_1.fromEvent)(this.container, 'scroll')
117
- .pipe((0, rxjs_1.throttleTime)(300))
118
- .subscribe((event) => {
119
- // console.error('handleScroll . 1');
120
- this.handleScroll(event);
132
+ this.container.addEventListener('scroll', this.throttleScroll);
133
+ // 监听 window 的滚动事件
134
+ window.addEventListener('scroll', () => {
135
+ console.log('Window scrolled:', window.scrollY);
136
+ });
137
+ // 监听 document 的滚动事件
138
+ document.addEventListener('scroll', () => {
139
+ console.log('Document scrolled:', document.documentElement.scrollTop || document.body.scrollTop);
121
140
  });
122
141
  }
123
- handleScroll(event) {
124
- var _a;
125
- console.error('handleScroll . ');
126
- // console.log('this.el', this.el);
127
- if (this.el) {
128
- this.visible =
129
- this.el.scrollTop >= (((_a = this.props) === null || _a === void 0 ? void 0 : _a.visibilityHeight) || 200);
130
- console.log('this.visible', this.visible);
131
- // this.setStyleObj({
132
- // display: this.visible ? 'flex' : 'none',
133
- // })
134
- this.transition.showSlot(this.visible);
135
- }
142
+ destroy(root) {
143
+ this.container.removeEventListener('scroll', this.throttleScroll);
144
+ super.destroy(root);
136
145
  }
137
- handleClick(event) {
146
+ handleClick() {
138
147
  var _a;
139
148
  console.error('handleClick . ');
140
149
  (_a = this.el) === null || _a === void 0 ? void 0 : _a.scrollTo({ top: 0, behavior: 'smooth' });
@@ -23,4 +23,7 @@ export interface ITdBackTopConfig extends IUIConfig {
23
23
  * default: 40,
24
24
  */
25
25
  bottom?: number;
26
+ emits?: {
27
+ click: (event: MouseEvent) => void;
28
+ };
26
29
  }
@@ -0,0 +1,7 @@
1
+ import { AnyFn } from '@type-dom/framework';
2
+ import { ITdBackTopConfig } from './td-backtop.interface';
3
+ export declare const useBackTop: (props: ITdBackTopConfig, emit: (event: string, fn: AnyFn) => void, componentName: string) => {
4
+ visible: boolean;
5
+ handleClick: (fn: AnyFn) => void;
6
+ mounted: () => void;
7
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBackTop = void 0;
4
+ const useBackTop = (props,
5
+ // emit: ITdBacktopEmits,
6
+ emit, componentName) => {
7
+ let el;
8
+ let container;
9
+ let visible = false;
10
+ const handleScroll = () => {
11
+ var _a;
12
+ if (el) {
13
+ visible = el.scrollTop >= ((_a = props.visibilityHeight) !== null && _a !== void 0 ? _a : 0);
14
+ }
15
+ };
16
+ const handleClick = (fn) => {
17
+ el === null || el === void 0 ? void 0 : el.scrollTo({ top: 0, behavior: 'smooth' });
18
+ emit('click', fn);
19
+ };
20
+ // const handleScrollThrottled = useThrottleFn(handleScroll, 300, true)
21
+ //
22
+ // useEventListener(container, 'scroll', handleScrollThrottled);
23
+ const mounted = () => {
24
+ var _a;
25
+ container = document;
26
+ el = document.documentElement;
27
+ if (props.target) {
28
+ // el = document.querySelector<HTMLElement>(props.target) ?? undefined
29
+ el = (_a = props.target) !== null && _a !== void 0 ? _a : undefined;
30
+ if (!el) {
31
+ throw Error(componentName + `target does not exist: ${props.target}`);
32
+ }
33
+ container = el;
34
+ }
35
+ // Give visible an initial value, fix #13066
36
+ handleScroll();
37
+ };
38
+ return {
39
+ visible,
40
+ handleClick,
41
+ mounted
42
+ };
43
+ };
44
+ exports.useBackTop = useBackTop;
@@ -7,14 +7,14 @@ class TdBreadcrumb extends ui_abstract_1.UI {
7
7
  constructor(params = {}) {
8
8
  super(params);
9
9
  this.className = 'TdBreadcrumb';
10
- this.ctrl.addAttrName('td-breadcrumb');
11
- this.ctrl.addStyleObj({
10
+ this.attr.addName('td-breadcrumb');
11
+ this.style.addObj({
12
12
  fontSize: '14px',
13
13
  lineHeight: 1
14
14
  });
15
15
  this.childNodes = [];
16
16
  this.addChild(this.getSlotNode());
17
- this.props = this.setProps(params);
17
+ this.props = this.useParams(params);
18
18
  }
19
19
  created() {
20
20
  console.log('TdBreadcrumb created . ');
@@ -28,7 +28,7 @@ class TdBreadcrumb extends ui_abstract_1.UI {
28
28
  var _a;
29
29
  const items = this.childNodes;
30
30
  if (items.length) {
31
- (_a = items[items.length - 1]) === null || _a === void 0 ? void 0 : _a.ctrl.setAttribute('aria-current', 'page');
31
+ (_a = items[items.length - 1]) === null || _a === void 0 ? void 0 : _a.attr.set('aria-current', 'page');
32
32
  }
33
33
  }
34
34
  }
@@ -9,7 +9,7 @@ class TdBreadcrumbItem extends ui_abstract_1.UI {
9
9
  constructor(params = {}) {
10
10
  super(params, 'span');
11
11
  this.className = 'TdBreadcrumbItem';
12
- this.ctrl.addStyleObj({
12
+ this.style.addObj({
13
13
  float: 'left',
14
14
  display: 'inline-flex',
15
15
  alignItems: 'center'
@@ -39,11 +39,11 @@ class TdBreadcrumbItem extends ui_abstract_1.UI {
39
39
  if (params === null || params === void 0 ? void 0 : params.slot) {
40
40
  this.slotChild(params === null || params === void 0 ? void 0 : params.slot);
41
41
  }
42
- this.setProps(params);
42
+ this.useParams(params);
43
43
  }
44
44
  addSeparator(breadcrumbConfig) {
45
45
  if (breadcrumbConfig === null || breadcrumbConfig === void 0 ? void 0 : breadcrumbConfig.separatorIcon) {
46
- breadcrumbConfig.separatorIcon.ctrl.addStyleObj({
46
+ breadcrumbConfig.separatorIcon.style.addObj({
47
47
  verticalAlign: 'middle'
48
48
  });
49
49
  this.addChild(new td_icon_class_1.TdIcon({
@@ -7,11 +7,11 @@ class TdMenu extends ui_abstract_1.UI {
7
7
  constructor(params = {}) {
8
8
  super(params, 'ul');
9
9
  this.className = 'TdMenu';
10
- this.ctrl.addAttrObj({
10
+ this.attr.addObj({
11
11
  name: 'td-menu',
12
12
  role: 'menubar'
13
13
  });
14
- this.ctrl.addStyleObj({
14
+ this.style.addObj({
15
15
  // border-right: solid 1px var(--el-menu-border-color),
16
16
  borderRight: 'solid 1px ' + var_1.$borderColor.base,
17
17
  listStyle: 'none',
@@ -22,16 +22,16 @@ class TdMenu extends ui_abstract_1.UI {
22
22
  backgroundColor: var_1.$borderColor.base,
23
23
  boxSizing: 'border-box'
24
24
  });
25
- this.props = this.setProps(params);
25
+ this.props = this.useParams(params);
26
26
  }
27
27
  setup() {
28
28
  const props = this.props;
29
29
  const mode = props.mode || 'vertical';
30
30
  if (mode === 'vertical') {
31
- this.ctrl.addStyleObj({});
31
+ this.style.addObj({});
32
32
  }
33
33
  else {
34
- this.ctrl.addStyleObj({
34
+ this.style.addObj({
35
35
  display: 'flex',
36
36
  flexWrap: 'nowrap',
37
37
  borderRight: 'none'
@@ -1,4 +1,5 @@
1
1
  import { IUI, IUIConfig } from '../../../ui/ui.interface';
2
+ import { Router } from '@type-dom/framework';
2
3
  export interface ITdMenu extends IUI {
3
4
  className: 'TdMenu';
4
5
  }
@@ -6,7 +7,7 @@ export interface ITdMenuConfig extends IUIConfig {
6
7
  mode?: 'horizontal' | 'vertical';
7
8
  defaultActive?: string;
8
9
  uniqueOpened?: boolean;
9
- router?: boolean;
10
+ router?: Router;
10
11
  menuTrigger?: 'hover' | 'click';
11
12
  collapse?: boolean;
12
13
  backgroundColor?: string;
@@ -8,10 +8,10 @@ class TdTabBar extends ui_abstract_1.UI {
8
8
  constructor(params) {
9
9
  super(params);
10
10
  this.className = 'TdTabBar';
11
- this.ctrl.addAttrName('td-tab-bar');
12
- this.ctrl.addStyleObj(td_tabs_style_1.$tabsActiveBarStyle);
11
+ this.attr.addName('td-tab-bar');
12
+ this.style.addObj(td_tabs_style_1.$tabsActiveBarStyle);
13
13
  this.rootTabs = params === null || params === void 0 ? void 0 : params.rootTabs;
14
- this.props = this.setProps(params);
14
+ this.props = this.useParams(params);
15
15
  }
16
16
  getBarStyle() {
17
17
  var _a;
@@ -26,7 +26,7 @@ class TdTabBar extends ui_abstract_1.UI {
26
26
  this.props.tabs && this.props.tabs.every((tab, index) => {
27
27
  var _a, _b, _c, _d, _e;
28
28
  // const $el = instance.parent?.refs?.[`tab-${tab.uid}`] as HTMLElement
29
- const $el = ((_a = this.rootTabs) === null || _a === void 0 ? void 0 : _a.tabNav.tabs) && ((_c = (_b = this.rootTabs) === null || _b === void 0 ? void 0 : _b.tabNav.tabs.find((node) => { var _a, _b; return ((_a = node.props.attrObj) === null || _a === void 0 ? void 0 : _a.tabName) === ((_b = tab.name) !== null && _b !== void 0 ? _b : (index + 1)); })) === null || _c === void 0 ? void 0 : _c.dom);
29
+ const $el = ((_a = this.rootTabs) === null || _a === void 0 ? void 0 : _a.tabNav.tabs) && ((_c = (_b = this.rootTabs) === null || _b === void 0 ? void 0 : _b.tabNav.tabs.find((node) => { var _a; return node.attr.get('tabName') === ((_a = tab.name) !== null && _a !== void 0 ? _a : (index + 1)); })) === null || _c === void 0 ? void 0 : _c.dom);
30
30
  console.log('$el is ', $el);
31
31
  if (!$el)
32
32
  return false;
@@ -56,7 +56,7 @@ class TdTabBar extends ui_abstract_1.UI {
56
56
  change() {
57
57
  console.log('update . ');
58
58
  this.barStyle = this.getBarStyle();
59
- this.ctrl.setStyleObj(this.barStyle);
59
+ this.style.setObj(this.barStyle);
60
60
  }
61
61
  }
62
62
  exports.TdTabBar = TdTabBar;
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TdTabNav = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const utils_1 = require("@type-dom/utils");
5
6
  const framework_1 = require("@type-dom/framework");
6
7
  const svgs_1 = require("@type-dom/svgs");
7
- const utils_1 = require("@type-dom/utils");
8
8
  const ui_abstract_1 = require("../../../ui/ui.abstract");
9
9
  const var_1 = require("../../../styles/var");
10
- const aria_1 = require("../../../aria");
11
10
  const td_tabs_style_1 = require("./td-tabs.style");
12
11
  const td_tab_bar_class_1 = require("./td-tab-bar.class");
13
12
  const td_icon_class_1 = require("../../basic/td-icon/td-icon.class");
@@ -17,8 +16,8 @@ class TdTabNav extends ui_abstract_1.UI {
17
16
  super(params);
18
17
  this.tabs = [];
19
18
  this.className = 'TdTabNav';
20
- this.ctrl.addAttrName('td-tab-nav-wrap');
21
- this.ctrl.addStyleObj(td_tabs_style_1.$tabsNavWrapStyle);
19
+ this.attr.addName('td-tab-nav-wrap');
20
+ this.style.addObj(td_tabs_style_1.$tabsNavWrapStyle);
22
21
  this.addChild(new framework_1.U({
23
22
  name: 'underline',
24
23
  styleObj: td_tabs_style_1.$tabsNavWrapAfterStyle,
@@ -134,6 +133,8 @@ class TdTabNav extends ui_abstract_1.UI {
134
133
  this.removeFocus();
135
134
  // this.rootTabs.currentName = tabName;
136
135
  (_b = (_a = params.emits) === null || _a === void 0 ? void 0 : _a.tabClick) === null || _b === void 0 ? void 0 : _b.call(_a, pane, tabName, evt);
136
+ // tabClick是上级 tabs 的事件监听器,不是tabNav的;
137
+ // this.emit('tabClick', pane, tabName, evt);
137
138
  (0, framework_1.nextTick)(() => {
138
139
  this.selectTab(ele);
139
140
  });
@@ -141,21 +142,20 @@ class TdTabNav extends ui_abstract_1.UI {
141
142
  keydown: (ev) => {
142
143
  var _a, _b;
143
144
  if (closable &&
144
- (ev.code === aria_1.EVENT_CODE.delete ||
145
- ev.code === aria_1.EVENT_CODE.backspace)) {
146
- // emit('tabRemove', pane, ev)
145
+ ((ev === null || ev === void 0 ? void 0 : ev.code) === utils_1.EVENT_CODE.delete || (ev === null || ev === void 0 ? void 0 : ev.code) === utils_1.EVENT_CODE.backspace)) {
146
+ // emit('tabRemove', pane, ev);
147
147
  (_b = (_a = params.emits) === null || _a === void 0 ? void 0 : _a.tabRemove) === null || _b === void 0 ? void 0 : _b.call(_a, pane, ev);
148
148
  }
149
149
  },
150
150
  },
151
151
  });
152
152
  if (tabName === ((_d = this.rootTabs) === null || _d === void 0 ? void 0 : _d.currentName)) {
153
- item.ctrl.addStyleObj({
153
+ item.style.addObj({
154
154
  color: var_1.$colors.primary.base,
155
155
  });
156
156
  }
157
157
  else {
158
- item.ctrl.addStyleObj({
158
+ item.style.addObj({
159
159
  color: var_1.$textColor.regular,
160
160
  });
161
161
  }
@@ -187,8 +187,8 @@ class TdTabNav extends ui_abstract_1.UI {
187
187
  })) || [];
188
188
  console.log('this.tabs is ', this.tabs);
189
189
  this.nav.addChildren(...this.tabs);
190
- this.nav.ctrl.addStyleObj(this.navStyle);
191
- this.props = this.setProps(params);
190
+ this.nav.style.addObj(this.navStyle);
191
+ this.props = this.useParams(params);
192
192
  }
193
193
  mounted() {
194
194
  setTimeout(() => this.scrollToActiveTab(), 0);
@@ -300,12 +300,12 @@ class TdTabNav extends ui_abstract_1.UI {
300
300
  (_a = this.tabBar) === null || _a === void 0 ? void 0 : _a.change();
301
301
  this.tabs.forEach((tab) => {
302
302
  if (item === tab) {
303
- tab.ctrl.setStyleObj({
303
+ tab.style.setObj({
304
304
  color: var_1.$colors.primary.base,
305
305
  });
306
306
  }
307
307
  else {
308
- tab.ctrl.setStyleObj({
308
+ tab.style.setObj({
309
309
  color: var_1.$textColor.regular,
310
310
  });
311
311
  }
@@ -313,7 +313,7 @@ class TdTabNav extends ui_abstract_1.UI {
313
313
  }
314
314
  changeTab(e) {
315
315
  const code = e.code;
316
- const { up, down, left, right } = aria_1.EVENT_CODE;
316
+ const { up, down, left, right } = utils_1.EVENT_CODE;
317
317
  if (![up, down, left, right].includes(code))
318
318
  return;
319
319
  // 左右上下键更换tab