@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
@@ -15,7 +15,7 @@ class TdSwitch extends ui_abstract_1.UI {
15
15
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
16
16
  super(params);
17
17
  this.className = 'TdSwitch';
18
- this.ctrl.addStyleObj({
18
+ this.style.addObj({
19
19
  display: 'inline-flex',
20
20
  alignItems: 'center',
21
21
  position: 'relative',
@@ -62,7 +62,7 @@ class TdSwitch extends ui_abstract_1.UI {
62
62
  this.right = new td_switch_right_1.TdSwitchRight(params);
63
63
  this.addChild(this.right);
64
64
  }
65
- this.props = this.setParams(params);
65
+ this.props = this.useParams(params);
66
66
  }
67
67
  get actualValue() {
68
68
  return this.isControlled ? this.props.modelValue : false;
@@ -74,13 +74,13 @@ class TdSwitch extends ui_abstract_1.UI {
74
74
  const props = this.props;
75
75
  this.setChecked(this.modelValue === this.activeValue);
76
76
  if (props === null || props === void 0 ? void 0 : props.disabled) {
77
- this.setDisabled(props === null || props === void 0 ? void 0 : props.disabled);
77
+ this.setDisabled(props.disabled);
78
78
  }
79
79
  if (props.loading) {
80
- this.setLoading(props === null || props === void 0 ? void 0 : props.loading);
80
+ this.setLoading(props.loading);
81
81
  }
82
82
  }
83
- initEvents() {
83
+ setup() {
84
84
  this.addEvents({
85
85
  click: (evt) => {
86
86
  // changeValue
@@ -90,19 +90,18 @@ class TdSwitch extends ui_abstract_1.UI {
90
90
  });
91
91
  }
92
92
  handleChange() {
93
- var _a, _b, _c, _d, _e, _f;
94
93
  console.log('handleChange . ');
95
94
  const props = this.props;
96
95
  const checked = this.modelValue === this.activeValue;
97
96
  // this.modelValue = !this.modelValue;
98
97
  this.modelValue = checked ? this.inactiveValue : this.activeValue;
99
98
  const val = checked ? this.inactiveValue : this.activeValue;
100
- // emit(UPDATE_MODEL_EVENT, val)
101
- (_b = (_a = this.props.emits) === null || _a === void 0 ? void 0 : _a[event_1.UPDATE_MODEL_EVENT]) === null || _b === void 0 ? void 0 : _b.call(_a, val);
102
- // emit(CHANGE_EVENT, val)
103
- (_d = (_c = this.props.emits) === null || _c === void 0 ? void 0 : _c[event_1.CHANGE_EVENT]) === null || _d === void 0 ? void 0 : _d.call(_c, val);
104
- // emit(INPUT_EVENT, val)
105
- (_f = (_e = this.props.emits) === null || _e === void 0 ? void 0 : _e[event_1.INPUT_EVENT]) === null || _f === void 0 ? void 0 : _f.call(_e, val);
99
+ this.emit(event_1.UPDATE_MODEL_EVENT, val);
100
+ // this.props.emits?.[UPDATE_MODEL_EVENT]?.(val);
101
+ this.emit(event_1.CHANGE_EVENT, val);
102
+ // this.props.emits?.[CHANGE_EVENT]?.(val);
103
+ this.emit(event_1.INPUT_EVENT, val);
104
+ // this.props.emits?.[INPUT_EVENT]?.(val);
106
105
  (0, framework_1.nextTick)(() => {
107
106
  this.input.dom.checked = !checked;
108
107
  console.log('handleChange . this.input.dom.checked is ', checked);
@@ -113,32 +112,32 @@ class TdSwitch extends ui_abstract_1.UI {
113
112
  setDisabled(disabled) {
114
113
  var _a, _b;
115
114
  if (disabled) {
116
- this.ctrl.setStyleObj({
115
+ this.style.setObj({
117
116
  opacity: 0.6
118
117
  });
119
- this.input.ctrl.setAttrObj({
118
+ this.input.attr.setObj({
120
119
  disabled: true,
121
120
  ariaDisabled: true
122
121
  });
123
- (_a = this.left) === null || _a === void 0 ? void 0 : _a.ctrl.setStyleObj({
122
+ (_a = this.left) === null || _a === void 0 ? void 0 : _a.style.setObj({
124
123
  cursor: 'not-allowed'
125
124
  });
126
- this.core.ctrl.setStyleObj({
125
+ this.core.style.setObj({
127
126
  cursor: 'not-allowed'
128
127
  });
129
128
  }
130
129
  else {
131
- this.ctrl.setStyleObj({
130
+ this.style.setObj({
132
131
  opacity: 1
133
132
  });
134
- this.input.ctrl.setAttrObj({
133
+ this.input.attr.setObj({
135
134
  disabled: false,
136
135
  ariaDisabled: false
137
136
  });
138
- (_b = this.left) === null || _b === void 0 ? void 0 : _b.ctrl.setStyleObj({
137
+ (_b = this.left) === null || _b === void 0 ? void 0 : _b.style.setObj({
139
138
  cursor: 'auto'
140
139
  });
141
- this.core.ctrl.setStyleObj({
140
+ this.core.style.setObj({
142
141
  cursor: 'auto'
143
142
  });
144
143
  }
@@ -147,10 +146,10 @@ class TdSwitch extends ui_abstract_1.UI {
147
146
  setChecked(checked) {
148
147
  var _a, _b, _c, _d, _e, _f, _g, _h;
149
148
  if (checked) {
150
- this.core.ctrl.setStyleObj({
149
+ this.core.style.setObj({
151
150
  backgroundColor: (_a = this.props.switchOnColor) !== null && _a !== void 0 ? _a : td_switch_style_1.$switchOnColor
152
151
  });
153
- this.core.action.ctrl.setStyleObj({
152
+ this.core.action.style.setObj({
154
153
  color: td_switch_style_1.$switchOnColor,
155
154
  // left: calc(100% - #{map.get($switch-button-size, 'default') + 1px});
156
155
  left: 'calc(100% - ' +
@@ -158,12 +157,12 @@ class TdSwitch extends ui_abstract_1.UI {
158
157
  ' - 1px)'
159
158
  });
160
159
  if (this.right) {
161
- this.right.ctrl.setStyleObj({
160
+ this.right.style.setObj({
162
161
  color: var_1.$colors.primary.base
163
162
  });
164
163
  }
165
164
  if (this.left) {
166
- this.left.ctrl.setStyleObj({
165
+ this.left.style.setObj({
167
166
  color: var_1.$colors.default.base
168
167
  });
169
168
  }
@@ -178,20 +177,20 @@ class TdSwitch extends ui_abstract_1.UI {
178
177
  }
179
178
  }
180
179
  else {
181
- this.core.ctrl.setStyleObj({
180
+ this.core.style.setObj({
182
181
  backgroundColor: (_e = this.props.switchOffColor) !== null && _e !== void 0 ? _e : td_switch_style_1.$switchOffColor
183
182
  });
184
- this.core.action.ctrl.setStyleObj({
183
+ this.core.action.style.setObj({
185
184
  left: '1px',
186
185
  color: td_switch_style_1.$switchOffColor
187
186
  });
188
187
  if (this.left) {
189
- this.left.ctrl.setStyleObj({
188
+ this.left.style.setObj({
190
189
  color: var_1.$colors.primary.base
191
190
  });
192
191
  }
193
192
  if (this.right) {
194
- this.right.ctrl.setStyleObj({
193
+ this.right.style.setObj({
195
194
  color: var_1.$colors.default.base
196
195
  });
197
196
  }
@@ -10,10 +10,10 @@ class TdSwitchCore extends framework_1.TypeSpan {
10
10
  constructor(params = {}) {
11
11
  super();
12
12
  this.className = 'TdSwitchCore';
13
- this.ctrl.addAttrObj({
13
+ this.attr.addObj({
14
14
  name: 'switch-core'
15
15
  });
16
- this.ctrl.addStyleObj({
16
+ this.style.addObj({
17
17
  display: 'inline-flex',
18
18
  position: 'relative',
19
19
  alignItems: 'center',
@@ -131,7 +131,7 @@ class TdSwitchCore extends framework_1.TypeSpan {
131
131
  this.action.addChild(loadingIcon);
132
132
  }
133
133
  else if ((params === null || params === void 0 ? void 0 : params.modelValue) === (params === null || params === void 0 ? void 0 : params.activeValue)) {
134
- this.action.ctrl.addStyleObj({
134
+ this.action.style.addObj({
135
135
  color: td_switch_style_1.$switchOnColor
136
136
  });
137
137
  if (params === null || params === void 0 ? void 0 : params.activeActionIcon) {
@@ -166,12 +166,12 @@ class TdSwitchCore extends framework_1.TypeSpan {
166
166
  }
167
167
  }
168
168
  this.addChild(this.action);
169
- this.props = this.setParams(params);
169
+ this.props = this.useParams(params);
170
170
  }
171
171
  setInnerChecked(checked) {
172
172
  var _a, _b, _c, _d, _e, _f, _g, _h;
173
173
  if (checked) {
174
- (_a = this.inner) === null || _a === void 0 ? void 0 : _a.ctrl.setStyleObj({
174
+ (_a = this.inner) === null || _a === void 0 ? void 0 : _a.style.setObj({
175
175
  // padding: 0 calc(#{map.get($switch-button-size, 'default')} + 2px) 0 #{map.get(
176
176
  // $switch-content-padding,
177
177
  // 'default'
@@ -191,7 +191,7 @@ class TdSwitchCore extends framework_1.TypeSpan {
191
191
  }
192
192
  }
193
193
  else {
194
- (_e = this.inner) === null || _e === void 0 ? void 0 : _e.ctrl.setStyleObj({
194
+ (_e = this.inner) === null || _e === void 0 ? void 0 : _e.style.setObj({
195
195
  // padding: 0 #{map.get($switch-content-padding, 'default')} 0 calc(#{map.get(
196
196
  // $switch-button-size,
197
197
  // 'default'
@@ -8,8 +8,8 @@ class TdSwitchLeft extends framework_1.TypeSpan {
8
8
  constructor(params = {}) {
9
9
  super();
10
10
  this.className = 'TdSwitchLeft';
11
- this.ctrl.addAttrName('switch-label');
12
- this.ctrl.addStyleObj(Object.assign(Object.assign({}, td_switch_style_1.$switchLabel), { marginRight: '10px' }));
11
+ this.attr.addName('switch-label');
12
+ this.style.addObj(Object.assign(Object.assign({}, td_switch_style_1.$switchLabel), { marginRight: '10px' }));
13
13
  if (params === null || params === void 0 ? void 0 : params.inactiveIcon) {
14
14
  this.addChild(new td_icon_class_1.TdIcon({
15
15
  svgObj: params.inactiveIcon
@@ -20,7 +20,7 @@ class TdSwitchLeft extends framework_1.TypeSpan {
20
20
  text: params.inactiveText
21
21
  }));
22
22
  }
23
- this.props = this.setParams(params);
23
+ this.props = this.useParams(params);
24
24
  }
25
25
  }
26
26
  exports.TdSwitchLeft = TdSwitchLeft;
@@ -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.setParams(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.setParams(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.setParams(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.setParams(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
- slot: 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.setParams(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,34 +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();
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);
140
+ });
111
141
  }
112
- initEvents() {
113
- console.log('TdBackTop initEvents');
114
- // nextTick(() => {
115
- console.log('TdBackTop initEvents 2');
116
- this.subscriptions.push((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);
121
- }));
122
- // });
123
- }
124
- handleScroll(event) {
125
- var _a;
126
- console.error('handleScroll . ');
127
- // console.log('this.el', this.el);
128
- if (this.el) {
129
- this.visible =
130
- this.el.scrollTop >= (((_a = this.props) === null || _a === void 0 ? void 0 : _a.visibilityHeight) || 200);
131
- console.log('this.visible', this.visible);
132
- // this.setStyleObj({
133
- // display: this.visible ? 'flex' : 'none',
134
- // })
135
- this.transition.showSlot(this.visible);
136
- }
142
+ destroy(root) {
143
+ this.container.removeEventListener('scroll', this.throttleScroll);
144
+ super.destroy(root);
137
145
  }
138
- handleClick(event) {
146
+ handleClick() {
139
147
  var _a;
140
148
  console.error('handleClick . ');
141
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;