ketekny-ui-kit 1.0.35 → 1.0.36

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,7 +1,7 @@
1
1
  {
2
2
  "name": "ketekny-ui-kit",
3
3
  "type": "module",
4
- "version": "1.0.35",
4
+ "version": "1.0.36",
5
5
  "description": "A Vue 3 UI component library with Tailwind CSS styling",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -5,6 +5,7 @@
5
5
  'k-datatable-wrapper rounded-lg border border-primary/15',
6
6
  disabled ? 'pointer-events-none opacity-60' : '',
7
7
  ]"
8
+ :style="{ '--k-datatable-checkbox-accent': themeColor }"
8
9
  >
9
10
  <EasyDataTable
10
11
  v-bind="$attrs"
@@ -22,10 +23,11 @@
22
23
  <div class="k-datatable-select-cell">
23
24
  <input
24
25
  type="checkbox"
25
- class="easy-checkbox"
26
+ class="k-datatable-checkbox"
26
27
  :checked="allSelectableSelected"
27
28
  :indeterminate.prop="partiallySelectableSelected"
28
29
  :disabled="disabled || pageSelectableKeys.length === 0"
30
+ @mousedown="captureSelectionInteraction"
29
31
  @click.stop
30
32
  @change="handleSelectAllChange"
31
33
  />
@@ -36,10 +38,12 @@
36
38
  <div class="k-datatable-select-cell">
37
39
  <input
38
40
  type="checkbox"
39
- class="easy-checkbox"
41
+ class="k-datatable-checkbox"
40
42
  :checked="isItemSelected(slotItem)"
41
43
  :disabled="disabled || !isItemSelectable(slotItem)"
42
- @click.stop
44
+ :title="!isItemSelectable(slotItem) ? 'Row is not selectable' : ''"
45
+ @mousedown="captureSelectionInteraction"
46
+ @click.stop="captureSelectionInteraction"
43
47
  @change="($event) => handleItemSelectionChange($event, slotItem)"
44
48
  />
45
49
  </div>
