base-ui-vue 0.1.0 → 0.2.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 +41 -1
- package/dist/button/Button.cjs +53 -12
- package/dist/button/Button.cjs.map +1 -1
- package/dist/button/Button.js +26 -15
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ToolbarButton.cjs +367 -0
- package/dist/button/ToolbarButton.cjs.map +1 -0
- package/dist/button/ToolbarButton.js +320 -0
- package/dist/button/ToolbarButton.js.map +1 -0
- package/dist/button/ToolbarButtonDataAttributes.cjs +27 -0
- package/dist/button/ToolbarButtonDataAttributes.cjs.map +1 -0
- package/dist/button/ToolbarButtonDataAttributes.js +21 -0
- package/dist/button/ToolbarButtonDataAttributes.js.map +1 -0
- package/dist/checkbox/index.cjs +1173 -0
- package/dist/checkbox/index.cjs.map +1 -0
- package/dist/checkbox/index.js +1048 -0
- package/dist/checkbox/index.js.map +1 -0
- package/dist/checkbox-group/CheckboxGroup.cjs +629 -0
- package/dist/checkbox-group/CheckboxGroup.cjs.map +1 -0
- package/dist/checkbox-group/CheckboxGroup.js +540 -0
- package/dist/checkbox-group/CheckboxGroup.js.map +1 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.cjs +18 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.cjs.map +1 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.js +12 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.js.map +1 -0
- package/dist/composite/composite.cjs +167 -0
- package/dist/composite/composite.cjs.map +1 -1
- package/dist/composite/composite.js +96 -1
- package/dist/composite/composite.js.map +1 -1
- package/dist/composite/constants.cjs +12 -0
- package/dist/composite/constants.cjs.map +1 -0
- package/dist/composite/constants.js +6 -0
- package/dist/composite/constants.js.map +1 -0
- package/dist/control/FieldControl.cjs +18 -343
- package/dist/control/FieldControl.cjs.map +1 -1
- package/dist/control/FieldControl.js +14 -285
- package/dist/control/FieldControl.js.map +1 -1
- package/dist/control/SliderControl.cjs +636 -0
- package/dist/control/SliderControl.cjs.map +1 -0
- package/dist/control/SliderControl.js +553 -0
- package/dist/control/SliderControl.js.map +1 -0
- package/dist/control/SliderControlDataAttributes.cjs +47 -0
- package/dist/control/SliderControlDataAttributes.cjs.map +1 -0
- package/dist/control/SliderControlDataAttributes.js +41 -0
- package/dist/control/SliderControlDataAttributes.js.map +1 -0
- package/dist/csp-provider/CSPContext.cjs +32 -0
- package/dist/csp-provider/CSPContext.cjs.map +1 -0
- package/dist/csp-provider/CSPContext.js +21 -0
- package/dist/csp-provider/CSPContext.js.map +1 -0
- package/dist/csp-provider/CSPProvider.cjs +46 -0
- package/dist/csp-provider/CSPProvider.cjs.map +1 -0
- package/dist/csp-provider/CSPProvider.js +41 -0
- package/dist/csp-provider/CSPProvider.js.map +1 -0
- package/dist/description/FieldDescription.cjs +5 -5
- package/dist/description/FieldDescription.cjs.map +1 -1
- package/dist/description/FieldDescription.js +1 -1
- package/dist/direction-provider/DirectionProvider.cjs +2 -2
- package/dist/direction-provider/DirectionProvider.cjs.map +1 -1
- package/dist/direction-provider/DirectionProvider.js +1 -1
- package/dist/error/FieldError.cjs +10 -288
- package/dist/error/FieldError.cjs.map +1 -1
- package/dist/error/FieldError.js +4 -246
- package/dist/error/FieldError.js.map +1 -1
- package/dist/form/Form.cjs +5 -4
- package/dist/form/Form.cjs.map +1 -1
- package/dist/form/Form.js +5 -4
- package/dist/form/Form.js.map +1 -1
- package/dist/group/ToolbarGroup.cjs +92 -0
- package/dist/group/ToolbarGroup.cjs.map +1 -0
- package/dist/group/ToolbarGroup.js +87 -0
- package/dist/group/ToolbarGroup.js.map +1 -0
- package/dist/group/ToolbarGroupDataAttributes.cjs +23 -0
- package/dist/group/ToolbarGroupDataAttributes.cjs.map +1 -0
- package/dist/group/ToolbarGroupDataAttributes.js +17 -0
- package/dist/group/ToolbarGroupDataAttributes.js.map +1 -0
- package/dist/header/AccordionHeader.cjs +2 -2
- package/dist/header/AccordionHeader.js +1 -1
- package/dist/image/AvatarImage.cjs +4 -4
- package/dist/image/AvatarImage.cjs.map +1 -1
- package/dist/image/AvatarImage.js +1 -1
- package/dist/index.cjs +80 -10
- package/dist/index.d.cts +2751 -612
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2751 -612
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index2.cjs +3651 -370
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +3365 -270
- package/dist/index2.js.map +1 -1
- package/package.json +8 -4
- package/src/accordion/root/AccordionRoot.vue +2 -1
- package/src/checkbox/index.ts +23 -0
- package/src/checkbox/indicator/CheckboxIndicator.vue +102 -0
- package/src/checkbox/indicator/CheckboxIndicatorDataAttributes.ts +61 -0
- package/src/checkbox/root/CheckboxRoot.vue +632 -0
- package/src/checkbox/root/CheckboxRootContext.ts +22 -0
- package/src/checkbox/root/CheckboxRootDataAttributes.ts +54 -0
- package/src/checkbox/utils/useStateAttributesMapping.ts +30 -0
- package/src/checkbox-group/CheckboxGroup.vue +241 -0
- package/src/checkbox-group/CheckboxGroupContext.ts +39 -0
- package/src/checkbox-group/CheckboxGroupDataAttributes.ts +6 -0
- package/src/checkbox-group/index.ts +11 -0
- package/src/checkbox-group/useCheckboxGroupParent.ts +173 -0
- package/src/collapsible/panel/useCollapsiblePanel.ts +2 -1
- package/src/collapsible/root/useCollapsibleRoot.ts +3 -1
- package/src/composite/composite.ts +2 -0
- package/src/composite/item/CompositeItem.vue +7 -8
- package/src/composite/root/CompositeRoot.vue +12 -1
- package/src/csp-provider/CSPContext.ts +26 -0
- package/src/csp-provider/CSPProvider.vue +40 -0
- package/src/csp-provider/index.ts +5 -0
- package/src/field/item/FieldItem.vue +6 -1
- package/src/field/label/FieldLabel.vue +10 -51
- package/src/field/root/FieldRoot.vue +16 -3
- package/src/floating-ui-vue/types.ts +1 -4
- package/src/floating-ui-vue/utils/element.ts +12 -0
- package/src/floating-ui-vue/utils/shadowDom.ts +44 -0
- package/src/floating-ui-vue/utils.ts +3 -0
- package/src/form/Form.vue +5 -3
- package/src/index.ts +9 -0
- package/src/labelable-provider/LabelableContext.ts +2 -2
- package/src/labelable-provider/LabelableProvider.vue +21 -4
- package/src/labelable-provider/index.ts +2 -0
- package/src/labelable-provider/useAriaLabelledBy.ts +9 -9
- package/src/labelable-provider/useLabel.ts +115 -0
- package/src/labelable-provider/useLabelableId.ts +12 -10
- package/src/separator/Separator.vue +65 -0
- package/src/separator/SeparatorDataAttributes.ts +7 -0
- package/src/separator/index.ts +3 -0
- package/src/slider/control/SliderControl.vue +497 -0
- package/src/slider/control/SliderControlDataAttributes.ts +35 -0
- package/src/slider/index.ts +35 -0
- package/src/slider/indicator/SliderIndicator.vue +144 -0
- package/src/slider/indicator/SliderIndicatorDataAttributes.ts +35 -0
- package/src/slider/label/SliderLabel.vue +75 -0
- package/src/slider/root/SliderRoot.vue +557 -0
- package/src/slider/root/SliderRootContext.ts +126 -0
- package/src/slider/root/SliderRootDataAttributes.ts +35 -0
- package/src/slider/root/stateAttributesMapping.ts +13 -0
- package/src/slider/thumb/SliderThumb.vue +601 -0
- package/src/slider/thumb/SliderThumbDataAttributes.ts +39 -0
- package/src/slider/thumb/prehydrationScript.min.ts +5 -0
- package/src/slider/thumb/prehydrationScript.template.js +69 -0
- package/src/slider/track/SliderTrack.vue +48 -0
- package/src/slider/track/SliderTrackDataAttributes.ts +10 -0
- package/src/slider/utils/asc.ts +3 -0
- package/src/slider/utils/getMidpoint.ts +9 -0
- package/src/slider/utils/getPushedThumbValues.ts +68 -0
- package/src/slider/utils/getSliderValue.ts +25 -0
- package/src/slider/utils/replaceArrayItemAtIndex.ts +15 -0
- package/src/slider/utils/resolveThumbCollision.ts +177 -0
- package/src/slider/utils/roundValueToStep.ts +19 -0
- package/src/slider/utils/test-utils.ts +25 -0
- package/src/slider/utils/validateMinimumDistance.ts +20 -0
- package/src/slider/utils/valueArrayToPercentages.ts +10 -0
- package/src/slider/value/SliderValue.vue +90 -0
- package/src/slider/value/SliderValueDataAttributes.ts +35 -0
- package/src/switch/index.ts +14 -0
- package/src/switch/root/SwitchRoot.vue +448 -0
- package/src/switch/root/SwitchRootContext.ts +22 -0
- package/src/switch/root/SwitchRootDataAttributes.ts +46 -0
- package/src/switch/stateAttributesMapping.ts +23 -0
- package/src/switch/thumb/SwitchThumb.vue +59 -0
- package/src/switch/thumb/SwitchThumbDataAttributes.ts +46 -0
- package/src/toggle/Toggle.vue +211 -0
- package/src/toggle/ToggleDataAttributes.ts +6 -0
- package/src/toggle/index.ts +3 -0
- package/src/toggle-group/ToggleGroup.vue +224 -0
- package/src/toggle-group/ToggleGroupContext.ts +45 -0
- package/src/toggle-group/ToggleGroupDataAttributes.ts +15 -0
- package/src/toggle-group/index.ts +5 -0
- package/src/toolbar/button/ToolbarButton.vue +99 -0
- package/src/toolbar/button/ToolbarButtonDataAttributes.ts +15 -0
- package/src/toolbar/group/ToolbarGroup.vue +70 -0
- package/src/toolbar/group/ToolbarGroupContext.ts +23 -0
- package/src/toolbar/group/ToolbarGroupDataAttributes.ts +11 -0
- package/src/toolbar/index.ts +27 -0
- package/src/toolbar/input/ToolbarInput.vue +114 -0
- package/src/toolbar/input/ToolbarInputDataAttributes.ts +15 -0
- package/src/toolbar/link/ToolbarLink.vue +54 -0
- package/src/toolbar/link/ToolbarLinkDataAttributes.ts +7 -0
- package/src/toolbar/root/ToolbarRoot.vue +144 -0
- package/src/toolbar/root/ToolbarRootContext.ts +29 -0
- package/src/toolbar/root/ToolbarRootDataAttributes.ts +11 -0
- package/src/toolbar/separator/ToolbarSeparator.vue +41 -0
- package/src/toolbar/separator/ToolbarSeparatorDataAttributes.ts +7 -0
- package/src/use-button/useButton.ts +2 -1
- package/src/utils/areArraysEqual.ts +12 -0
- package/src/utils/clamp.ts +7 -0
- package/src/utils/createBaseUIEventDetails.ts +9 -0
- package/src/utils/formatNumber.ts +7 -0
- package/src/utils/owner.ts +5 -0
- package/src/utils/resolveAriaLabelledBy.ts +10 -0
- package/src/utils/useControllableState.ts +78 -14
- package/src/utils/useFocusableWhenDisabled.ts +6 -1
- package/src/utils/useMergedRefs.ts +26 -2
- package/src/utils/useRegisteredLabelId.ts +21 -0
- package/src/utils/valueToPercent.ts +7 -0
- package/src/utils/visuallyHidden.ts +24 -0
- package/dist/direction-provider/DirectionContext.cjs +0 -26
- package/dist/direction-provider/DirectionContext.cjs.map +0 -1
- package/dist/direction-provider/DirectionContext.js +0 -15
- package/dist/direction-provider/DirectionContext.js.map +0 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
const require_button_Button = require('./Button.cjs');
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
|
|
4
|
+
//#region src/composite/list/CompositeListContext.ts
|
|
5
|
+
const compositeListContextKey = Symbol("CompositeListContext");
|
|
6
|
+
function useCompositeListContext() {
|
|
7
|
+
return (0, vue.inject)(compositeListContextKey);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/composite/list/useCompositeListItem.ts
|
|
12
|
+
let IndexGuessBehavior = /* @__PURE__ */ function(IndexGuessBehavior) {
|
|
13
|
+
IndexGuessBehavior[IndexGuessBehavior["None"] = 0] = "None";
|
|
14
|
+
IndexGuessBehavior[IndexGuessBehavior["GuessFromOrder"] = 1] = "GuessFromOrder";
|
|
15
|
+
return IndexGuessBehavior;
|
|
16
|
+
}({});
|
|
17
|
+
/**
|
|
18
|
+
* Used to register a list item and its index (DOM position) in the `CompositeList`.
|
|
19
|
+
*/
|
|
20
|
+
function useCompositeListItem(params = {}) {
|
|
21
|
+
const externalIndex = (0, vue.computed)(() => params.index?.());
|
|
22
|
+
const label = (0, vue.computed)(() => params.label?.());
|
|
23
|
+
const metadata = (0, vue.computed)(() => params.metadata?.());
|
|
24
|
+
const textRef = (0, vue.computed)(() => params.textRef?.());
|
|
25
|
+
const indexGuessBehavior = (0, vue.computed)(() => params.indexGuessBehavior?.());
|
|
26
|
+
const { register, unregister, subscribeMapChange, elementsRef, labelsRef, nextIndexRef } = useCompositeListContext();
|
|
27
|
+
const indexRef = (0, vue.ref)(-1);
|
|
28
|
+
function initializeIndex() {
|
|
29
|
+
if (externalIndex.value != null) return externalIndex.value;
|
|
30
|
+
if (indexGuessBehavior.value === IndexGuessBehavior.GuessFromOrder) {
|
|
31
|
+
if (indexRef.value === -1) {
|
|
32
|
+
const newIndex = nextIndexRef.value;
|
|
33
|
+
nextIndexRef.value += 1;
|
|
34
|
+
indexRef.value = newIndex;
|
|
35
|
+
}
|
|
36
|
+
return indexRef.value;
|
|
37
|
+
}
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
const internalIndex = (0, vue.ref)(initializeIndex());
|
|
41
|
+
const index = (0, vue.computed)(() => externalIndex.value ?? internalIndex.value);
|
|
42
|
+
const componentRef = (0, vue.ref)(null);
|
|
43
|
+
function setRef(node) {
|
|
44
|
+
const el = node?.$el || node;
|
|
45
|
+
componentRef.value = el;
|
|
46
|
+
if (index.value !== -1 && el !== null) {
|
|
47
|
+
elementsRef.value[index.value] = el;
|
|
48
|
+
if (labelsRef) {
|
|
49
|
+
const isLabelDefined = label.value !== void 0;
|
|
50
|
+
labelsRef.value[index.value] = isLabelDefined ? label.value : textRef.value?.value?.textContent ?? el.textContent;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
55
|
+
if (externalIndex.value != null) return;
|
|
56
|
+
const node = componentRef.value;
|
|
57
|
+
if (node) {
|
|
58
|
+
register(node, metadata.value);
|
|
59
|
+
onCleanup(() => {
|
|
60
|
+
unregister(node);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, { flush: "post" });
|
|
64
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
65
|
+
if (externalIndex.value != null) return;
|
|
66
|
+
const unsubscribe = subscribeMapChange((map) => {
|
|
67
|
+
const i = componentRef.value ? map.get(componentRef.value)?.index : null;
|
|
68
|
+
if (i != null) internalIndex.value = i;
|
|
69
|
+
});
|
|
70
|
+
onCleanup(() => {
|
|
71
|
+
unsubscribe();
|
|
72
|
+
});
|
|
73
|
+
}, { flush: "post" });
|
|
74
|
+
return {
|
|
75
|
+
ref: setRef,
|
|
76
|
+
index
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/composite/item/useCompositeItem.ts
|
|
82
|
+
function useCompositeItem(params = {}) {
|
|
83
|
+
const context = require_button_Button.useCompositeRootContext();
|
|
84
|
+
const { ref: listItemRef, index } = useCompositeListItem(params);
|
|
85
|
+
const isHighlighted = (0, vue.computed)(() => context.highlightedIndex === index.value);
|
|
86
|
+
const itemRef = (0, vue.ref)(null);
|
|
87
|
+
const mergedRef = require_button_Button.useMergedRefs(listItemRef, itemRef);
|
|
88
|
+
(0, vue.watch)(index, (newIndex, oldIndex) => {
|
|
89
|
+
if (oldIndex === -1 && newIndex !== -1 && itemRef.value) {
|
|
90
|
+
if (document.activeElement === itemRef.value) context.onHighlightedIndexChange(newIndex);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
compositeProps: (0, vue.computed)(() => ({
|
|
95
|
+
tabindex: isHighlighted.value ? 0 : -1,
|
|
96
|
+
onFocus() {
|
|
97
|
+
context.onHighlightedIndexChange(index.value);
|
|
98
|
+
},
|
|
99
|
+
onMousemove() {
|
|
100
|
+
const item = itemRef.value;
|
|
101
|
+
if (!context.highlightItemOnHover || !item) return;
|
|
102
|
+
const disabled = item.hasAttribute("disabled") || item.getAttribute("aria-disabled") === "true";
|
|
103
|
+
if (!isHighlighted.value && !disabled) item.focus();
|
|
104
|
+
}
|
|
105
|
+
})),
|
|
106
|
+
compositeRef: mergedRef,
|
|
107
|
+
index
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/composite/item/CompositeItem.vue?vue&type=script&setup=true&lang.ts
|
|
113
|
+
var CompositeItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
114
|
+
name: "BaseUICompositeItem",
|
|
115
|
+
inheritAttrs: false,
|
|
116
|
+
__name: "CompositeItem",
|
|
117
|
+
props: {
|
|
118
|
+
as: {
|
|
119
|
+
type: null,
|
|
120
|
+
required: false,
|
|
121
|
+
default: "div"
|
|
122
|
+
},
|
|
123
|
+
style: {
|
|
124
|
+
type: [
|
|
125
|
+
Boolean,
|
|
126
|
+
null,
|
|
127
|
+
String,
|
|
128
|
+
Object,
|
|
129
|
+
Array,
|
|
130
|
+
Function
|
|
131
|
+
],
|
|
132
|
+
required: false,
|
|
133
|
+
skipCheck: true
|
|
134
|
+
},
|
|
135
|
+
metadata: {
|
|
136
|
+
type: null,
|
|
137
|
+
required: false
|
|
138
|
+
},
|
|
139
|
+
refs: {
|
|
140
|
+
type: Array,
|
|
141
|
+
required: false
|
|
142
|
+
},
|
|
143
|
+
props: {
|
|
144
|
+
type: Array,
|
|
145
|
+
required: false
|
|
146
|
+
},
|
|
147
|
+
stateAttributesMapping: {
|
|
148
|
+
type: null,
|
|
149
|
+
required: false
|
|
150
|
+
},
|
|
151
|
+
state: {
|
|
152
|
+
type: null,
|
|
153
|
+
required: false,
|
|
154
|
+
default: () => require_button_Button.EMPTY_OBJECT
|
|
155
|
+
},
|
|
156
|
+
class: {
|
|
157
|
+
type: Function,
|
|
158
|
+
required: false,
|
|
159
|
+
skipCheck: true
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
setup(__props) {
|
|
163
|
+
const props = __props;
|
|
164
|
+
const attrs = (0, vue.useAttrs)();
|
|
165
|
+
const { compositeProps, compositeRef } = useCompositeItem({ metadata: () => props.metadata });
|
|
166
|
+
const externalProps = (0, vue.computed)(() => {
|
|
167
|
+
let externalProps = {};
|
|
168
|
+
if (props.props) props.props.forEach((prop) => {
|
|
169
|
+
const p = typeof prop === "function" ? prop() : prop;
|
|
170
|
+
externalProps = require_button_Button.mergeProps(externalProps, p);
|
|
171
|
+
});
|
|
172
|
+
return require_button_Button.mergeProps(attrs, externalProps, compositeProps.value);
|
|
173
|
+
});
|
|
174
|
+
const { tag, mergedProps, renderless, ref: renderRef } = require_button_Button.useRenderElement({
|
|
175
|
+
componentProps: props,
|
|
176
|
+
state: (0, vue.computed)(() => props.state),
|
|
177
|
+
props: externalProps,
|
|
178
|
+
stateAttributesMapping: props.stateAttributesMapping,
|
|
179
|
+
defaultTagName: "div",
|
|
180
|
+
ref: props.refs?.length ? require_button_Button.useMergedRefs(...props.refs, compositeRef) : compositeRef
|
|
181
|
+
});
|
|
182
|
+
return (_ctx, _cache) => {
|
|
183
|
+
return (0, vue.unref)(renderless) ? (0, vue.renderSlot)(_ctx.$slots, "default", {
|
|
184
|
+
key: 0,
|
|
185
|
+
ref: (0, vue.unref)(renderRef),
|
|
186
|
+
props: (0, vue.unref)(mergedProps),
|
|
187
|
+
state: props.state
|
|
188
|
+
}) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)((0, vue.unref)(tag)), (0, vue.mergeProps)({
|
|
189
|
+
key: 1,
|
|
190
|
+
ref: (0, vue.unref)(renderRef)
|
|
191
|
+
}, (0, vue.unref)(mergedProps)), {
|
|
192
|
+
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default", { state: props.state })]),
|
|
193
|
+
_: 3
|
|
194
|
+
}, 16));
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/composite/item/CompositeItem.vue
|
|
201
|
+
var CompositeItem_default = CompositeItem_vue_vue_type_script_setup_true_lang_default;
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/toolbar/root/ToolbarRootContext.ts
|
|
205
|
+
const toolbarRootContextKey = Symbol("ToolbarRootContext");
|
|
206
|
+
function useToolbarRootContext(optional = false) {
|
|
207
|
+
const context = (0, vue.inject)(toolbarRootContextKey, void 0);
|
|
208
|
+
if (context === void 0 && !optional) throw new Error("Base UI Vue: ToolbarRootContext is missing. Toolbar parts must be placed within <ToolbarRoot>.");
|
|
209
|
+
return context;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/toolbar/group/ToolbarGroupContext.ts
|
|
214
|
+
const toolbarGroupContextKey = Symbol("ToolbarGroupContext");
|
|
215
|
+
function useToolbarGroupContext(optional = false) {
|
|
216
|
+
const context = (0, vue.inject)(toolbarGroupContextKey, void 0);
|
|
217
|
+
if (context === void 0 && !optional) throw new Error("Base UI Vue: ToolbarGroupContext is missing. ToolbarGroup parts must be placed within <ToolbarGroup>.");
|
|
218
|
+
return context;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/toolbar/button/ToolbarButton.vue?vue&type=script&setup=true&lang.ts
|
|
223
|
+
/**
|
|
224
|
+
* A button that can be used as-is or as a trigger for other components.
|
|
225
|
+
* Renders a `<button>` element.
|
|
226
|
+
*
|
|
227
|
+
* Documentation: [Base UI Vue Toolbar](https://baseui-vue.com/docs/components/toolbar)
|
|
228
|
+
*/
|
|
229
|
+
var ToolbarButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
230
|
+
name: "ToolbarButton",
|
|
231
|
+
inheritAttrs: false,
|
|
232
|
+
__name: "ToolbarButton",
|
|
233
|
+
props: {
|
|
234
|
+
disabled: {
|
|
235
|
+
type: Boolean,
|
|
236
|
+
required: false,
|
|
237
|
+
default: false
|
|
238
|
+
},
|
|
239
|
+
focusableWhenDisabled: {
|
|
240
|
+
type: Boolean,
|
|
241
|
+
required: false,
|
|
242
|
+
default: true
|
|
243
|
+
},
|
|
244
|
+
nativeButton: {
|
|
245
|
+
type: Boolean,
|
|
246
|
+
required: false,
|
|
247
|
+
default: true
|
|
248
|
+
},
|
|
249
|
+
as: {
|
|
250
|
+
type: null,
|
|
251
|
+
required: false,
|
|
252
|
+
default: "button"
|
|
253
|
+
},
|
|
254
|
+
class: {
|
|
255
|
+
type: Function,
|
|
256
|
+
required: false,
|
|
257
|
+
skipCheck: true
|
|
258
|
+
},
|
|
259
|
+
style: {
|
|
260
|
+
type: [
|
|
261
|
+
Boolean,
|
|
262
|
+
null,
|
|
263
|
+
String,
|
|
264
|
+
Object,
|
|
265
|
+
Array,
|
|
266
|
+
Function
|
|
267
|
+
],
|
|
268
|
+
required: false,
|
|
269
|
+
skipCheck: true
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
setup(__props) {
|
|
273
|
+
const props = __props;
|
|
274
|
+
const attrs = (0, vue.useAttrs)();
|
|
275
|
+
const toolbarRootContext = useToolbarRootContext();
|
|
276
|
+
const toolbarGroupContext = useToolbarGroupContext(true);
|
|
277
|
+
const disabled = (0, vue.computed)(() => toolbarRootContext.disabled.value || (toolbarGroupContext?.disabled.value ?? false) || props.disabled);
|
|
278
|
+
const { getButtonProps, buttonRef } = require_button_Button.useButton({
|
|
279
|
+
disabled,
|
|
280
|
+
focusableWhenDisabled: () => props.focusableWhenDisabled,
|
|
281
|
+
native: () => props.nativeButton ?? true
|
|
282
|
+
});
|
|
283
|
+
const state = (0, vue.computed)(() => ({
|
|
284
|
+
disabled: disabled.value,
|
|
285
|
+
orientation: toolbarRootContext.orientation.value,
|
|
286
|
+
focusable: props.focusableWhenDisabled
|
|
287
|
+
}));
|
|
288
|
+
const itemRefs = [buttonRef];
|
|
289
|
+
const componentProps = (0, vue.computed)(() => typeof props.as === "string" ? {} : { disabled: disabled.value });
|
|
290
|
+
return (_ctx, _cache) => {
|
|
291
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)(CompositeItem_default, {
|
|
292
|
+
as: __props.as,
|
|
293
|
+
class: (0, vue.normalizeClass)(props.class),
|
|
294
|
+
style: (0, vue.normalizeStyle)(props.style),
|
|
295
|
+
metadata: { focusableWhenDisabled: __props.focusableWhenDisabled },
|
|
296
|
+
state: state.value,
|
|
297
|
+
refs: itemRefs,
|
|
298
|
+
props: [componentProps.value, () => (0, vue.unref)(getButtonProps)((0, vue.unref)(attrs))]
|
|
299
|
+
}, {
|
|
300
|
+
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default", { state: state.value })]),
|
|
301
|
+
_: 3
|
|
302
|
+
}, 8, [
|
|
303
|
+
"as",
|
|
304
|
+
"class",
|
|
305
|
+
"style",
|
|
306
|
+
"metadata",
|
|
307
|
+
"state",
|
|
308
|
+
"props"
|
|
309
|
+
]);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/toolbar/button/ToolbarButton.vue
|
|
316
|
+
var ToolbarButton_default = ToolbarButton_vue_vue_type_script_setup_true_lang_default;
|
|
317
|
+
|
|
318
|
+
//#endregion
|
|
319
|
+
Object.defineProperty(exports, 'CompositeItem_default', {
|
|
320
|
+
enumerable: true,
|
|
321
|
+
get: function () {
|
|
322
|
+
return CompositeItem_default;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
Object.defineProperty(exports, 'ToolbarButton_default', {
|
|
326
|
+
enumerable: true,
|
|
327
|
+
get: function () {
|
|
328
|
+
return ToolbarButton_default;
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
Object.defineProperty(exports, 'compositeListContextKey', {
|
|
332
|
+
enumerable: true,
|
|
333
|
+
get: function () {
|
|
334
|
+
return compositeListContextKey;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
Object.defineProperty(exports, 'toolbarGroupContextKey', {
|
|
338
|
+
enumerable: true,
|
|
339
|
+
get: function () {
|
|
340
|
+
return toolbarGroupContextKey;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
Object.defineProperty(exports, 'toolbarRootContextKey', {
|
|
344
|
+
enumerable: true,
|
|
345
|
+
get: function () {
|
|
346
|
+
return toolbarRootContextKey;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
Object.defineProperty(exports, 'useCompositeListItem', {
|
|
350
|
+
enumerable: true,
|
|
351
|
+
get: function () {
|
|
352
|
+
return useCompositeListItem;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
Object.defineProperty(exports, 'useToolbarGroupContext', {
|
|
356
|
+
enumerable: true,
|
|
357
|
+
get: function () {
|
|
358
|
+
return useToolbarGroupContext;
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
Object.defineProperty(exports, 'useToolbarRootContext', {
|
|
362
|
+
enumerable: true,
|
|
363
|
+
get: function () {
|
|
364
|
+
return useToolbarRootContext;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
//# sourceMappingURL=ToolbarButton.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.cjs","names":["useCompositeRootContext","useMergedRefs"],"sources":["../../src/composite/list/CompositeListContext.ts","../../src/composite/list/useCompositeListItem.ts","../../src/composite/item/useCompositeItem.ts","../../src/composite/item/CompositeItem.vue","../../src/composite/item/CompositeItem.vue","../../src/toolbar/root/ToolbarRootContext.ts","../../src/toolbar/group/ToolbarGroupContext.ts","../../src/toolbar/button/ToolbarButton.vue","../../src/toolbar/button/ToolbarButton.vue"],"sourcesContent":[],"mappings":";;;;AAcA,MAAa,0BAA0B,OACrC,uBACD;AAED,SAAgB,0BAA0B;AACxC,wBAAc,wBAAwB;;;;;ACfxC,IAAY,kEAAL;AACL;AACA;;;;;;AAwBF,SAAgB,qBACd,SAAmD,EAAE,EACpB;CACjC,MAAM,wCAA+B,OAAO,SAAS,CAAC;CACtD,MAAM,gCAAuB,OAAO,SAAS,CAAC;CAC9C,MAAM,mCAA0B,OAAO,YAAY,CAAC;CACpD,MAAM,kCAAyB,OAAO,WAAW,CAAC;CAClD,MAAM,6CAAoC,OAAO,sBAAsB,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AU,SAAS,OAAO,CAClC;;qDAiBkB,uBAAA;IAZb,IAAI,QAAA;IACJ,+BAAO,MAAM,MAAK;IAClB,+BAAO,MAAM,MAAK;IAClB,UAAQ,EAAA,uBAAI,QAAA,uBAAqB;IACjC,OAAO,MAAA;IACP,MAAM;IACN,OAAK,CAAU,eAAA,4BAA4B,eAAc,gBAAC,MAAK,CAAA;;oCAKzC,qBAAA,KAAA,QAAA,WAAA,EAAhB,OAAO,MAAA,OAAK,CAAA"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { EMPTY_OBJECT, mergeProps as mergeProps$1, useButton, useCompositeRootContext, useMergedRefs, useRenderElement } from "./Button.js";
|
|
2
|
+
import { computed, createBlock, createCommentVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, resolveDynamicComponent, unref, useAttrs, watch, watchEffect, withCtx } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/composite/list/CompositeListContext.ts
|
|
5
|
+
const compositeListContextKey = Symbol("CompositeListContext");
|
|
6
|
+
function useCompositeListContext() {
|
|
7
|
+
return inject(compositeListContextKey);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/composite/list/useCompositeListItem.ts
|
|
12
|
+
let IndexGuessBehavior = /* @__PURE__ */ function(IndexGuessBehavior) {
|
|
13
|
+
IndexGuessBehavior[IndexGuessBehavior["None"] = 0] = "None";
|
|
14
|
+
IndexGuessBehavior[IndexGuessBehavior["GuessFromOrder"] = 1] = "GuessFromOrder";
|
|
15
|
+
return IndexGuessBehavior;
|
|
16
|
+
}({});
|
|
17
|
+
/**
|
|
18
|
+
* Used to register a list item and its index (DOM position) in the `CompositeList`.
|
|
19
|
+
*/
|
|
20
|
+
function useCompositeListItem(params = {}) {
|
|
21
|
+
const externalIndex = computed(() => params.index?.());
|
|
22
|
+
const label = computed(() => params.label?.());
|
|
23
|
+
const metadata = computed(() => params.metadata?.());
|
|
24
|
+
const textRef = computed(() => params.textRef?.());
|
|
25
|
+
const indexGuessBehavior = computed(() => params.indexGuessBehavior?.());
|
|
26
|
+
const { register, unregister, subscribeMapChange, elementsRef, labelsRef, nextIndexRef } = useCompositeListContext();
|
|
27
|
+
const indexRef = ref(-1);
|
|
28
|
+
function initializeIndex() {
|
|
29
|
+
if (externalIndex.value != null) return externalIndex.value;
|
|
30
|
+
if (indexGuessBehavior.value === IndexGuessBehavior.GuessFromOrder) {
|
|
31
|
+
if (indexRef.value === -1) {
|
|
32
|
+
const newIndex = nextIndexRef.value;
|
|
33
|
+
nextIndexRef.value += 1;
|
|
34
|
+
indexRef.value = newIndex;
|
|
35
|
+
}
|
|
36
|
+
return indexRef.value;
|
|
37
|
+
}
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
const internalIndex = ref(initializeIndex());
|
|
41
|
+
const index = computed(() => externalIndex.value ?? internalIndex.value);
|
|
42
|
+
const componentRef = ref(null);
|
|
43
|
+
function setRef(node) {
|
|
44
|
+
const el = node?.$el || node;
|
|
45
|
+
componentRef.value = el;
|
|
46
|
+
if (index.value !== -1 && el !== null) {
|
|
47
|
+
elementsRef.value[index.value] = el;
|
|
48
|
+
if (labelsRef) {
|
|
49
|
+
const isLabelDefined = label.value !== void 0;
|
|
50
|
+
labelsRef.value[index.value] = isLabelDefined ? label.value : textRef.value?.value?.textContent ?? el.textContent;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
watchEffect((onCleanup) => {
|
|
55
|
+
if (externalIndex.value != null) return;
|
|
56
|
+
const node = componentRef.value;
|
|
57
|
+
if (node) {
|
|
58
|
+
register(node, metadata.value);
|
|
59
|
+
onCleanup(() => {
|
|
60
|
+
unregister(node);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, { flush: "post" });
|
|
64
|
+
watchEffect((onCleanup) => {
|
|
65
|
+
if (externalIndex.value != null) return;
|
|
66
|
+
const unsubscribe = subscribeMapChange((map) => {
|
|
67
|
+
const i = componentRef.value ? map.get(componentRef.value)?.index : null;
|
|
68
|
+
if (i != null) internalIndex.value = i;
|
|
69
|
+
});
|
|
70
|
+
onCleanup(() => {
|
|
71
|
+
unsubscribe();
|
|
72
|
+
});
|
|
73
|
+
}, { flush: "post" });
|
|
74
|
+
return {
|
|
75
|
+
ref: setRef,
|
|
76
|
+
index
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/composite/item/useCompositeItem.ts
|
|
82
|
+
function useCompositeItem(params = {}) {
|
|
83
|
+
const context = useCompositeRootContext();
|
|
84
|
+
const { ref: listItemRef, index } = useCompositeListItem(params);
|
|
85
|
+
const isHighlighted = computed(() => context.highlightedIndex === index.value);
|
|
86
|
+
const itemRef = ref(null);
|
|
87
|
+
const mergedRef = useMergedRefs(listItemRef, itemRef);
|
|
88
|
+
watch(index, (newIndex, oldIndex) => {
|
|
89
|
+
if (oldIndex === -1 && newIndex !== -1 && itemRef.value) {
|
|
90
|
+
if (document.activeElement === itemRef.value) context.onHighlightedIndexChange(newIndex);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
compositeProps: computed(() => ({
|
|
95
|
+
tabindex: isHighlighted.value ? 0 : -1,
|
|
96
|
+
onFocus() {
|
|
97
|
+
context.onHighlightedIndexChange(index.value);
|
|
98
|
+
},
|
|
99
|
+
onMousemove() {
|
|
100
|
+
const item = itemRef.value;
|
|
101
|
+
if (!context.highlightItemOnHover || !item) return;
|
|
102
|
+
const disabled = item.hasAttribute("disabled") || item.getAttribute("aria-disabled") === "true";
|
|
103
|
+
if (!isHighlighted.value && !disabled) item.focus();
|
|
104
|
+
}
|
|
105
|
+
})),
|
|
106
|
+
compositeRef: mergedRef,
|
|
107
|
+
index
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/composite/item/CompositeItem.vue?vue&type=script&setup=true&lang.ts
|
|
113
|
+
var CompositeItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
114
|
+
name: "BaseUICompositeItem",
|
|
115
|
+
inheritAttrs: false,
|
|
116
|
+
__name: "CompositeItem",
|
|
117
|
+
props: {
|
|
118
|
+
as: {
|
|
119
|
+
type: null,
|
|
120
|
+
required: false,
|
|
121
|
+
default: "div"
|
|
122
|
+
},
|
|
123
|
+
style: {
|
|
124
|
+
type: [
|
|
125
|
+
Boolean,
|
|
126
|
+
null,
|
|
127
|
+
String,
|
|
128
|
+
Object,
|
|
129
|
+
Array,
|
|
130
|
+
Function
|
|
131
|
+
],
|
|
132
|
+
required: false,
|
|
133
|
+
skipCheck: true
|
|
134
|
+
},
|
|
135
|
+
metadata: {
|
|
136
|
+
type: null,
|
|
137
|
+
required: false
|
|
138
|
+
},
|
|
139
|
+
refs: {
|
|
140
|
+
type: Array,
|
|
141
|
+
required: false
|
|
142
|
+
},
|
|
143
|
+
props: {
|
|
144
|
+
type: Array,
|
|
145
|
+
required: false
|
|
146
|
+
},
|
|
147
|
+
stateAttributesMapping: {
|
|
148
|
+
type: null,
|
|
149
|
+
required: false
|
|
150
|
+
},
|
|
151
|
+
state: {
|
|
152
|
+
type: null,
|
|
153
|
+
required: false,
|
|
154
|
+
default: () => EMPTY_OBJECT
|
|
155
|
+
},
|
|
156
|
+
class: {
|
|
157
|
+
type: Function,
|
|
158
|
+
required: false,
|
|
159
|
+
skipCheck: true
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
setup(__props) {
|
|
163
|
+
const props = __props;
|
|
164
|
+
const attrs = useAttrs();
|
|
165
|
+
const { compositeProps, compositeRef } = useCompositeItem({ metadata: () => props.metadata });
|
|
166
|
+
const externalProps = computed(() => {
|
|
167
|
+
let externalProps = {};
|
|
168
|
+
if (props.props) props.props.forEach((prop) => {
|
|
169
|
+
const p = typeof prop === "function" ? prop() : prop;
|
|
170
|
+
externalProps = mergeProps$1(externalProps, p);
|
|
171
|
+
});
|
|
172
|
+
return mergeProps$1(attrs, externalProps, compositeProps.value);
|
|
173
|
+
});
|
|
174
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
175
|
+
componentProps: props,
|
|
176
|
+
state: computed(() => props.state),
|
|
177
|
+
props: externalProps,
|
|
178
|
+
stateAttributesMapping: props.stateAttributesMapping,
|
|
179
|
+
defaultTagName: "div",
|
|
180
|
+
ref: props.refs?.length ? useMergedRefs(...props.refs, compositeRef) : compositeRef
|
|
181
|
+
});
|
|
182
|
+
return (_ctx, _cache) => {
|
|
183
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
184
|
+
key: 0,
|
|
185
|
+
ref: unref(renderRef),
|
|
186
|
+
props: unref(mergedProps),
|
|
187
|
+
state: props.state
|
|
188
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
189
|
+
key: 1,
|
|
190
|
+
ref: unref(renderRef)
|
|
191
|
+
}, unref(mergedProps)), {
|
|
192
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: props.state })]),
|
|
193
|
+
_: 3
|
|
194
|
+
}, 16));
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/composite/item/CompositeItem.vue
|
|
201
|
+
var CompositeItem_default = CompositeItem_vue_vue_type_script_setup_true_lang_default;
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/toolbar/root/ToolbarRootContext.ts
|
|
205
|
+
const toolbarRootContextKey = Symbol("ToolbarRootContext");
|
|
206
|
+
function useToolbarRootContext(optional = false) {
|
|
207
|
+
const context = inject(toolbarRootContextKey, void 0);
|
|
208
|
+
if (context === void 0 && !optional) throw new Error("Base UI Vue: ToolbarRootContext is missing. Toolbar parts must be placed within <ToolbarRoot>.");
|
|
209
|
+
return context;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/toolbar/group/ToolbarGroupContext.ts
|
|
214
|
+
const toolbarGroupContextKey = Symbol("ToolbarGroupContext");
|
|
215
|
+
function useToolbarGroupContext(optional = false) {
|
|
216
|
+
const context = inject(toolbarGroupContextKey, void 0);
|
|
217
|
+
if (context === void 0 && !optional) throw new Error("Base UI Vue: ToolbarGroupContext is missing. ToolbarGroup parts must be placed within <ToolbarGroup>.");
|
|
218
|
+
return context;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/toolbar/button/ToolbarButton.vue?vue&type=script&setup=true&lang.ts
|
|
223
|
+
/**
|
|
224
|
+
* A button that can be used as-is or as a trigger for other components.
|
|
225
|
+
* Renders a `<button>` element.
|
|
226
|
+
*
|
|
227
|
+
* Documentation: [Base UI Vue Toolbar](https://baseui-vue.com/docs/components/toolbar)
|
|
228
|
+
*/
|
|
229
|
+
var ToolbarButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
230
|
+
name: "ToolbarButton",
|
|
231
|
+
inheritAttrs: false,
|
|
232
|
+
__name: "ToolbarButton",
|
|
233
|
+
props: {
|
|
234
|
+
disabled: {
|
|
235
|
+
type: Boolean,
|
|
236
|
+
required: false,
|
|
237
|
+
default: false
|
|
238
|
+
},
|
|
239
|
+
focusableWhenDisabled: {
|
|
240
|
+
type: Boolean,
|
|
241
|
+
required: false,
|
|
242
|
+
default: true
|
|
243
|
+
},
|
|
244
|
+
nativeButton: {
|
|
245
|
+
type: Boolean,
|
|
246
|
+
required: false,
|
|
247
|
+
default: true
|
|
248
|
+
},
|
|
249
|
+
as: {
|
|
250
|
+
type: null,
|
|
251
|
+
required: false,
|
|
252
|
+
default: "button"
|
|
253
|
+
},
|
|
254
|
+
class: {
|
|
255
|
+
type: Function,
|
|
256
|
+
required: false,
|
|
257
|
+
skipCheck: true
|
|
258
|
+
},
|
|
259
|
+
style: {
|
|
260
|
+
type: [
|
|
261
|
+
Boolean,
|
|
262
|
+
null,
|
|
263
|
+
String,
|
|
264
|
+
Object,
|
|
265
|
+
Array,
|
|
266
|
+
Function
|
|
267
|
+
],
|
|
268
|
+
required: false,
|
|
269
|
+
skipCheck: true
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
setup(__props) {
|
|
273
|
+
const props = __props;
|
|
274
|
+
const attrs = useAttrs();
|
|
275
|
+
const toolbarRootContext = useToolbarRootContext();
|
|
276
|
+
const toolbarGroupContext = useToolbarGroupContext(true);
|
|
277
|
+
const disabled = computed(() => toolbarRootContext.disabled.value || (toolbarGroupContext?.disabled.value ?? false) || props.disabled);
|
|
278
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
279
|
+
disabled,
|
|
280
|
+
focusableWhenDisabled: () => props.focusableWhenDisabled,
|
|
281
|
+
native: () => props.nativeButton ?? true
|
|
282
|
+
});
|
|
283
|
+
const state = computed(() => ({
|
|
284
|
+
disabled: disabled.value,
|
|
285
|
+
orientation: toolbarRootContext.orientation.value,
|
|
286
|
+
focusable: props.focusableWhenDisabled
|
|
287
|
+
}));
|
|
288
|
+
const itemRefs = [buttonRef];
|
|
289
|
+
const componentProps = computed(() => typeof props.as === "string" ? {} : { disabled: disabled.value });
|
|
290
|
+
return (_ctx, _cache) => {
|
|
291
|
+
return openBlock(), createBlock(CompositeItem_default, {
|
|
292
|
+
as: __props.as,
|
|
293
|
+
class: normalizeClass(props.class),
|
|
294
|
+
style: normalizeStyle(props.style),
|
|
295
|
+
metadata: { focusableWhenDisabled: __props.focusableWhenDisabled },
|
|
296
|
+
state: state.value,
|
|
297
|
+
refs: itemRefs,
|
|
298
|
+
props: [componentProps.value, () => unref(getButtonProps)(unref(attrs))]
|
|
299
|
+
}, {
|
|
300
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
301
|
+
_: 3
|
|
302
|
+
}, 8, [
|
|
303
|
+
"as",
|
|
304
|
+
"class",
|
|
305
|
+
"style",
|
|
306
|
+
"metadata",
|
|
307
|
+
"state",
|
|
308
|
+
"props"
|
|
309
|
+
]);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/toolbar/button/ToolbarButton.vue
|
|
316
|
+
var ToolbarButton_default = ToolbarButton_vue_vue_type_script_setup_true_lang_default;
|
|
317
|
+
|
|
318
|
+
//#endregion
|
|
319
|
+
export { CompositeItem_default, ToolbarButton_default, compositeListContextKey, toolbarGroupContextKey, toolbarRootContextKey, useCompositeListItem, useToolbarGroupContext, useToolbarRootContext };
|
|
320
|
+
//# sourceMappingURL=ToolbarButton.js.map
|