@tb-dev/vue 0.3.34 → 0.3.35

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.
@@ -16,7 +16,7 @@ declare const _default: import('vue').DefineComponent<InputProps, {
16
16
  type: import('vue').InputTypeHTMLAttribute;
17
17
  spellcheck: boolean | "true" | "false";
18
18
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
19
- baseInput: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
19
+ inputComponent: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
20
20
  defaultValue?: string | number;
21
21
  modelValue?: string | number;
22
22
  class?: import('vue').HTMLAttributes["class"];
@@ -1,14 +1,76 @@
1
1
  import { Option } from '@tb-dev/utils';
2
2
  import { InputTextProps } from './types';
3
3
  type __VLS_Props = InputTextProps;
4
+ declare function focus(): void;
5
+ declare function blur(): void;
6
+ declare function select(): void;
4
7
  type __VLS_PublicProps = {
5
8
  modelValue: Option<string>;
6
9
  } & __VLS_Props;
7
- declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
10
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
11
+ inputEl: import('vue').ComputedRef<Option<HTMLInputElement>>;
12
+ focus: typeof focus;
13
+ blur: typeof blur;
14
+ select: typeof select;
15
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
16
  "update:modelValue": (value: Option<string>) => any;
9
17
  }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
18
  "onUpdate:modelValue"?: ((value: Option<string>) => any) | undefined;
11
19
  }>, {
12
20
  spellcheck: boolean | "true" | "false";
13
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
21
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
22
+ inputComponent: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').InputProps> & Readonly<{
23
+ "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
24
+ }>, {
25
+ inputEl: import('vue').ComputedRef<Option<HTMLInputElement>>;
26
+ focus: () => void;
27
+ blur: () => void;
28
+ select: () => void;
29
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
30
+ "update:modelValue": (value: string | null) => any;
31
+ }, import('vue').PublicProps, {
32
+ type: import('vue').InputTypeHTMLAttribute;
33
+ spellcheck: boolean | "true" | "false";
34
+ }, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
35
+ inputComponent: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
36
+ defaultValue?: string | number;
37
+ modelValue?: string | number;
38
+ class?: import('vue').HTMLAttributes["class"];
39
+ }> & Readonly<{
40
+ "onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
41
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
42
+ "update:modelValue": (payload: string | number) => any;
43
+ }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLInputElement, import('vue').ComponentProvideOptions, {
44
+ P: {};
45
+ B: {};
46
+ D: {};
47
+ C: {};
48
+ M: {};
49
+ Defaults: {};
50
+ }, Readonly<{
51
+ defaultValue?: string | number;
52
+ modelValue?: string | number;
53
+ class?: import('vue').HTMLAttributes["class"];
54
+ }> & Readonly<{
55
+ "onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
56
+ }>, {}, {}, {}, {}, {}> | null;
57
+ }, any, import('vue').ComponentProvideOptions, {
58
+ P: {};
59
+ B: {};
60
+ D: {};
61
+ C: {};
62
+ M: {};
63
+ Defaults: {};
64
+ }, Readonly<import('..').InputProps> & Readonly<{
65
+ "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
66
+ }>, {
67
+ inputEl: import('vue').ComputedRef<Option<HTMLInputElement>>;
68
+ focus: () => void;
69
+ blur: () => void;
70
+ select: () => void;
71
+ }, {}, {}, {}, {
72
+ type: import('vue').InputTypeHTMLAttribute;
73
+ spellcheck: boolean | "true" | "false";
74
+ }> | null;
75
+ }, any>;
14
76
  export default _default;
@@ -1,5 +1,8 @@
1
1
  import { TextareaProps } from './types';
2
- declare const _default: import('vue').DefineComponent<TextareaProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
2
+ import { Option } from '@tb-dev/utils';
3
+ declare const _default: import('vue').DefineComponent<TextareaProps, {
4
+ textareaEl: import('vue').ComputedRef<Option<HTMLTextAreaElement>>;
5
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
3
6
  "update:modelValue": (value: string | null) => any;
4
7
  }, string, import('vue').PublicProps, Readonly<TextareaProps> & Readonly<{
5
8
  "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
@@ -7,5 +10,28 @@ declare const _default: import('vue').DefineComponent<TextareaProps, {}, {}, {},
7
10
  autocomplete: string;
8
11
  spellcheck: boolean | "true" | "false";
9
12
  autocorrect: string;
10
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
13
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
14
+ textareaComponent: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
15
+ class?: import('vue').HTMLAttributes["class"];
16
+ defaultValue?: string | number;
17
+ modelValue?: string | number;
18
+ }> & Readonly<{
19
+ "onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
20
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
21
+ "update:modelValue": (payload: string | number) => any;
22
+ }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLTextAreaElement, import('vue').ComponentProvideOptions, {
23
+ P: {};
24
+ B: {};
25
+ D: {};
26
+ C: {};
27
+ M: {};
28
+ Defaults: {};
29
+ }, Readonly<{
30
+ class?: import('vue').HTMLAttributes["class"];
31
+ defaultValue?: string | number;
32
+ modelValue?: string | number;
33
+ }> & Readonly<{
34
+ "onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
35
+ }>, {}, {}, {}, {}, {}> | null;
36
+ }, any>;
11
37
  export default _default;
