How to use the @aurelia/kernel.kebabCase function in @aurelia/kernel

To help you get started, we’ve selected a few @aurelia/kernel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / plugin-conventions / src / preprocess-resource.ts View on Github external
export function preprocessResource(unit: IFileUnit, options: IPreprocessOptions): ModifyCodeResult {
  const basename = path.basename(unit.path, path.extname(unit.path));
  const expectedResourceName = kebabCase(basename);
  const sf = ts.createSourceFile(unit.path, unit.contents, ts.ScriptTarget.Latest);

  let runtimeImport: ICapturedImport = { names: [], start: 0, end: 0 };
  let jitImport: ICapturedImport = { names: [], start: 0, end: 0 };

  let implicitElement: IPos | undefined;

  // When there are multiple exported classes (e.g. local value converters),
  // they might be deps for rendering the main implicit custom element.
  const localDeps: string[] = [];
  const conventionalDecorators: [number, string][] = [];

  sf.statements.forEach(s => {
    // Find existing import {customElement} from '@aurelia/runtime';
    const runtime = captureImport(s, '@aurelia/runtime', unit.contents);
    if (runtime) {
github aurelia / aurelia / packages / plugin-conventions / dist / umd / preprocess-resource.js View on Github external
const { name, type } = name_convention_1.nameConvention(className);
        const isImplicitResource = isKindOfSame(name, expectedResourceName);
        const decoratedType = findDecoratedResourceType(node);
        if (decoratedType) {
            // Explicitly decorated resource
            if (!isImplicitResource && decoratedType !== 'customElement' && decoratedType !== 'view') {
                return { localDep: className };
            }
        }
        else {
            if (type === 'customElement') {
                // Custom element can only be implicit resource
                if (isImplicitResource && filePair) {
                    return {
                        implicitStatement: { pos: pos, end: node.end },
                        runtimeImportName: kernel_1.kebabCase(filePair).startsWith(`${expectedResourceName}-view`) ? 'view' : 'customElement'
                    };
                }
            }
            else {
                const result = {
                    needDecorator: [pos, `@${type}('${name}')\n`],
                    localDep: className,
                };
                if (type === 'bindingCommand') {
                    result.jitImportName = type;
                }
                else {
                    result.runtimeImportName = type;
                }
                return result;
            }
github aurelia / aurelia / packages / jit / dist / index.es6.js View on Github external
let prop;
    let attr;
    let mode;
    for (prop in bindables) {
        bindable = bindables[prop];
        // explicitly provided property name has priority over the implicit property name
        if (bindable.property !== void 0) {
            prop = bindable.property;
        }
        // explicitly provided attribute name has priority over the derived implicit attribute name
        if (bindable.attribute !== void 0) {
            attr = bindable.attribute;
        }
        else {
            // derive the attribute name from the resolved property name
            attr = kebabCase(prop);
        }
        if (bindable.mode !== void 0 && bindable.mode !== BindingMode.default) {
            mode = bindable.mode;
        }
        else {
            mode = defaultBindingMode;
        }
        info.bindables[attr] = new BindableInfo(prop, mode);
    }
    return info;
}
function createAttributeInfo(def) {
github aurelia / aurelia / packages / plugin-conventions / src / preprocess-html-template.ts View on Github external
export function preprocessHtmlTemplate(unit: IFileUnit, options: IPreprocessOptions): ModifyCodeResult {
  const name = kebabCase(path.basename(unit.path, path.extname(unit.path)));
  const stripped = stripMetaData(unit.contents);
  const { html, deps, containerless, bindables } = stripped;
  let { shadowMode } = stripped;

  if (unit.filePair) {
    const basename = path.basename(unit.filePair, path.extname(unit.filePair));
    if (!deps.some(dep => options.cssExtensions.some(e => dep === './' + basename + e))) {
      // implicit dep ./foo.css for foo.html
      deps.unshift('./' + unit.filePair);
    }
  }

  if (options.defaultShadowOptions && !shadowMode) {
    shadowMode = options.defaultShadowOptions.mode;
  }
github aurelia / aurelia / packages / plugin-conventions / dist / esnext / preprocess-resource.js View on Github external
const { name, type } = nameConvention(className);
    const isImplicitResource = isKindOfSame(name, expectedResourceName);
    const decoratedType = findDecoratedResourceType(node);
    if (decoratedType) {
        // Explicitly decorated resource
        if (!isImplicitResource && decoratedType !== 'customElement' && decoratedType !== 'view') {
            return { localDep: className };
        }
    }
    else {
        if (type === 'customElement') {
            // Custom element can only be implicit resource
            if (isImplicitResource && filePair) {
                return {
                    implicitStatement: { pos: pos, end: node.end },
                    runtimeImportName: kebabCase(filePair).startsWith(`${expectedResourceName}-view`) ? 'view' : 'customElement'
                };
            }
        }
        else {
            const result = {
                needDecorator: [pos, `@${type}('${name}')\n`],
                localDep: className,
            };
            if (type === 'bindingCommand') {
                result.jitImportName = type;
            }
            else {
                result.runtimeImportName = type;
            }
            return result;
        }
github aurelia / aurelia / packages / runtime / dist / esnext / templating / bindable.js View on Github external
static create(prop, def = {}) {
        return new BindableDefinition(firstDefined(def.attribute, kebabCase(prop)), firstDefined(def.callback, `${prop}Changed`), firstDefined(def.mode, BindingMode.toView), firstDefined(def.primary, false), firstDefined(def.property, prop), firstDefined(def.set, PLATFORM.noop));
    }
}
github aurelia / aurelia / packages / runtime-html / dist / esnext / observation / style-attribute-accessor.js View on Github external
getStyleTuplesFromObject(currentValue) {
        let value;
        const styles = [];
        for (const property in currentValue) {
            value = currentValue[property];
            if (value == null) {
                continue;
            }
            if (typeof value === 'string') {
                styles.push([kebabCase(property), value]);
                continue;
            }
            styles.push(...this.getStyleTuples(value));
        }
        return styles;
    }
    getStyleTuplesFromArray(currentValue) {
github aurelia / aurelia / packages / runtime-html / src / observation / style-attribute-accessor.ts View on Github external
private getStyleTuplesFromObject(currentValue: Record): [string, string][] {
    let value: unknown;
    const styles: [string, string][] = [];
    for (const property in currentValue) {
      value = currentValue[property];
      if (value == null) {
        continue;
      }
      if (typeof value === 'string') {
        styles.push([kebabCase(property), value]);
        continue;
      }

      styles.push(...this.getStyleTuples(value));
    }

    return styles;
  }
github aurelia / aurelia / packages / plugin-conventions / dist / umd / name-convention.js View on Github external
function normalizedName(name, type) {
        if (type === 'valueConverter' || type === 'bindingBehavior') {
            return kernel_1.camelCase(name);
        }
        return kernel_1.kebabCase(name);
    }
});