orio-ui 1.24.0 → 1.27.0
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/README.md +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/components/Button.d.vue.ts +3 -2
- package/dist/runtime/components/Button.vue +19 -11
- package/dist/runtime/components/Button.vue.d.ts +3 -2
- package/dist/runtime/components/Calendar.USAGE.md +51 -0
- package/dist/runtime/components/Calendar.vue +254 -87
- package/dist/runtime/components/Canvas/USAGE.md +65 -0
- package/dist/runtime/components/CheckBox.vue +9 -3
- package/dist/runtime/components/CheckboxGroup.vue +7 -1
- package/dist/runtime/components/ControlElement.USAGE.md +69 -0
- package/dist/runtime/components/ControlElement.d.vue.ts +42 -27
- package/dist/runtime/components/ControlElement.vue +28 -9
- package/dist/runtime/components/ControlElement.vue.d.ts +42 -27
- package/dist/runtime/components/Input.USAGE.md +49 -0
- package/dist/runtime/components/Input.vue +13 -3
- package/dist/runtime/components/Modal.USAGE.md +64 -0
- package/dist/runtime/components/NavButton.d.vue.ts +0 -1
- package/dist/runtime/components/NavButton.vue +9 -5
- package/dist/runtime/components/NavButton.vue.d.ts +0 -1
- package/dist/runtime/components/NumberInput/Horizontal.vue +7 -2
- package/dist/runtime/components/NumberInput/Vertical.vue +7 -2
- package/dist/runtime/components/NumberInput/index.d.vue.ts +0 -2
- package/dist/runtime/components/NumberInput/index.vue +9 -7
- package/dist/runtime/components/NumberInput/index.vue.d.ts +0 -2
- package/dist/runtime/components/RadioButton.d.vue.ts +0 -2
- package/dist/runtime/components/RadioButton.vue +9 -4
- package/dist/runtime/components/RadioButton.vue.d.ts +0 -2
- package/dist/runtime/components/Selector.d.vue.ts +1 -0
- package/dist/runtime/components/Selector.vue +10 -4
- package/dist/runtime/components/Selector.vue.d.ts +1 -0
- package/dist/runtime/components/SwitchButton.d.vue.ts +1 -4
- package/dist/runtime/components/SwitchButton.vue +10 -7
- package/dist/runtime/components/SwitchButton.vue.d.ts +1 -4
- package/dist/runtime/components/TaggableSelector.vue +7 -1
- package/dist/runtime/components/Textarea.vue +13 -3
- package/dist/runtime/components/date/Picker.USAGE.md +44 -0
- package/dist/runtime/components/date/Picker.vue +7 -1
- package/dist/runtime/components/date/PickerTrigger.vue +9 -3
- package/dist/runtime/components/date/RangePicker.vue +7 -1
- package/dist/runtime/composables/useFilter.d.ts +91 -0
- package/dist/runtime/composables/useFilter.js +111 -0
- package/dist/runtime/composables/useRovingGrid.d.ts +35 -0
- package/dist/runtime/composables/useRovingGrid.js +115 -0
- package/dist/runtime/i18n/en.json +4 -1
- package/dist/runtime/i18n/uk.json +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { computed, nextTick, ref } from "vue";
|
|
2
|
+
const ARROW_OFFSETS = {
|
|
3
|
+
up: { rowDelta: -1, columnDelta: 0 },
|
|
4
|
+
down: { rowDelta: 1, columnDelta: 0 },
|
|
5
|
+
left: { rowDelta: 0, columnDelta: -1 },
|
|
6
|
+
right: { rowDelta: 0, columnDelta: 1 }
|
|
7
|
+
};
|
|
8
|
+
const ARROW_KEYS = {
|
|
9
|
+
ArrowUp: "up",
|
|
10
|
+
ArrowDown: "down",
|
|
11
|
+
ArrowLeft: "left",
|
|
12
|
+
ArrowRight: "right"
|
|
13
|
+
};
|
|
14
|
+
export function useRovingGrid(options) {
|
|
15
|
+
const focusedKey = ref(null);
|
|
16
|
+
function findCell(key) {
|
|
17
|
+
for (const [rowIndex, cellsInRow] of options.rows.value.entries()) {
|
|
18
|
+
const columnIndex = cellsInRow.findIndex(
|
|
19
|
+
(cell) => options.getKey(cell) === key
|
|
20
|
+
);
|
|
21
|
+
if (columnIndex !== -1) {
|
|
22
|
+
return { rowIndex, columnIndex, cell: cellsInRow[columnIndex] };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const activeKey = computed(() => {
|
|
28
|
+
if (focusedKey.value && findCell(focusedKey.value)) return focusedKey.value;
|
|
29
|
+
return options.initial();
|
|
30
|
+
});
|
|
31
|
+
function focusActive() {
|
|
32
|
+
nextTick(() => {
|
|
33
|
+
const selector = `[focus-key="${CSS.escape(activeKey.value)}"]`;
|
|
34
|
+
const element = options.gridRef.value?.querySelector(selector);
|
|
35
|
+
if (!element) return;
|
|
36
|
+
element.scrollIntoView({
|
|
37
|
+
block: "nearest",
|
|
38
|
+
inline: "nearest",
|
|
39
|
+
behavior: "smooth"
|
|
40
|
+
});
|
|
41
|
+
element.focus({ preventScroll: true });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function setActive(key, shouldFocus = true) {
|
|
45
|
+
focusedKey.value = key;
|
|
46
|
+
if (shouldFocus) focusActive();
|
|
47
|
+
}
|
|
48
|
+
function tryArrow(direction) {
|
|
49
|
+
const position = findCell(activeKey.value);
|
|
50
|
+
if (!position) return;
|
|
51
|
+
const offset = ARROW_OFFSETS[direction];
|
|
52
|
+
const rows = options.rows.value;
|
|
53
|
+
let targetRowIndex = position.rowIndex + offset.rowDelta;
|
|
54
|
+
let targetColumnIndex = position.columnIndex + offset.columnDelta;
|
|
55
|
+
while (rows[targetRowIndex]?.[targetColumnIndex] !== void 0) {
|
|
56
|
+
const candidate = rows[targetRowIndex][targetColumnIndex];
|
|
57
|
+
if (!options.isNavigable || options.isNavigable(candidate)) {
|
|
58
|
+
setActive(options.getKey(candidate));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
targetRowIndex += offset.rowDelta;
|
|
62
|
+
targetColumnIndex += offset.columnDelta;
|
|
63
|
+
}
|
|
64
|
+
const overflowKey = options.onArrowOverflow?.(direction, activeKey.value);
|
|
65
|
+
if (overflowKey) setActive(overflowKey);
|
|
66
|
+
}
|
|
67
|
+
function moveToRowEdge(toEnd) {
|
|
68
|
+
const position = findCell(activeKey.value);
|
|
69
|
+
if (!position) return;
|
|
70
|
+
const row = options.rows.value[position.rowIndex];
|
|
71
|
+
const ordered = toEnd ? [...row].reverse() : row;
|
|
72
|
+
const edgeCell = ordered.find(
|
|
73
|
+
(cell) => !options.isNavigable || options.isNavigable(cell)
|
|
74
|
+
);
|
|
75
|
+
if (!edgeCell) return;
|
|
76
|
+
setActive(options.getKey(edgeCell));
|
|
77
|
+
}
|
|
78
|
+
function tryPage(direction, bigJump) {
|
|
79
|
+
const newKey = options.onPage?.(direction, bigJump, activeKey.value);
|
|
80
|
+
if (newKey) setActive(newKey);
|
|
81
|
+
}
|
|
82
|
+
function activate() {
|
|
83
|
+
const position = findCell(activeKey.value);
|
|
84
|
+
if (position) options.onActivate?.(position.cell);
|
|
85
|
+
}
|
|
86
|
+
function onKeydown(event) {
|
|
87
|
+
const arrow = ARROW_KEYS[event.key];
|
|
88
|
+
if (arrow) {
|
|
89
|
+
tryArrow(arrow);
|
|
90
|
+
} else if (event.key === "Home") {
|
|
91
|
+
moveToRowEdge(false);
|
|
92
|
+
} else if (event.key === "End") {
|
|
93
|
+
moveToRowEdge(true);
|
|
94
|
+
} else if (event.key === "PageUp") {
|
|
95
|
+
tryPage("up", event.shiftKey);
|
|
96
|
+
} else if (event.key === "PageDown") {
|
|
97
|
+
tryPage("down", event.shiftKey);
|
|
98
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
99
|
+
activate();
|
|
100
|
+
} else {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
}
|
|
105
|
+
function tabindexFor(key) {
|
|
106
|
+
return key === activeKey.value ? 0 : -1;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
activeKey,
|
|
110
|
+
setActive,
|
|
111
|
+
focusActive,
|
|
112
|
+
onKeydown,
|
|
113
|
+
tabindexFor
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
},
|
|
7
7
|
"calendar": {
|
|
8
8
|
"previousMonth": "Previous month",
|
|
9
|
-
"nextMonth": "Next month"
|
|
9
|
+
"nextMonth": "Next month",
|
|
10
|
+
"previousYear": "Previous year",
|
|
11
|
+
"nextYear": "Next year",
|
|
12
|
+
"navigation": "Calendar navigation"
|
|
10
13
|
},
|
|
11
14
|
"datePicker": {
|
|
12
15
|
"placeholder": "Select a date"
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
},
|
|
7
7
|
"calendar": {
|
|
8
8
|
"previousMonth": "Попередній місяць",
|
|
9
|
-
"nextMonth": "Наступний місяць"
|
|
9
|
+
"nextMonth": "Наступний місяць",
|
|
10
|
+
"previousYear": "Попередній рік",
|
|
11
|
+
"nextYear": "Наступний рік",
|
|
12
|
+
"navigation": "Навігація календаря"
|
|
10
13
|
},
|
|
11
14
|
"datePicker": {
|
|
12
15
|
"placeholder": "Оберіть дату"
|