package/dist/index.js CHANGED
@@ -2374,9 +2374,9 @@ const _sfc_main$1T = /* @__PURE__ */ defineComponent({
2374
2374
  setup(__props, { expose: __expose, emit: __emit }) {
2375
2375
  const props = __props;
2376
2376
  const emit = __emit;
2377
- const baseInput = useTemplateRef("baseInput");
2377
+ const inputComponent = useTemplateRef("inputComponent");
2378
2378
  const inputEl = computed(() => {
2379
- return baseInput.value?.$el;
2379
+ return inputComponent.value?.$el;
2380
2380
  });
2381
2381
  const value = computed({
2382
2382
  // eslint-disable-next-line no-undefined
@@ -2399,8 +2399,8 @@ const _sfc_main$1T = /* @__PURE__ */ defineComponent({
2399
2399
  createVNode(unref(DefineTemplate), null, {
2400
2400
  default: withCtx(() => [
2401
2401
  createVNode(unref(_sfc_main$1U), mergeProps({
2402
- ref_key: "baseInput",
2403
- ref: baseInput
2402
+ ref_key: "inputComponent",
2403
+ ref: inputComponent
2404
2404
  }, _ctx.$attrs, {
2405
2405
  modelValue: value.value,
2406
2406
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
@@ -2700,11 +2700,25 @@ const _sfc_main$1M = /* @__PURE__ */ defineComponent({
2700
2700
  "modelModifiers": {}
2701
2701
  }),
2702
2702
  emits: ["update:modelValue"],
2703
- setup(__props) {
2703
+ setup(__props, { expose: __expose }) {
2704
2704
  const props = __props;
2705
2705
  const value = useModel(__props, "modelValue");
2706
+ const inputComponent = useTemplateRef("inputComponent");
2707
+ const inputEl = computed(() => inputComponent.value?.inputEl);
2708
+ function focus() {
2709
+ inputEl.value?.focus();
2710
+ }
2711
+ function blur() {
2712
+ inputEl.value?.blur();
2713
+ }
2714
+ function select() {
2715
+ inputEl.value?.select();
2716
+ }
2717
+ __expose({ inputEl, focus, blur, select });
2706
2718
  return (_ctx, _cache) => {
2707
2719
  return openBlock(), createBlock(unref(_sfc_main$1T), {
2720
+ ref_key: "inputComponent",
2721
+ ref: inputComponent,
2708
2722
  modelValue: value.value,
2709
2723
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
2710
2724
  type: "text",
@@ -6340,9 +6354,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6340
6354
  style: {}
6341
6355
  },
6342
6356
  emits: ["update:modelValue"],
6343
- setup(__props, { emit: __emit }) {
6357
+ setup(__props, { expose: __expose, emit: __emit }) {
6344
6358
  const props = __props;
6345
6359
  const emit = __emit;
6360
+ const textareaComponent = useTemplateRef("textareaComponent");
6361
+ const textareaEl = computed(() => {
6362
+ return textareaComponent.value?.$el;
6363
+ });
6346
6364
  const value = computed({
6347
6365
  // eslint-disable-next-line no-undefined
6348
6366
  get: () => props.modelValue ?? void 0,
@@ -6352,11 +6370,15 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6352
6370
  return props.height ? { height: toPixel(props.height) } : null;
6353
6371
  });
6354
6372
  const [DefineTemplate, ReuseTemplate] = createReusableTemplate();
6373
+ __expose({ textareaEl });
6355
6374
  return (_ctx, _cache) => {
6356
6375
  return openBlock(), createElementBlock(Fragment, null, [
6357
6376
  createVNode(unref(DefineTemplate), null, {
6358
6377
  default: withCtx(() => [
6359
- createVNode(unref(_sfc_main$3), mergeProps(_ctx.$attrs, {
6378
+ createVNode(unref(_sfc_main$3), mergeProps({
6379
+ ref_key: "textareaComponent",
6380
+ ref: textareaComponent
6381
+ }, _ctx.$attrs, {
6360
6382
  modelValue: value.value,
6361
6383
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
6362
6384
  modelModifiers: { trim: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "0.3.34",
3
+ "version": "0.3.35",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",