@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
50 lines (47 loc) • 1.49 kB
JavaScript
import { defineComponent, mergeDefaults, createBlock, openBlock, unref, mergeProps, withCtx, renderSlot } from 'vue';
import { ark } from '../factory.js';
import { useSwitch } from './use-switch.js';
import { SwitchProvider } from './use-switch-context.js';
import { useForwardExpose } from '../../utils/use-forward-expose.js';
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "switch-root",
props: /* @__PURE__ */ mergeDefaults({
checked: { type: Boolean },
defaultChecked: { type: Boolean },
disabled: { type: Boolean },
form: {},
id: {},
ids: {},
invalid: { type: Boolean },
label: {},
name: {},
readOnly: { type: Boolean },
required: { type: Boolean },
value: {},
asChild: { type: Boolean }
}, {
checked: void 0,
defaultChecked: void 0,
disabled: void 0,
invalid: void 0,
readOnly: void 0,
required: void 0
}),
emits: ["checkedChange", "update:checked"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const context = useSwitch(props, emits);
SwitchProvider(context);
useForwardExpose();
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(ark).label, mergeProps(unref(context).getRootProps(), { "as-child": __props.asChild }), {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 16, ["as-child"]);
};
}
});
export { _sfc_main as default };