@qikdev/vue-ui 0.0.1 → 0.0.2

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 (72) hide show
  1. package/package.json +6 -2
  2. package/src/components.js +209 -6
  3. package/src/content/browser.vue +477 -0
  4. package/src/content/item.vue +48 -0
  5. package/src/content/render/field.vue +423 -0
  6. package/src/content/render/group.vue +65 -0
  7. package/src/content/render/render-mixin.js +101 -0
  8. package/src/content/render/render.vue +86 -0
  9. package/src/filter/FilterBuilder.vue +147 -0
  10. package/src/filter/FilterCondition.vue +335 -0
  11. package/src/filter/FilterRule.vue +257 -0
  12. package/src/form/expressions/index.js +83 -0
  13. package/src/form/field.vue +624 -0
  14. package/src/form/form.vue +280 -0
  15. package/src/form/getDefaultValue.js +224 -0
  16. package/src/form/inputs/button-select.vue +208 -0
  17. package/src/form/inputs/checkbox.vue +91 -0
  18. package/src/form/inputs/content-select.vue +187 -0
  19. package/src/form/inputs/currency.vue +205 -0
  20. package/src/form/inputs/datefield.vue +132 -0
  21. package/src/form/inputs/group.vue +155 -0
  22. package/src/form/inputs/input-mixin.js +440 -0
  23. package/src/form/inputs/native-select-old.vue +43 -0
  24. package/src/form/inputs/object-field.vue +50 -0
  25. package/src/form/inputs/option.vue +19 -0
  26. package/src/form/inputs/options-manager.vue +244 -0
  27. package/src/form/inputs/phone-number-input.vue +235 -0
  28. package/src/form/inputs/search.vue +117 -0
  29. package/src/form/inputs/select.vue +211 -0
  30. package/src/form/inputs/switch.vue +87 -0
  31. package/src/form/inputs/textarea.vue +80 -0
  32. package/src/form/inputs/textfield.vue +165 -0
  33. package/src/form/inputs/timezone.vue +642 -0
  34. package/src/form/inputs/upload/filedrop.vue +72 -0
  35. package/src/form/inputs/upload/upload.vue +323 -0
  36. package/src/form/parseBoolean.js +24 -0
  37. package/src/layout/flex-body.vue +3 -2
  38. package/src/layout/flex-cell.vue +45 -0
  39. package/src/layout/flex-column.vue +1 -1
  40. package/src/layout/flex-footer.vue +3 -2
  41. package/src/layout/flex-header.vue +3 -2
  42. package/src/layout/flex-row.vue +35 -0
  43. package/src/layout/flex-spacer.vue +17 -0
  44. package/src/layout/panel-body.vue +13 -0
  45. package/src/layout/panel-footer.vue +20 -0
  46. package/src/layout/panel-header.vue +20 -0
  47. package/src/layout/panel.vue +23 -0
  48. package/src/modal/ConfirmModal.vue +50 -0
  49. package/src/modal/ContentModal.vue +99 -0
  50. package/src/modal/Modal.vue +85 -0
  51. package/src/modal/ModalMixin.js +21 -0
  52. package/src/modal/OptionsModal.vue +31 -0
  53. package/src/modal/PromptModal.vue +31 -0
  54. package/src/services/selection.js +140 -0
  55. package/src/table/Table.vue +269 -0
  56. package/src/table/TableCell.vue +64 -0
  57. package/src/table/TableRow.vue +94 -0
  58. package/src/table/cells/TableCellMixin.js +15 -0
  59. package/src/table/cells/Thumbnail.vue +38 -0
  60. package/src/ui/button.vue +254 -0
  61. package/src/ui/checkbox.vue +79 -0
  62. package/src/ui/icon.vue +57 -0
  63. package/src/ui/image.vue +158 -0
  64. package/src/ui/link.vue +62 -0
  65. package/src/ui/list-item.vue +16 -0
  66. package/src/ui/list.vue +26 -0
  67. package/src/ui/menu.vue +135 -0
  68. package/src/ui/progressbar.vue +77 -0
  69. package/src/ui/spinner.vue +26 -0
  70. package/src/ui/switch.vue +89 -0
  71. package/yarn-error.log +2923 -0
  72. package/index.js +0 -14
