classcard-ui 0.2.1466 → 0.2.1468

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": "classcard-ui",
3
- "version": "0.2.1466",
3
+ "version": "0.2.1468",
4
4
  "main": "dist/classcard-ui.umd.min.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -5,49 +5,66 @@
5
5
  ? `bg-${color}-50 border-l-4 border-${color}-400 p-4`
6
6
  : `rounded-md bg-${color}-50 p-4`
7
7
  "
8
+ :id="id || undefined"
9
+ :role="id ? 'region' : undefined"
10
+ :aria-labelledby="id ? id + '-title' : undefined"
11
+ :aria-describedby="
12
+ id && description && type !== 'withAccentBorder'
13
+ ? id + '-desc'
14
+ : undefined
15
+ "
8
16
  >
9
- <div class="flex">
10
- <div class="flex-shrink-0" v-if="icon">
17
+ <div class="flex gap-2">
18
+ <div class="flex-shrink-0" v-if="icon" aria-hidden="true">
11
19
  <c-icon
12
20
  :type="icon.type"
13
21
  :name="icon.name"
14
- :class="`h-5 w-5 text-${color}-700`"
22
+ :class="`h-5 w-5 text-${color}-500`"
15
23
  ></c-icon>
16
24
  </div>
17
- <div class="ml-3" v-if="type == 'withAccentBorder'">
18
- <p :class="`text-sm text-${color}-700`">
19
- <a
20
- href="#"
21
- :class="`font-medium underline text-${color}-700 hover:text-${color}-600`"
22
- :id="id"
25
+ <div class="flex-1">
26
+ <template v-if="type == 'withAccentBorder'">
27
+ <p
28
+ :id="id ? id + '-title' : undefined"
29
+ :class="`text-sm text-${color}-700`"
23
30
  >
24
- {{ linkLabel }}
25
- </a>
26
- {{ label }}
27
- </p>
28
- </div>
29
- <div v-else class="ml-3">
30
- <h3 :class="`text-sm font-medium text-${color}-800 word-break`">
31
- {{ label }}
32
- </h3>
33
- <div
34
- :class="`mt-2 text-sm text-${color}-700 max-w-full`"
35
- v-if="description"
36
- >
37
- <p class="whitespace-pre-line break-all">
38
- {{ description }}
39
- </p>
40
- </div>
41
- <div class="mt-4" v-if="type == 'withActions'">
42
- <div class="-mx-2 -my-1.5 flex">
43
- <button
44
- :id="id"
45
- :class="`bg-${color}-50 rounded-md px-2 py-1.5 text-sm font-medium text-${color}-800 hover:bg-${color}-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-${color}-50 focus:ring-${color}-600`"
31
+ <a
32
+ href="#"
33
+ :class="`font-medium underline text-${color}-700 hover:text-${color}-600`"
46
34
  >
47
- {{ actions.label }}
48
- </button>
35
+ {{ linkLabel }}
36
+ </a>
37
+ {{ label }}
38
+ </p>
39
+ </template>
40
+ <template v-else>
41
+ <h3
42
+ :id="id ? id + '-title' : undefined"
43
+ :class="`text-sm font-medium text-${color}-700 word-break`"
44
+ >
45
+ {{ label }}
46
+ </h3>
47
+ <div
48
+ :id="id && description ? id + '-desc' : undefined"
49
+ :class="`mt-2 text-sm text-${color}-700 max-w-full`"
50
+ v-if="description"
51
+ >
52
+ <p class="whitespace-pre-line break-all">
53
+ {{ description }}
54
+ </p>
55
+ </div>
56
+ <div class="mt-4" v-if="type == 'withActions'">
57
+ <div class="-mx-2 -my-1.5 flex">
58
+ <button
59
+ type="button"
60
+ :id="id ? id + '-action' : undefined"
61
+ :class="`bg-${color}-50 rounded-md px-2 py-1.5 text-sm font-medium text-${color}-800 hover:bg-${color}-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-${color}-50 focus:ring-${color}-600`"
62
+ >
63
+ {{ actions.label }}
64
+ </button>
65
+ </div>
49
66
  </div>
50
- </div>
67
+ </template>
51
68
  </div>
52
69
  </div>
53
70
  </div>
@@ -100,13 +100,13 @@
100
100
  <c-button
101
101
  v-if="!hideActionOne"
102
102
  id="cancel-button"
103
- type="white"
103
+ :type="actionOneType"
104
104
  :label="actionOneLabel"
105
105
  @action="$emit('action-one')"
106
106
  ></c-button>
107
107
  <c-button
108
108
  id="confirm-button"
109
- type="danger"
109
+ :type="actionTwoType"
110
110
  :label="actionTwoLabel"
111
111
  :isLoading="loadButton"
112
112
  :disabled="loadButton"
@@ -152,6 +152,14 @@ export default {
152
152
  type: String,
153
153
  default: "Confirm",
154
154
  },
