useProps.js 903 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var lodashUnified = require('lodash-unified');
  5. const defaultProps = {
  6. label: "label",
  7. value: "value",
  8. disabled: "disabled",
  9. options: "options"
  10. };
  11. function useProps(props) {
  12. const aliasProps = vue.computed(() => ({ ...defaultProps, ...props.props }));
  13. const getLabel = (option) => lodashUnified.get(option, aliasProps.value.label);
  14. const getValue = (option) => lodashUnified.get(option, aliasProps.value.value);
  15. const getDisabled = (option) => lodashUnified.get(option, aliasProps.value.disabled);
  16. const getOptions = (option) => lodashUnified.get(option, aliasProps.value.options);
  17. return {
  18. aliasProps,
  19. getLabel,
  20. getValue,
  21. getDisabled,
  22. getOptions
  23. };
  24. }
  25. exports.defaultProps = defaultProps;
  26. exports.useProps = useProps;
  27. //# sourceMappingURL=useProps.js.map