@fewangsit/wangsvue 1.5.196-alpha.0 → 1.5.196-alpha.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.
@@ -4,6 +4,56 @@ import { CustomValidation } from '../form/Form.vue.d';
4
4
  import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
5
5
  import { BadgeProps } from 'lib/components/badge/Badge.vue.d';
6
6
 
7
+ /**
8
+ * Configuration interface for localizing dropdown component placeholders and error messages.
9
+ */
10
+ export interface DropdownLocaleConfig {
11
+ /**
12
+ * Placeholder text for the filter input field.
13
+ *
14
+ * @default undefined
15
+ */
16
+ filterPlaceholder?: string;
17
+
18
+ /**
19
+ * Placeholder text displayed while the dropdown is loading.
20
+ *
21
+ * @example 'Loading...'
22
+ * @default undefined
23
+ */
24
+ loadingPlaceholder?: string;
25
+
26
+ /**
27
+ * Placeholder text for the input field when no selection has been made.
28
+ *
29
+ * This text can include a placeholder `{label}` which will be replaced with the value of `props.label`.
30
+ *
31
+ * @example 'Select {label}' - If `props.label` is 'Option', the placeholder will be 'Select Option'.
32
+ * @example 'Select {lowercaseLabel}' - If `props.label` is 'Option', the placeholder will be 'Select option'.
33
+ * @default undefined
34
+ */
35
+ inputPlaceholder?: string;
36
+
37
+ /**
38
+ * Error message displayed when no selection has been made.
39
+ *
40
+ * This message can include placeholders:
41
+ * - `{label}`: Replaced with the value of `props.label`.
42
+ * - `{formattedLabel}`: Replaced with the value of `props.label` formatted with an appropriate article (a/an).
43
+ *
44
+ * @example
45
+ * // If `props.label` is 'Label', the error message will be:
46
+ * '{label} must be picked' - 'Label must be picked'
47
+ *
48
+ * @example
49
+ * // If `props.label` is 'user', the error message will be:
50
+ * 'You must pick {formattedLabel}' - 'You must pick a user'
51
+ *
52
+ * @default undefined
53
+ */
54
+ emptySelectionErrorMessage?: string;
55
+ }
56
+
7
57
  /**
8
58
  * Dropdown component props
9
59
  */
