@qikdev/vue-ui 0.0.5 → 0.1.6

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 (84) hide show
  1. package/README.md +4 -89
  2. package/dist/favicon.ico +0 -0
  3. package/dist/index.css +1 -0
  4. package/dist/lib.es.js +17781 -0
  5. package/dist/lib.es.js.map +1 -0
  6. package/dist/lib.umd.js +9 -0
  7. package/dist/lib.umd.js.map +1 -0
  8. package/package.json +31 -24
  9. package/.gitlab-ci.yml +0 -13
  10. package/jsdoc.conf +0 -10
  11. package/src/components.js +0 -227
  12. package/src/content/browser.vue +0 -493
  13. package/src/content/item.vue +0 -48
  14. package/src/content/render/field.vue +0 -423
  15. package/src/content/render/group.vue +0 -65
  16. package/src/content/render/render-mixin.js +0 -101
  17. package/src/content/render/render.vue +0 -86
  18. package/src/filter/FilterBuilder.vue +0 -144
  19. package/src/filter/FilterCondition.vue +0 -335
  20. package/src/filter/FilterRule.vue +0 -257
  21. package/src/form/expressions/index.js +0 -83
  22. package/src/form/field.vue +0 -634
  23. package/src/form/form.vue +0 -280
  24. package/src/form/getDefaultValue.js +0 -224
  25. package/src/form/inputs/button-select.vue +0 -208
  26. package/src/form/inputs/checkbox.vue +0 -91
  27. package/src/form/inputs/content-select.vue +0 -187
  28. package/src/form/inputs/currency.vue +0 -205
  29. package/src/form/inputs/datefield.vue +0 -132
  30. package/src/form/inputs/group.vue +0 -155
  31. package/src/form/inputs/input-mixin.js +0 -440
  32. package/src/form/inputs/native-select-old.vue +0 -43
  33. package/src/form/inputs/object-field.vue +0 -50
  34. package/src/form/inputs/option.vue +0 -19
  35. package/src/form/inputs/options-manager.vue +0 -244
  36. package/src/form/inputs/phone-number-input.vue +0 -235
  37. package/src/form/inputs/search.vue +0 -117
  38. package/src/form/inputs/select.vue +0 -211
  39. package/src/form/inputs/switch.vue +0 -87
  40. package/src/form/inputs/textarea.vue +0 -80
  41. package/src/form/inputs/textfield.vue +0 -185
  42. package/src/form/inputs/timezone.vue +0 -642
  43. package/src/form/inputs/type-select.vue +0 -247
  44. package/src/form/inputs/upload/filedrop.vue +0 -72
  45. package/src/form/inputs/upload/upload.vue +0 -323
  46. package/src/form/parseBoolean.js +0 -24
  47. package/src/layout/flex-body.vue +0 -23
  48. package/src/layout/flex-cell.vue +0 -45
  49. package/src/layout/flex-column.vue +0 -31
  50. package/src/layout/flex-footer.vue +0 -14
  51. package/src/layout/flex-header.vue +0 -14
  52. package/src/layout/flex-row.vue +0 -39
  53. package/src/layout/flex-spacer.vue +0 -17
  54. package/src/layout/panel-body.vue +0 -13
  55. package/src/layout/panel-footer.vue +0 -20
  56. package/src/layout/panel-header.vue +0 -20
  57. package/src/layout/panel.vue +0 -23
  58. package/src/modal/ConfirmModal.vue +0 -50
  59. package/src/modal/ContentModal.vue +0 -98
  60. package/src/modal/Modal.vue +0 -85
  61. package/src/modal/ModalMixin.js +0 -21
  62. package/src/modal/OptionsModal.vue +0 -31
  63. package/src/modal/PromptModal.vue +0 -31
  64. package/src/services/selection.js +0 -140
  65. package/src/table/Table.vue +0 -269
  66. package/src/table/TableCell.vue +0 -64
  67. package/src/table/TableRow.vue +0 -94
  68. package/src/table/cells/TableCellMixin.js +0 -15
  69. package/src/table/cells/Thumbnail.vue +0 -38
  70. package/src/ui/button.vue +0 -255
  71. package/src/ui/checkbox.vue +0 -79
  72. package/src/ui/icon.vue +0 -57
  73. package/src/ui/image.vue +0 -158
  74. package/src/ui/link.vue +0 -62
  75. package/src/ui/list-item.vue +0 -16
  76. package/src/ui/list.vue +0 -26
  77. package/src/ui/menu.vue +0 -135
  78. package/src/ui/progressbar.vue +0 -77
  79. package/src/ui/spinner.vue +0 -26
  80. package/src/ui/switch.vue +0 -89
  81. package/src/version.js +0 -1
  82. package/test/index.spec.js +0 -42
  83. package/test/mocha.opts +0 -0
  84. package/yarn-error.log +0 -2923