@@ -0,0 +1,257 @@
1
+ <template>
2
+ <div class="filter-rule">
3
+ <div class="top">
4
+ <flex-row>
5
+ <flex-cell>
6
+ <div class="summary">
7
+ Match <native-select v-model="model.operator" :field="operatorField">
8
+ {{summary}}
9
+ </native-select> of the following conditions
10
+ </div>
11
+ </flex-cell>
12
+ <flex-cell @click="$emit('remove')" shrink v-if="enableRemove">
13
+ <ux-button icon>
14
+ <ux-icon icon="fa-trash" />
15
+ </ux-button>
16
+ </flex-cell>
17
+ </flex-row>
18
+ </div>
19
+ <flex-row :key="`condition-${index}`" v-for="(filter, index) in model.filters">
20
+ <flex-cell class="operator-cell" :class="[model.operator, {last:index == model.filters.length}]" vcenter shrink v-if="index != 0">
21
+ <span class="line" />
22
+ <div class="operator">{{model.operator}}</div>
23
+ </flex-cell>
24
+ <flex-cell>
25
+ <filter-condition :enableRemove="model.filters.length > 1" :fields="fields" @remove="removeCondition(index)" v-model="model.filters[index]" />
26
+ </flex-cell>
27
+ </flex-row>
28
+ <ux-button @click="addCondition">Add Condition</ux-button>
29
+ </div>
30
+ </template>
31
+ <script>
32
+ import NativeSelect from '../form/inputs/select.vue';
33
+ import FilterCondition from './FilterCondition.vue';
34
+
35
+ import _debounce from 'lodash/debounce';
36
+
37
+ export default {
38
+ props: {
39
+ enableRemove: {
40
+ type: Boolean,
41
+ },
42
+ definition: {
43
+ type: Object,
44
+ default () {
45
+ return {}
46
+ }
47
+ },
48
+ modelValue: {
49
+ type: Object,
50
+ default () {
51
+ return {
52
+ operator: 'and',
53
+ filters: [],
54
+ }
55
+ }
56
+ },
57
+ },
58
+ methods: {
59
+ addCondition() {
60
+ this.model.filters.push({
61
+
62
+ });
63
+ },
64
+ removeCondition(index) {
65
+ console.log('remove index', index)
66
+ this.model.filters.splice(index, 1);
67
+ },
68
+ },
69
+ data() {
70
+
71
+ if (!this.modelValue.operator) {
72
+ this.modelValue.operator = 'and';
73
+ }
74
+
75
+ if (!this.modelValue.filters) {
76
+ this.modelValue.filters = [];
77
+ }
78
+
79
+
80
+ return {
81
+ model: JSON.parse(JSON.stringify(this.modelValue)),
82
+ }
83
+ },
84
+
85
+ watch: {
86
+ modelValue(m) {
87
+ if (m != this.model) {
88
+ this.model = m; //JSON.parse(JSON.stringify(m));
89
+ }
90
+ },
91
+ model: {
92
+ handler: _debounce(function(v) {
93
+ this.$emit('update:modelValue', v);
94
+ }, 200),
95
+ deep: true,
96
+ }
97
+ },
98
+ computed: {
99
+ summary() {
100
+ switch (this.model.operator) {
101
+ case 'or':
102
+ return `any`;
103
+ break;
104
+ case 'nor':
105
+ return `none`;
106
+ break;
107
+ default:
108
+ return `all`;
109
+ break;
110
+ }
111
+ },
112
+ fields() {
113
+ var allFields = [...this.definition.fields];
114
+ var definedFields = this.definition.definedFields || [];
115
+ if (definedFields.length) {
116
+ var customFields = {
117
+ title: `${this.definition.title}`,
118
+ minimum: 1,
119
+ maximum: 1,
120
+ key: 'data',
121
+ asObject: true,
122
+ type: 'group',
123
+ fields: definedFields,
124
+ }
125
+
126
+ allFields.push(customFields);
127
+ }
128
+
129
+ var mapped = this.$qik.utils.mapFields(allFields);
130
+ return mapped;
131
+ },
132
+ operatorField() {
133
+ return {
134
+ minimum: 1,
135
+ maximum: 1,
136
+ options: [{
137
+ title: 'All',
138
+ value: 'and',
139
+
140
+ },
141
+ {
142
+ title: 'Any',
143
+ value: 'or',
144
+
145
+ },
146
+ {
147
+ title: 'None',
148
+ value: 'nor',
149
+
150
+ }
151
+ ],
152
+ }
153
+ },
154
+ },
155
+
156
+
157
+ components: {
158
+ FilterCondition,
159
+ NativeSelect,
160
+ },
161
+ }
162
+ </script>
163
+ <style lang="scss">
164
+ .filter-rule {
165
+ padding: 0.5em;
166
+ background: #fff;
167
+ border: 1px solid rgba(#000, 0.1);
168
+ border-radius: 0.5em;
169
+ box-shadow: 0 0.1em 0.5em rgba(#000, 0.05);
170
+ margin-bottom: 0.5em;
171
+
172
+
173
+ .operator-cell {
174
+ position:relative;
175
+
176
+ &.and {
177
+ .line {
178
+ background: green;
179
+ }
180
+ .operator {
181
+ background: green;
182
+ color: #fff;
183
+ }
184
+ }
185
+
186
+ &.or {
187
+ .line {
188
+ background: orange;
189
+ }
190
+ .operator {
191
+ background: orange;
192
+ color: #fff;
193
+ }
194
+ }
195
+
196
+ &.nor {
197
+ .line {
198
+ background: #000;
199
+ }
200
+ .operator {
201
+ background: #000;
202
+ color: #fff;
203
+ }
204
+ }
205
+
206
+ &.last {
207
+ .line {
208
+ background: #ff0066;
209
+ }
210
+ }
211
+ }
212
+
213
+ .line {
214
+ position: absolute;
215
+ width: 0.1em;
216
+ display: block;
217
+ height: 100%;
218
+ left: 0.5em;
219
+ top: 0;
220
+ bottom: 0;
221
+ }
222
+
223
+ .operator {
224
+ border-radius: 50%;
225
+ position: relative;
226
+ width: 3em;
227
+ height: 0;
228
+ overflow: hidden;
229
+ padding: 0 0 3em;
230
+ text-align: center;
231
+ line-height: 3em;
232
+ background: #111;
233
+ color: #fff;
234
+ font-size: 0.4em;
235
+ text-transform: uppercase;
236
+ font-weight: 600;
237
+ display: block;
238
+ }
239
+
240
+ .summary {
241
+ font-size: 0.8em;
242
+ opacity: 0.5;
243
+
244
+ .native-select {
245
+ display: inline-block;
246
+ border: 1px solid transparent;
247
+ border-radius: 0.3em;
248
+ padding: 0.2em;
249
+
250
+ &:hover {
251
+ background: #fff;
252
+ border-color: $primary;
253
+ }
254
+ }
255
+ }
256
+ }
257
+ </style>
@@ -0,0 +1,83 @@
1
+ import { parse as exprParse } from "expression-eval";
2
+ import { eval as exprEval } from "expression-eval";
3
+
4
+ ////////////////////////////
5
+
6
+
7
+ const service = {}
8
+
9
+ ////////////////////////////
10
+
11
+ service.evaluateExpression = function(expression, context) {
12
+
13
+ //////////////////////////////
14
+
15
+ //Its a direct function so just run it
16
+ if (typeof expression == 'function') {
17
+ return expression(context);
18
+ }
19
+
20
+ //////////////////////////////
21
+
22
+ const contextDefaults = {
23
+ Math:Math,
24
+ String:String,
25
+ Array:Array,
26
+ Date:Date,
27
+ Boolean:Boolean,
28
+ parseInt:parseInt,
29
+ parseFloat:parseFloat,
30
+ create(Class, ...rest) {
31
+ return new Class(...rest);
32
+ },
33
+ }
34
+
35
+
36
+
37
+ context = Object.assign({}, contextDefaults, context);
38
+
39
+
40
+ //////////////////////////////
41
+
42
+ //evaluate the string input
43
+ var ast;
44
+ var result;
45
+
46
+ try {
47
+ ast = exprParse(expression);
48
+ result = exprEval(ast, context);
49
+ } catch (err) {
50
+ // console.log('error evaluating expression', err);
51
+ } finally {
52
+ return result;
53
+ }
54
+
55
+ }
56
+
57
+ ////////////////////////////
58
+
59
+ // function testExpression(expression, context) {
60
+ // service.evaluateExpression(expression, context).then(function(result) {
61
+ // console.log('Expression', expression, context, result)
62
+ // })
63
+ // }
64
+
65
+
66
+ // var testModel = {
67
+ // data: {
68
+ // firstName: 'Cade',
69
+ // lastName: 'Embery',
70
+ // age: 33,
71
+ // nested: {
72
+ // deep: 10,
73
+ // }
74
+ // }
75
+ // }
76
+
77
+ // testExpression(`data.firstName == 'Cade'`, testModel)
78
+ // testExpression(`data.nested.deep * data.age / 2.3`, testModel)
79
+
80
+
81
+ ////////////////////////////
82
+
83
+ export default service;