quasar-ui-danx 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  ref="actionTable"
9
9
  :selected="selectedRows"
10
10
  :pagination="pagination"
11
- :columns="columns"
11
+ :columns="tableColumns"
12
12
  :loading="loadingList"
13
13
  :rows="pagedItems?.data || []"
14
14
  :binary-state-sort="false"
@@ -18,7 +18,7 @@
18
18
  :color="color"
19
19
  @update:selected="$emit('update:selected-rows', $event)"
20
20
  @update:pagination="() => {}"
21
- @request="(e) => $emit('update:pagination', {...e.pagination, __sort: mapSortBy(e.pagination, columns)})"
21
+ @request="(e) => $emit('update:pagination', {...e.pagination, __sort: mapSortBy(e.pagination, tableColumns)})"
22
22
  >
23
23
  <template #no-data>
24
24
  <slot name="empty">
@@ -33,7 +33,7 @@
33
33
  :selected-count="selectedRows.length"
34
34
  :loading="loadingSummary"
35
35
  :summary="summary"
36
- :columns="columns"
36
+ :columns="tableColumns"
37
37
  @clear="$emit('update:selected-rows', [])"
38
38
  />
39
39
  </template>
@@ -116,6 +116,7 @@ const props = defineProps({
116
116
  const actionTable = ref(null);
117
117
  registerStickyScrolling(actionTable);
118
118
 
119
+ const tableColumns = computed(() => props.columns.map((column) => ({ ...column, field: column.field || column.name })));
119
120
  const hasData = computed(() => props.pagedItems?.data?.length);
120
121
  const COLUMN_SETTINGS_KEY = `column-settings-${props.name}`;
121
122
  const columnSettings = ref(getItem(COLUMN_SETTINGS_KEY) || {});
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <CollapsableSidebar
3
+ class="dx-collapsable-filters-sidebar"
3
4
  :collapse="!showFilters"
4
5
  disabled
5
6
  :min-width="minWidth"
@@ -22,17 +23,17 @@ import { CollapsableSidebar } from "../../Utility";
22
23
  defineEmits(["update:active-filter", "update:show-filters"]);
23
24
 
24
25
  export interface Props {
25
- name: string,
26
- showFilters?: boolean,
27
- activeFilter: ListControlsFilter,
28
- minWidth?: string,
29
- maxWidth?: string,
30
- filters?: FilterField[]
26
+ name: string,
27
+ showFilters?: boolean,
28
+ activeFilter: ListControlsFilter,
29
+ minWidth?: string,
30
+ maxWidth?: string,
31
+ filters?: FilterField[]
31
32
  }
32
33
 
33
34
  withDefaults(defineProps<Props>(), {
34
- minWidth: "5rem",
35
- maxWidth: "18rem",
36
- filters: () => []
35
+ minWidth: "5rem",
36
+ maxWidth: "18rem",
37
+ filters: () => []
37
38
  });
38
39
  </script>
@@ -12,8 +12,8 @@
12
12
  ref="fileUpload"
13
13
  data-testid="file-upload"
14
14
  type="file"
15
- :accept="geolocation ? 'image/*;capture=camera' : undefined"
16
- :capture="geolocation ? 'environment' : undefined"
15
+ :accept="(geolocation && cameraOnly) ? 'image/*;capture=camera' : undefined"
16
+ :capture="(geolocation && cameraOnly) ? 'environment' : undefined"
17
17
  class="hidden"
18
18
  multiple
19
19
  @change="onAttachFiles"
@@ -28,28 +28,29 @@ import { FileUpload } from "../../../../helpers";
28
28
 
29
29
  defineExpose({ upload });
30
30
  const emit = defineEmits([
31
- "uploading",
32
- "file-progress",
33
- "file-complete",
34
- "complete"
31
+ "uploading",
32
+ "file-progress",
33
+ "file-complete",
34
+ "complete"
35
35
  ]);
36
36
  const props = defineProps({
37
- ...QBtn.props,
38
- text: {
39
- type: String,
40
- default: "Add File"
41
- },
42
- locationWaitMessage: {
43
- type: String,
44
- default: "Waiting for location..."
45
- },
46
- geolocation: Boolean
37
+ ...QBtn.props,
38
+ text: {
39
+ type: String,
40
+ default: "Add File"
41
+ },
42
+ locationWaitMessage: {
43
+ type: String,
44
+ default: "Waiting for location..."
45
+ },
46
+ cameraOnly: Boolean,
47
+ geolocation: Boolean
47
48
  });
48
49
 
49
50
  const fileUpload = ref(null);
50
51
 
51
52
  function upload() {
52
- fileUpload.value.click();
53
+ fileUpload.value.click();
53
54
  }
54
55
 
55
56
  /**
@@ -59,23 +60,23 @@ function upload() {
59
60
  * @returns {Promise<void>}
60
61
  */
61
62
  async function onAttachFiles({ target: { files } }) {
62
- emit("uploading", files);
63
- let fileUpload = new FileUpload(files)
64
- .onProgress(({ file, progress }) => {
65
- file.progress = progress;
66
- emit("file-progress", file);
67
- })
68
- .onComplete(({ file, uploadedFile }) => {
69
- emit("file-complete", { file, uploadedFile });
70
- })
71
- .onAllComplete(() => {
72
- emit("complete", fileUpload.files);
73
- });
63
+ emit("uploading", files);
64
+ let fileUpload = new FileUpload(files)
65
+ .onProgress(({ file, progress }) => {
66
+ file.progress = progress;
67
+ emit("file-progress", file);
68
+ })
69
+ .onComplete(({ file, uploadedFile }) => {
70
+ emit("file-complete", { file, uploadedFile });
71
+ })
72
+ .onAllComplete(() => {
73
+ emit("complete", fileUpload.files);
74
+ });
74
75
 
75
- if (props.geolocation) {
76
- await fileUpload.resolveLocation(props.locationWaitMessage);
77
- }
76
+ if (props.geolocation) {
77
+ await fileUpload.resolveLocation(props.locationWaitMessage);
78
+ }
78
79
 
79
- fileUpload.upload();
80
+ fileUpload.upload();
80
81
  }
81
82
  </script>
@@ -1,13 +1,14 @@
1
1
  <template>
2
2
  <QInput
3
+ class="dx-number-field max-w-full"
4
+ :class="{'dx-no-prepend-label': hidePrependLabel, 'dx-prepend-label': !hidePrependLabel}"
3
5
  :model-value="numberVal"
4
6
  :data-testid="'number-field-' + fieldOptions.id"
5
7
  :placeholder="fieldOptions.placeholder"
6
8
  outlined
7
9
  dense
8
10
  inputmode="numeric"
9
- :input-class="{[inputClass]: true, 'text-right bg-white': !hidePrependLabel, 'text-right !text-xs text-black font-normal': hidePrependLabel}"
10
- :class="{'no-prepend-icon w-32 max-w-full': hidePrependLabel, 'prepend-label': !hidePrependLabel}"
11
+ :input-class="inputClass"
11
12
  @update:model-value="onInput"
12
13
  >
13
14
  <template #prepend>
@@ -27,33 +28,33 @@ import FieldLabel from "./FieldLabel";
27
28
 
28
29
  const emit = defineEmits(["update:model-value", "update"]);
29
30
  const props = defineProps({
30
- modelValue: {
31
- type: [String, Number],
32
- default: ""
33
- },
34
- precision: {
35
- type: Number,
36
- default: 2
37
- },
38
- label: {
39
- type: String,
40
- default: undefined
41
- },
42
- field: {
43
- type: Object,
44
- default: null
45
- },
46
- inputClass: {
47
- type: String,
48
- default: ""
49
- },
50
- delay: {
51
- type: Number,
52
- default: 1000
53
- },
54
- hidePrependLabel: Boolean,
55
- currency: Boolean,
56
- showName: Boolean
31
+ modelValue: {
32
+ type: [String, Number],
33
+ default: ""
34
+ },
35
+ precision: {
36
+ type: Number,
37
+ default: 2
38
+ },
39
+ label: {
40
+ type: String,
41
+ default: undefined
42
+ },
43
+ field: {
44
+ type: Object,
45
+ default: null
46
+ },
47
+ inputClass: {
48
+ type: [String, Object],
49
+ default: ""
50
+ },
51
+ delay: {
52
+ type: Number,
53
+ default: 1000
54
+ },
55
+ hidePrependLabel: Boolean,
56
+ currency: Boolean,
57
+ showName: Boolean
57
58
  });
58
59
 
59
60
  const numberVal = ref(format(props.modelValue));
@@ -62,46 +63,46 @@ watch(() => props.modelValue, () => numberVal.value = format(props.modelValue));
62
63
  const fieldOptions = computed(() => props.field || { label: props.label || "", placeholder: "", id: "" });
63
64
 
64
65
  function format(number) {
65
- if (!number && number !== 0 && number !== "0") return number;
66
+ if (!number && number !== 0 && number !== "0") return number;
66
67
 
67
- const minimumFractionDigits = Math.min(props.precision, ("" + number).split(".")[1]?.length || 0);
68
- let options = {
69
- minimumFractionDigits
70
- };
68
+ const minimumFractionDigits = Math.min(props.precision, ("" + number).split(".")[1]?.length || 0);
69
+ let options = {
70
+ minimumFractionDigits
71
+ };
71
72
 
72
- if (props.currency) {
73
- options = {
74
- style: "currency",
75
- currency: "USD",
76
- minimumFractionDigits
77
- };
78
- }
79
- return fNumber(number, options);
73
+ if (props.currency) {
74
+ options = {
75
+ style: "currency",
76
+ currency: "USD",
77
+ minimumFractionDigits
78
+ };
79
+ }
80
+ return fNumber(number, options);
80
81
  }
81
82
 
82
83
  const onUpdateDebounced = useDebounceFn((val) => emit("update", val), props.delay);
83
84
 
84
85
  function onInput(value) {
85
- let number = "";
86
+ let number = "";
86
87
 
87
- // Prevent invalid characters
88
- if (value.match(/[^\d.,$]/)) {
89
- const oldVal = numberVal.value;
90
- // XXX: To get QInput to show only the value we want
91
- numberVal.value += " ";
92
- return nextTick(() => numberVal.value = oldVal);
93
- }
88
+ // Prevent invalid characters
89
+ if (value.match(/[^\d.,$]/)) {
90
+ const oldVal = numberVal.value;
91
+ // XXX: To get QInput to show only the value we want
92
+ numberVal.value += " ";
93
+ return nextTick(() => numberVal.value = oldVal);
94
+ }
94
95
 
95
- if (value !== "") {
96
- value = value.replace(/[^\d.]/g, "");
97
- number = Number(value);
98
- numberVal.value = format(number);
99
- }
96
+ if (value !== "") {
97
+ value = value.replace(/[^\d.]/g, "");
98
+ number = Number(value);
99
+ numberVal.value = format(number);
100
+ }
100
101
 
101
- number = number === "" ? undefined : number;
102
- emit("update:model-value", number);
102
+ number = number === "" ? undefined : number;
103
+ emit("update:model-value", number);
103
104
 
104
- // Delay the change event, so we only see the value after the user has finished
105
- onUpdateDebounced(number);
105
+ // Delay the change event, so we only see the value after the user has finished
106
+ onUpdateDebounced(number);
106
107
  }
107
108
  </script>