@tmagic/tdesign-vue-next-adapter 1.7.0-beta.0 → 1.7.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, createBlock, openBlock, unref, createSlots, withCtx, renderSlot, computed, createElementBlock, createVNode, createElementVNode, useTemplateRef, h } from 'vue';
1
+ import { defineComponent, ref, watch, createBlock, openBlock, unref, createSlots, withCtx, renderSlot, computed, createElementBlock, useTemplateRef, createVNode, createElementVNode, h } from 'vue';
2
2
  import { Checkbox, DateRangePicker, DatePicker, Dialog, Textarea, InputAdornment, Input, Popconfirm, Radio, RadioButton, Table, Tabs, LoadingDirective, Upload, Tooltip, TimePicker, Tag, TabPanel, Switch, Steps, StepItem, Select, Row, RadioGroup, Pagination, OptionGroup, Option, InputNumber, FormItem, Form, Dropdown, DropdownItem, Drawer, Divider, ColorPicker, CollapsePanel, Collapse, Col, CheckboxGroup, Cascader, Card, Button, Badge, MessagePlugin, DialogPlugin } from 'tdesign-vue-next';
3
3
 
4
4
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
@@ -212,32 +212,55 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
212
212
  placeholder: {},
213
213
  rows: {},
214
214
  type: {},
215
- size: {},
216
- row: {}
215
+ size: {}
217
216
  },
