density.mjs 798 B

1234567891011121314151617181920212223242526
  1. // Utilities
  2. import { computed } from 'vue';
  3. import { getCurrentInstanceName, propsFactory } from "../util/index.mjs"; // Types
  4. const allowedDensities = [null, 'default', 'comfortable', 'compact'];
  5. // typeof allowedDensities[number] evalutes to any
  6. // when generating api types for whatever reason.
  7. // Composables
  8. export const makeDensityProps = propsFactory({
  9. density: {
  10. type: String,
  11. default: 'default',
  12. validator: v => allowedDensities.includes(v)
  13. }
  14. }, 'density');
  15. export function useDensity(props) {
  16. let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getCurrentInstanceName();
  17. const densityClasses = computed(() => {
  18. return `${name}--density-${props.density}`;
  19. });
  20. return {
  21. densityClasses
  22. };
  23. }
  24. //# sourceMappingURL=density.mjs.map