base-ui-vue 0.4.0 → 0.5.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/arrow/TooltipArrow.cjs +609 -0
- package/dist/arrow/TooltipArrow.cjs.map +1 -0
- package/dist/arrow/TooltipArrow.js +478 -0
- package/dist/arrow/TooltipArrow.js.map +1 -0
- package/dist/button/Button.cjs +5 -317
- package/dist/button/Button.cjs.map +1 -1
- package/dist/button/Button.js +3 -249
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ToolbarButton.cjs +13 -6
- package/dist/button/ToolbarButton.cjs.map +1 -1
- package/dist/button/ToolbarButton.js +3 -2
- package/dist/button/ToolbarButton.js.map +1 -1
- package/dist/checkbox/index.cjs +20 -9
- package/dist/checkbox/index.cjs.map +1 -1
- package/dist/checkbox/index.js +7 -2
- package/dist/checkbox/index.js.map +1 -1
- package/dist/checkbox-group/CheckboxGroup.cjs +14 -13
- package/dist/checkbox-group/CheckboxGroup.cjs.map +1 -1
- package/dist/checkbox-group/CheckboxGroup.js +2 -1
- package/dist/checkbox-group/CheckboxGroup.js.map +1 -1
- package/dist/components/FloatingPortal.cjs +66 -0
- package/dist/components/FloatingPortal.cjs.map +1 -0
- package/dist/components/FloatingPortal.js +55 -0
- package/dist/components/FloatingPortal.js.map +1 -0
- package/dist/components/FloatingRootStore.cjs +101 -0
- package/dist/components/FloatingRootStore.cjs.map +1 -0
- package/dist/components/FloatingRootStore.js +84 -0
- package/dist/components/FloatingRootStore.js.map +1 -0
- package/dist/components/FloatingTree.cjs +33 -0
- package/dist/components/FloatingTree.cjs.map +1 -0
- package/dist/components/FloatingTree.js +22 -0
- package/dist/components/FloatingTree.js.map +1 -0
- package/dist/composite/composite.cjs +6 -0
- package/dist/composite/composite.js +1 -1
- package/dist/content/ScrollAreaContent.cjs +3 -3
- package/dist/content/ScrollAreaContent.cjs.map +1 -1
- package/dist/content/ScrollAreaContent.js +1 -1
- package/dist/control/FieldControl.cjs +3 -3
- package/dist/control/FieldControl.cjs.map +1 -1
- package/dist/control/FieldControl.js +1 -1
- package/dist/control/SliderControl.cjs +3 -3
- package/dist/control/SliderControl.cjs.map +1 -1
- package/dist/control/SliderControl.js +1 -1
- package/dist/corner/ScrollAreaCorner.cjs +3 -3
- package/dist/corner/ScrollAreaCorner.cjs.map +1 -1
- package/dist/corner/ScrollAreaCorner.js +1 -1
- package/dist/decrement/NumberFieldDecrement.cjs +10 -3
- package/dist/decrement/NumberFieldDecrement.cjs.map +1 -1
- package/dist/decrement/NumberFieldDecrement.js +3 -2
- package/dist/decrement/NumberFieldDecrement.js.map +1 -1
- package/dist/description/FieldDescription.cjs +2 -2
- package/dist/description/FieldDescription.cjs.map +1 -1
- package/dist/description/FieldDescription.js +1 -1
- package/dist/error/FieldError.cjs +2 -2
- package/dist/error/FieldError.cjs.map +1 -1
- package/dist/error/FieldError.js +1 -1
- package/dist/fallback/AvatarFallback.cjs +2 -2
- package/dist/fallback/AvatarFallback.cjs.map +1 -1
- package/dist/fallback/AvatarFallback.js +1 -1
- package/dist/floating-ui-vue/index.js +638 -0
- package/dist/floating-ui-vue/index.js.map +1 -0
- package/dist/form/Form.cjs +3 -3
- package/dist/form/Form.cjs.map +1 -1
- package/dist/form/Form.js +1 -1
- package/dist/group/NumberFieldGroup.cjs +3 -3
- package/dist/group/NumberFieldGroup.cjs.map +1 -1
- package/dist/group/NumberFieldGroup.js +1 -1
- package/dist/group/ToolbarGroup.cjs +2 -2
- package/dist/group/ToolbarGroup.cjs.map +1 -1
- package/dist/group/ToolbarGroup.js +1 -1
- package/dist/header/AccordionHeader.cjs +2 -2
- package/dist/header/AccordionHeader.cjs.map +1 -1
- package/dist/header/AccordionHeader.js +1 -1
- package/dist/hooks/useDismiss.cjs +502 -0
- package/dist/hooks/useDismiss.cjs.map +1 -0
- package/dist/hooks/useHoverFloatingInteraction.cjs +233 -0
- package/dist/hooks/useHoverFloatingInteraction.cjs.map +1 -0
- package/dist/image/AvatarImage.cjs +4 -4
- package/dist/image/AvatarImage.cjs.map +1 -1
- package/dist/image/AvatarImage.js +1 -1
- package/dist/increment/NumberFieldIncrement.cjs +3 -2
- package/dist/increment/NumberFieldIncrement.cjs.map +1 -1
- package/dist/increment/NumberFieldIncrement.js +2 -1
- package/dist/increment/NumberFieldIncrement.js.map +1 -1
- package/dist/index.cjs +60 -7
- package/dist/index.d.cts +3838 -1726
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3838 -1726
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index2.cjs +7475 -3089
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +7215 -3106
- package/dist/index2.js.map +1 -1
- package/dist/rolldown-runtime.js +36 -0
- package/package.json +1 -1
- package/src/floating-ui-vue/components/FloatingPortal.ts +171 -0
- package/src/floating-ui-vue/components/FloatingPortal.vue +259 -0
- package/src/floating-ui-vue/components/FloatingRootStore.ts +83 -0
- package/src/floating-ui-vue/components/FloatingTree.ts +64 -0
- package/src/floating-ui-vue/components/FloatingTreeStore.ts +21 -0
- package/src/floating-ui-vue/hooks/useDismiss.ts +689 -0
- package/src/floating-ui-vue/hooks/useHoverFloatingInteraction.ts +244 -0
- package/src/floating-ui-vue/hooks/useHoverInteractionSharedState.ts +125 -0
- package/src/floating-ui-vue/hooks/useHoverShared.ts +53 -0
- package/src/floating-ui-vue/index.ts +48 -0
- package/src/floating-ui-vue/middleware/arrow.ts +114 -0
- package/src/floating-ui-vue/types.ts +117 -0
- package/src/floating-ui-vue/utils/composite.ts +20 -0
- package/src/floating-ui-vue/utils/constants.ts +2 -0
- package/src/floating-ui-vue/utils/createAttribute.ts +3 -0
- package/src/floating-ui-vue/utils/createEventEmitter.ts +20 -0
- package/src/floating-ui-vue/utils/element.ts +59 -0
- package/src/floating-ui-vue/utils/event.ts +15 -0
- package/src/floating-ui-vue/utils/nodes.ts +14 -0
- package/src/floating-ui-vue/utils/tabbable.ts +309 -0
- package/src/index.ts +4 -0
- package/src/radio/index.ts +28 -0
- package/src/radio/indicator/RadioIndicator.vue +90 -0
- package/src/radio/indicator/RadioIndicatorDataAttributes.ts +54 -0
- package/src/radio/root/RadioRoot.vue +544 -0
- package/src/radio/root/RadioRootContext.ts +18 -0
- package/src/radio/root/RadioRootDataAttributes.ts +46 -0
- package/src/radio/utils/stateAttributesMapping.ts +29 -0
- package/src/radio-group/RadioGroup.vue +381 -0
- package/src/radio-group/RadioGroupContext.ts +42 -0
- package/src/radio-group/RadioGroupDataAttributes.ts +6 -0
- package/src/radio-group/index.ts +10 -0
- package/src/tabs/index.ts +38 -0
- package/src/tabs/indicator/TabsIndicator.vue +201 -0
- package/src/tabs/indicator/TabsIndicatorCssVars.ts +26 -0
- package/src/tabs/indicator/TabsIndicatorDataAttributes.ts +12 -0
- package/src/tabs/indicator/prehydrationScript.min.ts +5 -0
- package/src/tabs/indicator/prehydrationScript.template.js +87 -0
- package/src/tabs/list/TabsList.vue +201 -0
- package/src/tabs/list/TabsListContext.ts +29 -0
- package/src/tabs/list/TabsListDataAttributes.ts +12 -0
- package/src/tabs/panel/TabsPanel.vue +167 -0
- package/src/tabs/panel/TabsPanelDataAttributes.ts +28 -0
- package/src/tabs/root/TabsRoot.vue +468 -0
- package/src/tabs/root/TabsRootContext.ts +56 -0
- package/src/tabs/root/TabsRootDataAttributes.ts +12 -0
- package/src/tabs/root/stateAttributesMapping.ts +9 -0
- package/src/tabs/tab/TabsTab.vue +274 -0
- package/src/tabs/tab/TabsTabDataAttributes.ts +20 -0
- package/src/tabs/utils/areTabValuesEqual.ts +6 -0
- package/src/tooltip/arrow/TooltipArrow.vue +116 -0
- package/src/tooltip/arrow/TooltipArrowDataAttributes.ts +31 -0
- package/src/tooltip/index.ts +54 -0
- package/src/tooltip/popup/TooltipPopup.vue +142 -0
- package/src/tooltip/popup/TooltipPopupDataAttributes.ts +35 -0
- package/src/tooltip/portal/TooltipPortal.vue +83 -0
- package/src/tooltip/portal/TooltipPortalContext.ts +19 -0
- package/src/tooltip/positioner/TooltipPositioner.vue +221 -0
- package/src/tooltip/positioner/TooltipPositionerContext.ts +23 -0
- package/src/tooltip/positioner/TooltipPositionerCssVars.ts +27 -0
- package/src/tooltip/positioner/TooltipPositionerDataAttributes.ts +26 -0
- package/src/tooltip/provider/TooltipProvider.vue +78 -0
- package/src/tooltip/provider/TooltipProviderContext.ts +19 -0
- package/src/tooltip/root/TooltipRoot.vue +401 -0
- package/src/tooltip/root/TooltipRootContext.ts +71 -0
- package/src/tooltip/store/TooltipHandle.ts +215 -0
- package/src/tooltip/trigger/TooltipTrigger.vue +343 -0
- package/src/tooltip/trigger/TooltipTriggerDataAttributes.ts +12 -0
- package/src/tooltip/utils/constants.ts +2 -0
- package/src/tooltip/viewport/TooltipViewport.vue +149 -0
- package/src/tooltip/viewport/TooltipViewportCssVars.ts +14 -0
- package/src/tooltip/viewport/TooltipViewportDataAttributes.ts +26 -0
- package/src/utils/FloatingPortalLite.vue +66 -0
- package/src/utils/FocusGuard.vue +36 -0
- package/src/utils/adaptiveOriginMiddleware.ts +79 -0
- package/src/utils/addEventListener.ts +16 -0
- package/src/utils/constants.ts +11 -0
- package/src/utils/createBaseUIEventDetails.ts +2 -0
- package/src/utils/getCssDimensions.ts +19 -0
- package/src/utils/getDisabledMountTransitionStyles.ts +9 -0
- package/src/utils/hideMiddleware.ts +19 -0
- package/src/utils/mergeCleanups.ts +7 -0
- package/src/utils/platform.ts +18 -0
- package/src/utils/popupStateMapping.ts +103 -0
- package/src/utils/reasons.ts +4 -0
- package/src/utils/serializeValue.ts +17 -0
- package/src/utils/useAnchorPositioning.ts +644 -0
- package/src/utils/usePopupAutoResize.ts +254 -0
- package/src/utils/usePopupViewport.ts +398 -0
- package/src/utils/usePositioner.ts +61 -0
- package/src/utils/useRenderElement.ts +3 -0
package/dist/button/Button.cjs
CHANGED
|
@@ -1,253 +1,7 @@
|
|
|
1
|
+
const require_arrow_TooltipArrow = require('../arrow/TooltipArrow.cjs');
|
|
1
2
|
let vue = require("vue");
|
|
2
3
|
let _floating_ui_utils_dom = require("@floating-ui/utils/dom");
|
|
3
4
|
|
|
4
|
-
//#region src/merge-props/mergeProps.ts
|
|
5
|
-
function makeEventPreventable(event) {
|
|
6
|
-
const baseUIEvent = event;
|
|
7
|
-
if (!baseUIEvent.preventBaseUIHandler) baseUIEvent.preventBaseUIHandler = () => {
|
|
8
|
-
baseUIEvent.baseUIHandlerPrevented = true;
|
|
9
|
-
};
|
|
10
|
-
return baseUIEvent;
|
|
11
|
-
}
|
|
12
|
-
function mergeClasses(ourClass, theirClass) {
|
|
13
|
-
if (theirClass) {
|
|
14
|
-
if (ourClass) return `${theirClass} ${ourClass}`;
|
|
15
|
-
return theirClass;
|
|
16
|
-
}
|
|
17
|
-
return ourClass;
|
|
18
|
-
}
|
|
19
|
-
function mergeObjects(a, b) {
|
|
20
|
-
if (a && !b) return a;
|
|
21
|
-
if (!a && b) return b;
|
|
22
|
-
if (a || b) return {
|
|
23
|
-
...a,
|
|
24
|
-
...b
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function isEventHandler(key, value) {
|
|
28
|
-
return key.startsWith("on") && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90 && (typeof value === "function" || Array.isArray(value) || typeof value === "undefined");
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Merges Vue prop/attr objects using Base UI Vue semantics.
|
|
32
|
-
*
|
|
33
|
-
* Later props overwrite earlier ones, except for:
|
|
34
|
-
* - Event listeners: merged so the rightmost listener runs first and can prevent earlier listeners.
|
|
35
|
-
* - `class`: merged in rightmost-first order.
|
|
36
|
-
* - `style`: merged using Vue's native style merging.
|
|
37
|
-
*/
|
|
38
|
-
function mergeProps(...args) {
|
|
39
|
-
const definedArgs = args.filter((arg) => arg != null);
|
|
40
|
-
const merged = (0, vue.mergeProps)(...definedArgs);
|
|
41
|
-
const classValue = mergeClassValues(definedArgs);
|
|
42
|
-
if (classValue !== void 0) merged.class = classValue;
|
|
43
|
-
for (const propName in merged) if (isEventHandler(propName, merged[propName])) merged[propName] = wrapEventHandlers(merged[propName]);
|
|
44
|
-
return merged;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Merges an array of Vue prop/attr objects using the same semantics as {@link mergeProps}.
|
|
48
|
-
*
|
|
49
|
-
* Useful when prop layers are assembled dynamically before being bound with `v-bind`.
|
|
50
|
-
*/
|
|
51
|
-
function mergePropsN(props) {
|
|
52
|
-
const definedProps = props.filter((prop) => prop != null);
|
|
53
|
-
if (definedProps.length === 0) return {};
|
|
54
|
-
return mergeProps(...definedProps);
|
|
55
|
-
}
|
|
56
|
-
function mergeClassValues(args) {
|
|
57
|
-
const classValues = args.map((props) => props?.class).filter((value) => value != null);
|
|
58
|
-
if (classValues.length === 0) return;
|
|
59
|
-
return (0, vue.normalizeClass)(classValues.reverse());
|
|
60
|
-
}
|
|
61
|
-
function wrapEventHandlers(handlers) {
|
|
62
|
-
if (Array.isArray(handlers)) {
|
|
63
|
-
const flatHandlers = handlers.flat(Infinity).filter((handler) => typeof handler === "function");
|
|
64
|
-
return (...args) => {
|
|
65
|
-
const preventableArgs = getPreventableArgs(args);
|
|
66
|
-
if (preventableArgs) {
|
|
67
|
-
let result;
|
|
68
|
-
for (let i = flatHandlers.length - 1; i >= 0; i -= 1) {
|
|
69
|
-
const handlerResult = flatHandlers[i](...preventableArgs.args);
|
|
70
|
-
if (result === void 0) result = handlerResult;
|
|
71
|
-
if (preventableArgs.event.baseUIHandlerPrevented) break;
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
let result;
|
|
76
|
-
for (let i = flatHandlers.length - 1; i >= 0; i -= 1) {
|
|
77
|
-
const handlerResult = flatHandlers[i](...args);
|
|
78
|
-
if (result === void 0) result = handlerResult;
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (typeof handlers !== "function") return handlers;
|
|
84
|
-
return (...args) => {
|
|
85
|
-
const preventableArgs = getPreventableArgs(args);
|
|
86
|
-
if (preventableArgs) return handlers(...preventableArgs.args);
|
|
87
|
-
return handlers(...args);
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function getPreventableArgs(args) {
|
|
91
|
-
const eventIndex = args.findIndex(isPreventableEventArg);
|
|
92
|
-
if (eventIndex === -1) return null;
|
|
93
|
-
const nextArgs = [...args];
|
|
94
|
-
const event = makeEventPreventable(nextArgs[eventIndex]);
|
|
95
|
-
nextArgs[eventIndex] = event;
|
|
96
|
-
return {
|
|
97
|
-
args: nextArgs,
|
|
98
|
-
event
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function isPreventableEventArg(value) {
|
|
102
|
-
return Boolean(value && typeof value === "object" && (value instanceof Event || "nativeEvent" in value || "preventBaseUIHandler" in value));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region src/utils/empty.ts
|
|
107
|
-
function NOOP() {}
|
|
108
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
109
|
-
const EMPTY_OBJECT = Object.freeze({});
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/utils/getStateAttributesProps.ts
|
|
113
|
-
function getStateAttributesProps(state, customMapping) {
|
|
114
|
-
const props = {};
|
|
115
|
-
for (const key in state) {
|
|
116
|
-
const value = state[key];
|
|
117
|
-
if (customMapping && Object.prototype.hasOwnProperty.call(customMapping, key)) {
|
|
118
|
-
const customProps = customMapping[key](value);
|
|
119
|
-
if (customProps != null) Object.assign(props, customProps);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (value === true) props[`data-${key.toLowerCase()}`] = "";
|
|
123
|
-
else if (value !== false && value != null) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
124
|
-
}
|
|
125
|
-
return props;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/utils/slot.ts
|
|
130
|
-
/**
|
|
131
|
-
* Pass as the `as` prop to make a component renderless.
|
|
132
|
-
*/
|
|
133
|
-
const Slot = Symbol("Slot");
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/utils/useMergedRefs.ts
|
|
137
|
-
/**
|
|
138
|
-
* Merges multiple refs or ref callbacks into a single template ref callback.
|
|
139
|
-
* Returns `undefined` when all input refs are nullish (optimization to avoid no-op callbacks).
|
|
140
|
-
*
|
|
141
|
-
* Supports cleanup callbacks: if a callback ref returns a function, it will be
|
|
142
|
-
* called on unmount (when the ref receives `null`) instead of calling the
|
|
143
|
-
* callback with `null` directly.
|
|
144
|
-
*
|
|
145
|
-
* Vue-specific: automatically unwraps `ComponentPublicInstance` to its root `$el`,
|
|
146
|
-
* since Vue template refs on components return the instance, not the DOM element.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```vue
|
|
150
|
-
* <script setup>
|
|
151
|
-
* const internalRef = ref(null)
|
|
152
|
-
* const externalRef = ref(null)
|
|
153
|
-
*
|
|
154
|
-
* const mergedRef = useMergedRefs(internalRef, externalRef)
|
|
155
|
-
* <\/script>
|
|
156
|
-
*
|
|
157
|
-
* <template>
|
|
158
|
-
* <div :ref="mergedRef"></div>
|
|
159
|
-
* </template>
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
function useMergedRefs(...refs) {
|
|
163
|
-
if (refs.every((ref) => ref == null)) return;
|
|
164
|
-
const cleanupCallbacks = Array.from({ length: refs.length }, () => null);
|
|
165
|
-
return (el) => {
|
|
166
|
-
const instance = resolveRefTarget(el);
|
|
167
|
-
if (instance != null) for (let i = 0; i < refs.length; i += 1) {
|
|
168
|
-
const ref = refs[i];
|
|
169
|
-
if (ref == null) continue;
|
|
170
|
-
if (typeof ref === "function") {
|
|
171
|
-
const refCleanup = ref(instance);
|
|
172
|
-
if (typeof refCleanup === "function") cleanupCallbacks[i] = refCleanup;
|
|
173
|
-
} else if ("value" in ref) ref.value = instance;
|
|
174
|
-
}
|
|
175
|
-
else for (let i = 0; i < refs.length; i += 1) {
|
|
176
|
-
const ref = refs[i];
|
|
177
|
-
if (ref == null) continue;
|
|
178
|
-
if (typeof ref === "function") {
|
|
179
|
-
const cleanupCallback = cleanupCallbacks[i];
|
|
180
|
-
if (typeof cleanupCallback === "function") {
|
|
181
|
-
cleanupCallback();
|
|
182
|
-
cleanupCallbacks[i] = null;
|
|
183
|
-
} else ref(null);
|
|
184
|
-
} else if ("value" in ref) ref.value = null;
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function resolveRefTarget(el) {
|
|
189
|
-
if (el == null) return null;
|
|
190
|
-
if (el instanceof Element) return el;
|
|
191
|
-
if (typeof el === "object" && "element" in el) {
|
|
192
|
-
const exposedElement = (0, vue.unref)(el.element);
|
|
193
|
-
if (exposedElement instanceof Element) return exposedElement;
|
|
194
|
-
}
|
|
195
|
-
if ("$el" in el) return el.$el;
|
|
196
|
-
return el;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/utils/useRenderElement.ts
|
|
201
|
-
/**
|
|
202
|
-
* Renders a Base UI element (internal composable).
|
|
203
|
-
*
|
|
204
|
-
* Assembles state-to-data-attribute conversion, class/style resolution,
|
|
205
|
-
* and ref wrapping into a single composable used by all polymorphic components.
|
|
206
|
-
*
|
|
207
|
-
* @param params - The render element parameters.
|
|
208
|
-
*/
|
|
209
|
-
function useRenderElement(params) {
|
|
210
|
-
const renderless = (0, vue.computed)(() => params.componentProps.as === Slot);
|
|
211
|
-
return {
|
|
212
|
-
tag: (0, vue.computed)(() => {
|
|
213
|
-
if (renderless.value) return;
|
|
214
|
-
return params.componentProps.as ?? params.defaultTagName ?? "div";
|
|
215
|
-
}),
|
|
216
|
-
mergedProps: (0, vue.computed)(() => {
|
|
217
|
-
const state = (0, vue.unref)(params.state);
|
|
218
|
-
const rawProps = (0, vue.unref)(params.props) ?? EMPTY_OBJECT;
|
|
219
|
-
const merged = {
|
|
220
|
-
...getStateAttributesProps(state, params.stateAttributesMapping),
|
|
221
|
-
...rawProps
|
|
222
|
-
};
|
|
223
|
-
const resolvedClass = typeof params.componentProps.class === "function" ? params.componentProps.class(state) : params.componentProps.class;
|
|
224
|
-
const resolvedStyle = typeof params.componentProps.style === "function" ? params.componentProps.style(state) : params.componentProps.style;
|
|
225
|
-
if (resolvedClass !== void 0) merged.class = normalizeClass(merged.class, resolvedClass);
|
|
226
|
-
if (resolvedStyle !== void 0) merged.style = normalizeStyle(merged.style, resolvedStyle);
|
|
227
|
-
return merged;
|
|
228
|
-
}),
|
|
229
|
-
renderless,
|
|
230
|
-
state: params.state,
|
|
231
|
-
ref: params.ref ? useMergedRefs(params.ref) : void 0
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function normalizeClass(currentValue, nextValue) {
|
|
235
|
-
if (currentValue == null) return nextValue;
|
|
236
|
-
if (nextValue == null) return currentValue;
|
|
237
|
-
if (typeof currentValue === "string" && typeof nextValue === "string") return mergeClasses(currentValue, nextValue);
|
|
238
|
-
return [currentValue, nextValue];
|
|
239
|
-
}
|
|
240
|
-
function normalizeStyle(currentValue, nextValue) {
|
|
241
|
-
if (currentValue == null) return nextValue;
|
|
242
|
-
if (nextValue == null) return currentValue;
|
|
243
|
-
if (isPlainObject(currentValue) && isPlainObject(nextValue)) return mergeObjects(currentValue, nextValue);
|
|
244
|
-
return [currentValue, nextValue];
|
|
245
|
-
}
|
|
246
|
-
function isPlainObject(value) {
|
|
247
|
-
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
5
|
//#region src/utils/error.ts
|
|
252
6
|
let set;
|
|
253
7
|
if (process.env.NODE_ENV !== "production") set = /* @__PURE__ */ new Set();
|
|
@@ -323,7 +77,7 @@ function useButton(parameters = {}) {
|
|
|
323
77
|
const { onClick: externalOnClick, onMousedown: externalOnMousedown, onKeydown: externalOnKeydown, onKeyup: externalOnKeyup, onPointerdown: externalOnPointerdown, ...otherExternalProps } = externalProps;
|
|
324
78
|
const disabled = (0, vue.toValue)(parameters.disabled) ?? false;
|
|
325
79
|
const isNativeButton = (0, vue.toValue)(parameters.native) ?? true;
|
|
326
|
-
return mergeProps({
|
|
80
|
+
return require_arrow_TooltipArrow.mergeProps({
|
|
327
81
|
type: isNativeButton ? "button" : void 0,
|
|
328
82
|
onClick(event) {
|
|
329
83
|
if (disabled) {
|
|
@@ -337,7 +91,7 @@ function useButton(parameters = {}) {
|
|
|
337
91
|
},
|
|
338
92
|
onKeydown(event) {
|
|
339
93
|
if (disabled) return;
|
|
340
|
-
makeEventPreventable(event);
|
|
94
|
+
require_arrow_TooltipArrow.makeEventPreventable(event);
|
|
341
95
|
externalOnKeydown?.(event);
|
|
342
96
|
if (event.baseUIHandlerPrevented) return;
|
|
343
97
|
if (event.target === event.currentTarget && !isNativeButton && !isValidLinkElement(buttonRef.value)) {
|
|
@@ -348,7 +102,7 @@ function useButton(parameters = {}) {
|
|
|
348
102
|
},
|
|
349
103
|
onKeyup(event) {
|
|
350
104
|
if (disabled) return;
|
|
351
|
-
makeEventPreventable(event);
|
|
105
|
+
require_arrow_TooltipArrow.makeEventPreventable(event);
|
|
352
106
|
externalOnKeyup?.(event);
|
|
353
107
|
if (event.baseUIHandlerPrevented) return;
|
|
354
108
|
if (event.target === event.currentTarget && !isNativeButton && event.key === " ") externalOnClick?.(event);
|
|
@@ -431,7 +185,7 @@ var Button_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue
|
|
|
431
185
|
})
|
|
432
186
|
});
|
|
433
187
|
const state = (0, vue.computed)(() => ({ disabled: props.disabled }));
|
|
434
|
-
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
188
|
+
const { tag, mergedProps, renderless, ref: renderRef } = require_arrow_TooltipArrow.useRenderElement({
|
|
435
189
|
componentProps: props,
|
|
436
190
|
state,
|
|
437
191
|
props: (0, vue.computed)(() => getButtonProps({ ...attrs })),
|
|
@@ -466,30 +220,6 @@ Object.defineProperty(exports, 'Button_default', {
|
|
|
466
220
|
return Button_default;
|
|
467
221
|
}
|
|
468
222
|
});
|
|
469
|
-
Object.defineProperty(exports, 'EMPTY_ARRAY', {
|
|
470
|
-
enumerable: true,
|
|
471
|
-
get: function () {
|
|
472
|
-
return EMPTY_ARRAY;
|
|
473
|
-
}
|
|
474
|
-
});
|
|
475
|
-
Object.defineProperty(exports, 'EMPTY_OBJECT', {
|
|
476
|
-
enumerable: true,
|
|
477
|
-
get: function () {
|
|
478
|
-
return EMPTY_OBJECT;
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
Object.defineProperty(exports, 'NOOP', {
|
|
482
|
-
enumerable: true,
|
|
483
|
-
get: function () {
|
|
484
|
-
return NOOP;
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
Object.defineProperty(exports, 'Slot', {
|
|
488
|
-
enumerable: true,
|
|
489
|
-
get: function () {
|
|
490
|
-
return Slot;
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
223
|
Object.defineProperty(exports, 'compositeRootContextKey', {
|
|
494
224
|
enumerable: true,
|
|
495
225
|
get: function () {
|
|
@@ -502,36 +232,6 @@ Object.defineProperty(exports, 'error', {
|
|
|
502
232
|
return error;
|
|
503
233
|
}
|
|
504
234
|
});
|
|
505
|
-
Object.defineProperty(exports, 'makeEventPreventable', {
|
|
506
|
-
enumerable: true,
|
|
507
|
-
get: function () {
|
|
508
|
-
return makeEventPreventable;
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
Object.defineProperty(exports, 'mergeClasses', {
|
|
512
|
-
enumerable: true,
|
|
513
|
-
get: function () {
|
|
514
|
-
return mergeClasses;
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
Object.defineProperty(exports, 'mergeObjects', {
|
|
518
|
-
enumerable: true,
|
|
519
|
-
get: function () {
|
|
520
|
-
return mergeObjects;
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
Object.defineProperty(exports, 'mergeProps', {
|
|
524
|
-
enumerable: true,
|
|
525
|
-
get: function () {
|
|
526
|
-
return mergeProps;
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
Object.defineProperty(exports, 'mergePropsN', {
|
|
530
|
-
enumerable: true,
|
|
531
|
-
get: function () {
|
|
532
|
-
return mergePropsN;
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
235
|
Object.defineProperty(exports, 'useButton', {
|
|
536
236
|
enumerable: true,
|
|
537
237
|
get: function () {
|
|
@@ -550,16 +250,4 @@ Object.defineProperty(exports, 'useFocusableWhenDisabled', {
|
|
|
550
250
|
return useFocusableWhenDisabled;
|
|
551
251
|
}
|
|
552
252
|
});
|
|
553
|
-
Object.defineProperty(exports, 'useMergedRefs', {
|
|
554
|
-
enumerable: true,
|
|
555
|
-
get: function () {
|
|
556
|
-
return useMergedRefs;
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
Object.defineProperty(exports, 'useRenderElement', {
|
|
560
|
-
enumerable: true,
|
|
561
|
-
get: function () {
|
|
562
|
-
return useRenderElement;
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
253
|
//# sourceMappingURL=Button.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.cjs","names":[],"sources":["../../src/
|
|
1
|
+
{"version":3,"file":"Button.cjs","names":["mergeProps"],"sources":["../../src/utils/error.ts","../../src/composite/root/CompositeRootContext.ts","../../src/utils/useFocusableWhenDisabled.ts","../../src/use-button/useButton.ts","../../src/button/Button.vue","../../src/button/Button.vue"],"sourcesContent":[],"mappings":";;;;;AACA,IAAI;AACJ,IAAI,QAAQ,IAAI,aAAa,aAC3B,uBAAM,IAAI,KAAa;AAGzB,SAAgB,MAAM,GAAG,UAAoB;AAC3C,KAAI,QAAQ,IAAI,aAAa,cAAc;EACzC,MAAM,aAAa,SAAS,KAAK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QAAA,WAAA,EAAhB,OAAO,MAAA,OAAK,CAAA"}
|
package/dist/button/Button.js
CHANGED
|
@@ -1,253 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeEventPreventable, mergeProps as mergeProps$1, useRenderElement } from "../arrow/TooltipArrow.js";
|
|
2
|
+
import { computed, createBlock, createCommentVNode, defineComponent, inject, mergeProps, openBlock, ref, renderSlot, resolveDynamicComponent, toValue, unref, useAttrs, watchEffect, withCtx } from "vue";
|
|
2
3
|
import { isHTMLElement } from "@floating-ui/utils/dom";
|
|
3
4
|
|
|
4
|
-
//#region src/merge-props/mergeProps.ts
|
|
5
|
-
function makeEventPreventable(event) {
|
|
6
|
-
const baseUIEvent = event;
|
|
7
|
-
if (!baseUIEvent.preventBaseUIHandler) baseUIEvent.preventBaseUIHandler = () => {
|
|
8
|
-
baseUIEvent.baseUIHandlerPrevented = true;
|
|
9
|
-
};
|
|
10
|
-
return baseUIEvent;
|
|
11
|
-
}
|
|
12
|
-
function mergeClasses(ourClass, theirClass) {
|
|
13
|
-
if (theirClass) {
|
|
14
|
-
if (ourClass) return `${theirClass} ${ourClass}`;
|
|
15
|
-
return theirClass;
|
|
16
|
-
}
|
|
17
|
-
return ourClass;
|
|
18
|
-
}
|
|
19
|
-
function mergeObjects(a, b) {
|
|
20
|
-
if (a && !b) return a;
|
|
21
|
-
if (!a && b) return b;
|
|
22
|
-
if (a || b) return {
|
|
23
|
-
...a,
|
|
24
|
-
...b
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function isEventHandler(key, value) {
|
|
28
|
-
return key.startsWith("on") && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90 && (typeof value === "function" || Array.isArray(value) || typeof value === "undefined");
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Merges Vue prop/attr objects using Base UI Vue semantics.
|
|
32
|
-
*
|
|
33
|
-
* Later props overwrite earlier ones, except for:
|
|
34
|
-
* - Event listeners: merged so the rightmost listener runs first and can prevent earlier listeners.
|
|
35
|
-
* - `class`: merged in rightmost-first order.
|
|
36
|
-
* - `style`: merged using Vue's native style merging.
|
|
37
|
-
*/
|
|
38
|
-
function mergeProps$1(...args) {
|
|
39
|
-
const definedArgs = args.filter((arg) => arg != null);
|
|
40
|
-
const merged = mergeProps(...definedArgs);
|
|
41
|
-
const classValue = mergeClassValues(definedArgs);
|
|
42
|
-
if (classValue !== void 0) merged.class = classValue;
|
|
43
|
-
for (const propName in merged) if (isEventHandler(propName, merged[propName])) merged[propName] = wrapEventHandlers(merged[propName]);
|
|
44
|
-
return merged;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Merges an array of Vue prop/attr objects using the same semantics as {@link mergeProps}.
|
|
48
|
-
*
|
|
49
|
-
* Useful when prop layers are assembled dynamically before being bound with `v-bind`.
|
|
50
|
-
*/
|
|
51
|
-
function mergePropsN(props) {
|
|
52
|
-
const definedProps = props.filter((prop) => prop != null);
|
|
53
|
-
if (definedProps.length === 0) return {};
|
|
54
|
-
return mergeProps$1(...definedProps);
|
|
55
|
-
}
|
|
56
|
-
function mergeClassValues(args) {
|
|
57
|
-
const classValues = args.map((props) => props?.class).filter((value) => value != null);
|
|
58
|
-
if (classValues.length === 0) return;
|
|
59
|
-
return normalizeClass(classValues.reverse());
|
|
60
|
-
}
|
|
61
|
-
function wrapEventHandlers(handlers) {
|
|
62
|
-
if (Array.isArray(handlers)) {
|
|
63
|
-
const flatHandlers = handlers.flat(Infinity).filter((handler) => typeof handler === "function");
|
|
64
|
-
return (...args) => {
|
|
65
|
-
const preventableArgs = getPreventableArgs(args);
|
|
66
|
-
if (preventableArgs) {
|
|
67
|
-
let result;
|
|
68
|
-
for (let i = flatHandlers.length - 1; i >= 0; i -= 1) {
|
|
69
|
-
const handlerResult = flatHandlers[i](...preventableArgs.args);
|
|
70
|
-
if (result === void 0) result = handlerResult;
|
|
71
|
-
if (preventableArgs.event.baseUIHandlerPrevented) break;
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
let result;
|
|
76
|
-
for (let i = flatHandlers.length - 1; i >= 0; i -= 1) {
|
|
77
|
-
const handlerResult = flatHandlers[i](...args);
|
|
78
|
-
if (result === void 0) result = handlerResult;
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (typeof handlers !== "function") return handlers;
|
|
84
|
-
return (...args) => {
|
|
85
|
-
const preventableArgs = getPreventableArgs(args);
|
|
86
|
-
if (preventableArgs) return handlers(...preventableArgs.args);
|
|
87
|
-
return handlers(...args);
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function getPreventableArgs(args) {
|
|
91
|
-
const eventIndex = args.findIndex(isPreventableEventArg);
|
|
92
|
-
if (eventIndex === -1) return null;
|
|
93
|
-
const nextArgs = [...args];
|
|
94
|
-
const event = makeEventPreventable(nextArgs[eventIndex]);
|
|
95
|
-
nextArgs[eventIndex] = event;
|
|
96
|
-
return {
|
|
97
|
-
args: nextArgs,
|
|
98
|
-
event
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function isPreventableEventArg(value) {
|
|
102
|
-
return Boolean(value && typeof value === "object" && (value instanceof Event || "nativeEvent" in value || "preventBaseUIHandler" in value));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region src/utils/empty.ts
|
|
107
|
-
function NOOP() {}
|
|
108
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
109
|
-
const EMPTY_OBJECT = Object.freeze({});
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/utils/getStateAttributesProps.ts
|
|
113
|
-
function getStateAttributesProps(state, customMapping) {
|
|
114
|
-
const props = {};
|
|
115
|
-
for (const key in state) {
|
|
116
|
-
const value = state[key];
|
|
117
|
-
if (customMapping && Object.prototype.hasOwnProperty.call(customMapping, key)) {
|
|
118
|
-
const customProps = customMapping[key](value);
|
|
119
|
-
if (customProps != null) Object.assign(props, customProps);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (value === true) props[`data-${key.toLowerCase()}`] = "";
|
|
123
|
-
else if (value !== false && value != null) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
124
|
-
}
|
|
125
|
-
return props;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/utils/slot.ts
|
|
130
|
-
/**
|
|
131
|
-
* Pass as the `as` prop to make a component renderless.
|
|
132
|
-
*/
|
|
133
|
-
const Slot = Symbol("Slot");
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/utils/useMergedRefs.ts
|
|
137
|
-
/**
|
|
138
|
-
* Merges multiple refs or ref callbacks into a single template ref callback.
|
|
139
|
-
* Returns `undefined` when all input refs are nullish (optimization to avoid no-op callbacks).
|
|
140
|
-
*
|
|
141
|
-
* Supports cleanup callbacks: if a callback ref returns a function, it will be
|
|
142
|
-
* called on unmount (when the ref receives `null`) instead of calling the
|
|
143
|
-
* callback with `null` directly.
|
|
144
|
-
*
|
|
145
|
-
* Vue-specific: automatically unwraps `ComponentPublicInstance` to its root `$el`,
|
|
146
|
-
* since Vue template refs on components return the instance, not the DOM element.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```vue
|
|
150
|
-
* <script setup>
|
|
151
|
-
* const internalRef = ref(null)
|
|
152
|
-
* const externalRef = ref(null)
|
|
153
|
-
*
|
|
154
|
-
* const mergedRef = useMergedRefs(internalRef, externalRef)
|
|
155
|
-
* <\/script>
|
|
156
|
-
*
|
|
157
|
-
* <template>
|
|
158
|
-
* <div :ref="mergedRef"></div>
|
|
159
|
-
* </template>
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
function useMergedRefs(...refs) {
|
|
163
|
-
if (refs.every((ref) => ref == null)) return;
|
|
164
|
-
const cleanupCallbacks = Array.from({ length: refs.length }, () => null);
|
|
165
|
-
return (el) => {
|
|
166
|
-
const instance = resolveRefTarget(el);
|
|
167
|
-
if (instance != null) for (let i = 0; i < refs.length; i += 1) {
|
|
168
|
-
const ref = refs[i];
|
|
169
|
-
if (ref == null) continue;
|
|
170
|
-
if (typeof ref === "function") {
|
|
171
|
-
const refCleanup = ref(instance);
|
|
172
|
-
if (typeof refCleanup === "function") cleanupCallbacks[i] = refCleanup;
|
|
173
|
-
} else if ("value" in ref) ref.value = instance;
|
|
174
|
-
}
|
|
175
|
-
else for (let i = 0; i < refs.length; i += 1) {
|
|
176
|
-
const ref = refs[i];
|
|
177
|
-
if (ref == null) continue;
|
|
178
|
-
if (typeof ref === "function") {
|
|
179
|
-
const cleanupCallback = cleanupCallbacks[i];
|
|
180
|
-
if (typeof cleanupCallback === "function") {
|
|
181
|
-
cleanupCallback();
|
|
182
|
-
cleanupCallbacks[i] = null;
|
|
183
|
-
} else ref(null);
|
|
184
|
-
} else if ("value" in ref) ref.value = null;
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function resolveRefTarget(el) {
|
|
189
|
-
if (el == null) return null;
|
|
190
|
-
if (el instanceof Element) return el;
|
|
191
|
-
if (typeof el === "object" && "element" in el) {
|
|
192
|
-
const exposedElement = unref(el.element);
|
|
193
|
-
if (exposedElement instanceof Element) return exposedElement;
|
|
194
|
-
}
|
|
195
|
-
if ("$el" in el) return el.$el;
|
|
196
|
-
return el;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/utils/useRenderElement.ts
|
|
201
|
-
/**
|
|
202
|
-
* Renders a Base UI element (internal composable).
|
|
203
|
-
*
|
|
204
|
-
* Assembles state-to-data-attribute conversion, class/style resolution,
|
|
205
|
-
* and ref wrapping into a single composable used by all polymorphic components.
|
|
206
|
-
*
|
|
207
|
-
* @param params - The render element parameters.
|
|
208
|
-
*/
|
|
209
|
-
function useRenderElement(params) {
|
|
210
|
-
const renderless = computed(() => params.componentProps.as === Slot);
|
|
211
|
-
return {
|
|
212
|
-
tag: computed(() => {
|
|
213
|
-
if (renderless.value) return;
|
|
214
|
-
return params.componentProps.as ?? params.defaultTagName ?? "div";
|
|
215
|
-
}),
|
|
216
|
-
mergedProps: computed(() => {
|
|
217
|
-
const state = unref(params.state);
|
|
218
|
-
const rawProps = unref(params.props) ?? EMPTY_OBJECT;
|
|
219
|
-
const merged = {
|
|
220
|
-
...getStateAttributesProps(state, params.stateAttributesMapping),
|
|
221
|
-
...rawProps
|
|
222
|
-
};
|
|
223
|
-
const resolvedClass = typeof params.componentProps.class === "function" ? params.componentProps.class(state) : params.componentProps.class;
|
|
224
|
-
const resolvedStyle = typeof params.componentProps.style === "function" ? params.componentProps.style(state) : params.componentProps.style;
|
|
225
|
-
if (resolvedClass !== void 0) merged.class = normalizeClass$1(merged.class, resolvedClass);
|
|
226
|
-
if (resolvedStyle !== void 0) merged.style = normalizeStyle$1(merged.style, resolvedStyle);
|
|
227
|
-
return merged;
|
|
228
|
-
}),
|
|
229
|
-
renderless,
|
|
230
|
-
state: params.state,
|
|
231
|
-
ref: params.ref ? useMergedRefs(params.ref) : void 0
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function normalizeClass$1(currentValue, nextValue) {
|
|
235
|
-
if (currentValue == null) return nextValue;
|
|
236
|
-
if (nextValue == null) return currentValue;
|
|
237
|
-
if (typeof currentValue === "string" && typeof nextValue === "string") return mergeClasses(currentValue, nextValue);
|
|
238
|
-
return [currentValue, nextValue];
|
|
239
|
-
}
|
|
240
|
-
function normalizeStyle$1(currentValue, nextValue) {
|
|
241
|
-
if (currentValue == null) return nextValue;
|
|
242
|
-
if (nextValue == null) return currentValue;
|
|
243
|
-
if (isPlainObject(currentValue) && isPlainObject(nextValue)) return mergeObjects(currentValue, nextValue);
|
|
244
|
-
return [currentValue, nextValue];
|
|
245
|
-
}
|
|
246
|
-
function isPlainObject(value) {
|
|
247
|
-
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
5
|
//#region src/utils/error.ts
|
|
252
6
|
let set;
|
|
253
7
|
if (process.env.NODE_ENV !== "production") set = /* @__PURE__ */ new Set();
|
|
@@ -460,5 +214,5 @@ var Button_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
460
214
|
var Button_default = Button_vue_vue_type_script_setup_true_lang_default;
|
|
461
215
|
|
|
462
216
|
//#endregion
|
|
463
|
-
export { Button_default,
|
|
217
|
+
export { Button_default, compositeRootContextKey, error, useButton, useCompositeRootContext, useFocusableWhenDisabled };
|
|
464
218
|
//# sourceMappingURL=Button.js.map
|