{"version":3,"file":"fullerstack-ngx-menu.mjs","sources":["../../../../libs/ngx-menu/src/lib/menu.model.ts","../../../../libs/ngx-menu/src/lib/menu.default.ts","../../../../libs/ngx-menu/src/lib/menu.util.ts","../../../../libs/ngx-menu/src/lib/menu.module.ts","../../../../libs/ngx-menu/src/lib/menu.service.ts","../../../../libs/ngx-menu/src/fullerstack-ngx-menu.ts"],"sourcesContent":["/**\n * @license\n * Copyright Neekware Inc. All Rights Reserved.\n *\n * Use of this source code is governed by a proprietary notice\n * that can be found at http://neekware.com/license/PRI.html\n */\n\nexport interface MenuItem {\n  // translatable name of this menu\n  name: string;\n  // icon for the menu\n  icon?: string;\n  // if link (clickable)\n  link?: string;\n  // hides menu, navigation, popups (ex: calendar page is fullspan)\n  fullspan?: boolean;\n  // if true, this will be a fullscreen page\n  fullscreen?: boolean;\n  // if true, this will be a fullscreen page without header and footer\n  headless?: boolean;\n  // if external link\n  external?: boolean;\n  // open in new tab (_blank)\n  target?: string;\n  // if menu is disabled\n  disabled?: boolean;\n  // if menu is allowed (permission) - for manual override\n  allowed?: boolean;\n  // permissions required to render this menu\n  permissions?: string[];\n  // submenu\n  children?: MenuItem[];\n}\n\n/** Signature function for whether menu item is allowed to be rendered */\nexport type PermissionVerificationFuncType = (item: MenuItem) => boolean;\n","/**\n * @license\n * Copyright Neekware Inc. All Rights Reserved.\n *\n * Use of this source code is governed by a proprietary notice\n * that can be found at http://neekware.com/license/PRI.html\n */\n\nimport { MenuNode } from './menu.util';\n\n/**\n * Default Menu Tree (placeholder)\n */\nexport const DefaultMenuTree: MenuNode[] = [\n  {\n    name: 'Home',\n    icon: 'home',\n    link: '/',\n  } as MenuNode,\n];\n","/**\n * @license\n * Copyright Neekware Inc. All Rights Reserved.\n *\n * Use of this source code is governed by a proprietary notice\n * that can be found at http://neekware.com/license/PRI.html\n */\n\nimport { MenuItem } from './menu.model';\n\nexport class MenuNode implements MenuItem {\n  name: string = null;\n  icon: string = null;\n  link: string = null;\n  target = null;\n  external = false;\n  fullspan = false;\n  fullscreen = false;\n  headless = false;\n  allowed = true;\n  disabled = false;\n  permissions: string[] = [];\n\n  parent: MenuNode = null;\n  children: MenuNode[] = [];\n\n  level = 0;\n\n  constructor(params: MenuItem) {\n    for (const attr in params) {\n      if (attr !== 'children') {\n        if (Object.prototype.hasOwnProperty.call(params, attr)) {\n          if (Object.prototype.hasOwnProperty.call(this, attr)) {\n            this[attr] = params[attr];\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * @returns true if node is a `link` type\n   */\n  get isLink(): boolean {\n    if (this.link && this.link.length) {\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * @returns true if node is not a link\n   */\n  get isNode(): boolean {\n    return !this.isLink;\n  }\n\n  /**\n   * @returns true if node has children\n   */\n  get hasChildren(): boolean {\n    return this.children.length !== 0;\n  }\n\n  /**\n   * @returns true if node is external link (ex: 'www.youtube.com')\n   */\n  get isExternalLink(): boolean {\n    return this.isLink && this.external;\n  }\n\n  /**\n   * @returns true if node is internal link (ex: '/auth/login')\n   */\n  get isInternalLink(): boolean {\n    return this.isLink && !this.external;\n  }\n\n  /**\n   * @returns true if node is link that hinds the menu on click\n   */\n  get isFullSpan(): boolean {\n    return this.isLink && this.fullspan;\n  }\n\n  /**\n   * @returns true if node is a link that requires the header/footer to be hidden\n   */\n  get isFullScreen(): boolean {\n    return this.isLink && this.fullscreen;\n  }\n\n  /**\n   * @returns true if node is a link that requires the header/footer to be hidden\n   */\n  get isHeadless(): boolean {\n    return this.isLink && this.headless;\n  }\n\n  /**\n   * Calculates offsets for each node for use in padding and margins\n   * @param value numeric value for calculating an offset\n   * @param unit string type of the offset unit (ex: 'px', 'rem')\n   */\n  offset(value: number, unit = 'px') {\n    return `${this.level * value}${unit}`;\n  }\n\n  /**\n   * @param url current route url\n   * @returns true if node or any of its children are active\n   */\n  isActive(url: string) {\n    if (this.link === url) {\n      return true;\n    }\n    for (const child of this.children) {\n      if (child.isActive(url)) {\n        return true;\n      }\n    }\n    return false;\n  }\n}\n","/**\n * @license\n * Copyright Neekware Inc. All Rights Reserved.\n *\n * Use of this source code is governed by a proprietary notice\n * that can be found at http://neekware.com/license/PRI.html\n */\n\nimport { NgModule } from '@angular/core';\n\n@NgModule({})\nexport class MenuModule {}\n","/**\n * @license\n * Copyright Neekware Inc. All Rights Reserved.\n *\n * Use of this source code is governed by a proprietary notice\n * that can be found at http://neekware.com/license/PRI.html\n */\n\nimport { EventEmitter, Injectable, Output } from '@angular/core';\n\nimport { MenuItem, PermissionVerificationFuncType } from './menu.model';\nimport { MenuModule } from './menu.module';\nimport { MenuNode } from './menu.util';\n\n@Injectable({\n  providedIn: MenuModule,\n})\nexport class MenuService {\n  @Output() menuChange$ = new EventEmitter<MenuNode>();\n  private rootNode: MenuNode = new MenuNode({ name: 'root' });\n  private isAllowedFunc: PermissionVerificationFuncType = (node: MenuItem) =>\n    !!(node?.allowed ?? true);\n\n  buildMenuTree(menuItems: MenuItem[], force = false) {\n    if (this.rootNode?.children?.length === 0 || force) {\n      this.rootNode.children = this.makeMenuTree(menuItems);\n      this.menuChange$.emit(this.rootNode);\n    }\n    return this.rootNode;\n  }\n\n  private makeMenuTree(itemList: MenuItem[], parent?: MenuNode, level = 1): MenuNode[] {\n    const tree: MenuNode[] = [];\n    for (const item of itemList) {\n      if (!Object.prototype.hasOwnProperty.call(item, 'name') || item.name.length < 1) {\n        throw Error(`Menu item missing 'name'`);\n      }\n\n      if (this.isAllowedFunc(item)) {\n        const newItem = new MenuNode(item);\n        newItem.level = level;\n        newItem.parent = parent;\n        if (Object.prototype.hasOwnProperty.call(item, 'children')) {\n          if (item.children.length > 0) {\n            newItem.children = this.makeMenuTree(item.children, newItem, level + 1);\n          }\n        }\n        tree.push(newItem);\n      }\n    }\n    return tree;\n  }\n\n  setPermissionVerificationFunction(func: PermissionVerificationFuncType) {\n    this.isAllowedFunc = func;\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;A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