增加admin管理帐号和项目的界面--初步实现
This commit is contained in:
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export * from './use-checkbox-disabled';
|
||||
export * from './use-checkbox-event';
|
||||
export * from './use-checkbox-model';
|
||||
export * from './use-checkbox-status';
|
||||
export * from './use-checkbox';
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var useCheckboxDisabled = require('./use-checkbox-disabled.js');
|
||||
var useCheckboxEvent = require('./use-checkbox-event.js');
|
||||
var useCheckboxModel = require('./use-checkbox-model.js');
|
||||
var useCheckboxStatus = require('./use-checkbox-status.js');
|
||||
var useCheckbox = require('./use-checkbox.js');
|
||||
|
||||
|
||||
|
||||
exports.useCheckboxDisabled = useCheckboxDisabled.useCheckboxDisabled;
|
||||
exports.useCheckboxEvent = useCheckboxEvent.useCheckboxEvent;
|
||||
exports.useCheckboxModel = useCheckboxModel.useCheckboxModel;
|
||||
exports.useCheckboxStatus = useCheckboxStatus.useCheckboxStatus;
|
||||
exports.useCheckbox = useCheckbox.useCheckbox;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import type { CheckboxModel, CheckboxStatus } from '../composables';
|
||||
export declare const useCheckboxDisabled: ({ model, isChecked, }: Pick<CheckboxModel, "model"> & Pick<CheckboxStatus, "isChecked">) => {
|
||||
isDisabled: import("vue").ComputedRef<boolean>;
|
||||
isLimitDisabled: import("vue").ComputedRef<boolean>;
|
||||
};
|
||||
export type CheckboxDisabled = ReturnType<typeof useCheckboxDisabled>;
|
||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var constants = require('../constants.js');
|
||||
var constants$1 = require('../../../form/src/constants.js');
|
||||
var types = require('../../../../utils/types.js');
|
||||
var useFormCommonProps = require('../../../form/src/hooks/use-form-common-props.js');
|
||||
|
||||
const useCheckboxDisabled = ({
|
||||
model,
|
||||
isChecked
|
||||
}) => {
|
||||
const checkboxGroup = vue.inject(constants.checkboxGroupContextKey, void 0);
|
||||
const formContext = vue.inject(constants$1.formContextKey, void 0);
|
||||
const isLimitDisabled = vue.computed(() => {
|
||||
var _a, _b;
|
||||
const max = (_a = checkboxGroup == null ? void 0 : checkboxGroup.max) == null ? void 0 : _a.value;
|
||||
const min = (_b = checkboxGroup == null ? void 0 : checkboxGroup.min) == null ? void 0 : _b.value;
|
||||
return !types.isUndefined(max) && model.value.length >= max && !isChecked.value || !types.isUndefined(min) && model.value.length <= min && isChecked.value;
|
||||
});
|
||||
const isDisabled = useFormCommonProps.useFormDisabled(vue.computed(() => {
|
||||
var _a, _b;
|
||||
if (checkboxGroup === void 0) {
|
||||
return (_a = formContext == null ? void 0 : formContext.disabled) != null ? _a : isLimitDisabled.value;
|
||||
} else {
|
||||
return ((_b = checkboxGroup.disabled) == null ? void 0 : _b.value) || isLimitDisabled.value;
|
||||
}
|
||||
}));
|
||||
return {
|
||||
isDisabled,
|
||||
isLimitDisabled
|
||||
};
|
||||
};
|
||||
|
||||
exports.useCheckboxDisabled = useCheckboxDisabled;
|
||||
//# sourceMappingURL=use-checkbox-disabled.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-checkbox-disabled.js","sources":["../../../../../../../packages/components/checkbox/src/composables/use-checkbox-disabled.ts"],"sourcesContent":["import { computed, inject } from 'vue'\nimport { formContextKey, useFormDisabled } from '@element-plus/components/form'\nimport { isUndefined } from '@element-plus/utils'\nimport { checkboxGroupContextKey } from '../constants'\n\nimport type { CheckboxModel, CheckboxStatus } from '../composables'\n\nexport const useCheckboxDisabled = ({\n model,\n isChecked,\n}: Pick<CheckboxModel, 'model'> & Pick<CheckboxStatus, 'isChecked'>) => {\n const checkboxGroup = inject(checkboxGroupContextKey, undefined)\n const formContext = inject(formContextKey, undefined)\n\n const isLimitDisabled = computed(() => {\n const max = checkboxGroup?.max?.value\n const min = checkboxGroup?.min?.value\n return (\n (!isUndefined(max) && model.value.length >= max && !isChecked.value) ||\n (!isUndefined(min) && model.value.length <= min && isChecked.value)\n )\n })\n\n const isDisabled = useFormDisabled(\n computed(() => {\n // Directly use the checkbox\n if (checkboxGroup === undefined) {\n return formContext?.disabled ?? isLimitDisabled.value\n } else {\n return checkboxGroup.disabled?.value || isLimitDisabled.value\n }\n })\n )\n\n return {\n isDisabled,\n isLimitDisabled,\n }\n}\n\nexport type CheckboxDisabled = ReturnType<typeof useCheckboxDisabled>\n"],"names":["inject","checkboxGroupContextKey","formContextKey","computed","isUndefined","useFormDisabled"],"mappings":";;;;;;;;;;AAIY,MAAC,mBAAmB,GAAG,CAAC;AACpC,EAAE,KAAK;AACP,EAAE,SAAS;AACX,CAAC,KAAK;AACN,EAAE,MAAM,aAAa,GAAGA,UAAM,CAACC,iCAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;AAChE,EAAE,MAAM,WAAW,GAAGD,UAAM,CAACE,0BAAc,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,EAAE,MAAM,eAAe,GAAGC,YAAQ,CAAC,MAAM;AACzC,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;AACtG,IAAI,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;AACtG,IAAI,OAAO,CAACC,iBAAW,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,CAACA,iBAAW,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC;AACnJ,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,UAAU,GAAGC,kCAAe,CAACF,YAAQ,CAAC,MAAM;AACpD,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;AACf,IAAI,IAAI,aAAa,KAAK,KAAK,CAAC,EAAE;AAClC,MAAM,OAAO,CAAC,EAAE,GAAG,WAAW,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,QAAQ,KAAK,IAAI,GAAG,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC;AAC7G,KAAK,MAAM;AACX,MAAM,OAAO,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,QAAQ,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,eAAe,CAAC,KAAK,CAAC;AAClG,KAAK;AACL,GAAG,CAAC,CAAC,CAAC;AACN,EAAE,OAAO;AACT,IAAI,UAAU;AACd,IAAI,eAAe;AACnB,GAAG,CAAC;AACJ;;;;"}
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import type { useFormItemInputId } from 'element-plus/es/components/form';
|
||||
import type { CheckboxProps } from '../checkbox';
|
||||
import type { CheckboxDisabled, CheckboxModel, CheckboxStatus } from '../composables';
|
||||
export declare const useCheckboxEvent: (props: CheckboxProps, { model, isLimitExceeded, hasOwnLabel, isDisabled, isLabeledByFormItem, }: Pick<CheckboxModel, "model" | "isLimitExceeded"> & Pick<CheckboxStatus, "hasOwnLabel"> & Pick<CheckboxDisabled, "isDisabled"> & Pick<ReturnType<typeof useFormItemInputId>, "isLabeledByFormItem">) => {
|
||||
handleChange: (e: Event) => void;
|
||||
onClickRoot: (e: MouseEvent) => Promise<void>;
|
||||
};
|
||||
Generated
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var constants = require('../constants.js');
|
||||
var useFormItem = require('../../../form/src/hooks/use-form-item.js');
|
||||
var error = require('../../../../utils/error.js');
|
||||
var event = require('../../../../constants/event.js');
|
||||
|
||||
const useCheckboxEvent = (props, {
|
||||
model,
|
||||
isLimitExceeded,
|
||||
hasOwnLabel,
|
||||
isDisabled,
|
||||
isLabeledByFormItem
|
||||
}) => {
|
||||
const checkboxGroup = vue.inject(constants.checkboxGroupContextKey, void 0);
|
||||
const { formItem } = useFormItem.useFormItem();
|
||||
const { emit } = vue.getCurrentInstance();
|
||||
function getLabeledValue(value) {
|
||||
var _a, _b, _c, _d;
|
||||
return [true, props.trueValue, props.trueLabel].includes(value) ? (_b = (_a = props.trueValue) != null ? _a : props.trueLabel) != null ? _b : true : (_d = (_c = props.falseValue) != null ? _c : props.falseLabel) != null ? _d : false;
|
||||
}
|
||||
function emitChangeEvent(checked, e) {
|
||||
emit(event.CHANGE_EVENT, getLabeledValue(checked), e);
|
||||
}
|
||||
function handleChange(e) {
|
||||
if (isLimitExceeded.value)
|
||||
return;
|
||||
const target = e.target;
|
||||
emit(event.CHANGE_EVENT, getLabeledValue(target.checked), e);
|
||||
}
|
||||
async function onClickRoot(e) {
|
||||
if (isLimitExceeded.value)
|
||||
return;
|
||||
if (!hasOwnLabel.value && !isDisabled.value && isLabeledByFormItem.value) {
|
||||
const eventTargets = e.composedPath();
|
||||
const hasLabel = eventTargets.some((item) => item.tagName === "LABEL");
|
||||
if (!hasLabel) {
|
||||
model.value = getLabeledValue([false, props.falseValue, props.falseLabel].includes(model.value));
|
||||
await vue.nextTick();
|
||||
emitChangeEvent(model.value, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
const validateEvent = vue.computed(() => (checkboxGroup == null ? void 0 : checkboxGroup.validateEvent) || props.validateEvent);
|
||||
vue.watch(() => props.modelValue, () => {
|
||||
if (validateEvent.value) {
|
||||
formItem == null ? void 0 : formItem.validate("change").catch((err) => error.debugWarn(err));
|
||||
}
|
||||
});
|
||||
return {
|
||||
handleChange,
|
||||
onClickRoot
|
||||
};
|
||||
};
|
||||
|
||||
exports.useCheckboxEvent = useCheckboxEvent;
|
||||
//# sourceMappingURL=use-checkbox-event.js.map
|
||||
frontend/node_modules/element-plus/lib/components/checkbox/src/composables/use-checkbox-event.js.map
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import type { CheckboxProps } from '../checkbox';
|
||||
export declare const useCheckboxModel: (props: CheckboxProps) => {
|
||||
model: import("vue").WritableComputedRef<any>;
|
||||
isGroup: import("vue").ComputedRef<boolean>;
|
||||
isLimitExceeded: import("vue").Ref<boolean>;
|
||||
};
|
||||
export type CheckboxModel = ReturnType<typeof useCheckboxModel>;
|
||||
Generated
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var constants = require('../constants.js');
|
||||
var types = require('../../../../utils/types.js');
|
||||
var shared = require('@vue/shared');
|
||||
var event = require('../../../../constants/event.js');
|
||||
|
||||
const useCheckboxModel = (props) => {
|
||||
const selfModel = vue.ref(false);
|
||||
const { emit } = vue.getCurrentInstance();
|
||||
const checkboxGroup = vue.inject(constants.checkboxGroupContextKey, void 0);
|
||||
const isGroup = vue.computed(() => types.isUndefined(checkboxGroup) === false);
|
||||
const isLimitExceeded = vue.ref(false);
|
||||
const model = vue.computed({
|
||||
get() {
|
||||
var _a, _b;
|
||||
return isGroup.value ? (_a = checkboxGroup == null ? void 0 : checkboxGroup.modelValue) == null ? void 0 : _a.value : (_b = props.modelValue) != null ? _b : selfModel.value;
|
||||
},
|
||||
set(val) {
|
||||
var _a, _b;
|
||||
if (isGroup.value && shared.isArray(val)) {
|
||||
isLimitExceeded.value = ((_a = checkboxGroup == null ? void 0 : checkboxGroup.max) == null ? void 0 : _a.value) !== void 0 && val.length > (checkboxGroup == null ? void 0 : checkboxGroup.max.value) && val.length > model.value.length;
|
||||
isLimitExceeded.value === false && ((_b = checkboxGroup == null ? void 0 : checkboxGroup.changeEvent) == null ? void 0 : _b.call(checkboxGroup, val));
|
||||
} else {
|
||||
emit(event.UPDATE_MODEL_EVENT, val);
|
||||
selfModel.value = val;
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
model,
|
||||
isGroup,
|
||||
isLimitExceeded
|
||||
};
|
||||
};
|
||||
|
||||
exports.useCheckboxModel = useCheckboxModel;
|
||||
//# sourceMappingURL=use-checkbox-model.js.map
|
||||
frontend/node_modules/element-plus/lib/components/checkbox/src/composables/use-checkbox-model.js.map
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-checkbox-model.js","sources":["../../../../../../../packages/components/checkbox/src/composables/use-checkbox-model.ts"],"sourcesContent":["import { computed, getCurrentInstance, inject, ref } from 'vue'\nimport { isArray, isUndefined } from '@element-plus/utils'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { checkboxGroupContextKey } from '../constants'\n\nimport type { CheckboxProps } from '../checkbox'\n\nexport const useCheckboxModel = (props: CheckboxProps) => {\n const selfModel = ref<unknown>(false)\n const { emit } = getCurrentInstance()!\n const checkboxGroup = inject(checkboxGroupContextKey, undefined)\n const isGroup = computed(() => isUndefined(checkboxGroup) === false)\n const isLimitExceeded = ref(false)\n const model = computed({\n get() {\n return isGroup.value\n ? checkboxGroup?.modelValue?.value\n : (props.modelValue ?? selfModel.value)\n },\n\n set(val: unknown) {\n if (isGroup.value && isArray(val)) {\n isLimitExceeded.value =\n checkboxGroup?.max?.value !== undefined &&\n val.length > checkboxGroup?.max.value &&\n val.length > model.value.length\n isLimitExceeded.value === false && checkboxGroup?.changeEvent?.(val)\n } else {\n emit(UPDATE_MODEL_EVENT, val)\n selfModel.value = val\n }\n },\n })\n\n return {\n model,\n isGroup,\n isLimitExceeded,\n }\n}\n\nexport type CheckboxModel = ReturnType<typeof useCheckboxModel>\n"],"names":["ref","getCurrentInstance","inject","checkboxGroupContextKey","computed","isUndefined","isArray","UPDATE_MODEL_EVENT"],"mappings":";;;;;;;;;;AAIY,MAAC,gBAAgB,GAAG,CAAC,KAAK,KAAK;AAC3C,EAAE,MAAM,SAAS,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AAC/B,EAAE,MAAM,EAAE,IAAI,EAAE,GAAGC,sBAAkB,EAAE,CAAC;AACxC,EAAE,MAAM,aAAa,GAAGC,UAAM,CAACC,iCAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;AAChE,EAAE,MAAM,OAAO,GAAGC,YAAQ,CAAC,MAAMC,iBAAW,CAAC,aAAa,CAAC,KAAK,KAAK,CAAC,CAAC;AACvE,EAAE,MAAM,eAAe,GAAGL,OAAG,CAAC,KAAK,CAAC,CAAC;AACrC,EAAE,MAAM,KAAK,GAAGI,YAAQ,CAAC;AACzB,IAAI,GAAG,GAAG;AACV,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC;AACjB,MAAM,OAAO,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,UAAU,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,KAAK,IAAI,GAAG,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC;AACnL,KAAK;AACL,IAAI,GAAG,CAAC,GAAG,EAAE;AACb,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC;AACjB,MAAM,IAAI,OAAO,CAAC,KAAK,IAAIE,cAAO,CAAC,GAAG,CAAC,EAAE;AACzC,QAAQ,eAAe,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;AACjP,QAAQ,eAAe,CAAC,KAAK,KAAK,KAAK,KAAK,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,WAAW,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9J,OAAO,MAAM;AACb,QAAQ,IAAI,CAACC,wBAAkB,EAAE,GAAG,CAAC,CAAC;AACtC,QAAQ,SAAS,CAAC,KAAK,GAAG,GAAG,CAAC;AAC9B,OAAO;AACP,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,KAAK;AACT,IAAI,OAAO;AACX,IAAI,eAAe;AACnB,GAAG,CAAC;AACJ;;;;"}
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import type { ComponentInternalInstance } from 'vue';
|
||||
import type { CheckboxProps } from '../checkbox';
|
||||
import type { CheckboxModel } from '../composables';
|
||||
export declare const useCheckboxStatus: (props: CheckboxProps, slots: ComponentInternalInstance["slots"], { model }: Pick<CheckboxModel, "model">) => {
|
||||
checkboxButtonSize: import("vue").ComputedRef<"" | "small" | "default" | "large">;
|
||||
isChecked: import("vue").ComputedRef<boolean>;
|
||||
isFocused: import("vue").Ref<boolean>;
|
||||
checkboxSize: import("vue").ComputedRef<"" | "small" | "default" | "large">;
|
||||
hasOwnLabel: import("vue").ComputedRef<boolean>;
|
||||
actualValue: import("vue").ComputedRef<string | number | boolean | Record<string, any> | undefined>;
|
||||
};
|
||||
export type CheckboxStatus = ReturnType<typeof useCheckboxStatus>;
|
||||
Generated
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var lodashUnified = require('lodash-unified');
|
||||
var constants = require('../constants.js');
|
||||
var types = require('../../../../utils/types.js');
|
||||
var shared = require('@vue/shared');
|
||||
var useFormCommonProps = require('../../../form/src/hooks/use-form-common-props.js');
|
||||
|
||||
const useCheckboxStatus = (props, slots, { model }) => {
|
||||
const checkboxGroup = vue.inject(constants.checkboxGroupContextKey, void 0);
|
||||
const isFocused = vue.ref(false);
|
||||
const actualValue = vue.computed(() => {
|
||||
if (!types.isPropAbsent(props.value)) {
|
||||
return props.value;
|
||||
}
|
||||
return props.label;
|
||||
});
|
||||
const isChecked = vue.computed(() => {
|
||||
const value = model.value;
|
||||
if (types.isBoolean(value)) {
|
||||
return value;
|
||||
} else if (shared.isArray(value)) {
|
||||
if (shared.isObject(actualValue.value)) {
|
||||
return value.map(vue.toRaw).some((o) => lodashUnified.isEqual(o, actualValue.value));
|
||||
} else {
|
||||
return value.map(vue.toRaw).includes(actualValue.value);
|
||||
}
|
||||
} else if (value !== null && value !== void 0) {
|
||||
return value === props.trueValue || value === props.trueLabel;
|
||||
} else {
|
||||
return !!value;
|
||||
}
|
||||
});
|
||||
const checkboxButtonSize = useFormCommonProps.useFormSize(vue.computed(() => {
|
||||
var _a;
|
||||
return (_a = checkboxGroup == null ? void 0 : checkboxGroup.size) == null ? void 0 : _a.value;
|
||||
}), {
|
||||
prop: true
|
||||
});
|
||||
const checkboxSize = useFormCommonProps.useFormSize(vue.computed(() => {
|
||||
var _a;
|
||||
return (_a = checkboxGroup == null ? void 0 : checkboxGroup.size) == null ? void 0 : _a.value;
|
||||
}));
|
||||
const hasOwnLabel = vue.computed(() => {
|
||||
return !!slots.default || !types.isPropAbsent(actualValue.value);
|
||||
});
|
||||
return {
|
||||
checkboxButtonSize,
|
||||
isChecked,
|
||||
isFocused,
|
||||
checkboxSize,
|
||||
hasOwnLabel,
|
||||
actualValue
|
||||
};
|
||||
};
|
||||
|
||||
exports.useCheckboxStatus = useCheckboxStatus;
|
||||
//# sourceMappingURL=use-checkbox-status.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-checkbox-status.js","sources":["../../../../../../../packages/components/checkbox/src/composables/use-checkbox-status.ts"],"sourcesContent":["import { computed, inject, ref, toRaw } from 'vue'\nimport { isEqual } from 'lodash-unified'\nimport { useFormSize } from '@element-plus/components/form'\nimport { isArray, isBoolean, isObject, isPropAbsent } from '@element-plus/utils'\nimport { checkboxGroupContextKey } from '../constants'\n\nimport type { ComponentInternalInstance } from 'vue'\nimport type { CheckboxProps } from '../checkbox'\nimport type { CheckboxModel } from '../composables'\n\nexport const useCheckboxStatus = (\n props: CheckboxProps,\n slots: ComponentInternalInstance['slots'],\n { model }: Pick<CheckboxModel, 'model'>\n) => {\n const checkboxGroup = inject(checkboxGroupContextKey, undefined)\n const isFocused = ref(false)\n const actualValue = computed(() => {\n // In version 2.x, if there's no props.value, props.label will act as props.value\n // In version 3.x, remove this computed value, use props.value instead.\n if (!isPropAbsent(props.value)) {\n return props.value\n }\n return props.label\n })\n const isChecked = computed<boolean>(() => {\n const value = model.value\n if (isBoolean(value)) {\n return value\n } else if (isArray(value)) {\n if (isObject(actualValue.value)) {\n return value.map(toRaw).some((o) => isEqual(o, actualValue.value))\n } else {\n return value.map(toRaw).includes(actualValue.value)\n }\n } else if (value !== null && value !== undefined) {\n return value === props.trueValue || value === props.trueLabel\n } else {\n return !!value\n }\n })\n\n const checkboxButtonSize = useFormSize(\n computed(() => checkboxGroup?.size?.value),\n {\n prop: true,\n }\n )\n const checkboxSize = useFormSize(computed(() => checkboxGroup?.size?.value))\n\n const hasOwnLabel = computed<boolean>(() => {\n return !!slots.default || !isPropAbsent(actualValue.value)\n })\n\n return {\n checkboxButtonSize,\n isChecked,\n isFocused,\n checkboxSize,\n hasOwnLabel,\n actualValue,\n }\n}\n\nexport type CheckboxStatus = ReturnType<typeof useCheckboxStatus>\n"],"names":["inject","checkboxGroupContextKey","ref","computed","isPropAbsent","isBoolean","isArray","isObject","toRaw","isEqual","useFormSize"],"mappings":";;;;;;;;;;;AAKY,MAAC,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK;AAC9D,EAAE,MAAM,aAAa,GAAGA,UAAM,CAACC,iCAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;AAChE,EAAE,MAAM,SAAS,GAAGC,OAAG,CAAC,KAAK,CAAC,CAAC;AAC/B,EAAE,MAAM,WAAW,GAAGC,YAAQ,CAAC,MAAM;AACrC,IAAI,IAAI,CAACC,kBAAY,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;AACpC,MAAM,OAAO,KAAK,CAAC,KAAK,CAAC;AACzB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC;AACvB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,SAAS,GAAGD,YAAQ,CAAC,MAAM;AACnC,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;AAC9B,IAAI,IAAIE,eAAS,CAAC,KAAK,CAAC,EAAE;AAC1B,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK,MAAM,IAAIC,cAAO,CAAC,KAAK,CAAC,EAAE;AAC/B,MAAM,IAAIC,eAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;AACvC,QAAQ,OAAO,KAAK,CAAC,GAAG,CAACC,SAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAKC,qBAAO,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,OAAO,MAAM;AACb,QAAQ,OAAO,KAAK,CAAC,GAAG,CAACD,SAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5D,OAAO;AACP,KAAK,MAAM,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE;AACnD,MAAM,OAAO,KAAK,KAAK,KAAK,CAAC,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,SAAS,CAAC;AACpE,KAAK,MAAM;AACX,MAAM,OAAO,CAAC,CAAC,KAAK,CAAC;AACrB,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,kBAAkB,GAAGE,8BAAW,CAACP,YAAQ,CAAC,MAAM;AACxD,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,IAAI,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;AAClG,GAAG,CAAC,EAAE;AACN,IAAI,IAAI,EAAE,IAAI;AACd,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,YAAY,GAAGO,8BAAW,CAACP,YAAQ,CAAC,MAAM;AAClD,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,aAAa,CAAC,IAAI,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;AAClG,GAAG,CAAC,CAAC,CAAC;AACN,EAAE,MAAM,WAAW,GAAGA,YAAQ,CAAC,MAAM;AACrC,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAACC,kBAAY,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC/D,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,kBAAkB;AACtB,IAAI,SAAS;AACb,IAAI,SAAS;AACb,IAAI,YAAY;AAChB,IAAI,WAAW;AACf,IAAI,WAAW;AACf,GAAG,CAAC;AACJ;;;;"}
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import type { ComponentInternalInstance } from 'vue';
|
||||
import type { CheckboxProps } from '../checkbox';
|
||||
export declare const useCheckbox: (props: CheckboxProps, slots: ComponentInternalInstance["slots"]) => {
|
||||
inputId: import("vue").Ref<string | undefined>;
|
||||
isLabeledByFormItem: import("vue").ComputedRef<boolean>;
|
||||
isChecked: import("vue").ComputedRef<boolean>;
|
||||
isDisabled: import("vue").ComputedRef<boolean>;
|
||||
isFocused: import("vue").Ref<boolean>;
|
||||
checkboxButtonSize: import("vue").ComputedRef<"" | "small" | "default" | "large">;
|
||||
checkboxSize: import("vue").ComputedRef<"" | "small" | "default" | "large">;
|
||||
hasOwnLabel: import("vue").ComputedRef<boolean>;
|
||||
model: import("vue").WritableComputedRef<any>;
|
||||
actualValue: import("vue").ComputedRef<string | number | boolean | Record<string, any> | undefined>;
|
||||
handleChange: (e: Event) => void;
|
||||
onClickRoot: (e: MouseEvent) => Promise<void>;
|
||||
};
|
||||
Generated
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var useCheckboxDisabled = require('./use-checkbox-disabled.js');
|
||||
var useCheckboxEvent = require('./use-checkbox-event.js');
|
||||
var useCheckboxModel = require('./use-checkbox-model.js');
|
||||
var useCheckboxStatus = require('./use-checkbox-status.js');
|
||||
var useFormItem = require('../../../form/src/hooks/use-form-item.js');
|
||||
var index = require('../../../../hooks/use-deprecated/index.js');
|
||||
var types = require('../../../../utils/types.js');
|
||||
var shared = require('@vue/shared');
|
||||
|
||||
const useCheckbox = (props, slots) => {
|
||||
const { formItem: elFormItem } = useFormItem.useFormItem();
|
||||
const { model, isGroup, isLimitExceeded } = useCheckboxModel.useCheckboxModel(props);
|
||||
const {
|
||||
isFocused,
|
||||
isChecked,
|
||||
checkboxButtonSize,
|
||||
checkboxSize,
|
||||
hasOwnLabel,
|
||||
actualValue
|
||||
} = useCheckboxStatus.useCheckboxStatus(props, slots, { model });
|
||||
const { isDisabled } = useCheckboxDisabled.useCheckboxDisabled({ model, isChecked });
|
||||
const { inputId, isLabeledByFormItem } = useFormItem.useFormItemInputId(props, {
|
||||
formItemContext: elFormItem,
|
||||
disableIdGeneration: hasOwnLabel,
|
||||
disableIdManagement: isGroup
|
||||
});
|
||||
const { handleChange, onClickRoot } = useCheckboxEvent.useCheckboxEvent(props, {
|
||||
model,
|
||||
isLimitExceeded,
|
||||
hasOwnLabel,
|
||||
isDisabled,
|
||||
isLabeledByFormItem
|
||||
});
|
||||
const setStoreValue = () => {
|
||||
function addToStore() {
|
||||
var _a, _b;
|
||||
if (shared.isArray(model.value) && !model.value.includes(actualValue.value)) {
|
||||
model.value.push(actualValue.value);
|
||||
} else {
|
||||
model.value = (_b = (_a = props.trueValue) != null ? _a : props.trueLabel) != null ? _b : true;
|
||||
}
|
||||
}
|
||||
props.checked && addToStore();
|
||||
};
|
||||
setStoreValue();
|
||||
index.useDeprecated({
|
||||
from: "label act as value",
|
||||
replacement: "value",
|
||||
version: "3.0.0",
|
||||
scope: "el-checkbox",
|
||||
ref: "https://element-plus.org/en-US/component/checkbox.html"
|
||||
}, vue.computed(() => isGroup.value && types.isPropAbsent(props.value)));
|
||||
index.useDeprecated({
|
||||
from: "true-label",
|
||||
replacement: "true-value",
|
||||
version: "3.0.0",
|
||||
scope: "el-checkbox",
|
||||
ref: "https://element-plus.org/en-US/component/checkbox.html"
|
||||
}, vue.computed(() => !!props.trueLabel));
|
||||
index.useDeprecated({
|
||||
from: "false-label",
|
||||
replacement: "false-value",
|
||||
version: "3.0.0",
|
||||
scope: "el-checkbox",
|
||||
ref: "https://element-plus.org/en-US/component/checkbox.html"
|
||||
}, vue.computed(() => !!props.falseLabel));
|
||||
return {
|
||||
inputId,
|
||||
isLabeledByFormItem,
|
||||
isChecked,
|
||||
isDisabled,
|
||||
isFocused,
|
||||
checkboxButtonSize,
|
||||
checkboxSize,
|
||||
hasOwnLabel,
|
||||
model,
|
||||
actualValue,
|
||||
handleChange,
|
||||
onClickRoot
|
||||
};
|
||||
};
|
||||
|
||||
exports.useCheckbox = useCheckbox;
|
||||
//# sourceMappingURL=use-checkbox.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user