UNPKG

vuestic-ui

Version:
41 lines (40 loc) 1.35 kB
import { i as injectChildPropsFromParent } from "../../composables/useChildComponents.mjs"; const KEBAB_CASE_REGEX = /([a-z0-9])([A-Z])/g; const toKebabCase = (str) => str.replace(KEBAB_CASE_REGEX, "$1-$2").toLowerCase(); const findCamelCased = (obj, key) => { if (key in obj) { return obj[key]; } return obj[toKebabCase(key)]; }; const createProps = (instance, propsFromConfig) => { const instanceProps = instance.props; const childPropsFromParent = injectChildPropsFromParent(); return new Proxy(instanceProps, { get: (target, key) => { var _a, _b; if (typeof key !== "string") { return target[key]; } const childProp = (_a = childPropsFromParent == null ? void 0 : childPropsFromParent.value) == null ? void 0 : _a[key]; if (childProp !== void 0) { return childProp; } const incomingProps = instance.vnode.props || {}; const originalProp = target[key]; const incomingProp = findCamelCased(incomingProps, key); if (incomingProp !== void 0) { return originalProp; } const propFromConfig = (_b = propsFromConfig.value) == null ? void 0 : _b[key]; if (propFromConfig !== void 0) { return propFromConfig; } return originalProp; } }); }; export { createProps as c }; //# sourceMappingURL=createProps.mjs.map