@@ -13,79 +63,99 @@ export interface DropdownProps {
13
63
  * It may lead unexpected behavior.
14
64
  */
15
65
  modelValue?: OptionValue;
66
+
16
67
  /**
17
68
  * If you deals with form validation on edit form action, you can set the initial value of the field.
18
69
  */
19
70
  initialValue?: OptionValue;
71
+
20
72
  /**
21
73
  * The input label. Tell the user what input is this.
22
74
  */
23
75
  label?: string;
76
+
24
77
  /**
25
78
  * List of options to display.
26
79
  */
27
80
  options?: DropdownOption[] | string[] | Record<string, any>;
81
+
28
82
  /**
29
83
  * Specify the property name of option to be used as label.
30
84
  *
31
85
  * @default undefined - the label will be sets to the option itself.
32
86
  */
33
87
  optionLabel?: string;
88
+
34
89
  /**
35
90
  * Specify the property name of option to be used as value.
36
91
  *
37
92
  * @default undefined - the value will be sets to the option itself.
38
93
  */
39
94
  optionValue?: string;
95
+
40
96
  /**
41
97
  * Define the value style, whether badge or plain text
42
98
  *
43
99
  * @default 'plain'
44
100
  */
45
101
  valueType?: 'badge' | 'plain';
102
+
46
103
  /**
47
104
  * Bind the badge property to the dropdown value
48
105
  */
49
106
  badgeValueProps?: Omit<BadgeProps, 'label'>;
107
+
50
108
  /**
51
109
  * Set the input border style
52
110
  *
53
111
  * @default 'default'
54
112
  */
55
113
  inputBorder?: 'none' | 'default';
114
+
56
115
  /**
57
116
  * A property to uniquely identify an option.
58
117
  */
59
118
  dataKey?: string | undefined;
119
+
60
120
  /**
61
121
  * Determines if the field uses a validator
62
122
  */
63
123
  useValidator?: boolean;
124
+
64
125
  /**
65
126
  * Determines if the field is mandatory
66
127
  */
67
128
  mandatory?: boolean;
129
+
68
130
  /**
69
131
  * Show the text (opsional)
70
132
  *
71
133
  * @default true if mandatory true
72
134
  */
73
135
  showOptionalText?: boolean;
136
+
74
137
  /**
75
138
  * Set custom validator message.
76
139
  * It is rarely use, this component has handled the validator message.
140
+ *
141
+ *
142
+ * @example: 'This field is required'
143
+ * @example: { empty: 'This field is required' }
77
144
  */
78
- validatorMessage?: string;
145
+ validatorMessage?: string | CustomValidation<'empty'>;
146
+
79
147
  /**
80
148
  * Wether to format the message
81
149
  *
82
150
  * @default true
83
151
  */
84
152
  formatValidatorMessage?: boolean;
153
+
85
154
  /**
86
155
  * Set custom invalid state.
87
156
  */
88
157
  invalid?: boolean;
158
+
89
159
  /**
90
160
  * This prop is required if you use this component in a form input.
91
161
  * Specify the unique field name, match with your needs for API request.
@@ -93,39 +163,44 @@ export interface DropdownProps {
93
163
  * @default 'dropdown'
94
164
  */
95
165
  fieldName?: string;
166
+
96
167
  /**
97
168
  * Default text to display when no option is selected.
98
169
  *
99
170
  * @default `Select ${label}`
100
171
  */
101
172
  placeholder?: string;
173
+
102
174
  /**
103
175
  * Whether the dropdown is in loading state.
104
176
  * @defaultValue false
105
177
  */
106
178
  loading?: boolean;
179
+
107
180
  /**
108
181
  * Show icon 'info' on the right side of label.
109
182
  * Show information to user about the field on icon hover.
110
183
  */
111
184
  fieldInfo?: string;
185
+
112
186
  /**
113
187
  * Set disabled state for input dropdown.
114
188
  */
115
189
  disabled?: boolean;
190
+
116
191
  /**
117
192
  * Whether show the Dropdown option search or not.
118
193
  *
119
194
  * @default true,
120
195
  */
121
196
  filter?: boolean;
197
+
122
198
  /**
123
199
  * The filter input Placeholder
124
200
  *
125
201
  * @default 'Search'
126
202
  */
127
203
  filterPlaceholder?: string;
128
- customValidation?: CustomValidation;
129
204
  }
130
205
 
