akar 1.19.0 → 1.20.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/dist/autocomplete/autocomplete-input.js +122 -0
- package/dist/autocomplete/autocomplete-input.js.map +1 -0
- package/dist/autocomplete/autocomplete-root.js +253 -0
- package/dist/autocomplete/autocomplete-root.js.map +1 -0
- package/dist/checkbox/checkbox-group-root.js +1 -1
- package/dist/checkbox/checkbox-root.js +1 -1
- package/dist/combobox/combobox-content-impl.js +9 -2
- package/dist/combobox/combobox-content-impl.js.map +1 -1
- package/dist/combobox/combobox-content.js +4 -0
- package/dist/combobox/combobox-content.js.map +1 -1
- package/dist/combobox/combobox-root.js +1 -1
- package/dist/composables/use-window-splitter-panel-group-behavior.js +13 -9
- package/dist/composables/use-window-splitter-panel-group-behavior.js.map +1 -1
- package/dist/constant/components.js +18 -0
- package/dist/constant/components.js.map +1 -1
- package/dist/constant.d.ts +1 -0
- package/dist/constant.d.ts.map +1 -1
- package/dist/date-field/date-field-root.js +1 -1
- package/dist/date-range-field/date-range-field-root.js +1 -1
- package/dist/dialog/dialog-content-impl.js +1 -1
- package/dist/hover-card/hover-card-content-impl.js +1 -1
- package/dist/index.d.ts +2163 -2033
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -47
- package/dist/listbox/listbox-root.js +1 -1
- package/dist/listbox/listbox-virtualizer.js +1 -1
- package/dist/menu/menu-content-impl.js +1 -1
- package/dist/menu/menu-item-impl.js +1 -1
- package/dist/namespaced/index.cjs +19 -0
- package/dist/namespaced/index.d.cts +20 -2
- package/dist/namespaced/index.d.mts +20 -2
- package/dist/namespaced/index.mjs +20 -2
- package/dist/popover/popover-content-impl.js +1 -1
- package/dist/radio-group/radio-group-root.js +1 -1
- package/dist/select/select-content-impl.js +1 -1
- package/dist/select/select-root.js +1 -1
- package/dist/select/select-trigger.js +1 -1
- package/dist/shared/use-id.js +7 -4
- package/dist/shared/use-id.js.map +1 -1
- package/dist/splitter/splitter-group.js +143 -30
- package/dist/splitter/splitter-group.js.map +1 -1
- package/dist/splitter/splitter-panel.js +7 -2
- package/dist/splitter/splitter-panel.js.map +1 -1
- package/dist/time-field/time-field-root.js +1 -1
- package/dist/toast/toast-announce.js +4 -1
- package/dist/toast/toast-announce.js.map +1 -1
- package/dist/toggle-group/toggle-group-root.js +1 -1
- package/dist/tooltip/tooltip-content-impl.js +26 -19
- package/dist/tooltip/tooltip-content-impl.js.map +1 -1
- package/dist/tooltip/tooltip-content.js +1 -2
- package/dist/tooltip/tooltip-content.js.map +1 -1
- package/dist/tooltip/tooltip-provider.js +7 -2
- package/dist/tooltip/tooltip-provider.js.map +1 -1
- package/dist/utils/storage.js +7 -1
- package/dist/utils/storage.js.map +1 -1
- package/dist/utils/units.js +82 -0
- package/dist/utils/units.js.map +1 -0
- package/package.json +1 -1
- package/src/autocomplete/autocomplete-input.vue +124 -0
- package/src/autocomplete/autocomplete-root.vue +292 -0
- package/src/autocomplete/index.ts +74 -0
- package/src/combobox/combobox-content-impl.vue +13 -1
- package/src/index.ts +1 -0
- package/src/shared/use-id.ts +6 -8
- package/src/splitter/splitter-group.vue +249 -54
- package/src/splitter/splitter-panel.vue +12 -7
- package/src/splitter/utils/composables/use-window-splitter-panel-group-behavior.ts +18 -7
- package/src/splitter/utils/storage.ts +14 -0
- package/src/splitter/utils/units.ts +166 -0
- package/src/splitter/utils/validation.ts +3 -2
- package/src/toast/toast-announce.vue +4 -1
- package/src/tooltip/tooltip-content-impl.vue +18 -10
- package/src/tooltip/tooltip-content.vue +1 -3
- package/src/tooltip/tooltip-provider.vue +20 -3
|
@@ -31,6 +31,9 @@ export interface PanelConfigurationState {
|
|
|
31
31
|
[panelId: string]: number;
|
|
32
32
|
};
|
|
33
33
|
layout: Array<number>;
|
|
34
|
+
sizeUnits?: {
|
|
35
|
+
[panelIndex: number]: 'px' | '%';
|
|
36
|
+
};
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
export interface SerializedPanelGroupState {
|
|
@@ -99,9 +102,20 @@ export function savePanelGroupState(
|
|
|
99
102
|
const panelGroupKey = getPanelGroupKey(autoSaveId);
|
|
100
103
|
const panelKey = getPanelKey(panels);
|
|
101
104
|
const state = loadSerializedPanelGroupState(autoSaveId, storage) ?? {};
|
|
105
|
+
|
|
106
|
+
// Store the size units for each panel so we can restore them correctly
|
|
107
|
+
const sizeUnits: { [panelIndex: number]: 'px' | '%' } = {};
|
|
108
|
+
panels.forEach((panel, index) => {
|
|
109
|
+
const unit = panel.constraints.sizeUnit ?? '%';
|
|
110
|
+
if (unit === 'px') {
|
|
111
|
+
sizeUnits[index] = 'px';
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
102
115
|
state[panelKey] = {
|
|
103
116
|
expandToSizes: Object.fromEntries(panelSizesBeforeCollapse.entries()),
|
|
104
117
|
layout: sizes,
|
|
118
|
+
...(Object.keys(sizeUnits).length > 0 && { sizeUnits }),
|
|
105
119
|
};
|
|
106
120
|
|
|
107
121
|
try {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { PanelConstraints, PanelData } from '../splitter-panel.vue';
|
|
2
|
+
|
|
3
|
+
export type SizeUnit = '%' | 'px';
|
|
4
|
+
|
|
5
|
+
interface ConvertConstraintsToPercentOptions {
|
|
6
|
+
panelDataArray: Array<PanelData>;
|
|
7
|
+
groupSizeInPixels: number | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ConvertValueOptions {
|
|
11
|
+
sizeUnit: SizeUnit;
|
|
12
|
+
groupSizeInPixels: number | null;
|
|
13
|
+
value: number | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function convertValueToPercent({ sizeUnit, groupSizeInPixels, value }: ConvertValueOptions): number | undefined {
|
|
17
|
+
if (value == null) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (sizeUnit === '%') {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (groupSizeInPixels == null || groupSizeInPixels === 0) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (value / groupSizeInPixels) * 100;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function convertPanelConstraintsToPercent({
|
|
33
|
+
panelDataArray,
|
|
34
|
+
groupSizeInPixels,
|
|
35
|
+
}: ConvertConstraintsToPercentOptions): Array<PanelConstraints> | null {
|
|
36
|
+
const requiresMeasurement = panelDataArray.some(
|
|
37
|
+
(panelData) => (panelData.constraints.sizeUnit ?? '%') === 'px',
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (requiresMeasurement && (!groupSizeInPixels || Number.isNaN(groupSizeInPixels))) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return panelDataArray.map((panelData) => {
|
|
45
|
+
const constraints = panelData.constraints;
|
|
46
|
+
const sizeUnit = constraints.sizeUnit ?? '%';
|
|
47
|
+
|
|
48
|
+
const collapsedSize = convertValueToPercent({
|
|
49
|
+
groupSizeInPixels,
|
|
50
|
+
sizeUnit,
|
|
51
|
+
value: constraints.collapsedSize,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const defaultSize = convertValueToPercent({
|
|
55
|
+
groupSizeInPixels,
|
|
56
|
+
sizeUnit,
|
|
57
|
+
value: constraints.defaultSize,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const maxSize = convertValueToPercent({
|
|
61
|
+
groupSizeInPixels,
|
|
62
|
+
sizeUnit,
|
|
63
|
+
value: constraints.maxSize,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const minSize = convertValueToPercent({
|
|
67
|
+
groupSizeInPixels,
|
|
68
|
+
sizeUnit,
|
|
69
|
+
value: constraints.minSize,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
...constraints,
|
|
74
|
+
collapsedSize: collapsedSize ?? constraints.collapsedSize ?? 0,
|
|
75
|
+
defaultSize,
|
|
76
|
+
maxSize: maxSize ?? 100,
|
|
77
|
+
minSize: minSize ?? 0,
|
|
78
|
+
sizeUnit: '%',
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface RecalculateLayoutOptions {
|
|
84
|
+
layout: Array<number>;
|
|
85
|
+
panelDataArray: Array<PanelData>;
|
|
86
|
+
prevGroupSize: number | null;
|
|
87
|
+
nextGroupSize: number | null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function hasPixelSizedPanel(panelDataArray: Array<PanelData>): boolean {
|
|
91
|
+
return panelDataArray.some((panelData) => (panelData.constraints.sizeUnit ?? '%') === 'px');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function recalculateLayoutForPixelPanels({
|
|
95
|
+
layout,
|
|
96
|
+
panelDataArray,
|
|
97
|
+
prevGroupSize,
|
|
98
|
+
nextGroupSize,
|
|
99
|
+
}: RecalculateLayoutOptions): Array<number> | null {
|
|
100
|
+
if (!hasPixelSizedPanel(panelDataArray)) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
prevGroupSize == null
|
|
106
|
+
|| nextGroupSize == null
|
|
107
|
+
|| prevGroupSize === 0
|
|
108
|
+
|| nextGroupSize === 0
|
|
109
|
+
|| Number.isNaN(prevGroupSize)
|
|
110
|
+
|| Number.isNaN(nextGroupSize)
|
|
111
|
+
) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const pixelPanelIndices = panelDataArray.reduce<Array<number>>((indices, panelData, index) => {
|
|
116
|
+
if ((panelData.constraints.sizeUnit ?? '%') === 'px') {
|
|
117
|
+
indices.push(index);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return indices;
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
if (pixelPanelIndices.length === 0) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const pixelIndexSet = new Set(pixelPanelIndices);
|
|
128
|
+
|
|
129
|
+
const nextLayout = layout.map((size) => size ?? 0);
|
|
130
|
+
|
|
131
|
+
const nextPixelPercents = pixelPanelIndices.map((index) => {
|
|
132
|
+
const prevPercent = layout[index] ?? 0;
|
|
133
|
+
const prevPixelSize = (prevPercent / 100) * prevGroupSize;
|
|
134
|
+
return (prevPixelSize / nextGroupSize) * 100;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const totalNextPixelPercent = nextPixelPercents.reduce((sum, value) => sum + value, 0);
|
|
138
|
+
|
|
139
|
+
const prevPercentForPercentPanels = layout.reduce((sum, size, index) => {
|
|
140
|
+
if (pixelIndexSet.has(index)) {
|
|
141
|
+
return sum;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return sum + (size ?? 0);
|
|
145
|
+
}, 0);
|
|
146
|
+
|
|
147
|
+
const availableNextPercent = Math.max(0, 100 - totalNextPixelPercent);
|
|
148
|
+
const scaleFactor = prevPercentForPercentPanels > 0
|
|
149
|
+
? availableNextPercent / prevPercentForPercentPanels
|
|
150
|
+
: 0;
|
|
151
|
+
|
|
152
|
+
pixelPanelIndices.forEach((panelIndex, arrayIndex) => {
|
|
153
|
+
nextLayout[panelIndex] = nextPixelPercents[arrayIndex];
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
for (let index = 0; index < nextLayout.length; index++) {
|
|
157
|
+
if (pixelIndexSet.has(index)) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const prevSize = layout[index] ?? 0;
|
|
162
|
+
nextLayout[index] = prevSize * scaleFactor;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return nextLayout;
|
|
166
|
+
}
|
|
@@ -111,11 +111,12 @@ export function validatePanelConstraints({
|
|
|
111
111
|
defaultSize,
|
|
112
112
|
maxSize = 100,
|
|
113
113
|
minSize = 0,
|
|
114
|
+
sizeUnit = '%',
|
|
114
115
|
} = panelConstraints;
|
|
115
116
|
|
|
116
117
|
if (minSize > maxSize) {
|
|
117
118
|
warnings.push(
|
|
118
|
-
`min size (${minSize}
|
|
119
|
+
`min size (${minSize}${sizeUnit}) should not be greater than max size (${maxSize}${sizeUnit})`,
|
|
119
120
|
);
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -129,7 +130,7 @@ export function validatePanelConstraints({
|
|
|
129
130
|
warnings.push('default size should not be less than min size');
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
if (defaultSize > 100) {
|
|
133
|
+
if (sizeUnit === '%' && defaultSize > 100) {
|
|
133
134
|
warnings.push('default size should not be greater than 100');
|
|
134
135
|
} else if (defaultSize > maxSize) {
|
|
135
136
|
warnings.push('default size should not be greater than max size');
|
|
@@ -16,7 +16,10 @@ useRafFn(() => {
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<template>
|
|
19
|
-
<AVisuallyHidden
|
|
19
|
+
<AVisuallyHidden
|
|
20
|
+
v-if="isAnnounced || renderAnnounceText"
|
|
21
|
+
feature="fully-hidden"
|
|
22
|
+
>
|
|
20
23
|
{{ providerContext.label.value }}
|
|
21
24
|
<slot />
|
|
22
25
|
</AVisuallyHidden>
|
|
@@ -40,35 +40,43 @@ export interface TooltipContentImplProps
|
|
|
40
40
|
|
|
41
41
|
<script setup lang="ts">
|
|
42
42
|
import { useEventListener } from '@vueuse/core';
|
|
43
|
+
import { defu } from 'defu';
|
|
43
44
|
import { computed, onMounted } from 'vue';
|
|
44
45
|
import { DismissableLayer } from '../dismissable-layer';
|
|
45
46
|
import { APopperContent } from '../popper';
|
|
46
47
|
import { useForwardExpose } from '../shared';
|
|
47
48
|
import { AVisuallyHidden } from '../visually-hidden';
|
|
49
|
+
import { injectATooltipProviderContext } from './tooltip-provider.vue';
|
|
48
50
|
import { injectATooltipRootContext } from './tooltip-root.vue';
|
|
49
51
|
import { TOOLTIP_OPEN } from './utils';
|
|
50
52
|
|
|
51
53
|
const props = withDefaults(defineProps<TooltipContentImplProps>(), {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
avoidCollisions: true,
|
|
56
|
-
collisionBoundary: () => [],
|
|
57
|
-
collisionPadding: 0,
|
|
58
|
-
arrowPadding: 0,
|
|
59
|
-
sticky: 'partial',
|
|
60
|
-
hideWhenDetached: false,
|
|
54
|
+
avoidCollisions: undefined,
|
|
55
|
+
asChild: undefined,
|
|
56
|
+
hideWhenDetached: undefined,
|
|
61
57
|
});
|
|
62
58
|
const emits = defineEmits<TooltipContentImplEmits>();
|
|
63
59
|
|
|
64
60
|
const rootContext = injectATooltipRootContext();
|
|
61
|
+
const providerContext = injectATooltipProviderContext();
|
|
65
62
|
|
|
66
63
|
const { forwardRef, currentElement } = useForwardExpose();
|
|
67
64
|
const ariaLabel = computed(() => props.ariaLabel || currentElement.value?.textContent);
|
|
68
65
|
|
|
69
66
|
const popperContentProps = computed(() => {
|
|
70
67
|
const { ariaLabel: _, ...restProps } = props;
|
|
71
|
-
|
|
68
|
+
|
|
69
|
+
return defu(restProps, providerContext.content.value ?? {}, {
|
|
70
|
+
side: 'top',
|
|
71
|
+
sideOffset: 0,
|
|
72
|
+
align: 'center',
|
|
73
|
+
avoidCollisions: true,
|
|
74
|
+
collisionBoundary: [],
|
|
75
|
+
collisionPadding: 0,
|
|
76
|
+
arrowPadding: 0,
|
|
77
|
+
sticky: 'partial',
|
|
78
|
+
hideWhenDetached: false,
|
|
79
|
+
} satisfies TooltipContentImplProps);
|
|
72
80
|
});
|
|
73
81
|
|
|
74
82
|
onMounted(() => {
|
|
@@ -19,9 +19,7 @@ import TooltipContentHoverable from './tooltip-content-hoverable.vue';
|
|
|
19
19
|
import TooltipContentImpl from './tooltip-content-impl.vue';
|
|
20
20
|
import { injectATooltipRootContext } from './tooltip-root.vue';
|
|
21
21
|
|
|
22
|
-
const props =
|
|
23
|
-
side: 'top',
|
|
24
|
-
});
|
|
22
|
+
const props = defineProps<ATooltipContentProps>();
|
|
25
23
|
const emits = defineEmits<ATooltipContentEmits>();
|
|
26
24
|
|
|
27
25
|
const rootContext = injectATooltipRootContext();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
|
+
import type { ATooltipContentProps } from './tooltip-content.vue';
|
|
3
4
|
import { createContext, useForwardExpose } from '../shared';
|
|
4
5
|
|
|
5
6
|
interface TooltipProviderContext {
|
|
@@ -12,10 +13,13 @@ interface TooltipProviderContext {
|
|
|
12
13
|
disableClosingTrigger: Ref<boolean>;
|
|
13
14
|
disabled: Ref<boolean>;
|
|
14
15
|
ignoreNonKeyboardFocus: Ref<boolean>;
|
|
16
|
+
content: Ref<ATooltipContentProps | undefined>;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export const [
|
|
18
|
-
|
|
19
|
+
export const [
|
|
20
|
+
injectATooltipProviderContext,
|
|
21
|
+
provideTooltipProviderContext,
|
|
22
|
+
] = createContext<TooltipProviderContext>('ATooltipProvider');
|
|
19
23
|
|
|
20
24
|
export interface ATooltipProviderProps {
|
|
21
25
|
/**
|
|
@@ -51,6 +55,10 @@ export interface ATooltipProviderProps {
|
|
|
51
55
|
* @defaultValue false
|
|
52
56
|
*/
|
|
53
57
|
ignoreNonKeyboardFocus?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Default settings that will be used by all tooltip components.
|
|
60
|
+
*/
|
|
61
|
+
content?: ATooltipContentProps;
|
|
54
62
|
}
|
|
55
63
|
</script>
|
|
56
64
|
|
|
@@ -68,7 +76,15 @@ const props = withDefaults(defineProps<ATooltipProviderProps>(), {
|
|
|
68
76
|
disableHoverableContent: false,
|
|
69
77
|
ignoreNonKeyboardFocus: false,
|
|
70
78
|
});
|
|
71
|
-
const {
|
|
79
|
+
const {
|
|
80
|
+
delayDuration,
|
|
81
|
+
skipDelayDuration,
|
|
82
|
+
disableHoverableContent,
|
|
83
|
+
disableClosingTrigger,
|
|
84
|
+
ignoreNonKeyboardFocus,
|
|
85
|
+
disabled,
|
|
86
|
+
content,
|
|
87
|
+
} = toRefs(props);
|
|
72
88
|
useForwardExpose();
|
|
73
89
|
|
|
74
90
|
const isOpenDelayed = ref(true);
|
|
@@ -94,6 +110,7 @@ provideTooltipProviderContext({
|
|
|
94
110
|
disableClosingTrigger,
|
|
95
111
|
disabled,
|
|
96
112
|
ignoreNonKeyboardFocus,
|
|
113
|
+
content,
|
|
97
114
|
});
|
|
98
115
|
</script>
|
|
99
116
|
|