@@ -1,634 +0,0 @@
1
- <template>
2
- <div class="ux-field" @focusin="focus" @focusout="blur" v-if="visible" :class="classes">
3
- <template v-if="widget == 'checkbox'">
4
- <checkbox @touched="touch" :field="actualField" v-model="fieldModel" />
5
- </template>
6
- <template v-if="widget == 'switch'">
7
- <boolean-switch @touched="touch" :field="actualField" v-model="fieldModel" />
8
- </template>
9
- <template v-if="widget == 'upload'">
10
- <upload @touched="touch" :field="actualField" v-model="fieldModel" />
11
- </template>
12
- <template v-if="widget == 'group'">
13
- <template v-if="asObject">
14
- <field-group @form:state="groupStateAltered" ref="group" @touched="touch" :field="actualField" :parentModel="parentModel" v-model="fieldModel" />
15
- </template>
16
- <template v-else>
17
- <field-group @form:state="groupStateAltered" ref="group" @touched="touch" :field="actualField" :parentModel="parentModel" v-model="sourceModel" />
18
- </template>
19
- </template>
20
- <template v-if="widget == 'select'">
21
- <native-select @touched="touch" :field="actualField" v-model="fieldModel" />
22
- </template>
23
- <template v-if="widget == 'button'">
24
- <button-select @touched="touch" :field="actualField" v-model="fieldModel" />
25
- </template>
26
- <template v-if="widget == 'textfield'">
27
- <text-field @touched="touch" :field="actualField" v-model="fieldModel" />
28
- </template>
29
- <template v-if="widget == 'currency'">
30
- <currency-field @touched="touch" :field="actualField" v-model="fieldModel" />
31
- </template>
32
- <template v-if="widget == 'datefield'">
33
- <date-field @touched="touch" :field="actualField" v-model="fieldModel" />
34
- </template>
35
- <template v-if="widget == 'content-select'">
36
- <content-select @touched="touch" :field="actualField" v-model="fieldModel" />
37
- </template>
38
-
39
- <template v-if="widget == 'type-select'">
40
- <type-select @touched="touch" :field="actualField" v-model="fieldModel" />
41
- </template>
42
- <template v-if="widget == 'richtext'">
43
- <text-area @touched="touch" :field="actualField" v-model="fieldModel" />
44
- </template>
45
- <template v-if="widget == 'textarea'">
46
- <text-area @touched="touch" :field="actualField" v-model="fieldModel" />
47
- </template>
48
- <template v-if="widget == 'timezone'">
49
- <timezone-select @touched="touch" :field="actualField" v-model="fieldModel" />
50
- </template>
51
- <template v-if="widget == 'phone'">
52
- <phone-number-input @touched="touch" :field="actualField" v-model="fieldModel" />
53
- </template>
54
- <template v-if="widget == 'value'">
55
- </template>
56
- <template v-if="widget == 'object'">
57
- <object-field @touched="touch" :field="actualField" v-model="fieldModel" />
58
- </template>
59
- <template v-if="widget == 'options'">
60
- <options-manager @touched="touch" :field="actualField" v-model="fieldModel" />
61
- </template>
62
- <div v-if="error && validateResults.message" class="ux-field-message">
63
- {{validateResults.message}}
64
- </div>
65
- <!-- <pre>Has Data: {{hasData}}</pre>
66
- <pre>Dirty: {{dirty}}</pre>
67
- <pre>Dirty Before: {{isDirtyBeforeInput}}</pre>
68
- <pre>Touched: {{touched}}</pre>
69
- <pre>DEFAULT VALUE: {{fieldDefaultValue}}</pre> -->
70
- </div>
71
- </template>
72
- <script>
73
- //Inputs
74
- import PhoneNumberInput from './inputs/phone-number-input.vue';
75
- import TimezoneSelect from './inputs/timezone.vue';
76
- import ContentSelect from './inputs/content-select.vue';
77
- import TypeSelect from './inputs/type-select.vue';
78
- import CurrencyField from './inputs/currency.vue';
79
- import TextField from './inputs/textfield.vue';
80
- import TextArea from './inputs/textarea.vue';
81
- import DateField from './inputs/datefield.vue';
82
- import Checkbox from './inputs/checkbox.vue';
83
- import Switch from './inputs/switch.vue';
84
- import Upload from './inputs/upload/upload.vue';
85
- import FieldGroup from './inputs/group.vue';
86
- import NativeSelect from './inputs/select.vue';
87
- import ButtonSelect from './inputs/button-select.vue';
88
- import ObjectField from './inputs/object-field.vue';
89
- import OptionsManager from './inputs/options-manager.vue';
90
-
91
- ////////////////
92
-
93
- import Expressions from './expressions';
94
- import getDefaultValue from './getDefaultValue';
95
- import parseBoolean from './parseBoolean';
96
-
97
- ////////////////////////////////////////
98
-
99
- function hasExpression(key) {
100
- return function() {
101
- var self = this;
102
- if (!self.expressions) {
103
- return;
104
- }
105
-
106
- let expression = self.expressions[key];
107
- if (expression) {
108
- return true;
109
- }
110
- }
111
- }
112
-
113
- ////////////////////////////////////////
114
-
115
- function computedExpression(key) {
116
- return function() {
117
- var self = this;
118
- if (!self.expressions) {
119
- return;
120
- }
121
-
122
- let expression = self.expressions[key];
123
- if (!expression) {
124
- return;
125
- }
126
-
127
- let context = self.expressionsContext;
128
- return Expressions.evaluateExpression(expression, context);
129
- }
130
- }
131
-
132
-
133
- export default {
134
- components: {
135
- ButtonSelect,
136
- NativeSelect,
137
- DateField,
138
- TextField,
139
- CurrencyField,
140
- TextArea,
141
- Checkbox,
142
- BooleanSwitch: Switch,
143
- FieldGroup,
144
- ContentSelect,
145
- TypeSelect,
146
- TimezoneSelect,
147
- PhoneNumberInput,
148
- Upload,
149
- ObjectField,
150
- OptionsManager,
151
- },
152
- props: {
153
- field: {
154
- type: Object,
155
- required: true,
156
- },
157
- parentModel: {
158
- type: Object,
159
- },
160
- modelValue: {
161
- type: Object,
162
- required: true,
163
- },
164
- },
165
- data() {
166
-
167
-
168
- return {
169
- defaultValue: null,
170
- model: this.modelValue,
171
- touched: false,
172
- focussed: false,
173
- validateResults: { valid: true },
174
- mounted: false,
175
- subFormState: {},
176
- isDirty: false,
177
- isDirtyBeforeInput: false,
178
- }
179
- },
180
-
181
- created() {
182
- this.checkDirtyState();
183
- },
184
- mounted() {
185
- this.mounted = true;
186
- },
187
- beforeUnmount() {
188
- this.mounted = false;
189
- },
190
- methods: {
191
- checkDirtyState() {
192
-
193
- //What is the value for this field right now?
194
- var existingData = this.fieldModel;
195
- var proposedDefaultValue = this.fieldDefaultValue;
196
-
197
- ///////////////////////////////////////////
198
-
199
- var existingString = JSON.stringify(this.cleanOutput(existingData));
200
- var proposedString = JSON.stringify(this.cleanOutput(proposedDefaultValue));
201
-
202
- //We already have data
203
-
204
-
205
- if (existingData && (existingString != proposedString)) {
206
- this.isDirty = true;
207
- this.isDirtyBeforeInput = true;
208
- //May as well put it in anyway so it can clean itself if need be
209
- this.fieldModel = existingData;
210
- } else {
211
- //The field is untouched
212
- this.isDirty = false;
213
- this.isDirtyBeforeInput = false;
214
-
215
- //Use the default
216
- this.fieldModel = proposedDefaultValue;
217
- }
218
-
219
- // ///////////////////////////////////////////
220
-
221
- // var defaultValue = currentValue || proposedDefaultValue
222
- // if (!currentValue) {
223
- // currentValue = defaultValue;
224
- // }
225
-
226
- // ///////////////////////////////////////////
227
-
228
- // this.fieldModel = currentValue;
229
-
230
- },
231
- groupStateAltered(details) {
232
- this.subFormState = details;
233
- },
234
- focus() {
235
- this.focussed = true;
236
- },
237
- blur() {
238
- this.focussed = false;
239
- if (this.expressions && this.expressions.value) {
240
- //Reset the value after we blur out
241
- this.fieldModel = this.getExpressionValue;
242
- }
243
- },
244
- reset() {
245
- // var defaultValue = this.expressions && this.expressions.defaultValue ? this.getExpressionDefaultValue : getDefaultValue(this.actualField);
246
- // this.fieldModel = defaultValue;
247
- this.touched = false;
248
- },
249
- touch() {
250
- this.touched = true;
251
- },
252
- cleanInput(val) {
253
- return val;
254
- },
255
- cleanOutput(val) {
256
- return val;
257
- }
258
- },
259
- watch: {
260
- mounted(val) {
261
- if (val) {
262
- this.$emit('field:mount', this);
263
- } else {
264
- this.$emit('field:unmount', this);
265
- }
266
- },
267
- visible(now) {
268
- //Remove and clear all data
269
- if (!now) {
270
- this.touched = false;
271
- if (this.expressions && this.expressions.value) {
272
- this.fieldModel = this.getExpressionValue
273
- } else {
274
- this.fieldModel = undefined;
275
- }
276
-
277
- } else {
278
- this.reset();
279
- }
280
-
281
- },
282
- focussed(val) {
283
- if (val) {
284
- this.$emit('field:focus', this);
285
- } else {
286
- this.$emit('field:blur', this);
287
- }
288
- },
289
- invalid(val) {
290
- this.$emit('field:invalid', this);
291
- },
292
- valid(val) {
293
- this.$emit('field:valid', this);
294
- },
295
- error(val) {
296
- this.$emit('field:error', this);
297
- },
298
- touched(val) {
299
- this.$emit('field:touched', this);
300
- },
301
- dirty(val) {
302
- this.$emit('field:dirty', this);
303
- },
304
- changeString(v) {
305
- this.validateResults = this.$qik.content.validateField(this.fieldModel, this.actualField);
306
- },
307
- modelValue(val, old) {
308
- this.model = val;
309
- this.touched = false;
310
- this.checkDirtyState();
311
- },
312
- getExpressionHide(result) {
313
-
314
- },
315
- getExpressionDefaultValue(result) {
316
-
317
- //If this already had data, or has been touched and now has data
318
- if (this.isDirtyBeforeInput || (this.touched && this.dirty)) {
319
- //Don't update it
320
- } else {
321
- this.fieldModel = result;
322
- }
323
-
324
- },
325
- getExpressionValue(result) {
326
- this.fieldModel = result;
327
- },
328
- },
329
- computed: {
330
- fieldDefaultValue() {
331
- return this.cleanInput(this.expressions && this.expressions.defaultValue ? this.getExpressionDefaultValue : getDefaultValue(this.actualField));
332
- },
333
- title() {
334
- return this.field.title;
335
- },
336
- actualField() {
337
-
338
- var field = this.field;
339
- if (this.getExpressionRequired) {
340
- return Object.assign({}, field, { minimum: 1 });
341
- }
342
-
343
- return field;
344
- },
345
- changeString() {
346
- return `${JSON.stringify(this.fieldModel)}-${this.actualField.minimum}`;
347
- },
348
- valid() {
349
- return !this.invalid;
350
- },
351
- error() {
352
- return !this.focussed && this.touched && this.invalid;
353
- },
354
- invalid() {
355
- //Check the subform
356
- var invalidSubForm = this.subFormState && this.subFormState.invalid;
357
- if (invalidSubForm) {
358
-
359
- return { invalidSubForm: this.subFormState, mounted: this.mounted };
360
- }
361
-
362
- //Check if our validator says this field is valid
363
- var isInvalid = !this.validateResults.valid;
364
- // if (isInvalid) {
365
-
366
- // }
367
-
368
-
369
-
370
- return isInvalid;
371
- },
372
- dirty() {
373
-
374
- return this.isDirty;
375
-
376
- },
377
- hasData() {
378
-
379
- if (typeof this.fieldModel === 'undefined') {
380
- return false;
381
- }
382
-
383
- if (this.multiValue) {
384
- if (!this.fieldModel || !this.fieldModel.length) {
385
- return false;
386
- }
387
- }
388
-
389
- if (this.fieldModel == '') {
390
- return false;
391
- }
392
-
393
- // if (this.hasExpressionDefaultValue) {
394
- // return this.touched && (this.fieldModel != this.getExpressionDefaultValue);
395
- // }
396
-
397
- return true;
398
- },
399
- getExpressionHide() {
400
- if (!this.expressions) {
401
- return;
402
- }
403
-
404
- let showExpression = this.expressions.show;
405
- let hideExpression = this.expressions.hide;
406
- let context = this.expressionsContext;
407
-
408
- if (showExpression) {
409
- return !!!Expressions.evaluateExpression(showExpression, context);
410
- } else if (hideExpression) {
411
- return Expressions.evaluateExpression(hideExpression, context);
412
- }
413
- },
414
- getExpressionRequired: computedExpression('required'),
415
- getExpressionDefaultValue: computedExpression('defaultValue'),
416
- getExpressionValue: computedExpression('value'),
417
- hasExpressionDefaultValue: hasExpression('defaultValue'),
418
- expressions() {
419
- return this.field.expressions;
420
- },
421
- expressionsContext() {
422
- return {
423
- this: this.model,
424
- model: this.model,
425
- data: this.parentModel,
426
- }
427
- },
428
- hidden() {
429
- if (this.actualField.readOnly) {
430
- return true;
431
- }
432
- return this.getExpressionHide;
433
- },
434
- visible() {
435
- return this.mounted && !this.hidden;
436
- },
437
- type() {
438
- return this.actualField.type || 'string';
439
- },
440
- key() {
441
- return this.actualField.key;
442
- },
443
- isGroup() {
444
- return this.type === 'group'
445
- },
446
- asObject() {
447
- return this.isGroup && this.actualField.asObject;
448
- },
449
- layoutGroup() {
450
- return this.isGroup && !this.actualField.asObject;
451
- },
452
- fieldModel: {
453
- get() {
454
- return this.cleanOutput(this.model[this.key]);
455
- },
456
- set(value) {
457
-
458
- var cleaned = this.cleanInput(value);
459
-
460
- if (this.model[this.key] != cleaned) {
461
- this.model[this.key] = cleaned
462
- this.isDirty = true;
463
- this.$emit('update:modelValue', this.model);
464
- }
465
- }
466
- },
467
- sourceModel: {
468
- get() {
469
- return this.model;
470
- },
471
- set(value) {
472
- this.model = value;
473
- this.$emit('update:modelValue', this.model);
474
- }
475
- },
476
- classes() {
477
- var array = [];
478
- array.push(`ux-field-${this.type}`)
479
-
480
- if (this.layoutGroup) {
481
- array.push('ux-layout-only');
482
- }
483
-
484
- if (this.touched) {
485
- array.push('ux-field-touched');
486
- }
487
-
488
- if (this.dirty) {
489
- array.push('ux-field-dirty');
490
- }
491
-
492
- if (this.valid) {
493
- array.push('ux-field-valid');
494
- }
495
-
496
- if (this.invalid) {
497
- array.push('ux-field-invalid');
498
- }
499
-
500
- if (this.error) {
501
- array.push('ux-field-error');
502
- }
503
-
504
- return array;
505
- },
506
- widget() {
507
-
508
- //We're a group
509
- if (this.type == 'group') {
510
- return this.type;
511
- }
512
-
513
- //Get the widget
514
- var widget = this.actualField.widget;
515
-
516
- ///////////////////////////////
517
-
518
-
519
- ///////////////////////////////
520
-
521
- switch (widget) {
522
- case 'content-select':
523
- case 'select':
524
- case 'checkbox':
525
- case 'datefield':
526
- case 'richtext':
527
- case 'textarea':
528
- case 'switch':
529
- case 'email':
530
- case 'url':
531
- case 'currency':
532
- case 'timezone':
533
- case 'country':
534
- case 'typeselect':
535
- case 'upload':
536
- case 'options':
537
- case 'button':
538
- case 'type-select':
539
- break;
540
- case 'password':
541
- return 'textfield';
542
- break;
543
- case 'phone':
544
- case 'phonenumber':
545
- return 'phone'
546
- break;
547
-
548
- default:
549
- switch (this.type) {
550
- case 'date':
551
- widget = 'datefield';
552
- break;
553
- case 'reference':
554
- widget = 'content-select';
555
- break;
556
- case 'boolean':
557
- widget = 'checkbox';
558
- break;
559
- default:
560
- case 'string':
561
- widget = 'textfield';
562
- break;
563
- case 'object':
564
- widget = 'object';
565
- break;
566
- }
567
- break;
568
- }
569
-
570
- return widget;
571
-
572
- },
573
- },
574
-
575
- }
576
- </script>
577
- <style lang="scss" scoped>
578
- .ux-field {
579
- margin-bottom: 1.5em;
580
-
581
- &.ux-layout-only {
582
- margin-bottom: 0;
583
- }
584
-
585
- .ux-field-message {
586
- border: red;
587
- background: rgba(red, 0.1);
588
- color: red;
589
- font-size: 0.7em;
590
- padding: 0.3em 0.5em;
591
- border-radius: 0 1em 1em;
592
- margin: 0.3em 0;
593
- display: inline-block;
594
- }
595
-
596
- // &.ux-field-error {
597
- // .ux-field-message {
598
- // visibility: visible;
599
- // }
600
- // }
601
-
602
-
603
-
604
- }
605
-
606
-
607
-
608
- :deep(.ux-field-title) {
609
- // .ux-field-title {
610
- margin-top: 0.5em;
611
- display: block;
612
- margin-bottom: 0.2em;
613
- font-size: 0.9em;
614
- font-weight: bold;
615
- }
616
-
617
-
618
- :deep(.ux-field-description) {
619
- // .ux-field-description {
620
-
621
- font-size: clamp(12px, 0.8em, 16px);
622
- opacity: 0.5;
623
- margin-bottom: 0.5em;
624
-
625
- }
626
-
627
- .ux-field.ux-field-error> :deep(.ux-field-title) {
628
- color: red;
629
- }
630
-
631
- :deep(.ux-form-flex .ux-field-description) {
632
- // min-height: 2.6em;
633
- }
634
- </style>