131
206
  export interface DropdownSlots {
@@ -143,6 +218,7 @@ export type DropdownEmits = {
143
218
  * Emits when an option selected.
144
219
  */
145
220
  'update:modelValue': [value: OptionValue | undefined];
221
+
146
222
  /**
147
223
  * Emits when overlay shown.
148
224
  */
@@ -15,7 +15,8 @@ export type Condition =
15
15
  | 'exist'
16
16
  | 'mismatch';
17
17
 
18
- export type CustomValidation = Partial<Record<Condition, string>>;
18
+ export type CustomValidation<T extends Partial<Condition> = Condition> =
19
+ Partial<Record<T, string>>;
19
20
 
20
21
  type FieldValue =
21
22
  | Nullable<string>
@@ -59,49 +60,60 @@ export interface FormProps {
59
60
  * The template for form buttons.
60
61
  */
61
62
  buttonsTemplate?: ('clear' | 'submit' | 'cancel')[];
63
+
62
64
  /**
63
65
  * Custom button cancel label.
64
66
  */
65
67
  cancelBtnLabel?: string;
68
+
66
69
  /**
67
70
  * Custom button clear label.
68
71
  */
69
72
  clearBtnLabel?: string;
73
+
70
74
  /**
71
75
  * The number of columns per row.
72
76
  * @default 1;
73
77
  */
74
78
  columnPerRow?: number;
79
+
75
80
  /**
76
81
  * Determines whether form footer should be hidden or not
77
82
  */
78
83
  hideFooter?: boolean;
84
+
79
85
  /**
80
86
  * Determines if the stay checkbox should be hidden.
81
87
  */
82
88
  hideStayCheckbox?: boolean;
89
+
83
90
  /**
84
91
  * Invalid form state.
85
92
  */
86
93
  invalid?: boolean;
94
+
87
95
  /**
88
96
  * Prevent form resets after submitted. Default behaviour is form resetted after submit.
89
97
  *
90
98
  * @default true
91
99
  */
92
100
  resetAfterSubmit?: boolean;
101
+
93
102
  /**
94
103
  * Custom button submit label.
95
104
  */
96
105
  submitBtnLabel?: string;
106
+
97
107
  /**
98
108
  * Custom label for stay checkbox.
99
109
  */
100
110
  stayCheckboxLabel?: string;
111
+
101
112
  /**
102
113
  * Custom submit form validator message.
103
114
  */
104
115
  validatorMessage?: string;
116
+
105
117
  /**
106
118
  * Defines the style of the cancel button.
107
119
  */
@@ -114,6 +126,7 @@ export interface FormProps {
114
126
  | 'danger'
115
127
  | 'contrast'
116
128
  >;
129
+
117
130
  /**
118
131
  * Defines the style of the submit button.
119
132
  */
@@ -146,10 +159,12 @@ export type FormEmits = {
146
159
  * Emitted when button template `Cancel` clicked (doesn't matter its label)
147
160
  */
148
161
  cancel: [];
162
+
149
163
  /**
150
164
  * Emitted when button template `Clear` clicked (doesn't matter its label)
151
165
  */
152
166
  clear: [];
167
+
153
168
  /**
154
169
  * Emitted when button template `Submit` clicked (doesn't matter its label)
155
170
  */
@@ -172,30 +187,37 @@ declare class Form extends ClassComponent<FormProps, FormSlots, FormEmits> {
172
187
  * Exposed errors of form
173
188
  */
174
189
  errors: Partial<Record<string, string>>;
190
+
175
191
  /**
176
192
  * The ref of form element.
177
193
  */
178
194
  formElement: HTMLFormElement;
195
+
179
196
  /**
180
197
  * Whether to show validator or not
181
198
  */
182
199
  showValidator: boolean;
200
+
183
201
  /**
184
202
  * Whether to keep the dialog remains visible or not after submit.
185
203
  */
186
204
  stayAfterSubmit: CheckboxModelValue;
205
+
187
206
  /**
188
207
  * Exposed function to clears the form fields.
189
208
  */
190
209
  clearField: () => void;
210
+
191
211
  /**
192
212
  * Exposed function to clears the specific field.
193
213
  */
194
214
  resetField: (field: string, state?: Partial<FieldState>) => void;
215
+
195
216
  /**
196
217
  * Exposed function that handle submit inside form component
197
218
  */
198
219
  submit: (e?: Event | undefined) => Promise<void | undefined>;
220
+
199
221
  /**
200
222
  * Exposed function to set the outer fields wrapper height.
201
223
  */
@@ -0,0 +1,15 @@
1
+ import { SetupContext, VNode } from 'vue';
2
+ interface LabelProps {
3
+ label: string;
4
+ }
5
+ /**
6
+ * For input like checkbox, radiobutton, toggleswitch, etc.
7
+ *
8
+ * Conditionally wrap the input with label element when props.label is defined.
9
+ *
10
+ * @param propsData
11
+ * @param setupContext
12
+ * @returns
13
+ */
14
+ declare const Label: (propsData: LabelProps, setupContext?: SetupContext) => VNode;
15
+ export default Label;
@@ -15,8 +15,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_TypePropsToOp
15
15
  touchResize?: unknown;
16
16
  wheelResize?: unknown;
17
17
  }>>> & {
18
- onMove?: (e: any) => any;
19
18
  onResize?: (e: any) => any;
19
+ onMove?: (e: any) => any;
20
20
  }, {}, {}>;
21
21
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
22
22
  export default _default;
@@ -29,6 +29,7 @@ export { default as ButtonFilter } from './buttonfilter/ButtonFilter.vue';
29
29
  export { default as ButtonRadio } from './buttonradio/ButtonRadio.vue';
30
30
  export { default as ButtonSearch } from './buttonsearch/ButtonSearch.vue';
31
31
  export { default as ButtonToggle } from './buttontoggle/ButtonToggle.vue';
32
+ export { default as ToggleSwitch } from './toggleswitch/ToggleSwitch.vue';
32
33
  export { default as Calendar } from './calendar/Calendar.vue';
33
34
  export { default as Card } from './card/Card.vue';
34
35
  export { default as Checkbox } from './checkbox/Checkbox.vue';
@@ -1,4 +1,5 @@
1
- import { DefineComponent } from 'vue';
1
+ import { CustomValidation } from '../form/Form.vue.d';
2
+ import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
2
3
 
3
4
  export type CurrencyFormat = {
4
5
  name?: string;
@@ -13,6 +14,18 @@ export interface CurrencyValue {
13
14
  value?: number;
14
15
  }
15
16
 
17
+ /**
18
+ * Configuration interface for locale-specific settings of the InputCurrency component.
19
+ */
20
+ export interface InputCurrencyLocaleConfig {
21
+ /**
22
+ * Error message to display when the input is empty.
23
+ *
24
+ * @example '{label} must not be empty' - 'Amount must not be empty'
25
+ */
26
+ emptyInputErrorMessage?: string;
27
+ }
28
+
16
29
  /**
17
30
  * InputCurrency component props
18
31
  */
@@ -21,6 +34,7 @@ export interface InputCurrencyProps {
21
34
  * Number modelValue of the input.
22
35
  */
23
36
  modelValue?: CurrencyValue;
37
+
24
38
  /**
25
39
  * Sets the initial value of the field.
26
40
  * This will only available with option 'useValidator'.
@@ -28,19 +42,23 @@ export interface InputCurrencyProps {
28
42
  * In usecase like edit form, you need to display the previous inputted value.
29
43
  */
30
44
  value?: number;
45
+
31
46
  /**
32
47
  * The input label. Tell the user what input is this.
33
48
  */
34
49
  label?: string;
50
+
35
51
  /**
36
52
  * Max input number value.
37
53
  */
38
54
  max?: number;
55
+
39
56
  /**
40
57
  * Wether the input should be validated with vee-validator or not.
41
58
  * If you use this component within form input, you need to set this props as true.
42
59
  */
43
60
  useValidator?: boolean;
61
+
44
62
  /**
45
63
  * This prop is required if you use this component in a form input.
46
64
  * Specify the unique field name, match with your needs for API request.
@@ -48,47 +66,60 @@ export interface InputCurrencyProps {
48
66
  * @default 'numberInput'
49
67
  */
50
68
  fieldName?: string;
69
+
51
70
  /**
52
71
  * Wether this input field is required or not.
53
72
  */
54
73
  mandatory?: boolean;
74
+
55
75
  /**
56
76
  * Set custom validator message.
57
77
  * It is rarely use, this component has handled the validator message.
78
+ *
79
+ * @example: '{label} is required'
80
+ * @example: { empty: '{label} field is required' }
58
81
  */
59
- validatorMessage?: string;
82
+ validatorMessage?: string | CustomValidation<'empty'>;
83
+
60
84
  /**
61
85
  * Custom invalid state.
62
86
  */
63
87
  invalid?: boolean;
88
+
64
89
  /**
65
90
  * Specify the input placeholder.
66
91
  *
67
92
  * @default 'Enter {label}' or 'Enter number'
68
93
  */
69
94
  placeholder?: string;
95
+
70
96
  /**
71
97
  * Disabled the input.
72
98
  */
73
99
  disabled?: boolean;
100
+
74
101
  /**
75
102
  * Displays increment/decrement buttons.
76
103
  */
77
104
  showButtons?: boolean;
105
+
78
106
  /**
79
107
  * The width of input.
80
108
  */
81
109
  size?: 'small' | 'normal' | 'full';
110
+
82
111
  /**
83
112
  * Defines the behavior of the component.
84
113
  * @defaultValue currency
85
114
  */
86
115
  mode?: 'decimal' | 'currency';
116
+
87
117
  /**
88
118
  * Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.
89
119
  * @defaultValue true
90
120
  */
91
121
  useGrouping?: boolean;
122
+
92
123
  /**
93
124
  * Show information about the field.
94
125
  */
@@ -107,6 +138,7 @@ export type InputCurrencyEmits = {
107
138
  * If the inputted number is above max, return the max. And vice versa.
108
139
  */
109
140
  'update:modelValue': [payload?: CurrencyValue];
141
+
110
142
  /**
111
143
  * If you need to check validation, you can use this events.
112
144
  */
@@ -123,9 +155,16 @@ export type InputCurrencyEmits = {
123
155
  *
124
156
  * @group form
125
157
  */
126
- declare const InputCurrency: DefineComponent<
158
+ declare class InputCurrency extends ClassComponent<
127
159
  InputCurrencyProps,
160
+ unknown,
128
161
  InputCurrencyEmits
129
- >;
162
+ > {}
163
+
164
+ declare module '@vue/runtime-core' {
165
+ interface GlobalComponents {
166
+ InputCurrency: GlobalComponentConstructor<InputCurrency>;
167
+ }
168
+ }
130
169
 
131
170
  export default InputCurrency;