@teleporthq/teleport-shared
Advanced tools
Comparing version
@@ -406,2 +406,12 @@ import { | ||
describe('getComponentFolderPathWithSubstringURL', () => { | ||
const testComponent = component('MyComponent', elementNode('random')) | ||
testComponent.outputOptions = { fileName: 'sub/string/url' } | ||
const useFileNameForNavigation = true | ||
it('returns a relative folder path to the filename if useFileNameForNavigation is set to true', () => { | ||
expect(getComponentFolderPath(testComponent, useFileNameForNavigation)).toContain('../../') | ||
}) | ||
}) | ||
describe('getRepeatIteratorNameAndKey', () => { | ||
@@ -408,0 +418,0 @@ it('returns the fallback as name and key', () => { |
@@ -8,3 +8,3 @@ import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent } from '@teleporthq/teleport-types'; | ||
export declare const getTemplateFileName: (component: ComponentUIDL) => string; | ||
export declare const getComponentFolderPath: (component: ComponentUIDL) => string[]; | ||
export declare const getComponentFolderPath: (component: ComponentUIDL, useFileNameForNavigation?: boolean) => string[]; | ||
export declare const getComponentClassName: (component: ComponentUIDL) => string; | ||
@@ -11,0 +11,0 @@ export declare const getRepeatIteratorNameAndKey: (meta?: UIDLRepeatMeta) => { |
@@ -65,3 +65,13 @@ "use strict"; | ||
exports.getTemplateFileName = getTemplateFileName; | ||
var getComponentFolderPath = function (component) { | ||
var getComponentFolderPath = function (component, useFileNameForNavigation) { | ||
if (useFileNameForNavigation === void 0) { useFileNameForNavigation = false; } | ||
if (useFileNameForNavigation) { | ||
var prefixPath = ''; | ||
if (component.outputOptions && component.outputOptions.fileName) { | ||
for (var i = 0; i < component.outputOptions.fileName.split('/').length - 1; i++) { | ||
prefixPath += '../'; | ||
} | ||
} | ||
return prefixPath !== '' ? [prefixPath] : []; | ||
} | ||
return component.outputOptions && component.outputOptions.folderPath | ||
@@ -68,0 +78,0 @@ ? component.outputOptions.folderPath |
@@ -8,3 +8,3 @@ import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent } from '@teleporthq/teleport-types'; | ||
export declare const getTemplateFileName: (component: ComponentUIDL) => string; | ||
export declare const getComponentFolderPath: (component: ComponentUIDL) => string[]; | ||
export declare const getComponentFolderPath: (component: ComponentUIDL, useFileNameForNavigation?: boolean) => string[]; | ||
export declare const getComponentClassName: (component: ComponentUIDL) => string; | ||
@@ -11,0 +11,0 @@ export declare const getRepeatIteratorNameAndKey: (meta?: UIDLRepeatMeta) => { |
@@ -56,3 +56,13 @@ import { ASSETS_IDENTIFIER } from '../constants'; | ||
}; | ||
export var getComponentFolderPath = function (component) { | ||
export var getComponentFolderPath = function (component, useFileNameForNavigation) { | ||
if (useFileNameForNavigation === void 0) { useFileNameForNavigation = false; } | ||
if (useFileNameForNavigation) { | ||
var prefixPath = ''; | ||
if (component.outputOptions && component.outputOptions.fileName) { | ||
for (var i = 0; i < component.outputOptions.fileName.split('/').length - 1; i++) { | ||
prefixPath += '../'; | ||
} | ||
} | ||
return prefixPath !== '' ? [prefixPath] : []; | ||
} | ||
return component.outputOptions && component.outputOptions.folderPath | ||
@@ -59,0 +69,0 @@ ? component.outputOptions.folderPath |
{ | ||
"name": "@teleporthq/teleport-shared", | ||
"version": "0.23.0", | ||
"version": "0.23.5", | ||
"description": "A utility belt for the entire teleportHQ ecosystem", | ||
@@ -32,3 +32,3 @@ "author": "teleportHQ", | ||
}, | ||
"gitHead": "8d528aa48896a0163a42ebadd7df3fe6e5f47d41" | ||
"gitHead": "fd2283a3c4fd514554c9b29b6a995f58fe36b689" | ||
} |
@@ -93,6 +93,19 @@ import { ASSETS_IDENTIFIER } from '../constants' | ||
export const getComponentFolderPath = (component: ComponentUIDL) => | ||
component.outputOptions && component.outputOptions.folderPath | ||
export const getComponentFolderPath = ( | ||
component: ComponentUIDL, | ||
useFileNameForNavigation: boolean = false | ||
) => { | ||
if (useFileNameForNavigation) { | ||
let prefixPath = '' | ||
if (component.outputOptions && component.outputOptions.fileName) { | ||
for (let i = 0; i < component.outputOptions.fileName.split('/').length - 1; i++) { | ||
prefixPath += '../' | ||
} | ||
} | ||
return prefixPath !== '' ? [prefixPath] : [] | ||
} | ||
return component.outputOptions && component.outputOptions.folderPath | ||
? component.outputOptions.folderPath | ||
: [] | ||
} | ||
@@ -99,0 +112,0 @@ export const getComponentClassName = (component: ComponentUIDL) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
169197
1.6%2430
1.72%