UNPKG

tav-ui

Version:
54 lines (51 loc) 1.85 kB
import { ref, useAttrs, toRefs, provide, reactive, renderSlot, normalizeProps, guardReactiveProps, unref, defineComponent } from 'vue'; import { permissionsContextKey } from '../constants2.mjs'; import { DEFAULT_PERMISSIONS_ID, DEFAULT_PERMISSIONS_CLASSNAME } from './constants2.mjs'; import { pagePermissionProps } from './types2.mjs'; import _export_sfc from '../../../../../_virtual/plugin-vue_export-helper.mjs'; const __default__ = { name: "TaPermissions" }; function setup(__props, { expose }) { const props = __props; const id = ref(DEFAULT_PERMISSIONS_ID()); const type = ref(DEFAULT_PERMISSIONS_CLASSNAME); const attrs = useAttrs(); const { disabled } = toRefs(props); const permissionsContext = []; const getPermission = (id2) => { return permissionsContext.find((permissionContext) => permissionContext.id === id2); }; const addPermission = (permissionContext) => { permissionsContext.push(permissionContext); }; const removePermission = (permissionContext) => { if (permissionContext.id) { permissionsContext.splice(permissionsContext.indexOf(permissionContext), 1); } }; provide(permissionsContextKey, reactive({ id, type, disabled, getPermission, addPermission, removePermission })); expose({ id, permissionsContext, getPermission }); return (_ctx, _cache) => { return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ ...toRefs(props), ...unref(attrs) }))); }; } const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: pagePermissionProps, setup }); var Permissions = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/permission/src/Permissions/index.vue"]]); export { Permissions as default }; //# sourceMappingURL=index2.mjs.map