155
+ actionOneType: {
156
+ type: String,
157
+ default: "white",
158
+ },
159
+ actionTwoType: {
160
+ type: String,
161
+ default: "danger",
162
+ },
155
163
  loadButton: {
156
164
  type: Boolean,
157
165
  default: false,
@@ -76,7 +76,7 @@
76
76
  <div
77
77
  v-if="activeOptionIndex === index && hasSubOptions(option)"
78
78
  :class="`absolute top-0 ${
79
- submenuDirection === 'right'
79
+ effectiveSubmenuDirection === 'right'
80
80
  ? 'left-full ml-2'
81
81
  : 'right-full mr-2'
82
82
  } max-h-48 w-56 overflow-auto rounded-md bg-white py-1 shadow-lg ring-1 ring-gray-900 ring-opacity-5`"
@@ -93,7 +93,10 @@
93
93
  selectFilter(sub.isSelected ? 0 : 1, index, subIdx)
94
94
  "
95
95
  >
96
- <c-checkbox :value="sub.isSelected" setMarginLeft="ml-0"></c-checkbox>
96
+ <c-checkbox
97
+ :value="sub.isSelected"
98
+ setMarginLeft="ml-0"
99
+ ></c-checkbox>
97
100
  <p class="text-sm text-gray-700">{{ sub.label }}</p>
98
101
  </div>
99
102
  </div>
@@ -128,10 +131,6 @@ export default {
128
131
  type: String,
129
132
  default: "right",
130
133
  },
131
- filterSelected: {
132
- type: Number,
133
- default: 0,
134
- },
135
134
  options: {
136
135
  type: Array,
137
136
  required: true,
@@ -149,16 +148,29 @@ export default {
149
148
  submenuCloseTimeout: null,
150
149
  subMenuLocked: false,
151
150
  displayTooltip: false,
151
+ internalSubmenuDirection: null,
152
152
  };
153
153
  },
154
+ computed: {
155
+ filterSelected() {
156
+ return this.options.filter((option) => option.selected).length;
157
+ },
158
+ effectiveSubmenuDirection() {
159
+ return this.internalSubmenuDirection || this.submenuDirection;
160
+ },
161
+ },
154
162
  methods: {
155
163
  showTooltip(value) {
156
164
  this.displayTooltip = value;
157
165
  },
158
166
  handleToggleDropdown() {
159
167
  this.toggleDropdown = !this.toggleDropdown;
160
- if (this.toggleDropdown) this.updateEventListeners();
161
- else document.removeEventListener("click", this.handleClickOutside);
168
+ if (this.toggleDropdown) {
169
+ this.updateEventListeners();
170
+ } else {
171
+ document.removeEventListener("click", this.handleClickOutside);
172
+ this.internalSubmenuDirection = null;
173
+ }
162
174
  },
163
175
  closeSubmenuWithDelay() {
164
176
  if (!this.subMenuLocked) {
@@ -172,7 +184,7 @@ export default {
172
184
  try {
173
185
  const rootEl = this.$refs.dropdownRoot;
174
186
  if (!rootEl) {
175
- this.submenuDirection = "right";
187
+ this.internalSubmenuDirection = null;
176
188
  return;
177
189
  }
178
190
  const rect = rootEl.getBoundingClientRect();
@@ -180,9 +192,10 @@ export default {
180
192
  window.innerWidth || document.documentElement.clientWidth;
181
193
  const rightSpace = viewportWidth - rect.right;
182
194
  const submenuWidthPx = 224 + 8;
183
- this.submenuDirection = rightSpace < submenuWidthPx ? "left" : "right";
195
+ this.internalSubmenuDirection =
196
+ rightSpace < submenuWidthPx ? "left" : "right";
184
197
  } catch (e) {
185
- this.submenuDirection = "right";
198
+ this.internalSubmenuDirection = null;
186
199
  }
187
200
  },
188
201
  handleMainOptionMouseEnter(option, index) {
@@ -220,10 +233,6 @@ export default {
220
233
  } else {
221
234
  this.options[index].selected--;
222
235
  }
223
- this.filterSelected = this.options.reduce(
224
- (acc, option) => (option.selected ? acc + 1 : acc),
225
- 0
226
- );
227
236
  this.$emit(
228
237
  "filter-changed",
229
238
  this.options[index].options[subIdx].isSelected,
@@ -239,6 +248,7 @@ export default {
239
248
  this.activeOptionIndex = null;
240
249
  this.subMenuLocked = false;
241
250
  this.toggleDropdown = false;
251
+ this.internalSubmenuDirection = null;
242
252
  document.removeEventListener("click", this.handleClickOutside);
243
253
  }
244
254
  },
@@ -11,7 +11,8 @@ export default {
11
11
  linkLabel: String,
12
12
  icon: { control: { type: "object" } },
13
13
  actions: { control: { type: "object" } },
14
- type: {control: { type: 'select', options: ['withActions', 'withAccentBorder']}}
14
+ type: {control: { type: 'select', options: ['withActions', 'withAccentBorder']}},
15
+ id: String,
15
16
  },
16
17
  };
17
18
 
@@ -34,4 +35,5 @@ Default.args = {
34
35
  actions:{
35
36
  label: 'Update'
36
37
  },
38
+ id: 'c-alert',
37
39
  };
@@ -53,6 +53,8 @@ Default.args = {
53
53
  message: "This action cannot be undone.",
54
54
  actionOneLabel: "Cancel",
55
55
  actionTwoLabel: "Confirm",
56
+ actionOneType: "white",
57
+ actionTwoType: "danger",
56
58
  loadButton: false,
57
59
  isTextAreaEnabled: false,
58
60
  };