@@ -101,6 +105,8 @@ export default {
101
105
  selectedKeys: [],
102
106
  selectedKeySet: new Set(),
103
107
  lastSelectionAnchorKey: null,
108
+ pendingShiftSelection: false,
109
+ isShiftKeyPressed: false,
104
110
  _pageSelectableKeys: [],
105
111
  keyedItems: [],
106
112
  currentItemsByKey: new Map(),
@@ -141,6 +147,16 @@ export default {
141
147
  this.rebuildItemCaches();
142
148
  this.applyExternalModelValue(this.modelValue);
143
149
  },
150
+ mounted() {
151
+ window.addEventListener("keydown", this.handleWindowKeydown);
152
+ window.addEventListener("keyup", this.handleWindowKeyup);
153
+ window.addEventListener("blur", this.handleWindowBlur);
154
+ },
155
+ beforeUnmount() {
156
+ window.removeEventListener("keydown", this.handleWindowKeydown);
157
+ window.removeEventListener("keyup", this.handleWindowKeyup);
158
+ window.removeEventListener("blur", this.handleWindowBlur);
159
+ },
144
160
 
145
161
  watch: {
146
162
  items: {
@@ -173,8 +189,26 @@ export default {
173
189
  },
174
190
 
175
191
  methods: {
192
+ captureSelectionInteraction(event) {
193
+ this.pendingShiftSelection = Boolean(event?.shiftKey || this.isShiftKeyPressed);
194
+ },
195
+ handleWindowKeydown(event) {
196
+ if (event?.key === "Shift") {
197
+ this.isShiftKeyPressed = true;
198
+ }
199
+ },
200
+ handleWindowKeyup(event) {
201
+ if (event?.key === "Shift") {
202
+ this.isShiftKeyPressed = false;
203
+ }
204
+ },
205
+ handleWindowBlur() {
206
+ this.isShiftKeyPressed = false;
207
+ this.pendingShiftSelection = false;
208
+ },
176
209
  handleSelectAllChange(event) {
177
210
  if (this.effectiveSelectionMode !== "multiple" || this.disabled) return;
211
+ this.pendingShiftSelection = false;
178
212
  const shouldSelect = Boolean(event?.target?.checked);
179
213
  const nextKeySet = new Set(this.selectedKeys);
180
214
 
@@ -199,6 +233,8 @@ export default {
199
233
  if (!sourceItem || !this.isItemSelectable(sourceItem)) return;
200
234
 
201
235
  const shouldSelect = Boolean(event?.target?.checked);
236
+ const shiftPressed = Boolean(this.pendingShiftSelection || event?.shiftKey || this.isShiftKeyPressed);
237
+ this.pendingShiftSelection = false;
202
238
 
203
239
  if (this.selectionMode === "single") {
204
240
  this.commitSelectionByKeys(shouldSelect ? [key] : [], {
@@ -208,7 +244,7 @@ export default {
208
244
  return;
209
245
  }
210
246
 
211
- if (event?.shiftKey && this.lastSelectionAnchorKey && key !== this.lastSelectionAnchorKey) {
247
+ if (shiftPressed && this.lastSelectionAnchorKey && key !== this.lastSelectionAnchorKey) {
212
248
  const selectableKeySet = new Set(this.selectableKeys);
213
249
  const rangeKeys = this.resolveRangeKeys(this.lastSelectionAnchorKey, key).filter((rangeKey) =>
214
250
  selectableKeySet.has(rangeKey),
@@ -569,6 +605,70 @@ export default {
569
605
  justify-content: center;
570
606
  }
571
607
 
608
+ .k-datatable-checkbox {
609
+ appearance: none;
610
+ -webkit-appearance: none;
611
+ width: 1rem;
612
+ height: 1rem;
613
+ margin: 0;
614
+ border: 1px solid #94a3b8;
615
+ border-radius: 0.2rem;
616
+ background-color: #fff;
617
+ display: grid;
618
+ place-content: center;
619
+ cursor: pointer;
620
+ transition: background-color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
621
+ }
622
+
623
+ .k-datatable-checkbox::before {
624
+ content: "";
625
+ width: 0.58rem;
626
+ height: 0.32rem;
627
+ border: 2px solid #fff;
628
+ border-top: 0;
629
+ border-right: 0;
630
+ transform: rotate(-45deg) scale(0);
631
+ transform-origin: center;
632
+ transition: transform 0.12s ease;
633
+ margin-top: -0.05rem;
634
+ }
635
+
636
+ .k-datatable-checkbox:checked {
637
+ background-color: var(--k-datatable-checkbox-accent, #2563eb);
638
+ border-color: var(--k-datatable-checkbox-accent, #2563eb);
639
+ }
640
+
641
+ .k-datatable-checkbox:checked::before {
642
+ transform: rotate(-45deg) scale(1);
643
+ }
644
+
645
+ .k-datatable-checkbox:indeterminate {
646
+ background-color: var(--k-datatable-checkbox-accent, #2563eb);
647
+ border-color: var(--k-datatable-checkbox-accent, #2563eb);
648
+ }
649
+
650
+ .k-datatable-checkbox:indeterminate::before {
651
+ width: 0.52rem;
652
+ height: 0;
653
+ border: 0;
654
+ border-top: 2px solid #fff;
655
+ transform: scale(1);
656
+ margin-top: 0;
657
+ }
658
+
659
+ .k-datatable-checkbox:disabled {
660
+ cursor: not-allowed;
661
+ background-color: #e5e7eb;
662
+ border-color: #cbd5e1;
663
+ opacity: 1;
664
+ }
665
+
666
+ .k-datatable-checkbox:disabled:checked,
667
+ .k-datatable-checkbox:disabled:indeterminate {
668
+ background-color: #9ca3af;
669
+ border-color: #9ca3af;
670
+ }
671
+
572
672
  /* Target the rows-per-page dropdown */
573
673
  .customize-table .easy-data-table__footer select {
574
674
  background-color: #fff;