sprintify-ui 0.8.19 → 0.8.21

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.
@@ -5,10 +5,19 @@ declare const _default: import("vue").DefineComponent<{}, {
5
5
  title: string;
6
6
  message: string;
7
7
  html: boolean;
8
+ input: false | {
9
+ label?: string | undefined;
10
+ placeholder?: string | undefined;
11
+ name?: string | undefined;
12
+ type?: string | undefined;
13
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
14
+ required?: boolean | undefined;
15
+ disabled?: boolean | undefined;
16
+ };
8
17
  confirmText: string;
9
18
  cancelText: string;
10
19
  closeOnOutsideClick: boolean;
11
- onConfirm: () => void;
20
+ onConfirm: (input?: string | undefined) => void;
12
21
  onCancel: () => void;
13
22
  }[]>;
14
23
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
@@ -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;
@@ -59,6 +68,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
59
68
  title: string;
60
69
  message: string;
61
70
  html: boolean;
71
+ input: boolean | InputConfigProps;
62
72
  confirmText: string;
63
73
  cancelText: string;
64
74
  }, {}>, {
@@ -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;
@@ -54,10 +54,10 @@ declare const _default: import("vue").DefineComponent<{
54
54
  focus: typeof focus;
55
55
  blur: typeof blur;
56
56
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
57
+ input: (...args: any[]) => void;
57
58
  focus: (...args: any[]) => void;
58
59
  "update:modelValue": (...args: any[]) => void;
59
60
  submit: (...args: any[]) => void;
60
- input: (...args: any[]) => void;
61
61
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
62
62
  modelValue: {
63
63
  default: string;
@@ -110,8 +110,8 @@ declare const _default: import("vue").DefineComponent<{
110
110
  }>> & {
111
111
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
112
112
  onFocus?: ((...args: any[]) => any) | undefined;
113
- onSubmit?: ((...args: any[]) => any) | undefined;
114
113
  onInput?: ((...args: any[]) => any) | undefined;
114
+ onSubmit?: ((...args: any[]) => any) | undefined;
115
115
  }, {
116
116
  required: boolean;
117
117
  modelValue: string | null;
@@ -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
  };
@@ -120,10 +121,11 @@ export interface DialogOptions {
120
121
  title: string;
121
122
  message: string;
122
123
  html?: boolean;
124
+ input?: InputConfigProps | false;
123
125
  confirmText?: string;
124
126
  cancelText?: string;
125
127
  closeOnOutsideClick?: boolean;
126
- onConfirm?: () => void;
128
+ onConfirm?: (input?: string) => void;
127
129
  onCancel?: () => void;
128
130
  }
129
131
  export interface Dialog {
@@ -132,10 +134,11 @@ export interface Dialog {
132
134
  title: string;
133
135
  message: string;
134
136
  html: boolean;
137
+ input: InputConfigProps | false;
135
138
  confirmText: string;
136
139
  cancelText: string;
137
140
  closeOnOutsideClick: boolean;
138
- onConfirm: () => void;
141
+ onConfirm: (input?: string) => void;
139
142
  onCancel: () => void;
140
143
  }
141
144
  /**
@@ -230,3 +233,12 @@ export type JsonDataItem = string | number | null | undefined | JsonData[] | Jso
230
233
  export interface JsonData {
231
234
  [key: string]: JsonDataItem;
232
235
  }
236
+ export interface InputConfigProps {
237
+ label?: string;
238
+ placeholder?: string;
239
+ name?: string;
240
+ type?: string;
241
+ size?: Size;
242
+ required?: boolean;
243
+ disabled?: boolean;
244
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -48,9 +48,10 @@
48
48
  :message="dialog.message"
49
49
  :confirm-text="dialog.confirmText"
50
50
  :html="dialog.html"
51
+ :input="dialog.input"
51
52
  :cancel-text="dialog.cancelText"
52
53
  @cancel="cancel(dialog)"
53
- @confirm="confirm(dialog)"
54
+ @confirm="event => confirm(dialog, event)"
54
55
  />
55
56
  </div>
56
57
  </div>
@@ -70,8 +71,8 @@ const dialogs = computed(() => {
70
71
  return dialogStore.dialogs;
71
72
  });
72
73
 
73
- function confirm(dialog: Dialog) {
74
- dialog.onConfirm();
74
+ function confirm(dialog: Dialog, input?: string) {
75
+ dialog.onConfirm(input);
75
76
  remove(dialog);
76
77
  }
77
78
 
@@ -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,
@@ -21,6 +21,7 @@ export const useDialogsStore = defineStore('dialogs', {
21
21
  confirmText: options.confirmText ?? t('sui.confirm'),
22
22
  cancelText: options.cancelText ?? t('sui.cancel'),
23
23
  closeOnOutsideClick: options.closeOnOutsideClick ?? true,
24
+ input: options.input ?? false,
24
25
  onConfirm:
25
26
  options.onConfirm ??
26
27
  function () {
@@ -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
 
@@ -152,10 +153,11 @@ export interface DialogOptions {
152
153
  title: string;
153
154
  message: string;
154
155
  html?: boolean;
156
+ input?: InputConfigProps | false;
155
157
  confirmText?: string;
156
158
  cancelText?: string;
157
159
  closeOnOutsideClick?: boolean;
158
- onConfirm?: () => void;
160
+ onConfirm?: (input?: string) => void;
159
161
  onCancel?: () => void;
160
162
  }
161
163
 
@@ -165,10 +167,11 @@ export interface Dialog {
165
167
  title: string;
166
168
  message: string;
167
169
  html: boolean;
170
+ input: InputConfigProps | false;
168
171
  confirmText: string;
169
172
  cancelText: string;
170
173
  closeOnOutsideClick: boolean;
171
- onConfirm: () => void;
174
+ onConfirm: (input?: string) => void;
172
175
  onCancel: () => void;
173
176
  }
174
177
 
@@ -279,3 +282,13 @@ export type JsonDataItem = string | number | null | undefined | JsonData[] | Jso
279
282
  export interface JsonData {
280
283
  [key: string]: JsonDataItem;
281
284
  }
285
+
286
+ export interface InputConfigProps {
287
+ label?: string;
288
+ placeholder?: string;
289
+ name?: string;
290
+ type?: string;
291
+ size?: Size;
292
+ required?: boolean;
293
+ disabled?: boolean;
294
+ }