@aplus-frontend/ui
Version:
43 lines (42 loc) • 889 B
JavaScript
import "../../config-provider/index.mjs";
import { ref as r, watch as c } from "vue";
import { useLocale as f } from "../../config-provider/hooks/use-locale.mjs";
const m = "SELECTABLE_ALL_VALUE_KEY", E = (l) => {
const e = r(l?.options || []), { t: n } = f(), u = {
[l.fieldNames?.label || "label"]: n("ap.common.all"),
[l.fieldNames?.value || "value"]: m
};
function i(t) {
const a = l.addAll;
if (!l.multiple || !a)
return !1;
const d = Math.min(0, a === !0 ? 0 : a);
return t.length > d;
}
function o(t) {
if (t) {
if (!i(t)) {
e.value = t;
return;
}
e.value = [u, ...t];
}
}
return c(
() => l.options,
(t) => {
o(t);
},
{
deep: !0
}
), {
options: e,
updateOptions: o
};
};
export {
m as SELECT_ALL_VALUE_KEY,
E as default,
E as useSelectOptions
};