quasar-ui-danx 0.4.45 → 0.4.47

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.4.45",
3
+ "version": "0.4.47",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -15,50 +15,49 @@
15
15
  :show-icon="selectIcon || DefaultSelectIcon"
16
16
  class="mr-2"
17
17
  >
18
- <template #label>
19
- <QMenu
20
- :model-value="isSelecting"
21
- @before-hide="isSelecting = false"
22
- @hide="isSelecting = false"
23
- >
24
- <div>
25
- <div
26
- v-for="option in options"
27
- :key="option.id"
28
- v-ripple
29
- class="cursor-pointer flex items-center relative"
30
- :class="{'bg-sky-900 hover:bg-sky-800': selected?.id === option.id, 'hover:bg-slate-600': selected?.id !== option.id}"
31
- @click="selected = option"
32
- >
33
- <div class="flex-grow px-4 py-2">
34
- {{ option.name }}
35
- </div>
36
- <ActionButton
37
- v-if="deletable"
38
- type="trash"
39
- class="ml-4 mr-2"
40
- @click.stop.prevent="$emit('delete', option)"
41
- />
18
+ <QMenu
19
+ :model-value="isSelecting"
20
+ @before-hide="isSelecting = false"
21
+ @hide="isSelecting = false"
22
+ >
23
+ <div>
24
+ <div
25
+ v-for="option in options"
26
+ :key="option.id"
27
+ v-ripple
28
+ class="cursor-pointer flex items-center relative"
29
+ :class="{'bg-sky-900 hover:bg-sky-800': selected?.id === option.id, 'hover:bg-slate-600': selected?.id !== option.id}"
30
+ @click="selected = option"
31
+ >
32
+ <div class="flex-grow px-4 py-2">
33
+ {{ option.name }}
42
34
  </div>
43
- <template v-if="creatable">
44
- <QSeparator class="bg-slate-400 my-2" />
45
- <div class="px-4 mb-2">
46
- <QBtn
47
- :class="createClass"
48
- :loading="loading"
49
- @click="$emit('create')"
50
- >
51
- <CreateIcon
52
- class="w-3"
53
- :class="createText ? 'mr-2' : ''"
54
- />
55
- {{ createText }}
56
- </QBtn>
57
- </div>
58
- </template>
35
+ <ActionButton
36
+ v-if="deletable"
37
+ type="trash"
38
+ class="ml-4 mr-2"
39
+ size="sm"
40
+ @click.stop.prevent="$emit('delete', option)"
41
+ />
59
42
  </div>
60
- </QMenu>
61
- </template>
43
+ <template v-if="creatable">
44
+ <QSeparator class="bg-slate-400 my-2" />
45
+ <div class="px-4 mb-2">
46
+ <QBtn
47
+ :class="createClass"
48
+ :loading="loading"
49
+ @click="$emit('create')"
50
+ >
51
+ <CreateIcon
52
+ class="w-3"
53
+ :class="createText ? 'mr-2' : ''"
54
+ />
55
+ {{ createText }}
56
+ </QBtn>
57
+ </div>
58
+ </template>
59
+ </div>
60
+ </QMenu>
62
61
  </ShowHideButton>
63
62
 
64
63
  <div :class="labelClass">
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <QBtn
3
3
  :loading="isSaving"
4
- class="shadow-none"
5
- :class="disabled ? disabledClass : colorClass"
4
+ class="shadow-none py-0"
5
+ :class="buttonClass"
6
6
  :disable="disabled"
7
7
  @click="()=> onAction()"
8
8
  >
@@ -16,6 +16,7 @@
16
16
  <div
17
17
  v-if="label"
18
18
  class="ml-2"
19
+ :class="labelClass"
19
20
  >
20
21
  {{ label }}
21
22
  </div>
@@ -25,7 +26,9 @@
25
26
  v-if="tooltip"
26
27
  class="whitespace-nowrap"
27
28
  >
28
- {{ tooltip }}
29
+ <slot name="tooltip">
30
+ {{ tooltip }}
31
+ </slot>
29
32
  </QTooltip>
30
33
  <QMenu
