sprintify-ui 0.8.18 → 0.8.20

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,5 @@
1
1
  import { PropType } from 'vue';
2
+ import { InputConfigProps } from '@/types';
2
3
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
3
4
  color: {
4
5
  required: true;
@@ -24,6 +25,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
24
25
  default(): string;
25
26
  type: StringConstructor;
26
27
  };
28
+ input: {
29
+ default: boolean;
30
+ type: PropType<boolean | InputConfigProps>;
31
+ };
27
32
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
33
  cancel: (...args: any[]) => void;
29
34
  confirm: (...args: any[]) => void;
@@ -52,6 +57,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
52
57
  default(): string;
53
58
  type: StringConstructor;
54
59
  };
60
+ input: {
61
+ default: boolean;
62
+ type: PropType<boolean | InputConfigProps>;
63
+ };
55
64
  }>> & {
56
65
  onConfirm?: ((...args: any[]) => any) | undefined;
57
66
  onCancel?: ((...args: any[]) => any) | undefined;
@@ -61,6 +70,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
61
70
  html: boolean;
62
71
  confirmText: string;
63
72
  cancelText: string;
73
+ input: boolean | InputConfigProps;
64
74
  }, {}>, {
65
75
  default?(_: {}): any;
66
76
  }>;
@@ -11,7 +11,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
11
11
  };
12
12
  size: {
13
13
  default: undefined;
14
- type: PropType<"xs" | "sm" | "md" | "lg" | "xl">;
14
+ type: PropType<"xs" | "sm" | "md" | "lg" | "xl" | undefined>;
15
15
  };
16
16
  required: {
17
17
  type: BooleanConstructor;
@@ -44,7 +44,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
44
44
  };
45
45
  size: {
46
46
  default: undefined;
47
- type: PropType<"xs" | "sm" | "md" | "lg" | "xl">;
47
+ type: PropType<"xs" | "sm" | "md" | "lg" | "xl" | undefined>;
48
48
  };
49
49
  required: {
50
50
  type: BooleanConstructor;
@@ -68,7 +68,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
68
68
  };
