pui9-components 1.16.4

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.
Files changed (60) hide show
  1. package/README.md +43 -0
  2. package/dist/demo.html +10 -0
  3. package/dist/pui9-components.common.js +81953 -0
  4. package/dist/pui9-components.common.js.map +1 -0
  5. package/dist/pui9-components.css +5 -0
  6. package/dist/pui9-components.umd.js +81963 -0
  7. package/dist/pui9-components.umd.js.map +1 -0
  8. package/dist/pui9-components.umd.min.js +308 -0
  9. package/dist/pui9-components.umd.min.js.map +1 -0
  10. package/package-lock.json +15945 -0
  11. package/package.json +78 -0
  12. package/src/App.vue +117 -0
  13. package/src/components/PuiCheckbox.vue +105 -0
  14. package/src/components/PuiCodeEditor.vue +123 -0
  15. package/src/components/PuiDateField.vue +1004 -0
  16. package/src/components/PuiField.vue +30 -0
  17. package/src/components/PuiFieldSet.vue +27 -0
  18. package/src/components/PuiFormFooter.vue +64 -0
  19. package/src/components/PuiFormFooterBtns.vue +118 -0
  20. package/src/components/PuiFormHeader.vue +25 -0
  21. package/src/components/PuiFormLoading.vue +12 -0
  22. package/src/components/PuiFormMiniAudit.vue +53 -0
  23. package/src/components/PuiMasterDetail.vue +96 -0
  24. package/src/components/PuiModalDialog.vue +87 -0
  25. package/src/components/PuiModalDialogForm.vue +205 -0
  26. package/src/components/PuiMultiSelect.vue +499 -0
  27. package/src/components/PuiNumberField.vue +503 -0
  28. package/src/components/PuiPasswordField.vue +105 -0
  29. package/src/components/PuiRadioGroup.vue +105 -0
  30. package/src/components/PuiRichTextEditor.vue +117 -0
  31. package/src/components/PuiSelect.vue +1638 -0
  32. package/src/components/PuiSelectDetailDialog.vue +106 -0
  33. package/src/components/PuiSelectTextService.vue +61 -0
  34. package/src/components/PuiSpinnerField.vue +484 -0
  35. package/src/components/PuiSwitch.vue +104 -0
  36. package/src/components/PuiTextArea.vue +203 -0
  37. package/src/components/PuiTextField.vue +272 -0
  38. package/src/dateTimeUtils.js +78 -0
  39. package/src/index.js +73 -0
  40. package/src/main.js +33 -0
  41. package/src/mixins/PuiFormComponentMixin.js +81 -0
  42. package/src/mixins/PuiMultiSelectMixin.js +106 -0
  43. package/src/mixins/PuiUtilsNumberMixin.js +19 -0
  44. package/src/plugins/vuetify.js +32 -0
  45. package/src/tests/TestAutocomplete.vue +138 -0
  46. package/src/tests/TestCodeEditor.vue +48 -0
  47. package/src/tests/TestField.vue +22 -0
  48. package/src/tests/TestFieldSet.vue +30 -0
  49. package/src/tests/TestInputCheckbox.vue +53 -0
  50. package/src/tests/TestInputDate.vue +146 -0
  51. package/src/tests/TestInputNumber.vue +77 -0
  52. package/src/tests/TestInputRadioGroup.vue +86 -0
  53. package/src/tests/TestInputSpinner.vue +77 -0
  54. package/src/tests/TestInputSwitch.vue +52 -0
  55. package/src/tests/TestInputText.vue +120 -0
  56. package/src/tests/TestInputTextArea.vue +73 -0
  57. package/src/tests/TestMultiSelect.vue +127 -0
  58. package/src/tests/TestPuiForm.vue +68 -0
  59. package/src/tests/TestRichTextEditor.vue +54 -0
  60. package/src/utils.js +148 -0