31
34
  v-if="isConfirming"
@@ -70,9 +73,11 @@ import { ActionTarget, ResourceAction } from "../../../types";
70
73
  export interface ActionButtonProps {
71
74
  type?: "trash" | "trash-red" | "create" | "edit" | "copy" | "play" | "stop" | "pause" | "refresh" | "confirm" | "cancel";
72
75
  color?: "red" | "blue" | "sky" | "green" | "green-invert" | "lime" | "white" | "gray";
76
+ size?: "xxs" | "xs" | "sm" | "md" | "lg";
73
77
  icon?: object | string;
74
78
  iconClass?: string;
75
- label?: string;
79
+ label?: string | number;
80
+ labelClass?: string;
76
81
  tooltip?: string;
77
82
  saving?: boolean;
78
83
  action?: ResourceAction;
@@ -90,7 +95,9 @@ const props = withDefaults(defineProps<ActionButtonProps>(), {
90
95
  color: null,
91
96
  icon: null,
92
97
  iconClass: "",
98
+ size: "md",
93
99
  label: "",
100
+ labelClass: "",
94
101
  tooltip: "",
95
102
  action: null,
96
103
  target: null,
@@ -99,6 +106,36 @@ const props = withDefaults(defineProps<ActionButtonProps>(), {
99
106
  disabledClass: "text-slate-800 bg-slate-500 opacity-50"
100
107
  });
101
108
 
109
+ const mappedSizeClass = {
110
+ xxs: {
111
+ icon: "w-2",
112
+ button: "px-.5 h-5"
113
+ },
114
+ xs: {
115
+ icon: "w-3",
116
+ button: "px-1.5 h-6"
117
+ },
118
+ sm: {
119
+ icon: "w-4",
120
+ button: "px-2 h-8"
121
+ },
122
+ md: {
123
+ icon: "w-5",
124
+ button: "px-2.5 h-10"
125
+ },
126
+ lg: {
127
+ icon: "w-6",
128
+ button: "px-3 h-12"
129
+ }
130
+ };
131
+
132
+ const buttonClass = computed(() => {
133
+ return {
134
+ [props.disabled ? props.disabledClass : colorClass.value]: true,
135
+ [mappedSizeClass[props.size].button]: true
136
+ };
137
+ });
138
+
102
139
  const colorClass = computed(() => {
103
140
  switch (props.color) {
104
141
  case "red":
@@ -122,61 +159,62 @@ const colorClass = computed(() => {
122
159
  }
123
160
  });
124
161
  const typeOptions = computed(() => {
162
+ const iconClass = mappedSizeClass[props.size].icon;
125
163
  switch (props.type) {
126
164
  case "trash":
127
165
  return {
128
166
  icon: TrashIcon,
129
- iconClass: "w-3"
167
+ iconClass
130
168
  };
131
169
  case "create":
132
170
  return {
133
171
  icon: CreateIcon,
134
- iconClass: "w-3"
172
+ iconClass
135
173
  };
136
174
  case "confirm":
137
175
  return {
138
176
  icon: ConfirmIcon,
139
- iconClass: "w-3"
177
+ iconClass
140
178
  };
141
179
  case "cancel":
142
180
  return {
143
181
  icon: CancelIcon,
144
- iconClass: "w-3"
182
+ iconClass
145
183
  };
146
184
  case "edit":
147
185
  return {
148
186
  icon: EditIcon,
149
- iconClass: "w-3"
187
+ iconClass
150
188
  };
151
189
  case "copy":
152
190
  return {
153
191
  icon: CopyIcon,
154
- iconClass: "w-3"
192
+ iconClass
155
193
  };
156
194
  case "play":
157
195
  return {
158
196
  icon: PlayIcon,
159
- iconClass: "w-3"
197
+ iconClass
160
198
  };
161
199
  case "stop":
162
200
  return {
163
201
  icon: StopIcon,
164
- iconClass: "w-3"
202
+ iconClass
165
203
  };
166
204
  case "pause":
167
205
  return {
168
206
  icon: PauseIcon,
169
- iconClass: "w-3"
207
+ iconClass
170
208
  };
171
209
  case "refresh":
172
210
  return {
173
211
  icon: RefreshIcon,
174
- iconClass: "w-4"
212
+ iconClass
175
213
  };
176
214
  default:
177
215
  return {
178
216
  icon: EditIcon,
179
- iconClass: "w-3"
217
+ iconClass
180
218
  };
181
219
  }
182
220
  });
@@ -1,37 +1,21 @@
1
1
  <template>
2
- <QBtn
3
- class="py-1 px-2"
4
- :disable="disable"
2
+ <ActionButton
3
+ :icon="isShowing ? (hideIcon || DefaultHideIcon) : (showIcon || DefaultShowIcon)"
4
+ :label="(isShowing ? hideLabel : showLabel) || label"
5
+ :label-class="labelClass"
5
6
  @click="onToggle"
6
7
  >
7
- <div class="flex items-center flex-nowrap whitespace-nowrap">
8
- <slot :is-showing="isShowing">
9
- <component
10
- :is="isShowing ? (hideIcon || DefaultHideIcon) : (showIcon || DefaultShowIcon)"
11
- :class="iconClass"
12
- />
13
- </slot>
14
- <slot
15
- name="label"
16
- :is-showing="isShowing"
17
- >
18
- <div
19
- v-if="label"
20
- :class="labelClass"
21
- >
22
- {{ (isShowing ? hideLabel : showLabel) || label }}
23
- </div>
24
- </slot>
25
- </div>
26
- <QTooltip v-if="tooltip">
27
- {{ tooltip }}
28
- </QTooltip>
29
- </QBtn>
8
+ <slot />
9
+ <template #tooltip>
10
+ <slot name="tooltip" />
11
+ </template>
12
+ </ActionButton>
30
13
  </template>
31
14
  <script lang="ts" setup>
32
15
  import { FaSolidEye as DefaultShowIcon, FaSolidEyeSlash as DefaultHideIcon } from "danx-icon";
33
16
  import { nextTick } from "vue";
34
17
  import { getItem, setItem } from "../../../helpers";
18
+ import ActionButton from "./ActionButton";
35
19
 
36
20
  export interface Props {
37
21
  name?: string;
@@ -39,14 +23,11 @@ export interface Props {
39
23
  hideLabel?: string;
40
24
  showIcon?: object | string;
41
25
  hideIcon?: object | string;
42
- iconClass?: string;
43
26
  labelClass?: string;
44
27
  label?: string | number;
45
- tooltip?: string;
46
- disable?: boolean;
47
28
  }
48
29
 
49
- const emit = defineEmits(["show", "hide"]);
30
+ const emit = defineEmits<{ show: void, hide: void }>();
50
31
  const isShowing = defineModel<boolean>();
51
32
  const props = withDefaults(defineProps<Props>(), {
52
33
  name: "",
@@ -54,10 +35,8 @@ const props = withDefaults(defineProps<Props>(), {
54
35
  hideLabel: "",
55
36
  showIcon: null,
56
37
  hideIcon: null,
57
- iconClass: "w-4 h-6",
58
38
  labelClass: "ml-2",
59
- label: "",
60
- tooltip: ""
39
+ label: ""
61
40
  });
62
41
 
63
42
  const SETTINGS_KEY = "show-hide-button";
@@ -72,7 +51,6 @@ if (props.name) {
72
51
  function onToggle() {
73
52
  isShowing.value = !isShowing.value;
74
53
 
75
-
76
54
  // NOTE: use nextTick to ensure the value is updated before saving (if the parent does not pass a value for modelValue, this can cause a desync)
77
55
  nextTick(() => {
78
56
  if (isShowing.value) {
@@ -21,6 +21,7 @@ const colorClasses = {
21
21
  yellow: "bg-yellow-950 text-yellow-400",
22
22
  blue: "bg-blue-950 text-blue-400",
23
23
  slate: "bg-slate-950 text-slate-400",
24
+ "slate-mid": "bg-slate-800 text-slate-400",
24
25
  gray: "bg-slate-700 text-gray-300",
25
26
  none: ""
26
27
  };