3b0a4461eedd04d6cac9f08d3b0a02a87524fa6458676b0f98eb9763ab7a589e237d69b8b9fc5d950ef1df8da4bd4e703902e5f7f9505ac3e5717678e6279d 1.0 KB

12345678910111213141516171819202122232425
  1. import { inject, computed } from 'vue';
  2. import { checkboxGroupContextKey } from '../constants.mjs';
  3. import { isUndefined } from '../../../../utils/types.mjs';
  4. import { useFormDisabled } from '../../../form/src/hooks/use-form-common-props.mjs';
  5. const useCheckboxDisabled = ({
  6. model,
  7. isChecked
  8. }) => {
  9. const checkboxGroup = inject(checkboxGroupContextKey, void 0);
  10. const isLimitDisabled = computed(() => {
  11. var _a, _b;
  12. const max = (_a = checkboxGroup == null ? void 0 : checkboxGroup.max) == null ? void 0 : _a.value;
  13. const min = (_b = checkboxGroup == null ? void 0 : checkboxGroup.min) == null ? void 0 : _b.value;
  14. return !isUndefined(max) && model.value.length >= max && !isChecked.value || !isUndefined(min) && model.value.length <= min && isChecked.value;
  15. });
  16. const isDisabled = useFormDisabled(computed(() => (checkboxGroup == null ? void 0 : checkboxGroup.disabled.value) || isLimitDisabled.value));
  17. return {
  18. isDisabled,
  19. isLimitDisabled
  20. };
  21. };
  22. export { useCheckboxDisabled };
  23. //# sourceMappingURL=use-checkbox-disabled.mjs.map