Skip to content

Commit

Permalink
Update assets
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Jun 16, 2024
1 parent aa0ac92 commit a3edc55
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
25 changes: 24 additions & 1 deletion app/assets/javascripts/turbo-mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,27 @@ function buildRegisterFunction(plugin) {
};
}

export { TurboMount, TurboMountController, buildRegisterFunction };
const identifierNames = (name) => {
const controllerName = camelToKebabCase(name);
return [`turbo-mount--${controllerName}`, `turbo-mount-${controllerName}`];
};
const registerComponentsBase = ({ plugin, turboMount, components, controllers, }) => {
var _a;
const controllerModules = controllers !== null && controllers !== void 0 ? controllers : [];
for (const { module, filename } of components) {
const name = filename
.replace(/\.\w*$/, "")
.replace(/^[./]*components\//, "");
const identifiers = identifierNames(name);
const controller = controllerModules.find(({ identifier }) => identifiers.includes(identifier));
const component = (_a = module.default) !== null && _a !== void 0 ? _a : module;
if (controller) {
turboMount.register(plugin, name, component, controller.controllerConstructor);
}
else {
turboMount.register(plugin, name, component);
}
}
};

export { TurboMount, TurboMountController, buildRegisterFunction, registerComponentsBase };
2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo-mount.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a3edc55

Please sign in to comment.