98804282133ebbce018ee6a8b0585c6e40d75ab2584871a88288aebf302aa5513a4ef5afe935d36896891f6a8337ad55fc50e56b6747bfc475371f2fab5cf6 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var lodashUnified = require('lodash-unified');
  5. var shared = require('@vue/shared');
  6. function useFormLabelWidth() {
  7. const potentialLabelWidthArr = vue.ref([]);
  8. const autoLabelWidth = vue.computed(() => {
  9. if (!potentialLabelWidthArr.value.length)
  10. return "0";
  11. const max = Math.max(...potentialLabelWidthArr.value);
  12. return max ? `${max}px` : "";
  13. });
  14. function getLabelWidthIndex(width) {
  15. const index = potentialLabelWidthArr.value.indexOf(width);
  16. if (index === -1 && autoLabelWidth.value === "0") ;
  17. return index;
  18. }
  19. function registerLabelWidth(val, oldVal) {
  20. if (val && oldVal) {
  21. const index = getLabelWidthIndex(oldVal);
  22. potentialLabelWidthArr.value.splice(index, 1, val);
  23. } else if (val) {
  24. potentialLabelWidthArr.value.push(val);
  25. }
  26. }
  27. function deregisterLabelWidth(val) {
  28. const index = getLabelWidthIndex(val);
  29. if (index > -1) {
  30. potentialLabelWidthArr.value.splice(index, 1);
  31. }
  32. }
  33. return {
  34. autoLabelWidth,
  35. registerLabelWidth,
  36. deregisterLabelWidth
  37. };
  38. }
  39. const filterFields = (fields, props) => {
  40. const normalized = lodashUnified.castArray(props).map((prop) => shared.isArray(prop) ? prop.join(".") : prop);
  41. return normalized.length > 0 ? fields.filter((field) => field.propString && normalized.includes(field.propString)) : fields;
  42. };
  43. exports.filterFields = filterFields;
  44. exports.useFormLabelWidth = useFormLabelWidth;
  45. //# sourceMappingURL=utils.js.map