@@ -0,0 +1,503 @@
1
+ <template>
2
+ <!-- DESKTOP - TABLE -->
3
+ <div v-if="!isMobile">
4
+ <div v-if="toplabel" class="ml-1 mr-1">
5
+ <v-layout>
6
+ <v-flex xs12>
7
+ <label v-if="getLabel === '$nbsp;'">&nbsp;</label>
8
+ <label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
9
+ <v-tooltip top v-if="showTooltip">
10
+ <template v-slot:activator="{ on }">
11
+ <v-icon class="info-tooltip" size="14" v-on="on">fas fa-info-circle info-tooltip</v-icon>
12
+ </template>
13
+ <span>
14
+ <span v-if="this.description !== ''">
15
+ {{ this.description }}
16
+ <hr v-if="this.infoTooltipMessages.length > 0" />
17
+ </span>
18
+ <ul>
19
+ <li v-for="(message, index) in this.infoTooltipMessages" :key="index">{{ message }}</li>
20
+ </ul>
21
+ </span>
22
+ </v-tooltip>
23
+ </v-flex>
24
+ </v-layout>
25
+ <v-layout>
26
+ <v-flex xs12>
27
+ <v-text-field
28
+ v-show="!showVisibleModel"
29
+ v-model="internalModel"
30
+ v-bind="allProps"
31
+ :class="getEditedClass"
32
+ solo
33
+ outlined
34
+ flat
35
+ @blur="updateValueLazy"
36
+ :rules="getRules"
37
+ @keydown="clearMessages"
38
+ @keyup="validateNumber"
39
+ :messages="internalMessages"
40
+ type="number"
41
+ :placeholder="getPlaceholder"
42
+ :error-messages="internalErrorMessages"
43
+ :error="internalError"
44
+ ref="puiNumberField"
45
+ ></v-text-field>
46
+ <v-text-field
47
+ :id="`${allProps.id}_internal`"
48
+ v-show="showVisibleModel"
49
+ v-model="visibleModel"
50
+ v-bind="allProps"
51
+ :class="getEditedClass"
52
+ solo
53
+ outlined
54
+ flat
55
+ @focus="onFocusText"
56
+ :messages="internalMessages"
57
+ :error-messages="internalErrorMessages"
58
+ :error="internalError"
59
+ ></v-text-field>
60
+ </v-flex>
61
+ </v-layout>
62
+ </div>
63
+ <div v-else class="ml-1 mr-1">
64
+ <v-layout>
65
+ <v-flex :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
66
+ <label :class="getLabelRequiredClass">{{ getLabel }}</label>
67
+ <v-tooltip top v-if="showTooltip">
68
+ <template v-slot:activator="{ on }">
69
+ <v-icon class="info-tooltip" size="14" v-on="on">fas fa-info-circle info-tooltip</v-icon>
70
+ </template>
71
+ <span>
72
+ <span v-if="this.description !== ''">
73
+ {{ this.description }}
74
+ <hr v-if="this.infoTooltipMessages.length > 0" />
75
+ </span>
76
+ <ul>
77
+ <li v-for="(message, index) in this.infoTooltipMessages" :key="index">{{ message }}</li>
78
+ </ul>
79
+ </span>
80
+ </v-tooltip>
81
+ </v-flex>
82
+ <v-flex :class="valueColumnStyles ? valueColumnStyles : 'xs12 sm6 md8 xl9'">
83
+ <v-text-field
84
+ v-show="!showVisibleModel"
85
+ v-model="internalModel"
86
+ v-bind="allProps"
87
+ :class="getEditedClass"
88
+ solo
89
+ outlined
90
+ flat
91
+ @blur="updateValueLazy"
92
+ :rules="getRules"
93
+ @keydown="clearMessages"
94
+ @keyup="validateNumber"
95
+ :messages="internalMessages"
96
+ type="number"
97
+ :placeholder="getPlaceholder"
98
+ :error-messages="internalErrorMessages"
99
+ :error="internalError"
100
+ ref="puiNumberField"
101
+ ></v-text-field>
102
+ <v-text-field
103
+ :id="`${allProps.id}_internal`"
104
+ v-show="showVisibleModel"
105
+ v-model="visibleModel"
106
+ v-bind="allProps"
107
+ :class="getEditedClass"
108
+ solo
109
+ outlined
110
+ flat
111
+ @focus="onFocusText"
112
+ :messages="internalMessages"
113
+ :error-messages="internalErrorMessages"
114
+ :error="internalError"
115
+ ></v-text-field>
116
+ </v-flex>
117
+ </v-layout>
118
+ </div>
119
+ </div>
120
+ <!-- MOBILE -->
121
+ <div v-else>
122
+ <v-layout>
123
+ <v-flex xs12>
124
+ <v-text-field
125
+ v-show="!showVisibleModel"
126
+ v-model="internalModel"
127
+ v-bind="allProps"
128
+ :class="getMobileClass"
129
+ class="v-text-field--mobile"
130
+ :label="getLabel"
131
+ flat
132
+ @blur="updateValueLazy"
133
+ @keydown="clearMessages"
134
+ @keyup="validateNumber"
135
+ :rules="getRules"
136
+ :messages="internalMessages"
137
+ type="number"
138
+ :placeholder="getPlaceholder"
139
+ :error-messages="internalErrorMessages"
140
+ :error="internalError"
141
+ ref="puiNumberField"
142
+ ></v-text-field>
143
+ <v-text-field
144
+ :id="`${allProps.id}_internal`"
145
+ v-show="showVisibleModel"
146
+ v-model="visibleModel"
147
+ v-bind="allProps"
148
+ :class="getMobileClass"
149
+ class="v-text-field--mobile"
150
+ :label="getLabel"
151
+ flat
152
+ @focus="onFocusText"
153
+ :messages="internalMessages"
154
+ :error-messages="internalErrorMessages"
155
+ :error="internalError"
156
+ ></v-text-field>
157
+ </v-flex>
158
+ </v-layout>
159
+ </div>
160
+ </template>
161
+
162
+ <script>
163
+ import PuiUtilsNumberMixin from '../mixins/PuiUtilsNumberMixin';
164
+ import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
165
+
166
+ export default {
167
+ name: 'PuiNumberField',
168
+ mixins: [PuiUtilsNumberMixin, PuiFormComponentMixin],
169
+ data: () => ({
170
+ internalMessages: [],
171
+ internalErrorMessages: [],
172
+ internalDecimals: 999,
173
+ internalMax: Number.MAX_SAFE_INTEGER,
174
+ internalMin: Number.MIN_SAFE_INTEGER,
175
+ infoTooltipMessages: [],
176
+ showVisibleModel: true
177
+ }),
178
+ props: {
179
+ value: {
180
+ type: [String, Number],
181
+ required: false
182
+ },
183
+ decimals: {
184
+ type: [String, Number],
185
+ default: 999,
186
+ required: false
187
+ },
188
+ max: {
189
+ type: [String, Number],
190
+ default: () => {
191
+ return Number.MAX_SAFE_INTEGER;
192
+ },
193
+ required: false
194
+ },
195
+ min: {
196
+ type: [String, Number],
197
+ default: () => {
198
+ return Number.MIN_SAFE_INTEGER;
199
+ },
200
+ required: false
201
+ },
202
+ tooltip: {
203
+ type: [Boolean],
204
+ default: false,
205
+ required: false
206
+ },
207
+ description: {
208
+ type: [String],
209
+ default: '',
210
+ required: false
211
+ },
212
+ integer: {
213
+ type: [Boolean],
214
+ default: false,
215
+ required: false
216
+ },
217
+ rules: {
218
+ type: Array,
219
+ default: () => {
220
+ return [];
221
+ }
222
+ },
223
+ placeholder: {
224
+ type: [String],
225
+ default: ' ',
226
+ required: false
227
+ },
228
+ noLazyModel: {
229
+ type: [Boolean],
230
+ default: false,
231
+ required: false
232
+ },
233
+ labelColumnStyles: {
234
+ type: [String],
235
+ required: false
236
+ },
237
+ valueColumnStyles: {
238
+ type: [String],
239
+ required: false
240
+ }
241
+ },
242
+ methods: {
243
+ getInfoTooltip() {
244
+ if (this.max < Number.MAX_SAFE_INTEGER) {
245
+ this.infoTooltipMessages.push(this.$t('pui9.components.numberField.maxvaluemessage') + ': ' + this.max);
246
+ }
247
+
248
+ if (this.min > Number.MIN_SAFE_INTEGER) {
249
+ this.infoTooltipMessages.push(this.$t('pui9.components.numberField.minvaluemessage') + ': ' + this.min);
250
+ }
251
+
252
+ if (this.integer) {
253
+ this.infoTooltipMessages.push(this.$t('pui9.components.numberField.integermessage'));
254
+ }
255
+
256
+ if (this.decimals !== 999) {
257
+ this.infoTooltipMessages.push(this.$t('pui9.components.numberField.maxdecimalsmessage') + ': ' + this.decimals);
258
+ }
259
+ },
260
+ onFocusText() {
261
+ this.showVisibleModel = false;
262
+ setTimeout(() => {
263
+ this.$refs.puiNumberField.focus();
264
+ }, 5);
265
+ },
266
+ updateValueLazy(val) {
267
+ this.showVisibleModel = true;
268
+ var valueAsNumber = val.target.valueAsNumber;
269
+
270
+ this.validateNumber(val);
271
+ this.checkMinMax(valueAsNumber);
272
+
273
+ if (!this.internalError) {
274
+ this.$emit('input', this.internalModel);
275
+ } else {
276
+ this.$emit('input', null);
277
+ }
278
+ },
279
+ showWrongNumberMessage() {
280
+ var message = this.$t('pui9.components.numberField.wrongnumber');
281
+ this.internalError = true;
282
+ this.internalErrorMessages = [message];
283
+ },
284
+ showRequiredMessage() {
285
+ var message = this.$t('pui9.error.field_required');
286
+ this.internalError = true;
287
+ this.internalErrorMessages = [message];
288
+ },
289
+ validateNumber(evt) {
290
+ var val = evt.target.value;
291
+ var valNum = evt.target.valueAsNumber;
292
+ var wrong = isNaN(valNum);
293
+
294
+ if (!wrong) {
295
+ this.checkNumber(val);
296
+ } else {
297
+ if (evt.target.validity.badInput) {
298
+ this.showWrongNumberMessage();
299
+ } else {
300
+ if (this.required) {
301
+ this.showRequiredMessage();
302
+ }
303
+ }
304
+ // Con este código conforme pones algo inválido te vacía el campo... Si pones un '.' sin querer te borra todo. Igual con un timeout de unos segundos sí que queda bien.
305
+ /* if (!val) {
306
+ this.internalModel = Number.NaN;
307
+ } */
308
+ }
309
+ },
310
+ checkNumber(val) {
311
+ // INTEGERS
312
+ if (this.integer) {
313
+ var isInt = this.checkInteger(val);
314
+ if (isInt) {
315
+ this.internalModel = parseInt(val);
316
+ } else {
317
+ var int = parseInt(val);
318
+ if (!isNaN(int)) {
319
+ this.internalModel = int;
320
+ } else {
321
+ this.showWrongNumberMessage();
322
+ }
323
+ }
324
+ } else {
325
+ var isFloat = this.checkFloat(val);
326
+ if (isFloat) {
327
+ this.formatNumber(val);
328
+ } else {
329
+ this.showWrongNumberMessage();
330
+ }
331
+ }
332
+ },
333
+ checkMinMax(value) {
334
+ // MAX
335
+ if (value > this.internalMax) {
336
+ this.internalErrorMessages = [];
337
+ this.internalErrorMessages.push(this.$t('pui9.components.numberField.maxvaluemessage') + ' ' + this.internalMax);
338
+ this.internalError = true;
339
+ }
340
+ // MIN
341
+ if (value < this.internalMin) {
342
+ this.internalErrorMessages = [];
343
+ this.internalErrorMessages.push(this.$t('pui9.components.numberField.minvaluemessage') + ' ' + this.internalMin);
344
+ this.internalError = true;
345
+ }
346
+ },
347
+ formatNumber(val) {
348
+ var fval = parseFloat(val);
349
+
350
+ if (val && val.length > 0) {
351
+ // DECIMALS
352
+ if (val.indexOf('.') !== -1) {
353
+ var parts = val.split('.');
354
+ var decimalPart = parts[1];
355
+ if (decimalPart && decimalPart.length > this.internalDecimals) {
356
+ var nfloat = this.truncateDecimal(val, this.internalDecimals);
357
+ //if (parseFloat(this.internalModel) !== nfloat) {
358
+ this.internalModel = nfloat;
359
+ this.internalMessages = [];
360
+ this.internalMessages.push(this.$t('pui9.components.numberField.maxdecimalsmessage') + ' ' + this.internalDecimals);
361
+ this.internalError = true;
362
+ //}
363
+ } else {
364
+ this.clearMessages();
365
+ }
366
+ } else {
367
+ this.clearMessages();
368
+ }
369
+ this.checkMinMax(fval);
370
+ } else {
371
+ this.clearMessages();
372
+ }
373
+ },
374
+ clearMessages() {
375
+ this.internalError = false;
376
+ this.internalMessages = [];
377
+ this.internalErrorMessages = [];
378
+ },
379
+ initializeModel(value) {
380
+ if (this.integer) {
381
+ //this.initialValue = parseInt(value);
382
+ this.internalModel = parseInt(value);
383
+ } else {
384
+ //this.initialValue = parseFloat(value);
385
+ this.internalModel = parseFloat(value);
386
+ }
387
+ // check max/min
388
+ this.checkMinMax(value);
389
+ },
390
+ formatAndSetMinMax() {
391
+ const mmax = parseFloat(this.max);
392
+ const mmin = parseFloat(this.min);
393
+ this.internalMax = !isNaN(mmax) ? mmax : this.internalMax;
394
+ this.internalMin = !isNaN(mmin) ? mmin : this.internalMin;
395
+ }
396
+ },
397
+ computed: {
398
+ getMobileClass() {
399
+ return { 'v-text-field--edited': this.isEdited, 'v-text-field--required': this.required };
400
+ },
401
+ getLabelRequiredClass() {
402
+ return { 'v-label--required': this.required };
403
+ },
404
+ getEditedClass() {
405
+ return { 'v-text-field--edited': this.isEdited };
406
+ },
407
+ getRules() {
408
+ const rules = [...this.rules];
409
+ var func2 = () => !this.internalError || '';
410
+ rules.push(func2);
411
+ if (this.required) {
412
+ // Si se descomenta el código, cuando el campo es erróneo y presionas alguna tecla antes de mostrar mensaje de campo erróneo se muestra el de campo obligatorio. Así funciona correctamente
413
+
414
+ /* var func = value => !!value || this.requiredMessage; */
415
+ var func3 = () => {
416
+ if (this.internalModel === '' || this.internalModel === null || isNaN(this.internalModel)) {
417
+ return this.requiredMessage;
418
+ }
419
+ return true;
420
+ };
421
+ /* rules.push(func, func2, func3); */
422
+ rules.push(func3);
423
+ }
424
+ return rules;
425
+ },
426
+ compPlaceholder() {
427
+ if (this.placeholder && this.placeholder.length > 0) {
428
+ return this.placeholder;
429
+ }
430
+ return ' ';
431
+ },
432
+ showTooltip() {
433
+ if (!this.tooltip || this.getLabel === '' || this.getLabel === null) {
434
+ return false;
435
+ }
436
+ return (this.infoTooltipMessages.length > 0 || this.description !== '') && this.tooltip;
437
+ },
438
+ thousandSeparator() {
439
+ return this.$store.getters.thousandSeparator;
440
+ },
441
+ decimalSeparator() {
442
+ return this.$store.getters.decimalSeparator;
443
+ },
444
+ visibleModel() {
445
+ if (this.internalModel === null || this.internalModel === undefined || isNaN(this.internalModel)) return '';
446
+ const value = this.internalModel.toString();
447
+ if (value.includes('.')) {
448
+ const parts = value.split('.');
449
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
450
+ return parts.join(this.decimalSeparator);
451
+ }
452
+ return value.replace(/(\d)(?=(\d{3})+(?!\d))/g, `$1${this.thousandSeparator}`);
453
+ }
454
+ },
455
+ created() {
456
+ this.internalDecimals = parseInt(this.decimals);
457
+ this.formatAndSetMinMax();
458
+ if (this.noLazyModel) {
459
+ this.firstLazyLoad = true;
460
+ }
461
+ if (this.integer) {
462
+ this.initialValue = parseInt(this.value);
463
+ } else {
464
+ this.initialValue = parseFloat(this.value);
465
+ }
466
+ this.initializeModel(this.value);
467
+ this.getInfoTooltip();
468
+ },
469
+ watch: {
470
+ value(val) {
471
+ if (!this.noLazyModel && !this.firstLazyLoad) {
472
+ this.clearMessages();
473
+ this.initializeModel(val);
474
+ this.firstLazyLoad = true;
475
+ } else {
476
+ this.internalModel = val;
477
+ if (val) {
478
+ this.clearMessages();
479
+ this.checkMinMax(val);
480
+ }
481
+ }
482
+ },
483
+ required(val) {
484
+ if (!val) {
485
+ this.clearMessages();
486
+ if (this.internalModel) {
487
+ this.checkNumber(this.internalModel);
488
+ }
489
+ }
490
+ },
491
+ min() {
492
+ this.clearMessages();
493
+ this.formatAndSetMinMax();
494
+ this.checkMinMax(this.value);
495
+ },
496
+ max() {
497
+ this.clearMessages();
498
+ this.formatAndSetMinMax();
499
+ this.checkMinMax(this.value);
500
+ }
501
+ }
502
+ };
503
+ </script>
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <!-- DESKTOP -->
3
+ <div v-if="!isMobile">
4
+ <div class="ml-1 mr-1">
5
+ <v-layout>
6
+ <v-flex xs12 sm6 md4 xl3>
7
+ <label v-if="getLabel === '$nbsp;'">&nbsp;</label>
8
+ <label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
9
+ </v-flex>
10
+ <v-flex xs12 sm6 md8 xl9>
11
+ <v-text-field
12
+ :append-icon="show ? 'far fa-eye-slash' : 'far fa-eye'"
13
+ :type="show ? 'text' : 'password'"
14
+ v-bind="allProps"
15
+ v-model="internalModel"
16
+ class="input-group--focused"
17
+ @click:append="show = !show"
18
+ :rules="getRules"
19
+ :placeholder="getPlaceholder"
20
+ solo
21
+ flat
22
+ outlined
23
+ single-line
24
+ @input="updateValue"
25
+ v-if="!isMobile"
26
+ ></v-text-field>
27
+ </v-flex>
28
+ </v-layout>
29
+ </div>
30
+ </div>
31
+
32
+ <!-- MOBILE -->
33
+ <div v-else>
34
+ <v-layout>
35
+ <v-flex xs12>
36
+ <v-text-field
37
+ :append-icon="show ? 'far fa-eye-slash' : 'far fa-eye'"
38
+ :type="show ? 'text' : 'password'"
39
+ v-bind="allProps"
40
+ v-model="internalModel"
41
+ class="input-group--focused v-text-field--mobile"
42
+ @click:append="show = !show"
43
+ :rules="getRules"
44
+ :placeholder="getPlaceholder"
45
+ flat
46
+ @input="updateValue"
47
+ ></v-text-field>
48
+ </v-flex>
49
+ </v-layout>
50
+ </div>
51
+ </template>
52
+
53
+ <script>
54
+ import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
55
+
56
+ export default {
57
+ name: 'PuiPasswordField',
58
+ mixins: [PuiFormComponentMixin],
59
+ data() {
60
+ return {
61
+ required: true,
62
+ isMobile: false,
63
+ show: false
64
+ };
65
+ },
66
+ props: {
67
+ rules: {
68
+ type: Array,
69
+ default: () => {
70
+ return [];
71
+ }
72
+ }
73
+ },
74
+ methods: {
75
+ updateValue(value) {
76
+ this.$emit('input', value);
77
+ }
78
+ },
79
+ computed: {
80
+ getLabelRequiredClass() {
81
+ return { 'v-label--required': this.required };
82
+ },
83
+ getRules() {
84
+ const rules = [...this.rules];
85
+ if (this.required) {
86
+ var func = (value) => !!value || this.$t('pui9.error.field_required');
87
+ rules.push(func);
88
+ }
89
+ return rules;
90
+ },
91
+ getPlaceholder() {
92
+ return this.$t('pui9.password');
93
+ }
94
+ },
95
+ created() {
96
+ this.isMobile = this.$store.getters.isMobile;
97
+ this.internalModel = this.value;
98
+ },
99
+ watch: {
100
+ value(val) {
101
+ this.internalModel = val;
102
+ }
103
+ }
104
+ };
105
+ </script>
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <div v-if="!isMobile">
3
+ <div v-if="toplabel">
4
+ <v-layout>
5
+ <v-flex xs12>
6
+ <label v-if="getLabel === '$nbsp;'">&nbsp;</label>
7
+ <label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
8
+ </v-flex>
9
+ </v-layout>
10
+ <v-layout>
11
+ <v-flex xs12>
12
+ <v-radio-group v-model="internalModel" v-bind="allProps" @change="updateValue">
13
+ <v-radio v-for="radio in this.radios" :key="radio.id" :label="radio.label" :value="radio.id"></v-radio>
14
+ </v-radio-group>
15
+ </v-flex>
16
+ </v-layout>
17
+ </div>
18
+ <div v-else>
19
+ <v-layout>
20
+ <v-flex v-if="label" :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
21
+ <label :class="getLabelRequiredClass">{{ getLabel }}</label>
22
+ </v-flex>
23
+ <v-flex :class="valueColumnStyles ? valueColumnStyles : 'xs12 sm6 md8 xl9'">
24
+ <v-radio-group v-model="internalModel" v-bind="allProps" @change="updateValue">
25
+ <v-radio v-for="radio in this.radios" :key="radio.id" :label="radio.label" :value="radio.id"></v-radio>
26
+ </v-radio-group>
27
+ </v-flex>
28
+ </v-layout>
29
+ </div>
30
+ </div>
31
+ <!-- MOBILE -->
32
+ <div v-else>
33
+ <label v-if="label" class="mr-3">{{ getLabel }}</label>
34
+ <v-radio-group v-model="internalModel" v-bind="allProps" @change="updateValue">
35
+ <v-radio v-for="radio in this.radios" :key="radio.id" :label="radio.label" :value="radio.id" :ripple="false"></v-radio>
36
+ </v-radio-group>
37
+ </div>
38
+ </template>
39
+
40
+ <script>
41
+ import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
42
+
43
+ export default {
44
+ name: 'PuiRadioGroup',
45
+ mixins: [PuiFormComponentMixin],
46
+ data: () => ({
47
+ initialValue: 1,
48
+ internalModel: 1
49
+ }),
50
+ props: {
51
+ radios: {
52
+ type: [Array],
53
+ required: true
54
+ },
55
+ value: {
56
+ type: [Number, String],
57
+ required: false
58
+ },
59
+ rules: {
60
+ type: Array,
61
+ default: () => {
62
+ return [];
63
+ }
64
+ },
65
+ labelColumnStyles: {
66
+ type: [String],
67
+ required: false
68
+ },
69
+ valueColumnStyles: {
70
+ type: [String],
71
+ required: false
72
+ }
73
+ },
74
+ methods: {
75
+ updateValue(value) {
76
+ this.$emit('input', value);
77
+ }
78
+ },
79
+ computed: {
80
+ getLabelRequiredClass() {
81
+ return { 'v-label--required': this.required };
82
+ },
83
+ getRules() {
84
+ const rules = [...this.rules];
85
+ if (this.required) {
86
+ var func = (value) => !!value || this.$t('pui9.error.field_selected');
87
+ rules.push(func);
88
+ }
89
+ return rules;
90
+ },
91
+ isRequired() {
92
+ return { 'v-input--checkbox--required': this.required };
93
+ }
94
+ },
95
+ created() {
96
+ this.initialValue = this.value;
97
+ this.internalModel = this.value;
98
+ },
99
+ watch: {
100
+ value(val) {
101
+ this.internalModel = val;
102
+ }
103
+ }
104
+ };
105
+ </script>