218
- emits: ["change", "input", "update:modelValue"],
217
+ emits: ["change", "input", "blur", "focus", "update:modelValue"],
219
218
  setup(__props, { emit: __emit }) {
219
+ const props = __props;
220
220
  const emit = __emit;
221
+ const textareaRef = useTemplateRef("textarea");
222
+ watch(
223
+ [textareaRef, () => props.rows],
224
+ ([val, rows]) => {
225
+ if (val && rows) {
226
+ const el = val.$el.querySelector("textarea");
227
+ if (el) {
228
+ el.rows = rows;
229
+ }
230
+ }
231
+ },
232
+ { immediate: true }
233
+ );
221
234
  const changeHandler = (...args) => {
222
235
  emit("change", ...args);
223
236
  };
224
237
  const inputHandler = (...args) => {
225
238
  emit("input", ...args);
226
239
  };
240
+ const blurHandler = (...args) => {
241
+ emit("blur", ...args);
242
+ };
243
+ const focusHandler = (...args) => {
244
+ emit("focus", ...args);
245
+ };
227
246
  const updateModelValue = (...args) => {
228
247
  emit("update:modelValue", ...args);
229
248
  };
230
249
  return (_ctx, _cache) => {
231
250
  return __props.type === "textarea" ? (openBlock(), createBlock(unref(Textarea), {
232
251
  key: 0,
252
+ ref: "textarea",
233
253
  modelValue: __props.modelValue,
234
254
  size: __props.size === "default" ? "medium" : __props.size,
235
255
  disabled: __props.disabled,
236
256
  placeholder: __props.placeholder,
237
- row: __props.row,
257
+ rows: __props.rows,
238
258
  onKeypress: inputHandler,
239
- onChange: changeHandler
240
- }, null, 8, ["modelValue", "size", "disabled", "placeholder", "row"])) : (openBlock(), createBlock(
259
+ onChange: changeHandler,
260
+ onBlur: blurHandler,
261
+ onFocus: focusHandler,
262
+ "onUpdate:modelValue": updateModelValue
263
+ }, null, 8, ["modelValue", "size", "disabled", "placeholder", "rows"])) : (openBlock(), createBlock(
241
264
  unref(InputAdornment),
242
265
  { key: 1 },
243
266
  createSlots({
@@ -250,6 +273,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
250
273
  placeholder: __props.placeholder,
251
274
  onKeypress: inputHandler,
252
275
  onChange: changeHandler,
276
+ onBlur: blurHandler,
277
+ onFocus: focusHandler,
253
278
  "onUpdate:modelValue": updateModelValue
254
279
  }, createSlots({
255
280
  _: 2
@@ -215,32 +215,55 @@
215
215
  placeholder: {},
216
216
  rows: {},
217
217
  type: {},
218
- size: {},
219
- row: {}
218
+ size: {}
220
219
  },
221
- emits: ["change", "input", "update:modelValue"],
220
+ emits: ["change", "input", "blur", "focus", "update:modelValue"],
222
221
  setup(__props, { emit: __emit }) {
222
+ const props = __props;
223
223
  const emit = __emit;
224
+ const textareaRef = vue.useTemplateRef("textarea");
225
+ vue.watch(
226
+ [textareaRef, () => props.rows],
227
+ ([val, rows]) => {
228
+ if (val && rows) {
229
+ const el = val.$el.querySelector("textarea");
230
+ if (el) {
231
+ el.rows = rows;
232
+ }
233
+ }
234
+ },
235
+ { immediate: true }
236
+ );
224
237
  const changeHandler = (...args) => {
225
238
  emit("change", ...args);
226
239
  };
227
240
  const inputHandler = (...args) => {
228
241
  emit("input", ...args);
229
242
  };
243
+ const blurHandler = (...args) => {
244
+ emit("blur", ...args);
245
+ };
246
+ const focusHandler = (...args) => {
247
+ emit("focus", ...args);
248
+ };
230
249
  const updateModelValue = (...args) => {
231
250
  emit("update:modelValue", ...args);
232
251
  };
233
252
  return (_ctx, _cache) => {
234
253
  return __props.type === "textarea" ? (vue.openBlock(), vue.createBlock(vue.unref(tdesignVueNext.Textarea), {
235
254
  key: 0,
255
+ ref: "textarea",
236
256
  modelValue: __props.modelValue,
237
257
  size: __props.size === "default" ? "medium" : __props.size,
238
258
  disabled: __props.disabled,
239
259
  placeholder: __props.placeholder,
240
- row: __props.row,
260
+ rows: __props.rows,
241
261
  onKeypress: inputHandler,
242
- onChange: changeHandler
243
- }, null, 8, ["modelValue", "size", "disabled", "placeholder", "row"])) : (vue.openBlock(), vue.createBlock(
262
+ onChange: changeHandler,
263
+ onBlur: blurHandler,
264
+ onFocus: focusHandler,
265
+ "onUpdate:modelValue": updateModelValue
266
+ }, null, 8, ["modelValue", "size", "disabled", "placeholder", "rows"])) : (vue.openBlock(), vue.createBlock(
244
267
  vue.unref(tdesignVueNext.InputAdornment),
245
268
  { key: 1 },
246
269
  vue.createSlots({
@@ -253,6 +276,8 @@
253
276
  placeholder: __props.placeholder,
254
277
  onKeypress: inputHandler,
255
278
  onChange: changeHandler,
279
+ onBlur: blurHandler,
280
+ onFocus: focusHandler,
256
281
  "onUpdate:modelValue": updateModelValue
257
282
  }, vue.createSlots({
258
283
  _: 2
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.0-beta.0",
2
+ "version": "1.7.0-beta.1",
3
3
  "name": "@tmagic/tdesign-vue-next-adapter",
4
4
  "type": "module",
5
5
  "main": "dist/tmagic-tdesign-vue-next-adapter.umd.cjs",
@@ -38,7 +38,7 @@
38
38
  "tdesign-vue-next": "^1.17.1",
39
39
  "vue": "^3.5.22",
40
40
  "typescript": "^5.9.3",
41
- "@tmagic/design": "1.7.0-beta.0"
41
+ "@tmagic/design": "1.7.0-beta.1"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "typescript": {
package/src/Input.vue CHANGED
@@ -1,13 +1,17 @@
1
1
  <template>
2
2
  <TTextarea
3
3
  v-if="type === 'textarea'"
4
+ ref="textarea"
4
5
  :modelValue="modelValue"
5
6
  :size="size === 'default' ? 'medium' : size"
6
7
  :disabled="disabled"
7
8
  :placeholder="placeholder"
8
- :row="row"
9
+ :rows="rows"
9
10
  @keypress="inputHandler"
10
11
  @change="changeHandler"
12
+ @blur="blurHandler"
13
+ @focus="focusHandler"
14
+ @update:modelValue="updateModelValue"
11
15
  ></TTextarea>
12
16
  <TInputAdornment v-else>
13
17
  <template #prepend v-if="$slots.prepend">
@@ -24,6 +28,8 @@
24
28
  :placeholder="placeholder"
25
29
  @keypress="inputHandler"
26
30
  @change="changeHandler"
31
+ @blur="blurHandler"
32
+ @focus="focusHandler"
27
33
  @update:modelValue="updateModelValue"
28
34
  >
29
35
  <template #prefix-icon v-if="$slots.prefix">
@@ -37,6 +43,7 @@
37
43
  </template>
38
44
 
39
45
  <script lang="ts" setup>
46
+ import { useTemplateRef, watch } from 'vue';
40
47
  import { Input as TInput, InputAdornment as TInputAdornment, Textarea as TTextarea } from 'tdesign-vue-next';
41
48
 
42
49
  import type { InputProps } from '@tmagic/design';
@@ -45,13 +52,28 @@ defineOptions({
45
52
  name: 'TTDesignAdapterInput',
46
53
  });
47
54
 
48
- defineProps<
55
+ const props = defineProps<
49
56
  InputProps & {
50
57
  modelValue: string;
51
58
  }
52
59
  >();
53
60
 
54
- const emit = defineEmits(['change', 'input', 'update:modelValue']);
61
+ const emit = defineEmits(['change', 'input', 'blur', 'focus', 'update:modelValue']);
62
+
63
+ const textareaRef = useTemplateRef('textarea');
64
+
65
+ watch(
66
+ [textareaRef, () => props.rows],
67
+ ([val, rows]) => {
68
+ if (val && rows) {
69
+ const el = val.$el.querySelector('textarea');
70
+ if (el) {
71
+ el.rows = rows;
72
+ }
73
+ }
74
+ },
75
+ { immediate: true },
76
+ );
55
77
 
56
78
  const changeHandler = (...args: any[]) => {
57
79
  emit('change', ...args);
@@ -61,6 +83,14 @@ const inputHandler = (...args: any[]) => {
61
83
  emit('input', ...args);
62
84
  };
63
85
 
86
+ const blurHandler = (...args: any[]) => {
87
+ emit('blur', ...args);
88
+ };
89
+
90
+ const focusHandler = (...args: any[]) => {
91
+ emit('focus', ...args);
92
+ };
93
+
64
94
  const updateModelValue = (...args: any[]) => {
65
95
  emit('update:modelValue', ...args);
66
96
  };