69
69
  }>>, {
70
70
  required: boolean;
71
- size: "xs" | "sm" | "md" | "lg" | "xl";
71
+ size: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
72
72
  name: string;
73
73
  label: string;
74
74
  help: string;
@@ -3,6 +3,7 @@ import { UploadedFile } from './UploadedFile';
3
3
  import { Notification } from './Notification';
4
4
  import { CropType, ResultOptions } from 'croppie';
5
5
  import { Media } from './Media';
6
+ import { Size } from '@/utils/sizes';
6
7
  export type Locales = {
7
8
  [locale: string]: string;
8
9
  };
@@ -230,3 +231,12 @@ export type JsonDataItem = string | number | null | undefined | JsonData[] | Jso
230
231
  export interface JsonData {
231
232
  [key: string]: JsonDataItem;
232
233
  }
234
+ export interface InputConfigProps {
235
+ label?: string;
236
+ placeholder?: string;
237
+ name?: string;
238
+ type?: string;
239
+ size?: Size;
240
+ required?: boolean;
241
+ disabled?: boolean;
242
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.8.18",
3
+ "version": "0.8.20",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -21,10 +21,19 @@ export default {
21
21
  const Template = (args) => ({
22
22
  components: { BaseDialog },
23
23
  setup() {
24
- return { args };
24
+
25
+ const confirm = () => {
26
+ alert('Confirmed');
27
+ }
28
+
29
+ const cancel = () => {
30
+ alert('Canceled');
31
+ }
32
+
33
+ return { args, confirm, cancel };
25
34
  },
26
35
  template: `
27
- <BaseDialog v-bind="args">
36
+ <BaseDialog v-bind="args" @confirm="confirm" @cancel="cancel">
28
37
  </BaseDialog>
29
38
  `,
30
39
  });
@@ -59,3 +68,14 @@ export const Colors = ColorsTemplate.bind({});
59
68
  Colors.args = {
60
69
  title: 'Be careful',
61
70
  };
71
+
72
+ export const WithInput = Template.bind({});
73
+ WithInput.args = {
74
+ input: {
75
+ label: 'Enter your password',
76
+ type: 'password',
77
+ size: 'sm',
78
+ required: true,
79
+ placeholder: 'Password',
80
+ },
81
+ };
@@ -54,9 +54,36 @@
54
54
  {{ message }}
55
55
  </p>
56
56
  </div>
57
+
58
+ <BaseField
59
+ v-if="inputConfig"
60
+ class="mt-5"
61
+ :label="inputConfig.label"
62
+ :size="inputConfig.size"
63
+ :required="inputConfig.required"
64
+ >
65
+ <BasePassword
66
+ v-if="inputConfig.type == 'password'"
67
+ ref="inputRef"
68
+ v-model="input"
69
+ name="input"
70
+ :placeholder="inputConfig.placeholder"
71
+ class="w-full"
72
+ />
73
+ <BaseInput
74
+ v-else
75
+ ref="inputRef"
76
+ v-model="input"
77
+ name="input"
78
+ :placeholder="inputConfig.placeholder"
79
+ :type="inputConfig.type"
80
+ class="w-full"
81
+ />
82
+ </BaseField>
57
83
  </slot>
58
84
  </div>
59
85
  </div>
86
+
60
87
  <div class="mt-5 || sm:mt-4 sm:flex sm:flex-row-reverse">
61
88
  <BaseButton
62
89
  ref="confirm"
@@ -64,7 +91,7 @@
64
91
  size="sm"
65
92
  class="mb-2 w-full sm:mb-0 sm:w-auto"
66
93
  :color="color"
67
- @click="$emit('confirm')"
94
+ @click="confirm"
68
95
  >
69
96
  {{ confirmText ?? t('sui.confirm') }}
70
97
  </BaseButton>
@@ -85,8 +112,12 @@ import { PropType } from 'vue';
85
112
  import { Icon as BaseIcon } from '@iconify/vue';
86
113
  import { t } from '@/i18n';
87
114
  import BaseButton from './BaseButton.vue';
115
+ import BaseInput from './BaseInput.vue';
116
+ import BaseField from './BaseField.vue';
117
+ import BasePassword from './BasePassword.vue';
118
+ import { InputConfigProps } from '@/types';
88
119
 
89
- defineProps({
120
+ const props = defineProps({
90
121
  color: {
91
122
  required: true,
92
123
  type: String as PropType<'info' | 'success' | 'danger' | 'warning'>,
@@ -115,15 +146,58 @@ defineProps({
115
146
  },
116
147
  type: String,
117
148
  },
149
+ input: {
150
+ default: false,
151
+ type: [Boolean, Object] as PropType<boolean | InputConfigProps>,
152
+ },
118
153
  });
119
154
 
120
- defineEmits(['cancel', 'confirm']);
155
+ const emit = defineEmits(['cancel', 'confirm']);
121
156
 
122
- const confirm = ref<HTMLButtonElement | null>(null);
157
+ const confirmRef = ref<HTMLButtonElement | null>(null);
158
+ const inputRef = ref<HTMLInputElement | null>(null);
123
159
 
124
160
  onMounted(() => {
125
- if (confirm.value) {
126
- confirm.value.focus();
161
+ if (inputRef.value) {
162
+ inputRef.value.focus();
163
+ } else {
164
+ if (confirmRef.value) {
165
+ confirmRef.value.focus();
166
+ }
167
+ }
168
+ });
169
+
170
+ const input = ref('');
171
+
172
+ const inputConfig = computed(() => {
173
+
174
+ if (props.input === false) {
175
+ return null;
176
+ }
177
+
178
+ if (typeof props.input === 'object') {
179
+ return props.input;
127
180
  }
181
+
182
+ return {
183
+ label: '',
184
+ placeholder: '',
185
+ } as InputConfigProps;
128
186
  });
187
+
188
+ function confirm() {
189
+ if (props.input === false) {
190
+ return emit('confirm');
191
+ }
192
+
193
+ if (input.value == '' && inputConfig.value?.required) {
194
+
195
+ inputRef.value?.focus();
196
+
197
+ return;
198
+ }
199
+
200
+ emit('confirm', input);
201
+ }
202
+
129
203
  </script>
@@ -57,7 +57,7 @@ const props = defineProps({
57
57
  },
58
58
  size: {
59
59
  default: undefined,
60
- type: String as PropType<Size>,
60
+ type: [String, undefined] as PropType<Size | undefined>,
61
61
  },
62
62
  required: {
63
63
  type: Boolean,
@@ -5,6 +5,7 @@ import { UploadedFile } from './UploadedFile';
5
5
  import { Notification } from './Notification';
6
6
  import { CropType, ResultOptions } from 'croppie';
7
7
  import { Media } from './Media';
8
+ import { Size } from '@/utils/sizes';
8
9
 
9
10
  export type Locales = { [locale: string]: string };
10
11
 
@@ -279,3 +280,13 @@ export type JsonDataItem = string | number | null | undefined | JsonData[] | Jso
279
280
  export interface JsonData {
280
281
  [key: string]: JsonDataItem;
281
282
  }
283
+
284
+ export interface InputConfigProps {
285
+ label?: string;
286
+ placeholder?: string;
287
+ name?: string;
288
+ type?: string;
289
+ size?: Size;
290
+ required?: boolean;
291
+ disabled?: boolean;
292
+ }