sprintify-ui 0.2.15 → 0.2.16

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,6 @@
1
1
  import { PropType } from 'vue';
2
+ declare function focus(): void;
3
+ declare function blur(): void;
2
4
  declare const _default: import("vue").DefineComponent<{
3
5
  modelValue: {
4
6
  default: string;
@@ -71,7 +73,10 @@ declare const _default: import("vue").DefineComponent<{
71
73
  type: (ArrayConstructor | StringConstructor | FunctionConstructor)[];
72
74
  default(): null;
73
75
  };
74
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "focus" | "blur")[], "update:modelValue" | "focus" | "blur", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
76
+ }, {
77
+ focus: typeof focus;
78
+ blur: typeof blur;
79
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "focus" | "blur")[], "update:modelValue" | "focus" | "blur", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
75
80
  modelValue: {
76
81
  default: string;
77
82
  type: PropType<string | number | null>;
@@ -1,4 +1,6 @@
1
1
  import { PropType } from 'vue';
2
+ declare function focus(): void;
3
+ declare function blur(): void;
2
4
  declare const _default: import("vue").DefineComponent<{
3
5
  /**
4
6
  * The value of the input. Can be a number or null.
@@ -56,7 +58,10 @@ declare const _default: import("vue").DefineComponent<{
56
58
  default: undefined;
57
59
  type: NumberConstructor;
58
60
  };
59
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "focus" | "blur")[], "update:modelValue" | "focus" | "blur", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
61
+ }, {
62
+ focus: typeof focus;
63
+ blur: typeof blur;
64
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "focus" | "blur")[], "update:modelValue" | "focus" | "blur", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
60
65
  /**
61
66
  * The value of the input. Can be a number or null.
62
67
  * 0.1 = 10%
@@ -1,4 +1,6 @@
1
1
  import { PropType } from 'vue';
2
+ declare function focus(): void;
3
+ declare function blur(): void;
2
4
  declare const _default: import("vue").DefineComponent<{
3
5
  modelValue: {
4
6
  default: string;
@@ -24,7 +26,10 @@ declare const _default: import("vue").DefineComponent<{
24
26
  default: boolean;
25
27
  type: BooleanConstructor;
26
28
  };
27
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
29
+ }, {
30
+ focus: typeof focus;
31
+ blur: typeof blur;
32
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
28
33
  modelValue: {
29
34
  default: string;
30
35
  type: PropType<string | null>;
@@ -1,4 +1,6 @@
1
1
  import { PropType } from 'vue';
2
+ declare function focus(): void;
3
+ declare function blur(): void;
2
4
  declare const _default: import("vue").DefineComponent<{
3
5
  modelValue: {
4
6
  default: undefined;
@@ -40,7 +42,10 @@ declare const _default: import("vue").DefineComponent<{
40
42
  default: boolean;
41
43
  type: BooleanConstructor;
42
44
  };
43
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
45
+ }, {
46
+ focus: typeof focus;
47
+ blur: typeof blur;
48
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
44
49
  modelValue: {
45
50
  default: undefined;
46
51
  type: PropType<string | null | undefined>;
@@ -1,4 +1,6 @@
1
1
  import { PropType } from 'vue';
2
+ declare function focus(): void;
3
+ declare function blur(): void;
2
4
  declare const _default: import("vue").DefineComponent<{
3
5
  modelValue: {
4
6
  default: string;
@@ -44,7 +46,10 @@ declare const _default: import("vue").DefineComponent<{
44
46
  default: string;
45
47
  type: PropType<string | string[]>;
46
48
  };
47
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "submit" | "update:modelValue" | "focus")[], "input" | "submit" | "update:modelValue" | "focus", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
49
+ }, {
50
+ focus: typeof focus;
51
+ blur: typeof blur;
52
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "submit" | "update:modelValue" | "focus")[], "input" | "submit" | "update:modelValue" | "focus", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
48
53
  modelValue: {
49
54
  default: string;
50
55
  type: PropType<string | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -149,3 +149,20 @@ export const Field = createFieldStory({
149
149
  componentName: 'BaseInput',
150
150
  label: 'Name',
151
151
  });
152
+
153
+
154
+ const FocusTemplate = (args) => ({
155
+ components: { BaseInput },
156
+ setup() {
157
+ const value = ref(null);
158
+ const input = ref(null);
159
+ return { args, value, input };
160
+ },
161
+ template: `
162
+ <BaseInput ref="input" v-model="value" v-bind="args" class="w-full"></BaseInput>
163
+
164
+ <button @click="input.focus()" class="mt-4 underline">Focus</button>
165
+ `,
166
+ });
167
+
168
+ export const Focus = FocusTemplate.bind({});
@@ -156,6 +156,8 @@ const props = defineProps({
156
156
  },
157
157
  });
158
158
 
159
+ const input = ref<HTMLInputElement | null>(null);
160
+
159
161
  const maskOptions = computed(() => {
160
162
  if (props.mask) {
161
163
  return {
@@ -246,4 +248,17 @@ const backgroundColor = computed(() => {
246
248
  const textColor = computed(() => {
247
249
  return hasErrorInternal.value ? 'text-red-800' : 'text-slate-600';
248
250
  });
251
+
252
+ function focus() {
253
+ input.value?.focus();
254
+ }
255
+
256
+ function blur() {
257
+ input.value?.blur();
258
+ }
259
+
260
+ defineExpose({
261
+ focus,
262
+ blur,
263
+ });
249
264
  </script>
@@ -48,3 +48,19 @@ export const Field = createFieldStory({
48
48
  componentName: 'BaseInputPercent',
49
49
  label: 'Rebate',
50
50
  });
51
+
52
+ const FocusTemplate = (args) => ({
53
+ components: { BaseInputPercent },
54
+ setup() {
55
+ const value = ref(null);
56
+ const input = ref(null);
57
+ return { args, value, input };
58
+ },
59
+ template: `
60
+ <BaseInputPercent ref="input" v-model="value" v-bind="args" class="w-full"></BaseInputPercent>
61
+
62
+ <button @click="input.focus()" class="mt-4 underline">Focus</button>
63
+ `,
64
+ });
65
+
66
+ export const Focus = FocusTemplate.bind({});
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <BaseInput
3
+ ref="input"
3
4
  :model-value="value"
4
5
  suffix="%"
5
6
  type="number"
@@ -83,6 +84,8 @@ const props = defineProps({
83
84
 
84
85
  const emit = defineEmits(['update:modelValue', 'focus', 'blur']);
85
86
 
87
+ const input = ref<HTMLInputElement | null>(null);
88
+
86
89
  const stepNormalized = computed<number>(() => {
87
90
  if (props.step === undefined) return 1;
88
91
  if (props.step === 0) return 1;
@@ -120,4 +123,17 @@ function onUpdate(value: string | number | null) {
120
123
 
121
124
  emit('update:modelValue', round(valueToNumber / 100, precision.value + 2));
122
125
  }
126
+
127
+ function focus() {
128
+ input.value?.focus();
129
+ }
130
+
131
+ function blur() {
132
+ input.value?.blur();
133
+ }
134
+
135
+ defineExpose({
136
+ focus,
137
+ blur,
138
+ });
123
139
  </script>
@@ -39,3 +39,20 @@ export const Field = createFieldStory({
39
39
  componentName: 'BasePassword',
40
40
  label: 'Password',
41
41
  });
42
+
43
+
44
+ const FocusTemplate = (args) => ({
45
+ components: { BasePassword },
46
+ setup() {
47
+ const value = ref(null);
48
+ const input = ref(null);
49
+ return { args, value, input };
50
+ },
51
+ template: `
52
+ <BasePassword ref="input" v-model="value" v-bind="args" class="w-full"></BasePassword>
53
+
54
+ <button @click="input.focus()" class="mt-4 underline">Focus</button>
55
+ `,
56
+ });
57
+
58
+ export const Focus = FocusTemplate.bind({});
@@ -73,6 +73,8 @@ const props = defineProps({
73
73
  },
74
74
  });
75
75
 
76
+ const input = ref<HTMLInputElement | null>(null);
77
+
76
78
  const emit = defineEmits(['update:modelValue']);
77
79
 
78
80
  const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate } =
@@ -89,4 +91,17 @@ function onInput(event: any) {
89
91
  const value = event.target.value + '';
90
92
  emitUpdate(trim(value));
91
93
  }
94
+
95
+ function focus() {
96
+ input.value?.focus();
97
+ }
98
+
99
+ function blur() {
100
+ input.value?.blur();
101
+ }
102
+
103
+ defineExpose({
104
+ focus,
105
+ blur,
106
+ });
92
107
  </script>
@@ -41,3 +41,19 @@ export const Field = createFieldStory({
41
41
  componentName: 'BaseTextarea',
42
42
  label: 'Biography',
43
43
  });
44
+
45
+ const FocusTemplate = (args) => ({
46
+ components: { BaseTextarea },
47
+ setup() {
48
+ const value = ref(null);
49
+ const input = ref(null);
50
+ return { args, value, input };
51
+ },
52
+ template: `
53
+ <BaseTextarea ref="input" v-model="value" v-bind="args" class="w-full"></BaseTextarea>
54
+
55
+ <button @click="input.focus()" class="mt-4 underline">Focus</button>
56
+ `,
57
+ });
58
+
59
+ export const Focus = FocusTemplate.bind({});
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <textarea
3
+ ref="textareaRef"
3
4
  :value="modelValue ?? undefined"
4
5
  :type="type"
5
6
  :name="nameInternal"
@@ -84,4 +85,19 @@ function transformInputValue(event: Event | null): string | null {
84
85
 
85
86
  return '';
86
87
  }
88
+
89
+ const textareaRef = ref<HTMLTextAreaElement | null>(null);
90
+
91
+ function focus() {
92
+ textareaRef.value?.focus();
93
+ }
94
+
95
+ function blur() {
96
+ textareaRef.value?.blur();
97
+ }
98
+
99
+ defineExpose({
100
+ focus,
101
+ blur,
102
+ });
87
103
  </script>
@@ -85,3 +85,19 @@ export const Field = createFieldStory({
85
85
  componentName: 'BaseTextareaAutoresize',
86
86
  label: 'Biography',
87
87
  });
88
+
89
+ const FocusTemplate = (args) => ({
90
+ components: { BaseTextareaAutoresize },
91
+ setup() {
92
+ const value = ref(null);
93
+ const input = ref(null);
94
+ return { args, value, input };
95
+ },
96
+ template: `
97
+ <BaseTextareaAutoresize ref="input" v-model="value" v-bind="args" class="w-full"></BaseTextareaAutoresize>
98
+
99
+ <button @click="input.focus()" class="mt-4 underline">Focus</button>
100
+ `,
101
+ });
102
+
103
+ export const Focus = FocusTemplate.bind({});
@@ -5,6 +5,7 @@
5
5
  :style="{ maxHeight: maxHeight + 'px' }"
6
6
  >
7
7
  <textarea
8
+ ref="textareaRef"
8
9
  :value="modelValue ?? ''"
9
10
  :name="nameInternal"
10
11
  :placeholder="placeholder"
@@ -95,6 +96,8 @@ const props = defineProps({
95
96
 
96
97
  const emit = defineEmits(['update:modelValue', 'submit', 'focus', 'input']);
97
98
 
99
+ const textareaRef = ref<null | HTMLTextAreaElement>(null);
100
+
98
101
  const { nameInternal, requiredInternal, hasErrorInternal } =
99
102
  useField({
100
103
  name: computed(() => props.name),
@@ -147,4 +150,17 @@ const textareaClasses = computed(() => {
147
150
  props.twTextarea
148
151
  );
149
152
  });
153
+
154
+ function focus() {
155
+ textareaRef.value?.focus();
156
+ }
157
+
158
+ function blur() {
159
+ textareaRef.value?.blur();
160
+ }
161
+
162
+ defineExpose({
163
+ focus,
164
+ blur,
165
+ });
150
166
  </script>