| 1 |
var __defProp = Object.defineProperty; |
| 2 |
var __defProps = Object.defineProperties; |
| 3 |
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; |
| 4 |
var __getOwnPropSymbols = Object.getOwnPropertySymbols; |
| 5 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 6 |
var __propIsEnum = Object.prototype.propertyIsEnumerable; |
| 7 |
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; |
| 8 |
var __spreadValues = (a, b) => { |
| 9 |
for (var prop in b || (b = {})) |
| 10 |
if (__hasOwnProp.call(b, prop)) |
| 11 |
__defNormalProp(a, prop, b[prop]); |
| 12 |
if (__getOwnPropSymbols) |
| 13 |
for (var prop of __getOwnPropSymbols(b)) { |
| 14 |
if (__propIsEnum.call(b, prop)) |
| 15 |
__defNormalProp(a, prop, b[prop]); |
| 16 |
} |
| 17 |
return a; |
| 18 |
}; |
| 19 |
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); |
| 20 |
var __objRest = (source, exclude) => { |
| 21 |
var target = {}; |
| 22 |
for (var prop in source) |
| 23 |
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) |
| 24 |
target[prop] = source[prop]; |
| 25 |
if (source != null && __getOwnPropSymbols) |
| 26 |
for (var prop of __getOwnPropSymbols(source)) { |
| 27 |
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) |
| 28 |
target[prop] = source[prop]; |
| 29 |
} |
| 30 |
return target; |
| 31 |
}; |
| 32 |
var __publicField = (obj, key, value) => { |
| 33 |
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); |
| 34 |
return value; |
| 35 |
}; |
| 36 |
var __async = (__this, __arguments, generator) => { |
| 37 |
return new Promise((resolve, reject) => { |
| 38 |
var fulfilled = (value) => { |
| 39 |
try { |
| 40 |
step(generator.next(value)); |
| 41 |
} catch (e) { |
| 42 |
reject(e); |
| 43 |
} |
| 44 |
}; |
| 45 |
var rejected = (value) => { |
| 46 |
try { |
| 47 |
step(generator.throw(value)); |
| 48 |
} catch (e) { |
| 49 |
reject(e); |
| 50 |
} |
| 51 |
}; |
| 52 |
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); |
| 53 |
step((generator = generator.apply(__this, __arguments)).next()); |
| 54 |
}); |
| 55 |
}; |
| 56 |
import { ref, onMounted, defineComponent, computed, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, Comment, warn, watch, withKeys, withModifiers, renderSlot, resolveComponent, createElementVNode, createBlock, resolveDynamicComponent, withCtx, createVNode, toRef, Fragment, renderList, createTextVNode, Transition, normalizeStyle, inject, mergeProps, getCurrentInstance, withDirectives, vModelCheckbox, createSlots, nextTick, vModelDynamic, onUnmounted, vShow, unref, shallowRef, getCurrentScope, onScopeDispose, shallowReadonly, Teleport, toRefs, provide, vModelRadio, vModelText } from "vue"; |
| 57 |
const g = '<path d="M11.53 2.3A1.85 1.85 0 0010 1.21 1.85 1.85 0 008.48 2.3L.36 16.36C-.48 17.81.21 19 1.88 19h16.24c1.67 0 2.36-1.19 1.52-2.64zM11 16H9v-2h2zm0-4H9V6h2z"/>', q = '<path d="M12.43 14.34A5 5 0 0110 15a5 5 0 113.95-2L17 16.09V3a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 001.45-.63z"/><circle cx="10" cy="10" r="3"/>', s1 = '<path d="M7 14.17 2.83 10l-1.41 1.41L7 17 19 5l-1.41-1.42z"/>', n1 = '<path d="M10 0a10 10 0 1010 10A10 10 0 0010 0m5.66 14.24-1.41 1.41L10 11.41l-4.24 4.25-1.42-1.42L8.59 10 4.34 5.76l1.42-1.42L10 8.59l4.24-4.24 1.41 1.41L11.41 10z"/>', d1 = '<path d="m4.34 2.93 12.73 12.73-1.41 1.41L2.93 4.35z"/><path d="M17.07 4.34 4.34 17.07l-1.41-1.41L15.66 2.93z"/>', g1 = '<path d="M10 15 2 5h16z"/>', k1 = '<path d="M13.728 1H6.272L1 6.272v7.456L6.272 19h7.456L19 13.728V6.272zM11 15H9v-2h2zm0-4H9V5h2z"/>', F1 = '<path d="m17.5 4.75-7.5 7.5-7.5-7.5L1 6.25l9 9 9-9z"/>', t0 = '<path d="M19 3H1v14h18zM3 14l3.5-4.5 2.5 3L12.5 8l4.5 6z"/><path d="M19 5H1V3h18zm0 12H1v-2h18z"/>', p = '<path d="M8 19a1 1 0 001 1h2a1 1 0 001-1v-1H8zm9-12a7 7 0 10-12 4.9S7 14 7 15v1a1 1 0 001 1h4a1 1 0 001-1v-1c0-1 2-3.1 2-3.1A7 7 0 0017 7"/>', e0 = '<path d="M10 0C4.477 0 0 4.477 0 10s4.477 10 10 10 10-4.477 10-10S15.523 0 10 0M9 5h2v2H9zm0 4h2v6H9z"/>', z2 = '<path d="M3 1h2v18H3zm13.5 1.5L15 1l-9 9 9 9 1.5-1.5L9 10z"/>', i2 = '<path d="M15 1h2v18h-2zM3.5 2.5 11 10l-7.5 7.5L5 19l9-9-9-9z"/>', V2 = '<path d="M7 1 5.6 2.5 13 10l-7.4 7.5L7 19l9-9z"/>', b2 = '<path d="m4 10 9 9 1.4-1.5L7 10l7.4-7.5L13 1z"/>', J2 = '<path d="M12.2 13.6a7 7 0 111.4-1.4l5.4 5.4-1.4 1.4zM3 8a5 5 0 1010 0A5 5 0 003 8"/>', h5 = '<path d="M10 0 3 8h14zm0 18-7-8h14z"/>', M5 = '<path d="M10 20a10 10 0 010-20 10 10 0 110 20m-2-5 9-8.5L15.5 5 8 12 4.5 8.5 3 10z"/>', G5 = '<path d="m10 5 8 10H2z"/>', M3 = g, S3 = q, K3 = s1, Y3 = n1, X3 = d1, l4 = g1, i4 = k1, m4 = F1, P4 = t0, Y4 = { |
| 58 |
langCodeMap: { |
| 59 |
ar: p |
| 60 |
}, |
| 61 |
default: e0 |
| 62 |
}, P6 = { |
| 63 |
ltr: z2, |
| 64 |
shouldFlip: true |
| 65 |
}, N6 = { |
| 66 |
ltr: i2, |
| 67 |
shouldFlip: true |
| 68 |
}, j6 = { |
| 69 |
ltr: V2, |
| 70 |
shouldFlip: true |
| 71 |
}, d7 = { |
| 72 |
ltr: b2, |
| 73 |
shouldFlip: true |
| 74 |
}, A7 = J2, T7 = h5, O7 = M5, x8 = G5; |
| 75 |
function N8(c, s, h) { |
| 76 |
if (typeof c == "string" || "path" in c) |
| 77 |
return c; |
| 78 |
if ("shouldFlip" in c) |
| 79 |
return c.ltr; |
| 80 |
if ("rtl" in c) |
| 81 |
return h === "rtl" ? c.rtl : c.ltr; |
| 82 |
const n = s in c.langCodeMap ? c.langCodeMap[s] : c.default; |
| 83 |
return typeof n == "string" || "path" in n ? n : n.ltr; |
| 84 |
} |
| 85 |
function O8(c, s) { |
| 86 |
if (typeof c == "string") |
| 87 |
return false; |
| 88 |
if ("langCodeMap" in c) { |
| 89 |
const h = s in c.langCodeMap ? c.langCodeMap[s] : c.default; |
| 90 |
if (typeof h == "string") |
| 91 |
return false; |
| 92 |
c = h; |
| 93 |
} |
| 94 |
if ("shouldFlipExceptions" in c && Array.isArray(c.shouldFlipExceptions)) { |
| 95 |
const h = c.shouldFlipExceptions.indexOf(s); |
| 96 |
return h === void 0 || h === -1; |
| 97 |
} |
| 98 |
return "shouldFlip" in c ? c.shouldFlip : false; |
| 99 |
} |
| 100 |
function useComputedDirection(root) { |
| 101 |
const computedDir = ref(null); |
| 102 |
onMounted(() => { |
| 103 |
const dir = window.getComputedStyle(root.value).direction; |
| 104 |
computedDir.value = dir === "ltr" || dir === "rtl" ? dir : null; |
| 105 |
}); |
| 106 |
return computedDir; |
| 107 |
} |
| 108 |
function useComputedLanguage(root) { |
| 109 |
const computedLang = ref(""); |
| 110 |
onMounted(() => { |
| 111 |
let ancestor = root.value; |
| 112 |
while (ancestor && ancestor.lang === "") { |
| 113 |
ancestor = ancestor.parentElement; |
| 114 |
} |
| 115 |
computedLang.value = ancestor ? ancestor.lang : null; |
| 116 |
}); |
| 117 |
return computedLang; |
| 118 |
} |
| 119 |
function makeStringTypeValidator(allowedValues) { |
| 120 |
return (s) => typeof s === "string" && allowedValues.indexOf(s) !== -1; |
| 121 |
} |
| 122 |
const LibraryPrefix = "cdx"; |
| 123 |
const ButtonActions = [ |
| 124 |
"default", |
| 125 |
"progressive", |
| 126 |
"destructive" |
| 127 |
]; |
| 128 |
const ButtonWeights = [ |
| 129 |
"normal", |
| 130 |
"primary", |
| 131 |
"quiet" |
| 132 |
]; |
| 133 |
const ButtonSizes = [ |
| 134 |
"medium", |
| 135 |
"large" |
| 136 |
]; |
| 137 |
const IconSizes = [ |
| 138 |
"x-small", |
| 139 |
"small", |
| 140 |
"medium" |
| 141 |
]; |
| 142 |
const StatusTypes = [ |
| 143 |
"notice", |
| 144 |
"warning", |
| 145 |
"error", |
| 146 |
"success" |
| 147 |
]; |
| 148 |
const statusTypeValidator = makeStringTypeValidator(StatusTypes); |
| 149 |
const TextInputTypes = [ |
| 150 |
"text", |
| 151 |
"search", |
| 152 |
"number", |
| 153 |
"email", |
| 154 |
"month", |
| 155 |
"password", |
| 156 |
"tel", |
| 157 |
"url", |
| 158 |
"week", |
| 159 |
"date", |
| 160 |
"datetime-local", |
| 161 |
"time" |
| 162 |
]; |
| 163 |
const ValidationStatusTypes = [ |
| 164 |
"default", |
| 165 |
"warning", |
| 166 |
"error", |
| 167 |
"success" |
| 168 |
]; |
| 169 |
const TableTextAlignments = [ |
| 170 |
"start", |
| 171 |
"center", |
| 172 |
"end", |
| 173 |
|
| 174 |
"number" |
| 175 |
]; |
| 176 |
const DebounceInterval = 120; |
| 177 |
const PendingDelay = 500; |
| 178 |
const MenuFooterValue = "cdx-menu-footer-item"; |
| 179 |
const TabsKey = Symbol("CdxTabs"); |
| 180 |
const ActiveTabKey = Symbol("CdxActiveTab"); |
| 181 |
const AllowArbitraryKey = Symbol("CdxAllowArbitrary"); |
| 182 |
const FieldInputIdKey = Symbol("CdxFieldInputId"); |
| 183 |
const FieldDescriptionIdKey = Symbol("CdxFieldDescriptionId"); |
| 184 |
const FieldStatusKey = Symbol("CdxFieldStatus"); |
| 185 |
const DisabledKey = Symbol("CdxDisabled"); |
| 186 |
const NoInvertClass = "".concat(LibraryPrefix, "-no-invert"); |
| 187 |
const TableRowIdentifier = Symbol("CdxTableRowIdentifier"); |
| 188 |
const TablePaginationPositions = [ |
| 189 |
"top", |
| 190 |
"bottom", |
| 191 |
"both" |
| 192 |
]; |
| 193 |
const iconSizeValidator = makeStringTypeValidator(IconSizes); |
| 194 |
const _sfc_main$y = defineComponent({ |
| 195 |
name: "CdxIcon", |
| 196 |
props: { |
| 197 |
|
| 198 |
icon: { |
| 199 |
type: [String, Object], |
| 200 |
required: true |
| 201 |
}, |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
iconLabel: { |
| 209 |
type: String, |
| 210 |
default: "" |
| 211 |
}, |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
lang: { |
| 218 |
type: String, |
| 219 |
default: null |
| 220 |
}, |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
dir: { |
| 227 |
type: String, |
| 228 |
default: null |
| 229 |
}, |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
size: { |
| 236 |
type: String, |
| 237 |
default: "medium", |
| 238 |
validator: iconSizeValidator |
| 239 |
} |
| 240 |
}, |
| 241 |
setup(props) { |
| 242 |
const rootElement = ref(); |
| 243 |
const computedDir = useComputedDirection(rootElement); |
| 244 |
const computedLang = useComputedLanguage(rootElement); |
| 245 |
const overriddenDir = computed(() => { |
| 246 |
var _a; |
| 247 |
return (_a = props.dir) != null ? _a : computedDir.value; |
| 248 |
}); |
| 249 |
const overriddenLang = computed(() => { |
| 250 |
var _a; |
| 251 |
return (_a = props.lang) != null ? _a : computedLang.value; |
| 252 |
}); |
| 253 |
const rootClasses = computed(() => { |
| 254 |
return { |
| 255 |
"cdx-icon--flipped": overriddenDir.value === "rtl" && overriddenLang.value !== null && O8(props.icon, overriddenLang.value), |
| 256 |
["cdx-icon--".concat(props.size)]: true |
| 257 |
}; |
| 258 |
}); |
| 259 |
const resolvedIcon = computed( |
| 260 |
() => { |
| 261 |
var _a, _b; |
| 262 |
return N8(props.icon, (_a = overriddenLang.value) != null ? _a : "", (_b = overriddenDir.value) != null ? _b : "ltr"); |
| 263 |
} |
| 264 |
); |
| 265 |
const iconSvg = computed(() => typeof resolvedIcon.value === "string" ? resolvedIcon.value : ""); |
| 266 |
const iconPath = computed(() => typeof resolvedIcon.value !== "string" ? resolvedIcon.value.path : ""); |
| 267 |
return { |
| 268 |
rootElement, |
| 269 |
rootClasses, |
| 270 |
iconSvg, |
| 271 |
iconPath |
| 272 |
}; |
| 273 |
} |
| 274 |
}); |
| 275 |
const _export_sfc = (sfc, props) => { |
| 276 |
const target = sfc.__vccOpts || sfc; |
| 277 |
for (const [key, val] of props) { |
| 278 |
target[key] = val; |
| 279 |
} |
| 280 |
return target; |
| 281 |
}; |
| 282 |
const _hoisted_1$v = ["aria-hidden"]; |
| 283 |
const _hoisted_2$m = { key: 0 }; |
| 284 |
const _hoisted_3$e = ["innerHTML"]; |
| 285 |
const _hoisted_4$9 = ["d"]; |
| 286 |
function _sfc_render$y(_ctx, _cache, $props, $setup, $data, $options) { |
| 287 |
return openBlock(), createElementBlock( |
| 288 |
"span", |
| 289 |
{ |
| 290 |
ref: "rootElement", |
| 291 |
class: normalizeClass(["cdx-icon", _ctx.rootClasses]) |
| 292 |
}, |
| 293 |
[ |
| 294 |
(openBlock(), createElementBlock("svg", { |
| 295 |
xmlns: "http://www.w3.org/2000/svg", |
| 296 |
"xmlns:xlink": "http://www.w3.org/1999/xlink", |
| 297 |
width: "20", |
| 298 |
height: "20", |
| 299 |
viewBox: "0 0 20 20", |
| 300 |
"aria-hidden": _ctx.iconLabel ? void 0 : true |
| 301 |
}, [ |
| 302 |
_ctx.iconLabel ? (openBlock(), createElementBlock( |
| 303 |
"title", |
| 304 |
_hoisted_2$m, |
| 305 |
toDisplayString(_ctx.iconLabel), |
| 306 |
1 |
| 307 |
|
| 308 |
)) : createCommentVNode("v-if", true), |
| 309 |
_ctx.iconSvg ? (openBlock(), createElementBlock("g", { |
| 310 |
key: 1, |
| 311 |
innerHTML: _ctx.iconSvg |
| 312 |
}, null, 8, _hoisted_3$e)) : (openBlock(), createElementBlock("path", { |
| 313 |
key: 2, |
| 314 |
d: _ctx.iconPath |
| 315 |
}, null, 8, _hoisted_4$9)) |
| 316 |
], 8, _hoisted_1$v)) |
| 317 |
], |
| 318 |
2 |
| 319 |
|
| 320 |
); |
| 321 |
} |
| 322 |
const CdxIcon = _export_sfc(_sfc_main$y, [["render", _sfc_render$y]]); |
| 323 |
function flattenSlotContents(slotContents) { |
| 324 |
const flattened = []; |
| 325 |
for (const node of slotContents) { |
| 326 |
if ( |
| 327 |
|
| 328 |
typeof node.type === "string" || |
| 329 |
typeof node.type === "object" |
| 330 |
) { |
| 331 |
flattened.push(node); |
| 332 |
} else if (node.type !== Comment) { |
| 333 |
if (typeof node.children === "string" && node.children.trim() !== "") { |
| 334 |
flattened.push(node.children); |
| 335 |
} else if (Array.isArray(node.children)) { |
| 336 |
flattened.push(...flattenSlotContents(node.children)); |
| 337 |
} |
| 338 |
} |
| 339 |
} |
| 340 |
return flattened; |
| 341 |
} |
| 342 |
function isComponentVNode(node, componentName) { |
| 343 |
if (typeof node.type === "object" && "name" in node.type) { |
| 344 |
if (componentName !== void 0) { |
| 345 |
return node.type.name === componentName; |
| 346 |
} |
| 347 |
return true; |
| 348 |
} |
| 349 |
return false; |
| 350 |
} |
| 351 |
function isTagVNode(node, tagName) { |
| 352 |
if (typeof node.type === "string") { |
| 353 |
{ |
| 354 |
return node.type === tagName.toLowerCase(); |
| 355 |
} |
| 356 |
} |
| 357 |
return false; |
| 358 |
} |
| 359 |
function useSlotContents(slot) { |
| 360 |
const slotContents = typeof slot === "function" ? slot() : slot; |
| 361 |
return slotContents ? flattenSlotContents(slotContents) : []; |
| 362 |
} |
| 363 |
function useWarnOnce(shouldWarn, message) { |
| 364 |
if (shouldWarn()) { |
| 365 |
warn(message); |
| 366 |
return; |
| 367 |
} |
| 368 |
const stop = watch(shouldWarn, (newValue) => { |
| 369 |
if (newValue) { |
| 370 |
warn(message); |
| 371 |
stop(); |
| 372 |
} |
| 373 |
}); |
| 374 |
} |
| 375 |
function useIconOnlyButton(slot, attrs, componentName) { |
| 376 |
const isIconOnly = computed(() => { |
| 377 |
const slotContents = useSlotContents(slot); |
| 378 |
if (slotContents.length !== 1) { |
| 379 |
return false; |
| 380 |
} |
| 381 |
const soleNode = slotContents[0]; |
| 382 |
if (typeof soleNode === "object" && (isComponentVNode(soleNode, "CdxIcon") || isTagVNode(soleNode, "svg"))) { |
| 383 |
return true; |
| 384 |
} |
| 385 |
return false; |
| 386 |
}); |
| 387 |
useWarnOnce( |
| 388 |
() => isIconOnly.value && !attrs["aria-label"] && !attrs["aria-hidden"], |
| 389 |
"".concat(componentName, ": Icon-only buttons require one of the following attributes: aria-label or aria-hidden. See documentation at https://doc.wikimedia.org/codex/latest/components/demos/button.html#icon-only-button") |
| 390 |
); |
| 391 |
return isIconOnly; |
| 392 |
} |
| 393 |
const buttonActionValidator = makeStringTypeValidator(ButtonActions); |
| 394 |
const buttonWeightValidator = makeStringTypeValidator(ButtonWeights); |
| 395 |
const buttonSizeValidator = makeStringTypeValidator(ButtonSizes); |
| 396 |
const _sfc_main$x = defineComponent({ |
| 397 |
name: "CdxButton", |
| 398 |
props: { |
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
action: { |
| 405 |
type: String, |
| 406 |
default: "default", |
| 407 |
validator: buttonActionValidator |
| 408 |
}, |
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
weight: { |
| 415 |
type: String, |
| 416 |
default: "normal", |
| 417 |
validator: buttonWeightValidator |
| 418 |
}, |
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
size: { |
| 428 |
type: String, |
| 429 |
default: "medium", |
| 430 |
validator: buttonSizeValidator |
| 431 |
} |
| 432 |
}, |
| 433 |
emits: ["click"], |
| 434 |
setup(props, { emit, slots, attrs }) { |
| 435 |
const button = ref(); |
| 436 |
const isIconOnly = useIconOnlyButton(slots.default, attrs, "CdxButton"); |
| 437 |
const isActive = ref(false); |
| 438 |
const rootClasses = computed(() => ({ |
| 439 |
["cdx-button--action-".concat(props.action)]: true, |
| 440 |
["cdx-button--weight-".concat(props.weight)]: true, |
| 441 |
["cdx-button--size-".concat(props.size)]: true, |
| 442 |
"cdx-button--framed": props.weight !== "quiet", |
| 443 |
"cdx-button--icon-only": isIconOnly.value, |
| 444 |
"cdx-button--is-active": isActive.value |
| 445 |
})); |
| 446 |
const onClick = (event) => { |
| 447 |
emit("click", event); |
| 448 |
}; |
| 449 |
const setActive = (active) => { |
| 450 |
isActive.value = active; |
| 451 |
}; |
| 452 |
function onKeyDown() { |
| 453 |
setActive(true); |
| 454 |
} |
| 455 |
function onKeyUp() { |
| 456 |
var _a; |
| 457 |
setActive(false); |
| 458 |
(_a = button.value) == null ? void 0 : _a.click(); |
| 459 |
} |
| 460 |
return { |
| 461 |
button, |
| 462 |
rootClasses, |
| 463 |
onClick, |
| 464 |
onKeyDown, |
| 465 |
onKeyUp |
| 466 |
}; |
| 467 |
} |
| 468 |
}); |
| 469 |
function _sfc_render$x(_ctx, _cache, $props, $setup, $data, $options) { |
| 470 |
return openBlock(), createElementBlock( |
| 471 |
"button", |
| 472 |
{ |
| 473 |
ref: "button", |
| 474 |
class: normalizeClass(["cdx-button", _ctx.rootClasses]), |
| 475 |
onKeydown: _cache[0] || (_cache[0] = withKeys(withModifiers((...args) => _ctx.onKeyDown && _ctx.onKeyDown(...args), ["prevent"]), ["space", "enter"])), |
| 476 |
onKeyup: _cache[1] || (_cache[1] = withKeys((...args) => _ctx.onKeyUp && _ctx.onKeyUp(...args), ["space", "enter"])), |
| 477 |
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.onClick && _ctx.onClick(...args)) |
| 478 |
}, |
| 479 |
[ |
| 480 |
renderSlot(_ctx.$slots, "default") |
| 481 |
], |
| 482 |
34 |
| 483 |
|
| 484 |
); |
| 485 |
} |
| 486 |
const CdxButton = _export_sfc(_sfc_main$x, [["render", _sfc_render$x]]); |
| 487 |
const _sfc_main$w = defineComponent({ |
| 488 |
name: "CdxAccordion", |
| 489 |
components: { CdxButton, CdxIcon }, |
| 490 |
props: { |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
actionAlwaysVisible: { |
| 497 |
type: Boolean, |
| 498 |
default: false |
| 499 |
}, |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
actionIcon: { |
| 505 |
type: [String, Object], |
| 506 |
default: null |
| 507 |
}, |
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
actionButtonLabel: { |
| 513 |
type: String, |
| 514 |
default: "" |
| 515 |
}, |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
headingLevel: { |
| 522 |
type: String, |
| 523 |
default: "h3" |
| 524 |
} |
| 525 |
}, |
| 526 |
emits: [ |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
"action-button-click" |
| 532 |
], |
| 533 |
setup(props, { attrs, emit }) { |
| 534 |
const isExpanded = ref("open" in attrs); |
| 535 |
const emitActionButtonClick = () => { |
| 536 |
emit("action-button-click"); |
| 537 |
}; |
| 538 |
const onToggle = (e) => { |
| 539 |
isExpanded.value = e.newState === "open"; |
| 540 |
}; |
| 541 |
const shouldShowActionButton = computed(() => { |
| 542 |
return props.actionIcon && (isExpanded.value || props.actionAlwaysVisible); |
| 543 |
}); |
| 544 |
const rootClasses = computed(() => ({ |
| 545 |
"cdx-accordion--has-icon": shouldShowActionButton.value |
| 546 |
})); |
| 547 |
return { |
| 548 |
emitActionButtonClick, |
| 549 |
rootClasses, |
| 550 |
shouldShowActionButton, |
| 551 |
onToggle |
| 552 |
}; |
| 553 |
} |
| 554 |
}); |
| 555 |
const _hoisted_1$u = { class: "cdx-accordion__header__title" }; |
| 556 |
const _hoisted_2$l = { class: "cdx-accordion__header__description" }; |
| 557 |
function _sfc_render$w(_ctx, _cache, $props, $setup, $data, $options) { |
| 558 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 559 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 560 |
return openBlock(), createElementBlock( |
| 561 |
"details", |
| 562 |
{ |
| 563 |
class: normalizeClass(["cdx-accordion", _ctx.rootClasses]), |
| 564 |
onToggle: _cache[1] || (_cache[1] = (...args) => _ctx.onToggle && _ctx.onToggle(...args)) |
| 565 |
}, |
| 566 |
[ |
| 567 |
createElementVNode("summary", null, [ |
| 568 |
(openBlock(), createBlock(resolveDynamicComponent(_ctx.headingLevel), { class: "cdx-accordion__header" }, { |
| 569 |
default: withCtx(() => [ |
| 570 |
createElementVNode("span", _hoisted_1$u, [ |
| 571 |
renderSlot(_ctx.$slots, "title") |
| 572 |
]), |
| 573 |
createElementVNode("span", _hoisted_2$l, [ |
| 574 |
renderSlot(_ctx.$slots, "description") |
| 575 |
]) |
| 576 |
]), |
| 577 |
_: 3 |
| 578 |
|
| 579 |
})), |
| 580 |
_ctx.shouldShowActionButton ? (openBlock(), createBlock(_component_cdx_button, { |
| 581 |
key: 0, |
| 582 |
class: "cdx-accordion__action", |
| 583 |
"aria-label": _ctx.actionButtonLabel, |
| 584 |
type: "button", |
| 585 |
weight: "quiet", |
| 586 |
onClick: withModifiers(_ctx.emitActionButtonClick, ["stop"]) |
| 587 |
}, { |
| 588 |
default: withCtx(() => [ |
| 589 |
createVNode(_component_cdx_icon, { |
| 590 |
icon: _ctx.actionIcon, |
| 591 |
"icon-label": _ctx.actionButtonLabel, |
| 592 |
size: "medium" |
| 593 |
}, null, 8, ["icon", "icon-label"]) |
| 594 |
]), |
| 595 |
_: 1 |
| 596 |
|
| 597 |
}, 8, ["aria-label", "onClick"])) : createCommentVNode("v-if", true) |
| 598 |
]), |
| 599 |
createElementVNode("div", { |
| 600 |
class: "cdx-accordion__content", |
| 601 |
onClick: _cache[0] || (_cache[0] = withModifiers(() => { |
| 602 |
}, ["stop"])) |
| 603 |
}, [ |
| 604 |
renderSlot(_ctx.$slots, "default") |
| 605 |
]) |
| 606 |
], |
| 607 |
34 |
| 608 |
|
| 609 |
); |
| 610 |
} |
| 611 |
const Accordion = _export_sfc(_sfc_main$w, [["render", _sfc_render$w]]); |
| 612 |
function getButtonLabel(button) { |
| 613 |
if (button.label === void 0) { |
| 614 |
return button.value; |
| 615 |
} |
| 616 |
if (button.label === null) { |
| 617 |
return ""; |
| 618 |
} |
| 619 |
return button.label; |
| 620 |
} |
| 621 |
function useButtonGroupKeyboardNav(buttonsProp) { |
| 622 |
const rootElement = ref(); |
| 623 |
const focusedButtonIndex = ref(); |
| 624 |
const buttonRefs = ref( new Map()); |
| 625 |
const currentDirection = useComputedDirection(rootElement); |
| 626 |
function assignTemplateRef(templateRef, index) { |
| 627 |
const button = templateRef; |
| 628 |
if (button) { |
| 629 |
buttonRefs.value.set(index, button); |
| 630 |
} |
| 631 |
} |
| 632 |
function onFocus(index) { |
| 633 |
focusedButtonIndex.value = index; |
| 634 |
} |
| 635 |
function onBlur() { |
| 636 |
focusedButtonIndex.value = void 0; |
| 637 |
} |
| 638 |
function focusNonDisabled(index, increment) { |
| 639 |
var _a; |
| 640 |
const newIndex = index + increment; |
| 641 |
const targetButton = buttonsProp.value[newIndex]; |
| 642 |
if (targetButton) { |
| 643 |
if (targetButton.disabled) { |
| 644 |
focusNonDisabled(newIndex, increment); |
| 645 |
} else { |
| 646 |
const buttonElement = (_a = buttonRefs.value.get(newIndex)) == null ? void 0 : _a.$el; |
| 647 |
buttonElement == null ? void 0 : buttonElement.focus(); |
| 648 |
} |
| 649 |
} |
| 650 |
} |
| 651 |
function next() { |
| 652 |
var _a; |
| 653 |
focusNonDisabled((_a = focusedButtonIndex.value) != null ? _a : -1, 1); |
| 654 |
} |
| 655 |
function prev() { |
| 656 |
var _a; |
| 657 |
focusNonDisabled((_a = focusedButtonIndex.value) != null ? _a : buttonsProp.value.length, -1); |
| 658 |
} |
| 659 |
function moveRight() { |
| 660 |
if (currentDirection.value === "rtl") { |
| 661 |
prev(); |
| 662 |
} else { |
| 663 |
next(); |
| 664 |
} |
| 665 |
} |
| 666 |
function moveLeft() { |
| 667 |
if (currentDirection.value === "rtl") { |
| 668 |
next(); |
| 669 |
} else { |
| 670 |
prev(); |
| 671 |
} |
| 672 |
} |
| 673 |
function onKeydown(e) { |
| 674 |
switch (e.key) { |
| 675 |
case "ArrowRight": |
| 676 |
e.preventDefault(); |
| 677 |
moveRight(); |
| 678 |
break; |
| 679 |
case "ArrowLeft": |
| 680 |
e.preventDefault(); |
| 681 |
moveLeft(); |
| 682 |
break; |
| 683 |
case "ArrowDown": |
| 684 |
e.preventDefault(); |
| 685 |
next(); |
| 686 |
break; |
| 687 |
case "ArrowUp": |
| 688 |
e.preventDefault(); |
| 689 |
prev(); |
| 690 |
break; |
| 691 |
} |
| 692 |
} |
| 693 |
return { |
| 694 |
rootElement, |
| 695 |
assignTemplateRef, |
| 696 |
onFocus, |
| 697 |
onBlur, |
| 698 |
onKeydown |
| 699 |
}; |
| 700 |
} |
| 701 |
const _sfc_main$v = defineComponent({ |
| 702 |
name: "CdxButtonGroup", |
| 703 |
components: { |
| 704 |
CdxButton, |
| 705 |
CdxIcon |
| 706 |
}, |
| 707 |
props: { |
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
buttons: { |
| 712 |
type: Array, |
| 713 |
required: true, |
| 714 |
validator: (value) => Array.isArray(value) && value.length >= 1 |
| 715 |
}, |
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
disabled: { |
| 723 |
type: Boolean, |
| 724 |
default: false |
| 725 |
} |
| 726 |
}, |
| 727 |
emits: [ |
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
"click" |
| 734 |
], |
| 735 |
setup(props) { |
| 736 |
const { |
| 737 |
rootElement, |
| 738 |
assignTemplateRef, |
| 739 |
onFocus, |
| 740 |
onBlur, |
| 741 |
onKeydown |
| 742 |
} = useButtonGroupKeyboardNav(toRef(props, "buttons")); |
| 743 |
return { |
| 744 |
rootElement, |
| 745 |
assignTemplateRef, |
| 746 |
onFocus, |
| 747 |
onBlur, |
| 748 |
onKeydown, |
| 749 |
getButtonLabel |
| 750 |
}; |
| 751 |
} |
| 752 |
}); |
| 753 |
const _hoisted_1$t = { |
| 754 |
ref: "rootElement", |
| 755 |
class: "cdx-button-group" |
| 756 |
}; |
| 757 |
function _sfc_render$v(_ctx, _cache, $props, $setup, $data, $options) { |
| 758 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 759 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 760 |
return openBlock(), createElementBlock( |
| 761 |
"div", |
| 762 |
_hoisted_1$t, |
| 763 |
[ |
| 764 |
(openBlock(true), createElementBlock( |
| 765 |
Fragment, |
| 766 |
null, |
| 767 |
renderList(_ctx.buttons, (button, index) => { |
| 768 |
return openBlock(), createBlock(_component_cdx_button, { |
| 769 |
key: button.value, |
| 770 |
ref_for: true, |
| 771 |
ref: (ref2) => _ctx.assignTemplateRef(ref2, index), |
| 772 |
disabled: button.disabled || _ctx.disabled, |
| 773 |
"aria-label": button.ariaLabel, |
| 774 |
onClick: ($event) => _ctx.$emit("click", button.value), |
| 775 |
onFocus: ($event) => _ctx.onFocus(index), |
| 776 |
onBlur: _ctx.onBlur, |
| 777 |
onKeydown: _ctx.onKeydown |
| 778 |
}, { |
| 779 |
default: withCtx(() => [ |
| 780 |
renderSlot(_ctx.$slots, "default", { button }, () => [ |
| 781 |
button.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 782 |
key: 0, |
| 783 |
icon: button.icon |
| 784 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 785 |
createTextVNode( |
| 786 |
" " + toDisplayString(_ctx.getButtonLabel(button)), |
| 787 |
1 |
| 788 |
|
| 789 |
) |
| 790 |
]) |
| 791 |
]), |
| 792 |
_: 2 |
| 793 |
|
| 794 |
}, 1032, ["disabled", "aria-label", "onClick", "onFocus", "onBlur", "onKeydown"]); |
| 795 |
}), |
| 796 |
128 |
| 797 |
|
| 798 |
)) |
| 799 |
], |
| 800 |
512 |
| 801 |
|
| 802 |
); |
| 803 |
} |
| 804 |
const ButtonGroup = _export_sfc(_sfc_main$v, [["render", _sfc_render$v]]); |
| 805 |
const _sfc_main$u = defineComponent({ |
| 806 |
name: "CdxThumbnail", |
| 807 |
components: { CdxIcon }, |
| 808 |
props: { |
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
thumbnail: { |
| 813 |
type: [Object, null], |
| 814 |
default: null |
| 815 |
}, |
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
placeholderIcon: { |
| 820 |
type: [String, Object], |
| 821 |
default: P4 |
| 822 |
} |
| 823 |
}, |
| 824 |
setup: (props) => { |
| 825 |
const thumbnailLoaded = ref(false); |
| 826 |
const thumbnailStyle = ref({}); |
| 827 |
const preloadThumbnail = (url) => { |
| 828 |
const escapedUrl = url.replace(/([\\"\n])/g, "\\$1"); |
| 829 |
const image = new Image(); |
| 830 |
image.onload = () => { |
| 831 |
thumbnailStyle.value = { backgroundImage: 'url("'.concat(escapedUrl, '")') }; |
| 832 |
thumbnailLoaded.value = true; |
| 833 |
}; |
| 834 |
image.onerror = () => { |
| 835 |
thumbnailLoaded.value = false; |
| 836 |
}; |
| 837 |
image.src = escapedUrl; |
| 838 |
}; |
| 839 |
onMounted(() => { |
| 840 |
var _a; |
| 841 |
if ((_a = props.thumbnail) == null ? void 0 : _a.url) { |
| 842 |
preloadThumbnail(props.thumbnail.url); |
| 843 |
} |
| 844 |
}); |
| 845 |
return { |
| 846 |
thumbnailStyle, |
| 847 |
thumbnailLoaded, |
| 848 |
NoInvertClass |
| 849 |
}; |
| 850 |
} |
| 851 |
}); |
| 852 |
const _hoisted_1$s = { class: "cdx-thumbnail" }; |
| 853 |
const _hoisted_2$k = { |
| 854 |
key: 0, |
| 855 |
class: "cdx-thumbnail__placeholder" |
| 856 |
}; |
| 857 |
function _sfc_render$u(_ctx, _cache, $props, $setup, $data, $options) { |
| 858 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 859 |
return openBlock(), createElementBlock("span", _hoisted_1$s, [ |
| 860 |
!_ctx.thumbnailLoaded ? (openBlock(), createElementBlock("span", _hoisted_2$k, [ |
| 861 |
createVNode(_component_cdx_icon, { |
| 862 |
icon: _ctx.placeholderIcon, |
| 863 |
class: "cdx-thumbnail__placeholder__icon--vue" |
| 864 |
}, null, 8, ["icon"]) |
| 865 |
])) : createCommentVNode("v-if", true), |
| 866 |
createVNode(Transition, { name: "cdx-thumbnail__image" }, { |
| 867 |
default: withCtx(() => [ |
| 868 |
_ctx.thumbnailLoaded ? (openBlock(), createElementBlock( |
| 869 |
"span", |
| 870 |
{ |
| 871 |
key: 0, |
| 872 |
style: normalizeStyle(_ctx.thumbnailStyle), |
| 873 |
class: normalizeClass([_ctx.NoInvertClass, "cdx-thumbnail__image"]) |
| 874 |
}, |
| 875 |
null, |
| 876 |
6 |
| 877 |
|
| 878 |
)) : createCommentVNode("v-if", true) |
| 879 |
]), |
| 880 |
_: 1 |
| 881 |
|
| 882 |
}) |
| 883 |
]); |
| 884 |
} |
| 885 |
const CdxThumbnail = _export_sfc(_sfc_main$u, [["render", _sfc_render$u]]); |
| 886 |
const _sfc_main$t = defineComponent({ |
| 887 |
name: "CdxCard", |
| 888 |
components: { CdxIcon, CdxThumbnail }, |
| 889 |
props: { |
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
url: { |
| 894 |
type: String, |
| 895 |
default: "" |
| 896 |
}, |
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
icon: { |
| 901 |
type: [String, Object], |
| 902 |
default: "" |
| 903 |
}, |
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
thumbnail: { |
| 908 |
type: [Object, null], |
| 909 |
default: null |
| 910 |
}, |
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
forceThumbnail: { |
| 925 |
type: Boolean, |
| 926 |
default: false |
| 927 |
}, |
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
customPlaceholderIcon: { |
| 935 |
type: [String, Object], |
| 936 |
default: void 0 |
| 937 |
} |
| 938 |
}, |
| 939 |
setup(props) { |
| 940 |
const isLink = computed(() => !!props.url); |
| 941 |
const contentTag = computed(() => isLink.value ? "a" : "span"); |
| 942 |
const cardLink = computed(() => isLink.value ? props.url : void 0); |
| 943 |
return { |
| 944 |
isLink, |
| 945 |
contentTag, |
| 946 |
cardLink |
| 947 |
}; |
| 948 |
} |
| 949 |
}); |
| 950 |
const _hoisted_1$r = { class: "cdx-card__text" }; |
| 951 |
const _hoisted_2$j = { class: "cdx-card__text__title" }; |
| 952 |
const _hoisted_3$d = { |
| 953 |
key: 0, |
| 954 |
class: "cdx-card__text__description" |
| 955 |
}; |
| 956 |
const _hoisted_4$8 = { |
| 957 |
key: 1, |
| 958 |
class: "cdx-card__text__supporting-text" |
| 959 |
}; |
| 960 |
function _sfc_render$t(_ctx, _cache, $props, $setup, $data, $options) { |
| 961 |
const _component_cdx_thumbnail = resolveComponent("cdx-thumbnail"); |
| 962 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 963 |
return openBlock(), createBlock(resolveDynamicComponent(_ctx.contentTag), { |
| 964 |
href: _ctx.cardLink, |
| 965 |
class: normalizeClass(["cdx-card", { |
| 966 |
"cdx-card--is-link": _ctx.isLink, |
| 967 |
|
| 968 |
"cdx-card--title-only": !_ctx.$slots.description && !_ctx.$slots["supporting-text"] |
| 969 |
}]) |
| 970 |
}, { |
| 971 |
default: withCtx(() => [ |
| 972 |
_ctx.thumbnail || _ctx.forceThumbnail ? (openBlock(), createBlock(_component_cdx_thumbnail, { |
| 973 |
key: 0, |
| 974 |
thumbnail: _ctx.thumbnail, |
| 975 |
"placeholder-icon": _ctx.customPlaceholderIcon, |
| 976 |
class: "cdx-card__thumbnail" |
| 977 |
}, null, 8, ["thumbnail", "placeholder-icon"])) : _ctx.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 978 |
key: 1, |
| 979 |
icon: _ctx.icon, |
| 980 |
class: "cdx-card__icon" |
| 981 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 982 |
createElementVNode("span", _hoisted_1$r, [ |
| 983 |
createElementVNode("span", _hoisted_2$j, [ |
| 984 |
renderSlot(_ctx.$slots, "title") |
| 985 |
]), |
| 986 |
_ctx.$slots.description ? (openBlock(), createElementBlock("span", _hoisted_3$d, [ |
| 987 |
renderSlot(_ctx.$slots, "description") |
| 988 |
])) : createCommentVNode("v-if", true), |
| 989 |
_ctx.$slots["supporting-text"] ? (openBlock(), createElementBlock("span", _hoisted_4$8, [ |
| 990 |
renderSlot(_ctx.$slots, "supporting-text") |
| 991 |
])) : createCommentVNode("v-if", true) |
| 992 |
]) |
| 993 |
]), |
| 994 |
_: 3 |
| 995 |
|
| 996 |
}, 8, ["href", "class"]); |
| 997 |
} |
| 998 |
const Card = _export_sfc(_sfc_main$t, [["render", _sfc_render$t]]); |
| 999 |
function useComputedDisabled(disabledProp) { |
| 1000 |
const providedDisabled = inject(DisabledKey, ref(false)); |
| 1001 |
return computed(() => providedDisabled.value || disabledProp.value); |
| 1002 |
} |
| 1003 |
function useFieldData(disabledProp, statusProp, idAttr) { |
| 1004 |
const computedDisabled = useComputedDisabled(disabledProp); |
| 1005 |
const providedStatus = inject(FieldStatusKey, ref("default")); |
| 1006 |
const computedStatus = computed(() => { |
| 1007 |
if ((statusProp == null ? void 0 : statusProp.value) && statusProp.value !== "default") { |
| 1008 |
return statusProp.value; |
| 1009 |
} |
| 1010 |
return providedStatus.value; |
| 1011 |
}); |
| 1012 |
const providedId = inject(FieldInputIdKey, void 0); |
| 1013 |
const computedInputId = computed(() => { |
| 1014 |
var _a; |
| 1015 |
return (_a = providedId == null ? void 0 : providedId.value) != null ? _a : idAttr; |
| 1016 |
}); |
| 1017 |
return { |
| 1018 |
computedDisabled, |
| 1019 |
computedStatus, |
| 1020 |
computedInputId |
| 1021 |
}; |
| 1022 |
} |
| 1023 |
function useSplitAttributes(attrs, internalClasses = computed(() => ({}))) { |
| 1024 |
const rootClasses = computed(() => { |
| 1025 |
const classRecord = __objRest(internalClasses.value, []); |
| 1026 |
if (attrs.class) { |
| 1027 |
const providedClasses = attrs.class.split(" "); |
| 1028 |
providedClasses.forEach((className) => { |
| 1029 |
classRecord[className] = true; |
| 1030 |
}); |
| 1031 |
} |
| 1032 |
return classRecord; |
| 1033 |
}); |
| 1034 |
const rootStyle = computed(() => { |
| 1035 |
if ("style" in attrs) { |
| 1036 |
return attrs.style; |
| 1037 |
} |
| 1038 |
return void 0; |
| 1039 |
}); |
| 1040 |
const otherAttrs = computed(() => { |
| 1041 |
const _a = attrs, { class: _ignoredClass, style: _ignoredStyle } = _a, attrsCopy = __objRest(_a, ["class", "style"]); |
| 1042 |
return attrsCopy; |
| 1043 |
}); |
| 1044 |
return { |
| 1045 |
rootClasses, |
| 1046 |
rootStyle, |
| 1047 |
otherAttrs |
| 1048 |
}; |
| 1049 |
} |
| 1050 |
function useI18n(messageKey, defaultValue, params = []) { |
| 1051 |
const providedI18nFunc = inject("CdxI18nFunction", void 0); |
| 1052 |
return computed(() => { |
| 1053 |
const unwrappedParams = params.map((p2) => typeof p2 === "function" ? p2() : p2.value); |
| 1054 |
const fromProvidedFunc = providedI18nFunc == null ? void 0 : providedI18nFunc(messageKey, ...unwrappedParams); |
| 1055 |
if (fromProvidedFunc !== void 0 && fromProvidedFunc !== null) { |
| 1056 |
return fromProvidedFunc; |
| 1057 |
} |
| 1058 |
return typeof defaultValue === "function" ? defaultValue(...unwrappedParams) : defaultValue; |
| 1059 |
}); |
| 1060 |
} |
| 1061 |
function useI18nWithOverride(override, messageKey, defaultValue, params = []) { |
| 1062 |
const translatedMessage = useI18n(messageKey, defaultValue, params); |
| 1063 |
return computed(() => override.value || translatedMessage.value); |
| 1064 |
} |
| 1065 |
const _sfc_main$s = defineComponent({ |
| 1066 |
name: "CdxLabel", |
| 1067 |
components: { CdxIcon }, |
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
inheritAttrs: false, |
| 1072 |
props: { |
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
icon: { |
| 1079 |
type: [String, Object], |
| 1080 |
default: null |
| 1081 |
}, |
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
optional: { |
| 1088 |
type: Boolean, |
| 1089 |
default: false |
| 1090 |
}, |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
optionalFlag: { |
| 1098 |
type: String, |
| 1099 |
default: "" |
| 1100 |
}, |
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
visuallyHidden: { |
| 1105 |
type: Boolean, |
| 1106 |
default: false |
| 1107 |
}, |
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
isLegend: { |
| 1115 |
type: Boolean, |
| 1116 |
default: false |
| 1117 |
}, |
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
inputId: { |
| 1124 |
type: String, |
| 1125 |
default: "" |
| 1126 |
}, |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
descriptionId: { |
| 1133 |
type: String, |
| 1134 |
default: "" |
| 1135 |
}, |
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
disabled: { |
| 1140 |
type: Boolean, |
| 1141 |
default: false |
| 1142 |
} |
| 1143 |
}, |
| 1144 |
setup(props, { attrs }) { |
| 1145 |
const { computedDisabled } = useFieldData(toRef(props, "disabled")); |
| 1146 |
const internalClasses = computed(() => { |
| 1147 |
return { |
| 1148 |
"cdx-label--visually-hidden": props.visuallyHidden, |
| 1149 |
"cdx-label--disabled": computedDisabled.value |
| 1150 |
}; |
| 1151 |
}); |
| 1152 |
const { |
| 1153 |
rootClasses, |
| 1154 |
rootStyle, |
| 1155 |
otherAttrs |
| 1156 |
} = useSplitAttributes(attrs, internalClasses); |
| 1157 |
const translatedOptionalFlag = useI18nWithOverride( |
| 1158 |
toRef(props, "optionalFlag"), |
| 1159 |
"cdx-label-optional-flag", |
| 1160 |
"(optional)" |
| 1161 |
); |
| 1162 |
return { |
| 1163 |
rootClasses, |
| 1164 |
rootStyle, |
| 1165 |
otherAttrs, |
| 1166 |
translatedOptionalFlag |
| 1167 |
}; |
| 1168 |
} |
| 1169 |
}); |
| 1170 |
const _hoisted_1$q = ["for"]; |
| 1171 |
const _hoisted_2$i = { class: "cdx-label__label__text" }; |
| 1172 |
const _hoisted_3$c = { |
| 1173 |
key: 1, |
| 1174 |
class: "cdx-label__label__optional-flag" |
| 1175 |
}; |
| 1176 |
const _hoisted_4$7 = ["id"]; |
| 1177 |
const _hoisted_5$7 = { class: "cdx-label__label" }; |
| 1178 |
const _hoisted_6$6 = { class: "cdx-label__label__text" }; |
| 1179 |
const _hoisted_7$2 = { |
| 1180 |
key: 1, |
| 1181 |
class: "cdx-label__label__optional-flag" |
| 1182 |
}; |
| 1183 |
const _hoisted_8$1 = { |
| 1184 |
key: 0, |
| 1185 |
class: "cdx-label__description" |
| 1186 |
}; |
| 1187 |
function _sfc_render$s(_ctx, _cache, $props, $setup, $data, $options) { |
| 1188 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 1189 |
return !_ctx.isLegend ? (openBlock(), createElementBlock( |
| 1190 |
"div", |
| 1191 |
{ |
| 1192 |
key: 0, |
| 1193 |
class: normalizeClass(["cdx-label", _ctx.rootClasses]), |
| 1194 |
style: normalizeStyle(_ctx.rootStyle) |
| 1195 |
}, |
| 1196 |
[ |
| 1197 |
createElementVNode("label", mergeProps({ |
| 1198 |
class: "cdx-label__label", |
| 1199 |
for: _ctx.inputId ? _ctx.inputId : void 0 |
| 1200 |
}, _ctx.otherAttrs), [ |
| 1201 |
_ctx.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 1202 |
key: 0, |
| 1203 |
icon: _ctx.icon, |
| 1204 |
class: "cdx-label__label__icon" |
| 1205 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 1206 |
createElementVNode("span", _hoisted_2$i, [ |
| 1207 |
renderSlot(_ctx.$slots, "default") |
| 1208 |
]), |
| 1209 |
_ctx.optionalFlag || _ctx.optional ? (openBlock(), createElementBlock( |
| 1210 |
"span", |
| 1211 |
_hoisted_3$c, |
| 1212 |
toDisplayString(" ") + " " + toDisplayString(_ctx.translatedOptionalFlag), |
| 1213 |
1 |
| 1214 |
|
| 1215 |
)) : createCommentVNode("v-if", true) |
| 1216 |
], 16, _hoisted_1$q), |
| 1217 |
_ctx.$slots.description && _ctx.$slots.description().length > 0 ? (openBlock(), createElementBlock("span", { |
| 1218 |
key: 0, |
| 1219 |
id: _ctx.descriptionId || void 0, |
| 1220 |
class: "cdx-label__description" |
| 1221 |
}, [ |
| 1222 |
renderSlot(_ctx.$slots, "description") |
| 1223 |
], 8, _hoisted_4$7)) : createCommentVNode("v-if", true) |
| 1224 |
], |
| 1225 |
6 |
| 1226 |
|
| 1227 |
)) : (openBlock(), createElementBlock( |
| 1228 |
"legend", |
| 1229 |
mergeProps({ |
| 1230 |
key: 1, |
| 1231 |
class: ["cdx-label", _ctx.rootClasses], |
| 1232 |
style: _ctx.rootStyle |
| 1233 |
}, _ctx.otherAttrs), |
| 1234 |
[ |
| 1235 |
createElementVNode("span", _hoisted_5$7, [ |
| 1236 |
_ctx.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 1237 |
key: 0, |
| 1238 |
icon: _ctx.icon, |
| 1239 |
class: "cdx-label__label__icon" |
| 1240 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 1241 |
createElementVNode("span", _hoisted_6$6, [ |
| 1242 |
renderSlot(_ctx.$slots, "default") |
| 1243 |
]), |
| 1244 |
_ctx.optionalFlag || _ctx.optional ? (openBlock(), createElementBlock( |
| 1245 |
"span", |
| 1246 |
_hoisted_7$2, |
| 1247 |
toDisplayString(" ") + " " + toDisplayString(_ctx.translatedOptionalFlag), |
| 1248 |
1 |
| 1249 |
|
| 1250 |
)) : createCommentVNode("v-if", true) |
| 1251 |
]), |
| 1252 |
_ctx.$slots.description && _ctx.$slots.description().length > 0 ? (openBlock(), createElementBlock("span", _hoisted_8$1, [ |
| 1253 |
renderSlot(_ctx.$slots, "description") |
| 1254 |
])) : createCommentVNode("v-if", true) |
| 1255 |
], |
| 1256 |
16 |
| 1257 |
|
| 1258 |
)); |
| 1259 |
} |
| 1260 |
const CdxLabel = _export_sfc(_sfc_main$s, [["render", _sfc_render$s]]); |
| 1261 |
function useLabelChecker(slot, attrs, componentName) { |
| 1262 |
useWarnOnce( |
| 1263 |
() => useSlotContents(slot).length === 0 && !(attrs == null ? void 0 : attrs["aria-label"]) && !(attrs == null ? void 0 : attrs["aria-labelledby"]), |
| 1264 |
"".concat(componentName, ": Inputs must have an associated label. Provide one of the following:\n - A label via the appropriate slot\n - An `aria-label` attribute set to the label text\n - An `aria-labelledby` attribute set to the ID of the label element") |
| 1265 |
); |
| 1266 |
} |
| 1267 |
function useModelWrapper(modelValueRef, emit, eventName) { |
| 1268 |
return computed({ |
| 1269 |
get: () => modelValueRef.value, |
| 1270 |
set: (value) => ( |
| 1271 |
|
| 1272 |
|
| 1273 |
emit(eventName || "update:modelValue", value) |
| 1274 |
) |
| 1275 |
}); |
| 1276 |
} |
| 1277 |
let counter = 0; |
| 1278 |
function useGeneratedId(identifier) { |
| 1279 |
var _a; |
| 1280 |
const vm = getCurrentInstance(); |
| 1281 |
const externalId = (_a = vm == null ? void 0 : vm.props.id) != null ? _a : vm == null ? void 0 : vm.attrs.id; |
| 1282 |
if (identifier) { |
| 1283 |
return "".concat(LibraryPrefix, "-").concat(identifier, "-").concat(counter++); |
| 1284 |
} else if (externalId) { |
| 1285 |
return "".concat(LibraryPrefix, "-").concat(externalId, "-").concat(counter++); |
| 1286 |
} else { |
| 1287 |
return "".concat(LibraryPrefix, "-").concat(counter++); |
| 1288 |
} |
| 1289 |
} |
| 1290 |
const statusValidator$a = makeStringTypeValidator(ValidationStatusTypes); |
| 1291 |
const _sfc_main$r = defineComponent({ |
| 1292 |
name: "CdxCheckbox", |
| 1293 |
components: { CdxLabel }, |
| 1294 |
props: { |
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
modelValue: { |
| 1301 |
type: [Boolean, Array], |
| 1302 |
default: false |
| 1303 |
}, |
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
inputValue: { |
| 1310 |
type: [String, Number, Boolean], |
| 1311 |
default: false |
| 1312 |
}, |
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
name: { |
| 1317 |
type: String, |
| 1318 |
default: null |
| 1319 |
}, |
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
disabled: { |
| 1324 |
type: Boolean, |
| 1325 |
default: false |
| 1326 |
}, |
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
indeterminate: { |
| 1334 |
type: Boolean, |
| 1335 |
default: false |
| 1336 |
}, |
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
inline: { |
| 1344 |
type: Boolean, |
| 1345 |
default: false |
| 1346 |
}, |
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
hideLabel: { |
| 1353 |
type: Boolean, |
| 1354 |
default: false |
| 1355 |
}, |
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
status: { |
| 1360 |
type: String, |
| 1361 |
default: "default", |
| 1362 |
validator: statusValidator$a |
| 1363 |
} |
| 1364 |
}, |
| 1365 |
emits: [ |
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
"update:modelValue" |
| 1372 |
], |
| 1373 |
setup(props, { emit, slots, attrs }) { |
| 1374 |
var _a; |
| 1375 |
useLabelChecker((_a = slots.default) == null ? void 0 : _a.call(slots), attrs, "CdxCheckbox"); |
| 1376 |
const { |
| 1377 |
computedDisabled, |
| 1378 |
computedStatus |
| 1379 |
} = useFieldData( |
| 1380 |
toRef(props, "disabled"), |
| 1381 |
toRef(props, "status") |
| 1382 |
); |
| 1383 |
const rootClasses = computed(() => { |
| 1384 |
return { |
| 1385 |
"cdx-checkbox--inline": props.inline, |
| 1386 |
["cdx-checkbox--status-".concat(computedStatus.value)]: true |
| 1387 |
}; |
| 1388 |
}); |
| 1389 |
const customInputClasses = computed(() => { |
| 1390 |
return { |
| 1391 |
"cdx-checkbox__custom-input--inline": props.inline |
| 1392 |
}; |
| 1393 |
}); |
| 1394 |
const input = ref(); |
| 1395 |
const checkboxId = useGeneratedId("checkbox"); |
| 1396 |
const descriptionId = useGeneratedId("description"); |
| 1397 |
const wrappedModel = useModelWrapper(toRef(props, "modelValue"), emit); |
| 1398 |
return { |
| 1399 |
rootClasses, |
| 1400 |
computedDisabled, |
| 1401 |
input, |
| 1402 |
checkboxId, |
| 1403 |
descriptionId, |
| 1404 |
wrappedModel, |
| 1405 |
customInputClasses |
| 1406 |
}; |
| 1407 |
} |
| 1408 |
}); |
| 1409 |
const _hoisted_1$p = { class: "cdx-checkbox__wrapper" }; |
| 1410 |
const _hoisted_2$h = ["id", "aria-describedby", "value", "name", "disabled", ".indeterminate"]; |
| 1411 |
const _hoisted_3$b = createElementVNode( |
| 1412 |
"span", |
| 1413 |
{ class: "cdx-checkbox__icon" }, |
| 1414 |
null, |
| 1415 |
-1 |
| 1416 |
|
| 1417 |
); |
| 1418 |
function _sfc_render$r(_ctx, _cache, $props, $setup, $data, $options) { |
| 1419 |
const _component_cdx_label = resolveComponent("cdx-label"); |
| 1420 |
return openBlock(), createElementBlock( |
| 1421 |
"div", |
| 1422 |
{ |
| 1423 |
class: normalizeClass(["cdx-checkbox", _ctx.rootClasses]) |
| 1424 |
}, |
| 1425 |
[ |
| 1426 |
createElementVNode("div", _hoisted_1$p, [ |
| 1427 |
withDirectives(createElementVNode("input", { |
| 1428 |
id: _ctx.checkboxId, |
| 1429 |
ref: "input", |
| 1430 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedModel = $event), |
| 1431 |
class: "cdx-checkbox__input", |
| 1432 |
type: "checkbox", |
| 1433 |
"aria-describedby": _ctx.$slots.description && _ctx.$slots.description().length > 0 ? _ctx.descriptionId : void 0, |
| 1434 |
value: _ctx.inputValue, |
| 1435 |
name: _ctx.name, |
| 1436 |
disabled: _ctx.computedDisabled, |
| 1437 |
".indeterminate": _ctx.indeterminate |
| 1438 |
}, null, 40, _hoisted_2$h), [ |
| 1439 |
[vModelCheckbox, _ctx.wrappedModel] |
| 1440 |
]), |
| 1441 |
_hoisted_3$b, |
| 1442 |
_ctx.$slots.default && _ctx.$slots.default().length ? (openBlock(), createBlock(_component_cdx_label, { |
| 1443 |
key: 0, |
| 1444 |
class: "cdx-checkbox__label", |
| 1445 |
"input-id": _ctx.checkboxId, |
| 1446 |
"description-id": _ctx.$slots.description && _ctx.$slots.description().length > 0 ? _ctx.descriptionId : void 0, |
| 1447 |
disabled: _ctx.computedDisabled, |
| 1448 |
"visually-hidden": _ctx.hideLabel |
| 1449 |
}, createSlots({ |
| 1450 |
default: withCtx(() => [ |
| 1451 |
renderSlot(_ctx.$slots, "default") |
| 1452 |
]), |
| 1453 |
_: 2 |
| 1454 |
|
| 1455 |
}, [ |
| 1456 |
_ctx.$slots.description && _ctx.$slots.description().length > 0 ? { |
| 1457 |
name: "description", |
| 1458 |
fn: withCtx(() => [ |
| 1459 |
renderSlot(_ctx.$slots, "description") |
| 1460 |
]), |
| 1461 |
key: "0" |
| 1462 |
} : void 0 |
| 1463 |
]), 1032, ["input-id", "description-id", "disabled", "visually-hidden"])) : createCommentVNode("v-if", true) |
| 1464 |
]), |
| 1465 |
_ctx.$slots["custom-input"] ? (openBlock(), createElementBlock( |
| 1466 |
"div", |
| 1467 |
{ |
| 1468 |
key: 0, |
| 1469 |
class: normalizeClass(["cdx-checkbox__custom-input", _ctx.customInputClasses]) |
| 1470 |
}, |
| 1471 |
[ |
| 1472 |
renderSlot(_ctx.$slots, "custom-input") |
| 1473 |
], |
| 1474 |
2 |
| 1475 |
|
| 1476 |
)) : createCommentVNode("v-if", true) |
| 1477 |
], |
| 1478 |
2 |
| 1479 |
|
| 1480 |
); |
| 1481 |
} |
| 1482 |
const CdxCheckbox = _export_sfc(_sfc_main$r, [["render", _sfc_render$r]]); |
| 1483 |
const _sfc_main$q = defineComponent({ |
| 1484 |
name: "CdxInputChip", |
| 1485 |
components: { |
| 1486 |
CdxButton, |
| 1487 |
CdxIcon |
| 1488 |
}, |
| 1489 |
props: { |
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
icon: { |
| 1494 |
type: [String, Object], |
| 1495 |
default: null |
| 1496 |
}, |
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
disabled: { |
| 1501 |
type: Boolean, |
| 1502 |
default: false |
| 1503 |
} |
| 1504 |
}, |
| 1505 |
expose: [ |
| 1506 |
"focus" |
| 1507 |
], |
| 1508 |
emits: [ |
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
"remove-chip", |
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
"click-chip", |
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
"arrow-left", |
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
"arrow-right" |
| 1527 |
], |
| 1528 |
setup(props, { emit }) { |
| 1529 |
const rootElement = ref(); |
| 1530 |
const rootClasses = computed(() => { |
| 1531 |
return { |
| 1532 |
"cdx-input-chip--disabled": props.disabled |
| 1533 |
}; |
| 1534 |
}); |
| 1535 |
const ariaDescription = useI18n( |
| 1536 |
"cdx-input-chip-aria-description", |
| 1537 |
"Press Enter to edit or Delete to remove" |
| 1538 |
); |
| 1539 |
function onKeydown(e) { |
| 1540 |
var _a; |
| 1541 |
switch (e.key) { |
| 1542 |
case "Enter": |
| 1543 |
emit("click-chip"); |
| 1544 |
e.preventDefault(); |
| 1545 |
e.stopPropagation(); |
| 1546 |
break; |
| 1547 |
case "Escape": |
| 1548 |
(_a = rootElement.value) == null ? void 0 : _a.blur(); |
| 1549 |
e.preventDefault(); |
| 1550 |
e.stopPropagation(); |
| 1551 |
break; |
| 1552 |
case "Backspace": |
| 1553 |
case "Delete": |
| 1554 |
emit("remove-chip", e.key); |
| 1555 |
e.preventDefault(); |
| 1556 |
e.stopPropagation(); |
| 1557 |
break; |
| 1558 |
case "ArrowLeft": |
| 1559 |
emit("arrow-left"); |
| 1560 |
e.preventDefault(); |
| 1561 |
e.stopPropagation(); |
| 1562 |
break; |
| 1563 |
case "ArrowRight": |
| 1564 |
emit("arrow-right"); |
| 1565 |
e.preventDefault(); |
| 1566 |
e.stopPropagation(); |
| 1567 |
break; |
| 1568 |
} |
| 1569 |
} |
| 1570 |
return { |
| 1571 |
rootElement, |
| 1572 |
rootClasses, |
| 1573 |
ariaDescription, |
| 1574 |
onKeydown, |
| 1575 |
cdxIconClose: X3 |
| 1576 |
}; |
| 1577 |
}, |
| 1578 |
methods: { |
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
|
| 1584 |
focus() { |
| 1585 |
this.$refs.rootElement.focus(); |
| 1586 |
} |
| 1587 |
} |
| 1588 |
}); |
| 1589 |
const _hoisted_1$o = ["aria-description"]; |
| 1590 |
const _hoisted_2$g = { class: "cdx-input-chip__text" }; |
| 1591 |
function _sfc_render$q(_ctx, _cache, $props, $setup, $data, $options) { |
| 1592 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 1593 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 1594 |
return openBlock(), createElementBlock("div", { |
| 1595 |
ref: "rootElement", |
| 1596 |
class: normalizeClass(["cdx-input-chip", _ctx.rootClasses]), |
| 1597 |
tabindex: "0", |
| 1598 |
role: "option", |
| 1599 |
"aria-description": _ctx.ariaDescription, |
| 1600 |
onKeydown: _cache[1] || (_cache[1] = (...args) => _ctx.onKeydown && _ctx.onKeydown(...args)), |
| 1601 |
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("click-chip")) |
| 1602 |
}, [ |
| 1603 |
_ctx.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 1604 |
key: 0, |
| 1605 |
icon: _ctx.icon, |
| 1606 |
size: "small" |
| 1607 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 1608 |
createElementVNode("span", _hoisted_2$g, [ |
| 1609 |
renderSlot(_ctx.$slots, "default") |
| 1610 |
]), |
| 1611 |
createVNode(_component_cdx_button, { |
| 1612 |
class: "cdx-input-chip__button", |
| 1613 |
weight: "quiet", |
| 1614 |
tabindex: "-1", |
| 1615 |
"aria-hidden": "true", |
| 1616 |
disabled: _ctx.disabled, |
| 1617 |
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.$emit("remove-chip", "button"), ["stop"])) |
| 1618 |
}, { |
| 1619 |
default: withCtx(() => [ |
| 1620 |
createVNode(_component_cdx_icon, { |
| 1621 |
icon: _ctx.cdxIconClose, |
| 1622 |
size: "x-small" |
| 1623 |
}, null, 8, ["icon"]) |
| 1624 |
]), |
| 1625 |
_: 1 |
| 1626 |
|
| 1627 |
}, 8, ["disabled"]) |
| 1628 |
], 42, _hoisted_1$o); |
| 1629 |
} |
| 1630 |
const CdxInputChip = _export_sfc(_sfc_main$q, [["render", _sfc_render$q]]); |
| 1631 |
function useOptionalModelWrapper(internalValueRef, modelValueRef, emit, eventName) { |
| 1632 |
return computed({ |
| 1633 |
get: () => { |
| 1634 |
var _a; |
| 1635 |
return (_a = modelValueRef.value) != null ? _a : internalValueRef.value; |
| 1636 |
}, |
| 1637 |
set: (value) => { |
| 1638 |
if (modelValueRef.value !== null) { |
| 1639 |
emit(eventName || "update:modelValue", value); |
| 1640 |
} else { |
| 1641 |
internalValueRef.value = value; |
| 1642 |
} |
| 1643 |
} |
| 1644 |
}); |
| 1645 |
} |
| 1646 |
const statusValidator$9 = makeStringTypeValidator(ValidationStatusTypes); |
| 1647 |
const _sfc_main$p = defineComponent({ |
| 1648 |
name: "CdxChipInput", |
| 1649 |
components: { |
| 1650 |
CdxInputChip |
| 1651 |
}, |
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
inheritAttrs: false, |
| 1656 |
props: { |
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
inputChips: { |
| 1663 |
type: Array, |
| 1664 |
required: true |
| 1665 |
}, |
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
inputValue: { |
| 1673 |
type: [String, Number], |
| 1674 |
default: null |
| 1675 |
}, |
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
separateInput: { |
| 1682 |
type: Boolean, |
| 1683 |
default: false |
| 1684 |
}, |
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
status: { |
| 1689 |
type: String, |
| 1690 |
default: "default", |
| 1691 |
validator: statusValidator$9 |
| 1692 |
}, |
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
chipValidator: { |
| 1698 |
type: Function, |
| 1699 |
|
| 1700 |
default: (value) => true |
| 1701 |
}, |
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
disabled: { |
| 1706 |
type: Boolean, |
| 1707 |
default: false |
| 1708 |
} |
| 1709 |
}, |
| 1710 |
emits: [ |
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
"update:input-chips", |
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
"update:input-value" |
| 1723 |
], |
| 1724 |
setup(props, { emit, attrs }) { |
| 1725 |
const rootElement = ref(); |
| 1726 |
const chipsContainer = ref(); |
| 1727 |
const separateInputWrapper = ref(); |
| 1728 |
const statusMessageContent = ref(""); |
| 1729 |
const computedDirection = useComputedDirection(rootElement); |
| 1730 |
const input = ref(); |
| 1731 |
const allowArbitrary = inject(AllowArbitraryKey, ref(true)); |
| 1732 |
const internalInputValue = ref(""); |
| 1733 |
const computedInputValue = useOptionalModelWrapper( |
| 1734 |
internalInputValue, |
| 1735 |
toRef(props, "inputValue"), |
| 1736 |
emit, |
| 1737 |
"update:input-value" |
| 1738 |
); |
| 1739 |
const validatedStatus = ref("default"); |
| 1740 |
const internalStatus = computed(() => { |
| 1741 |
if (validatedStatus.value === "error" || props.status === "error") { |
| 1742 |
return "error"; |
| 1743 |
} |
| 1744 |
return "default"; |
| 1745 |
}); |
| 1746 |
const { computedDisabled, computedStatus } = useFieldData(toRef(props, "disabled"), internalStatus); |
| 1747 |
const isFocused = ref(false); |
| 1748 |
const internalClasses = computed(() => { |
| 1749 |
return { |
| 1750 |
"cdx-chip-input--has-separate-input": props.separateInput, |
| 1751 |
["cdx-chip-input--status-".concat(computedStatus.value)]: true, |
| 1752 |
|
| 1753 |
|
| 1754 |
"cdx-chip-input--focused": isFocused.value, |
| 1755 |
"cdx-chip-input--disabled": computedDisabled.value |
| 1756 |
}; |
| 1757 |
}); |
| 1758 |
const { |
| 1759 |
rootClasses, |
| 1760 |
rootStyle, |
| 1761 |
otherAttrs |
| 1762 |
} = useSplitAttributes(attrs, internalClasses); |
| 1763 |
const chipRefs = []; |
| 1764 |
const currentChipToRemove = ref(null); |
| 1765 |
const computedChipToRemove = computed(() => currentChipToRemove.value ? currentChipToRemove.value.value : ""); |
| 1766 |
const chipAddedMessage = useI18n( |
| 1767 |
"cdx-chip-input-chip-added", |
| 1768 |
(x) => "Chip ".concat(x, " was added."), |
| 1769 |
[computedInputValue] |
| 1770 |
); |
| 1771 |
const chipRemovedMessage = useI18n( |
| 1772 |
"cdx-chip-input-chip-removed", |
| 1773 |
(x) => "Chip ".concat(x, " was removed."), |
| 1774 |
[computedChipToRemove] |
| 1775 |
); |
| 1776 |
function assignChipTemplateRef(chip, index) { |
| 1777 |
if (chip !== null) { |
| 1778 |
chipRefs[index] = chip; |
| 1779 |
} |
| 1780 |
} |
| 1781 |
const focusInput = () => { |
| 1782 |
input.value.focus(); |
| 1783 |
}; |
| 1784 |
function addChip() { |
| 1785 |
if ( |
| 1786 |
|
| 1787 |
!!props.inputChips.find((chip) => chip.value === computedInputValue.value) || |
| 1788 |
!props.chipValidator(computedInputValue.value) |
| 1789 |
) { |
| 1790 |
validatedStatus.value = "error"; |
| 1791 |
} else if (computedInputValue.value.toString().length > 0) { |
| 1792 |
statusMessageContent.value = chipAddedMessage.value; |
| 1793 |
emit("update:input-chips", props.inputChips.concat({ value: computedInputValue.value })); |
| 1794 |
computedInputValue.value = ""; |
| 1795 |
} |
| 1796 |
} |
| 1797 |
function removeChip(chipToRemove) { |
| 1798 |
emit("update:input-chips", props.inputChips.filter( |
| 1799 |
(chip) => chip.value !== chipToRemove.value |
| 1800 |
)); |
| 1801 |
} |
| 1802 |
function moveChipFocus(direction, startIndex) { |
| 1803 |
const resolvedDirection = ( |
| 1804 |
|
| 1805 |
computedDirection.value === "ltr" && direction === "left" || computedDirection.value === "rtl" && direction === "right" ? -1 : 1 |
| 1806 |
); |
| 1807 |
const newIndex = startIndex + resolvedDirection; |
| 1808 |
if (newIndex < 0) { |
| 1809 |
return; |
| 1810 |
} |
| 1811 |
if (newIndex >= props.inputChips.length) { |
| 1812 |
focusInput(); |
| 1813 |
return; |
| 1814 |
} |
| 1815 |
chipRefs[newIndex].focus(); |
| 1816 |
} |
| 1817 |
function handleChipClick(clickedChip) { |
| 1818 |
return __async(this, null, function* () { |
| 1819 |
var _a; |
| 1820 |
addChip(); |
| 1821 |
yield nextTick(); |
| 1822 |
removeChip(clickedChip); |
| 1823 |
computedInputValue.value = (_a = clickedChip.label) != null ? _a : clickedChip.value; |
| 1824 |
focusInput(); |
| 1825 |
}); |
| 1826 |
} |
| 1827 |
function handleChipRemove(chipToRemove, index, method) { |
| 1828 |
currentChipToRemove.value = chipToRemove; |
| 1829 |
statusMessageContent.value = chipRemovedMessage.value; |
| 1830 |
if (method === "button") { |
| 1831 |
focusInput(); |
| 1832 |
} else if (method === "Backspace") { |
| 1833 |
const newIndex = index === 0 ? 1 : index - 1; |
| 1834 |
if (newIndex < props.inputChips.length) { |
| 1835 |
chipRefs[newIndex].focus(); |
| 1836 |
} else { |
| 1837 |
focusInput(); |
| 1838 |
} |
| 1839 |
} else if (method === "Delete") { |
| 1840 |
const newIndex = index + 1; |
| 1841 |
if (newIndex < props.inputChips.length) { |
| 1842 |
chipRefs[newIndex].focus(); |
| 1843 |
} else { |
| 1844 |
focusInput(); |
| 1845 |
} |
| 1846 |
} |
| 1847 |
removeChip(chipToRemove); |
| 1848 |
} |
| 1849 |
function onInputKeydown(e) { |
| 1850 |
var _a, _b; |
| 1851 |
const prevArrow = computedDirection.value === "rtl" ? "ArrowRight" : "ArrowLeft"; |
| 1852 |
switch (e.key) { |
| 1853 |
case "Enter": |
| 1854 |
if (computedInputValue.value.toString().length > 0 && allowArbitrary.value) { |
| 1855 |
addChip(); |
| 1856 |
e.preventDefault(); |
| 1857 |
e.stopPropagation(); |
| 1858 |
return; |
| 1859 |
} |
| 1860 |
break; |
| 1861 |
case "Escape": |
| 1862 |
(_a = input.value) == null ? void 0 : _a.blur(); |
| 1863 |
e.preventDefault(); |
| 1864 |
e.stopPropagation(); |
| 1865 |
return; |
| 1866 |
case "Backspace": |
| 1867 |
case prevArrow: |
| 1868 |
if (((_b = input.value) == null ? void 0 : _b.selectionStart) === 0 && input.value.selectionEnd === 0 && props.inputChips.length > 0) { |
| 1869 |
chipRefs[props.inputChips.length - 1].focus(); |
| 1870 |
e.preventDefault(); |
| 1871 |
e.stopPropagation(); |
| 1872 |
return; |
| 1873 |
} |
| 1874 |
break; |
| 1875 |
} |
| 1876 |
} |
| 1877 |
function onInputFocus() { |
| 1878 |
isFocused.value = true; |
| 1879 |
} |
| 1880 |
function onInputBlur() { |
| 1881 |
isFocused.value = false; |
| 1882 |
} |
| 1883 |
function onFocusOut(e) { |
| 1884 |
var _a; |
| 1885 |
if (!((_a = rootElement.value) == null ? void 0 : _a.contains(e.relatedTarget)) && allowArbitrary.value) { |
| 1886 |
addChip(); |
| 1887 |
} |
| 1888 |
} |
| 1889 |
watch(toRef(props, "inputChips"), (newVal) => { |
| 1890 |
const matchingChip = newVal.find((chip) => chip.value === computedInputValue.value); |
| 1891 |
validatedStatus.value = matchingChip ? "error" : "default"; |
| 1892 |
}); |
| 1893 |
watch(computedInputValue, () => { |
| 1894 |
if (validatedStatus.value === "error") { |
| 1895 |
validatedStatus.value = "default"; |
| 1896 |
} |
| 1897 |
}); |
| 1898 |
return { |
| 1899 |
rootElement, |
| 1900 |
chipsContainer, |
| 1901 |
separateInputWrapper, |
| 1902 |
input, |
| 1903 |
computedInputValue, |
| 1904 |
rootClasses, |
| 1905 |
rootStyle, |
| 1906 |
otherAttrs, |
| 1907 |
assignChipTemplateRef, |
| 1908 |
handleChipClick, |
| 1909 |
handleChipRemove, |
| 1910 |
moveChipFocus, |
| 1911 |
onInputKeydown, |
| 1912 |
focusInput, |
| 1913 |
onInputFocus, |
| 1914 |
onInputBlur, |
| 1915 |
onFocusOut, |
| 1916 |
computedDisabled, |
| 1917 |
statusMessageContent |
| 1918 |
}; |
| 1919 |
} |
| 1920 |
}); |
| 1921 |
const _hoisted_1$n = { |
| 1922 |
ref: "chipsContainer", |
| 1923 |
class: "cdx-chip-input__chips", |
| 1924 |
role: "listbox", |
| 1925 |
"aria-orientation": "horizontal" |
| 1926 |
}; |
| 1927 |
const _hoisted_2$f = ["disabled"]; |
| 1928 |
const _hoisted_3$a = { |
| 1929 |
key: 0, |
| 1930 |
ref: "separateInputWrapper", |
| 1931 |
class: "cdx-chip-input__separate-input" |
| 1932 |
}; |
| 1933 |
const _hoisted_4$6 = ["disabled"]; |
| 1934 |
const _hoisted_5$6 = { |
| 1935 |
class: "cdx-chip-input__aria-status", |
| 1936 |
role: "status", |
| 1937 |
"aria-live": "polite" |
| 1938 |
}; |
| 1939 |
function _sfc_render$p(_ctx, _cache, $props, $setup, $data, $options) { |
| 1940 |
const _component_cdx_input_chip = resolveComponent("cdx-input-chip"); |
| 1941 |
return openBlock(), createElementBlock( |
| 1942 |
"div", |
| 1943 |
{ |
| 1944 |
ref: "rootElement", |
| 1945 |
class: normalizeClass(["cdx-chip-input", _ctx.rootClasses]), |
| 1946 |
style: normalizeStyle(_ctx.rootStyle), |
| 1947 |
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.focusInput && _ctx.focusInput(...args)), |
| 1948 |
onFocusout: _cache[9] || (_cache[9] = (...args) => _ctx.onFocusOut && _ctx.onFocusOut(...args)) |
| 1949 |
}, |
| 1950 |
[ |
| 1951 |
createElementVNode( |
| 1952 |
"div", |
| 1953 |
_hoisted_1$n, |
| 1954 |
[ |
| 1955 |
(openBlock(true), createElementBlock( |
| 1956 |
Fragment, |
| 1957 |
null, |
| 1958 |
renderList(_ctx.inputChips, (chip, index) => { |
| 1959 |
return openBlock(), createBlock(_component_cdx_input_chip, { |
| 1960 |
key: chip.value, |
| 1961 |
ref_for: true, |
| 1962 |
ref: (ref2) => _ctx.assignChipTemplateRef(ref2, index), |
| 1963 |
class: "cdx-chip-input__item", |
| 1964 |
icon: chip.icon, |
| 1965 |
disabled: _ctx.computedDisabled, |
| 1966 |
onClickChip: ($event) => _ctx.handleChipClick(chip), |
| 1967 |
onRemoveChip: (method) => _ctx.handleChipRemove(chip, index, method), |
| 1968 |
onArrowLeft: ($event) => _ctx.moveChipFocus("left", index), |
| 1969 |
onArrowRight: ($event) => _ctx.moveChipFocus("right", index) |
| 1970 |
}, { |
| 1971 |
default: withCtx(() => { |
| 1972 |
var _a; |
| 1973 |
return [ |
| 1974 |
createTextVNode( |
| 1975 |
toDisplayString((_a = chip.label) != null ? _a : chip.value), |
| 1976 |
1 |
| 1977 |
|
| 1978 |
) |
| 1979 |
]; |
| 1980 |
}), |
| 1981 |
_: 2 |
| 1982 |
|
| 1983 |
}, 1032, ["icon", "disabled", "onClickChip", "onRemoveChip", "onArrowLeft", "onArrowRight"]); |
| 1984 |
}), |
| 1985 |
128 |
| 1986 |
|
| 1987 |
)), |
| 1988 |
!_ctx.separateInput ? withDirectives((openBlock(), createElementBlock("input", mergeProps({ |
| 1989 |
key: 0, |
| 1990 |
ref: "input", |
| 1991 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.computedInputValue = $event), |
| 1992 |
class: "cdx-chip-input__input", |
| 1993 |
disabled: _ctx.computedDisabled |
| 1994 |
}, _ctx.otherAttrs, { |
| 1995 |
onBlur: _cache[1] || (_cache[1] = (...args) => _ctx.onInputBlur && _ctx.onInputBlur(...args)), |
| 1996 |
onFocus: _cache[2] || (_cache[2] = (...args) => _ctx.onInputFocus && _ctx.onInputFocus(...args)), |
| 1997 |
onKeydown: _cache[3] || (_cache[3] = (...args) => _ctx.onInputKeydown && _ctx.onInputKeydown(...args)) |
| 1998 |
}), null, 16, _hoisted_2$f)), [ |
| 1999 |
[vModelDynamic, _ctx.computedInputValue] |
| 2000 |
]) : createCommentVNode("v-if", true) |
| 2001 |
], |
| 2002 |
512 |
| 2003 |
|
| 2004 |
), |
| 2005 |
_ctx.separateInput ? (openBlock(), createElementBlock( |
| 2006 |
"div", |
| 2007 |
_hoisted_3$a, |
| 2008 |
[ |
| 2009 |
withDirectives(createElementVNode("input", mergeProps({ |
| 2010 |
ref: "input", |
| 2011 |
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => _ctx.computedInputValue = $event), |
| 2012 |
class: "cdx-chip-input__input", |
| 2013 |
disabled: _ctx.computedDisabled |
| 2014 |
}, _ctx.otherAttrs, { |
| 2015 |
onBlur: _cache[5] || (_cache[5] = (...args) => _ctx.onInputBlur && _ctx.onInputBlur(...args)), |
| 2016 |
onFocus: _cache[6] || (_cache[6] = (...args) => _ctx.onInputFocus && _ctx.onInputFocus(...args)), |
| 2017 |
onKeydown: _cache[7] || (_cache[7] = (...args) => _ctx.onInputKeydown && _ctx.onInputKeydown(...args)) |
| 2018 |
}), null, 16, _hoisted_4$6), [ |
| 2019 |
[vModelDynamic, _ctx.computedInputValue] |
| 2020 |
]) |
| 2021 |
], |
| 2022 |
512 |
| 2023 |
|
| 2024 |
)) : createCommentVNode("v-if", true), |
| 2025 |
createElementVNode( |
| 2026 |
"div", |
| 2027 |
_hoisted_5$6, |
| 2028 |
toDisplayString(_ctx.statusMessageContent), |
| 2029 |
1 |
| 2030 |
|
| 2031 |
) |
| 2032 |
], |
| 2033 |
38 |
| 2034 |
|
| 2035 |
); |
| 2036 |
} |
| 2037 |
const CdxChipInput = _export_sfc(_sfc_main$p, [["render", _sfc_render$p]]); |
| 2038 |
function regExpEscape(value) { |
| 2039 |
return value.replace(/([\\{}()|.?*+\-^$[\]])/g, "\\$1"); |
| 2040 |
} |
| 2041 |
const COMBINING_MARK = "[̀-ͯ҃-҉֑-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࣓-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣ৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఀ-ఄా-ౄె-ైొ-్ౕౖౢౣಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝᠋-᠍ᢅᢆᢩᤠ-ᤫᤰ-᤻ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼᪰-᪾ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-ᮭ᯦-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿⃐-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯-꙲ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣠-꣱ꣿꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꧥꨩ-ꨶꩃꩌꩍꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭ﬞ︀-️︠-︯]"; |
| 2042 |
function splitStringAtMatch(query, title) { |
| 2043 |
if (!query) { |
| 2044 |
return [title, "", ""]; |
| 2045 |
} |
| 2046 |
const sanitizedQuery = regExpEscape(query); |
| 2047 |
const match = new RegExp( |
| 2048 |
|
| 2049 |
|
| 2050 |
|
| 2051 |
sanitizedQuery + COMBINING_MARK + "*", |
| 2052 |
"i" |
| 2053 |
).exec(title); |
| 2054 |
if (!match || match.index === void 0) { |
| 2055 |
return [title, "", ""]; |
| 2056 |
} |
| 2057 |
const matchStartIndex = match.index; |
| 2058 |
const matchEndIndex = matchStartIndex + match[0].length; |
| 2059 |
const highlightedTitle = title.slice(matchStartIndex, matchEndIndex); |
| 2060 |
const beforeHighlight = title.slice(0, matchStartIndex); |
| 2061 |
const afterHighlight = title.slice(matchEndIndex, title.length); |
| 2062 |
return [beforeHighlight, highlightedTitle, afterHighlight]; |
| 2063 |
} |
| 2064 |
const stringHelpers = Object.freeze( Object.defineProperty({ |
| 2065 |
__proto__: null, |
| 2066 |
regExpEscape, |
| 2067 |
splitStringAtMatch |
| 2068 |
}, Symbol.toStringTag, { value: "Module" })); |
| 2069 |
const _sfc_main$o = defineComponent({ |
| 2070 |
name: "CdxSearchResultTitle", |
| 2071 |
props: { |
| 2072 |
|
| 2073 |
|
| 2074 |
|
| 2075 |
title: { |
| 2076 |
type: String, |
| 2077 |
required: true |
| 2078 |
}, |
| 2079 |
|
| 2080 |
|
| 2081 |
|
| 2082 |
searchQuery: { |
| 2083 |
type: String, |
| 2084 |
default: "" |
| 2085 |
} |
| 2086 |
}, |
| 2087 |
setup: (props) => { |
| 2088 |
const titleChunks = computed(() => splitStringAtMatch(props.searchQuery, String(props.title))); |
| 2089 |
return { |
| 2090 |
titleChunks |
| 2091 |
}; |
| 2092 |
} |
| 2093 |
}); |
| 2094 |
const _hoisted_1$m = { class: "cdx-search-result-title" }; |
| 2095 |
const _hoisted_2$e = { class: "cdx-search-result-title__match" }; |
| 2096 |
function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) { |
| 2097 |
return openBlock(), createElementBlock("span", _hoisted_1$m, [ |
| 2098 |
createElementVNode("bdi", null, [ |
| 2099 |
createTextVNode( |
| 2100 |
toDisplayString(_ctx.titleChunks[0]), |
| 2101 |
1 |
| 2102 |
|
| 2103 |
), |
| 2104 |
createElementVNode( |
| 2105 |
"span", |
| 2106 |
_hoisted_2$e, |
| 2107 |
toDisplayString(_ctx.titleChunks[1]), |
| 2108 |
1 |
| 2109 |
|
| 2110 |
), |
| 2111 |
createTextVNode( |
| 2112 |
toDisplayString(_ctx.titleChunks[2]), |
| 2113 |
1 |
| 2114 |
|
| 2115 |
) |
| 2116 |
]) |
| 2117 |
]); |
| 2118 |
} |
| 2119 |
const CdxSearchResultTitle = _export_sfc(_sfc_main$o, [["render", _sfc_render$o]]); |
| 2120 |
const _sfc_main$n = defineComponent({ |
| 2121 |
name: "CdxMenuItem", |
| 2122 |
components: { CdxIcon, CdxThumbnail, CdxSearchResultTitle }, |
| 2123 |
props: { |
| 2124 |
|
| 2125 |
|
| 2126 |
|
| 2127 |
id: { |
| 2128 |
type: String, |
| 2129 |
required: true |
| 2130 |
}, |
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
value: { |
| 2135 |
type: [String, Number], |
| 2136 |
required: true |
| 2137 |
}, |
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
disabled: { |
| 2142 |
type: Boolean, |
| 2143 |
default: false |
| 2144 |
}, |
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
selected: { |
| 2149 |
type: Boolean, |
| 2150 |
default: false |
| 2151 |
}, |
| 2152 |
|
| 2153 |
|
| 2154 |
|
| 2155 |
active: { |
| 2156 |
type: Boolean, |
| 2157 |
default: false |
| 2158 |
}, |
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
highlighted: { |
| 2163 |
type: Boolean, |
| 2164 |
default: false |
| 2165 |
}, |
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
label: { |
| 2170 |
type: String, |
| 2171 |
default: "" |
| 2172 |
}, |
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
match: { |
| 2178 |
type: String, |
| 2179 |
default: "" |
| 2180 |
}, |
| 2181 |
|
| 2182 |
|
| 2183 |
|
| 2184 |
|
| 2185 |
supportingText: { |
| 2186 |
type: String, |
| 2187 |
default: "" |
| 2188 |
}, |
| 2189 |
|
| 2190 |
|
| 2191 |
|
| 2192 |
|
| 2193 |
url: { |
| 2194 |
type: String, |
| 2195 |
default: "" |
| 2196 |
}, |
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
icon: { |
| 2201 |
type: [String, Object], |
| 2202 |
default: "" |
| 2203 |
}, |
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
showThumbnail: { |
| 2208 |
type: Boolean, |
| 2209 |
default: false |
| 2210 |
}, |
| 2211 |
|
| 2212 |
|
| 2213 |
|
| 2214 |
thumbnail: { |
| 2215 |
type: [Object, null], |
| 2216 |
default: null |
| 2217 |
}, |
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
description: { |
| 2222 |
type: [String, null], |
| 2223 |
default: "" |
| 2224 |
}, |
| 2225 |
|
| 2226 |
|
| 2227 |
|
| 2228 |
searchQuery: { |
| 2229 |
type: String, |
| 2230 |
default: "" |
| 2231 |
}, |
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
boldLabel: { |
| 2236 |
type: Boolean, |
| 2237 |
default: false |
| 2238 |
}, |
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
hideDescriptionOverflow: { |
| 2243 |
type: Boolean, |
| 2244 |
default: false |
| 2245 |
}, |
| 2246 |
|
| 2247 |
|
| 2248 |
|
| 2249 |
|
| 2250 |
|
| 2251 |
|
| 2252 |
|
| 2253 |
language: { |
| 2254 |
type: Object, |
| 2255 |
default: () => { |
| 2256 |
return {}; |
| 2257 |
} |
| 2258 |
}, |
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
action: { |
| 2263 |
type: String, |
| 2264 |
default: "default" |
| 2265 |
}, |
| 2266 |
|
| 2267 |
|
| 2268 |
|
| 2269 |
multiselect: { |
| 2270 |
type: Boolean, |
| 2271 |
default: false |
| 2272 |
} |
| 2273 |
}, |
| 2274 |
emits: [ |
| 2275 |
|
| 2276 |
|
| 2277 |
|
| 2278 |
|
| 2279 |
|
| 2280 |
|
| 2281 |
|
| 2282 |
"change" |
| 2283 |
], |
| 2284 |
setup: (props, { emit }) => { |
| 2285 |
const onMouseMove = () => { |
| 2286 |
if (!props.highlighted) { |
| 2287 |
emit("change", "highlighted", true); |
| 2288 |
} |
| 2289 |
}; |
| 2290 |
const onMouseLeave = () => { |
| 2291 |
emit("change", "highlighted", false); |
| 2292 |
}; |
| 2293 |
const onMouseDown = (e) => { |
| 2294 |
if (e.button === 0) { |
| 2295 |
emit("change", "active", true); |
| 2296 |
} |
| 2297 |
}; |
| 2298 |
const onClick = () => { |
| 2299 |
emit("change", "selected", true); |
| 2300 |
}; |
| 2301 |
const highlightQuery = computed(() => props.searchQuery.length > 0); |
| 2302 |
const rootClasses = computed(() => { |
| 2303 |
return { |
| 2304 |
"cdx-menu-item--selected": props.selected, |
| 2305 |
|
| 2306 |
|
| 2307 |
|
| 2308 |
|
| 2309 |
|
| 2310 |
|
| 2311 |
"cdx-menu-item--active": props.active && props.highlighted, |
| 2312 |
"cdx-menu-item--highlighted": props.highlighted, |
| 2313 |
"cdx-menu-item--destructive": props.action && props.action === "destructive", |
| 2314 |
"cdx-menu-item--enabled": !props.disabled, |
| 2315 |
"cdx-menu-item--disabled": props.disabled, |
| 2316 |
"cdx-menu-item--highlight-query": highlightQuery.value, |
| 2317 |
"cdx-menu-item--bold-label": props.boldLabel, |
| 2318 |
"cdx-menu-item--has-description": !!props.description, |
| 2319 |
"cdx-menu-item--hide-description-overflow": props.hideDescriptionOverflow |
| 2320 |
}; |
| 2321 |
}); |
| 2322 |
const contentTag = computed(() => props.url ? "a" : "span"); |
| 2323 |
const title = computed(() => props.label || String(props.value)); |
| 2324 |
return { |
| 2325 |
onMouseMove, |
| 2326 |
onMouseLeave, |
| 2327 |
onMouseDown, |
| 2328 |
onClick, |
| 2329 |
highlightQuery, |
| 2330 |
rootClasses, |
| 2331 |
contentTag, |
| 2332 |
title, |
| 2333 |
cdxIconCheck: K3 |
| 2334 |
}; |
| 2335 |
} |
| 2336 |
}); |
| 2337 |
const _hoisted_1$l = ["id", "aria-disabled", "aria-selected", "aria-checked"]; |
| 2338 |
const _hoisted_2$d = { class: "cdx-menu-item__text" }; |
| 2339 |
const _hoisted_3$9 = ["lang"]; |
| 2340 |
const _hoisted_4$5 = ["lang"]; |
| 2341 |
const _hoisted_5$5 = ["lang"]; |
| 2342 |
const _hoisted_6$5 = ["lang"]; |
| 2343 |
function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) { |
| 2344 |
const _component_cdx_thumbnail = resolveComponent("cdx-thumbnail"); |
| 2345 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 2346 |
const _component_cdx_search_result_title = resolveComponent("cdx-search-result-title"); |
| 2347 |
return openBlock(), createElementBlock("li", { |
| 2348 |
id: _ctx.id, |
| 2349 |
role: "option", |
| 2350 |
class: normalizeClass(["cdx-menu-item", _ctx.rootClasses]), |
| 2351 |
"aria-disabled": _ctx.disabled, |
| 2352 |
"aria-selected": _ctx.selected && !_ctx.multiselect ? true : void 0, |
| 2353 |
"aria-checked": _ctx.selected && _ctx.multiselect ? true : void 0, |
| 2354 |
onMousemove: _cache[0] || (_cache[0] = (...args) => _ctx.onMouseMove && _ctx.onMouseMove(...args)), |
| 2355 |
onMouseleave: _cache[1] || (_cache[1] = (...args) => _ctx.onMouseLeave && _ctx.onMouseLeave(...args)), |
| 2356 |
onMousedown: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.onMouseDown && _ctx.onMouseDown(...args), ["prevent"])), |
| 2357 |
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.onClick && _ctx.onClick(...args)) |
| 2358 |
}, [ |
| 2359 |
renderSlot(_ctx.$slots, "default", {}, () => [ |
| 2360 |
(openBlock(), createBlock(resolveDynamicComponent(_ctx.contentTag), { |
| 2361 |
href: _ctx.url ? _ctx.url : void 0, |
| 2362 |
class: "cdx-menu-item__content" |
| 2363 |
}, { |
| 2364 |
default: withCtx(() => { |
| 2365 |
var _a, _b, _c, _d, _e, _f; |
| 2366 |
return [ |
| 2367 |
_ctx.showThumbnail ? (openBlock(), createBlock(_component_cdx_thumbnail, { |
| 2368 |
key: 0, |
| 2369 |
thumbnail: _ctx.thumbnail, |
| 2370 |
class: "cdx-menu-item__thumbnail" |
| 2371 |
}, null, 8, ["thumbnail"])) : _ctx.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 2372 |
key: 1, |
| 2373 |
icon: _ctx.icon, |
| 2374 |
class: "cdx-menu-item__icon" |
| 2375 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 2376 |
createElementVNode("span", _hoisted_2$d, [ |
| 2377 |
_ctx.highlightQuery ? (openBlock(), createBlock(_component_cdx_search_result_title, { |
| 2378 |
key: 0, |
| 2379 |
title: _ctx.title, |
| 2380 |
"search-query": _ctx.searchQuery, |
| 2381 |
lang: (_a = _ctx.language) == null ? void 0 : _a.label |
| 2382 |
}, null, 8, ["title", "search-query", "lang"])) : (openBlock(), createElementBlock("span", { |
| 2383 |
key: 1, |
| 2384 |
class: "cdx-menu-item__text__label", |
| 2385 |
lang: (_b = _ctx.language) == null ? void 0 : _b.label |
| 2386 |
}, [ |
| 2387 |
createElementVNode( |
| 2388 |
"bdi", |
| 2389 |
null, |
| 2390 |
toDisplayString(_ctx.title), |
| 2391 |
1 |
| 2392 |
|
| 2393 |
) |
| 2394 |
], 8, _hoisted_3$9)), |
| 2395 |
_ctx.match ? (openBlock(), createElementBlock( |
| 2396 |
Fragment, |
| 2397 |
{ key: 2 }, |
| 2398 |
[ |
| 2399 |
createTextVNode(toDisplayString(" ") + " "), |
| 2400 |
_ctx.highlightQuery ? (openBlock(), createBlock(_component_cdx_search_result_title, { |
| 2401 |
key: 0, |
| 2402 |
title: _ctx.match, |
| 2403 |
"search-query": _ctx.searchQuery, |
| 2404 |
lang: (_c = _ctx.language) == null ? void 0 : _c.match |
| 2405 |
}, null, 8, ["title", "search-query", "lang"])) : (openBlock(), createElementBlock("span", { |
| 2406 |
key: 1, |
| 2407 |
class: "cdx-menu-item__text__match", |
| 2408 |
lang: (_d = _ctx.language) == null ? void 0 : _d.match |
| 2409 |
}, [ |
| 2410 |
createElementVNode( |
| 2411 |
"bdi", |
| 2412 |
null, |
| 2413 |
toDisplayString(_ctx.match), |
| 2414 |
1 |
| 2415 |
|
| 2416 |
) |
| 2417 |
], 8, _hoisted_4$5)) |
| 2418 |
], |
| 2419 |
64 |
| 2420 |
|
| 2421 |
)) : createCommentVNode("v-if", true), |
| 2422 |
_ctx.supportingText ? (openBlock(), createElementBlock( |
| 2423 |
Fragment, |
| 2424 |
{ key: 3 }, |
| 2425 |
[ |
| 2426 |
createTextVNode(toDisplayString(" ") + " "), |
| 2427 |
createElementVNode("span", { |
| 2428 |
class: "cdx-menu-item__text__supporting-text", |
| 2429 |
lang: (_e = _ctx.language) == null ? void 0 : _e.supportingText |
| 2430 |
}, [ |
| 2431 |
createElementVNode( |
| 2432 |
"bdi", |
| 2433 |
null, |
| 2434 |
toDisplayString(_ctx.supportingText), |
| 2435 |
1 |
| 2436 |
|
| 2437 |
) |
| 2438 |
], 8, _hoisted_5$5) |
| 2439 |
], |
| 2440 |
64 |
| 2441 |
|
| 2442 |
)) : createCommentVNode("v-if", true), |
| 2443 |
_ctx.description ? (openBlock(), createElementBlock("span", { |
| 2444 |
key: 4, |
| 2445 |
class: "cdx-menu-item__text__description", |
| 2446 |
lang: (_f = _ctx.language) == null ? void 0 : _f.description |
| 2447 |
}, [ |
| 2448 |
createElementVNode( |
| 2449 |
"bdi", |
| 2450 |
null, |
| 2451 |
toDisplayString(_ctx.description), |
| 2452 |
1 |
| 2453 |
|
| 2454 |
) |
| 2455 |
], 8, _hoisted_6$5)) : createCommentVNode("v-if", true) |
| 2456 |
]), |
| 2457 |
_ctx.multiselect && _ctx.selected ? (openBlock(), createBlock(_component_cdx_icon, { |
| 2458 |
key: 2, |
| 2459 |
icon: _ctx.cdxIconCheck, |
| 2460 |
size: "small", |
| 2461 |
class: "cdx-menu-item__selected-icon" |
| 2462 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true) |
| 2463 |
]; |
| 2464 |
}), |
| 2465 |
_: 1 |
| 2466 |
|
| 2467 |
}, 8, ["href"])) |
| 2468 |
]) |
| 2469 |
], 42, _hoisted_1$l); |
| 2470 |
} |
| 2471 |
const CdxMenuItem = _export_sfc(_sfc_main$n, [["render", _sfc_render$n]]); |
| 2472 |
const _sfc_main$m = defineComponent({ |
| 2473 |
name: "CdxProgressBar", |
| 2474 |
props: { |
| 2475 |
|
| 2476 |
|
| 2477 |
|
| 2478 |
inline: { |
| 2479 |
type: Boolean, |
| 2480 |
default: false |
| 2481 |
}, |
| 2482 |
|
| 2483 |
|
| 2484 |
|
| 2485 |
disabled: { |
| 2486 |
type: Boolean, |
| 2487 |
default: false |
| 2488 |
} |
| 2489 |
}, |
| 2490 |
setup(props, { attrs }) { |
| 2491 |
useWarnOnce( |
| 2492 |
() => !props.inline && !attrs["aria-label"] && !attrs["aria-hidden"], |
| 2493 |
"CdxProgressBar: Progress bars require one of the following attribute, aria-label or aria-hidden. See documentation on https://doc.wikimedia.org/codex/latest/components/demos/progressbar.html" |
| 2494 |
); |
| 2495 |
const rootClasses = computed(() => { |
| 2496 |
return { |
| 2497 |
"cdx-progress-bar--block": !props.inline, |
| 2498 |
"cdx-progress-bar--inline": props.inline, |
| 2499 |
"cdx-progress-bar--enabled": !props.disabled, |
| 2500 |
"cdx-progress-bar--disabled": props.disabled |
| 2501 |
}; |
| 2502 |
}); |
| 2503 |
const computedAriaHidden = computed(() => { |
| 2504 |
return props.inline ? "true" : void 0; |
| 2505 |
}); |
| 2506 |
return { |
| 2507 |
rootClasses, |
| 2508 |
computedAriaHidden |
| 2509 |
}; |
| 2510 |
} |
| 2511 |
}); |
| 2512 |
const _hoisted_1$k = ["aria-hidden", "aria-disabled"]; |
| 2513 |
const _hoisted_2$c = createElementVNode( |
| 2514 |
"div", |
| 2515 |
{ class: "cdx-progress-bar__bar" }, |
| 2516 |
null, |
| 2517 |
-1 |
| 2518 |
|
| 2519 |
); |
| 2520 |
const _hoisted_3$8 = [ |
| 2521 |
_hoisted_2$c |
| 2522 |
]; |
| 2523 |
function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) { |
| 2524 |
return openBlock(), createElementBlock("div", { |
| 2525 |
class: normalizeClass(["cdx-progress-bar", _ctx.rootClasses]), |
| 2526 |
role: "progressbar", |
| 2527 |
"aria-hidden": _ctx.computedAriaHidden, |
| 2528 |
"aria-disabled": _ctx.disabled |
| 2529 |
}, _hoisted_3$8, 10, _hoisted_1$k); |
| 2530 |
} |
| 2531 |
const CdxProgressBar = _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]); |
| 2532 |
function useIntersectionObserver(templateRef, observerOptions) { |
| 2533 |
const intersectionRef = ref(false); |
| 2534 |
let mounted = false; |
| 2535 |
if (typeof window !== "object") { |
| 2536 |
return intersectionRef; |
| 2537 |
} |
| 2538 |
if (!("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype)) { |
| 2539 |
return intersectionRef; |
| 2540 |
} |
| 2541 |
const observer = new window.IntersectionObserver( |
| 2542 |
(entries) => { |
| 2543 |
const entry = entries[0]; |
| 2544 |
if (entry) { |
| 2545 |
intersectionRef.value = entry.isIntersecting; |
| 2546 |
} |
| 2547 |
}, |
| 2548 |
observerOptions |
| 2549 |
); |
| 2550 |
onMounted(() => { |
| 2551 |
mounted = true; |
| 2552 |
if (templateRef.value) { |
| 2553 |
observer.observe(templateRef.value); |
| 2554 |
} |
| 2555 |
}); |
| 2556 |
onUnmounted(() => { |
| 2557 |
mounted = false; |
| 2558 |
observer.disconnect(); |
| 2559 |
}); |
| 2560 |
watch(templateRef, (newElement) => { |
| 2561 |
if (!mounted) { |
| 2562 |
return; |
| 2563 |
} |
| 2564 |
observer.disconnect(); |
| 2565 |
intersectionRef.value = false; |
| 2566 |
if (newElement) { |
| 2567 |
observer.observe(newElement); |
| 2568 |
} |
| 2569 |
}); |
| 2570 |
return intersectionRef; |
| 2571 |
} |
| 2572 |
function selectedIsArray(selected) { |
| 2573 |
return selected !== null && Array.isArray(selected); |
| 2574 |
} |
| 2575 |
const _sfc_main$l = defineComponent({ |
| 2576 |
name: "CdxMenu", |
| 2577 |
components: { |
| 2578 |
CdxMenuItem, |
| 2579 |
CdxProgressBar |
| 2580 |
}, |
| 2581 |
|
| 2582 |
|
| 2583 |
|
| 2584 |
inheritAttrs: false, |
| 2585 |
props: { |
| 2586 |
|
| 2587 |
menuItems: { |
| 2588 |
type: Array, |
| 2589 |
required: true |
| 2590 |
}, |
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
|
| 2596 |
|
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
|
| 2601 |
footer: { |
| 2602 |
type: Object, |
| 2603 |
default: null |
| 2604 |
}, |
| 2605 |
|
| 2606 |
|
| 2607 |
|
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
selected: { |
| 2615 |
|
| 2616 |
type: [String, Number, Array, null], |
| 2617 |
required: true |
| 2618 |
}, |
| 2619 |
|
| 2620 |
|
| 2621 |
|
| 2622 |
expanded: { |
| 2623 |
type: Boolean, |
| 2624 |
required: true |
| 2625 |
}, |
| 2626 |
|
| 2627 |
|
| 2628 |
|
| 2629 |
|
| 2630 |
|
| 2631 |
|
| 2632 |
|
| 2633 |
|
| 2634 |
showPending: { |
| 2635 |
type: Boolean, |
| 2636 |
default: false |
| 2637 |
}, |
| 2638 |
|
| 2639 |
|
| 2640 |
|
| 2641 |
|
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
visibleItemLimit: { |
| 2646 |
type: Number, |
| 2647 |
default: null |
| 2648 |
}, |
| 2649 |
|
| 2650 |
|
| 2651 |
|
| 2652 |
showThumbnail: { |
| 2653 |
type: Boolean, |
| 2654 |
default: false |
| 2655 |
}, |
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
boldLabel: { |
| 2660 |
type: Boolean, |
| 2661 |
default: false |
| 2662 |
}, |
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
hideDescriptionOverflow: { |
| 2667 |
type: Boolean, |
| 2668 |
default: false |
| 2669 |
}, |
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
searchQuery: { |
| 2674 |
type: String, |
| 2675 |
default: "" |
| 2676 |
}, |
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
|
| 2686 |
|
| 2687 |
|
| 2688 |
|
| 2689 |
|
| 2690 |
showNoResultsSlot: { |
| 2691 |
type: Boolean, |
| 2692 |
default: null |
| 2693 |
} |
| 2694 |
}, |
| 2695 |
emits: [ |
| 2696 |
|
| 2697 |
|
| 2698 |
|
| 2699 |
|
| 2700 |
|
| 2701 |
|
| 2702 |
|
| 2703 |
|
| 2704 |
|
| 2705 |
|
| 2706 |
|
| 2707 |
"update:selected", |
| 2708 |
|
| 2709 |
|
| 2710 |
|
| 2711 |
|
| 2712 |
|
| 2713 |
"update:expanded", |
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
|
| 2719 |
|
| 2720 |
|
| 2721 |
|
| 2722 |
"menu-item-click", |
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
"menu-item-keyboard-navigation", |
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
"load-more" |
| 2737 |
], |
| 2738 |
expose: [ |
| 2739 |
"isExpanded", |
| 2740 |
"clearActive", |
| 2741 |
"getHighlightedMenuItem", |
| 2742 |
"getHighlightedViaKeyboard", |
| 2743 |
"delegateKeyNavigation" |
| 2744 |
], |
| 2745 |
setup(props, { emit, slots, attrs }) { |
| 2746 |
const computedMenuItems = computed(() => { |
| 2747 |
const menuItemsWithFooter = props.footer && props.menuItems ? [...props.menuItems, props.footer] : props.menuItems; |
| 2748 |
return menuItemsWithFooter.map((menuItem) => __spreadProps(__spreadValues({}, menuItem), { |
| 2749 |
id: useGeneratedId("menu-item") |
| 2750 |
})); |
| 2751 |
}); |
| 2752 |
const computedShowNoResultsSlot = computed(() => { |
| 2753 |
if (!slots["no-results"]) { |
| 2754 |
return false; |
| 2755 |
} |
| 2756 |
if (props.showNoResultsSlot !== null) { |
| 2757 |
return props.showNoResultsSlot; |
| 2758 |
} |
| 2759 |
return computedMenuItems.value.length === 0; |
| 2760 |
}); |
| 2761 |
const highlightedMenuItem = ref(null); |
| 2762 |
const highlightedViaKeyboard = ref(false); |
| 2763 |
const activeMenuItem = ref(null); |
| 2764 |
const ariaRelevant = "additions removals"; |
| 2765 |
let keyBuffer = ""; |
| 2766 |
let keyBufferTimeout = null; |
| 2767 |
function clearKeyBuffer() { |
| 2768 |
keyBuffer = ""; |
| 2769 |
if (keyBufferTimeout !== null) { |
| 2770 |
clearTimeout(keyBufferTimeout); |
| 2771 |
keyBufferTimeout = null; |
| 2772 |
} |
| 2773 |
} |
| 2774 |
function resetKeyBufferTimeout() { |
| 2775 |
if (keyBufferTimeout !== null) { |
| 2776 |
clearTimeout(keyBufferTimeout); |
| 2777 |
} |
| 2778 |
keyBufferTimeout = setTimeout(clearKeyBuffer, 1500); |
| 2779 |
} |
| 2780 |
function findFirstSelectedMenuItem() { |
| 2781 |
var _a; |
| 2782 |
return (_a = computedMenuItems.value.find( |
| 2783 |
(menuItem) => selectedIsArray(props.selected) ? props.selected.indexOf(menuItem.value) !== -1 : menuItem.value === props.selected |
| 2784 |
)) != null ? _a : null; |
| 2785 |
} |
| 2786 |
const isMultiselect = computed(() => selectedIsArray(props.selected)); |
| 2787 |
function isItemSelected(value) { |
| 2788 |
return selectedIsArray(props.selected) ? props.selected.indexOf(value) !== -1 : value === props.selected; |
| 2789 |
} |
| 2790 |
function updateSelected(value) { |
| 2791 |
if (selectedIsArray(props.selected)) { |
| 2792 |
const newSelected = props.selected.indexOf(value) === -1 ? props.selected.concat(value) : props.selected.filter((item) => item !== value); |
| 2793 |
emit("update:selected", newSelected); |
| 2794 |
} else { |
| 2795 |
emit("update:selected", value); |
| 2796 |
} |
| 2797 |
} |
| 2798 |
function handleMenuItemChange(menuState, menuItem) { |
| 2799 |
if (menuItem && menuItem.disabled) { |
| 2800 |
return; |
| 2801 |
} |
| 2802 |
switch (menuState) { |
| 2803 |
case "selected": |
| 2804 |
if (menuItem) { |
| 2805 |
updateSelected(menuItem.value); |
| 2806 |
} |
| 2807 |
if (!isMultiselect.value) { |
| 2808 |
emit("update:expanded", false); |
| 2809 |
} |
| 2810 |
activeMenuItem.value = null; |
| 2811 |
break; |
| 2812 |
case "highlighted": |
| 2813 |
highlightedMenuItem.value = menuItem != null ? menuItem : null; |
| 2814 |
highlightedViaKeyboard.value = false; |
| 2815 |
break; |
| 2816 |
case "highlightedViaKeyboard": |
| 2817 |
highlightedMenuItem.value = menuItem != null ? menuItem : null; |
| 2818 |
highlightedViaKeyboard.value = true; |
| 2819 |
break; |
| 2820 |
case "active": |
| 2821 |
activeMenuItem.value = menuItem != null ? menuItem : null; |
| 2822 |
break; |
| 2823 |
} |
| 2824 |
} |
| 2825 |
const highlightedMenuItemIndex = computed(() => { |
| 2826 |
if (highlightedMenuItem.value === null) { |
| 2827 |
return; |
| 2828 |
} |
| 2829 |
return computedMenuItems.value.findIndex( |
| 2830 |
(menuItem) => ( |
| 2831 |
|
| 2832 |
menuItem.value === highlightedMenuItem.value.value |
| 2833 |
) |
| 2834 |
); |
| 2835 |
}); |
| 2836 |
function handleHighlightViaKeyboard(newHighlightedMenuItem) { |
| 2837 |
if (!newHighlightedMenuItem) { |
| 2838 |
return; |
| 2839 |
} |
| 2840 |
handleMenuItemChange("highlightedViaKeyboard", newHighlightedMenuItem); |
| 2841 |
emit("menu-item-keyboard-navigation", newHighlightedMenuItem); |
| 2842 |
} |
| 2843 |
function highlightPrev(highlightedIndex) { |
| 2844 |
var _a; |
| 2845 |
const findPrevEnabled = (startIndex) => { |
| 2846 |
for (let index = startIndex - 1; index >= 0; index--) { |
| 2847 |
if (!computedMenuItems.value[index].disabled) { |
| 2848 |
return computedMenuItems.value[index]; |
| 2849 |
} |
| 2850 |
} |
| 2851 |
}; |
| 2852 |
highlightedIndex = highlightedIndex != null ? highlightedIndex : computedMenuItems.value.length; |
| 2853 |
const prev = (_a = findPrevEnabled(highlightedIndex)) != null ? _a : findPrevEnabled(computedMenuItems.value.length); |
| 2854 |
handleHighlightViaKeyboard(prev); |
| 2855 |
} |
| 2856 |
function highlightNext(highlightedIndex) { |
| 2857 |
var _a; |
| 2858 |
const findNextEnabled = (startIndex) => computedMenuItems.value.find((item, index) => !item.disabled && index > startIndex); |
| 2859 |
highlightedIndex = highlightedIndex != null ? highlightedIndex : -1; |
| 2860 |
const next = (_a = findNextEnabled(highlightedIndex)) != null ? _a : findNextEnabled(-1); |
| 2861 |
handleHighlightViaKeyboard(next); |
| 2862 |
} |
| 2863 |
function handleCharacterNavigation(e) { |
| 2864 |
if (e.key === "Clear") { |
| 2865 |
clearKeyBuffer(); |
| 2866 |
return true; |
| 2867 |
} |
| 2868 |
if (e.key === "Backspace") { |
| 2869 |
keyBuffer = keyBuffer.slice(0, -1); |
| 2870 |
resetKeyBufferTimeout(); |
| 2871 |
return true; |
| 2872 |
} |
| 2873 |
if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) { |
| 2874 |
if (!props.expanded) { |
| 2875 |
emit("update:expanded", true); |
| 2876 |
} |
| 2877 |
if (e.key === " " && keyBuffer.length < 1) { |
| 2878 |
return false; |
| 2879 |
} |
| 2880 |
keyBuffer += e.key.toLowerCase(); |
| 2881 |
const isRepeatedCharacter = keyBuffer.length > 1 && keyBuffer.split("").every((char) => char === keyBuffer[0]); |
| 2882 |
let itemsToMatch = computedMenuItems.value; |
| 2883 |
let stringToMatch = keyBuffer; |
| 2884 |
if (isRepeatedCharacter && highlightedMenuItemIndex.value !== void 0) { |
| 2885 |
itemsToMatch = itemsToMatch.slice(highlightedMenuItemIndex.value + 1).concat(itemsToMatch.slice(0, highlightedMenuItemIndex.value)); |
| 2886 |
stringToMatch = keyBuffer[0]; |
| 2887 |
} |
| 2888 |
const matchingItem = itemsToMatch.find( |
| 2889 |
(item) => { |
| 2890 |
var _a; |
| 2891 |
return !item.disabled && String((_a = item.label) != null ? _a : item.value).toLowerCase().startsWith(stringToMatch); |
| 2892 |
} |
| 2893 |
); |
| 2894 |
if (matchingItem) { |
| 2895 |
handleMenuItemChange("highlightedViaKeyboard", matchingItem); |
| 2896 |
maybeScrollIntoView(); |
| 2897 |
} |
| 2898 |
resetKeyBufferTimeout(); |
| 2899 |
return true; |
| 2900 |
} |
| 2901 |
return false; |
| 2902 |
} |
| 2903 |
function handleKeyNavigation(e, { prevent = true, characterNavigation = false } = {}) { |
| 2904 |
if (characterNavigation) { |
| 2905 |
if (handleCharacterNavigation(e)) { |
| 2906 |
e.preventDefault(); |
| 2907 |
return true; |
| 2908 |
} |
| 2909 |
clearKeyBuffer(); |
| 2910 |
} |
| 2911 |
function maybePrevent() { |
| 2912 |
if (prevent) { |
| 2913 |
e.preventDefault(); |
| 2914 |
e.stopPropagation(); |
| 2915 |
} |
| 2916 |
} |
| 2917 |
switch (e.key) { |
| 2918 |
case "Enter": |
| 2919 |
case " ": |
| 2920 |
maybePrevent(); |
| 2921 |
if (props.expanded) { |
| 2922 |
if (highlightedMenuItem.value && highlightedViaKeyboard.value) { |
| 2923 |
updateSelected(highlightedMenuItem.value.value); |
| 2924 |
} |
| 2925 |
if (!isMultiselect.value) { |
| 2926 |
emit("update:expanded", false); |
| 2927 |
} |
| 2928 |
} else { |
| 2929 |
emit("update:expanded", true); |
| 2930 |
} |
| 2931 |
return true; |
| 2932 |
case "Tab": |
| 2933 |
if (props.expanded) { |
| 2934 |
if (highlightedMenuItem.value && highlightedViaKeyboard.value && !isMultiselect.value) { |
| 2935 |
updateSelected(highlightedMenuItem.value.value); |
| 2936 |
emit("update:expanded", false); |
| 2937 |
} |
| 2938 |
} |
| 2939 |
return true; |
| 2940 |
case "ArrowUp": |
| 2941 |
maybePrevent(); |
| 2942 |
if (props.expanded) { |
| 2943 |
if (highlightedMenuItem.value === null) { |
| 2944 |
handleMenuItemChange("highlightedViaKeyboard", findFirstSelectedMenuItem()); |
| 2945 |
} |
| 2946 |
highlightPrev(highlightedMenuItemIndex.value); |
| 2947 |
} else { |
| 2948 |
emit("update:expanded", true); |
| 2949 |
} |
| 2950 |
maybeScrollIntoView(); |
| 2951 |
return true; |
| 2952 |
case "ArrowDown": |
| 2953 |
maybePrevent(); |
| 2954 |
if (props.expanded) { |
| 2955 |
if (highlightedMenuItem.value === null) { |
| 2956 |
handleMenuItemChange("highlightedViaKeyboard", findFirstSelectedMenuItem()); |
| 2957 |
} |
| 2958 |
highlightNext(highlightedMenuItemIndex.value); |
| 2959 |
} else { |
| 2960 |
emit("update:expanded", true); |
| 2961 |
} |
| 2962 |
maybeScrollIntoView(); |
| 2963 |
return true; |
| 2964 |
case "Home": |
| 2965 |
maybePrevent(); |
| 2966 |
if (props.expanded) { |
| 2967 |
if (highlightedMenuItem.value === null) { |
| 2968 |
handleMenuItemChange("highlightedViaKeyboard", findFirstSelectedMenuItem()); |
| 2969 |
} |
| 2970 |
highlightNext(); |
| 2971 |
} else { |
| 2972 |
emit("update:expanded", true); |
| 2973 |
} |
| 2974 |
maybeScrollIntoView(); |
| 2975 |
return true; |
| 2976 |
case "End": |
| 2977 |
maybePrevent(); |
| 2978 |
if (props.expanded) { |
| 2979 |
if (highlightedMenuItem.value === null) { |
| 2980 |
handleMenuItemChange("highlightedViaKeyboard", findFirstSelectedMenuItem()); |
| 2981 |
} |
| 2982 |
highlightPrev(); |
| 2983 |
} else { |
| 2984 |
emit("update:expanded", true); |
| 2985 |
} |
| 2986 |
maybeScrollIntoView(); |
| 2987 |
return true; |
| 2988 |
case "Escape": |
| 2989 |
maybePrevent(); |
| 2990 |
emit("update:expanded", false); |
| 2991 |
return true; |
| 2992 |
default: |
| 2993 |
return false; |
| 2994 |
} |
| 2995 |
} |
| 2996 |
function onMouseUp() { |
| 2997 |
handleMenuItemChange("active", null); |
| 2998 |
} |
| 2999 |
const menuItemElements = []; |
| 3000 |
const loadMoreTriggerElement = ref(void 0); |
| 3001 |
const isTriggerVisible = useIntersectionObserver( |
| 3002 |
loadMoreTriggerElement, |
| 3003 |
{ threshold: 0.8 } |
| 3004 |
); |
| 3005 |
watch(isTriggerVisible, (value) => { |
| 3006 |
if (value) { |
| 3007 |
emit("load-more"); |
| 3008 |
} |
| 3009 |
}); |
| 3010 |
function assignTemplateRef(templateRef, index) { |
| 3011 |
if (templateRef) { |
| 3012 |
menuItemElements[index] = templateRef.$el; |
| 3013 |
const visibleItemLimit = props.visibleItemLimit; |
| 3014 |
if (!visibleItemLimit || props.menuItems.length < visibleItemLimit) { |
| 3015 |
return; |
| 3016 |
} |
| 3017 |
const loadMoreThreshold = Math.min( |
| 3018 |
visibleItemLimit, |
| 3019 |
Math.max(2, Math.floor(0.2 * props.menuItems.length)) |
| 3020 |
); |
| 3021 |
if (index === props.menuItems.length - loadMoreThreshold) { |
| 3022 |
loadMoreTriggerElement.value = templateRef.$el; |
| 3023 |
} |
| 3024 |
} |
| 3025 |
} |
| 3026 |
const menuListbox = ref(); |
| 3027 |
function maybeScrollIntoView() { |
| 3028 |
const isListboxScrollable = menuListbox.value && menuListbox.value.scrollHeight > menuListbox.value.clientHeight; |
| 3029 |
if (highlightedMenuItemIndex.value === void 0 || !isListboxScrollable) { |
| 3030 |
return; |
| 3031 |
} |
| 3032 |
const scrollIndex = highlightedMenuItemIndex.value >= 0 ? highlightedMenuItemIndex.value : 0; |
| 3033 |
menuItemElements[scrollIndex].scrollIntoView({ |
| 3034 |
behavior: "smooth", |
| 3035 |
block: "nearest" |
| 3036 |
}); |
| 3037 |
} |
| 3038 |
const maxMenuHeight = ref(null); |
| 3039 |
const footerHeight = ref(null); |
| 3040 |
function resizeMenu() { |
| 3041 |
return __async(this, null, function* () { |
| 3042 |
yield nextTick(); |
| 3043 |
updateFooterHeight(); |
| 3044 |
updateMaxMenuHeight(); |
| 3045 |
yield nextTick(); |
| 3046 |
maybeScrollIntoView(); |
| 3047 |
}); |
| 3048 |
} |
| 3049 |
function updateFooterHeight() { |
| 3050 |
if (props.footer) { |
| 3051 |
const footerElement = menuItemElements[menuItemElements.length - 1]; |
| 3052 |
footerHeight.value = footerElement.scrollHeight; |
| 3053 |
} else { |
| 3054 |
footerHeight.value = null; |
| 3055 |
} |
| 3056 |
} |
| 3057 |
function updateMaxMenuHeight() { |
| 3058 |
if (!props.visibleItemLimit || menuItemElements.length <= props.visibleItemLimit) { |
| 3059 |
maxMenuHeight.value = null; |
| 3060 |
return; |
| 3061 |
} |
| 3062 |
const firstMenuItemTop = menuItemElements[0].getBoundingClientRect().top; |
| 3063 |
const firstHiddenMenuItemTop = menuItemElements[props.visibleItemLimit].getBoundingClientRect().top; |
| 3064 |
maxMenuHeight.value = firstHiddenMenuItemTop - firstMenuItemTop + 2; |
| 3065 |
} |
| 3066 |
onMounted(() => { |
| 3067 |
document.addEventListener("mouseup", onMouseUp); |
| 3068 |
}); |
| 3069 |
onUnmounted(() => { |
| 3070 |
document.removeEventListener("mouseup", onMouseUp); |
| 3071 |
}); |
| 3072 |
watch(toRef(props, "expanded"), (newVal) => __async(this, null, function* () { |
| 3073 |
if (newVal) { |
| 3074 |
const selectedMenuItem = findFirstSelectedMenuItem(); |
| 3075 |
if (selectedMenuItem && !highlightedMenuItem.value) { |
| 3076 |
handleMenuItemChange("highlighted", selectedMenuItem); |
| 3077 |
} |
| 3078 |
yield resizeMenu(); |
| 3079 |
} else { |
| 3080 |
handleMenuItemChange("highlighted", null); |
| 3081 |
} |
| 3082 |
})); |
| 3083 |
watch(toRef(props, "menuItems"), (newPropMenuItems) => __async(this, null, function* () { |
| 3084 |
if (newPropMenuItems.length < menuItemElements.length) { |
| 3085 |
menuItemElements.length = newPropMenuItems.length; |
| 3086 |
} |
| 3087 |
if (props.expanded) { |
| 3088 |
yield resizeMenu(); |
| 3089 |
} |
| 3090 |
}), { deep: true }); |
| 3091 |
const listBoxStyle = computed(() => { |
| 3092 |
return { |
| 3093 |
"max-height": maxMenuHeight.value ? "".concat(maxMenuHeight.value, "px") : void 0, |
| 3094 |
"margin-bottom": footerHeight.value ? "".concat(footerHeight.value, "px") : void 0 |
| 3095 |
}; |
| 3096 |
}); |
| 3097 |
const internalClasses = computed(() => { |
| 3098 |
return { |
| 3099 |
"cdx-menu--has-footer": !!props.footer |
| 3100 |
}; |
| 3101 |
}); |
| 3102 |
const { |
| 3103 |
rootClasses, |
| 3104 |
rootStyle, |
| 3105 |
otherAttrs |
| 3106 |
} = useSplitAttributes(attrs, internalClasses); |
| 3107 |
return { |
| 3108 |
listBoxStyle, |
| 3109 |
rootClasses, |
| 3110 |
rootStyle, |
| 3111 |
otherAttrs, |
| 3112 |
assignTemplateRef, |
| 3113 |
computedMenuItems, |
| 3114 |
computedShowNoResultsSlot, |
| 3115 |
highlightedMenuItem, |
| 3116 |
highlightedViaKeyboard, |
| 3117 |
activeMenuItem, |
| 3118 |
handleMenuItemChange, |
| 3119 |
handleKeyNavigation, |
| 3120 |
ariaRelevant, |
| 3121 |
isMultiselect, |
| 3122 |
isItemSelected, |
| 3123 |
menuListbox |
| 3124 |
}; |
| 3125 |
}, |
| 3126 |
|
| 3127 |
|
| 3128 |
|
| 3129 |
methods: { |
| 3130 |
|
| 3131 |
|
| 3132 |
|
| 3133 |
|
| 3134 |
|
| 3135 |
isExpanded() { |
| 3136 |
return this.expanded; |
| 3137 |
}, |
| 3138 |
|
| 3139 |
|
| 3140 |
|
| 3141 |
|
| 3142 |
|
| 3143 |
|
| 3144 |
|
| 3145 |
|
| 3146 |
|
| 3147 |
|
| 3148 |
|
| 3149 |
getHighlightedMenuItem() { |
| 3150 |
return this.expanded ? this.highlightedMenuItem : null; |
| 3151 |
}, |
| 3152 |
|
| 3153 |
|
| 3154 |
|
| 3155 |
|
| 3156 |
|
| 3157 |
|
| 3158 |
getHighlightedViaKeyboard() { |
| 3159 |
return this.highlightedViaKeyboard; |
| 3160 |
}, |
| 3161 |
|
| 3162 |
|
| 3163 |
|
| 3164 |
|
| 3165 |
|
| 3166 |
clearActive() { |
| 3167 |
this.handleMenuItemChange("active", null); |
| 3168 |
}, |
| 3169 |
|
| 3170 |
|
| 3171 |
|
| 3172 |
|
| 3173 |
|
| 3174 |
|
| 3175 |
|
| 3176 |
|
| 3177 |
|
| 3178 |
|
| 3179 |
|
| 3180 |
|
| 3181 |
|
| 3182 |
|
| 3183 |
|
| 3184 |
|
| 3185 |
delegateKeyNavigation(event, { prevent = true, characterNavigation = false } = {}) { |
| 3186 |
return this.handleKeyNavigation(event, { prevent, characterNavigation }); |
| 3187 |
} |
| 3188 |
} |
| 3189 |
}); |
| 3190 |
const _hoisted_1$j = ["aria-live", "aria-relevant", "aria-multiselectable"]; |
| 3191 |
const _hoisted_2$b = { |
| 3192 |
key: 0, |
| 3193 |
class: "cdx-menu__pending cdx-menu-item" |
| 3194 |
}; |
| 3195 |
const _hoisted_3$7 = { |
| 3196 |
key: 1, |
| 3197 |
class: "cdx-menu__no-results cdx-menu-item", |
| 3198 |
role: "option" |
| 3199 |
}; |
| 3200 |
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) { |
| 3201 |
const _component_cdx_menu_item = resolveComponent("cdx-menu-item"); |
| 3202 |
const _component_cdx_progress_bar = resolveComponent("cdx-progress-bar"); |
| 3203 |
return withDirectives((openBlock(), createElementBlock( |
| 3204 |
"div", |
| 3205 |
{ |
| 3206 |
class: normalizeClass(["cdx-menu", _ctx.rootClasses]), |
| 3207 |
style: normalizeStyle(_ctx.rootStyle) |
| 3208 |
}, |
| 3209 |
[ |
| 3210 |
createElementVNode("ul", mergeProps({ |
| 3211 |
ref: "menuListbox", |
| 3212 |
class: "cdx-menu__listbox", |
| 3213 |
role: "listbox", |
| 3214 |
style: _ctx.listBoxStyle, |
| 3215 |
"aria-live": _ctx.showPending ? "polite" : void 0, |
| 3216 |
"aria-relevant": _ctx.showPending ? _ctx.ariaRelevant : void 0, |
| 3217 |
"aria-multiselectable": _ctx.isMultiselect ? true : void 0 |
| 3218 |
}, _ctx.otherAttrs), [ |
| 3219 |
_ctx.showPending && _ctx.computedMenuItems.length === 0 && _ctx.$slots.pending ? (openBlock(), createElementBlock("li", _hoisted_2$b, [ |
| 3220 |
renderSlot(_ctx.$slots, "pending") |
| 3221 |
])) : createCommentVNode("v-if", true), |
| 3222 |
_ctx.computedShowNoResultsSlot ? (openBlock(), createElementBlock("li", _hoisted_3$7, [ |
| 3223 |
renderSlot(_ctx.$slots, "no-results") |
| 3224 |
])) : createCommentVNode("v-if", true), |
| 3225 |
(openBlock(true), createElementBlock( |
| 3226 |
Fragment, |
| 3227 |
null, |
| 3228 |
renderList(_ctx.computedMenuItems, (menuItem, index) => { |
| 3229 |
var _a, _b; |
| 3230 |
return openBlock(), createBlock(_component_cdx_menu_item, mergeProps({ |
| 3231 |
key: menuItem.value, |
| 3232 |
ref_for: true, |
| 3233 |
ref: (ref2) => _ctx.assignTemplateRef(ref2, index) |
| 3234 |
}, menuItem, { |
| 3235 |
selected: _ctx.isItemSelected(menuItem.value), |
| 3236 |
active: menuItem.value === ((_a = _ctx.activeMenuItem) == null ? void 0 : _a.value), |
| 3237 |
highlighted: menuItem.value === ((_b = _ctx.highlightedMenuItem) == null ? void 0 : _b.value), |
| 3238 |
"show-thumbnail": _ctx.showThumbnail, |
| 3239 |
"bold-label": _ctx.boldLabel, |
| 3240 |
"hide-description-overflow": _ctx.hideDescriptionOverflow, |
| 3241 |
"search-query": _ctx.searchQuery, |
| 3242 |
multiselect: _ctx.isMultiselect, |
| 3243 |
onChange: (menuState, setState) => _ctx.handleMenuItemChange(menuState, setState ? menuItem : null), |
| 3244 |
onClick: ($event) => _ctx.$emit("menu-item-click", menuItem) |
| 3245 |
}), { |
| 3246 |
default: withCtx(() => { |
| 3247 |
var _a2, _b2; |
| 3248 |
return [ |
| 3249 |
renderSlot(_ctx.$slots, "default", { |
| 3250 |
menuItem, |
| 3251 |
active: menuItem.value === ((_a2 = _ctx.activeMenuItem) == null ? void 0 : _a2.value) && menuItem.value === ((_b2 = _ctx.highlightedMenuItem) == null ? void 0 : _b2.value) |
| 3252 |
}) |
| 3253 |
]; |
| 3254 |
}), |
| 3255 |
_: 2 |
| 3256 |
|
| 3257 |
}, 1040, ["selected", "active", "highlighted", "show-thumbnail", "bold-label", "hide-description-overflow", "search-query", "multiselect", "onChange", "onClick"]); |
| 3258 |
}), |
| 3259 |
128 |
| 3260 |
|
| 3261 |
)), |
| 3262 |
_ctx.showPending ? (openBlock(), createBlock(_component_cdx_progress_bar, { |
| 3263 |
key: 2, |
| 3264 |
class: "cdx-menu__progress-bar", |
| 3265 |
inline: true |
| 3266 |
})) : createCommentVNode("v-if", true) |
| 3267 |
], 16, _hoisted_1$j) |
| 3268 |
], |
| 3269 |
6 |
| 3270 |
|
| 3271 |
)), [ |
| 3272 |
[vShow, _ctx.expanded] |
| 3273 |
]); |
| 3274 |
} |
| 3275 |
const CdxMenu = _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]); |
| 3276 |
const textInputTypeValidator = makeStringTypeValidator(TextInputTypes); |
| 3277 |
const statusValidator$8 = makeStringTypeValidator(ValidationStatusTypes); |
| 3278 |
const _sfc_main$k = defineComponent({ |
| 3279 |
name: "CdxTextInput", |
| 3280 |
components: { CdxIcon }, |
| 3281 |
|
| 3282 |
|
| 3283 |
|
| 3284 |
inheritAttrs: false, |
| 3285 |
expose: [ |
| 3286 |
"focus", |
| 3287 |
"blur" |
| 3288 |
], |
| 3289 |
props: { |
| 3290 |
|
| 3291 |
|
| 3292 |
|
| 3293 |
|
| 3294 |
|
| 3295 |
modelValue: { |
| 3296 |
type: [String, Number], |
| 3297 |
default: "" |
| 3298 |
}, |
| 3299 |
|
| 3300 |
|
| 3301 |
|
| 3302 |
|
| 3303 |
|
| 3304 |
|
| 3305 |
inputType: { |
| 3306 |
type: String, |
| 3307 |
default: "text", |
| 3308 |
validator: textInputTypeValidator |
| 3309 |
}, |
| 3310 |
|
| 3311 |
|
| 3312 |
|
| 3313 |
status: { |
| 3314 |
type: String, |
| 3315 |
default: "default", |
| 3316 |
validator: statusValidator$8 |
| 3317 |
}, |
| 3318 |
|
| 3319 |
|
| 3320 |
|
| 3321 |
disabled: { |
| 3322 |
type: Boolean, |
| 3323 |
default: false |
| 3324 |
}, |
| 3325 |
|
| 3326 |
|
| 3327 |
|
| 3328 |
startIcon: { |
| 3329 |
type: [String, Object], |
| 3330 |
default: void 0 |
| 3331 |
}, |
| 3332 |
|
| 3333 |
|
| 3334 |
|
| 3335 |
endIcon: { |
| 3336 |
type: [String, Object], |
| 3337 |
default: void 0 |
| 3338 |
}, |
| 3339 |
|
| 3340 |
|
| 3341 |
|
| 3342 |
|
| 3343 |
|
| 3344 |
|
| 3345 |
clearable: { |
| 3346 |
type: Boolean, |
| 3347 |
default: false |
| 3348 |
} |
| 3349 |
}, |
| 3350 |
emits: [ |
| 3351 |
|
| 3352 |
|
| 3353 |
|
| 3354 |
|
| 3355 |
|
| 3356 |
"update:modelValue", |
| 3357 |
|
| 3358 |
|
| 3359 |
|
| 3360 |
|
| 3361 |
|
| 3362 |
|
| 3363 |
|
| 3364 |
|
| 3365 |
"keydown", |
| 3366 |
|
| 3367 |
|
| 3368 |
|
| 3369 |
|
| 3370 |
|
| 3371 |
"input", |
| 3372 |
|
| 3373 |
|
| 3374 |
|
| 3375 |
|
| 3376 |
|
| 3377 |
"change", |
| 3378 |
|
| 3379 |
|
| 3380 |
|
| 3381 |
|
| 3382 |
|
| 3383 |
"focus", |
| 3384 |
|
| 3385 |
|
| 3386 |
|
| 3387 |
|
| 3388 |
|
| 3389 |
"blur", |
| 3390 |
|
| 3391 |
|
| 3392 |
|
| 3393 |
|
| 3394 |
|
| 3395 |
"clear" |
| 3396 |
], |
| 3397 |
setup(props, { emit, attrs }) { |
| 3398 |
const idAttribute = attrs.id; |
| 3399 |
const { |
| 3400 |
computedDisabled, |
| 3401 |
computedStatus, |
| 3402 |
computedInputId |
| 3403 |
} = useFieldData( |
| 3404 |
toRef(props, "disabled"), |
| 3405 |
toRef(props, "status"), |
| 3406 |
idAttribute |
| 3407 |
); |
| 3408 |
const descriptionId = inject(FieldDescriptionIdKey, void 0); |
| 3409 |
const wrappedModel = useModelWrapper(toRef(props, "modelValue"), emit); |
| 3410 |
const isClearable = computed(() => { |
| 3411 |
return props.clearable && !!wrappedModel.value && !computedDisabled.value; |
| 3412 |
}); |
| 3413 |
const internalClasses = computed(() => { |
| 3414 |
return { |
| 3415 |
"cdx-text-input--has-start-icon": !!props.startIcon, |
| 3416 |
"cdx-text-input--has-end-icon": !!props.endIcon, |
| 3417 |
"cdx-text-input--clearable": isClearable.value, |
| 3418 |
["cdx-text-input--status-".concat(computedStatus.value)]: true |
| 3419 |
}; |
| 3420 |
}); |
| 3421 |
const { |
| 3422 |
rootClasses, |
| 3423 |
rootStyle, |
| 3424 |
otherAttrs |
| 3425 |
} = useSplitAttributes(attrs, internalClasses); |
| 3426 |
const otherAttrsMinusId = computed(() => { |
| 3427 |
const _a = otherAttrs.value, { id } = _a, everythingElse = __objRest(_a, ["id"]); |
| 3428 |
return everythingElse; |
| 3429 |
}); |
| 3430 |
const inputClasses = computed(() => { |
| 3431 |
return { |
| 3432 |
"cdx-text-input__input--has-value": !!wrappedModel.value |
| 3433 |
}; |
| 3434 |
}); |
| 3435 |
const onClear = (event) => { |
| 3436 |
wrappedModel.value = ""; |
| 3437 |
emit("clear", event); |
| 3438 |
}; |
| 3439 |
const onKeydown = (event) => { |
| 3440 |
if ((event.key === "Home" || event.key === "End") && !event.ctrlKey && !event.metaKey) { |
| 3441 |
return; |
| 3442 |
} |
| 3443 |
emit("keydown", event); |
| 3444 |
}; |
| 3445 |
const onInput = (event) => { |
| 3446 |
emit("input", event); |
| 3447 |
}; |
| 3448 |
const onChange = (event) => { |
| 3449 |
emit("change", event); |
| 3450 |
}; |
| 3451 |
const onFocus = (event) => { |
| 3452 |
emit("focus", event); |
| 3453 |
}; |
| 3454 |
const onBlur = (event) => { |
| 3455 |
emit("blur", event); |
| 3456 |
}; |
| 3457 |
return { |
| 3458 |
computedInputId, |
| 3459 |
descriptionId, |
| 3460 |
wrappedModel, |
| 3461 |
isClearable, |
| 3462 |
rootClasses, |
| 3463 |
rootStyle, |
| 3464 |
otherAttrsMinusId, |
| 3465 |
inputClasses, |
| 3466 |
computedDisabled, |
| 3467 |
onClear, |
| 3468 |
onInput, |
| 3469 |
onChange, |
| 3470 |
onKeydown, |
| 3471 |
onFocus, |
| 3472 |
onBlur, |
| 3473 |
cdxIconClear: Y3 |
| 3474 |
}; |
| 3475 |
}, |
| 3476 |
|
| 3477 |
|
| 3478 |
|
| 3479 |
methods: { |
| 3480 |
|
| 3481 |
|
| 3482 |
|
| 3483 |
|
| 3484 |
|
| 3485 |
focus() { |
| 3486 |
const input = this.$refs.input; |
| 3487 |
input.focus(); |
| 3488 |
}, |
| 3489 |
|
| 3490 |
|
| 3491 |
|
| 3492 |
|
| 3493 |
|
| 3494 |
blur() { |
| 3495 |
const input = this.$refs.input; |
| 3496 |
input.blur(); |
| 3497 |
} |
| 3498 |
} |
| 3499 |
}); |
| 3500 |
const _hoisted_1$i = ["id", "type", "aria-describedby", "disabled"]; |
| 3501 |
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) { |
| 3502 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 3503 |
return openBlock(), createElementBlock( |
| 3504 |
"div", |
| 3505 |
{ |
| 3506 |
class: normalizeClass(["cdx-text-input", _ctx.rootClasses]), |
| 3507 |
style: normalizeStyle(_ctx.rootStyle) |
| 3508 |
}, |
| 3509 |
[ |
| 3510 |
withDirectives(createElementVNode("input", mergeProps({ |
| 3511 |
id: _ctx.computedInputId, |
| 3512 |
ref: "input", |
| 3513 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedModel = $event), |
| 3514 |
class: ["cdx-text-input__input", _ctx.inputClasses] |
| 3515 |
}, _ctx.otherAttrsMinusId, { |
| 3516 |
type: _ctx.inputType, |
| 3517 |
"aria-describedby": _ctx.descriptionId, |
| 3518 |
disabled: _ctx.computedDisabled, |
| 3519 |
size: "1", |
| 3520 |
onInput: _cache[1] || (_cache[1] = (...args) => _ctx.onInput && _ctx.onInput(...args)), |
| 3521 |
onChange: _cache[2] || (_cache[2] = (...args) => _ctx.onChange && _ctx.onChange(...args)), |
| 3522 |
onFocus: _cache[3] || (_cache[3] = (...args) => _ctx.onFocus && _ctx.onFocus(...args)), |
| 3523 |
onBlur: _cache[4] || (_cache[4] = (...args) => _ctx.onBlur && _ctx.onBlur(...args)), |
| 3524 |
onKeydown: _cache[5] || (_cache[5] = (...args) => _ctx.onKeydown && _ctx.onKeydown(...args)) |
| 3525 |
}), null, 16, _hoisted_1$i), [ |
| 3526 |
[vModelDynamic, _ctx.wrappedModel] |
| 3527 |
]), |
| 3528 |
_ctx.startIcon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 3529 |
key: 0, |
| 3530 |
icon: _ctx.startIcon, |
| 3531 |
class: "cdx-text-input__icon-vue cdx-text-input__start-icon" |
| 3532 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 3533 |
_ctx.endIcon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 3534 |
key: 1, |
| 3535 |
icon: _ctx.endIcon, |
| 3536 |
class: "cdx-text-input__icon-vue cdx-text-input__end-icon" |
| 3537 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 3538 |
_ctx.isClearable ? (openBlock(), createBlock(_component_cdx_icon, { |
| 3539 |
key: 2, |
| 3540 |
icon: _ctx.cdxIconClear, |
| 3541 |
class: "cdx-text-input__icon-vue cdx-text-input__clear-icon", |
| 3542 |
onMousedown: _cache[6] || (_cache[6] = withModifiers(() => { |
| 3543 |
}, ["prevent"])), |
| 3544 |
onClick: _ctx.onClear |
| 3545 |
}, null, 8, ["icon", "onClick"])) : createCommentVNode("v-if", true) |
| 3546 |
], |
| 3547 |
6 |
| 3548 |
|
| 3549 |
); |
| 3550 |
} |
| 3551 |
const CdxTextInput = _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]); |
| 3552 |
const sides = ["top", "right", "bottom", "left"]; |
| 3553 |
const min = Math.min; |
| 3554 |
const max = Math.max; |
| 3555 |
const round = Math.round; |
| 3556 |
const floor = Math.floor; |
| 3557 |
const createCoords = (v) => ({ |
| 3558 |
x: v, |
| 3559 |
y: v |
| 3560 |
}); |
| 3561 |
const oppositeSideMap = { |
| 3562 |
left: "right", |
| 3563 |
right: "left", |
| 3564 |
bottom: "top", |
| 3565 |
top: "bottom" |
| 3566 |
}; |
| 3567 |
const oppositeAlignmentMap = { |
| 3568 |
start: "end", |
| 3569 |
end: "start" |
| 3570 |
}; |
| 3571 |
function clamp(start, value, end) { |
| 3572 |
return max(start, min(value, end)); |
| 3573 |
} |
| 3574 |
function evaluate(value, param) { |
| 3575 |
return typeof value === "function" ? value(param) : value; |
| 3576 |
} |
| 3577 |
function getSide(placement) { |
| 3578 |
return placement.split("-")[0]; |
| 3579 |
} |
| 3580 |
function getAlignment(placement) { |
| 3581 |
return placement.split("-")[1]; |
| 3582 |
} |
| 3583 |
function getOppositeAxis(axis) { |
| 3584 |
return axis === "x" ? "y" : "x"; |
| 3585 |
} |
| 3586 |
function getAxisLength(axis) { |
| 3587 |
return axis === "y" ? "height" : "width"; |
| 3588 |
} |
| 3589 |
function getSideAxis(placement) { |
| 3590 |
return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x"; |
| 3591 |
} |
| 3592 |
function getAlignmentAxis(placement) { |
| 3593 |
return getOppositeAxis(getSideAxis(placement)); |
| 3594 |
} |
| 3595 |
function getAlignmentSides(placement, rects, rtl) { |
| 3596 |
if (rtl === void 0) { |
| 3597 |
rtl = false; |
| 3598 |
} |
| 3599 |
const alignment = getAlignment(placement); |
| 3600 |
const alignmentAxis = getAlignmentAxis(placement); |
| 3601 |
const length = getAxisLength(alignmentAxis); |
| 3602 |
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; |
| 3603 |
if (rects.reference[length] > rects.floating[length]) { |
| 3604 |
mainAlignmentSide = getOppositePlacement(mainAlignmentSide); |
| 3605 |
} |
| 3606 |
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; |
| 3607 |
} |
| 3608 |
function getExpandedPlacements(placement) { |
| 3609 |
const oppositePlacement = getOppositePlacement(placement); |
| 3610 |
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; |
| 3611 |
} |
| 3612 |
function getOppositeAlignmentPlacement(placement) { |
| 3613 |
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]); |
| 3614 |
} |
| 3615 |
function getSideList(side, isStart, rtl) { |
| 3616 |
const lr = ["left", "right"]; |
| 3617 |
const rl = ["right", "left"]; |
| 3618 |
const tb = ["top", "bottom"]; |
| 3619 |
const bt = ["bottom", "top"]; |
| 3620 |
switch (side) { |
| 3621 |
case "top": |
| 3622 |
case "bottom": |
| 3623 |
if (rtl) |
| 3624 |
return isStart ? rl : lr; |
| 3625 |
return isStart ? lr : rl; |
| 3626 |
case "left": |
| 3627 |
case "right": |
| 3628 |
return isStart ? tb : bt; |
| 3629 |
default: |
| 3630 |
return []; |
| 3631 |
} |
| 3632 |
} |
| 3633 |
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { |
| 3634 |
const alignment = getAlignment(placement); |
| 3635 |
let list = getSideList(getSide(placement), direction === "start", rtl); |
| 3636 |
if (alignment) { |
| 3637 |
list = list.map((side) => side + "-" + alignment); |
| 3638 |
if (flipAlignment) { |
| 3639 |
list = list.concat(list.map(getOppositeAlignmentPlacement)); |
| 3640 |
} |
| 3641 |
} |
| 3642 |
return list; |
| 3643 |
} |
| 3644 |
function getOppositePlacement(placement) { |
| 3645 |
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]); |
| 3646 |
} |
| 3647 |
function expandPaddingObject(padding) { |
| 3648 |
return __spreadValues({ |
| 3649 |
top: 0, |
| 3650 |
right: 0, |
| 3651 |
bottom: 0, |
| 3652 |
left: 0 |
| 3653 |
}, padding); |
| 3654 |
} |
| 3655 |
function getPaddingObject(padding) { |
| 3656 |
return typeof padding !== "number" ? expandPaddingObject(padding) : { |
| 3657 |
top: padding, |
| 3658 |
right: padding, |
| 3659 |
bottom: padding, |
| 3660 |
left: padding |
| 3661 |
}; |
| 3662 |
} |
| 3663 |
function rectToClientRect(rect) { |
| 3664 |
return __spreadProps(__spreadValues({}, rect), { |
| 3665 |
top: rect.y, |
| 3666 |
left: rect.x, |
| 3667 |
right: rect.x + rect.width, |
| 3668 |
bottom: rect.y + rect.height |
| 3669 |
}); |
| 3670 |
} |
| 3671 |
function computeCoordsFromPlacement(_ref, placement, rtl) { |
| 3672 |
let { |
| 3673 |
reference, |
| 3674 |
floating |
| 3675 |
} = _ref; |
| 3676 |
const sideAxis = getSideAxis(placement); |
| 3677 |
const alignmentAxis = getAlignmentAxis(placement); |
| 3678 |
const alignLength = getAxisLength(alignmentAxis); |
| 3679 |
const side = getSide(placement); |
| 3680 |
const isVertical = sideAxis === "y"; |
| 3681 |
const commonX = reference.x + reference.width / 2 - floating.width / 2; |
| 3682 |
const commonY = reference.y + reference.height / 2 - floating.height / 2; |
| 3683 |
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; |
| 3684 |
let coords; |
| 3685 |
switch (side) { |
| 3686 |
case "top": |
| 3687 |
coords = { |
| 3688 |
x: commonX, |
| 3689 |
y: reference.y - floating.height |
| 3690 |
}; |
| 3691 |
break; |
| 3692 |
case "bottom": |
| 3693 |
coords = { |
| 3694 |
x: commonX, |
| 3695 |
y: reference.y + reference.height |
| 3696 |
}; |
| 3697 |
break; |
| 3698 |
case "right": |
| 3699 |
coords = { |
| 3700 |
x: reference.x + reference.width, |
| 3701 |
y: commonY |
| 3702 |
}; |
| 3703 |
break; |
| 3704 |
case "left": |
| 3705 |
coords = { |
| 3706 |
x: reference.x - floating.width, |
| 3707 |
y: commonY |
| 3708 |
}; |
| 3709 |
break; |
| 3710 |
default: |
| 3711 |
coords = { |
| 3712 |
x: reference.x, |
| 3713 |
y: reference.y |
| 3714 |
}; |
| 3715 |
} |
| 3716 |
switch (getAlignment(placement)) { |
| 3717 |
case "start": |
| 3718 |
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); |
| 3719 |
break; |
| 3720 |
case "end": |
| 3721 |
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); |
| 3722 |
break; |
| 3723 |
} |
| 3724 |
return coords; |
| 3725 |
} |
| 3726 |
const computePosition$1 = (reference, floating, config) => __async(void 0, null, function* () { |
| 3727 |
const { |
| 3728 |
placement = "bottom", |
| 3729 |
strategy = "absolute", |
| 3730 |
middleware = [], |
| 3731 |
platform: platform2 |
| 3732 |
} = config; |
| 3733 |
const validMiddleware = middleware.filter(Boolean); |
| 3734 |
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating); |
| 3735 |
let rects = yield platform2.getElementRects({ |
| 3736 |
reference, |
| 3737 |
floating, |
| 3738 |
strategy |
| 3739 |
}); |
| 3740 |
let { |
| 3741 |
x, |
| 3742 |
y |
| 3743 |
} = computeCoordsFromPlacement(rects, placement, rtl); |
| 3744 |
let statefulPlacement = placement; |
| 3745 |
let middlewareData = {}; |
| 3746 |
let resetCount = 0; |
| 3747 |
for (let i = 0; i < validMiddleware.length; i++) { |
| 3748 |
const { |
| 3749 |
name, |
| 3750 |
fn |
| 3751 |
} = validMiddleware[i]; |
| 3752 |
const { |
| 3753 |
x: nextX, |
| 3754 |
y: nextY, |
| 3755 |
data, |
| 3756 |
reset |
| 3757 |
} = yield fn({ |
| 3758 |
x, |
| 3759 |
y, |
| 3760 |
initialPlacement: placement, |
| 3761 |
placement: statefulPlacement, |
| 3762 |
strategy, |
| 3763 |
middlewareData, |
| 3764 |
rects, |
| 3765 |
platform: platform2, |
| 3766 |
elements: { |
| 3767 |
reference, |
| 3768 |
floating |
| 3769 |
} |
| 3770 |
}); |
| 3771 |
x = nextX != null ? nextX : x; |
| 3772 |
y = nextY != null ? nextY : y; |
| 3773 |
middlewareData = __spreadProps(__spreadValues({}, middlewareData), { |
| 3774 |
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data) |
| 3775 |
}); |
| 3776 |
if (reset && resetCount <= 50) { |
| 3777 |
resetCount++; |
| 3778 |
if (typeof reset === "object") { |
| 3779 |
if (reset.placement) { |
| 3780 |
statefulPlacement = reset.placement; |
| 3781 |
} |
| 3782 |
if (reset.rects) { |
| 3783 |
rects = reset.rects === true ? yield platform2.getElementRects({ |
| 3784 |
reference, |
| 3785 |
floating, |
| 3786 |
strategy |
| 3787 |
}) : reset.rects; |
| 3788 |
} |
| 3789 |
({ |
| 3790 |
x, |
| 3791 |
y |
| 3792 |
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); |
| 3793 |
} |
| 3794 |
i = -1; |
| 3795 |
} |
| 3796 |
} |
| 3797 |
return { |
| 3798 |
x, |
| 3799 |
y, |
| 3800 |
placement: statefulPlacement, |
| 3801 |
strategy, |
| 3802 |
middlewareData |
| 3803 |
}; |
| 3804 |
}); |
| 3805 |
function detectOverflow(state, options) { |
| 3806 |
return __async(this, null, function* () { |
| 3807 |
var _await$platform$isEle; |
| 3808 |
if (options === void 0) { |
| 3809 |
options = {}; |
| 3810 |
} |
| 3811 |
const { |
| 3812 |
x, |
| 3813 |
y, |
| 3814 |
platform: platform2, |
| 3815 |
rects, |
| 3816 |
elements, |
| 3817 |
strategy |
| 3818 |
} = state; |
| 3819 |
const { |
| 3820 |
boundary = "clippingAncestors", |
| 3821 |
rootBoundary = "viewport", |
| 3822 |
elementContext = "floating", |
| 3823 |
altBoundary = false, |
| 3824 |
padding = 0 |
| 3825 |
} = evaluate(options, state); |
| 3826 |
const paddingObject = getPaddingObject(padding); |
| 3827 |
const altContext = elementContext === "floating" ? "reference" : "floating"; |
| 3828 |
const element = elements[altBoundary ? altContext : elementContext]; |
| 3829 |
const clippingClientRect = rectToClientRect(yield platform2.getClippingRect({ |
| 3830 |
element: ((_await$platform$isEle = yield platform2.isElement == null ? void 0 : platform2.isElement(element)) != null ? _await$platform$isEle : true) ? element : element.contextElement || (yield platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)), |
| 3831 |
boundary, |
| 3832 |
rootBoundary, |
| 3833 |
strategy |
| 3834 |
})); |
| 3835 |
const rect = elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), { |
| 3836 |
x, |
| 3837 |
y |
| 3838 |
}) : rects.reference; |
| 3839 |
const offsetParent = yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating); |
| 3840 |
const offsetScale = (yield platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? (yield platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || { |
| 3841 |
x: 1, |
| 3842 |
y: 1 |
| 3843 |
} : { |
| 3844 |
x: 1, |
| 3845 |
y: 1 |
| 3846 |
}; |
| 3847 |
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform2.convertOffsetParentRelativeRectToViewportRelativeRect({ |
| 3848 |
elements, |
| 3849 |
rect, |
| 3850 |
offsetParent, |
| 3851 |
strategy |
| 3852 |
}) : rect); |
| 3853 |
return { |
| 3854 |
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, |
| 3855 |
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, |
| 3856 |
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, |
| 3857 |
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x |
| 3858 |
}; |
| 3859 |
}); |
| 3860 |
} |
| 3861 |
const flip$1 = function(options) { |
| 3862 |
if (options === void 0) { |
| 3863 |
options = {}; |
| 3864 |
} |
| 3865 |
return { |
| 3866 |
name: "flip", |
| 3867 |
options, |
| 3868 |
fn(state) { |
| 3869 |
return __async(this, null, function* () { |
| 3870 |
var _middlewareData$arrow, _middlewareData$flip; |
| 3871 |
const { |
| 3872 |
placement, |
| 3873 |
middlewareData, |
| 3874 |
rects, |
| 3875 |
initialPlacement, |
| 3876 |
platform: platform2, |
| 3877 |
elements |
| 3878 |
} = state; |
| 3879 |
const _a2 = evaluate(options, state), { |
| 3880 |
mainAxis: checkMainAxis = true, |
| 3881 |
crossAxis: checkCrossAxis = true, |
| 3882 |
fallbackPlacements: specifiedFallbackPlacements, |
| 3883 |
fallbackStrategy = "bestFit", |
| 3884 |
fallbackAxisSideDirection = "none", |
| 3885 |
flipAlignment = true |
| 3886 |
} = _a2, detectOverflowOptions = __objRest(_a2, [ |
| 3887 |
"mainAxis", |
| 3888 |
"crossAxis", |
| 3889 |
"fallbackPlacements", |
| 3890 |
"fallbackStrategy", |
| 3891 |
"fallbackAxisSideDirection", |
| 3892 |
"flipAlignment" |
| 3893 |
]); |
| 3894 |
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { |
| 3895 |
return {}; |
| 3896 |
} |
| 3897 |
const side = getSide(placement); |
| 3898 |
const isBasePlacement = getSide(initialPlacement) === initialPlacement; |
| 3899 |
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating); |
| 3900 |
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); |
| 3901 |
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") { |
| 3902 |
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); |
| 3903 |
} |
| 3904 |
const placements = [initialPlacement, ...fallbackPlacements]; |
| 3905 |
const overflow = yield detectOverflow(state, detectOverflowOptions); |
| 3906 |
const overflows = []; |
| 3907 |
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; |
| 3908 |
if (checkMainAxis) { |
| 3909 |
overflows.push(overflow[side]); |
| 3910 |
} |
| 3911 |
if (checkCrossAxis) { |
| 3912 |
const sides2 = getAlignmentSides(placement, rects, rtl); |
| 3913 |
overflows.push(overflow[sides2[0]], overflow[sides2[1]]); |
| 3914 |
} |
| 3915 |
overflowsData = [...overflowsData, { |
| 3916 |
placement, |
| 3917 |
overflows |
| 3918 |
}]; |
| 3919 |
if (!overflows.every((side2) => side2 <= 0)) { |
| 3920 |
var _middlewareData$flip2, _overflowsData$filter; |
| 3921 |
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; |
| 3922 |
const nextPlacement = placements[nextIndex]; |
| 3923 |
if (nextPlacement) { |
| 3924 |
return { |
| 3925 |
data: { |
| 3926 |
index: nextIndex, |
| 3927 |
overflows: overflowsData |
| 3928 |
}, |
| 3929 |
reset: { |
| 3930 |
placement: nextPlacement |
| 3931 |
} |
| 3932 |
}; |
| 3933 |
} |
| 3934 |
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; |
| 3935 |
if (!resetPlacement) { |
| 3936 |
switch (fallbackStrategy) { |
| 3937 |
case "bestFit": { |
| 3938 |
var _overflowsData$map$so; |
| 3939 |
const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; |
| 3940 |
if (placement2) { |
| 3941 |
resetPlacement = placement2; |
| 3942 |
} |
| 3943 |
break; |
| 3944 |
} |
| 3945 |
case "initialPlacement": |
| 3946 |
resetPlacement = initialPlacement; |
| 3947 |
break; |
| 3948 |
} |
| 3949 |
} |
| 3950 |
if (placement !== resetPlacement) { |
| 3951 |
return { |
| 3952 |
reset: { |
| 3953 |
placement: resetPlacement |
| 3954 |
} |
| 3955 |
}; |
| 3956 |
} |
| 3957 |
} |
| 3958 |
return {}; |
| 3959 |
}); |
| 3960 |
} |
| 3961 |
}; |
| 3962 |
}; |
| 3963 |
function getSideOffsets(overflow, rect) { |
| 3964 |
return { |
| 3965 |
top: overflow.top - rect.height, |
| 3966 |
right: overflow.right - rect.width, |
| 3967 |
bottom: overflow.bottom - rect.height, |
| 3968 |
left: overflow.left - rect.width |
| 3969 |
}; |
| 3970 |
} |
| 3971 |
function isAnySideFullyClipped(overflow) { |
| 3972 |
return sides.some((side) => overflow[side] >= 0); |
| 3973 |
} |
| 3974 |
const hide$1 = function(options) { |
| 3975 |
if (options === void 0) { |
| 3976 |
options = {}; |
| 3977 |
} |
| 3978 |
return { |
| 3979 |
name: "hide", |
| 3980 |
options, |
| 3981 |
fn(state) { |
| 3982 |
return __async(this, null, function* () { |
| 3983 |
const { |
| 3984 |
rects |
| 3985 |
} = state; |
| 3986 |
const _a2 = evaluate(options, state), { |
| 3987 |
strategy = "referenceHidden" |
| 3988 |
} = _a2, detectOverflowOptions = __objRest(_a2, [ |
| 3989 |
"strategy" |
| 3990 |
]); |
| 3991 |
switch (strategy) { |
| 3992 |
case "referenceHidden": { |
| 3993 |
const overflow = yield detectOverflow(state, __spreadProps(__spreadValues({}, detectOverflowOptions), { |
| 3994 |
elementContext: "reference" |
| 3995 |
})); |
| 3996 |
const offsets = getSideOffsets(overflow, rects.reference); |
| 3997 |
return { |
| 3998 |
data: { |
| 3999 |
referenceHiddenOffsets: offsets, |
| 4000 |
referenceHidden: isAnySideFullyClipped(offsets) |
| 4001 |
} |
| 4002 |
}; |
| 4003 |
} |
| 4004 |
case "escaped": { |
| 4005 |
const overflow = yield detectOverflow(state, __spreadProps(__spreadValues({}, detectOverflowOptions), { |
| 4006 |
altBoundary: true |
| 4007 |
})); |
| 4008 |
const offsets = getSideOffsets(overflow, rects.floating); |
| 4009 |
return { |
| 4010 |
data: { |
| 4011 |
escapedOffsets: offsets, |
| 4012 |
escaped: isAnySideFullyClipped(offsets) |
| 4013 |
} |
| 4014 |
}; |
| 4015 |
} |
| 4016 |
default: { |
| 4017 |
return {}; |
| 4018 |
} |
| 4019 |
} |
| 4020 |
}); |
| 4021 |
} |
| 4022 |
}; |
| 4023 |
}; |
| 4024 |
function convertValueToCoords(state, options) { |
| 4025 |
return __async(this, null, function* () { |
| 4026 |
const { |
| 4027 |
placement, |
| 4028 |
platform: platform2, |
| 4029 |
elements |
| 4030 |
} = state; |
| 4031 |
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating); |
| 4032 |
const side = getSide(placement); |
| 4033 |
const alignment = getAlignment(placement); |
| 4034 |
const isVertical = getSideAxis(placement) === "y"; |
| 4035 |
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1; |
| 4036 |
const crossAxisMulti = rtl && isVertical ? -1 : 1; |
| 4037 |
const rawValue = evaluate(options, state); |
| 4038 |
let { |
| 4039 |
mainAxis, |
| 4040 |
crossAxis, |
| 4041 |
alignmentAxis |
| 4042 |
} = typeof rawValue === "number" ? { |
| 4043 |
mainAxis: rawValue, |
| 4044 |
crossAxis: 0, |
| 4045 |
alignmentAxis: null |
| 4046 |
} : __spreadValues({ |
| 4047 |
mainAxis: 0, |
| 4048 |
crossAxis: 0, |
| 4049 |
alignmentAxis: null |
| 4050 |
}, rawValue); |
| 4051 |
if (alignment && typeof alignmentAxis === "number") { |
| 4052 |
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; |
| 4053 |
} |
| 4054 |
return isVertical ? { |
| 4055 |
x: crossAxis * crossAxisMulti, |
| 4056 |
y: mainAxis * mainAxisMulti |
| 4057 |
} : { |
| 4058 |
x: mainAxis * mainAxisMulti, |
| 4059 |
y: crossAxis * crossAxisMulti |
| 4060 |
}; |
| 4061 |
}); |
| 4062 |
} |
| 4063 |
const offset = function(options) { |
| 4064 |
if (options === void 0) { |
| 4065 |
options = 0; |
| 4066 |
} |
| 4067 |
return { |
| 4068 |
name: "offset", |
| 4069 |
options, |
| 4070 |
fn(state) { |
| 4071 |
return __async(this, null, function* () { |
| 4072 |
var _middlewareData$offse, _middlewareData$arrow; |
| 4073 |
const { |
| 4074 |
x, |
| 4075 |
y, |
| 4076 |
placement, |
| 4077 |
middlewareData |
| 4078 |
} = state; |
| 4079 |
const diffCoords = yield convertValueToCoords(state, options); |
| 4080 |
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { |
| 4081 |
return {}; |
| 4082 |
} |
| 4083 |
return { |
| 4084 |
x: x + diffCoords.x, |
| 4085 |
y: y + diffCoords.y, |
| 4086 |
data: __spreadProps(__spreadValues({}, diffCoords), { |
| 4087 |
placement |
| 4088 |
}) |
| 4089 |
}; |
| 4090 |
}); |
| 4091 |
} |
| 4092 |
}; |
| 4093 |
}; |
| 4094 |
const shift$1 = function(options) { |
| 4095 |
if (options === void 0) { |
| 4096 |
options = {}; |
| 4097 |
} |
| 4098 |
return { |
| 4099 |
name: "shift", |
| 4100 |
options, |
| 4101 |
fn(state) { |
| 4102 |
return __async(this, null, function* () { |
| 4103 |
const { |
| 4104 |
x, |
| 4105 |
y, |
| 4106 |
placement |
| 4107 |
} = state; |
| 4108 |
const _a2 = evaluate(options, state), { |
| 4109 |
mainAxis: checkMainAxis = true, |
| 4110 |
crossAxis: checkCrossAxis = false, |
| 4111 |
limiter = { |
| 4112 |
fn: (_ref) => { |
| 4113 |
let { |
| 4114 |
x: x2, |
| 4115 |
y: y2 |
| 4116 |
} = _ref; |
| 4117 |
return { |
| 4118 |
x: x2, |
| 4119 |
y: y2 |
| 4120 |
}; |
| 4121 |
} |
| 4122 |
} |
| 4123 |
} = _a2, detectOverflowOptions = __objRest(_a2, [ |
| 4124 |
"mainAxis", |
| 4125 |
"crossAxis", |
| 4126 |
"limiter" |
| 4127 |
]); |
| 4128 |
const coords = { |
| 4129 |
x, |
| 4130 |
y |
| 4131 |
}; |
| 4132 |
const overflow = yield detectOverflow(state, detectOverflowOptions); |
| 4133 |
const crossAxis = getSideAxis(getSide(placement)); |
| 4134 |
const mainAxis = getOppositeAxis(crossAxis); |
| 4135 |
let mainAxisCoord = coords[mainAxis]; |
| 4136 |
let crossAxisCoord = coords[crossAxis]; |
| 4137 |
if (checkMainAxis) { |
| 4138 |
const minSide = mainAxis === "y" ? "top" : "left"; |
| 4139 |
const maxSide = mainAxis === "y" ? "bottom" : "right"; |
| 4140 |
const min2 = mainAxisCoord + overflow[minSide]; |
| 4141 |
const max2 = mainAxisCoord - overflow[maxSide]; |
| 4142 |
mainAxisCoord = clamp(min2, mainAxisCoord, max2); |
| 4143 |
} |
| 4144 |
if (checkCrossAxis) { |
| 4145 |
const minSide = crossAxis === "y" ? "top" : "left"; |
| 4146 |
const maxSide = crossAxis === "y" ? "bottom" : "right"; |
| 4147 |
const min2 = crossAxisCoord + overflow[minSide]; |
| 4148 |
const max2 = crossAxisCoord - overflow[maxSide]; |
| 4149 |
crossAxisCoord = clamp(min2, crossAxisCoord, max2); |
| 4150 |
} |
| 4151 |
const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, state), { |
| 4152 |
[mainAxis]: mainAxisCoord, |
| 4153 |
[crossAxis]: crossAxisCoord |
| 4154 |
})); |
| 4155 |
return __spreadProps(__spreadValues({}, limitedCoords), { |
| 4156 |
data: { |
| 4157 |
x: limitedCoords.x - x, |
| 4158 |
y: limitedCoords.y - y |
| 4159 |
} |
| 4160 |
}); |
| 4161 |
}); |
| 4162 |
} |
| 4163 |
}; |
| 4164 |
}; |
| 4165 |
const size$1 = function(options) { |
| 4166 |
if (options === void 0) { |
| 4167 |
options = {}; |
| 4168 |
} |
| 4169 |
return { |
| 4170 |
name: "size", |
| 4171 |
options, |
| 4172 |
fn(state) { |
| 4173 |
return __async(this, null, function* () { |
| 4174 |
const { |
| 4175 |
placement, |
| 4176 |
rects, |
| 4177 |
platform: platform2, |
| 4178 |
elements |
| 4179 |
} = state; |
| 4180 |
const _a2 = evaluate(options, state), { |
| 4181 |
apply = () => { |
| 4182 |
} |
| 4183 |
} = _a2, detectOverflowOptions = __objRest(_a2, [ |
| 4184 |
"apply" |
| 4185 |
]); |
| 4186 |
const overflow = yield detectOverflow(state, detectOverflowOptions); |
| 4187 |
const side = getSide(placement); |
| 4188 |
const alignment = getAlignment(placement); |
| 4189 |
const isYAxis = getSideAxis(placement) === "y"; |
| 4190 |
const { |
| 4191 |
width, |
| 4192 |
height |
| 4193 |
} = rects.floating; |
| 4194 |
let heightSide; |
| 4195 |
let widthSide; |
| 4196 |
if (side === "top" || side === "bottom") { |
| 4197 |
heightSide = side; |
| 4198 |
widthSide = alignment === ((yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; |
| 4199 |
} else { |
| 4200 |
widthSide = side; |
| 4201 |
heightSide = alignment === "end" ? "top" : "bottom"; |
| 4202 |
} |
| 4203 |
const overflowAvailableHeight = height - overflow[heightSide]; |
| 4204 |
const overflowAvailableWidth = width - overflow[widthSide]; |
| 4205 |
const noShift = !state.middlewareData.shift; |
| 4206 |
let availableHeight = overflowAvailableHeight; |
| 4207 |
let availableWidth = overflowAvailableWidth; |
| 4208 |
if (isYAxis) { |
| 4209 |
const maximumClippingWidth = width - overflow.left - overflow.right; |
| 4210 |
availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; |
| 4211 |
} else { |
| 4212 |
const maximumClippingHeight = height - overflow.top - overflow.bottom; |
| 4213 |
availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; |
| 4214 |
} |
| 4215 |
if (noShift && !alignment) { |
| 4216 |
const xMin = max(overflow.left, 0); |
| 4217 |
const xMax = max(overflow.right, 0); |
| 4218 |
const yMin = max(overflow.top, 0); |
| 4219 |
const yMax = max(overflow.bottom, 0); |
| 4220 |
if (isYAxis) { |
| 4221 |
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); |
| 4222 |
} else { |
| 4223 |
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); |
| 4224 |
} |
| 4225 |
} |
| 4226 |
yield apply(__spreadProps(__spreadValues({}, state), { |
| 4227 |
availableWidth, |
| 4228 |
availableHeight |
| 4229 |
})); |
| 4230 |
const nextDimensions = yield platform2.getDimensions(elements.floating); |
| 4231 |
if (width !== nextDimensions.width || height !== nextDimensions.height) { |
| 4232 |
return { |
| 4233 |
reset: { |
| 4234 |
rects: true |
| 4235 |
} |
| 4236 |
}; |
| 4237 |
} |
| 4238 |
return {}; |
| 4239 |
}); |
| 4240 |
} |
| 4241 |
}; |
| 4242 |
}; |
| 4243 |
function getNodeName(node) { |
| 4244 |
if (isNode(node)) { |
| 4245 |
return (node.nodeName || "").toLowerCase(); |
| 4246 |
} |
| 4247 |
return "#document"; |
| 4248 |
} |
| 4249 |
function getWindow(node) { |
| 4250 |
var _node$ownerDocument; |
| 4251 |
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; |
| 4252 |
} |
| 4253 |
function getDocumentElement(node) { |
| 4254 |
var _ref; |
| 4255 |
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; |
| 4256 |
} |
| 4257 |
function isNode(value) { |
| 4258 |
return value instanceof Node || value instanceof getWindow(value).Node; |
| 4259 |
} |
| 4260 |
function isElement(value) { |
| 4261 |
return value instanceof Element || value instanceof getWindow(value).Element; |
| 4262 |
} |
| 4263 |
function isHTMLElement(value) { |
| 4264 |
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; |
| 4265 |
} |
| 4266 |
function isShadowRoot(value) { |
| 4267 |
if (typeof ShadowRoot === "undefined") { |
| 4268 |
return false; |
| 4269 |
} |
| 4270 |
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; |
| 4271 |
} |
| 4272 |
function isOverflowElement(element) { |
| 4273 |
const { |
| 4274 |
overflow, |
| 4275 |
overflowX, |
| 4276 |
overflowY, |
| 4277 |
display |
| 4278 |
} = getComputedStyle(element); |
| 4279 |
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display); |
| 4280 |
} |
| 4281 |
function isTableElement(element) { |
| 4282 |
return ["table", "td", "th"].includes(getNodeName(element)); |
| 4283 |
} |
| 4284 |
function isContainingBlock(element) { |
| 4285 |
const webkit = isWebKit(); |
| 4286 |
const css = getComputedStyle(element); |
| 4287 |
return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value)); |
| 4288 |
} |
| 4289 |
function getContainingBlock(element) { |
| 4290 |
let currentNode = getParentNode(element); |
| 4291 |
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { |
| 4292 |
if (isContainingBlock(currentNode)) { |
| 4293 |
return currentNode; |
| 4294 |
} else { |
| 4295 |
currentNode = getParentNode(currentNode); |
| 4296 |
} |
| 4297 |
} |
| 4298 |
return null; |
| 4299 |
} |
| 4300 |
function isWebKit() { |
| 4301 |
if (typeof CSS === "undefined" || !CSS.supports) |
| 4302 |
return false; |
| 4303 |
return CSS.supports("-webkit-backdrop-filter", "none"); |
| 4304 |
} |
| 4305 |
function isLastTraversableNode(node) { |
| 4306 |
return ["html", "body", "#document"].includes(getNodeName(node)); |
| 4307 |
} |
| 4308 |
function getComputedStyle(element) { |
| 4309 |
return getWindow(element).getComputedStyle(element); |
| 4310 |
} |
| 4311 |
function getNodeScroll(element) { |
| 4312 |
if (isElement(element)) { |
| 4313 |
return { |
| 4314 |
scrollLeft: element.scrollLeft, |
| 4315 |
scrollTop: element.scrollTop |
| 4316 |
}; |
| 4317 |
} |
| 4318 |
return { |
| 4319 |
scrollLeft: element.pageXOffset, |
| 4320 |
scrollTop: element.pageYOffset |
| 4321 |
}; |
| 4322 |
} |
| 4323 |
function getParentNode(node) { |
| 4324 |
if (getNodeName(node) === "html") { |
| 4325 |
return node; |
| 4326 |
} |
| 4327 |
const result = ( |
| 4328 |
|
| 4329 |
node.assignedSlot || |
| 4330 |
node.parentNode || |
| 4331 |
isShadowRoot(node) && node.host || |
| 4332 |
getDocumentElement(node) |
| 4333 |
); |
| 4334 |
return isShadowRoot(result) ? result.host : result; |
| 4335 |
} |
| 4336 |
function getNearestOverflowAncestor(node) { |
| 4337 |
const parentNode = getParentNode(node); |
| 4338 |
if (isLastTraversableNode(parentNode)) { |
| 4339 |
return node.ownerDocument ? node.ownerDocument.body : node.body; |
| 4340 |
} |
| 4341 |
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
| 4342 |
return parentNode; |
| 4343 |
} |
| 4344 |
return getNearestOverflowAncestor(parentNode); |
| 4345 |
} |
| 4346 |
function getOverflowAncestors(node, list, traverseIframes) { |
| 4347 |
var _node$ownerDocument2; |
| 4348 |
if (list === void 0) { |
| 4349 |
list = []; |
| 4350 |
} |
| 4351 |
if (traverseIframes === void 0) { |
| 4352 |
traverseIframes = true; |
| 4353 |
} |
| 4354 |
const scrollableAncestor = getNearestOverflowAncestor(node); |
| 4355 |
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); |
| 4356 |
const win = getWindow(scrollableAncestor); |
| 4357 |
if (isBody) { |
| 4358 |
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []); |
| 4359 |
} |
| 4360 |
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); |
| 4361 |
} |
| 4362 |
function getCssDimensions(element) { |
| 4363 |
const css = getComputedStyle(element); |
| 4364 |
let width = parseFloat(css.width) || 0; |
| 4365 |
let height = parseFloat(css.height) || 0; |
| 4366 |
const hasOffset = isHTMLElement(element); |
| 4367 |
const offsetWidth = hasOffset ? element.offsetWidth : width; |
| 4368 |
const offsetHeight = hasOffset ? element.offsetHeight : height; |
| 4369 |
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; |
| 4370 |
if (shouldFallback) { |
| 4371 |
width = offsetWidth; |
| 4372 |
height = offsetHeight; |
| 4373 |
} |
| 4374 |
return { |
| 4375 |
width, |
| 4376 |
height, |
| 4377 |
$: shouldFallback |
| 4378 |
}; |
| 4379 |
} |
| 4380 |
function unwrapElement$2(element) { |
| 4381 |
return !isElement(element) ? element.contextElement : element; |
| 4382 |
} |
| 4383 |
function getScale(element) { |
| 4384 |
const domElement = unwrapElement$2(element); |
| 4385 |
if (!isHTMLElement(domElement)) { |
| 4386 |
return createCoords(1); |
| 4387 |
} |
| 4388 |
const rect = domElement.getBoundingClientRect(); |
| 4389 |
const { |
| 4390 |
width, |
| 4391 |
height, |
| 4392 |
$ |
| 4393 |
} = getCssDimensions(domElement); |
| 4394 |
let x = ($ ? round(rect.width) : rect.width) / width; |
| 4395 |
let y = ($ ? round(rect.height) : rect.height) / height; |
| 4396 |
if (!x || !Number.isFinite(x)) { |
| 4397 |
x = 1; |
| 4398 |
} |
| 4399 |
if (!y || !Number.isFinite(y)) { |
| 4400 |
y = 1; |
| 4401 |
} |
| 4402 |
return { |
| 4403 |
x, |
| 4404 |
y |
| 4405 |
}; |
| 4406 |
} |
| 4407 |
const noOffsets = createCoords(0); |
| 4408 |
function getVisualOffsets(element) { |
| 4409 |
const win = getWindow(element); |
| 4410 |
if (!isWebKit() || !win.visualViewport) { |
| 4411 |
return noOffsets; |
| 4412 |
} |
| 4413 |
return { |
| 4414 |
x: win.visualViewport.offsetLeft, |
| 4415 |
y: win.visualViewport.offsetTop |
| 4416 |
}; |
| 4417 |
} |
| 4418 |
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { |
| 4419 |
if (isFixed === void 0) { |
| 4420 |
isFixed = false; |
| 4421 |
} |
| 4422 |
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { |
| 4423 |
return false; |
| 4424 |
} |
| 4425 |
return isFixed; |
| 4426 |
} |
| 4427 |
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { |
| 4428 |
if (includeScale === void 0) { |
| 4429 |
includeScale = false; |
| 4430 |
} |
| 4431 |
if (isFixedStrategy === void 0) { |
| 4432 |
isFixedStrategy = false; |
| 4433 |
} |
| 4434 |
const clientRect = element.getBoundingClientRect(); |
| 4435 |
const domElement = unwrapElement$2(element); |
| 4436 |
let scale = createCoords(1); |
| 4437 |
if (includeScale) { |
| 4438 |
if (offsetParent) { |
| 4439 |
if (isElement(offsetParent)) { |
| 4440 |
scale = getScale(offsetParent); |
| 4441 |
} |
| 4442 |
} else { |
| 4443 |
scale = getScale(element); |
| 4444 |
} |
| 4445 |
} |
| 4446 |
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); |
| 4447 |
let x = (clientRect.left + visualOffsets.x) / scale.x; |
| 4448 |
let y = (clientRect.top + visualOffsets.y) / scale.y; |
| 4449 |
let width = clientRect.width / scale.x; |
| 4450 |
let height = clientRect.height / scale.y; |
| 4451 |
if (domElement) { |
| 4452 |
const win = getWindow(domElement); |
| 4453 |
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; |
| 4454 |
let currentWin = win; |
| 4455 |
let currentIFrame = currentWin.frameElement; |
| 4456 |
while (currentIFrame && offsetParent && offsetWin !== currentWin) { |
| 4457 |
const iframeScale = getScale(currentIFrame); |
| 4458 |
const iframeRect = currentIFrame.getBoundingClientRect(); |
| 4459 |
const css = getComputedStyle(currentIFrame); |
| 4460 |
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; |
| 4461 |
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; |
| 4462 |
x *= iframeScale.x; |
| 4463 |
y *= iframeScale.y; |
| 4464 |
width *= iframeScale.x; |
| 4465 |
height *= iframeScale.y; |
| 4466 |
x += left; |
| 4467 |
y += top; |
| 4468 |
currentWin = getWindow(currentIFrame); |
| 4469 |
currentIFrame = currentWin.frameElement; |
| 4470 |
} |
| 4471 |
} |
| 4472 |
return rectToClientRect({ |
| 4473 |
width, |
| 4474 |
height, |
| 4475 |
x, |
| 4476 |
y |
| 4477 |
}); |
| 4478 |
} |
| 4479 |
const topLayerSelectors = [":popover-open", ":modal"]; |
| 4480 |
function isTopLayer(floating) { |
| 4481 |
return topLayerSelectors.some((selector) => { |
| 4482 |
try { |
| 4483 |
return floating.matches(selector); |
| 4484 |
} catch (e) { |
| 4485 |
return false; |
| 4486 |
} |
| 4487 |
}); |
| 4488 |
} |
| 4489 |
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { |
| 4490 |
let { |
| 4491 |
elements, |
| 4492 |
rect, |
| 4493 |
offsetParent, |
| 4494 |
strategy |
| 4495 |
} = _ref; |
| 4496 |
const isFixed = strategy === "fixed"; |
| 4497 |
const documentElement = getDocumentElement(offsetParent); |
| 4498 |
const topLayer = elements ? isTopLayer(elements.floating) : false; |
| 4499 |
if (offsetParent === documentElement || topLayer && isFixed) { |
| 4500 |
return rect; |
| 4501 |
} |
| 4502 |
let scroll = { |
| 4503 |
scrollLeft: 0, |
| 4504 |
scrollTop: 0 |
| 4505 |
}; |
| 4506 |
let scale = createCoords(1); |
| 4507 |
const offsets = createCoords(0); |
| 4508 |
const isOffsetParentAnElement = isHTMLElement(offsetParent); |
| 4509 |
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { |
| 4510 |
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { |
| 4511 |
scroll = getNodeScroll(offsetParent); |
| 4512 |
} |
| 4513 |
if (isHTMLElement(offsetParent)) { |
| 4514 |
const offsetRect = getBoundingClientRect(offsetParent); |
| 4515 |
scale = getScale(offsetParent); |
| 4516 |
offsets.x = offsetRect.x + offsetParent.clientLeft; |
| 4517 |
offsets.y = offsetRect.y + offsetParent.clientTop; |
| 4518 |
} |
| 4519 |
} |
| 4520 |
return { |
| 4521 |
width: rect.width * scale.x, |
| 4522 |
height: rect.height * scale.y, |
| 4523 |
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x, |
| 4524 |
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y |
| 4525 |
}; |
| 4526 |
} |
| 4527 |
function getClientRects(element) { |
| 4528 |
return Array.from(element.getClientRects()); |
| 4529 |
} |
| 4530 |
function getWindowScrollBarX(element) { |
| 4531 |
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; |
| 4532 |
} |
| 4533 |
function getDocumentRect(element) { |
| 4534 |
const html = getDocumentElement(element); |
| 4535 |
const scroll = getNodeScroll(element); |
| 4536 |
const body = element.ownerDocument.body; |
| 4537 |
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); |
| 4538 |
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); |
| 4539 |
let x = -scroll.scrollLeft + getWindowScrollBarX(element); |
| 4540 |
const y = -scroll.scrollTop; |
| 4541 |
if (getComputedStyle(body).direction === "rtl") { |
| 4542 |
x += max(html.clientWidth, body.clientWidth) - width; |
| 4543 |
} |
| 4544 |
return { |
| 4545 |
width, |
| 4546 |
height, |
| 4547 |
x, |
| 4548 |
y |
| 4549 |
}; |
| 4550 |
} |
| 4551 |
function getViewportRect(element, strategy) { |
| 4552 |
const win = getWindow(element); |
| 4553 |
const html = getDocumentElement(element); |
| 4554 |
const visualViewport = win.visualViewport; |
| 4555 |
let width = html.clientWidth; |
| 4556 |
let height = html.clientHeight; |
| 4557 |
let x = 0; |
| 4558 |
let y = 0; |
| 4559 |
if (visualViewport) { |
| 4560 |
width = visualViewport.width; |
| 4561 |
height = visualViewport.height; |
| 4562 |
const visualViewportBased = isWebKit(); |
| 4563 |
if (!visualViewportBased || visualViewportBased && strategy === "fixed") { |
| 4564 |
x = visualViewport.offsetLeft; |
| 4565 |
y = visualViewport.offsetTop; |
| 4566 |
} |
| 4567 |
} |
| 4568 |
return { |
| 4569 |
width, |
| 4570 |
height, |
| 4571 |
x, |
| 4572 |
y |
| 4573 |
}; |
| 4574 |
} |
| 4575 |
function getInnerBoundingClientRect(element, strategy) { |
| 4576 |
const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); |
| 4577 |
const top = clientRect.top + element.clientTop; |
| 4578 |
const left = clientRect.left + element.clientLeft; |
| 4579 |
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); |
| 4580 |
const width = element.clientWidth * scale.x; |
| 4581 |
const height = element.clientHeight * scale.y; |
| 4582 |
const x = left * scale.x; |
| 4583 |
const y = top * scale.y; |
| 4584 |
return { |
| 4585 |
width, |
| 4586 |
height, |
| 4587 |
x, |
| 4588 |
y |
| 4589 |
}; |
| 4590 |
} |
| 4591 |
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { |
| 4592 |
let rect; |
| 4593 |
if (clippingAncestor === "viewport") { |
| 4594 |
rect = getViewportRect(element, strategy); |
| 4595 |
} else if (clippingAncestor === "document") { |
| 4596 |
rect = getDocumentRect(getDocumentElement(element)); |
| 4597 |
} else if (isElement(clippingAncestor)) { |
| 4598 |
rect = getInnerBoundingClientRect(clippingAncestor, strategy); |
| 4599 |
} else { |
| 4600 |
const visualOffsets = getVisualOffsets(element); |
| 4601 |
rect = __spreadProps(__spreadValues({}, clippingAncestor), { |
| 4602 |
x: clippingAncestor.x - visualOffsets.x, |
| 4603 |
y: clippingAncestor.y - visualOffsets.y |
| 4604 |
}); |
| 4605 |
} |
| 4606 |
return rectToClientRect(rect); |
| 4607 |
} |
| 4608 |
function hasFixedPositionAncestor(element, stopNode) { |
| 4609 |
const parentNode = getParentNode(element); |
| 4610 |
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { |
| 4611 |
return false; |
| 4612 |
} |
| 4613 |
return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); |
| 4614 |
} |
| 4615 |
function getClippingElementAncestors(element, cache) { |
| 4616 |
const cachedResult = cache.get(element); |
| 4617 |
if (cachedResult) { |
| 4618 |
return cachedResult; |
| 4619 |
} |
| 4620 |
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body"); |
| 4621 |
let currentContainingBlockComputedStyle = null; |
| 4622 |
const elementIsFixed = getComputedStyle(element).position === "fixed"; |
| 4623 |
let currentNode = elementIsFixed ? getParentNode(element) : element; |
| 4624 |
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { |
| 4625 |
const computedStyle = getComputedStyle(currentNode); |
| 4626 |
const currentNodeIsContaining = isContainingBlock(currentNode); |
| 4627 |
if (!currentNodeIsContaining && computedStyle.position === "fixed") { |
| 4628 |
currentContainingBlockComputedStyle = null; |
| 4629 |
} |
| 4630 |
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); |
| 4631 |
if (shouldDropCurrentNode) { |
| 4632 |
result = result.filter((ancestor) => ancestor !== currentNode); |
| 4633 |
} else { |
| 4634 |
currentContainingBlockComputedStyle = computedStyle; |
| 4635 |
} |
| 4636 |
currentNode = getParentNode(currentNode); |
| 4637 |
} |
| 4638 |
cache.set(element, result); |
| 4639 |
return result; |
| 4640 |
} |
| 4641 |
function getClippingRect(_ref) { |
| 4642 |
let { |
| 4643 |
element, |
| 4644 |
boundary, |
| 4645 |
rootBoundary, |
| 4646 |
strategy |
| 4647 |
} = _ref; |
| 4648 |
const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary); |
| 4649 |
const clippingAncestors = [...elementClippingAncestors, rootBoundary]; |
| 4650 |
const firstClippingAncestor = clippingAncestors[0]; |
| 4651 |
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => { |
| 4652 |
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy); |
| 4653 |
accRect.top = max(rect.top, accRect.top); |
| 4654 |
accRect.right = min(rect.right, accRect.right); |
| 4655 |
accRect.bottom = min(rect.bottom, accRect.bottom); |
| 4656 |
accRect.left = max(rect.left, accRect.left); |
| 4657 |
return accRect; |
| 4658 |
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); |
| 4659 |
return { |
| 4660 |
width: clippingRect.right - clippingRect.left, |
| 4661 |
height: clippingRect.bottom - clippingRect.top, |
| 4662 |
x: clippingRect.left, |
| 4663 |
y: clippingRect.top |
| 4664 |
}; |
| 4665 |
} |
| 4666 |
function getDimensions(element) { |
| 4667 |
const { |
| 4668 |
width, |
| 4669 |
height |
| 4670 |
} = getCssDimensions(element); |
| 4671 |
return { |
| 4672 |
width, |
| 4673 |
height |
| 4674 |
}; |
| 4675 |
} |
| 4676 |
function getRectRelativeToOffsetParent(element, offsetParent, strategy) { |
| 4677 |
const isOffsetParentAnElement = isHTMLElement(offsetParent); |
| 4678 |
const documentElement = getDocumentElement(offsetParent); |
| 4679 |
const isFixed = strategy === "fixed"; |
| 4680 |
const rect = getBoundingClientRect(element, true, isFixed, offsetParent); |
| 4681 |
let scroll = { |
| 4682 |
scrollLeft: 0, |
| 4683 |
scrollTop: 0 |
| 4684 |
}; |
| 4685 |
const offsets = createCoords(0); |
| 4686 |
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { |
| 4687 |
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { |
| 4688 |
scroll = getNodeScroll(offsetParent); |
| 4689 |
} |
| 4690 |
if (isOffsetParentAnElement) { |
| 4691 |
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); |
| 4692 |
offsets.x = offsetRect.x + offsetParent.clientLeft; |
| 4693 |
offsets.y = offsetRect.y + offsetParent.clientTop; |
| 4694 |
} else if (documentElement) { |
| 4695 |
offsets.x = getWindowScrollBarX(documentElement); |
| 4696 |
} |
| 4697 |
} |
| 4698 |
const x = rect.left + scroll.scrollLeft - offsets.x; |
| 4699 |
const y = rect.top + scroll.scrollTop - offsets.y; |
| 4700 |
return { |
| 4701 |
x, |
| 4702 |
y, |
| 4703 |
width: rect.width, |
| 4704 |
height: rect.height |
| 4705 |
}; |
| 4706 |
} |
| 4707 |
function getTrueOffsetParent(element, polyfill) { |
| 4708 |
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") { |
| 4709 |
return null; |
| 4710 |
} |
| 4711 |
if (polyfill) { |
| 4712 |
return polyfill(element); |
| 4713 |
} |
| 4714 |
return element.offsetParent; |
| 4715 |
} |
| 4716 |
function getOffsetParent(element, polyfill) { |
| 4717 |
const window2 = getWindow(element); |
| 4718 |
if (!isHTMLElement(element) || isTopLayer(element)) { |
| 4719 |
return window2; |
| 4720 |
} |
| 4721 |
let offsetParent = getTrueOffsetParent(element, polyfill); |
| 4722 |
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") { |
| 4723 |
offsetParent = getTrueOffsetParent(offsetParent, polyfill); |
| 4724 |
} |
| 4725 |
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) { |
| 4726 |
return window2; |
| 4727 |
} |
| 4728 |
return offsetParent || getContainingBlock(element) || window2; |
| 4729 |
} |
| 4730 |
const getElementRects = function(data) { |
| 4731 |
return __async(this, null, function* () { |
| 4732 |
const getOffsetParentFn = this.getOffsetParent || getOffsetParent; |
| 4733 |
const getDimensionsFn = this.getDimensions; |
| 4734 |
return { |
| 4735 |
reference: getRectRelativeToOffsetParent(data.reference, yield getOffsetParentFn(data.floating), data.strategy), |
| 4736 |
floating: __spreadValues({ |
| 4737 |
x: 0, |
| 4738 |
y: 0 |
| 4739 |
}, yield getDimensionsFn(data.floating)) |
| 4740 |
}; |
| 4741 |
}); |
| 4742 |
}; |
| 4743 |
function isRTL(element) { |
| 4744 |
return getComputedStyle(element).direction === "rtl"; |
| 4745 |
} |
| 4746 |
const platform = { |
| 4747 |
convertOffsetParentRelativeRectToViewportRelativeRect, |
| 4748 |
getDocumentElement, |
| 4749 |
getClippingRect, |
| 4750 |
getOffsetParent, |
| 4751 |
getElementRects, |
| 4752 |
getClientRects, |
| 4753 |
getDimensions, |
| 4754 |
getScale, |
| 4755 |
isElement, |
| 4756 |
isRTL |
| 4757 |
}; |
| 4758 |
function observeMove(element, onMove) { |
| 4759 |
let io = null; |
| 4760 |
let timeoutId; |
| 4761 |
const root = getDocumentElement(element); |
| 4762 |
function cleanup() { |
| 4763 |
var _io; |
| 4764 |
clearTimeout(timeoutId); |
| 4765 |
(_io = io) == null || _io.disconnect(); |
| 4766 |
io = null; |
| 4767 |
} |
| 4768 |
function refresh(skip, threshold) { |
| 4769 |
if (skip === void 0) { |
| 4770 |
skip = false; |
| 4771 |
} |
| 4772 |
if (threshold === void 0) { |
| 4773 |
threshold = 1; |
| 4774 |
} |
| 4775 |
cleanup(); |
| 4776 |
const { |
| 4777 |
left, |
| 4778 |
top, |
| 4779 |
width, |
| 4780 |
height |
| 4781 |
} = element.getBoundingClientRect(); |
| 4782 |
if (!skip) { |
| 4783 |
onMove(); |
| 4784 |
} |
| 4785 |
if (!width || !height) { |
| 4786 |
return; |
| 4787 |
} |
| 4788 |
const insetTop = floor(top); |
| 4789 |
const insetRight = floor(root.clientWidth - (left + width)); |
| 4790 |
const insetBottom = floor(root.clientHeight - (top + height)); |
| 4791 |
const insetLeft = floor(left); |
| 4792 |
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; |
| 4793 |
const options = { |
| 4794 |
rootMargin, |
| 4795 |
threshold: max(0, min(1, threshold)) || 1 |
| 4796 |
}; |
| 4797 |
let isFirstUpdate = true; |
| 4798 |
function handleObserve(entries) { |
| 4799 |
const ratio = entries[0].intersectionRatio; |
| 4800 |
if (ratio !== threshold) { |
| 4801 |
if (!isFirstUpdate) { |
| 4802 |
return refresh(); |
| 4803 |
} |
| 4804 |
if (!ratio) { |
| 4805 |
timeoutId = setTimeout(() => { |
| 4806 |
refresh(false, 1e-7); |
| 4807 |
}, 100); |
| 4808 |
} else { |
| 4809 |
refresh(false, ratio); |
| 4810 |
} |
| 4811 |
} |
| 4812 |
isFirstUpdate = false; |
| 4813 |
} |
| 4814 |
try { |
| 4815 |
io = new IntersectionObserver(handleObserve, __spreadProps(__spreadValues({}, options), { |
| 4816 |
|
| 4817 |
root: root.ownerDocument |
| 4818 |
})); |
| 4819 |
} catch (e) { |
| 4820 |
io = new IntersectionObserver(handleObserve, options); |
| 4821 |
} |
| 4822 |
io.observe(element); |
| 4823 |
} |
| 4824 |
refresh(true); |
| 4825 |
return cleanup; |
| 4826 |
} |
| 4827 |
function autoUpdate(reference, floating, update, options) { |
| 4828 |
if (options === void 0) { |
| 4829 |
options = {}; |
| 4830 |
} |
| 4831 |
const { |
| 4832 |
ancestorScroll = true, |
| 4833 |
ancestorResize = true, |
| 4834 |
elementResize = typeof ResizeObserver === "function", |
| 4835 |
layoutShift = typeof IntersectionObserver === "function", |
| 4836 |
animationFrame = false |
| 4837 |
} = options; |
| 4838 |
const referenceEl = unwrapElement$2(reference); |
| 4839 |
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : []; |
| 4840 |
ancestors.forEach((ancestor) => { |
| 4841 |
ancestorScroll && ancestor.addEventListener("scroll", update, { |
| 4842 |
passive: true |
| 4843 |
}); |
| 4844 |
ancestorResize && ancestor.addEventListener("resize", update); |
| 4845 |
}); |
| 4846 |
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null; |
| 4847 |
let reobserveFrame = -1; |
| 4848 |
let resizeObserver = null; |
| 4849 |
if (elementResize) { |
| 4850 |
resizeObserver = new ResizeObserver((_ref) => { |
| 4851 |
let [firstEntry] = _ref; |
| 4852 |
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) { |
| 4853 |
resizeObserver.unobserve(floating); |
| 4854 |
cancelAnimationFrame(reobserveFrame); |
| 4855 |
reobserveFrame = requestAnimationFrame(() => { |
| 4856 |
var _resizeObserver; |
| 4857 |
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating); |
| 4858 |
}); |
| 4859 |
} |
| 4860 |
update(); |
| 4861 |
}); |
| 4862 |
if (referenceEl && !animationFrame) { |
| 4863 |
resizeObserver.observe(referenceEl); |
| 4864 |
} |
| 4865 |
resizeObserver.observe(floating); |
| 4866 |
} |
| 4867 |
let frameId; |
| 4868 |
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null; |
| 4869 |
if (animationFrame) { |
| 4870 |
frameLoop(); |
| 4871 |
} |
| 4872 |
function frameLoop() { |
| 4873 |
const nextRefRect = getBoundingClientRect(reference); |
| 4874 |
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) { |
| 4875 |
update(); |
| 4876 |
} |
| 4877 |
prevRefRect = nextRefRect; |
| 4878 |
frameId = requestAnimationFrame(frameLoop); |
| 4879 |
} |
| 4880 |
update(); |
| 4881 |
return () => { |
| 4882 |
var _resizeObserver2; |
| 4883 |
ancestors.forEach((ancestor) => { |
| 4884 |
ancestorScroll && ancestor.removeEventListener("scroll", update); |
| 4885 |
ancestorResize && ancestor.removeEventListener("resize", update); |
| 4886 |
}); |
| 4887 |
cleanupIo == null || cleanupIo(); |
| 4888 |
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect(); |
| 4889 |
resizeObserver = null; |
| 4890 |
if (animationFrame) { |
| 4891 |
cancelAnimationFrame(frameId); |
| 4892 |
} |
| 4893 |
}; |
| 4894 |
} |
| 4895 |
const shift = shift$1; |
| 4896 |
const flip = flip$1; |
| 4897 |
const size = size$1; |
| 4898 |
const hide = hide$1; |
| 4899 |
const computePosition = (reference, floating, options) => { |
| 4900 |
const cache = new Map(); |
| 4901 |
const mergedOptions = __spreadValues({ |
| 4902 |
platform |
| 4903 |
}, options); |
| 4904 |
const platformWithCache = __spreadProps(__spreadValues({}, mergedOptions.platform), { |
| 4905 |
_c: cache |
| 4906 |
}); |
| 4907 |
return computePosition$1(reference, floating, __spreadProps(__spreadValues({}, mergedOptions), { |
| 4908 |
platform: platformWithCache |
| 4909 |
})); |
| 4910 |
}; |
| 4911 |
function isComponentPublicInstance(target) { |
| 4912 |
return target != null && typeof target === "object" && "$el" in target; |
| 4913 |
} |
| 4914 |
function unwrapElement$1(target) { |
| 4915 |
if (isComponentPublicInstance(target)) { |
| 4916 |
const element = target.$el; |
| 4917 |
return isNode(element) && getNodeName(element) === "#comment" ? null : element; |
| 4918 |
} |
| 4919 |
return target; |
| 4920 |
} |
| 4921 |
function getDPR(element) { |
| 4922 |
if (typeof window === "undefined") { |
| 4923 |
return 1; |
| 4924 |
} |
| 4925 |
const win = element.ownerDocument.defaultView || window; |
| 4926 |
return win.devicePixelRatio || 1; |
| 4927 |
} |
| 4928 |
function roundByDPR(element, value) { |
| 4929 |
const dpr = getDPR(element); |
| 4930 |
return Math.round(value * dpr) / dpr; |
| 4931 |
} |
| 4932 |
function useFloating(reference, floating, options) { |
| 4933 |
if (options === void 0) { |
| 4934 |
options = {}; |
| 4935 |
} |
| 4936 |
const whileElementsMountedOption = options.whileElementsMounted; |
| 4937 |
const openOption = computed(() => { |
| 4938 |
var _unref; |
| 4939 |
return (_unref = unref(options.open)) != null ? _unref : true; |
| 4940 |
}); |
| 4941 |
const middlewareOption = computed(() => unref(options.middleware)); |
| 4942 |
const placementOption = computed(() => { |
| 4943 |
var _unref2; |
| 4944 |
return (_unref2 = unref(options.placement)) != null ? _unref2 : "bottom"; |
| 4945 |
}); |
| 4946 |
const strategyOption = computed(() => { |
| 4947 |
var _unref3; |
| 4948 |
return (_unref3 = unref(options.strategy)) != null ? _unref3 : "absolute"; |
| 4949 |
}); |
| 4950 |
const transformOption = computed(() => { |
| 4951 |
var _unref4; |
| 4952 |
return (_unref4 = unref(options.transform)) != null ? _unref4 : true; |
| 4953 |
}); |
| 4954 |
const referenceElement = computed(() => unwrapElement$1(reference.value)); |
| 4955 |
const floatingElement = computed(() => unwrapElement$1(floating.value)); |
| 4956 |
const x = ref(0); |
| 4957 |
const y = ref(0); |
| 4958 |
const strategy = ref(strategyOption.value); |
| 4959 |
const placement = ref(placementOption.value); |
| 4960 |
const middlewareData = shallowRef({}); |
| 4961 |
const isPositioned = ref(false); |
| 4962 |
const floatingStyles = computed(() => { |
| 4963 |
const initialStyles = { |
| 4964 |
position: strategy.value, |
| 4965 |
left: "0", |
| 4966 |
top: "0" |
| 4967 |
}; |
| 4968 |
if (!floatingElement.value) { |
| 4969 |
return initialStyles; |
| 4970 |
} |
| 4971 |
const xVal = roundByDPR(floatingElement.value, x.value); |
| 4972 |
const yVal = roundByDPR(floatingElement.value, y.value); |
| 4973 |
if (transformOption.value) { |
| 4974 |
return __spreadValues(__spreadProps(__spreadValues({}, initialStyles), { |
| 4975 |
transform: "translate(" + xVal + "px, " + yVal + "px)" |
| 4976 |
}), getDPR(floatingElement.value) >= 1.5 && { |
| 4977 |
willChange: "transform" |
| 4978 |
}); |
| 4979 |
} |
| 4980 |
return { |
| 4981 |
position: strategy.value, |
| 4982 |
left: xVal + "px", |
| 4983 |
top: yVal + "px" |
| 4984 |
}; |
| 4985 |
}); |
| 4986 |
let whileElementsMountedCleanup; |
| 4987 |
function update() { |
| 4988 |
if (referenceElement.value == null || floatingElement.value == null) { |
| 4989 |
return; |
| 4990 |
} |
| 4991 |
computePosition(referenceElement.value, floatingElement.value, { |
| 4992 |
middleware: middlewareOption.value, |
| 4993 |
placement: placementOption.value, |
| 4994 |
strategy: strategyOption.value |
| 4995 |
}).then((position) => { |
| 4996 |
x.value = position.x; |
| 4997 |
y.value = position.y; |
| 4998 |
strategy.value = position.strategy; |
| 4999 |
placement.value = position.placement; |
| 5000 |
middlewareData.value = position.middlewareData; |
| 5001 |
isPositioned.value = true; |
| 5002 |
}); |
| 5003 |
} |
| 5004 |
function cleanup() { |
| 5005 |
if (typeof whileElementsMountedCleanup === "function") { |
| 5006 |
whileElementsMountedCleanup(); |
| 5007 |
whileElementsMountedCleanup = void 0; |
| 5008 |
} |
| 5009 |
} |
| 5010 |
function attach() { |
| 5011 |
cleanup(); |
| 5012 |
if (whileElementsMountedOption === void 0) { |
| 5013 |
update(); |
| 5014 |
return; |
| 5015 |
} |
| 5016 |
if (referenceElement.value != null && floatingElement.value != null) { |
| 5017 |
whileElementsMountedCleanup = whileElementsMountedOption(referenceElement.value, floatingElement.value, update); |
| 5018 |
return; |
| 5019 |
} |
| 5020 |
} |
| 5021 |
function reset() { |
| 5022 |
if (!openOption.value) { |
| 5023 |
isPositioned.value = false; |
| 5024 |
} |
| 5025 |
} |
| 5026 |
watch([middlewareOption, placementOption, strategyOption], update, { |
| 5027 |
flush: "sync" |
| 5028 |
}); |
| 5029 |
watch([referenceElement, floatingElement], attach, { |
| 5030 |
flush: "sync" |
| 5031 |
}); |
| 5032 |
watch(openOption, reset, { |
| 5033 |
flush: "sync" |
| 5034 |
}); |
| 5035 |
if (getCurrentScope()) { |
| 5036 |
onScopeDispose(cleanup); |
| 5037 |
} |
| 5038 |
return { |
| 5039 |
x: shallowReadonly(x), |
| 5040 |
y: shallowReadonly(y), |
| 5041 |
strategy: shallowReadonly(strategy), |
| 5042 |
placement: shallowReadonly(placement), |
| 5043 |
middlewareData: shallowReadonly(middlewareData), |
| 5044 |
isPositioned: shallowReadonly(isPositioned), |
| 5045 |
floatingStyles, |
| 5046 |
update |
| 5047 |
}; |
| 5048 |
} |
| 5049 |
function unwrapElement(element) { |
| 5050 |
return element && "$el" in element ? element.$el : element; |
| 5051 |
} |
| 5052 |
const clipPadding = 16; |
| 5053 |
const minClipHeight = 128; |
| 5054 |
function useFloatingMenu(referenceElement, menu, opt) { |
| 5055 |
var _a; |
| 5056 |
const menuIsExpanded = () => { |
| 5057 |
var _a2; |
| 5058 |
return (_a2 = menu.value) == null ? void 0 : _a2.isExpanded(); |
| 5059 |
}; |
| 5060 |
const middleware = [ |
| 5061 |
offset(opt == null ? void 0 : opt.offset), |
| 5062 |
size({ |
| 5063 |
|
| 5064 |
|
| 5065 |
|
| 5066 |
padding: clipPadding, |
| 5067 |
apply({ rects, elements, availableHeight, availableWidth }) { |
| 5068 |
Object.assign(elements.floating.style, { |
| 5069 |
|
| 5070 |
|
| 5071 |
|
| 5072 |
|
| 5073 |
width: "".concat((opt == null ? void 0 : opt.useAvailableWidth) ? availableWidth : rects.reference.width, "px"), |
| 5074 |
|
| 5075 |
|
| 5076 |
|
| 5077 |
|
| 5078 |
maxHeight: "".concat(Math.max(minClipHeight, availableHeight), "px") |
| 5079 |
}); |
| 5080 |
} |
| 5081 |
}), |
| 5082 |
|
| 5083 |
|
| 5084 |
|
| 5085 |
flip({ |
| 5086 |
|
| 5087 |
|
| 5088 |
|
| 5089 |
padding: clipPadding |
| 5090 |
}), |
| 5091 |
|
| 5092 |
|
| 5093 |
|
| 5094 |
hide({ |
| 5095 |
strategy: "escaped" |
| 5096 |
}), |
| 5097 |
|
| 5098 |
|
| 5099 |
hide() |
| 5100 |
]; |
| 5101 |
const { floatingStyles, placement, middlewareData, update } = useFloating( |
| 5102 |
referenceElement, |
| 5103 |
menu, |
| 5104 |
{ |
| 5105 |
middleware, |
| 5106 |
placement: (_a = opt == null ? void 0 : opt.placement) != null ? _a : "bottom" |
| 5107 |
} |
| 5108 |
); |
| 5109 |
const menuVisibility = computed(() => { |
| 5110 |
var _a2, _b; |
| 5111 |
const isHidden = !menuIsExpanded() || !!((_a2 = middlewareData.value.hide) == null ? void 0 : _a2.escaped) || ((_b = middlewareData.value.hide) == null ? void 0 : _b.referenceHidden); |
| 5112 |
return isHidden ? "hidden" : "visible"; |
| 5113 |
}); |
| 5114 |
watch( |
| 5115 |
[floatingStyles, menuVisibility, placement], |
| 5116 |
([newStyles, newVisibility, newPlacement]) => { |
| 5117 |
var _a2, _b, _c, _d, _e; |
| 5118 |
Object.assign((_b = (_a2 = menu.value) == null ? void 0 : _a2.$el.style) != null ? _b : {}, { |
| 5119 |
visibility: newVisibility, |
| 5120 |
position: newStyles.position, |
| 5121 |
top: "".concat(newStyles.top, "px"), |
| 5122 |
|
| 5123 |
|
| 5124 |
|
| 5125 |
right: "unset", |
| 5126 |
|
| 5127 |
|
| 5128 |
|
| 5129 |
left: "".concat(newStyles.left, "px"), |
| 5130 |
|
| 5131 |
transform: (_c = newStyles.transform) != null ? _c : "none", |
| 5132 |
|
| 5133 |
|
| 5134 |
borderTopLeftRadius: newPlacement === "bottom" && newVisibility === "visible" ? "0" : "", |
| 5135 |
borderTopRightRadius: newPlacement === "bottom" && newVisibility === "visible" ? "0" : "", |
| 5136 |
borderBottomLeftRadius: newPlacement === "top" && newVisibility === "visible" ? "0" : "", |
| 5137 |
borderBottomRightRadius: newPlacement === "top" && newVisibility === "visible" ? "0" : "" |
| 5138 |
}); |
| 5139 |
Object.assign((_e = (_d = unwrapElement(referenceElement.value)) == null ? void 0 : _d.style) != null ? _e : {}, { |
| 5140 |
|
| 5141 |
|
| 5142 |
borderTopLeftRadius: newPlacement === "top" && newVisibility === "visible" ? "0" : "", |
| 5143 |
borderTopRightRadius: newPlacement === "top" && newVisibility === "visible" ? "0" : "", |
| 5144 |
borderBottomLeftRadius: newPlacement === "bottom" && newVisibility === "visible" ? "0" : "", |
| 5145 |
borderBottomRightRadius: newPlacement === "bottom" && newVisibility === "visible" ? "0" : "" |
| 5146 |
}); |
| 5147 |
} |
| 5148 |
); |
| 5149 |
let cleanupAutoUpdate = null; |
| 5150 |
watch(menuIsExpanded, (newExpanded) => { |
| 5151 |
var _a2; |
| 5152 |
if (newExpanded) { |
| 5153 |
cleanupAutoUpdate = autoUpdate( |
| 5154 |
|
| 5155 |
referenceElement.value && "$el" in referenceElement.value ? referenceElement.value.$el : referenceElement, |
| 5156 |
|
| 5157 |
(_a2 = menu.value) == null ? void 0 : _a2.$el, |
| 5158 |
update |
| 5159 |
); |
| 5160 |
} else { |
| 5161 |
if (cleanupAutoUpdate) { |
| 5162 |
cleanupAutoUpdate(); |
| 5163 |
cleanupAutoUpdate = null; |
| 5164 |
} |
| 5165 |
} |
| 5166 |
}); |
| 5167 |
} |
| 5168 |
const statusValidator$7 = makeStringTypeValidator(ValidationStatusTypes); |
| 5169 |
const _sfc_main$j = defineComponent({ |
| 5170 |
name: "CdxCombobox", |
| 5171 |
components: { |
| 5172 |
CdxButton, |
| 5173 |
CdxIcon, |
| 5174 |
CdxMenu, |
| 5175 |
CdxTextInput |
| 5176 |
}, |
| 5177 |
|
| 5178 |
|
| 5179 |
|
| 5180 |
|
| 5181 |
inheritAttrs: false, |
| 5182 |
props: { |
| 5183 |
|
| 5184 |
|
| 5185 |
|
| 5186 |
menuItems: { |
| 5187 |
type: Array, |
| 5188 |
required: true |
| 5189 |
}, |
| 5190 |
|
| 5191 |
|
| 5192 |
|
| 5193 |
|
| 5194 |
|
| 5195 |
selected: { |
| 5196 |
type: [String, Number], |
| 5197 |
required: true |
| 5198 |
}, |
| 5199 |
|
| 5200 |
|
| 5201 |
|
| 5202 |
disabled: { |
| 5203 |
type: Boolean, |
| 5204 |
default: false |
| 5205 |
}, |
| 5206 |
|
| 5207 |
|
| 5208 |
|
| 5209 |
|
| 5210 |
|
| 5211 |
|
| 5212 |
menuConfig: { |
| 5213 |
type: Object, |
| 5214 |
default: () => { |
| 5215 |
return {}; |
| 5216 |
} |
| 5217 |
}, |
| 5218 |
|
| 5219 |
|
| 5220 |
|
| 5221 |
status: { |
| 5222 |
type: String, |
| 5223 |
default: "default", |
| 5224 |
validator: statusValidator$7 |
| 5225 |
} |
| 5226 |
}, |
| 5227 |
emits: [ |
| 5228 |
|
| 5229 |
|
| 5230 |
|
| 5231 |
|
| 5232 |
|
| 5233 |
"update:selected", |
| 5234 |
|
| 5235 |
|
| 5236 |
|
| 5237 |
|
| 5238 |
|
| 5239 |
|
| 5240 |
"load-more", |
| 5241 |
|
| 5242 |
|
| 5243 |
|
| 5244 |
|
| 5245 |
|
| 5246 |
"input", |
| 5247 |
|
| 5248 |
|
| 5249 |
|
| 5250 |
|
| 5251 |
|
| 5252 |
"change", |
| 5253 |
|
| 5254 |
|
| 5255 |
|
| 5256 |
|
| 5257 |
|
| 5258 |
"focus", |
| 5259 |
|
| 5260 |
|
| 5261 |
|
| 5262 |
|
| 5263 |
|
| 5264 |
"blur" |
| 5265 |
], |
| 5266 |
setup(props, { emit, attrs, slots }) { |
| 5267 |
const input = ref(); |
| 5268 |
const inputWrapper = ref(); |
| 5269 |
const menu = ref(); |
| 5270 |
const menuId = useGeneratedId("combobox"); |
| 5271 |
const selectedProp = toRef(props, "selected"); |
| 5272 |
const modelWrapper = useModelWrapper(selectedProp, emit, "update:selected"); |
| 5273 |
const expanded = ref(false); |
| 5274 |
const expanderClicked = ref(false); |
| 5275 |
const highlightedId = computed(() => { |
| 5276 |
var _a, _b; |
| 5277 |
return (_b = (_a = menu.value) == null ? void 0 : _a.getHighlightedMenuItem()) == null ? void 0 : _b.id; |
| 5278 |
}); |
| 5279 |
const { |
| 5280 |
computedDisabled, |
| 5281 |
computedStatus |
| 5282 |
} = useFieldData( |
| 5283 |
toRef(props, "disabled"), |
| 5284 |
toRef(props, "status") |
| 5285 |
); |
| 5286 |
const internalClasses = computed(() => { |
| 5287 |
return { |
| 5288 |
"cdx-combobox--expanded": expanded.value, |
| 5289 |
"cdx-combobox--disabled": computedDisabled.value |
| 5290 |
}; |
| 5291 |
}); |
| 5292 |
const { |
| 5293 |
rootClasses, |
| 5294 |
rootStyle, |
| 5295 |
otherAttrs |
| 5296 |
} = useSplitAttributes(attrs, internalClasses); |
| 5297 |
function onInputFocus(event) { |
| 5298 |
if (expanderClicked.value && expanded.value) { |
| 5299 |
expanded.value = false; |
| 5300 |
} else if (props.menuItems.length > 0 || slots["no-results"]) { |
| 5301 |
expanded.value = true; |
| 5302 |
} |
| 5303 |
emit("focus", event); |
| 5304 |
} |
| 5305 |
function onInputBlur(event) { |
| 5306 |
expanded.value = expanderClicked.value && expanded.value; |
| 5307 |
emit("blur", event); |
| 5308 |
} |
| 5309 |
function onButtonMousedown() { |
| 5310 |
if (computedDisabled.value) { |
| 5311 |
return; |
| 5312 |
} |
| 5313 |
expanderClicked.value = true; |
| 5314 |
} |
| 5315 |
function onButtonClick() { |
| 5316 |
var _a; |
| 5317 |
if (computedDisabled.value) { |
| 5318 |
return; |
| 5319 |
} |
| 5320 |
(_a = input.value) == null ? void 0 : _a.focus(); |
| 5321 |
} |
| 5322 |
function onKeydown(e) { |
| 5323 |
if (!menu.value || computedDisabled.value || props.menuItems.length === 0 || e.key === " ") { |
| 5324 |
return; |
| 5325 |
} |
| 5326 |
menu.value.delegateKeyNavigation(e); |
| 5327 |
} |
| 5328 |
useFloatingMenu(input, menu); |
| 5329 |
watch(expanded, () => { |
| 5330 |
expanderClicked.value = false; |
| 5331 |
}); |
| 5332 |
return { |
| 5333 |
input, |
| 5334 |
inputWrapper, |
| 5335 |
menu, |
| 5336 |
menuId, |
| 5337 |
modelWrapper, |
| 5338 |
expanded, |
| 5339 |
highlightedId, |
| 5340 |
computedDisabled, |
| 5341 |
computedStatus, |
| 5342 |
onInputFocus, |
| 5343 |
onInputBlur, |
| 5344 |
onKeydown, |
| 5345 |
onButtonClick, |
| 5346 |
onButtonMousedown, |
| 5347 |
cdxIconExpand: m4, |
| 5348 |
rootClasses, |
| 5349 |
rootStyle, |
| 5350 |
otherAttrs |
| 5351 |
}; |
| 5352 |
} |
| 5353 |
}); |
| 5354 |
const _hoisted_1$h = { |
| 5355 |
ref: "inputWrapper", |
| 5356 |
class: "cdx-combobox__input-wrapper" |
| 5357 |
}; |
| 5358 |
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) { |
| 5359 |
const _component_cdx_text_input = resolveComponent("cdx-text-input"); |
| 5360 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 5361 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 5362 |
const _component_cdx_menu = resolveComponent("cdx-menu"); |
| 5363 |
return openBlock(), createElementBlock( |
| 5364 |
"div", |
| 5365 |
{ |
| 5366 |
class: normalizeClass(["cdx-combobox", _ctx.rootClasses]), |
| 5367 |
style: normalizeStyle(_ctx.rootStyle) |
| 5368 |
}, |
| 5369 |
[ |
| 5370 |
createElementVNode( |
| 5371 |
"div", |
| 5372 |
_hoisted_1$h, |
| 5373 |
[ |
| 5374 |
createVNode(_component_cdx_text_input, mergeProps({ |
| 5375 |
ref: "input", |
| 5376 |
modelValue: _ctx.modelWrapper, |
| 5377 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.modelWrapper = $event) |
| 5378 |
}, _ctx.otherAttrs, { |
| 5379 |
class: "cdx-combobox__input", |
| 5380 |
"aria-activedescendant": _ctx.highlightedId, |
| 5381 |
"aria-expanded": _ctx.expanded, |
| 5382 |
"aria-controls": _ctx.menuId, |
| 5383 |
disabled: _ctx.computedDisabled, |
| 5384 |
status: _ctx.computedStatus, |
| 5385 |
autocomplete: "off", |
| 5386 |
role: "combobox", |
| 5387 |
onKeydown: _ctx.onKeydown, |
| 5388 |
onInput: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("input", $event)), |
| 5389 |
onChange: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("change", $event)), |
| 5390 |
onFocus: _ctx.onInputFocus, |
| 5391 |
onBlur: _ctx.onInputBlur |
| 5392 |
}), null, 16, ["modelValue", "aria-activedescendant", "aria-expanded", "aria-controls", "disabled", "status", "onKeydown", "onFocus", "onBlur"]), |
| 5393 |
createVNode(_component_cdx_button, { |
| 5394 |
class: "cdx-combobox__expand-button", |
| 5395 |
"aria-hidden": "true", |
| 5396 |
disabled: _ctx.computedDisabled, |
| 5397 |
tabindex: "-1", |
| 5398 |
type: "button", |
| 5399 |
onMousedown: _ctx.onButtonMousedown, |
| 5400 |
onClick: _ctx.onButtonClick |
| 5401 |
}, { |
| 5402 |
default: withCtx(() => [ |
| 5403 |
createVNode(_component_cdx_icon, { |
| 5404 |
class: "cdx-combobox__expand-icon", |
| 5405 |
icon: _ctx.cdxIconExpand |
| 5406 |
}, null, 8, ["icon"]) |
| 5407 |
]), |
| 5408 |
_: 1 |
| 5409 |
|
| 5410 |
}, 8, ["disabled", "onMousedown", "onClick"]) |
| 5411 |
], |
| 5412 |
512 |
| 5413 |
|
| 5414 |
), |
| 5415 |
createVNode(_component_cdx_menu, mergeProps({ |
| 5416 |
id: _ctx.menuId, |
| 5417 |
ref: "menu", |
| 5418 |
selected: _ctx.modelWrapper, |
| 5419 |
"onUpdate:selected": _cache[3] || (_cache[3] = ($event) => _ctx.modelWrapper = $event), |
| 5420 |
expanded: _ctx.expanded, |
| 5421 |
"onUpdate:expanded": _cache[4] || (_cache[4] = ($event) => _ctx.expanded = $event), |
| 5422 |
"menu-items": _ctx.menuItems |
| 5423 |
}, _ctx.menuConfig, { |
| 5424 |
onLoadMore: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("load-more")) |
| 5425 |
}), { |
| 5426 |
default: withCtx(({ menuItem }) => [ |
| 5427 |
renderSlot(_ctx.$slots, "menu-item", { menuItem }) |
| 5428 |
]), |
| 5429 |
"no-results": withCtx(() => [ |
| 5430 |
renderSlot(_ctx.$slots, "no-results") |
| 5431 |
]), |
| 5432 |
_: 3 |
| 5433 |
|
| 5434 |
}, 16, ["id", "selected", "expanded", "menu-items"]) |
| 5435 |
], |
| 5436 |
6 |
| 5437 |
|
| 5438 |
); |
| 5439 |
} |
| 5440 |
const Combobox = _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]); |
| 5441 |
function useResizeObserver(templateRef) { |
| 5442 |
const currentDimensions = ref( |
| 5443 |
{ width: void 0, height: void 0 } |
| 5444 |
); |
| 5445 |
if (typeof window !== "object" || !("ResizeObserver" in window) || !("ResizeObserverEntry" in window)) { |
| 5446 |
return currentDimensions; |
| 5447 |
} |
| 5448 |
const observer = new window.ResizeObserver( |
| 5449 |
(entries) => { |
| 5450 |
const entry = entries[0]; |
| 5451 |
if (entry) { |
| 5452 |
currentDimensions.value = { |
| 5453 |
width: entry.borderBoxSize[0].inlineSize, |
| 5454 |
height: entry.borderBoxSize[0].blockSize |
| 5455 |
}; |
| 5456 |
} |
| 5457 |
} |
| 5458 |
); |
| 5459 |
let mounted = false; |
| 5460 |
onMounted(() => { |
| 5461 |
mounted = true; |
| 5462 |
if (templateRef.value) { |
| 5463 |
observer.observe(templateRef.value); |
| 5464 |
} |
| 5465 |
}); |
| 5466 |
onUnmounted(() => { |
| 5467 |
mounted = false; |
| 5468 |
observer.disconnect(); |
| 5469 |
}); |
| 5470 |
watch(templateRef, (newElement) => { |
| 5471 |
if (!mounted) { |
| 5472 |
return; |
| 5473 |
} |
| 5474 |
observer.disconnect(); |
| 5475 |
currentDimensions.value = { |
| 5476 |
width: void 0, |
| 5477 |
height: void 0 |
| 5478 |
}; |
| 5479 |
if (newElement) { |
| 5480 |
observer.observe(newElement); |
| 5481 |
} |
| 5482 |
}); |
| 5483 |
return currentDimensions; |
| 5484 |
} |
| 5485 |
const _sfc_main$i = defineComponent({ |
| 5486 |
name: "CdxDialog", |
| 5487 |
components: { |
| 5488 |
CdxButton, |
| 5489 |
CdxIcon |
| 5490 |
}, |
| 5491 |
inheritAttrs: false, |
| 5492 |
props: { |
| 5493 |
|
| 5494 |
|
| 5495 |
|
| 5496 |
|
| 5497 |
open: { |
| 5498 |
type: Boolean, |
| 5499 |
default: false |
| 5500 |
}, |
| 5501 |
|
| 5502 |
|
| 5503 |
|
| 5504 |
|
| 5505 |
title: { |
| 5506 |
type: String, |
| 5507 |
required: true |
| 5508 |
}, |
| 5509 |
|
| 5510 |
|
| 5511 |
|
| 5512 |
subtitle: { |
| 5513 |
type: String, |
| 5514 |
required: false, |
| 5515 |
default: null |
| 5516 |
}, |
| 5517 |
|
| 5518 |
|
| 5519 |
|
| 5520 |
hideTitle: { |
| 5521 |
type: Boolean, |
| 5522 |
default: false |
| 5523 |
}, |
| 5524 |
|
| 5525 |
|
| 5526 |
|
| 5527 |
useCloseButton: { |
| 5528 |
type: Boolean, |
| 5529 |
default: false |
| 5530 |
}, |
| 5531 |
|
| 5532 |
|
| 5533 |
|
| 5534 |
|
| 5535 |
|
| 5536 |
|
| 5537 |
closeButtonLabel: { |
| 5538 |
type: String, |
| 5539 |
default: "" |
| 5540 |
}, |
| 5541 |
|
| 5542 |
|
| 5543 |
|
| 5544 |
|
| 5545 |
primaryAction: { |
| 5546 |
type: Object, |
| 5547 |
default: null |
| 5548 |
}, |
| 5549 |
|
| 5550 |
|
| 5551 |
|
| 5552 |
defaultAction: { |
| 5553 |
type: Object, |
| 5554 |
default: null |
| 5555 |
}, |
| 5556 |
|
| 5557 |
|
| 5558 |
|
| 5559 |
stackedActions: { |
| 5560 |
type: Boolean, |
| 5561 |
default: false |
| 5562 |
}, |
| 5563 |
|
| 5564 |
|
| 5565 |
|
| 5566 |
|
| 5567 |
|
| 5568 |
|
| 5569 |
|
| 5570 |
|
| 5571 |
|
| 5572 |
|
| 5573 |
|
| 5574 |
|
| 5575 |
target: { |
| 5576 |
type: String, |
| 5577 |
default: null |
| 5578 |
}, |
| 5579 |
|
| 5580 |
|
| 5581 |
|
| 5582 |
|
| 5583 |
|
| 5584 |
renderInPlace: { |
| 5585 |
type: Boolean, |
| 5586 |
default: false |
| 5587 |
} |
| 5588 |
}, |
| 5589 |
emits: [ |
| 5590 |
|
| 5591 |
|
| 5592 |
|
| 5593 |
|
| 5594 |
|
| 5595 |
"update:open", |
| 5596 |
|
| 5597 |
|
| 5598 |
|
| 5599 |
"primary", |
| 5600 |
|
| 5601 |
|
| 5602 |
|
| 5603 |
"default" |
| 5604 |
], |
| 5605 |
setup(props, { emit }) { |
| 5606 |
const labelId = useGeneratedId("dialog-label"); |
| 5607 |
const backdrop = ref(); |
| 5608 |
const dialogElement = ref(); |
| 5609 |
const dialogBody = ref(); |
| 5610 |
const focusHolder = ref(); |
| 5611 |
const focusTrapStart = ref(); |
| 5612 |
const focusTrapEnd = ref(); |
| 5613 |
let previouslyFocused = null; |
| 5614 |
const useCloseButtonOrLabel = computed( |
| 5615 |
() => props.useCloseButton || props.closeButtonLabel.length > 0 |
| 5616 |
); |
| 5617 |
const translatedCloseButtonLabel = useI18nWithOverride( |
| 5618 |
toRef(props, "closeButtonLabel"), |
| 5619 |
"cdx-dialog-close-button-label", |
| 5620 |
"Close" |
| 5621 |
); |
| 5622 |
const showHeader = computed(() => !props.hideTitle || useCloseButtonOrLabel.value); |
| 5623 |
const showFooterActions = computed(() => !!props.primaryAction || !!props.defaultAction); |
| 5624 |
const bodyDimensions = useResizeObserver(dialogBody); |
| 5625 |
const currentBodyHeight = computed(() => { |
| 5626 |
var _a; |
| 5627 |
return (_a = bodyDimensions.value.height) != null ? _a : 0; |
| 5628 |
}); |
| 5629 |
const showDividers = ref(false); |
| 5630 |
const rootClasses = computed(() => ({ |
| 5631 |
"cdx-dialog--vertical-actions": props.stackedActions, |
| 5632 |
"cdx-dialog--horizontal-actions": !props.stackedActions, |
| 5633 |
"cdx-dialog--dividers": showDividers.value |
| 5634 |
})); |
| 5635 |
const providedTarget = inject("CdxTeleportTarget", void 0); |
| 5636 |
const computedTarget = computed(() => { |
| 5637 |
var _a, _b; |
| 5638 |
return (_b = (_a = props.target) != null ? _a : providedTarget) != null ? _b : "body"; |
| 5639 |
}); |
| 5640 |
const scrollWidth = ref(0); |
| 5641 |
function close() { |
| 5642 |
emit("update:open", false); |
| 5643 |
} |
| 5644 |
function focusFirst() { |
| 5645 |
focusFirstFocusableElement(dialogElement.value); |
| 5646 |
} |
| 5647 |
function focusLast() { |
| 5648 |
focusFirstFocusableElement(dialogElement.value, true); |
| 5649 |
} |
| 5650 |
function focusFirstFocusableElement(container, backwards = false) { |
| 5651 |
let candidates = Array.from( |
| 5652 |
container.querySelectorAll('\n input, select, textarea, button, object, a, area,\n [contenteditable], [tabindex]:not([tabindex^="-"])\n ') |
| 5653 |
); |
| 5654 |
if (backwards) { |
| 5655 |
candidates = candidates.reverse(); |
| 5656 |
} |
| 5657 |
for (const candidate of candidates) { |
| 5658 |
candidate.focus(); |
| 5659 |
if (document.activeElement === candidate) { |
| 5660 |
return true; |
| 5661 |
} |
| 5662 |
} |
| 5663 |
return false; |
| 5664 |
} |
| 5665 |
let ariaHiddenElements = []; |
| 5666 |
let inertElements = []; |
| 5667 |
function setAriaHiddenAndInert() { |
| 5668 |
let element = backdrop.value; |
| 5669 |
while (element.parentElement && element.nodeName !== "BODY") { |
| 5670 |
for (const sibling of Array.from(element.parentElement.children)) { |
| 5671 |
if (sibling === element || sibling.nodeName === "SCRIPT") { |
| 5672 |
continue; |
| 5673 |
} |
| 5674 |
if (!sibling.hasAttribute("aria-hidden")) { |
| 5675 |
sibling.setAttribute("aria-hidden", "true"); |
| 5676 |
ariaHiddenElements.push(sibling); |
| 5677 |
} |
| 5678 |
if (!sibling.hasAttribute("inert")) { |
| 5679 |
sibling.setAttribute("inert", ""); |
| 5680 |
inertElements.push(sibling); |
| 5681 |
} |
| 5682 |
} |
| 5683 |
element = element.parentElement; |
| 5684 |
} |
| 5685 |
} |
| 5686 |
function unsetAriaHiddenAndInert() { |
| 5687 |
for (const element of ariaHiddenElements) { |
| 5688 |
element.removeAttribute("aria-hidden"); |
| 5689 |
} |
| 5690 |
for (const element of inertElements) { |
| 5691 |
element.removeAttribute("inert"); |
| 5692 |
} |
| 5693 |
ariaHiddenElements = []; |
| 5694 |
inertElements = []; |
| 5695 |
} |
| 5696 |
function onDialogOpen() { |
| 5697 |
return __async(this, null, function* () { |
| 5698 |
var _a; |
| 5699 |
yield nextTick(); |
| 5700 |
scrollWidth.value = window.innerWidth - document.documentElement.clientWidth; |
| 5701 |
document.documentElement.style.setProperty("margin-right", "".concat(scrollWidth.value, "px")); |
| 5702 |
document.body.classList.add("cdx-dialog-open"); |
| 5703 |
setAriaHiddenAndInert(); |
| 5704 |
previouslyFocused = document.activeElement; |
| 5705 |
if (!focusFirstFocusableElement(dialogBody.value)) { |
| 5706 |
(_a = focusHolder.value) == null ? void 0 : _a.focus(); |
| 5707 |
} |
| 5708 |
}); |
| 5709 |
} |
| 5710 |
function onDialogClose() { |
| 5711 |
document.body.classList.remove("cdx-dialog-open"); |
| 5712 |
document.documentElement.style.removeProperty("margin-right"); |
| 5713 |
unsetAriaHiddenAndInert(); |
| 5714 |
if (previouslyFocused instanceof HTMLElement && document.contains(previouslyFocused)) { |
| 5715 |
previouslyFocused.focus(); |
| 5716 |
previouslyFocused = null; |
| 5717 |
} |
| 5718 |
} |
| 5719 |
onMounted(() => { |
| 5720 |
if (props.open) { |
| 5721 |
onDialogOpen(); |
| 5722 |
} |
| 5723 |
}); |
| 5724 |
onUnmounted(() => { |
| 5725 |
if (props.open) { |
| 5726 |
onDialogClose(); |
| 5727 |
} |
| 5728 |
}); |
| 5729 |
watch(toRef(props, "open"), (opened) => { |
| 5730 |
if (opened) { |
| 5731 |
onDialogOpen(); |
| 5732 |
} else { |
| 5733 |
onDialogClose(); |
| 5734 |
} |
| 5735 |
}); |
| 5736 |
watch(currentBodyHeight, () => { |
| 5737 |
if (dialogBody.value) { |
| 5738 |
showDividers.value = dialogBody.value.clientHeight < dialogBody.value.scrollHeight; |
| 5739 |
} |
| 5740 |
}); |
| 5741 |
return { |
| 5742 |
close, |
| 5743 |
cdxIconClose: X3, |
| 5744 |
labelId, |
| 5745 |
rootClasses, |
| 5746 |
backdrop, |
| 5747 |
dialogElement, |
| 5748 |
focusTrapStart, |
| 5749 |
focusTrapEnd, |
| 5750 |
focusFirst, |
| 5751 |
focusLast, |
| 5752 |
dialogBody, |
| 5753 |
focusHolder, |
| 5754 |
showHeader, |
| 5755 |
showFooterActions, |
| 5756 |
useCloseButtonOrLabel, |
| 5757 |
translatedCloseButtonLabel, |
| 5758 |
computedTarget |
| 5759 |
}; |
| 5760 |
} |
| 5761 |
}); |
| 5762 |
const _hoisted_1$g = ["aria-label", "aria-labelledby"]; |
| 5763 |
const _hoisted_2$a = { |
| 5764 |
key: 0, |
| 5765 |
class: "cdx-dialog__header__title-group" |
| 5766 |
}; |
| 5767 |
const _hoisted_3$6 = ["id"]; |
| 5768 |
const _hoisted_4$4 = { |
| 5769 |
key: 0, |
| 5770 |
class: "cdx-dialog__header__subtitle" |
| 5771 |
}; |
| 5772 |
const _hoisted_5$4 = { |
| 5773 |
ref: "focusHolder", |
| 5774 |
class: "cdx-dialog-focus-trap", |
| 5775 |
tabindex: "-1" |
| 5776 |
}; |
| 5777 |
const _hoisted_6$4 = { |
| 5778 |
key: 0, |
| 5779 |
class: "cdx-dialog__footer__text" |
| 5780 |
}; |
| 5781 |
const _hoisted_7$1 = { |
| 5782 |
key: 1, |
| 5783 |
class: "cdx-dialog__footer__actions" |
| 5784 |
}; |
| 5785 |
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) { |
| 5786 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 5787 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 5788 |
return openBlock(), createBlock(Teleport, { |
| 5789 |
to: _ctx.computedTarget, |
| 5790 |
disabled: _ctx.renderInPlace |
| 5791 |
}, [ |
| 5792 |
createVNode(Transition, { |
| 5793 |
name: "cdx-dialog-fade", |
| 5794 |
appear: "" |
| 5795 |
}, { |
| 5796 |
default: withCtx(() => [ |
| 5797 |
_ctx.open ? (openBlock(), createElementBlock( |
| 5798 |
"div", |
| 5799 |
{ |
| 5800 |
key: 0, |
| 5801 |
ref: "backdrop", |
| 5802 |
class: "cdx-dialog-backdrop", |
| 5803 |
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.close && _ctx.close(...args)), |
| 5804 |
onKeyup: _cache[6] || (_cache[6] = withKeys((...args) => _ctx.close && _ctx.close(...args), ["escape"])) |
| 5805 |
}, |
| 5806 |
[ |
| 5807 |
createElementVNode( |
| 5808 |
"div", |
| 5809 |
{ |
| 5810 |
ref: "focusTrapStart", |
| 5811 |
tabindex: "0", |
| 5812 |
onFocus: _cache[0] || (_cache[0] = (...args) => _ctx.focusLast && _ctx.focusLast(...args)) |
| 5813 |
}, |
| 5814 |
null, |
| 5815 |
544 |
| 5816 |
|
| 5817 |
), |
| 5818 |
createElementVNode("div", mergeProps({ |
| 5819 |
ref: "dialogElement", |
| 5820 |
class: ["cdx-dialog", _ctx.rootClasses], |
| 5821 |
role: "dialog" |
| 5822 |
}, _ctx.$attrs, { |
| 5823 |
"aria-label": _ctx.$slots.header || _ctx.hideTitle ? _ctx.title : void 0, |
| 5824 |
"aria-labelledby": !_ctx.$slots.header && !_ctx.hideTitle ? _ctx.labelId : void 0, |
| 5825 |
"aria-modal": "true", |
| 5826 |
onClick: _cache[3] || (_cache[3] = withModifiers(() => { |
| 5827 |
}, ["stop"])) |
| 5828 |
}), [ |
| 5829 |
_ctx.showHeader || _ctx.$slots.header ? (openBlock(), createElementBlock( |
| 5830 |
"header", |
| 5831 |
{ |
| 5832 |
key: 0, |
| 5833 |
class: normalizeClass(["cdx-dialog__header", { "cdx-dialog__header--default": !_ctx.$slots.header }]) |
| 5834 |
}, |
| 5835 |
[ |
| 5836 |
renderSlot(_ctx.$slots, "header", {}, () => [ |
| 5837 |
!_ctx.hideTitle ? (openBlock(), createElementBlock("div", _hoisted_2$a, [ |
| 5838 |
createElementVNode("h2", { |
| 5839 |
id: _ctx.labelId, |
| 5840 |
class: "cdx-dialog__header__title" |
| 5841 |
}, toDisplayString(_ctx.title), 9, _hoisted_3$6), |
| 5842 |
_ctx.subtitle ? (openBlock(), createElementBlock( |
| 5843 |
"p", |
| 5844 |
_hoisted_4$4, |
| 5845 |
toDisplayString(_ctx.subtitle), |
| 5846 |
1 |
| 5847 |
|
| 5848 |
)) : createCommentVNode("v-if", true) |
| 5849 |
])) : createCommentVNode("v-if", true), |
| 5850 |
_ctx.useCloseButtonOrLabel ? (openBlock(), createBlock(_component_cdx_button, { |
| 5851 |
key: 1, |
| 5852 |
class: "cdx-dialog__header__close-button", |
| 5853 |
weight: "quiet", |
| 5854 |
type: "button", |
| 5855 |
"aria-label": _ctx.translatedCloseButtonLabel, |
| 5856 |
onClick: _ctx.close |
| 5857 |
}, { |
| 5858 |
default: withCtx(() => [ |
| 5859 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconClose }, null, 8, ["icon"]) |
| 5860 |
]), |
| 5861 |
_: 1 |
| 5862 |
|
| 5863 |
}, 8, ["aria-label", "onClick"])) : createCommentVNode("v-if", true) |
| 5864 |
]) |
| 5865 |
], |
| 5866 |
2 |
| 5867 |
|
| 5868 |
)) : createCommentVNode("v-if", true), |
| 5869 |
createElementVNode( |
| 5870 |
"div", |
| 5871 |
_hoisted_5$4, |
| 5872 |
null, |
| 5873 |
512 |
| 5874 |
|
| 5875 |
), |
| 5876 |
createElementVNode( |
| 5877 |
"div", |
| 5878 |
{ |
| 5879 |
ref: "dialogBody", |
| 5880 |
class: normalizeClass(["cdx-dialog__body", { |
| 5881 |
"cdx-dialog__body--no-header": !(_ctx.showHeader || _ctx.$slots.header), |
| 5882 |
"cdx-dialog__body--no-footer": !(_ctx.showFooterActions || _ctx.$slots.footer || _ctx.$slots["footer-text"]) |
| 5883 |
}]) |
| 5884 |
}, |
| 5885 |
[ |
| 5886 |
renderSlot(_ctx.$slots, "default") |
| 5887 |
], |
| 5888 |
2 |
| 5889 |
|
| 5890 |
), |
| 5891 |
_ctx.showFooterActions || _ctx.$slots.footer || _ctx.$slots["footer-text"] ? (openBlock(), createElementBlock( |
| 5892 |
"footer", |
| 5893 |
{ |
| 5894 |
key: 1, |
| 5895 |
class: normalizeClass(["cdx-dialog__footer", { "cdx-dialog__footer--default": !_ctx.$slots.footer }]) |
| 5896 |
}, |
| 5897 |
[ |
| 5898 |
renderSlot(_ctx.$slots, "footer", {}, () => [ |
| 5899 |
_ctx.$slots["footer-text"] ? (openBlock(), createElementBlock("p", _hoisted_6$4, [ |
| 5900 |
renderSlot(_ctx.$slots, "footer-text") |
| 5901 |
])) : createCommentVNode("v-if", true), |
| 5902 |
_ctx.showFooterActions ? (openBlock(), createElementBlock("div", _hoisted_7$1, [ |
| 5903 |
_ctx.primaryAction ? (openBlock(), createBlock(_component_cdx_button, { |
| 5904 |
key: 0, |
| 5905 |
class: "cdx-dialog__footer__primary-action", |
| 5906 |
weight: "primary", |
| 5907 |
action: _ctx.primaryAction.actionType, |
| 5908 |
disabled: _ctx.primaryAction.disabled, |
| 5909 |
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("primary")) |
| 5910 |
}, { |
| 5911 |
default: withCtx(() => [ |
| 5912 |
createTextVNode( |
| 5913 |
toDisplayString(_ctx.primaryAction.label), |
| 5914 |
1 |
| 5915 |
|
| 5916 |
) |
| 5917 |
]), |
| 5918 |
_: 1 |
| 5919 |
|
| 5920 |
}, 8, ["action", "disabled"])) : createCommentVNode("v-if", true), |
| 5921 |
_ctx.defaultAction ? (openBlock(), createBlock(_component_cdx_button, { |
| 5922 |
key: 1, |
| 5923 |
class: "cdx-dialog__footer__default-action", |
| 5924 |
disabled: _ctx.defaultAction.disabled, |
| 5925 |
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("default")) |
| 5926 |
}, { |
| 5927 |
default: withCtx(() => [ |
| 5928 |
createTextVNode( |
| 5929 |
toDisplayString(_ctx.defaultAction.label), |
| 5930 |
1 |
| 5931 |
|
| 5932 |
) |
| 5933 |
]), |
| 5934 |
_: 1 |
| 5935 |
|
| 5936 |
}, 8, ["disabled"])) : createCommentVNode("v-if", true) |
| 5937 |
])) : createCommentVNode("v-if", true) |
| 5938 |
]) |
| 5939 |
], |
| 5940 |
2 |
| 5941 |
|
| 5942 |
)) : createCommentVNode("v-if", true) |
| 5943 |
], 16, _hoisted_1$g), |
| 5944 |
createElementVNode( |
| 5945 |
"div", |
| 5946 |
{ |
| 5947 |
ref: "focusTrapEnd", |
| 5948 |
tabindex: "0", |
| 5949 |
onFocus: _cache[4] || (_cache[4] = (...args) => _ctx.focusFirst && _ctx.focusFirst(...args)) |
| 5950 |
}, |
| 5951 |
null, |
| 5952 |
544 |
| 5953 |
|
| 5954 |
) |
| 5955 |
], |
| 5956 |
544 |
| 5957 |
|
| 5958 |
)) : createCommentVNode("v-if", true) |
| 5959 |
]), |
| 5960 |
_: 3 |
| 5961 |
|
| 5962 |
}) |
| 5963 |
], 8, ["to", "disabled"]); |
| 5964 |
} |
| 5965 |
const Dialog = _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]); |
| 5966 |
const iconMap$2 = { |
| 5967 |
notice: Y4, |
| 5968 |
error: i4, |
| 5969 |
warning: M3, |
| 5970 |
success: O7 |
| 5971 |
}; |
| 5972 |
const _sfc_main$h = defineComponent({ |
| 5973 |
name: "CdxMessage", |
| 5974 |
components: { CdxButton, CdxIcon }, |
| 5975 |
props: { |
| 5976 |
|
| 5977 |
|
| 5978 |
|
| 5979 |
|
| 5980 |
|
| 5981 |
type: { |
| 5982 |
type: String, |
| 5983 |
default: "notice", |
| 5984 |
validator: statusTypeValidator |
| 5985 |
}, |
| 5986 |
|
| 5987 |
|
| 5988 |
|
| 5989 |
inline: { |
| 5990 |
type: Boolean, |
| 5991 |
default: false |
| 5992 |
}, |
| 5993 |
|
| 5994 |
|
| 5995 |
|
| 5996 |
icon: { |
| 5997 |
type: [String, Object], |
| 5998 |
default: null |
| 5999 |
}, |
| 6000 |
|
| 6001 |
|
| 6002 |
|
| 6003 |
|
| 6004 |
fadeIn: { |
| 6005 |
type: Boolean, |
| 6006 |
default: false |
| 6007 |
}, |
| 6008 |
|
| 6009 |
|
| 6010 |
|
| 6011 |
allowUserDismiss: { |
| 6012 |
type: Boolean, |
| 6013 |
default: false |
| 6014 |
}, |
| 6015 |
|
| 6016 |
|
| 6017 |
|
| 6018 |
|
| 6019 |
|
| 6020 |
|
| 6021 |
dismissButtonLabel: { |
| 6022 |
type: String, |
| 6023 |
default: "" |
| 6024 |
}, |
| 6025 |
|
| 6026 |
|
| 6027 |
|
| 6028 |
|
| 6029 |
|
| 6030 |
|
| 6031 |
|
| 6032 |
|
| 6033 |
|
| 6034 |
|
| 6035 |
|
| 6036 |
|
| 6037 |
|
| 6038 |
autoDismiss: { |
| 6039 |
type: [Boolean, Number], |
| 6040 |
default: false, |
| 6041 |
validator: (value) => typeof value === "boolean" || typeof value === "number" && value > 0 |
| 6042 |
} |
| 6043 |
}, |
| 6044 |
emits: [ |
| 6045 |
|
| 6046 |
|
| 6047 |
|
| 6048 |
"user-dismissed", |
| 6049 |
|
| 6050 |
|
| 6051 |
|
| 6052 |
"auto-dismissed" |
| 6053 |
], |
| 6054 |
setup(props, { emit }) { |
| 6055 |
const dismissed = ref(false); |
| 6056 |
const userDismissable = computed( |
| 6057 |
() => props.inline === false && |
| 6058 |
(props.dismissButtonLabel.length > 0 || props.allowUserDismiss) |
| 6059 |
); |
| 6060 |
const translatedDismissButtonLabel = useI18nWithOverride( |
| 6061 |
toRef(props, "dismissButtonLabel"), |
| 6062 |
"cdx-message-dismiss-button-label", |
| 6063 |
"Close" |
| 6064 |
); |
| 6065 |
const displayTime = computed(() => { |
| 6066 |
if (props.autoDismiss === false || props.type === "error") { |
| 6067 |
return false; |
| 6068 |
} else if (props.autoDismiss === true) { |
| 6069 |
return 4e3; |
| 6070 |
} |
| 6071 |
return props.autoDismiss; |
| 6072 |
}); |
| 6073 |
const rootClasses = computed(() => { |
| 6074 |
return { |
| 6075 |
"cdx-message--inline": props.inline, |
| 6076 |
"cdx-message--block": !props.inline, |
| 6077 |
"cdx-message--user-dismissable": userDismissable.value, |
| 6078 |
["cdx-message--".concat(props.type)]: true |
| 6079 |
}; |
| 6080 |
}); |
| 6081 |
const computedIcon = computed( |
| 6082 |
() => props.icon && props.type === "notice" ? props.icon : iconMap$2[props.type] |
| 6083 |
); |
| 6084 |
const leaveActiveClass = ref(""); |
| 6085 |
function onDismiss(eventName) { |
| 6086 |
if (dismissed.value) { |
| 6087 |
return; |
| 6088 |
} |
| 6089 |
leaveActiveClass.value = eventName === "user-dismissed" ? "cdx-message-leave-active-user" : "cdx-message-leave-active-system"; |
| 6090 |
dismissed.value = true; |
| 6091 |
emit(eventName); |
| 6092 |
} |
| 6093 |
onMounted(() => { |
| 6094 |
if (props.type === "error" && props.autoDismiss !== false) { |
| 6095 |
warn('CdxMessage: Message with type="error" cannot use auto-dismiss'); |
| 6096 |
} else if (displayTime.value) { |
| 6097 |
setTimeout(() => onDismiss("auto-dismissed"), displayTime.value); |
| 6098 |
} |
| 6099 |
}); |
| 6100 |
return { |
| 6101 |
dismissed, |
| 6102 |
userDismissable, |
| 6103 |
translatedDismissButtonLabel, |
| 6104 |
rootClasses, |
| 6105 |
leaveActiveClass, |
| 6106 |
computedIcon, |
| 6107 |
onDismiss, |
| 6108 |
cdxIconClose: X3 |
| 6109 |
}; |
| 6110 |
} |
| 6111 |
}); |
| 6112 |
const _hoisted_1$f = ["aria-live", "role"]; |
| 6113 |
const _hoisted_2$9 = { class: "cdx-message__content" }; |
| 6114 |
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) { |
| 6115 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 6116 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 6117 |
return openBlock(), createBlock(Transition, { |
| 6118 |
name: "cdx-message", |
| 6119 |
appear: _ctx.fadeIn, |
| 6120 |
"leave-active-class": _ctx.leaveActiveClass |
| 6121 |
}, { |
| 6122 |
default: withCtx(() => [ |
| 6123 |
!_ctx.dismissed ? (openBlock(), createElementBlock("div", { |
| 6124 |
key: 0, |
| 6125 |
class: normalizeClass(["cdx-message", _ctx.rootClasses]), |
| 6126 |
"aria-live": _ctx.type !== "error" ? "polite" : void 0, |
| 6127 |
role: _ctx.type === "error" ? "alert" : void 0 |
| 6128 |
}, [ |
| 6129 |
createVNode(_component_cdx_icon, { |
| 6130 |
class: "cdx-message__icon--vue", |
| 6131 |
icon: _ctx.computedIcon |
| 6132 |
}, null, 8, ["icon"]), |
| 6133 |
createElementVNode("div", _hoisted_2$9, [ |
| 6134 |
renderSlot(_ctx.$slots, "default") |
| 6135 |
]), |
| 6136 |
_ctx.userDismissable ? (openBlock(), createBlock(_component_cdx_button, { |
| 6137 |
key: 0, |
| 6138 |
class: "cdx-message__dismiss-button", |
| 6139 |
weight: "quiet", |
| 6140 |
type: "button", |
| 6141 |
"aria-label": _ctx.translatedDismissButtonLabel, |
| 6142 |
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.onDismiss("user-dismissed")) |
| 6143 |
}, { |
| 6144 |
default: withCtx(() => [ |
| 6145 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconClose }, null, 8, ["icon"]) |
| 6146 |
]), |
| 6147 |
_: 1 |
| 6148 |
|
| 6149 |
}, 8, ["aria-label"])) : createCommentVNode("v-if", true) |
| 6150 |
], 10, _hoisted_1$f)) : createCommentVNode("v-if", true) |
| 6151 |
]), |
| 6152 |
_: 3 |
| 6153 |
|
| 6154 |
}, 8, ["appear", "leave-active-class"]); |
| 6155 |
} |
| 6156 |
const CdxMessage = _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]); |
| 6157 |
const statusValidator$6 = makeStringTypeValidator(ValidationStatusTypes); |
| 6158 |
const _sfc_main$g = defineComponent({ |
| 6159 |
name: "CdxField", |
| 6160 |
components: { CdxLabel, CdxMessage }, |
| 6161 |
props: { |
| 6162 |
|
| 6163 |
|
| 6164 |
|
| 6165 |
|
| 6166 |
|
| 6167 |
labelIcon: { |
| 6168 |
type: [String, Object], |
| 6169 |
default: "" |
| 6170 |
}, |
| 6171 |
|
| 6172 |
|
| 6173 |
|
| 6174 |
|
| 6175 |
|
| 6176 |
optional: { |
| 6177 |
type: Boolean, |
| 6178 |
default: false |
| 6179 |
}, |
| 6180 |
|
| 6181 |
|
| 6182 |
|
| 6183 |
|
| 6184 |
|
| 6185 |
|
| 6186 |
optionalFlag: { |
| 6187 |
type: String, |
| 6188 |
default: "" |
| 6189 |
}, |
| 6190 |
|
| 6191 |
|
| 6192 |
|
| 6193 |
|
| 6194 |
|
| 6195 |
hideLabel: { |
| 6196 |
type: Boolean, |
| 6197 |
default: false |
| 6198 |
}, |
| 6199 |
|
| 6200 |
|
| 6201 |
|
| 6202 |
|
| 6203 |
|
| 6204 |
|
| 6205 |
isFieldset: { |
| 6206 |
type: Boolean, |
| 6207 |
default: false |
| 6208 |
}, |
| 6209 |
|
| 6210 |
|
| 6211 |
|
| 6212 |
disabled: { |
| 6213 |
type: Boolean, |
| 6214 |
default: false |
| 6215 |
}, |
| 6216 |
|
| 6217 |
|
| 6218 |
|
| 6219 |
status: { |
| 6220 |
type: String, |
| 6221 |
default: "default", |
| 6222 |
validator: statusValidator$6 |
| 6223 |
}, |
| 6224 |
|
| 6225 |
|
| 6226 |
|
| 6227 |
|
| 6228 |
messages: { |
| 6229 |
type: Object, |
| 6230 |
default: () => { |
| 6231 |
return {}; |
| 6232 |
} |
| 6233 |
} |
| 6234 |
}, |
| 6235 |
setup(props, { slots }) { |
| 6236 |
const { disabled, status, isFieldset } = toRefs(props); |
| 6237 |
const computedDisabled = useComputedDisabled(disabled); |
| 6238 |
const rootClasses = computed(() => { |
| 6239 |
return { |
| 6240 |
"cdx-field--disabled": computedDisabled.value, |
| 6241 |
"cdx-field--is-fieldset": isFieldset.value |
| 6242 |
}; |
| 6243 |
}); |
| 6244 |
const labelId = useGeneratedId("label"); |
| 6245 |
const descriptionId = useGeneratedId("description"); |
| 6246 |
const inputId = useGeneratedId("input"); |
| 6247 |
const computedInputId = computed(() => !isFieldset.value ? inputId : void 0); |
| 6248 |
provide(FieldInputIdKey, computedInputId); |
| 6249 |
const computedDescriptionId = computed( |
| 6250 |
() => !isFieldset.value && slots.description ? descriptionId : void 0 |
| 6251 |
); |
| 6252 |
provide(FieldDescriptionIdKey, computedDescriptionId); |
| 6253 |
provide(DisabledKey, computedDisabled); |
| 6254 |
provide(FieldStatusKey, status); |
| 6255 |
const validationMessage = computed( |
| 6256 |
() => props.status !== "default" && props.status in props.messages ? props.messages[props.status] : "" |
| 6257 |
); |
| 6258 |
const validationMessageType = computed(() => props.status === "default" ? "notice" : props.status); |
| 6259 |
return { |
| 6260 |
rootClasses, |
| 6261 |
computedDisabled, |
| 6262 |
labelId, |
| 6263 |
descriptionId, |
| 6264 |
inputId, |
| 6265 |
validationMessage, |
| 6266 |
validationMessageType |
| 6267 |
}; |
| 6268 |
} |
| 6269 |
}); |
| 6270 |
const _hoisted_1$e = { class: "cdx-field__control" }; |
| 6271 |
const _hoisted_2$8 = { class: "cdx-field__help-text" }; |
| 6272 |
const _hoisted_3$5 = { |
| 6273 |
key: 0, |
| 6274 |
class: "cdx-field__validation-message" |
| 6275 |
}; |
| 6276 |
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) { |
| 6277 |
const _component_cdx_label = resolveComponent("cdx-label"); |
| 6278 |
const _component_cdx_message = resolveComponent("cdx-message"); |
| 6279 |
return openBlock(), createBlock(resolveDynamicComponent(_ctx.isFieldset ? "fieldset" : "div"), { |
| 6280 |
class: normalizeClass(["cdx-field", _ctx.rootClasses]), |
| 6281 |
"aria-disabled": !_ctx.isFieldset && _ctx.computedDisabled ? true : void 0, |
| 6282 |
disabled: _ctx.isFieldset && _ctx.computedDisabled ? true : void 0 |
| 6283 |
}, { |
| 6284 |
default: withCtx(() => [ |
| 6285 |
createVNode(_component_cdx_label, { |
| 6286 |
id: _ctx.labelId, |
| 6287 |
icon: _ctx.labelIcon, |
| 6288 |
"visually-hidden": _ctx.hideLabel, |
| 6289 |
optional: _ctx.optional, |
| 6290 |
"optional-flag": _ctx.optionalFlag, |
| 6291 |
"input-id": _ctx.inputId, |
| 6292 |
"description-id": _ctx.descriptionId, |
| 6293 |
disabled: _ctx.computedDisabled, |
| 6294 |
"is-legend": _ctx.isFieldset |
| 6295 |
}, createSlots({ |
| 6296 |
default: withCtx(() => [ |
| 6297 |
renderSlot(_ctx.$slots, "label") |
| 6298 |
]), |
| 6299 |
_: 2 |
| 6300 |
|
| 6301 |
}, [ |
| 6302 |
_ctx.$slots.description && _ctx.$slots.description().length > 0 ? { |
| 6303 |
name: "description", |
| 6304 |
fn: withCtx(() => [ |
| 6305 |
renderSlot(_ctx.$slots, "description") |
| 6306 |
]), |
| 6307 |
key: "0" |
| 6308 |
} : void 0 |
| 6309 |
]), 1032, ["id", "icon", "visually-hidden", "optional", "optional-flag", "input-id", "description-id", "disabled", "is-legend"]), |
| 6310 |
createElementVNode("div", _hoisted_1$e, [ |
| 6311 |
renderSlot(_ctx.$slots, "default") |
| 6312 |
]), |
| 6313 |
createElementVNode("div", _hoisted_2$8, [ |
| 6314 |
renderSlot(_ctx.$slots, "help-text") |
| 6315 |
]), |
| 6316 |
!_ctx.computedDisabled && _ctx.validationMessage ? (openBlock(), createElementBlock("div", _hoisted_3$5, [ |
| 6317 |
createVNode(_component_cdx_message, { |
| 6318 |
type: _ctx.validationMessageType, |
| 6319 |
inline: true |
| 6320 |
}, { |
| 6321 |
default: withCtx(() => [ |
| 6322 |
createTextVNode( |
| 6323 |
toDisplayString(_ctx.validationMessage), |
| 6324 |
1 |
| 6325 |
|
| 6326 |
) |
| 6327 |
]), |
| 6328 |
_: 1 |
| 6329 |
|
| 6330 |
}, 8, ["type"]) |
| 6331 |
])) : createCommentVNode("v-if", true) |
| 6332 |
]), |
| 6333 |
_: 3 |
| 6334 |
|
| 6335 |
}, 8, ["class", "aria-disabled", "disabled"]); |
| 6336 |
} |
| 6337 |
const Field = _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]); |
| 6338 |
const iconMap$1 = { |
| 6339 |
error: i4, |
| 6340 |
warning: M3, |
| 6341 |
success: O7 |
| 6342 |
}; |
| 6343 |
const _sfc_main$f = defineComponent({ |
| 6344 |
name: "CdxInfoChip", |
| 6345 |
components: { CdxIcon }, |
| 6346 |
props: { |
| 6347 |
|
| 6348 |
|
| 6349 |
|
| 6350 |
|
| 6351 |
|
| 6352 |
status: { |
| 6353 |
type: String, |
| 6354 |
default: "notice", |
| 6355 |
validator: statusTypeValidator |
| 6356 |
}, |
| 6357 |
|
| 6358 |
|
| 6359 |
|
| 6360 |
|
| 6361 |
icon: { |
| 6362 |
type: [String, Object], |
| 6363 |
default: null |
| 6364 |
} |
| 6365 |
}, |
| 6366 |
setup(props) { |
| 6367 |
const iconClass = computed(() => { |
| 6368 |
return { |
| 6369 |
["cdx-info-chip__icon--".concat(props.status)]: true |
| 6370 |
}; |
| 6371 |
}); |
| 6372 |
const computedIcon = computed( |
| 6373 |
() => props.status === "notice" ? props.icon : iconMap$1[props.status] |
| 6374 |
); |
| 6375 |
return { |
| 6376 |
iconClass, |
| 6377 |
computedIcon |
| 6378 |
}; |
| 6379 |
} |
| 6380 |
}); |
| 6381 |
const _hoisted_1$d = { class: "cdx-info-chip" }; |
| 6382 |
const _hoisted_2$7 = { class: "cdx-info-chip--text" }; |
| 6383 |
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) { |
| 6384 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 6385 |
return openBlock(), createElementBlock("div", _hoisted_1$d, [ |
| 6386 |
_ctx.computedIcon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 6387 |
key: 0, |
| 6388 |
class: normalizeClass(["cdx-info-chip__icon", _ctx.iconClass]), |
| 6389 |
icon: _ctx.computedIcon |
| 6390 |
}, null, 8, ["class", "icon"])) : createCommentVNode("v-if", true), |
| 6391 |
createElementVNode("span", _hoisted_2$7, [ |
| 6392 |
renderSlot(_ctx.$slots, "default") |
| 6393 |
]) |
| 6394 |
]); |
| 6395 |
} |
| 6396 |
const InfoChip = _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]); |
| 6397 |
const statusValidator$5 = makeStringTypeValidator(ValidationStatusTypes); |
| 6398 |
const _sfc_main$e = defineComponent({ |
| 6399 |
name: "CdxLookup", |
| 6400 |
components: { |
| 6401 |
CdxMenu, |
| 6402 |
CdxTextInput |
| 6403 |
}, |
| 6404 |
|
| 6405 |
|
| 6406 |
|
| 6407 |
inheritAttrs: false, |
| 6408 |
props: { |
| 6409 |
|
| 6410 |
|
| 6411 |
|
| 6412 |
|
| 6413 |
|
| 6414 |
|
| 6415 |
|
| 6416 |
selected: { |
| 6417 |
type: [String, Number, null], |
| 6418 |
required: true |
| 6419 |
}, |
| 6420 |
|
| 6421 |
|
| 6422 |
|
| 6423 |
menuItems: { |
| 6424 |
type: Array, |
| 6425 |
required: true |
| 6426 |
}, |
| 6427 |
|
| 6428 |
|
| 6429 |
|
| 6430 |
|
| 6431 |
|
| 6432 |
|
| 6433 |
inputValue: { |
| 6434 |
type: [String, Number], |
| 6435 |
default: null |
| 6436 |
}, |
| 6437 |
|
| 6438 |
|
| 6439 |
|
| 6440 |
|
| 6441 |
|
| 6442 |
|
| 6443 |
initialInputValue: { |
| 6444 |
type: [String, Number], |
| 6445 |
default: "", |
| 6446 |
validator: (value) => { |
| 6447 |
if (value) { |
| 6448 |
console.warn( |
| 6449 |
"CdxLookup: prop initialInputValue is deprecated. Use inputValue instead." |
| 6450 |
); |
| 6451 |
} |
| 6452 |
return true; |
| 6453 |
} |
| 6454 |
}, |
| 6455 |
|
| 6456 |
|
| 6457 |
|
| 6458 |
disabled: { |
| 6459 |
type: Boolean, |
| 6460 |
default: false |
| 6461 |
}, |
| 6462 |
|
| 6463 |
|
| 6464 |
|
| 6465 |
|
| 6466 |
|
| 6467 |
|
| 6468 |
menuConfig: { |
| 6469 |
type: Object, |
| 6470 |
default: () => { |
| 6471 |
return {}; |
| 6472 |
} |
| 6473 |
}, |
| 6474 |
|
| 6475 |
|
| 6476 |
|
| 6477 |
status: { |
| 6478 |
type: String, |
| 6479 |
default: "default", |
| 6480 |
validator: statusValidator$5 |
| 6481 |
} |
| 6482 |
}, |
| 6483 |
emits: [ |
| 6484 |
|
| 6485 |
|
| 6486 |
|
| 6487 |
|
| 6488 |
|
| 6489 |
"update:selected", |
| 6490 |
|
| 6491 |
|
| 6492 |
|
| 6493 |
|
| 6494 |
|
| 6495 |
"update:input-value", |
| 6496 |
|
| 6497 |
|
| 6498 |
|
| 6499 |
|
| 6500 |
|
| 6501 |
|
| 6502 |
"load-more", |
| 6503 |
|
| 6504 |
|
| 6505 |
|
| 6506 |
|
| 6507 |
|
| 6508 |
"input", |
| 6509 |
|
| 6510 |
|
| 6511 |
|
| 6512 |
|
| 6513 |
|
| 6514 |
"change", |
| 6515 |
|
| 6516 |
|
| 6517 |
|
| 6518 |
|
| 6519 |
|
| 6520 |
"focus", |
| 6521 |
|
| 6522 |
|
| 6523 |
|
| 6524 |
|
| 6525 |
|
| 6526 |
"blur" |
| 6527 |
], |
| 6528 |
setup: (props, { emit, attrs, slots }) => { |
| 6529 |
const rootElement = ref(); |
| 6530 |
const textInput = ref(); |
| 6531 |
const menu = ref(); |
| 6532 |
const menuId = useGeneratedId("lookup-menu"); |
| 6533 |
const pending = ref(false); |
| 6534 |
const expanded = ref(false); |
| 6535 |
const isActive = ref(false); |
| 6536 |
const initialMenuItems = ref(props.menuItems); |
| 6537 |
const { |
| 6538 |
computedDisabled, |
| 6539 |
computedStatus |
| 6540 |
} = useFieldData( |
| 6541 |
toRef(props, "disabled"), |
| 6542 |
toRef(props, "status") |
| 6543 |
); |
| 6544 |
const selectedProp = toRef(props, "selected"); |
| 6545 |
const modelWrapper = useModelWrapper(selectedProp, emit, "update:selected"); |
| 6546 |
const selectedMenuItem = computed( |
| 6547 |
() => props.menuItems.find((item) => item.value === props.selected) |
| 6548 |
); |
| 6549 |
const highlightedId = computed(() => { |
| 6550 |
var _a, _b; |
| 6551 |
return (_b = (_a = menu.value) == null ? void 0 : _a.getHighlightedMenuItem()) == null ? void 0 : _b.id; |
| 6552 |
}); |
| 6553 |
const internalInputValue = ref(props.initialInputValue); |
| 6554 |
const computedInputValue = useOptionalModelWrapper( |
| 6555 |
internalInputValue, |
| 6556 |
toRef(props, "inputValue"), |
| 6557 |
emit, |
| 6558 |
"update:input-value" |
| 6559 |
); |
| 6560 |
const internalClasses = computed(() => { |
| 6561 |
return { |
| 6562 |
"cdx-lookup--disabled": computedDisabled.value, |
| 6563 |
"cdx-lookup--pending": pending.value |
| 6564 |
}; |
| 6565 |
}); |
| 6566 |
const { |
| 6567 |
rootClasses, |
| 6568 |
rootStyle, |
| 6569 |
otherAttrs |
| 6570 |
} = useSplitAttributes(attrs, internalClasses); |
| 6571 |
function onUpdateInput(newVal) { |
| 6572 |
if (selectedMenuItem.value) { |
| 6573 |
if (selectedMenuItem.value.label !== newVal && selectedMenuItem.value.value !== newVal) { |
| 6574 |
modelWrapper.value = null; |
| 6575 |
} |
| 6576 |
} else if (props.selected !== null && props.selected !== newVal) { |
| 6577 |
modelWrapper.value = null; |
| 6578 |
} |
| 6579 |
if (newVal === "" && initialMenuItems.value.length === 0) { |
| 6580 |
expanded.value = false; |
| 6581 |
pending.value = false; |
| 6582 |
} else { |
| 6583 |
pending.value = true; |
| 6584 |
} |
| 6585 |
emit("input", newVal); |
| 6586 |
} |
| 6587 |
function onInputFocus(event) { |
| 6588 |
isActive.value = true; |
| 6589 |
const hasInput = computedInputValue.value !== null && computedInputValue.value !== ""; |
| 6590 |
const hasMenuItems = !!(props.menuItems.length > 0 || slots["no-results"]); |
| 6591 |
if (hasMenuItems && (hasInput || initialMenuItems.value.length > 0)) { |
| 6592 |
expanded.value = true; |
| 6593 |
} |
| 6594 |
emit("focus", event); |
| 6595 |
} |
| 6596 |
function onInputBlur(event) { |
| 6597 |
isActive.value = false; |
| 6598 |
expanded.value = false; |
| 6599 |
emit("blur", event); |
| 6600 |
} |
| 6601 |
function onKeydown(e) { |
| 6602 |
if (!menu.value || computedDisabled.value || props.menuItems.length === 0 && !slots["no-results"] || e.key === " ") { |
| 6603 |
return; |
| 6604 |
} |
| 6605 |
menu.value.delegateKeyNavigation(e); |
| 6606 |
} |
| 6607 |
useFloatingMenu(textInput, menu); |
| 6608 |
watch(selectedProp, (newVal) => { |
| 6609 |
var _a; |
| 6610 |
if (newVal !== null) { |
| 6611 |
const selectedValue = selectedMenuItem.value ? (_a = selectedMenuItem.value.label) != null ? _a : selectedMenuItem.value.value : ""; |
| 6612 |
if (computedInputValue.value !== selectedValue) { |
| 6613 |
computedInputValue.value = selectedValue; |
| 6614 |
emit("input", computedInputValue.value); |
| 6615 |
} |
| 6616 |
} |
| 6617 |
}); |
| 6618 |
watch(toRef(props, "menuItems"), (newVal) => { |
| 6619 |
if ( |
| 6620 |
|
| 6621 |
|
| 6622 |
isActive.value && pending.value && |
| 6623 |
(newVal.length > 0 || slots["no-results"]) |
| 6624 |
) { |
| 6625 |
expanded.value = true; |
| 6626 |
} |
| 6627 |
if (newVal.length === 0 && !slots["no-results"]) { |
| 6628 |
expanded.value = false; |
| 6629 |
} |
| 6630 |
pending.value = false; |
| 6631 |
}); |
| 6632 |
return { |
| 6633 |
rootElement, |
| 6634 |
textInput, |
| 6635 |
menu, |
| 6636 |
menuId, |
| 6637 |
highlightedId, |
| 6638 |
computedInputValue, |
| 6639 |
modelWrapper, |
| 6640 |
expanded, |
| 6641 |
computedDisabled, |
| 6642 |
computedStatus, |
| 6643 |
onInputBlur, |
| 6644 |
rootClasses, |
| 6645 |
rootStyle, |
| 6646 |
otherAttrs, |
| 6647 |
onUpdateInput, |
| 6648 |
onInputFocus, |
| 6649 |
onKeydown |
| 6650 |
}; |
| 6651 |
} |
| 6652 |
}); |
| 6653 |
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) { |
| 6654 |
const _component_cdx_text_input = resolveComponent("cdx-text-input"); |
| 6655 |
const _component_cdx_menu = resolveComponent("cdx-menu"); |
| 6656 |
return openBlock(), createElementBlock( |
| 6657 |
"div", |
| 6658 |
{ |
| 6659 |
ref: "rootElement", |
| 6660 |
class: normalizeClass(["cdx-lookup", _ctx.rootClasses]), |
| 6661 |
style: normalizeStyle(_ctx.rootStyle) |
| 6662 |
}, |
| 6663 |
[ |
| 6664 |
createVNode(_component_cdx_text_input, mergeProps({ |
| 6665 |
ref: "textInput", |
| 6666 |
modelValue: _ctx.computedInputValue, |
| 6667 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.computedInputValue = $event) |
| 6668 |
}, _ctx.otherAttrs, { |
| 6669 |
class: "cdx-lookup__input", |
| 6670 |
role: "combobox", |
| 6671 |
autocomplete: "off", |
| 6672 |
"aria-autocomplete": "list", |
| 6673 |
"aria-controls": _ctx.menuId, |
| 6674 |
"aria-expanded": _ctx.expanded, |
| 6675 |
"aria-activedescendant": _ctx.highlightedId, |
| 6676 |
disabled: _ctx.computedDisabled, |
| 6677 |
status: _ctx.computedStatus, |
| 6678 |
"onUpdate:modelValue": _ctx.onUpdateInput, |
| 6679 |
onChange: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("change", $event)), |
| 6680 |
onFocus: _ctx.onInputFocus, |
| 6681 |
onBlur: _ctx.onInputBlur, |
| 6682 |
onKeydown: _ctx.onKeydown |
| 6683 |
}), null, 16, ["modelValue", "aria-controls", "aria-expanded", "aria-activedescendant", "disabled", "status", "onUpdate:modelValue", "onFocus", "onBlur", "onKeydown"]), |
| 6684 |
createVNode(_component_cdx_menu, mergeProps({ |
| 6685 |
id: _ctx.menuId, |
| 6686 |
ref: "menu", |
| 6687 |
selected: _ctx.modelWrapper, |
| 6688 |
"onUpdate:selected": _cache[2] || (_cache[2] = ($event) => _ctx.modelWrapper = $event), |
| 6689 |
expanded: _ctx.expanded, |
| 6690 |
"onUpdate:expanded": _cache[3] || (_cache[3] = ($event) => _ctx.expanded = $event), |
| 6691 |
"menu-items": _ctx.menuItems |
| 6692 |
}, _ctx.menuConfig, { |
| 6693 |
onLoadMore: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("load-more")) |
| 6694 |
}), { |
| 6695 |
default: withCtx(({ menuItem }) => [ |
| 6696 |
renderSlot(_ctx.$slots, "menu-item", { menuItem }) |
| 6697 |
]), |
| 6698 |
"no-results": withCtx(() => [ |
| 6699 |
renderSlot(_ctx.$slots, "no-results") |
| 6700 |
]), |
| 6701 |
_: 3 |
| 6702 |
|
| 6703 |
}, 16, ["id", "selected", "expanded", "menu-items"]) |
| 6704 |
], |
| 6705 |
6 |
| 6706 |
|
| 6707 |
); |
| 6708 |
} |
| 6709 |
const Lookup = _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]); |
| 6710 |
const _sfc_main$d = defineComponent({ |
| 6711 |
name: "CdxToggleButton", |
| 6712 |
props: { |
| 6713 |
|
| 6714 |
|
| 6715 |
|
| 6716 |
|
| 6717 |
|
| 6718 |
modelValue: { |
| 6719 |
type: Boolean, |
| 6720 |
default: false |
| 6721 |
}, |
| 6722 |
|
| 6723 |
|
| 6724 |
|
| 6725 |
|
| 6726 |
disabled: { |
| 6727 |
type: Boolean, |
| 6728 |
default: false |
| 6729 |
}, |
| 6730 |
|
| 6731 |
|
| 6732 |
|
| 6733 |
quiet: { |
| 6734 |
type: Boolean, |
| 6735 |
default: false |
| 6736 |
} |
| 6737 |
}, |
| 6738 |
emits: [ |
| 6739 |
|
| 6740 |
|
| 6741 |
|
| 6742 |
|
| 6743 |
|
| 6744 |
"update:modelValue" |
| 6745 |
], |
| 6746 |
setup(props, { emit, slots, attrs }) { |
| 6747 |
const isIconOnly = useIconOnlyButton(slots.default, attrs, "CdxToggleButton"); |
| 6748 |
const isActive = ref(false); |
| 6749 |
const rootClasses = computed(() => ({ |
| 6750 |
|
| 6751 |
"cdx-toggle-button--quiet": props.quiet, |
| 6752 |
"cdx-toggle-button--framed": !props.quiet, |
| 6753 |
|
| 6754 |
"cdx-toggle-button--toggled-on": props.modelValue, |
| 6755 |
"cdx-toggle-button--toggled-off": !props.modelValue, |
| 6756 |
"cdx-toggle-button--icon-only": isIconOnly.value, |
| 6757 |
"cdx-toggle-button--is-active": isActive.value |
| 6758 |
})); |
| 6759 |
const onClick = () => { |
| 6760 |
emit("update:modelValue", !props.modelValue); |
| 6761 |
}; |
| 6762 |
const setActive = (active) => { |
| 6763 |
isActive.value = active; |
| 6764 |
}; |
| 6765 |
function onKeyDown() { |
| 6766 |
setActive(true); |
| 6767 |
} |
| 6768 |
function onKeyUp() { |
| 6769 |
setActive(false); |
| 6770 |
onClick(); |
| 6771 |
} |
| 6772 |
return { |
| 6773 |
rootClasses, |
| 6774 |
onClick, |
| 6775 |
onKeyDown, |
| 6776 |
onKeyUp |
| 6777 |
}; |
| 6778 |
} |
| 6779 |
}); |
| 6780 |
const _hoisted_1$c = ["aria-pressed", "disabled"]; |
| 6781 |
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) { |
| 6782 |
return openBlock(), createElementBlock("button", { |
| 6783 |
class: normalizeClass(["cdx-toggle-button", _ctx.rootClasses]), |
| 6784 |
"aria-pressed": _ctx.modelValue, |
| 6785 |
disabled: _ctx.disabled, |
| 6786 |
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args)), |
| 6787 |
onKeydown: _cache[1] || (_cache[1] = withKeys(withModifiers((...args) => _ctx.onKeyDown && _ctx.onKeyDown(...args), ["prevent"]), ["space", "enter"])), |
| 6788 |
onKeyup: _cache[2] || (_cache[2] = withKeys((...args) => _ctx.onKeyUp && _ctx.onKeyUp(...args), ["space", "enter"])) |
| 6789 |
}, [ |
| 6790 |
renderSlot(_ctx.$slots, "default") |
| 6791 |
], 42, _hoisted_1$c); |
| 6792 |
} |
| 6793 |
const CdxToggleButton = _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]); |
| 6794 |
const _sfc_main$c = defineComponent({ |
| 6795 |
name: "CdxMenuButton", |
| 6796 |
components: { |
| 6797 |
CdxToggleButton, |
| 6798 |
CdxMenu |
| 6799 |
}, |
| 6800 |
inheritAttrs: false, |
| 6801 |
props: { |
| 6802 |
|
| 6803 |
|
| 6804 |
|
| 6805 |
|
| 6806 |
|
| 6807 |
selected: { |
| 6808 |
type: [String, Number, null], |
| 6809 |
required: true |
| 6810 |
}, |
| 6811 |
|
| 6812 |
|
| 6813 |
|
| 6814 |
menuItems: { |
| 6815 |
type: Array, |
| 6816 |
required: true |
| 6817 |
}, |
| 6818 |
|
| 6819 |
|
| 6820 |
|
| 6821 |
|
| 6822 |
|
| 6823 |
|
| 6824 |
menuConfig: { |
| 6825 |
type: Object, |
| 6826 |
default: () => { |
| 6827 |
return {}; |
| 6828 |
} |
| 6829 |
}, |
| 6830 |
|
| 6831 |
|
| 6832 |
|
| 6833 |
disabled: { |
| 6834 |
type: Boolean, |
| 6835 |
default: false |
| 6836 |
} |
| 6837 |
}, |
| 6838 |
emits: [ |
| 6839 |
|
| 6840 |
|
| 6841 |
|
| 6842 |
|
| 6843 |
|
| 6844 |
"update:selected" |
| 6845 |
], |
| 6846 |
setup(props, { emit, attrs }) { |
| 6847 |
const menu = ref(); |
| 6848 |
const toggle = ref(); |
| 6849 |
const selectedProp = toRef(props, "selected"); |
| 6850 |
const modelWrapper = useModelWrapper(selectedProp, emit, "update:selected"); |
| 6851 |
const expanded = ref(false); |
| 6852 |
const toggleId = useGeneratedId("menuToggle"); |
| 6853 |
const menuId = useGeneratedId("menu"); |
| 6854 |
const { computedDisabled } = useFieldData(toRef(props, "disabled")); |
| 6855 |
const { rootClasses, rootStyle, otherAttrs } = useSplitAttributes(attrs); |
| 6856 |
function onKeydown(e) { |
| 6857 |
if (!menu.value || computedDisabled.value || props.menuItems.length === 0 || e.key === " ") { |
| 6858 |
return; |
| 6859 |
} |
| 6860 |
menu.value.delegateKeyNavigation(e); |
| 6861 |
} |
| 6862 |
useFloatingMenu(toggle, menu, { |
| 6863 |
useAvailableWidth: true, |
| 6864 |
placement: "bottom-start", |
| 6865 |
offset: 4 |
| 6866 |
}); |
| 6867 |
return { |
| 6868 |
computedDisabled, |
| 6869 |
expanded, |
| 6870 |
menu, |
| 6871 |
menuId, |
| 6872 |
modelWrapper, |
| 6873 |
onKeydown, |
| 6874 |
toggle, |
| 6875 |
toggleId, |
| 6876 |
rootClasses, |
| 6877 |
rootStyle, |
| 6878 |
otherAttrs |
| 6879 |
}; |
| 6880 |
} |
| 6881 |
}); |
| 6882 |
const _hoisted_1$b = { class: "cdx-menu-button__menu-wrapper" }; |
| 6883 |
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) { |
| 6884 |
const _component_cdx_toggle_button = resolveComponent("cdx-toggle-button"); |
| 6885 |
const _component_cdx_menu = resolveComponent("cdx-menu"); |
| 6886 |
return openBlock(), createElementBlock( |
| 6887 |
"div", |
| 6888 |
{ |
| 6889 |
class: normalizeClass(["cdx-menu-button", _ctx.rootClasses]), |
| 6890 |
style: normalizeStyle(_ctx.rootStyle) |
| 6891 |
}, |
| 6892 |
[ |
| 6893 |
createVNode(_component_cdx_toggle_button, mergeProps({ |
| 6894 |
id: _ctx.toggleId, |
| 6895 |
ref: "toggle" |
| 6896 |
}, _ctx.otherAttrs, { |
| 6897 |
modelValue: _ctx.expanded, |
| 6898 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.expanded = $event), |
| 6899 |
disabled: _ctx.computedDisabled, |
| 6900 |
quiet: "", |
| 6901 |
"aria-haspopup": "menu", |
| 6902 |
"aria-controls": _ctx.menuId, |
| 6903 |
"aria-expanded": _ctx.expanded, |
| 6904 |
onBlur: _cache[1] || (_cache[1] = ($event) => _ctx.expanded = false), |
| 6905 |
onKeydown: _ctx.onKeydown |
| 6906 |
}), { |
| 6907 |
default: withCtx(() => [ |
| 6908 |
renderSlot(_ctx.$slots, "default") |
| 6909 |
]), |
| 6910 |
_: 3 |
| 6911 |
|
| 6912 |
}, 16, ["id", "modelValue", "disabled", "aria-controls", "aria-expanded", "onKeydown"]), |
| 6913 |
createElementVNode("div", _hoisted_1$b, [ |
| 6914 |
createVNode(_component_cdx_menu, mergeProps({ |
| 6915 |
id: _ctx.menuId, |
| 6916 |
ref: "menu", |
| 6917 |
selected: _ctx.modelWrapper, |
| 6918 |
"onUpdate:selected": _cache[2] || (_cache[2] = ($event) => _ctx.modelWrapper = $event), |
| 6919 |
expanded: _ctx.expanded, |
| 6920 |
"onUpdate:expanded": _cache[3] || (_cache[3] = ($event) => _ctx.expanded = $event), |
| 6921 |
"menu-items": _ctx.menuItems |
| 6922 |
}, _ctx.menuConfig, { |
| 6923 |
role: "menu", |
| 6924 |
"aria-labelledby": _ctx.toggleId |
| 6925 |
}), null, 16, ["id", "selected", "expanded", "menu-items", "aria-labelledby"]) |
| 6926 |
]) |
| 6927 |
], |
| 6928 |
6 |
| 6929 |
|
| 6930 |
); |
| 6931 |
} |
| 6932 |
const MenuButton = _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]); |
| 6933 |
const statusValidator$4 = makeStringTypeValidator(ValidationStatusTypes); |
| 6934 |
const _sfc_main$b = defineComponent({ |
| 6935 |
name: "CdxMultiselectLookup", |
| 6936 |
components: { |
| 6937 |
CdxChipInput, |
| 6938 |
CdxMenu |
| 6939 |
}, |
| 6940 |
props: { |
| 6941 |
|
| 6942 |
|
| 6943 |
|
| 6944 |
|
| 6945 |
|
| 6946 |
|
| 6947 |
|
| 6948 |
inputChips: { |
| 6949 |
type: Array, |
| 6950 |
required: true |
| 6951 |
}, |
| 6952 |
|
| 6953 |
|
| 6954 |
|
| 6955 |
|
| 6956 |
|
| 6957 |
|
| 6958 |
selected: { |
| 6959 |
type: [Array], |
| 6960 |
required: true |
| 6961 |
}, |
| 6962 |
|
| 6963 |
|
| 6964 |
|
| 6965 |
|
| 6966 |
|
| 6967 |
menuItems: { |
| 6968 |
type: Array, |
| 6969 |
required: true |
| 6970 |
}, |
| 6971 |
|
| 6972 |
|
| 6973 |
|
| 6974 |
|
| 6975 |
|
| 6976 |
|
| 6977 |
inputValue: { |
| 6978 |
type: [String, Number], |
| 6979 |
default: null |
| 6980 |
}, |
| 6981 |
|
| 6982 |
|
| 6983 |
|
| 6984 |
|
| 6985 |
|
| 6986 |
separateInput: { |
| 6987 |
type: Boolean, |
| 6988 |
default: false |
| 6989 |
}, |
| 6990 |
|
| 6991 |
|
| 6992 |
|
| 6993 |
disabled: { |
| 6994 |
type: Boolean, |
| 6995 |
default: false |
| 6996 |
}, |
| 6997 |
|
| 6998 |
|
| 6999 |
|
| 7000 |
status: { |
| 7001 |
type: String, |
| 7002 |
default: "default", |
| 7003 |
validator: statusValidator$4 |
| 7004 |
}, |
| 7005 |
|
| 7006 |
|
| 7007 |
|
| 7008 |
|
| 7009 |
|
| 7010 |
|
| 7011 |
menuConfig: { |
| 7012 |
type: Object, |
| 7013 |
default: () => { |
| 7014 |
return {}; |
| 7015 |
} |
| 7016 |
} |
| 7017 |
}, |
| 7018 |
emits: [ |
| 7019 |
|
| 7020 |
|
| 7021 |
|
| 7022 |
|
| 7023 |
|
| 7024 |
"update:input-chips", |
| 7025 |
|
| 7026 |
|
| 7027 |
|
| 7028 |
|
| 7029 |
|
| 7030 |
"update:selected", |
| 7031 |
|
| 7032 |
|
| 7033 |
|
| 7034 |
|
| 7035 |
|
| 7036 |
|
| 7037 |
|
| 7038 |
|
| 7039 |
"update:input-value", |
| 7040 |
|
| 7041 |
|
| 7042 |
|
| 7043 |
|
| 7044 |
|
| 7045 |
|
| 7046 |
"load-more", |
| 7047 |
|
| 7048 |
|
| 7049 |
|
| 7050 |
|
| 7051 |
|
| 7052 |
|
| 7053 |
"input", |
| 7054 |
|
| 7055 |
|
| 7056 |
|
| 7057 |
|
| 7058 |
|
| 7059 |
"change", |
| 7060 |
|
| 7061 |
|
| 7062 |
|
| 7063 |
|
| 7064 |
|
| 7065 |
"focus", |
| 7066 |
|
| 7067 |
|
| 7068 |
|
| 7069 |
|
| 7070 |
|
| 7071 |
"blur" |
| 7072 |
], |
| 7073 |
setup: (props, { emit, attrs, slots }) => { |
| 7074 |
const chipInput = ref(); |
| 7075 |
const menu = ref(); |
| 7076 |
const menuId = useGeneratedId("multiselect-lookup-menu"); |
| 7077 |
const highlightedId = computed(() => { |
| 7078 |
var _a, _b; |
| 7079 |
return (_b = (_a = menu.value) == null ? void 0 : _a.getHighlightedMenuItem()) == null ? void 0 : _b.id; |
| 7080 |
}); |
| 7081 |
const pending = ref(false); |
| 7082 |
const expanded = ref(false); |
| 7083 |
const isActive = ref(false); |
| 7084 |
provide(AllowArbitraryKey, ref(false)); |
| 7085 |
const { |
| 7086 |
computedDisabled, |
| 7087 |
computedStatus |
| 7088 |
} = useFieldData( |
| 7089 |
toRef(props, "disabled"), |
| 7090 |
toRef(props, "status") |
| 7091 |
); |
| 7092 |
const internalClasses = computed(() => { |
| 7093 |
return { |
| 7094 |
"cdx-multiselect-lookup--disabled": computedDisabled.value, |
| 7095 |
"cdx-multiselect-lookup--pending": pending.value |
| 7096 |
}; |
| 7097 |
}); |
| 7098 |
const { |
| 7099 |
rootClasses, |
| 7100 |
rootStyle, |
| 7101 |
otherAttrs |
| 7102 |
} = useSplitAttributes(attrs, internalClasses); |
| 7103 |
useFloatingMenu(chipInput, menu); |
| 7104 |
const selectedWrapper = useModelWrapper(toRef(props, "selected"), emit, "update:selected"); |
| 7105 |
const inputChipsWrapper = useModelWrapper(toRef(props, "inputChips"), emit, "update:input-chips"); |
| 7106 |
const internalInputValue = ref(""); |
| 7107 |
const computedInputValue = useOptionalModelWrapper( |
| 7108 |
internalInputValue, |
| 7109 |
toRef(props, "inputValue"), |
| 7110 |
emit, |
| 7111 |
"update:input-value" |
| 7112 |
); |
| 7113 |
const showNoResults = computed(() => computedInputValue.value.toString().length > 0 && slots["no-results"]); |
| 7114 |
function onUpdateInputValue(newVal) { |
| 7115 |
return __async(this, null, function* () { |
| 7116 |
yield nextTick(); |
| 7117 |
pending.value = newVal !== null && newVal !== ""; |
| 7118 |
emit("input", newVal); |
| 7119 |
}); |
| 7120 |
} |
| 7121 |
function onInputFocus(event) { |
| 7122 |
isActive.value = true; |
| 7123 |
if (props.menuItems.length > 0 || showNoResults.value) { |
| 7124 |
expanded.value = true; |
| 7125 |
} |
| 7126 |
emit("focus", event); |
| 7127 |
} |
| 7128 |
function onInputBlur(event) { |
| 7129 |
isActive.value = false; |
| 7130 |
expanded.value = false; |
| 7131 |
emit("blur", event); |
| 7132 |
} |
| 7133 |
function onKeydown(e) { |
| 7134 |
if (!menu.value || computedDisabled.value || props.menuItems.length === 0 && !showNoResults.value || e.key === " ") { |
| 7135 |
return; |
| 7136 |
} |
| 7137 |
menu.value.delegateKeyNavigation(e); |
| 7138 |
} |
| 7139 |
watch(toRef(props, "selected"), (newVal) => { |
| 7140 |
const newSelections = newVal.filter((selection) => inputChipsWrapper.value.find((chip) => selection === chip.value) === void 0); |
| 7141 |
if (newSelections.length > 0) { |
| 7142 |
newSelections.forEach((newSelection) => { |
| 7143 |
const newMenuItem = props.menuItems.find((menuItem) => menuItem.value === newSelection); |
| 7144 |
if (newMenuItem) { |
| 7145 |
inputChipsWrapper.value.push(newMenuItem); |
| 7146 |
} |
| 7147 |
}); |
| 7148 |
computedInputValue.value = ""; |
| 7149 |
emit("input", ""); |
| 7150 |
} |
| 7151 |
inputChipsWrapper.value = inputChipsWrapper.value.filter((chip) => { |
| 7152 |
return newVal.find((selection) => chip.value === selection) !== void 0; |
| 7153 |
}); |
| 7154 |
}); |
| 7155 |
watch(toRef(props, "inputChips"), (newVal) => { |
| 7156 |
if (newVal.length < selectedWrapper.value.length) { |
| 7157 |
selectedWrapper.value = newVal.map((chip) => chip.value); |
| 7158 |
} |
| 7159 |
}); |
| 7160 |
watch(toRef(props, "menuItems"), (newVal) => { |
| 7161 |
if (newVal.length === 0 && !showNoResults.value) { |
| 7162 |
expanded.value = false; |
| 7163 |
} else if (isActive.value && pending.value) { |
| 7164 |
expanded.value = true; |
| 7165 |
} |
| 7166 |
pending.value = false; |
| 7167 |
}); |
| 7168 |
return { |
| 7169 |
chipInput, |
| 7170 |
menu, |
| 7171 |
menuId, |
| 7172 |
highlightedId, |
| 7173 |
expanded, |
| 7174 |
computedDisabled, |
| 7175 |
computedStatus, |
| 7176 |
rootClasses, |
| 7177 |
rootStyle, |
| 7178 |
otherAttrs, |
| 7179 |
selectedWrapper, |
| 7180 |
inputChipsWrapper, |
| 7181 |
computedInputValue, |
| 7182 |
onUpdateInputValue, |
| 7183 |
onInputBlur, |
| 7184 |
onInputFocus, |
| 7185 |
onKeydown |
| 7186 |
}; |
| 7187 |
} |
| 7188 |
}); |
| 7189 |
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) { |
| 7190 |
const _component_cdx_chip_input = resolveComponent("cdx-chip-input"); |
| 7191 |
const _component_cdx_menu = resolveComponent("cdx-menu"); |
| 7192 |
return openBlock(), createElementBlock( |
| 7193 |
"div", |
| 7194 |
{ |
| 7195 |
class: normalizeClass(["cdx-multiselect-lookup", _ctx.rootClasses]), |
| 7196 |
style: normalizeStyle(_ctx.rootStyle) |
| 7197 |
}, |
| 7198 |
[ |
| 7199 |
createVNode(_component_cdx_chip_input, mergeProps({ |
| 7200 |
ref: "chipInput", |
| 7201 |
"input-chips": _ctx.inputChipsWrapper, |
| 7202 |
"onUpdate:inputChips": _cache[0] || (_cache[0] = ($event) => _ctx.inputChipsWrapper = $event), |
| 7203 |
"input-value": _ctx.computedInputValue, |
| 7204 |
"onUpdate:inputValue": _cache[1] || (_cache[1] = ($event) => _ctx.computedInputValue = $event) |
| 7205 |
}, _ctx.otherAttrs, { |
| 7206 |
class: "cdx-multiselect-lookup__chip-input", |
| 7207 |
role: "combobox", |
| 7208 |
autocomplete: "off", |
| 7209 |
"aria-autocomplete": "list", |
| 7210 |
"aria-controls": _ctx.menuId, |
| 7211 |
"aria-expanded": _ctx.expanded, |
| 7212 |
"aria-activedescendant": _ctx.highlightedId, |
| 7213 |
"separate-input": _ctx.separateInput, |
| 7214 |
disabled: _ctx.computedDisabled, |
| 7215 |
status: _ctx.computedStatus, |
| 7216 |
"disallow-arbitrary": true, |
| 7217 |
"onUpdate:inputValue": _ctx.onUpdateInputValue, |
| 7218 |
onFocus: _ctx.onInputFocus, |
| 7219 |
onBlur: _ctx.onInputBlur, |
| 7220 |
onKeydown: _ctx.onKeydown |
| 7221 |
}), null, 16, ["input-chips", "input-value", "aria-controls", "aria-expanded", "aria-activedescendant", "separate-input", "disabled", "status", "onUpdate:inputValue", "onFocus", "onBlur", "onKeydown"]), |
| 7222 |
createVNode(_component_cdx_menu, mergeProps({ |
| 7223 |
id: _ctx.menuId, |
| 7224 |
ref: "menu", |
| 7225 |
selected: _ctx.selectedWrapper, |
| 7226 |
"onUpdate:selected": _cache[2] || (_cache[2] = ($event) => _ctx.selectedWrapper = $event), |
| 7227 |
expanded: _ctx.expanded, |
| 7228 |
"onUpdate:expanded": _cache[3] || (_cache[3] = ($event) => _ctx.expanded = $event), |
| 7229 |
"menu-items": _ctx.menuItems |
| 7230 |
}, _ctx.menuConfig, { |
| 7231 |
onLoadMore: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("load-more")) |
| 7232 |
}), { |
| 7233 |
default: withCtx(({ menuItem }) => [ |
| 7234 |
renderSlot(_ctx.$slots, "menu-item", { menuItem }) |
| 7235 |
]), |
| 7236 |
"no-results": withCtx(() => [ |
| 7237 |
renderSlot(_ctx.$slots, "no-results") |
| 7238 |
]), |
| 7239 |
_: 3 |
| 7240 |
|
| 7241 |
}, 16, ["id", "selected", "expanded", "menu-items"]) |
| 7242 |
], |
| 7243 |
6 |
| 7244 |
|
| 7245 |
); |
| 7246 |
} |
| 7247 |
const MultiselectLookup = _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]); |
| 7248 |
const statusValidator$3 = makeStringTypeValidator(ValidationStatusTypes); |
| 7249 |
const _sfc_main$a = defineComponent({ |
| 7250 |
name: "CdxRadio", |
| 7251 |
components: { CdxLabel }, |
| 7252 |
props: { |
| 7253 |
|
| 7254 |
|
| 7255 |
|
| 7256 |
|
| 7257 |
|
| 7258 |
modelValue: { |
| 7259 |
type: [String, Number, Boolean], |
| 7260 |
default: "" |
| 7261 |
}, |
| 7262 |
|
| 7263 |
|
| 7264 |
|
| 7265 |
|
| 7266 |
|
| 7267 |
inputValue: { |
| 7268 |
type: [String, Number, Boolean], |
| 7269 |
default: false |
| 7270 |
}, |
| 7271 |
|
| 7272 |
|
| 7273 |
|
| 7274 |
name: { |
| 7275 |
type: String, |
| 7276 |
required: true |
| 7277 |
}, |
| 7278 |
|
| 7279 |
|
| 7280 |
|
| 7281 |
disabled: { |
| 7282 |
type: Boolean, |
| 7283 |
default: false |
| 7284 |
}, |
| 7285 |
|
| 7286 |
|
| 7287 |
|
| 7288 |
|
| 7289 |
|
| 7290 |
|
| 7291 |
inline: { |
| 7292 |
type: Boolean, |
| 7293 |
default: false |
| 7294 |
}, |
| 7295 |
|
| 7296 |
|
| 7297 |
|
| 7298 |
status: { |
| 7299 |
type: String, |
| 7300 |
default: "default", |
| 7301 |
validator: statusValidator$3 |
| 7302 |
} |
| 7303 |
}, |
| 7304 |
emits: [ |
| 7305 |
|
| 7306 |
|
| 7307 |
|
| 7308 |
|
| 7309 |
|
| 7310 |
"update:modelValue" |
| 7311 |
], |
| 7312 |
setup(props, { emit, slots, attrs }) { |
| 7313 |
var _a; |
| 7314 |
useLabelChecker((_a = slots.default) == null ? void 0 : _a.call(slots), attrs, "CdxRadio"); |
| 7315 |
const { |
| 7316 |
computedDisabled, |
| 7317 |
computedStatus |
| 7318 |
} = useFieldData( |
| 7319 |
toRef(props, "disabled"), |
| 7320 |
toRef(props, "status") |
| 7321 |
); |
| 7322 |
const rootClasses = computed(() => { |
| 7323 |
return { |
| 7324 |
"cdx-radio--inline": props.inline, |
| 7325 |
["cdx-radio--status-".concat(computedStatus.value)]: true |
| 7326 |
}; |
| 7327 |
}); |
| 7328 |
const customInputClasses = computed(() => { |
| 7329 |
return { |
| 7330 |
"cdx-radio__custom-input--inline": props.inline |
| 7331 |
}; |
| 7332 |
}); |
| 7333 |
const input = ref(); |
| 7334 |
const radioId = useGeneratedId("radio"); |
| 7335 |
const descriptionId = useGeneratedId("description"); |
| 7336 |
const focusInput = () => { |
| 7337 |
input.value.focus(); |
| 7338 |
}; |
| 7339 |
const wrappedModel = useModelWrapper(toRef(props, "modelValue"), emit); |
| 7340 |
return { |
| 7341 |
rootClasses, |
| 7342 |
computedDisabled, |
| 7343 |
input, |
| 7344 |
radioId, |
| 7345 |
descriptionId, |
| 7346 |
focusInput, |
| 7347 |
wrappedModel, |
| 7348 |
customInputClasses |
| 7349 |
}; |
| 7350 |
} |
| 7351 |
}); |
| 7352 |
const _hoisted_1$a = { class: "cdx-radio__wrapper" }; |
| 7353 |
const _hoisted_2$6 = ["id", "aria-describedby", "name", "value", "disabled"]; |
| 7354 |
const _hoisted_3$4 = createElementVNode( |
| 7355 |
"span", |
| 7356 |
{ class: "cdx-radio__icon" }, |
| 7357 |
null, |
| 7358 |
-1 |
| 7359 |
|
| 7360 |
); |
| 7361 |
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) { |
| 7362 |
const _component_cdx_label = resolveComponent("cdx-label"); |
| 7363 |
return openBlock(), createElementBlock( |
| 7364 |
"div", |
| 7365 |
{ |
| 7366 |
class: normalizeClass(["cdx-radio", _ctx.rootClasses]) |
| 7367 |
}, |
| 7368 |
[ |
| 7369 |
createElementVNode("div", _hoisted_1$a, [ |
| 7370 |
withDirectives(createElementVNode("input", { |
| 7371 |
id: _ctx.radioId, |
| 7372 |
ref: "input", |
| 7373 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedModel = $event), |
| 7374 |
class: "cdx-radio__input", |
| 7375 |
type: "radio", |
| 7376 |
"aria-describedby": _ctx.$slots.description && _ctx.$slots.description().length > 0 ? _ctx.descriptionId : void 0, |
| 7377 |
name: _ctx.name, |
| 7378 |
value: _ctx.inputValue, |
| 7379 |
disabled: _ctx.computedDisabled |
| 7380 |
}, null, 8, _hoisted_2$6), [ |
| 7381 |
[vModelRadio, _ctx.wrappedModel] |
| 7382 |
]), |
| 7383 |
_hoisted_3$4, |
| 7384 |
_ctx.$slots.default && _ctx.$slots.default().length ? (openBlock(), createBlock(_component_cdx_label, { |
| 7385 |
key: 0, |
| 7386 |
class: "cdx-radio__label", |
| 7387 |
"input-id": _ctx.radioId, |
| 7388 |
"description-id": _ctx.$slots.description && _ctx.$slots.description().length > 0 ? _ctx.descriptionId : void 0, |
| 7389 |
disabled: _ctx.computedDisabled, |
| 7390 |
onClick: _ctx.focusInput |
| 7391 |
}, createSlots({ |
| 7392 |
default: withCtx(() => [ |
| 7393 |
renderSlot(_ctx.$slots, "default") |
| 7394 |
]), |
| 7395 |
_: 2 |
| 7396 |
|
| 7397 |
}, [ |
| 7398 |
_ctx.$slots.description && _ctx.$slots.description().length > 0 ? { |
| 7399 |
name: "description", |
| 7400 |
fn: withCtx(() => [ |
| 7401 |
renderSlot(_ctx.$slots, "description") |
| 7402 |
]), |
| 7403 |
key: "0" |
| 7404 |
} : void 0 |
| 7405 |
]), 1032, ["input-id", "description-id", "disabled", "onClick"])) : createCommentVNode("v-if", true) |
| 7406 |
]), |
| 7407 |
_ctx.$slots["custom-input"] ? (openBlock(), createElementBlock( |
| 7408 |
"div", |
| 7409 |
{ |
| 7410 |
key: 0, |
| 7411 |
class: normalizeClass(["cdx-radio__custom-input", _ctx.customInputClasses]) |
| 7412 |
}, |
| 7413 |
[ |
| 7414 |
renderSlot(_ctx.$slots, "custom-input") |
| 7415 |
], |
| 7416 |
2 |
| 7417 |
|
| 7418 |
)) : createCommentVNode("v-if", true) |
| 7419 |
], |
| 7420 |
2 |
| 7421 |
|
| 7422 |
); |
| 7423 |
} |
| 7424 |
const Radio = _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]); |
| 7425 |
const statusValidator$2 = makeStringTypeValidator(ValidationStatusTypes); |
| 7426 |
const _sfc_main$9 = defineComponent({ |
| 7427 |
name: "CdxSearchInput", |
| 7428 |
components: { |
| 7429 |
CdxButton, |
| 7430 |
CdxTextInput |
| 7431 |
}, |
| 7432 |
|
| 7433 |
|
| 7434 |
|
| 7435 |
inheritAttrs: false, |
| 7436 |
props: { |
| 7437 |
|
| 7438 |
|
| 7439 |
|
| 7440 |
modelValue: { |
| 7441 |
type: [String, Number], |
| 7442 |
default: "" |
| 7443 |
}, |
| 7444 |
|
| 7445 |
|
| 7446 |
|
| 7447 |
|
| 7448 |
useButton: { |
| 7449 |
type: Boolean, |
| 7450 |
default: false |
| 7451 |
}, |
| 7452 |
|
| 7453 |
|
| 7454 |
|
| 7455 |
|
| 7456 |
|
| 7457 |
|
| 7458 |
buttonLabel: { |
| 7459 |
type: String, |
| 7460 |
default: "" |
| 7461 |
}, |
| 7462 |
|
| 7463 |
|
| 7464 |
|
| 7465 |
disabled: { |
| 7466 |
type: Boolean, |
| 7467 |
default: false |
| 7468 |
}, |
| 7469 |
|
| 7470 |
|
| 7471 |
|
| 7472 |
status: { |
| 7473 |
type: String, |
| 7474 |
default: "default", |
| 7475 |
validator: statusValidator$2 |
| 7476 |
} |
| 7477 |
}, |
| 7478 |
emits: [ |
| 7479 |
|
| 7480 |
|
| 7481 |
|
| 7482 |
|
| 7483 |
|
| 7484 |
"update:modelValue", |
| 7485 |
|
| 7486 |
|
| 7487 |
|
| 7488 |
|
| 7489 |
|
| 7490 |
"submit-click", |
| 7491 |
|
| 7492 |
|
| 7493 |
|
| 7494 |
|
| 7495 |
|
| 7496 |
"input", |
| 7497 |
|
| 7498 |
|
| 7499 |
|
| 7500 |
|
| 7501 |
|
| 7502 |
"change", |
| 7503 |
|
| 7504 |
|
| 7505 |
|
| 7506 |
|
| 7507 |
|
| 7508 |
"focus", |
| 7509 |
|
| 7510 |
|
| 7511 |
|
| 7512 |
|
| 7513 |
|
| 7514 |
"blur" |
| 7515 |
], |
| 7516 |
setup(props, { emit, attrs }) { |
| 7517 |
const wrappedModel = useModelWrapper(toRef(props, "modelValue"), emit); |
| 7518 |
const { computedDisabled } = useFieldData(toRef(props, "disabled")); |
| 7519 |
const internalClasses = computed(() => { |
| 7520 |
return { |
| 7521 |
"cdx-search-input--has-end-button": !!props.buttonLabel || props.useButton |
| 7522 |
}; |
| 7523 |
}); |
| 7524 |
const { |
| 7525 |
rootClasses, |
| 7526 |
rootStyle, |
| 7527 |
otherAttrs |
| 7528 |
} = useSplitAttributes(attrs, internalClasses); |
| 7529 |
const translatedSearchButtonLabel = useI18nWithOverride( |
| 7530 |
toRef(props, "buttonLabel"), |
| 7531 |
"cdx-search-input-search-button-label", |
| 7532 |
|
| 7533 |
"Search" |
| 7534 |
); |
| 7535 |
const useButtonOrLabel = computed( |
| 7536 |
() => props.useButton || props.buttonLabel.length > 0 |
| 7537 |
); |
| 7538 |
const handleSubmit = () => { |
| 7539 |
emit("submit-click", wrappedModel.value); |
| 7540 |
}; |
| 7541 |
return { |
| 7542 |
wrappedModel, |
| 7543 |
computedDisabled, |
| 7544 |
rootClasses, |
| 7545 |
rootStyle, |
| 7546 |
otherAttrs, |
| 7547 |
handleSubmit, |
| 7548 |
searchIcon: A7, |
| 7549 |
translatedSearchButtonLabel, |
| 7550 |
useButtonOrLabel |
| 7551 |
}; |
| 7552 |
}, |
| 7553 |
methods: { |
| 7554 |
|
| 7555 |
|
| 7556 |
|
| 7557 |
|
| 7558 |
|
| 7559 |
focus() { |
| 7560 |
const textInput = this.$refs.textInput; |
| 7561 |
textInput.focus(); |
| 7562 |
} |
| 7563 |
} |
| 7564 |
}); |
| 7565 |
const _hoisted_1$9 = { class: "cdx-search-input__input-wrapper" }; |
| 7566 |
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) { |
| 7567 |
const _component_cdx_text_input = resolveComponent("cdx-text-input"); |
| 7568 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 7569 |
return openBlock(), createElementBlock( |
| 7570 |
"div", |
| 7571 |
{ |
| 7572 |
class: normalizeClass(["cdx-search-input", _ctx.rootClasses]), |
| 7573 |
style: normalizeStyle(_ctx.rootStyle) |
| 7574 |
}, |
| 7575 |
[ |
| 7576 |
createElementVNode("div", _hoisted_1$9, [ |
| 7577 |
createVNode(_component_cdx_text_input, mergeProps({ |
| 7578 |
ref: "textInput", |
| 7579 |
modelValue: _ctx.wrappedModel, |
| 7580 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedModel = $event), |
| 7581 |
class: "cdx-search-input__text-input", |
| 7582 |
"input-type": "search", |
| 7583 |
"start-icon": _ctx.searchIcon, |
| 7584 |
disabled: _ctx.computedDisabled, |
| 7585 |
status: _ctx.status |
| 7586 |
}, _ctx.otherAttrs, { |
| 7587 |
onKeydown: withKeys(_ctx.handleSubmit, ["enter"]), |
| 7588 |
onInput: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("input", $event)), |
| 7589 |
onChange: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("change", $event)), |
| 7590 |
onFocus: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("focus", $event)), |
| 7591 |
onBlur: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("blur", $event)) |
| 7592 |
}), null, 16, ["modelValue", "start-icon", "disabled", "status", "onKeydown"]), |
| 7593 |
renderSlot(_ctx.$slots, "default") |
| 7594 |
]), |
| 7595 |
_ctx.useButtonOrLabel ? (openBlock(), createBlock(_component_cdx_button, { |
| 7596 |
key: 0, |
| 7597 |
class: "cdx-search-input__end-button", |
| 7598 |
disabled: _ctx.computedDisabled, |
| 7599 |
onClick: _ctx.handleSubmit |
| 7600 |
}, { |
| 7601 |
default: withCtx(() => [ |
| 7602 |
createTextVNode( |
| 7603 |
toDisplayString(_ctx.translatedSearchButtonLabel), |
| 7604 |
1 |
| 7605 |
|
| 7606 |
) |
| 7607 |
]), |
| 7608 |
_: 1 |
| 7609 |
|
| 7610 |
}, 8, ["disabled", "onClick"])) : createCommentVNode("v-if", true) |
| 7611 |
], |
| 7612 |
6 |
| 7613 |
|
| 7614 |
); |
| 7615 |
} |
| 7616 |
const CdxSearchInput = _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]); |
| 7617 |
const statusValidator$1 = makeStringTypeValidator(ValidationStatusTypes); |
| 7618 |
const _sfc_main$8 = defineComponent({ |
| 7619 |
name: "CdxSelect", |
| 7620 |
components: { |
| 7621 |
CdxIcon, |
| 7622 |
CdxMenu |
| 7623 |
}, |
| 7624 |
|
| 7625 |
|
| 7626 |
|
| 7627 |
inheritAttrs: false, |
| 7628 |
props: { |
| 7629 |
|
| 7630 |
|
| 7631 |
|
| 7632 |
menuItems: { |
| 7633 |
type: Array, |
| 7634 |
required: true |
| 7635 |
}, |
| 7636 |
|
| 7637 |
|
| 7638 |
|
| 7639 |
|
| 7640 |
|
| 7641 |
|
| 7642 |
|
| 7643 |
selected: { |
| 7644 |
type: [String, Number, null], |
| 7645 |
required: true |
| 7646 |
}, |
| 7647 |
|
| 7648 |
|
| 7649 |
|
| 7650 |
defaultLabel: { |
| 7651 |
type: String, |
| 7652 |
default: "" |
| 7653 |
}, |
| 7654 |
|
| 7655 |
|
| 7656 |
|
| 7657 |
disabled: { |
| 7658 |
type: Boolean, |
| 7659 |
default: false |
| 7660 |
}, |
| 7661 |
|
| 7662 |
|
| 7663 |
|
| 7664 |
|
| 7665 |
|
| 7666 |
|
| 7667 |
menuConfig: { |
| 7668 |
type: Object, |
| 7669 |
default: () => { |
| 7670 |
return {}; |
| 7671 |
} |
| 7672 |
}, |
| 7673 |
|
| 7674 |
|
| 7675 |
|
| 7676 |
|
| 7677 |
defaultIcon: { |
| 7678 |
type: [String, Object], |
| 7679 |
default: void 0 |
| 7680 |
}, |
| 7681 |
|
| 7682 |
|
| 7683 |
|
| 7684 |
status: { |
| 7685 |
type: String, |
| 7686 |
default: "default", |
| 7687 |
validator: statusValidator$1 |
| 7688 |
} |
| 7689 |
}, |
| 7690 |
emits: [ |
| 7691 |
|
| 7692 |
|
| 7693 |
|
| 7694 |
|
| 7695 |
|
| 7696 |
"update:selected", |
| 7697 |
|
| 7698 |
|
| 7699 |
|
| 7700 |
|
| 7701 |
|
| 7702 |
|
| 7703 |
"load-more" |
| 7704 |
], |
| 7705 |
setup(props, { emit, attrs }) { |
| 7706 |
const handle = ref(); |
| 7707 |
const menu = ref(); |
| 7708 |
const descriptionId = inject(FieldDescriptionIdKey, void 0); |
| 7709 |
const menuId = useGeneratedId("select-menu"); |
| 7710 |
const expanded = ref(false); |
| 7711 |
const handleId = attrs.id || useGeneratedId("select-handle"); |
| 7712 |
const { |
| 7713 |
computedDisabled, |
| 7714 |
computedStatus, |
| 7715 |
computedInputId: computedHandleId |
| 7716 |
} = useFieldData( |
| 7717 |
toRef(props, "disabled"), |
| 7718 |
toRef(props, "status"), |
| 7719 |
handleId |
| 7720 |
); |
| 7721 |
const modelWrapper = useModelWrapper(toRef(props, "selected"), emit, "update:selected"); |
| 7722 |
const selectedMenuItem = computed( |
| 7723 |
() => props.menuItems.find((menuItem) => menuItem.value === props.selected) |
| 7724 |
); |
| 7725 |
const currentLabel = computed(() => { |
| 7726 |
var _a; |
| 7727 |
return selectedMenuItem.value ? (_a = selectedMenuItem.value.label) != null ? _a : selectedMenuItem.value.value : props.defaultLabel; |
| 7728 |
}); |
| 7729 |
const startIcon = computed(() => { |
| 7730 |
var _a; |
| 7731 |
if (props.defaultIcon && !selectedMenuItem.value) { |
| 7732 |
return props.defaultIcon; |
| 7733 |
} else if ((_a = selectedMenuItem.value) == null ? void 0 : _a.icon) { |
| 7734 |
return selectedMenuItem.value.icon; |
| 7735 |
} |
| 7736 |
return void 0; |
| 7737 |
}); |
| 7738 |
const internalClasses = computed(() => { |
| 7739 |
return { |
| 7740 |
"cdx-select-vue--enabled": !computedDisabled.value, |
| 7741 |
"cdx-select-vue--disabled": computedDisabled.value, |
| 7742 |
"cdx-select-vue--expanded": expanded.value, |
| 7743 |
"cdx-select-vue--value-selected": !!selectedMenuItem.value, |
| 7744 |
"cdx-select-vue--no-selections": !selectedMenuItem.value, |
| 7745 |
"cdx-select-vue--has-start-icon": !!startIcon.value, |
| 7746 |
["cdx-select-vue--status-".concat(computedStatus.value)]: true |
| 7747 |
}; |
| 7748 |
}); |
| 7749 |
const { |
| 7750 |
rootClasses, |
| 7751 |
rootStyle, |
| 7752 |
otherAttrs |
| 7753 |
} = useSplitAttributes(attrs, internalClasses); |
| 7754 |
const otherAttrsMinusId = computed(() => { |
| 7755 |
const _a = otherAttrs.value, { id } = _a, everythingElse = __objRest(_a, ["id"]); |
| 7756 |
return everythingElse; |
| 7757 |
}); |
| 7758 |
const highlightedId = computed(() => { |
| 7759 |
var _a, _b; |
| 7760 |
return (_b = (_a = menu.value) == null ? void 0 : _a.getHighlightedMenuItem()) == null ? void 0 : _b.id; |
| 7761 |
}); |
| 7762 |
function onBlur() { |
| 7763 |
expanded.value = false; |
| 7764 |
} |
| 7765 |
function onClick() { |
| 7766 |
var _a; |
| 7767 |
if (computedDisabled.value) { |
| 7768 |
return; |
| 7769 |
} |
| 7770 |
expanded.value = !expanded.value; |
| 7771 |
(_a = handle.value) == null ? void 0 : _a.focus(); |
| 7772 |
} |
| 7773 |
function onKeydown(e) { |
| 7774 |
var _a; |
| 7775 |
if (computedDisabled.value) { |
| 7776 |
return; |
| 7777 |
} |
| 7778 |
(_a = menu.value) == null ? void 0 : _a.delegateKeyNavigation(e, { characterNavigation: true }); |
| 7779 |
} |
| 7780 |
useFloatingMenu(handle, menu); |
| 7781 |
return { |
| 7782 |
handle, |
| 7783 |
menu, |
| 7784 |
computedHandleId, |
| 7785 |
descriptionId, |
| 7786 |
menuId, |
| 7787 |
modelWrapper, |
| 7788 |
selectedMenuItem, |
| 7789 |
highlightedId, |
| 7790 |
expanded, |
| 7791 |
computedDisabled, |
| 7792 |
onBlur, |
| 7793 |
currentLabel, |
| 7794 |
rootClasses, |
| 7795 |
rootStyle, |
| 7796 |
otherAttrsMinusId, |
| 7797 |
onClick, |
| 7798 |
onKeydown, |
| 7799 |
startIcon, |
| 7800 |
cdxIconExpand: m4 |
| 7801 |
}; |
| 7802 |
} |
| 7803 |
}); |
| 7804 |
const _hoisted_1$8 = ["aria-disabled"]; |
| 7805 |
const _hoisted_2$5 = ["id", "aria-controls", "aria-activedescendant", "aria-expanded", "aria-describedby"]; |
| 7806 |
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) { |
| 7807 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 7808 |
const _component_cdx_menu = resolveComponent("cdx-menu"); |
| 7809 |
return openBlock(), createElementBlock("div", { |
| 7810 |
class: normalizeClass(["cdx-select-vue", _ctx.rootClasses]), |
| 7811 |
style: normalizeStyle(_ctx.rootStyle), |
| 7812 |
"aria-disabled": _ctx.computedDisabled |
| 7813 |
}, [ |
| 7814 |
createElementVNode("div", mergeProps({ |
| 7815 |
id: _ctx.computedHandleId, |
| 7816 |
ref: "handle", |
| 7817 |
class: "cdx-select-vue__handle" |
| 7818 |
}, _ctx.otherAttrsMinusId, { |
| 7819 |
tabindex: "0", |
| 7820 |
role: "combobox", |
| 7821 |
"aria-controls": _ctx.menuId, |
| 7822 |
"aria-activedescendant": _ctx.highlightedId, |
| 7823 |
"aria-expanded": _ctx.expanded, |
| 7824 |
"aria-describedby": _ctx.descriptionId, |
| 7825 |
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args)), |
| 7826 |
onBlur: _cache[1] || (_cache[1] = (...args) => _ctx.onBlur && _ctx.onBlur(...args)), |
| 7827 |
onKeydown: _cache[2] || (_cache[2] = (...args) => _ctx.onKeydown && _ctx.onKeydown(...args)) |
| 7828 |
}), [ |
| 7829 |
renderSlot(_ctx.$slots, "label", { |
| 7830 |
selectedMenuItem: _ctx.selectedMenuItem, |
| 7831 |
defaultLabel: _ctx.defaultLabel |
| 7832 |
}, () => [ |
| 7833 |
createTextVNode( |
| 7834 |
toDisplayString(_ctx.currentLabel), |
| 7835 |
1 |
| 7836 |
|
| 7837 |
) |
| 7838 |
]), |
| 7839 |
_ctx.startIcon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 7840 |
key: 0, |
| 7841 |
icon: _ctx.startIcon, |
| 7842 |
class: "cdx-select-vue__start-icon" |
| 7843 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 7844 |
createVNode(_component_cdx_icon, { |
| 7845 |
icon: _ctx.cdxIconExpand, |
| 7846 |
class: "cdx-select-vue__indicator" |
| 7847 |
}, null, 8, ["icon"]) |
| 7848 |
], 16, _hoisted_2$5), |
| 7849 |
createVNode(_component_cdx_menu, mergeProps({ |
| 7850 |
id: _ctx.menuId, |
| 7851 |
ref: "menu", |
| 7852 |
selected: _ctx.modelWrapper, |
| 7853 |
"onUpdate:selected": _cache[3] || (_cache[3] = ($event) => _ctx.modelWrapper = $event), |
| 7854 |
expanded: _ctx.expanded, |
| 7855 |
"onUpdate:expanded": _cache[4] || (_cache[4] = ($event) => _ctx.expanded = $event), |
| 7856 |
"menu-items": _ctx.menuItems |
| 7857 |
}, _ctx.menuConfig, { |
| 7858 |
onLoadMore: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("load-more")) |
| 7859 |
}), { |
| 7860 |
default: withCtx(({ menuItem }) => [ |
| 7861 |
renderSlot(_ctx.$slots, "menu-item", { menuItem }) |
| 7862 |
]), |
| 7863 |
_: 3 |
| 7864 |
|
| 7865 |
}, 16, ["id", "selected", "expanded", "menu-items"]) |
| 7866 |
], 14, _hoisted_1$8); |
| 7867 |
} |
| 7868 |
const CdxSelect = _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]); |
| 7869 |
const _sfc_main$7 = defineComponent({ |
| 7870 |
name: "CdxTablePager", |
| 7871 |
components: { CdxButton, CdxIcon, CdxSelect }, |
| 7872 |
props: { |
| 7873 |
paginationSizeOptions: { |
| 7874 |
type: Array, |
| 7875 |
required: true |
| 7876 |
}, |
| 7877 |
itemsPerPage: { |
| 7878 |
type: Number, |
| 7879 |
required: true |
| 7880 |
}, |
| 7881 |
nextDisabled: { |
| 7882 |
type: Boolean, |
| 7883 |
default: false |
| 7884 |
}, |
| 7885 |
prevDisabled: { |
| 7886 |
type: Boolean, |
| 7887 |
default: false |
| 7888 |
}, |
| 7889 |
lastDisabled: { |
| 7890 |
type: Boolean, |
| 7891 |
default: false |
| 7892 |
} |
| 7893 |
}, |
| 7894 |
emits: [ |
| 7895 |
|
| 7896 |
|
| 7897 |
|
| 7898 |
|
| 7899 |
|
| 7900 |
"update:itemsPerPage", |
| 7901 |
|
| 7902 |
|
| 7903 |
|
| 7904 |
"first", |
| 7905 |
|
| 7906 |
|
| 7907 |
|
| 7908 |
"last", |
| 7909 |
|
| 7910 |
|
| 7911 |
|
| 7912 |
"next", |
| 7913 |
|
| 7914 |
|
| 7915 |
|
| 7916 |
"prev" |
| 7917 |
], |
| 7918 |
setup(props, { emit }) { |
| 7919 |
const wrappedItemsPerPage = useModelWrapper( |
| 7920 |
toRef(props, "itemsPerPage"), |
| 7921 |
emit, |
| 7922 |
"update:itemsPerPage" |
| 7923 |
); |
| 7924 |
const defaultItemsPerPageLabel = useI18n( |
| 7925 |
"cdx-table-pager-items-per-page-default", |
| 7926 |
"Results per page" |
| 7927 |
); |
| 7928 |
const currentItemsPerPageLabel = useI18n( |
| 7929 |
"cdx-table-pager-items-per-page-current", |
| 7930 |
(current) => "".concat(current, " rows"), |
| 7931 |
[wrappedItemsPerPage] |
| 7932 |
); |
| 7933 |
const btnLabelFirst = useI18n( |
| 7934 |
"cdx-table-pager-button-first-page", |
| 7935 |
"First page" |
| 7936 |
); |
| 7937 |
const btnLabelNext = useI18n( |
| 7938 |
"cdx-table-pager-button-next-page", |
| 7939 |
"Next page" |
| 7940 |
); |
| 7941 |
const btnLabelPrev = useI18n( |
| 7942 |
"cdx-table-pager-button-prev-page", |
| 7943 |
"Previous page" |
| 7944 |
); |
| 7945 |
const btnLabelLast = useI18n( |
| 7946 |
"cdx-table-pager-button-last-page", |
| 7947 |
"Last page" |
| 7948 |
); |
| 7949 |
return { |
| 7950 |
defaultItemsPerPageLabel, |
| 7951 |
currentItemsPerPageLabel, |
| 7952 |
btnLabelFirst, |
| 7953 |
btnLabelNext, |
| 7954 |
btnLabelPrev, |
| 7955 |
btnLabelLast, |
| 7956 |
wrappedItemsPerPage, |
| 7957 |
cdxIconPrevious: d7, |
| 7958 |
cdxIconNext: j6, |
| 7959 |
cdxIconMoveFirst: P6, |
| 7960 |
cdxIconMoveLast: N6 |
| 7961 |
}; |
| 7962 |
} |
| 7963 |
}); |
| 7964 |
const _hoisted_1$7 = { class: "cdx-table-pager" }; |
| 7965 |
const _hoisted_2$4 = { class: "cdx-table-pager__start" }; |
| 7966 |
const _hoisted_3$3 = { key: 0 }; |
| 7967 |
const _hoisted_4$3 = { key: 1 }; |
| 7968 |
const _hoisted_5$3 = { class: "cdx-table-pager__center" }; |
| 7969 |
const _hoisted_6$3 = { class: "cdx-table-pager__end" }; |
| 7970 |
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) { |
| 7971 |
const _component_cdx_select = resolveComponent("cdx-select"); |
| 7972 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 7973 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 7974 |
return openBlock(), createElementBlock("div", _hoisted_1$7, [ |
| 7975 |
createElementVNode("div", _hoisted_2$4, [ |
| 7976 |
createVNode(_component_cdx_select, { |
| 7977 |
selected: _ctx.wrappedItemsPerPage, |
| 7978 |
"onUpdate:selected": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedItemsPerPage = $event), |
| 7979 |
"default-label": _ctx.defaultItemsPerPageLabel, |
| 7980 |
"menu-items": _ctx.paginationSizeOptions |
| 7981 |
}, { |
| 7982 |
label: withCtx(({ selectedMenuItem, defaultLabel }) => [ |
| 7983 |
selectedMenuItem ? (openBlock(), createElementBlock("span", _hoisted_3$3, [ |
| 7984 |
createElementVNode( |
| 7985 |
"span", |
| 7986 |
null, |
| 7987 |
toDisplayString(_ctx.currentItemsPerPageLabel), |
| 7988 |
1 |
| 7989 |
|
| 7990 |
) |
| 7991 |
])) : (openBlock(), createElementBlock( |
| 7992 |
"span", |
| 7993 |
_hoisted_4$3, |
| 7994 |
toDisplayString(defaultLabel), |
| 7995 |
1 |
| 7996 |
|
| 7997 |
)) |
| 7998 |
]), |
| 7999 |
_: 1 |
| 8000 |
|
| 8001 |
}, 8, ["selected", "default-label", "menu-items"]) |
| 8002 |
]), |
| 8003 |
createElementVNode("div", _hoisted_5$3, [ |
| 8004 |
renderSlot(_ctx.$slots, "default") |
| 8005 |
]), |
| 8006 |
createElementVNode("div", _hoisted_6$3, [ |
| 8007 |
createVNode(_component_cdx_button, { |
| 8008 |
disabled: _ctx.prevDisabled, |
| 8009 |
class: "cdx-table-pager__button-first", |
| 8010 |
weight: "quiet", |
| 8011 |
"aria-label": _ctx.btnLabelFirst, |
| 8012 |
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("first")) |
| 8013 |
}, { |
| 8014 |
default: withCtx(() => [ |
| 8015 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconMoveFirst }, null, 8, ["icon"]) |
| 8016 |
]), |
| 8017 |
_: 1 |
| 8018 |
|
| 8019 |
}, 8, ["disabled", "aria-label"]), |
| 8020 |
createVNode(_component_cdx_button, { |
| 8021 |
disabled: _ctx.prevDisabled, |
| 8022 |
class: "cdx-table-pager__button-prev", |
| 8023 |
weight: "quiet", |
| 8024 |
"aria-label": _ctx.btnLabelPrev, |
| 8025 |
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("prev")) |
| 8026 |
}, { |
| 8027 |
default: withCtx(() => [ |
| 8028 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconPrevious }, null, 8, ["icon"]) |
| 8029 |
]), |
| 8030 |
_: 1 |
| 8031 |
|
| 8032 |
}, 8, ["disabled", "aria-label"]), |
| 8033 |
createVNode(_component_cdx_button, { |
| 8034 |
disabled: _ctx.nextDisabled, |
| 8035 |
class: "cdx-table-pager__button-next", |
| 8036 |
weight: "quiet", |
| 8037 |
"aria-label": _ctx.btnLabelNext, |
| 8038 |
onClick: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("next")) |
| 8039 |
}, { |
| 8040 |
default: withCtx(() => [ |
| 8041 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconNext }, null, 8, ["icon"]) |
| 8042 |
]), |
| 8043 |
_: 1 |
| 8044 |
|
| 8045 |
}, 8, ["disabled", "aria-label"]), |
| 8046 |
createVNode(_component_cdx_button, { |
| 8047 |
disabled: _ctx.nextDisabled || _ctx.lastDisabled, |
| 8048 |
class: "cdx-table-pager__button-last", |
| 8049 |
weight: "quiet", |
| 8050 |
"aria-label": _ctx.btnLabelLast, |
| 8051 |
onClick: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("last")) |
| 8052 |
}, { |
| 8053 |
default: withCtx(() => [ |
| 8054 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconMoveLast }, null, 8, ["icon"]) |
| 8055 |
]), |
| 8056 |
_: 1 |
| 8057 |
|
| 8058 |
}, 8, ["disabled", "aria-label"]) |
| 8059 |
]) |
| 8060 |
]); |
| 8061 |
} |
| 8062 |
const CdxTablePager = _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]); |
| 8063 |
const tableTextAlignmentsValidator = makeStringTypeValidator(TableTextAlignments); |
| 8064 |
const paginationPositionValidator = makeStringTypeValidator(TablePaginationPositions); |
| 8065 |
const iconMap = { |
| 8066 |
none: T7, |
| 8067 |
asc: x8, |
| 8068 |
desc: l4 |
| 8069 |
}; |
| 8070 |
const sortDirectionMap = { |
| 8071 |
none: "none", |
| 8072 |
asc: "ascending", |
| 8073 |
desc: "descending" |
| 8074 |
}; |
| 8075 |
const _sfc_main$6 = defineComponent({ |
| 8076 |
name: "CdxTable", |
| 8077 |
components: { |
| 8078 |
CdxCheckbox, |
| 8079 |
CdxIcon, |
| 8080 |
CdxTablePager, |
| 8081 |
CdxProgressBar |
| 8082 |
}, |
| 8083 |
props: { |
| 8084 |
|
| 8085 |
|
| 8086 |
|
| 8087 |
|
| 8088 |
|
| 8089 |
caption: { |
| 8090 |
type: String, |
| 8091 |
required: true |
| 8092 |
}, |
| 8093 |
|
| 8094 |
|
| 8095 |
|
| 8096 |
hideCaption: { |
| 8097 |
type: Boolean, |
| 8098 |
default: false |
| 8099 |
}, |
| 8100 |
|
| 8101 |
|
| 8102 |
|
| 8103 |
|
| 8104 |
|
| 8105 |
columns: { |
| 8106 |
type: Array, |
| 8107 |
default: () => [], |
| 8108 |
validator: (value) => { |
| 8109 |
const ids = value.map((column) => column.id); |
| 8110 |
const hasUniqueIds = new Set(ids).size === ids.length; |
| 8111 |
if (!hasUniqueIds) { |
| 8112 |
console.warn( |
| 8113 |
'Each column in the "columns" prop of CdxTable must have a unique "id".' |
| 8114 |
); |
| 8115 |
return false; |
| 8116 |
} |
| 8117 |
return true; |
| 8118 |
} |
| 8119 |
}, |
| 8120 |
|
| 8121 |
|
| 8122 |
|
| 8123 |
|
| 8124 |
|
| 8125 |
|
| 8126 |
|
| 8127 |
|
| 8128 |
data: { |
| 8129 |
type: Array, |
| 8130 |
default: () => [], |
| 8131 |
validator: (value, props) => { |
| 8132 |
if (!Array.isArray(props.columns) || props.columns.length === 0 || value.length === 0) { |
| 8133 |
return true; |
| 8134 |
} |
| 8135 |
const hasSort = props.columns.some((column) => "allowSort" in column); |
| 8136 |
const rowsHaveIds = value.every((row) => TableRowIdentifier in row); |
| 8137 |
if (hasSort && props.useRowSelection && !rowsHaveIds) { |
| 8138 |
console.warn( |
| 8139 |
'For CdxTables with sorting and row selection, each row in the "data" prop must have a "TableRowIdentifier".' |
| 8140 |
); |
| 8141 |
return false; |
| 8142 |
} |
| 8143 |
return true; |
| 8144 |
} |
| 8145 |
}, |
| 8146 |
|
| 8147 |
|
| 8148 |
|
| 8149 |
useRowHeaders: { |
| 8150 |
type: Boolean, |
| 8151 |
default: false |
| 8152 |
}, |
| 8153 |
|
| 8154 |
|
| 8155 |
|
| 8156 |
showVerticalBorders: { |
| 8157 |
type: Boolean, |
| 8158 |
default: false |
| 8159 |
}, |
| 8160 |
|
| 8161 |
|
| 8162 |
|
| 8163 |
useRowSelection: { |
| 8164 |
type: Boolean, |
| 8165 |
default: false |
| 8166 |
}, |
| 8167 |
|
| 8168 |
|
| 8169 |
|
| 8170 |
|
| 8171 |
|
| 8172 |
|
| 8173 |
|
| 8174 |
selectedRows: { |
| 8175 |
type: Array, |
| 8176 |
default: () => [] |
| 8177 |
}, |
| 8178 |
|
| 8179 |
|
| 8180 |
|
| 8181 |
|
| 8182 |
|
| 8183 |
|
| 8184 |
|
| 8185 |
sort: { |
| 8186 |
type: Object, |
| 8187 |
default: () => ({}) |
| 8188 |
}, |
| 8189 |
|
| 8190 |
|
| 8191 |
|
| 8192 |
pending: { |
| 8193 |
type: Boolean, |
| 8194 |
default: false |
| 8195 |
}, |
| 8196 |
|
| 8197 |
|
| 8198 |
|
| 8199 |
paginate: { |
| 8200 |
type: Boolean, |
| 8201 |
default: false |
| 8202 |
}, |
| 8203 |
|
| 8204 |
|
| 8205 |
|
| 8206 |
|
| 8207 |
|
| 8208 |
serverPagination: { |
| 8209 |
type: Boolean, |
| 8210 |
default: false |
| 8211 |
}, |
| 8212 |
|
| 8213 |
|
| 8214 |
|
| 8215 |
|
| 8216 |
|
| 8217 |
|
| 8218 |
totalRows: { |
| 8219 |
type: Number, |
| 8220 |
default: NaN |
| 8221 |
}, |
| 8222 |
|
| 8223 |
|
| 8224 |
|
| 8225 |
paginationPosition: { |
| 8226 |
type: String, |
| 8227 |
default: "bottom", |
| 8228 |
validator: paginationPositionValidator |
| 8229 |
}, |
| 8230 |
|
| 8231 |
|
| 8232 |
|
| 8233 |
|
| 8234 |
|
| 8235 |
|
| 8236 |
paginationSizeOptions: { |
| 8237 |
type: Array, |
| 8238 |
default: () => [ |
| 8239 |
{ value: 10 }, |
| 8240 |
{ value: 20 }, |
| 8241 |
{ value: 50 } |
| 8242 |
], |
| 8243 |
validator: (value) => { |
| 8244 |
const hasNumberValue = (item) => typeof item.value === "number"; |
| 8245 |
if (value.every(hasNumberValue)) { |
| 8246 |
return true; |
| 8247 |
} else { |
| 8248 |
console.warn('"value" property of all menu items in PaginationOptions must be a number.'); |
| 8249 |
return false; |
| 8250 |
} |
| 8251 |
} |
| 8252 |
}, |
| 8253 |
|
| 8254 |
|
| 8255 |
|
| 8256 |
|
| 8257 |
|
| 8258 |
|
| 8259 |
|
| 8260 |
|
| 8261 |
paginationSizeDefault: { |
| 8262 |
type: Number, |
| 8263 |
default: (rawProps) => { |
| 8264 |
if (rawProps.paginate && rawProps.serverPagination) { |
| 8265 |
return rawProps.data.length; |
| 8266 |
} else { |
| 8267 |
return rawProps.paginationSizeOptions[0].value; |
| 8268 |
} |
| 8269 |
} |
| 8270 |
} |
| 8271 |
}, |
| 8272 |
emits: [ |
| 8273 |
|
| 8274 |
|
| 8275 |
|
| 8276 |
|
| 8277 |
|
| 8278 |
"update:selectedRows", |
| 8279 |
|
| 8280 |
|
| 8281 |
|
| 8282 |
|
| 8283 |
|
| 8284 |
"update:sort", |
| 8285 |
|
| 8286 |
|
| 8287 |
|
| 8288 |
|
| 8289 |
|
| 8290 |
|
| 8291 |
|
| 8292 |
"load-more", |
| 8293 |
|
| 8294 |
|
| 8295 |
|
| 8296 |
|
| 8297 |
|
| 8298 |
"last" |
| 8299 |
], |
| 8300 |
setup(props, { emit }) { |
| 8301 |
const offset2 = ref(0); |
| 8302 |
const pageSize = ref(props.paginationSizeDefault); |
| 8303 |
const dataForDisplay = computed(() => { |
| 8304 |
if (props.serverPagination && props.paginate) { |
| 8305 |
return props.data; |
| 8306 |
} else if (props.paginate) { |
| 8307 |
return props.data.slice(offset2.value, pageSize.value + offset2.value); |
| 8308 |
} else { |
| 8309 |
return props.data; |
| 8310 |
} |
| 8311 |
}); |
| 8312 |
const totalCount = computed(() => { |
| 8313 |
var _a; |
| 8314 |
if (props.serverPagination) { |
| 8315 |
return (_a = props.totalRows) != null ? _a : NaN; |
| 8316 |
} else { |
| 8317 |
return props.data.length; |
| 8318 |
} |
| 8319 |
}); |
| 8320 |
const indeterminate = computed(() => isNaN(totalCount.value)); |
| 8321 |
const currentCount = computed(() => dataForDisplay.value.length); |
| 8322 |
const firstOrdinal = computed(() => offset2.value + 1); |
| 8323 |
const lastOrdinal = computed(() => offset2.value + currentCount.value); |
| 8324 |
const lastDisabled = computed(() => indeterminate.value); |
| 8325 |
const prevDisabled = computed(() => offset2.value <= 0); |
| 8326 |
const nextDisabled = computed(() => { |
| 8327 |
if (indeterminate.value) { |
| 8328 |
return currentCount.value < pageSize.value; |
| 8329 |
} else { |
| 8330 |
return offset2.value + pageSize.value >= totalCount.value; |
| 8331 |
} |
| 8332 |
}); |
| 8333 |
const paginationStatusMessageDeterminateShort = useI18n( |
| 8334 |
"cdx-table-pagination-status-message-determinate-short", |
| 8335 |
(x, y, z) => "".concat(x, "–").concat(y, " of ").concat(z), |
| 8336 |
[firstOrdinal, lastOrdinal, totalCount] |
| 8337 |
); |
| 8338 |
const paginationStatusMessageDeterminateLong = useI18n( |
| 8339 |
"cdx-table-pagination-status-message-determinate-long", |
| 8340 |
(x, y, z) => "Showing results ".concat(x, "–").concat(y, " of ").concat(z), |
| 8341 |
[firstOrdinal, lastOrdinal, totalCount] |
| 8342 |
); |
| 8343 |
const paginationStatusMessageIndeterminateShort = useI18n( |
| 8344 |
"cdx-table-pagination-status-message-indeterminate-short", |
| 8345 |
(x, y) => "".concat(x, "–").concat(y, " of many"), |
| 8346 |
[firstOrdinal, lastOrdinal] |
| 8347 |
); |
| 8348 |
const paginationStatusMessageIndeterminateLong = useI18n( |
| 8349 |
"cdx-table-pagination-status-message-indeterminate-long", |
| 8350 |
(x, y) => "Showing results ".concat(x, "–").concat(y, " of many"), |
| 8351 |
[firstOrdinal, lastOrdinal] |
| 8352 |
); |
| 8353 |
const paginationStatusMessageIndeterminateFinal = useI18n( |
| 8354 |
"cdx-table-pagination-status-message-indeterminate-final", |
| 8355 |
(x) => "Showing the last ".concat(x, " results"), |
| 8356 |
[currentCount] |
| 8357 |
); |
| 8358 |
const paginationStatusMessagePending = useI18n( |
| 8359 |
"cdx-table-pagination-status-message-pending", |
| 8360 |
"Loading results..." |
| 8361 |
); |
| 8362 |
const paginationStatusMessageShort = computed(() => { |
| 8363 |
if (props.pending) { |
| 8364 |
return paginationStatusMessagePending.value; |
| 8365 |
} else if (indeterminate.value && nextDisabled.value) { |
| 8366 |
return paginationStatusMessageIndeterminateFinal.value; |
| 8367 |
} else if (indeterminate.value) { |
| 8368 |
return paginationStatusMessageIndeterminateShort.value; |
| 8369 |
} else { |
| 8370 |
return paginationStatusMessageDeterminateShort.value; |
| 8371 |
} |
| 8372 |
}); |
| 8373 |
const paginationStatusMessageLong = computed(() => { |
| 8374 |
if (props.pending) { |
| 8375 |
return paginationStatusMessagePending.value; |
| 8376 |
} else if (indeterminate.value && nextDisabled.value) { |
| 8377 |
return paginationStatusMessageIndeterminateFinal.value; |
| 8378 |
} else if (indeterminate.value) { |
| 8379 |
return paginationStatusMessageIndeterminateLong.value; |
| 8380 |
} else { |
| 8381 |
return paginationStatusMessageDeterminateLong.value; |
| 8382 |
} |
| 8383 |
}); |
| 8384 |
function onNext() { |
| 8385 |
offset2.value += pageSize.value; |
| 8386 |
if (props.serverPagination) { |
| 8387 |
emit("load-more", offset2.value, pageSize.value); |
| 8388 |
} |
| 8389 |
} |
| 8390 |
function onPrev() { |
| 8391 |
if (offset2.value - pageSize.value < 1) { |
| 8392 |
onFirst(); |
| 8393 |
} else { |
| 8394 |
offset2.value -= pageSize.value; |
| 8395 |
if (props.serverPagination) { |
| 8396 |
emit("load-more", offset2.value, pageSize.value); |
| 8397 |
} |
| 8398 |
} |
| 8399 |
} |
| 8400 |
function onFirst() { |
| 8401 |
offset2.value = 0; |
| 8402 |
if (props.serverPagination) { |
| 8403 |
emit("load-more", offset2.value, pageSize.value); |
| 8404 |
} |
| 8405 |
} |
| 8406 |
function onLast() { |
| 8407 |
if (totalCount.value % pageSize.value === 0) { |
| 8408 |
offset2.value = totalCount.value - pageSize.value; |
| 8409 |
emit("load-more", offset2.value, pageSize.value); |
| 8410 |
} else { |
| 8411 |
offset2.value = Math.floor(totalCount.value / pageSize.value) * pageSize.value; |
| 8412 |
emit("load-more", offset2.value, pageSize.value); |
| 8413 |
} |
| 8414 |
} |
| 8415 |
watch(pageSize, (newPageSize) => { |
| 8416 |
if (props.serverPagination) { |
| 8417 |
emit("load-more", offset2.value, newPageSize); |
| 8418 |
} |
| 8419 |
}); |
| 8420 |
const wrappedSelectedRows = useModelWrapper(toRef(props, "selectedRows"), emit, "update:selectedRows"); |
| 8421 |
const selectAll = ref(totalCount.value === wrappedSelectedRows.value.length); |
| 8422 |
const selectAllIndeterminate = ref(false); |
| 8423 |
const activeSortColumn = computed(() => { |
| 8424 |
return Object.keys(props.sort)[0]; |
| 8425 |
}); |
| 8426 |
const hasSortableColumns = computed(() => { |
| 8427 |
return props.columns.some((column) => column.allowSort); |
| 8428 |
}); |
| 8429 |
const tableClasses = computed(() => { |
| 8430 |
var _a; |
| 8431 |
const useFixedLayout = (_a = props.columns) == null ? void 0 : _a.some((column) => "width" in column || "minWidth" in column); |
| 8432 |
return { |
| 8433 |
"cdx-table__table--layout-fixed": useFixedLayout, |
| 8434 |
"cdx-table__table--borders-vertical": props.showVerticalBorders |
| 8435 |
}; |
| 8436 |
}); |
| 8437 |
const translatedSortCaption = useI18n( |
| 8438 |
"cdx-table-sort-caption", |
| 8439 |
(caption) => "".concat(caption, ", column headers with buttons are sortable."), |
| 8440 |
[toRef(props, "caption")] |
| 8441 |
); |
| 8442 |
const translatedSelectRowLabel = (rowIndex, totalRows) => useI18n( |
| 8443 |
"cdx-table-select-row-label", |
| 8444 |
(row, total) => "Select row ".concat(row, " of ").concat(total), |
| 8445 |
[() => rowIndex, () => totalRows] |
| 8446 |
).value; |
| 8447 |
const translatedSelectAllLabel = useI18n("cdx-table-select-all-label", "Select all rows"); |
| 8448 |
function getRowKey(row, index) { |
| 8449 |
return TableRowIdentifier in row ? row[TableRowIdentifier] : index; |
| 8450 |
} |
| 8451 |
function getRowClass(row, rowIndex) { |
| 8452 |
const rowKey = getRowKey(row, rowIndex); |
| 8453 |
return { |
| 8454 |
"cdx-table__row--selected": wrappedSelectedRows.value.indexOf(rowKey) !== -1 |
| 8455 |
}; |
| 8456 |
} |
| 8457 |
function getRowHeaderScope(columnId) { |
| 8458 |
const firstColumn = props.columns[0].id; |
| 8459 |
if (props.useRowHeaders === true && columnId === firstColumn) { |
| 8460 |
return "row"; |
| 8461 |
} |
| 8462 |
} |
| 8463 |
function getCellElement(columnId) { |
| 8464 |
const firstColumn = props.columns[0].id; |
| 8465 |
if (props.useRowHeaders && columnId === firstColumn) { |
| 8466 |
return "th"; |
| 8467 |
} |
| 8468 |
return "td"; |
| 8469 |
} |
| 8470 |
function getCellClass(column, hasSort = false) { |
| 8471 |
if ("textAlign" in column && !tableTextAlignmentsValidator(column.textAlign)) { |
| 8472 |
console.warn("Invalid value for TableColumn textAlign property."); |
| 8473 |
return void 0; |
| 8474 |
} |
| 8475 |
return { |
| 8476 |
|
| 8477 |
|
| 8478 |
["cdx-table__table__cell--align-".concat(column.textAlign)]: "textAlign" in column && column.textAlign !== "start", |
| 8479 |
"cdx-table__table__cell--has-sort": hasSort |
| 8480 |
}; |
| 8481 |
} |
| 8482 |
function getCellStyle(column) { |
| 8483 |
const styles = {}; |
| 8484 |
if ("width" in column) { |
| 8485 |
styles.width = column.width; |
| 8486 |
} |
| 8487 |
if ("minWidth" in column) { |
| 8488 |
styles.minWidth = column.minWidth; |
| 8489 |
} |
| 8490 |
return styles; |
| 8491 |
} |
| 8492 |
function handleRowSelection(newSelectedRows) { |
| 8493 |
if (totalCount.value === newSelectedRows.length) { |
| 8494 |
selectAll.value = true; |
| 8495 |
selectAllIndeterminate.value = false; |
| 8496 |
return; |
| 8497 |
} |
| 8498 |
selectAll.value = false; |
| 8499 |
if (totalCount.value > newSelectedRows.length) { |
| 8500 |
selectAllIndeterminate.value = true; |
| 8501 |
} |
| 8502 |
if (newSelectedRows.length === 0) { |
| 8503 |
selectAllIndeterminate.value = false; |
| 8504 |
} |
| 8505 |
} |
| 8506 |
function handleSelectAll(newValue) { |
| 8507 |
selectAllIndeterminate.value = false; |
| 8508 |
if (newValue) { |
| 8509 |
wrappedSelectedRows.value = props.data.map((row, rowIndex) => getRowKey(row, rowIndex)); |
| 8510 |
} else { |
| 8511 |
wrappedSelectedRows.value = []; |
| 8512 |
} |
| 8513 |
} |
| 8514 |
function handleSort(columnId) { |
| 8515 |
var _a; |
| 8516 |
const currentSortOrder = (_a = props.sort[columnId]) != null ? _a : "none"; |
| 8517 |
let newSortOrder = "asc"; |
| 8518 |
if (currentSortOrder === "asc") { |
| 8519 |
newSortOrder = "desc"; |
| 8520 |
} |
| 8521 |
if (currentSortOrder === "desc") { |
| 8522 |
newSortOrder = "none"; |
| 8523 |
} |
| 8524 |
emit("update:sort", { [columnId]: newSortOrder }); |
| 8525 |
} |
| 8526 |
function getSortIcon(columnId) { |
| 8527 |
var _a; |
| 8528 |
const currentSortOrder = (_a = props.sort[columnId]) != null ? _a : "none"; |
| 8529 |
return iconMap[currentSortOrder]; |
| 8530 |
} |
| 8531 |
function getSortOrder(columnId, hasSort = false) { |
| 8532 |
var _a; |
| 8533 |
if (hasSort) { |
| 8534 |
const currentSortOrder = (_a = props.sort[columnId]) != null ? _a : "none"; |
| 8535 |
return currentSortOrder === "none" ? void 0 : sortDirectionMap[currentSortOrder]; |
| 8536 |
} |
| 8537 |
} |
| 8538 |
return { |
| 8539 |
|
| 8540 |
dataForDisplay, |
| 8541 |
pageSize, |
| 8542 |
onNext, |
| 8543 |
onPrev, |
| 8544 |
onFirst, |
| 8545 |
onLast, |
| 8546 |
nextDisabled, |
| 8547 |
prevDisabled, |
| 8548 |
lastDisabled, |
| 8549 |
paginationStatusMessageShort, |
| 8550 |
paginationStatusMessageLong, |
| 8551 |
|
| 8552 |
wrappedSelectedRows, |
| 8553 |
selectAll, |
| 8554 |
selectAllIndeterminate, |
| 8555 |
|
| 8556 |
activeSortColumn, |
| 8557 |
hasSortableColumns, |
| 8558 |
|
| 8559 |
tableClasses, |
| 8560 |
getRowKey, |
| 8561 |
getRowClass, |
| 8562 |
getRowHeaderScope, |
| 8563 |
getCellElement, |
| 8564 |
getCellClass, |
| 8565 |
getCellStyle, |
| 8566 |
|
| 8567 |
handleRowSelection, |
| 8568 |
handleSelectAll, |
| 8569 |
|
| 8570 |
handleSort, |
| 8571 |
getSortIcon, |
| 8572 |
getSortOrder, |
| 8573 |
|
| 8574 |
translatedSortCaption, |
| 8575 |
translatedSelectRowLabel, |
| 8576 |
translatedSelectAllLabel |
| 8577 |
}; |
| 8578 |
} |
| 8579 |
}); |
| 8580 |
const _hoisted_1$6 = { |
| 8581 |
class: "cdx-table", |
| 8582 |
tabindex: "0" |
| 8583 |
}; |
| 8584 |
const _hoisted_2$3 = { |
| 8585 |
key: 0, |
| 8586 |
class: "cdx-table__header" |
| 8587 |
}; |
| 8588 |
const _hoisted_3$2 = ["aria-hidden"]; |
| 8589 |
const _hoisted_4$2 = { class: "cdx-table__header__content" }; |
| 8590 |
const _hoisted_5$2 = { class: "cdx-table__pagination-status--long" }; |
| 8591 |
const _hoisted_6$2 = { class: "cdx-table__pagination-status--short" }; |
| 8592 |
const _hoisted_7 = { class: "cdx-table__table-wrapper" }; |
| 8593 |
const _hoisted_8 = { key: 0 }; |
| 8594 |
const _hoisted_9 = { |
| 8595 |
key: 0, |
| 8596 |
class: "cdx-table__table__select-rows" |
| 8597 |
}; |
| 8598 |
const _hoisted_10 = ["aria-sort"]; |
| 8599 |
const _hoisted_11 = ["aria-selected", "onClick"]; |
| 8600 |
const _hoisted_12 = { class: "cdx-table__table__sort-label" }; |
| 8601 |
const _hoisted_13 = { key: 0 }; |
| 8602 |
const _hoisted_14 = { key: 0 }; |
| 8603 |
const _hoisted_15 = { key: 1 }; |
| 8604 |
const _hoisted_16 = { class: "cdx-table__table__empty-state" }; |
| 8605 |
const _hoisted_17 = { class: "cdx-table__table__empty-state-content" }; |
| 8606 |
const _hoisted_18 = { class: "cdx-table__pagination-status--long" }; |
| 8607 |
const _hoisted_19 = { class: "cdx-table__pagination-status--short" }; |
| 8608 |
const _hoisted_20 = { |
| 8609 |
key: 3, |
| 8610 |
class: "cdx-table__footer" |
| 8611 |
}; |
| 8612 |
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) { |
| 8613 |
const _component_cdx_table_pager = resolveComponent("cdx-table-pager"); |
| 8614 |
const _component_cdx_checkbox = resolveComponent("cdx-checkbox"); |
| 8615 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 8616 |
const _component_cdx_progress_bar = resolveComponent("cdx-progress-bar"); |
| 8617 |
return openBlock(), createElementBlock("div", _hoisted_1$6, [ |
| 8618 |
!_ctx.hideCaption || _ctx.$slots.header && _ctx.$slots.header().length > 0 ? (openBlock(), createElementBlock("div", _hoisted_2$3, [ |
| 8619 |
createElementVNode("div", { |
| 8620 |
class: "cdx-table__header__caption", |
| 8621 |
"aria-hidden": _ctx.$slots.header && _ctx.$slots.header().length > 0 ? void 0 : true |
| 8622 |
}, [ |
| 8623 |
!_ctx.hideCaption ? (openBlock(), createElementBlock( |
| 8624 |
Fragment, |
| 8625 |
{ key: 0 }, |
| 8626 |
[ |
| 8627 |
createTextVNode( |
| 8628 |
toDisplayString(_ctx.caption), |
| 8629 |
1 |
| 8630 |
|
| 8631 |
) |
| 8632 |
], |
| 8633 |
64 |
| 8634 |
|
| 8635 |
)) : createCommentVNode("v-if", true) |
| 8636 |
], 8, _hoisted_3$2), |
| 8637 |
createElementVNode("div", _hoisted_4$2, [ |
| 8638 |
renderSlot(_ctx.$slots, "header") |
| 8639 |
]) |
| 8640 |
])) : createCommentVNode("v-if", true), |
| 8641 |
_ctx.paginate && (_ctx.paginationPosition === "top" || _ctx.paginationPosition === "both") ? (openBlock(), createBlock(_component_cdx_table_pager, { |
| 8642 |
key: 1, |
| 8643 |
"items-per-page": _ctx.pageSize, |
| 8644 |
"onUpdate:itemsPerPage": _cache[0] || (_cache[0] = ($event) => _ctx.pageSize = $event), |
| 8645 |
class: "cdx-table__pagination--top", |
| 8646 |
"pagination-size-options": _ctx.paginationSizeOptions, |
| 8647 |
"prev-disabled": _ctx.prevDisabled, |
| 8648 |
"next-disabled": _ctx.nextDisabled, |
| 8649 |
"last-disabled": _ctx.lastDisabled, |
| 8650 |
onNext: _ctx.onNext, |
| 8651 |
onPrev: _ctx.onPrev, |
| 8652 |
onFirst: _ctx.onFirst, |
| 8653 |
onLast: _ctx.onLast |
| 8654 |
}, { |
| 8655 |
default: withCtx(() => [ |
| 8656 |
createElementVNode( |
| 8657 |
"span", |
| 8658 |
_hoisted_5$2, |
| 8659 |
toDisplayString(_ctx.paginationStatusMessageLong), |
| 8660 |
1 |
| 8661 |
|
| 8662 |
), |
| 8663 |
createElementVNode( |
| 8664 |
"span", |
| 8665 |
_hoisted_6$2, |
| 8666 |
toDisplayString(_ctx.paginationStatusMessageShort), |
| 8667 |
1 |
| 8668 |
|
| 8669 |
) |
| 8670 |
]), |
| 8671 |
_: 1 |
| 8672 |
|
| 8673 |
}, 8, ["items-per-page", "pagination-size-options", "prev-disabled", "next-disabled", "last-disabled", "onNext", "onPrev", "onFirst", "onLast"])) : createCommentVNode("v-if", true), |
| 8674 |
createElementVNode("div", _hoisted_7, [ |
| 8675 |
createElementVNode( |
| 8676 |
"table", |
| 8677 |
{ |
| 8678 |
class: normalizeClass(["cdx-table__table", _ctx.tableClasses]) |
| 8679 |
}, |
| 8680 |
[ |
| 8681 |
createElementVNode("caption", null, [ |
| 8682 |
!_ctx.hasSortableColumns ? (openBlock(), createElementBlock( |
| 8683 |
Fragment, |
| 8684 |
{ key: 0 }, |
| 8685 |
[ |
| 8686 |
createTextVNode( |
| 8687 |
toDisplayString(_ctx.caption), |
| 8688 |
1 |
| 8689 |
|
| 8690 |
) |
| 8691 |
], |
| 8692 |
64 |
| 8693 |
|
| 8694 |
)) : (openBlock(), createElementBlock( |
| 8695 |
Fragment, |
| 8696 |
{ key: 1 }, |
| 8697 |
[ |
| 8698 |
createTextVNode( |
| 8699 |
toDisplayString(_ctx.translatedSortCaption), |
| 8700 |
1 |
| 8701 |
|
| 8702 |
) |
| 8703 |
], |
| 8704 |
64 |
| 8705 |
|
| 8706 |
)) |
| 8707 |
]), |
| 8708 |
renderSlot(_ctx.$slots, "thead", {}, () => [ |
| 8709 |
_ctx.columns.length > 0 ? (openBlock(), createElementBlock("thead", _hoisted_8, [ |
| 8710 |
createElementVNode("tr", null, [ |
| 8711 |
_ctx.useRowSelection ? (openBlock(), createElementBlock("th", _hoisted_9, [ |
| 8712 |
createVNode(_component_cdx_checkbox, { |
| 8713 |
modelValue: _ctx.selectAll, |
| 8714 |
"onUpdate:modelValue": [ |
| 8715 |
_cache[1] || (_cache[1] = ($event) => _ctx.selectAll = $event), |
| 8716 |
_ctx.handleSelectAll |
| 8717 |
], |
| 8718 |
"hide-label": true, |
| 8719 |
indeterminate: _ctx.selectAllIndeterminate |
| 8720 |
}, { |
| 8721 |
default: withCtx(() => [ |
| 8722 |
createTextVNode( |
| 8723 |
toDisplayString(_ctx.translatedSelectAllLabel), |
| 8724 |
1 |
| 8725 |
|
| 8726 |
) |
| 8727 |
]), |
| 8728 |
_: 1 |
| 8729 |
|
| 8730 |
}, 8, ["modelValue", "indeterminate", "onUpdate:modelValue"]) |
| 8731 |
])) : createCommentVNode("v-if", true), |
| 8732 |
(openBlock(true), createElementBlock( |
| 8733 |
Fragment, |
| 8734 |
null, |
| 8735 |
renderList(_ctx.columns, (column) => { |
| 8736 |
return openBlock(), createElementBlock("th", { |
| 8737 |
key: column.id, |
| 8738 |
scope: "col", |
| 8739 |
class: normalizeClass(_ctx.getCellClass(column, column.allowSort)), |
| 8740 |
"aria-sort": _ctx.getSortOrder(column.id, column.allowSort), |
| 8741 |
style: normalizeStyle(_ctx.getCellStyle(column)) |
| 8742 |
}, [ |
| 8743 |
column.allowSort ? (openBlock(), createElementBlock("button", { |
| 8744 |
key: 0, |
| 8745 |
"aria-selected": column.id === _ctx.activeSortColumn, |
| 8746 |
class: "cdx-table__table__sort-button", |
| 8747 |
onClick: ($event) => _ctx.handleSort(column.id) |
| 8748 |
}, [ |
| 8749 |
createElementVNode( |
| 8750 |
"span", |
| 8751 |
_hoisted_12, |
| 8752 |
toDisplayString(column.label), |
| 8753 |
1 |
| 8754 |
|
| 8755 |
), |
| 8756 |
createVNode(_component_cdx_icon, { |
| 8757 |
icon: _ctx.getSortIcon(column.id), |
| 8758 |
size: "small", |
| 8759 |
class: "cdx-table__table__sort-icon", |
| 8760 |
"aria-hidden": "true" |
| 8761 |
}, null, 8, ["icon"]) |
| 8762 |
], 8, _hoisted_11)) : (openBlock(), createElementBlock( |
| 8763 |
Fragment, |
| 8764 |
{ key: 1 }, |
| 8765 |
[ |
| 8766 |
createTextVNode( |
| 8767 |
toDisplayString(column.label), |
| 8768 |
1 |
| 8769 |
|
| 8770 |
) |
| 8771 |
], |
| 8772 |
64 |
| 8773 |
|
| 8774 |
)) |
| 8775 |
], 14, _hoisted_10); |
| 8776 |
}), |
| 8777 |
128 |
| 8778 |
|
| 8779 |
)) |
| 8780 |
]) |
| 8781 |
])) : createCommentVNode("v-if", true) |
| 8782 |
]), |
| 8783 |
_ctx.pending ? (openBlock(), createBlock(_component_cdx_progress_bar, { |
| 8784 |
key: 0, |
| 8785 |
inline: true, |
| 8786 |
class: "cdx-table__pending-indicator" |
| 8787 |
})) : createCommentVNode("v-if", true), |
| 8788 |
renderSlot(_ctx.$slots, "tbody", {}, () => [ |
| 8789 |
_ctx.dataForDisplay.length > 0 ? (openBlock(), createElementBlock("tbody", _hoisted_13, [ |
| 8790 |
(openBlock(true), createElementBlock( |
| 8791 |
Fragment, |
| 8792 |
null, |
| 8793 |
renderList(_ctx.dataForDisplay, (row, rowIndex) => { |
| 8794 |
return openBlock(), createElementBlock( |
| 8795 |
"tr", |
| 8796 |
{ |
| 8797 |
key: _ctx.getRowKey(row, rowIndex), |
| 8798 |
class: normalizeClass(_ctx.getRowClass(row, rowIndex)) |
| 8799 |
}, |
| 8800 |
[ |
| 8801 |
_ctx.useRowSelection ? (openBlock(), createElementBlock("td", _hoisted_14, [ |
| 8802 |
createVNode(_component_cdx_checkbox, { |
| 8803 |
modelValue: _ctx.wrappedSelectedRows, |
| 8804 |
"onUpdate:modelValue": [ |
| 8805 |
_cache[2] || (_cache[2] = ($event) => _ctx.wrappedSelectedRows = $event), |
| 8806 |
_ctx.handleRowSelection |
| 8807 |
], |
| 8808 |
"input-value": _ctx.getRowKey(row, rowIndex), |
| 8809 |
"hide-label": true |
| 8810 |
}, { |
| 8811 |
default: withCtx(() => [ |
| 8812 |
createTextVNode( |
| 8813 |
toDisplayString(_ctx.translatedSelectRowLabel( |
| 8814 |
rowIndex + 1, |
| 8815 |
_ctx.dataForDisplay.length |
| 8816 |
)), |
| 8817 |
1 |
| 8818 |
|
| 8819 |
) |
| 8820 |
]), |
| 8821 |
_: 2 |
| 8822 |
|
| 8823 |
}, 1032, ["modelValue", "input-value", "onUpdate:modelValue"]) |
| 8824 |
])) : createCommentVNode("v-if", true), |
| 8825 |
(openBlock(true), createElementBlock( |
| 8826 |
Fragment, |
| 8827 |
null, |
| 8828 |
renderList(_ctx.columns, (column) => { |
| 8829 |
return openBlock(), createBlock(resolveDynamicComponent(_ctx.getCellElement(column.id)), { |
| 8830 |
key: column.id, |
| 8831 |
scope: _ctx.getRowHeaderScope(column.id), |
| 8832 |
class: normalizeClass(_ctx.getCellClass(column)) |
| 8833 |
}, { |
| 8834 |
default: withCtx(() => [ |
| 8835 |
renderSlot(_ctx.$slots, "item-" + column.id, { |
| 8836 |
item: row[column.id], |
| 8837 |
row |
| 8838 |
}, () => [ |
| 8839 |
createTextVNode( |
| 8840 |
toDisplayString(row[column.id]), |
| 8841 |
1 |
| 8842 |
|
| 8843 |
) |
| 8844 |
]) |
| 8845 |
]), |
| 8846 |
_: 2 |
| 8847 |
|
| 8848 |
}, 1032, ["scope", "class"]); |
| 8849 |
}), |
| 8850 |
128 |
| 8851 |
|
| 8852 |
)) |
| 8853 |
], |
| 8854 |
2 |
| 8855 |
|
| 8856 |
); |
| 8857 |
}), |
| 8858 |
128 |
| 8859 |
|
| 8860 |
)) |
| 8861 |
])) : _ctx.$slots["empty-state"] && _ctx.$slots["empty-state"]().length > 0 ? (openBlock(), createElementBlock("tbody", _hoisted_15, [ |
| 8862 |
createElementVNode("tr", _hoisted_16, [ |
| 8863 |
createElementVNode("td", _hoisted_17, [ |
| 8864 |
renderSlot(_ctx.$slots, "empty-state") |
| 8865 |
]) |
| 8866 |
]) |
| 8867 |
])) : createCommentVNode("v-if", true) |
| 8868 |
]), |
| 8869 |
renderSlot(_ctx.$slots, "tfoot") |
| 8870 |
], |
| 8871 |
2 |
| 8872 |
|
| 8873 |
) |
| 8874 |
]), |
| 8875 |
_ctx.paginate && (_ctx.paginationPosition === "bottom" || _ctx.paginationPosition === "both") ? (openBlock(), createBlock(_component_cdx_table_pager, { |
| 8876 |
key: 2, |
| 8877 |
"items-per-page": _ctx.pageSize, |
| 8878 |
"onUpdate:itemsPerPage": _cache[3] || (_cache[3] = ($event) => _ctx.pageSize = $event), |
| 8879 |
class: "cdx-table__pagination--bottom", |
| 8880 |
"pagination-size-options": _ctx.paginationSizeOptions, |
| 8881 |
"prev-disabled": _ctx.prevDisabled, |
| 8882 |
"next-disabled": _ctx.nextDisabled, |
| 8883 |
"last-disabled": _ctx.lastDisabled, |
| 8884 |
onNext: _ctx.onNext, |
| 8885 |
onPrev: _ctx.onPrev, |
| 8886 |
onFirst: _ctx.onFirst, |
| 8887 |
onLast: _ctx.onLast |
| 8888 |
}, { |
| 8889 |
default: withCtx(() => [ |
| 8890 |
createElementVNode( |
| 8891 |
"span", |
| 8892 |
_hoisted_18, |
| 8893 |
toDisplayString(_ctx.paginationStatusMessageLong), |
| 8894 |
1 |
| 8895 |
|
| 8896 |
), |
| 8897 |
createElementVNode( |
| 8898 |
"span", |
| 8899 |
_hoisted_19, |
| 8900 |
toDisplayString(_ctx.paginationStatusMessageShort), |
| 8901 |
1 |
| 8902 |
|
| 8903 |
) |
| 8904 |
]), |
| 8905 |
_: 1 |
| 8906 |
|
| 8907 |
}, 8, ["items-per-page", "pagination-size-options", "prev-disabled", "next-disabled", "last-disabled", "onNext", "onPrev", "onFirst", "onLast"])) : createCommentVNode("v-if", true), |
| 8908 |
_ctx.$slots.footer && _ctx.$slots.footer().length > 0 ? (openBlock(), createElementBlock("div", _hoisted_20, [ |
| 8909 |
renderSlot(_ctx.$slots, "footer") |
| 8910 |
])) : createCommentVNode("v-if", true) |
| 8911 |
]); |
| 8912 |
} |
| 8913 |
const Table = _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]); |
| 8914 |
const _sfc_main$5 = defineComponent({ |
| 8915 |
name: "CdxTab", |
| 8916 |
|
| 8917 |
|
| 8918 |
|
| 8919 |
|
| 8920 |
props: { |
| 8921 |
|
| 8922 |
|
| 8923 |
|
| 8924 |
|
| 8925 |
|
| 8926 |
name: { |
| 8927 |
type: String, |
| 8928 |
required: true |
| 8929 |
}, |
| 8930 |
|
| 8931 |
|
| 8932 |
|
| 8933 |
|
| 8934 |
|
| 8935 |
label: { |
| 8936 |
type: String, |
| 8937 |
default: "" |
| 8938 |
}, |
| 8939 |
|
| 8940 |
|
| 8941 |
|
| 8942 |
|
| 8943 |
|
| 8944 |
disabled: { |
| 8945 |
type: Boolean, |
| 8946 |
default: false |
| 8947 |
} |
| 8948 |
}, |
| 8949 |
setup(props) { |
| 8950 |
var _a; |
| 8951 |
const tabsData = inject(TabsKey); |
| 8952 |
const activeTab = inject(ActiveTabKey); |
| 8953 |
if (!tabsData || !activeTab) { |
| 8954 |
throw new Error("Tab component must be used inside a Tabs component"); |
| 8955 |
} |
| 8956 |
const tab = (_a = tabsData.value.get(props.name)) != null ? _a : {}; |
| 8957 |
const isActive = computed(() => props.name === activeTab.value); |
| 8958 |
return { |
| 8959 |
tab, |
| 8960 |
isActive |
| 8961 |
}; |
| 8962 |
} |
| 8963 |
}); |
| 8964 |
const _hoisted_1$5 = ["id", "aria-hidden", "aria-labelledby"]; |
| 8965 |
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) { |
| 8966 |
return withDirectives((openBlock(), createElementBlock("section", { |
| 8967 |
id: _ctx.tab.id, |
| 8968 |
"aria-hidden": !_ctx.isActive ? true : void 0, |
| 8969 |
"aria-labelledby": "".concat(_ctx.tab.id, "-label"), |
| 8970 |
class: "cdx-tab", |
| 8971 |
role: "tabpanel", |
| 8972 |
tabindex: "-1" |
| 8973 |
}, [ |
| 8974 |
renderSlot(_ctx.$slots, "default") |
| 8975 |
], 8, _hoisted_1$5)), [ |
| 8976 |
[vShow, _ctx.isActive] |
| 8977 |
]); |
| 8978 |
} |
| 8979 |
const CdxTab = _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]); |
| 8980 |
const _sfc_main$4 = defineComponent({ |
| 8981 |
name: "CdxTabs", |
| 8982 |
components: { |
| 8983 |
CdxButton, |
| 8984 |
CdxIcon |
| 8985 |
}, |
| 8986 |
props: { |
| 8987 |
|
| 8988 |
|
| 8989 |
|
| 8990 |
|
| 8991 |
|
| 8992 |
|
| 8993 |
|
| 8994 |
|
| 8995 |
|
| 8996 |
|
| 8997 |
|
| 8998 |
|
| 8999 |
|
| 9000 |
active: { |
| 9001 |
type: String, |
| 9002 |
default: null |
| 9003 |
}, |
| 9004 |
|
| 9005 |
|
| 9006 |
|
| 9007 |
|
| 9008 |
framed: { |
| 9009 |
type: Boolean, |
| 9010 |
default: false |
| 9011 |
} |
| 9012 |
}, |
| 9013 |
emits: [ |
| 9014 |
|
| 9015 |
|
| 9016 |
|
| 9017 |
|
| 9018 |
|
| 9019 |
|
| 9020 |
"update:active" |
| 9021 |
], |
| 9022 |
|
| 9023 |
|
| 9024 |
|
| 9025 |
|
| 9026 |
expose: [ |
| 9027 |
"select", |
| 9028 |
"next", |
| 9029 |
"prev" |
| 9030 |
], |
| 9031 |
setup(props, { slots, emit }) { |
| 9032 |
const rootElement = ref(); |
| 9033 |
const tabListElement = ref(); |
| 9034 |
const prevScroller = ref(); |
| 9035 |
const nextScroller = ref(); |
| 9036 |
const currentDirection = useComputedDirection(rootElement); |
| 9037 |
const childTabNodes = computed(() => { |
| 9038 |
const slotContents = useSlotContents(slots.default); |
| 9039 |
if (!slotContents.every( |
| 9040 |
(node) => typeof node === "object" && isComponentVNode(node, CdxTab.name) |
| 9041 |
)) { |
| 9042 |
throw new Error("Slot content may only contain CdxTab components"); |
| 9043 |
} |
| 9044 |
if (slotContents.length === 0) { |
| 9045 |
throw new Error("Slot content cannot be empty"); |
| 9046 |
} |
| 9047 |
return slotContents; |
| 9048 |
}); |
| 9049 |
const tabsData = computed(() => { |
| 9050 |
return childTabNodes.value.reduce((map, item) => { |
| 9051 |
var _a; |
| 9052 |
if (((_a = item.props) == null ? void 0 : _a.name) && typeof item.props.name === "string") { |
| 9053 |
if (map.get(item.props.name)) { |
| 9054 |
throw new Error("Tab names must be unique"); |
| 9055 |
} |
| 9056 |
map.set(item.props.name, { |
| 9057 |
name: item.props.name, |
| 9058 |
id: useGeneratedId(item.props.name), |
| 9059 |
label: item.props.label || item.props.name, |
| 9060 |
disabled: item.props.disabled |
| 9061 |
}); |
| 9062 |
} |
| 9063 |
return map; |
| 9064 |
}, new Map()); |
| 9065 |
}); |
| 9066 |
const internalRefForActiveTab = ref(Array.from(tabsData.value.keys())[0]); |
| 9067 |
const activeTab = useOptionalModelWrapper(internalRefForActiveTab, toRef(props, "active"), emit, "update:active"); |
| 9068 |
const tabNames = computed(() => Array.from(tabsData.value.keys())); |
| 9069 |
const activeTabIndex = computed(() => tabNames.value.indexOf(activeTab.value)); |
| 9070 |
const activeTabId = computed(() => { |
| 9071 |
var _a; |
| 9072 |
return (_a = tabsData.value.get(activeTab.value)) == null ? void 0 : _a.id; |
| 9073 |
}); |
| 9074 |
provide(ActiveTabKey, activeTab); |
| 9075 |
provide(TabsKey, tabsData); |
| 9076 |
const tabButtonRefs = ref( new Map()); |
| 9077 |
const firstTabLabel = ref(); |
| 9078 |
const lastTabLabel = ref(); |
| 9079 |
const firstLabelVisible = useIntersectionObserver(firstTabLabel, { threshold: 0.95 }); |
| 9080 |
const lastLabelVisible = useIntersectionObserver(lastTabLabel, { threshold: 0.95 }); |
| 9081 |
function assignTemplateRefForTabButton(templateRef, index) { |
| 9082 |
const el = templateRef; |
| 9083 |
if (el) { |
| 9084 |
tabButtonRefs.value.set(index, el); |
| 9085 |
if (index === 0) { |
| 9086 |
firstTabLabel.value = el; |
| 9087 |
} else if (index === tabNames.value.length - 1) { |
| 9088 |
lastTabLabel.value = el; |
| 9089 |
} |
| 9090 |
} |
| 9091 |
} |
| 9092 |
const rootClasses = computed(() => { |
| 9093 |
return { |
| 9094 |
"cdx-tabs--framed": props.framed, |
| 9095 |
"cdx-tabs--quiet": !props.framed |
| 9096 |
}; |
| 9097 |
}); |
| 9098 |
function focusActiveTab() { |
| 9099 |
var _a; |
| 9100 |
(_a = tabButtonRefs.value.get(activeTabIndex.value)) == null ? void 0 : _a.focus(); |
| 9101 |
} |
| 9102 |
function getScrollDistance(tabLabel) { |
| 9103 |
if (!tabListElement.value || !prevScroller.value || !nextScroller.value) { |
| 9104 |
return 0; |
| 9105 |
} |
| 9106 |
const leftScroller = currentDirection.value === "rtl" ? nextScroller.value : prevScroller.value; |
| 9107 |
const rightScroller = currentDirection.value === "rtl" ? prevScroller.value : nextScroller.value; |
| 9108 |
const labelLeft = tabLabel.offsetLeft; |
| 9109 |
const labelRight = labelLeft + tabLabel.clientWidth; |
| 9110 |
const visibleLeft = tabListElement.value.scrollLeft + leftScroller.clientWidth; |
| 9111 |
const visibleRight = tabListElement.value.scrollLeft + tabListElement.value.clientWidth - rightScroller.clientWidth; |
| 9112 |
if (labelLeft < visibleLeft) { |
| 9113 |
return labelLeft - visibleLeft; |
| 9114 |
} |
| 9115 |
if (labelRight > visibleRight) { |
| 9116 |
return labelRight - visibleRight; |
| 9117 |
} |
| 9118 |
return 0; |
| 9119 |
} |
| 9120 |
function scrollTabs(logicalDirection) { |
| 9121 |
if (!tabListElement.value || !prevScroller.value || !nextScroller.value) { |
| 9122 |
return; |
| 9123 |
} |
| 9124 |
const scrollDirection = logicalDirection === "next" && currentDirection.value === "ltr" || logicalDirection === "prev" && currentDirection.value === "rtl" ? 1 : -1; |
| 9125 |
let scrollDistance = 0; |
| 9126 |
let tabLabel = logicalDirection === "next" ? tabListElement.value.firstElementChild : tabListElement.value.lastElementChild; |
| 9127 |
while (tabLabel) { |
| 9128 |
const nextTabLabel = logicalDirection === "next" ? tabLabel.nextElementSibling : tabLabel.previousElementSibling; |
| 9129 |
scrollDistance = getScrollDistance(tabLabel); |
| 9130 |
if (Math.sign(scrollDistance) === scrollDirection) { |
| 9131 |
if (nextTabLabel && Math.abs(scrollDistance) < 0.25 * tabListElement.value.clientWidth) { |
| 9132 |
scrollDistance = getScrollDistance(nextTabLabel); |
| 9133 |
} |
| 9134 |
break; |
| 9135 |
} |
| 9136 |
tabLabel = nextTabLabel; |
| 9137 |
} |
| 9138 |
tabListElement.value.scrollBy({ |
| 9139 |
left: scrollDistance, |
| 9140 |
behavior: "smooth" |
| 9141 |
}); |
| 9142 |
focusActiveTab(); |
| 9143 |
} |
| 9144 |
watch(activeTab, () => { |
| 9145 |
if (activeTabId.value === void 0 || !tabListElement.value || !prevScroller.value || !nextScroller.value) { |
| 9146 |
return; |
| 9147 |
} |
| 9148 |
const activeTabLabel = document.getElementById("".concat(activeTabId.value, "-label")); |
| 9149 |
if (!activeTabLabel) { |
| 9150 |
return; |
| 9151 |
} |
| 9152 |
tabListElement.value.scrollBy({ |
| 9153 |
left: getScrollDistance(activeTabLabel), |
| 9154 |
behavior: "smooth" |
| 9155 |
}); |
| 9156 |
}); |
| 9157 |
return { |
| 9158 |
activeTab, |
| 9159 |
activeTabIndex, |
| 9160 |
activeTabId, |
| 9161 |
currentDirection, |
| 9162 |
rootElement, |
| 9163 |
tabListElement, |
| 9164 |
prevScroller, |
| 9165 |
nextScroller, |
| 9166 |
rootClasses, |
| 9167 |
tabNames, |
| 9168 |
tabsData, |
| 9169 |
firstLabelVisible, |
| 9170 |
lastLabelVisible, |
| 9171 |
assignTemplateRefForTabButton, |
| 9172 |
scrollTabs, |
| 9173 |
focusActiveTab, |
| 9174 |
cdxIconPrevious: d7, |
| 9175 |
cdxIconNext: j6 |
| 9176 |
}; |
| 9177 |
}, |
| 9178 |
|
| 9179 |
|
| 9180 |
|
| 9181 |
|
| 9182 |
|
| 9183 |
|
| 9184 |
methods: { |
| 9185 |
|
| 9186 |
|
| 9187 |
|
| 9188 |
|
| 9189 |
|
| 9190 |
|
| 9191 |
|
| 9192 |
select(tabName, setFocus) { |
| 9193 |
const target = this.tabsData.get(tabName); |
| 9194 |
if (target && !(target == null ? void 0 : target.disabled)) { |
| 9195 |
this.activeTab = tabName; |
| 9196 |
if (setFocus) { |
| 9197 |
nextTick(() => { |
| 9198 |
this.focusActiveTab(); |
| 9199 |
}); |
| 9200 |
} |
| 9201 |
} |
| 9202 |
}, |
| 9203 |
|
| 9204 |
|
| 9205 |
|
| 9206 |
|
| 9207 |
|
| 9208 |
|
| 9209 |
|
| 9210 |
|
| 9211 |
|
| 9212 |
selectNonDisabled(index, increment, setFocus) { |
| 9213 |
const target = this.tabsData.get(this.tabNames[index + increment]); |
| 9214 |
if (target) { |
| 9215 |
if (target.disabled) { |
| 9216 |
this.selectNonDisabled(index + increment, increment, setFocus); |
| 9217 |
} else { |
| 9218 |
this.select(target.name, setFocus); |
| 9219 |
} |
| 9220 |
} |
| 9221 |
}, |
| 9222 |
|
| 9223 |
|
| 9224 |
|
| 9225 |
|
| 9226 |
|
| 9227 |
|
| 9228 |
next(setFocus) { |
| 9229 |
this.selectNonDisabled(this.activeTabIndex, 1, setFocus); |
| 9230 |
}, |
| 9231 |
|
| 9232 |
|
| 9233 |
|
| 9234 |
|
| 9235 |
|
| 9236 |
|
| 9237 |
prev(setFocus) { |
| 9238 |
this.selectNonDisabled(this.activeTabIndex, -1, setFocus); |
| 9239 |
}, |
| 9240 |
|
| 9241 |
|
| 9242 |
|
| 9243 |
onLeftArrowKeypress() { |
| 9244 |
if (this.currentDirection === "rtl") { |
| 9245 |
this.next(true); |
| 9246 |
} else { |
| 9247 |
this.prev(true); |
| 9248 |
} |
| 9249 |
}, |
| 9250 |
|
| 9251 |
|
| 9252 |
|
| 9253 |
onRightArrowKeypress() { |
| 9254 |
if (this.currentDirection === "rtl") { |
| 9255 |
this.prev(true); |
| 9256 |
} else { |
| 9257 |
this.next(true); |
| 9258 |
} |
| 9259 |
}, |
| 9260 |
|
| 9261 |
|
| 9262 |
|
| 9263 |
|
| 9264 |
onDownArrowKeypress() { |
| 9265 |
var _a; |
| 9266 |
if (this.activeTabId) { |
| 9267 |
(_a = document.getElementById(this.activeTabId)) == null ? void 0 : _a.focus(); |
| 9268 |
} |
| 9269 |
} |
| 9270 |
} |
| 9271 |
}); |
| 9272 |
const _hoisted_1$4 = { class: "cdx-tabs__header" }; |
| 9273 |
const _hoisted_2$2 = { |
| 9274 |
ref: "prevScroller", |
| 9275 |
class: "cdx-tabs__prev-scroller" |
| 9276 |
}; |
| 9277 |
const _hoisted_3$1 = { |
| 9278 |
ref: "tabListElement", |
| 9279 |
class: "cdx-tabs__list", |
| 9280 |
role: "tablist" |
| 9281 |
}; |
| 9282 |
const _hoisted_4$1 = ["id", "disabled", "aria-controls", "aria-selected", "tabindex", "onClick", "onKeyup"]; |
| 9283 |
const _hoisted_5$1 = { |
| 9284 |
ref: "nextScroller", |
| 9285 |
class: "cdx-tabs__next-scroller" |
| 9286 |
}; |
| 9287 |
const _hoisted_6$1 = { class: "cdx-tabs__content" }; |
| 9288 |
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) { |
| 9289 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 9290 |
const _component_cdx_button = resolveComponent("cdx-button"); |
| 9291 |
return openBlock(), createElementBlock( |
| 9292 |
"div", |
| 9293 |
{ |
| 9294 |
ref: "rootElement", |
| 9295 |
class: normalizeClass(["cdx-tabs", _ctx.rootClasses]) |
| 9296 |
}, |
| 9297 |
[ |
| 9298 |
createElementVNode("div", _hoisted_1$4, [ |
| 9299 |
withDirectives(createElementVNode( |
| 9300 |
"div", |
| 9301 |
_hoisted_2$2, |
| 9302 |
[ |
| 9303 |
createVNode(_component_cdx_button, { |
| 9304 |
class: "cdx-tabs__scroll-button", |
| 9305 |
weight: "quiet", |
| 9306 |
type: "button", |
| 9307 |
tabindex: "-1", |
| 9308 |
"aria-hidden": true, |
| 9309 |
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => { |
| 9310 |
}, ["prevent"])), |
| 9311 |
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scrollTabs("prev")) |
| 9312 |
}, { |
| 9313 |
default: withCtx(() => [ |
| 9314 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconPrevious }, null, 8, ["icon"]) |
| 9315 |
]), |
| 9316 |
_: 1 |
| 9317 |
|
| 9318 |
}) |
| 9319 |
], |
| 9320 |
512 |
| 9321 |
|
| 9322 |
), [ |
| 9323 |
[vShow, !_ctx.firstLabelVisible] |
| 9324 |
]), |
| 9325 |
createElementVNode( |
| 9326 |
"div", |
| 9327 |
_hoisted_3$1, |
| 9328 |
[ |
| 9329 |
(openBlock(true), createElementBlock( |
| 9330 |
Fragment, |
| 9331 |
null, |
| 9332 |
renderList(_ctx.tabsData.values(), (tab, index) => { |
| 9333 |
return openBlock(), createElementBlock("button", { |
| 9334 |
id: "".concat(tab.id, "-label"), |
| 9335 |
key: index, |
| 9336 |
ref_for: true, |
| 9337 |
ref: (ref2) => _ctx.assignTemplateRefForTabButton(ref2, index), |
| 9338 |
disabled: tab.disabled ? true : void 0, |
| 9339 |
"aria-controls": tab.id, |
| 9340 |
"aria-selected": tab.name === _ctx.activeTab, |
| 9341 |
tabindex: tab.name === _ctx.activeTab ? void 0 : -1, |
| 9342 |
class: "cdx-tabs__list__item", |
| 9343 |
role: "tab", |
| 9344 |
onClick: withModifiers(($event) => _ctx.select(tab.name), ["prevent"]), |
| 9345 |
onKeyup: withKeys(($event) => _ctx.select(tab.name), ["enter"]), |
| 9346 |
onKeydown: [ |
| 9347 |
_cache[2] || (_cache[2] = withKeys(withModifiers((...args) => _ctx.onRightArrowKeypress && _ctx.onRightArrowKeypress(...args), ["prevent"]), ["right"])), |
| 9348 |
_cache[3] || (_cache[3] = withKeys(withModifiers((...args) => _ctx.onDownArrowKeypress && _ctx.onDownArrowKeypress(...args), ["prevent"]), ["down"])), |
| 9349 |
_cache[4] || (_cache[4] = withKeys(withModifiers((...args) => _ctx.onLeftArrowKeypress && _ctx.onLeftArrowKeypress(...args), ["prevent"]), ["left"])) |
| 9350 |
] |
| 9351 |
}, [ |
| 9352 |
createElementVNode( |
| 9353 |
"span", |
| 9354 |
null, |
| 9355 |
toDisplayString(tab.label), |
| 9356 |
1 |
| 9357 |
|
| 9358 |
) |
| 9359 |
], 40, _hoisted_4$1); |
| 9360 |
}), |
| 9361 |
128 |
| 9362 |
|
| 9363 |
)) |
| 9364 |
], |
| 9365 |
512 |
| 9366 |
|
| 9367 |
), |
| 9368 |
withDirectives(createElementVNode( |
| 9369 |
"div", |
| 9370 |
_hoisted_5$1, |
| 9371 |
[ |
| 9372 |
createVNode(_component_cdx_button, { |
| 9373 |
class: "cdx-tabs__scroll-button", |
| 9374 |
weight: "quiet", |
| 9375 |
type: "button", |
| 9376 |
tabindex: "-1", |
| 9377 |
"aria-hidden": true, |
| 9378 |
onMousedown: _cache[5] || (_cache[5] = withModifiers(() => { |
| 9379 |
}, ["prevent"])), |
| 9380 |
onClick: _cache[6] || (_cache[6] = ($event) => _ctx.scrollTabs("next")) |
| 9381 |
}, { |
| 9382 |
default: withCtx(() => [ |
| 9383 |
createVNode(_component_cdx_icon, { icon: _ctx.cdxIconNext }, null, 8, ["icon"]) |
| 9384 |
]), |
| 9385 |
_: 1 |
| 9386 |
|
| 9387 |
}) |
| 9388 |
], |
| 9389 |
512 |
| 9390 |
|
| 9391 |
), [ |
| 9392 |
[vShow, !_ctx.lastLabelVisible] |
| 9393 |
]) |
| 9394 |
]), |
| 9395 |
createElementVNode("div", _hoisted_6$1, [ |
| 9396 |
renderSlot(_ctx.$slots, "default") |
| 9397 |
]) |
| 9398 |
], |
| 9399 |
2 |
| 9400 |
|
| 9401 |
); |
| 9402 |
} |
| 9403 |
const Tabs = _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]); |
| 9404 |
const statusValidator = makeStringTypeValidator(ValidationStatusTypes); |
| 9405 |
const _sfc_main$3 = defineComponent({ |
| 9406 |
name: "CdxTextArea", |
| 9407 |
components: { CdxIcon }, |
| 9408 |
inheritAttrs: false, |
| 9409 |
props: { |
| 9410 |
|
| 9411 |
|
| 9412 |
|
| 9413 |
|
| 9414 |
|
| 9415 |
modelValue: { |
| 9416 |
type: String, |
| 9417 |
default: "" |
| 9418 |
}, |
| 9419 |
|
| 9420 |
|
| 9421 |
|
| 9422 |
status: { |
| 9423 |
type: String, |
| 9424 |
default: "default", |
| 9425 |
validator: statusValidator |
| 9426 |
}, |
| 9427 |
|
| 9428 |
|
| 9429 |
|
| 9430 |
disabled: { |
| 9431 |
type: Boolean, |
| 9432 |
default: false |
| 9433 |
}, |
| 9434 |
|
| 9435 |
|
| 9436 |
|
| 9437 |
|
| 9438 |
|
| 9439 |
|
| 9440 |
|
| 9441 |
|
| 9442 |
|
| 9443 |
autosize: { |
| 9444 |
type: Boolean, |
| 9445 |
default: false |
| 9446 |
}, |
| 9447 |
|
| 9448 |
|
| 9449 |
|
| 9450 |
startIcon: { |
| 9451 |
type: [String, Object], |
| 9452 |
default: void 0 |
| 9453 |
}, |
| 9454 |
|
| 9455 |
|
| 9456 |
|
| 9457 |
endIcon: { |
| 9458 |
type: [String, Object], |
| 9459 |
default: void 0 |
| 9460 |
} |
| 9461 |
}, |
| 9462 |
emits: [ |
| 9463 |
|
| 9464 |
|
| 9465 |
|
| 9466 |
|
| 9467 |
|
| 9468 |
"update:modelValue" |
| 9469 |
], |
| 9470 |
setup(props, { attrs, emit }) { |
| 9471 |
const wrappedModel = useModelWrapper(toRef(props, "modelValue"), emit); |
| 9472 |
const idAttribute = attrs.id; |
| 9473 |
const { |
| 9474 |
computedDisabled, |
| 9475 |
computedStatus, |
| 9476 |
computedInputId |
| 9477 |
} = useFieldData( |
| 9478 |
toRef(props, "disabled"), |
| 9479 |
toRef(props, "status"), |
| 9480 |
idAttribute |
| 9481 |
); |
| 9482 |
const descriptionId = inject(FieldDescriptionIdKey, void 0); |
| 9483 |
const textareaClasses = computed(() => { |
| 9484 |
return { |
| 9485 |
"cdx-text-area__textarea--has-value": !!wrappedModel.value, |
| 9486 |
"cdx-text-area__textarea--is-autosize": props.autosize |
| 9487 |
}; |
| 9488 |
}); |
| 9489 |
const internalClasses = computed(() => { |
| 9490 |
return { |
| 9491 |
"cdx-text-area--status-default": computedStatus.value === "default", |
| 9492 |
"cdx-text-area--status-error": computedStatus.value === "error", |
| 9493 |
"cdx-text-area--has-start-icon": !!props.startIcon, |
| 9494 |
"cdx-text-area--has-end-icon": !!props.endIcon |
| 9495 |
}; |
| 9496 |
}); |
| 9497 |
const { |
| 9498 |
rootClasses, |
| 9499 |
rootStyle, |
| 9500 |
otherAttrs |
| 9501 |
} = useSplitAttributes(attrs, internalClasses); |
| 9502 |
const otherAttrsMinusId = computed(() => { |
| 9503 |
const _a = otherAttrs.value, { id } = _a, everythingElse = __objRest(_a, ["id"]); |
| 9504 |
return everythingElse; |
| 9505 |
}); |
| 9506 |
const textarea = ref(); |
| 9507 |
function onInput() { |
| 9508 |
if (textarea.value && props.autosize) { |
| 9509 |
textarea.value.style.height = "auto"; |
| 9510 |
textarea.value.style.height = "".concat(textarea.value.scrollHeight, "px"); |
| 9511 |
} |
| 9512 |
} |
| 9513 |
return { |
| 9514 |
rootClasses, |
| 9515 |
rootStyle, |
| 9516 |
wrappedModel, |
| 9517 |
computedDisabled, |
| 9518 |
computedInputId, |
| 9519 |
descriptionId, |
| 9520 |
textareaClasses, |
| 9521 |
otherAttrsMinusId, |
| 9522 |
textarea, |
| 9523 |
onInput |
| 9524 |
}; |
| 9525 |
} |
| 9526 |
}); |
| 9527 |
const _hoisted_1$3 = ["id", "aria-describedby", "disabled"]; |
| 9528 |
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) { |
| 9529 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 9530 |
return openBlock(), createElementBlock( |
| 9531 |
"div", |
| 9532 |
{ |
| 9533 |
class: normalizeClass(["cdx-text-area", _ctx.rootClasses]), |
| 9534 |
style: normalizeStyle(_ctx.rootStyle) |
| 9535 |
}, |
| 9536 |
[ |
| 9537 |
withDirectives(createElementVNode("textarea", mergeProps({ |
| 9538 |
id: _ctx.computedInputId, |
| 9539 |
ref: "textarea" |
| 9540 |
}, _ctx.otherAttrsMinusId, { |
| 9541 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedModel = $event), |
| 9542 |
class: [_ctx.textareaClasses, "cdx-text-area__textarea"], |
| 9543 |
"aria-describedby": _ctx.descriptionId, |
| 9544 |
disabled: _ctx.computedDisabled, |
| 9545 |
onInput: _cache[1] || (_cache[1] = (...args) => _ctx.onInput && _ctx.onInput(...args)) |
| 9546 |
}), null, 16, _hoisted_1$3), [ |
| 9547 |
[vModelText, _ctx.wrappedModel] |
| 9548 |
]), |
| 9549 |
_ctx.startIcon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 9550 |
key: 0, |
| 9551 |
icon: _ctx.startIcon, |
| 9552 |
class: "cdx-text-area__icon-vue cdx-text-area__start-icon" |
| 9553 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 9554 |
_ctx.endIcon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 9555 |
key: 1, |
| 9556 |
icon: _ctx.endIcon, |
| 9557 |
class: "cdx-text-area__icon-vue cdx-text-area__end-icon" |
| 9558 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true) |
| 9559 |
], |
| 9560 |
6 |
| 9561 |
|
| 9562 |
); |
| 9563 |
} |
| 9564 |
const TextArea = _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]); |
| 9565 |
const _sfc_main$2 = defineComponent({ |
| 9566 |
name: "CdxToggleButtonGroup", |
| 9567 |
components: { |
| 9568 |
CdxIcon, |
| 9569 |
CdxToggleButton |
| 9570 |
}, |
| 9571 |
props: { |
| 9572 |
|
| 9573 |
|
| 9574 |
|
| 9575 |
buttons: { |
| 9576 |
type: Array, |
| 9577 |
required: true, |
| 9578 |
validator: (value) => Array.isArray(value) && value.length >= 1 |
| 9579 |
}, |
| 9580 |
|
| 9581 |
|
| 9582 |
|
| 9583 |
|
| 9584 |
|
| 9585 |
|
| 9586 |
|
| 9587 |
|
| 9588 |
|
| 9589 |
|
| 9590 |
|
| 9591 |
modelValue: { |
| 9592 |
type: [String, Number, null, Array], |
| 9593 |
required: true |
| 9594 |
}, |
| 9595 |
|
| 9596 |
|
| 9597 |
|
| 9598 |
|
| 9599 |
|
| 9600 |
|
| 9601 |
disabled: { |
| 9602 |
type: Boolean, |
| 9603 |
default: false |
| 9604 |
} |
| 9605 |
}, |
| 9606 |
emits: [ |
| 9607 |
|
| 9608 |
|
| 9609 |
|
| 9610 |
|
| 9611 |
|
| 9612 |
"update:modelValue" |
| 9613 |
], |
| 9614 |
setup(props, { emit }) { |
| 9615 |
const { |
| 9616 |
rootElement, |
| 9617 |
assignTemplateRef, |
| 9618 |
onFocus, |
| 9619 |
onBlur, |
| 9620 |
onKeydown |
| 9621 |
} = useButtonGroupKeyboardNav(toRef(props, "buttons")); |
| 9622 |
function isSelected(button) { |
| 9623 |
if (Array.isArray(props.modelValue)) { |
| 9624 |
return props.modelValue.indexOf(button.value) !== -1; |
| 9625 |
} else if (props.modelValue !== null) { |
| 9626 |
return props.modelValue === button.value; |
| 9627 |
} |
| 9628 |
return false; |
| 9629 |
} |
| 9630 |
function onUpdate(button, nowSelected) { |
| 9631 |
if (Array.isArray(props.modelValue)) { |
| 9632 |
const wasSelected = props.modelValue.indexOf(button.value) !== -1; |
| 9633 |
if (nowSelected && !wasSelected) { |
| 9634 |
emit("update:modelValue", props.modelValue.concat(button.value)); |
| 9635 |
} else if (!nowSelected && wasSelected) { |
| 9636 |
emit("update:modelValue", props.modelValue.filter((v) => v !== button.value)); |
| 9637 |
} |
| 9638 |
} else { |
| 9639 |
if (nowSelected && props.modelValue !== button.value) { |
| 9640 |
emit("update:modelValue", button.value); |
| 9641 |
} |
| 9642 |
} |
| 9643 |
} |
| 9644 |
return { |
| 9645 |
rootElement, |
| 9646 |
assignTemplateRef, |
| 9647 |
onFocus, |
| 9648 |
onBlur, |
| 9649 |
onKeydown, |
| 9650 |
getButtonLabel, |
| 9651 |
isSelected, |
| 9652 |
onUpdate |
| 9653 |
}; |
| 9654 |
} |
| 9655 |
}); |
| 9656 |
const _hoisted_1$2 = { |
| 9657 |
ref: "rootElement", |
| 9658 |
class: "cdx-toggle-button-group" |
| 9659 |
}; |
| 9660 |
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { |
| 9661 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 9662 |
const _component_cdx_toggle_button = resolveComponent("cdx-toggle-button"); |
| 9663 |
return openBlock(), createElementBlock( |
| 9664 |
"div", |
| 9665 |
_hoisted_1$2, |
| 9666 |
[ |
| 9667 |
(openBlock(true), createElementBlock( |
| 9668 |
Fragment, |
| 9669 |
null, |
| 9670 |
renderList(_ctx.buttons, (button, index) => { |
| 9671 |
return openBlock(), createBlock(_component_cdx_toggle_button, { |
| 9672 |
key: button.value, |
| 9673 |
ref_for: true, |
| 9674 |
ref: (ref2) => _ctx.assignTemplateRef(ref2, index), |
| 9675 |
"model-value": _ctx.isSelected(button), |
| 9676 |
disabled: button.disabled || _ctx.disabled, |
| 9677 |
"aria-label": button.ariaLabel, |
| 9678 |
"onUpdate:modelValue": ($event) => _ctx.onUpdate(button, $event), |
| 9679 |
onFocus: ($event) => _ctx.onFocus(index), |
| 9680 |
onBlur: _ctx.onBlur, |
| 9681 |
onKeydown: _ctx.onKeydown |
| 9682 |
}, { |
| 9683 |
default: withCtx(() => [ |
| 9684 |
renderSlot(_ctx.$slots, "default", { |
| 9685 |
button, |
| 9686 |
selected: _ctx.isSelected(button) |
| 9687 |
}, () => [ |
| 9688 |
button.icon ? (openBlock(), createBlock(_component_cdx_icon, { |
| 9689 |
key: 0, |
| 9690 |
icon: button.icon |
| 9691 |
}, null, 8, ["icon"])) : createCommentVNode("v-if", true), |
| 9692 |
createTextVNode( |
| 9693 |
" " + toDisplayString(_ctx.getButtonLabel(button)), |
| 9694 |
1 |
| 9695 |
|
| 9696 |
) |
| 9697 |
]) |
| 9698 |
]), |
| 9699 |
_: 2 |
| 9700 |
|
| 9701 |
}, 1032, ["model-value", "disabled", "aria-label", "onUpdate:modelValue", "onFocus", "onBlur", "onKeydown"]); |
| 9702 |
}), |
| 9703 |
128 |
| 9704 |
|
| 9705 |
)) |
| 9706 |
], |
| 9707 |
512 |
| 9708 |
|
| 9709 |
); |
| 9710 |
} |
| 9711 |
const ToggleButtonGroup = _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]); |
| 9712 |
const _sfc_main$1 = defineComponent({ |
| 9713 |
name: "CdxToggleSwitch", |
| 9714 |
components: { CdxLabel }, |
| 9715 |
|
| 9716 |
|
| 9717 |
|
| 9718 |
inheritAttrs: false, |
| 9719 |
props: { |
| 9720 |
|
| 9721 |
|
| 9722 |
|
| 9723 |
|
| 9724 |
|
| 9725 |
modelValue: { |
| 9726 |
type: [Boolean, Array], |
| 9727 |
default: false |
| 9728 |
}, |
| 9729 |
|
| 9730 |
|
| 9731 |
|
| 9732 |
|
| 9733 |
|
| 9734 |
inputValue: { |
| 9735 |
type: [String, Number, Boolean], |
| 9736 |
default: false |
| 9737 |
}, |
| 9738 |
|
| 9739 |
|
| 9740 |
|
| 9741 |
|
| 9742 |
|
| 9743 |
|
| 9744 |
alignSwitch: { |
| 9745 |
type: Boolean, |
| 9746 |
default: false |
| 9747 |
}, |
| 9748 |
|
| 9749 |
|
| 9750 |
|
| 9751 |
|
| 9752 |
|
| 9753 |
hideLabel: { |
| 9754 |
type: Boolean, |
| 9755 |
default: false |
| 9756 |
}, |
| 9757 |
|
| 9758 |
|
| 9759 |
|
| 9760 |
disabled: { |
| 9761 |
type: Boolean, |
| 9762 |
default: false |
| 9763 |
} |
| 9764 |
}, |
| 9765 |
emits: [ |
| 9766 |
|
| 9767 |
|
| 9768 |
|
| 9769 |
|
| 9770 |
|
| 9771 |
"update:modelValue" |
| 9772 |
], |
| 9773 |
setup(props, { emit, slots, attrs }) { |
| 9774 |
var _a; |
| 9775 |
useLabelChecker((_a = slots.default) == null ? void 0 : _a.call(slots), attrs, "CdxToggleSwitch"); |
| 9776 |
const input = ref(); |
| 9777 |
const inputId = useGeneratedId("toggle-switch"); |
| 9778 |
const descriptionId = useGeneratedId("description"); |
| 9779 |
const internalClasses = computed(() => { |
| 9780 |
return { |
| 9781 |
"cdx-toggle-switch--align-switch": props.alignSwitch |
| 9782 |
}; |
| 9783 |
}); |
| 9784 |
const { |
| 9785 |
rootClasses, |
| 9786 |
rootStyle, |
| 9787 |
otherAttrs |
| 9788 |
} = useSplitAttributes(attrs, internalClasses); |
| 9789 |
const { computedDisabled } = useFieldData(toRef(props, "disabled")); |
| 9790 |
const wrappedModel = useModelWrapper(toRef(props, "modelValue"), emit); |
| 9791 |
const clickInput = () => { |
| 9792 |
input.value.click(); |
| 9793 |
}; |
| 9794 |
return { |
| 9795 |
input, |
| 9796 |
inputId, |
| 9797 |
descriptionId, |
| 9798 |
rootClasses, |
| 9799 |
rootStyle, |
| 9800 |
otherAttrs, |
| 9801 |
computedDisabled, |
| 9802 |
wrappedModel, |
| 9803 |
clickInput |
| 9804 |
}; |
| 9805 |
} |
| 9806 |
}); |
| 9807 |
const _hoisted_1$1 = ["id", "aria-describedby", "value", "disabled"]; |
| 9808 |
const _hoisted_2$1 = createElementVNode( |
| 9809 |
"span", |
| 9810 |
{ class: "cdx-toggle-switch__switch" }, |
| 9811 |
[ |
| 9812 |
createElementVNode("span", { class: "cdx-toggle-switch__switch__grip" }) |
| 9813 |
], |
| 9814 |
-1 |
| 9815 |
|
| 9816 |
); |
| 9817 |
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { |
| 9818 |
const _component_cdx_label = resolveComponent("cdx-label"); |
| 9819 |
return openBlock(), createElementBlock( |
| 9820 |
"span", |
| 9821 |
{ |
| 9822 |
class: normalizeClass(["cdx-toggle-switch", _ctx.rootClasses]), |
| 9823 |
style: normalizeStyle(_ctx.rootStyle) |
| 9824 |
}, |
| 9825 |
[ |
| 9826 |
withDirectives(createElementVNode("input", mergeProps({ |
| 9827 |
id: _ctx.inputId, |
| 9828 |
ref: "input", |
| 9829 |
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.wrappedModel = $event), |
| 9830 |
class: "cdx-toggle-switch__input", |
| 9831 |
type: "checkbox", |
| 9832 |
role: "switch", |
| 9833 |
"aria-describedby": _ctx.$slots.description && _ctx.$slots.description().length > 0 ? _ctx.descriptionId : void 0, |
| 9834 |
value: _ctx.inputValue, |
| 9835 |
disabled: _ctx.computedDisabled |
| 9836 |
}, _ctx.otherAttrs, { |
| 9837 |
onKeydown: _cache[1] || (_cache[1] = withKeys(withModifiers((...args) => _ctx.clickInput && _ctx.clickInput(...args), ["prevent"]), ["enter"])) |
| 9838 |
}), null, 16, _hoisted_1$1), [ |
| 9839 |
[vModelCheckbox, _ctx.wrappedModel] |
| 9840 |
]), |
| 9841 |
_hoisted_2$1, |
| 9842 |
_ctx.$slots.default && _ctx.$slots.default().length ? (openBlock(), createBlock(_component_cdx_label, { |
| 9843 |
key: 0, |
| 9844 |
class: "cdx-toggle-switch__label", |
| 9845 |
"input-id": _ctx.inputId, |
| 9846 |
"description-id": _ctx.$slots.description && _ctx.$slots.description().length > 0 ? _ctx.descriptionId : void 0, |
| 9847 |
"visually-hidden": _ctx.hideLabel, |
| 9848 |
disabled: _ctx.computedDisabled |
| 9849 |
}, createSlots({ |
| 9850 |
default: withCtx(() => [ |
| 9851 |
renderSlot(_ctx.$slots, "default") |
| 9852 |
]), |
| 9853 |
_: 2 |
| 9854 |
|
| 9855 |
}, [ |
| 9856 |
_ctx.$slots.description && _ctx.$slots.description().length > 0 ? { |
| 9857 |
name: "description", |
| 9858 |
fn: withCtx(() => [ |
| 9859 |
renderSlot(_ctx.$slots, "description") |
| 9860 |
]), |
| 9861 |
key: "0" |
| 9862 |
} : void 0 |
| 9863 |
]), 1032, ["input-id", "description-id", "visually-hidden", "disabled"])) : createCommentVNode("v-if", true) |
| 9864 |
], |
| 9865 |
6 |
| 9866 |
|
| 9867 |
); |
| 9868 |
} |
| 9869 |
const ToggleSwitch = _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]); |
| 9870 |
class Tooltip { |
| 9871 |
constructor(referenceElement, options) { |
| 9872 |
__publicField(this, "referenceElement"); |
| 9873 |
__publicField(this, "tooltipElement"); |
| 9874 |
__publicField(this, "textContent"); |
| 9875 |
__publicField(this, "placement"); |
| 9876 |
__publicField(this, "autoUpdateCleanup"); |
| 9877 |
__publicField(this, "referenceElementHandlers"); |
| 9878 |
__publicField(this, "tooltipElementHandlers"); |
| 9879 |
__publicField(this, "escapeHandler"); |
| 9880 |
__publicField(this, "timeoutId"); |
| 9881 |
var _a, _b; |
| 9882 |
const doc = referenceElement.ownerDocument; |
| 9883 |
const tooltipId = useGeneratedId("tooltip"); |
| 9884 |
this.referenceElement = referenceElement; |
| 9885 |
this.textContent = options.textContent; |
| 9886 |
this.placement = (_a = options.placement) != null ? _a : "bottom"; |
| 9887 |
this.timeoutId = null; |
| 9888 |
this.tooltipElement = doc.createElement("div"); |
| 9889 |
this.tooltipElement.classList.add("cdx-tooltip"); |
| 9890 |
this.tooltipElement.role = "tooltip"; |
| 9891 |
this.tooltipElement.id = tooltipId; |
| 9892 |
this.referenceElement.setAttribute("aria-describedby", tooltipId); |
| 9893 |
this.tooltipElement.textContent = this.textContent; |
| 9894 |
(_b = this.referenceElement.parentElement) == null ? void 0 : _b.appendChild(this.tooltipElement); |
| 9895 |
this.referenceElementHandlers = {}; |
| 9896 |
this.referenceElementHandlers.mouseenter = this.show.bind(this); |
| 9897 |
this.referenceElementHandlers.mouseleave = this.hideAfterDelay.bind(this); |
| 9898 |
this.referenceElementHandlers.focus = this.show.bind(this); |
| 9899 |
this.referenceElementHandlers.blur = this.hide.bind(this); |
| 9900 |
this.tooltipElementHandlers = {}; |
| 9901 |
this.tooltipElementHandlers.mouseenter = this.show.bind(this); |
| 9902 |
this.tooltipElementHandlers.mouseleave = this.hideAfterDelay.bind(this); |
| 9903 |
this.escapeHandler = this.onKeyup.bind(this); |
| 9904 |
this.addEventListeners(); |
| 9905 |
this.autoUpdateCleanup = autoUpdate( |
| 9906 |
this.referenceElement, |
| 9907 |
this.tooltipElement, |
| 9908 |
() => this.update() |
| 9909 |
); |
| 9910 |
} |
| 9911 |
isVisible() { |
| 9912 |
return this.tooltipElement.style.display === "block"; |
| 9913 |
} |
| 9914 |
show() { |
| 9915 |
if (this.timeoutId) { |
| 9916 |
clearTimeout(this.timeoutId); |
| 9917 |
} |
| 9918 |
this.tooltipElement.style.display = "block"; |
| 9919 |
this.tooltipElement.ownerDocument.addEventListener("keyup", this.escapeHandler); |
| 9920 |
} |
| 9921 |
hide() { |
| 9922 |
this.tooltipElement.style.display = "none"; |
| 9923 |
this.tooltipElement.ownerDocument.removeEventListener("keyup", this.escapeHandler); |
| 9924 |
} |
| 9925 |
hideAfterDelay() { |
| 9926 |
this.timeoutId = setTimeout(this.hide.bind(this), 250); |
| 9927 |
} |
| 9928 |
onKeyup(event) { |
| 9929 |
if (event.key === "Escape" && this.isVisible()) { |
| 9930 |
this.hide(); |
| 9931 |
} |
| 9932 |
} |
| 9933 |
addEventListeners() { |
| 9934 |
Object.keys(this.referenceElementHandlers).forEach((k) => { |
| 9935 |
this.referenceElement.addEventListener(k, this.referenceElementHandlers[k]); |
| 9936 |
}); |
| 9937 |
Object.keys(this.tooltipElementHandlers).forEach((k) => { |
| 9938 |
this.tooltipElement.addEventListener(k, this.tooltipElementHandlers[k]); |
| 9939 |
}); |
| 9940 |
} |
| 9941 |
removeEventListeners() { |
| 9942 |
Object.keys(this.referenceElementHandlers).forEach((k) => { |
| 9943 |
this.referenceElement.removeEventListener(k, this.referenceElementHandlers[k]); |
| 9944 |
}); |
| 9945 |
Object.keys(this.tooltipElementHandlers).forEach((k) => { |
| 9946 |
this.tooltipElement.removeEventListener(k, this.tooltipElementHandlers[k]); |
| 9947 |
}); |
| 9948 |
} |
| 9949 |
update() { |
| 9950 |
computePosition(this.referenceElement, this.tooltipElement, { |
| 9951 |
placement: this.placement, |
| 9952 |
middleware: [ |
| 9953 |
offset(4), |
| 9954 |
flip(), |
| 9955 |
shift(), |
| 9956 |
hide() |
| 9957 |
] |
| 9958 |
}).then(({ x, y, middlewareData }) => { |
| 9959 |
var _a, _b, _c; |
| 9960 |
const finalPlacement = (_b = (_a = middlewareData.offset) == null ? void 0 : _a.placement) != null ? _b : this.placement; |
| 9961 |
const opposites = { |
| 9962 |
left: "right", |
| 9963 |
"left-start": "right", |
| 9964 |
"left-end": "right", |
| 9965 |
top: "bottom", |
| 9966 |
"top-start": "bottom", |
| 9967 |
"top-end": "bottom", |
| 9968 |
bottom: "top", |
| 9969 |
"bottom-start": "top", |
| 9970 |
"bottom-end": "top", |
| 9971 |
right: "left", |
| 9972 |
"right-start": "left", |
| 9973 |
"right-end": "left" |
| 9974 |
}; |
| 9975 |
Object.assign(this.tooltipElement.style, { |
| 9976 |
left: "".concat(x, "px"), |
| 9977 |
top: "".concat(y, "px"), |
| 9978 |
visibility: ((_c = middlewareData.hide) == null ? void 0 : _c.referenceHidden) ? "hidden" : "visible", |
| 9979 |
transformOrigin: opposites[finalPlacement] |
| 9980 |
}); |
| 9981 |
}); |
| 9982 |
} |
| 9983 |
remove() { |
| 9984 |
this.tooltipElement.remove(); |
| 9985 |
this.autoUpdateCleanup(); |
| 9986 |
this.removeEventListeners(); |
| 9987 |
} |
| 9988 |
} |
| 9989 |
const CdxTooltip = { |
| 9990 |
mounted(el, { value, arg }) { |
| 9991 |
el.tooltip = new Tooltip(el, { |
| 9992 |
textContent: String(value), |
| 9993 |
placement: arg |
| 9994 |
}); |
| 9995 |
}, |
| 9996 |
beforeUnmount(el) { |
| 9997 |
if (el.tooltip) { |
| 9998 |
el.tooltip.remove(); |
| 9999 |
} |
| 10000 |
} |
| 10001 |
}; |
| 10002 |
const _sfc_main = defineComponent({ |
| 10003 |
name: "CdxTypeaheadSearch", |
| 10004 |
components: { |
| 10005 |
CdxIcon, |
| 10006 |
CdxMenu, |
| 10007 |
CdxSearchInput |
| 10008 |
}, |
| 10009 |
|
| 10010 |
|
| 10011 |
|
| 10012 |
inheritAttrs: false, |
| 10013 |
props: { |
| 10014 |
|
| 10015 |
|
| 10016 |
|
| 10017 |
id: { |
| 10018 |
type: String, |
| 10019 |
required: true |
| 10020 |
}, |
| 10021 |
|
| 10022 |
|
| 10023 |
|
| 10024 |
formAction: { |
| 10025 |
type: String, |
| 10026 |
required: true |
| 10027 |
}, |
| 10028 |
|
| 10029 |
|
| 10030 |
|
| 10031 |
searchResults: { |
| 10032 |
type: Array, |
| 10033 |
required: true |
| 10034 |
}, |
| 10035 |
|
| 10036 |
|
| 10037 |
|
| 10038 |
|
| 10039 |
useButton: { |
| 10040 |
type: Boolean, |
| 10041 |
default: false |
| 10042 |
}, |
| 10043 |
|
| 10044 |
|
| 10045 |
|
| 10046 |
|
| 10047 |
|
| 10048 |
|
| 10049 |
buttonLabel: { |
| 10050 |
type: String, |
| 10051 |
default: "" |
| 10052 |
}, |
| 10053 |
|
| 10054 |
|
| 10055 |
|
| 10056 |
|
| 10057 |
|
| 10058 |
initialInputValue: { |
| 10059 |
type: String, |
| 10060 |
default: "" |
| 10061 |
}, |
| 10062 |
|
| 10063 |
|
| 10064 |
|
| 10065 |
|
| 10066 |
|
| 10067 |
searchFooterUrl: { |
| 10068 |
type: String, |
| 10069 |
default: "" |
| 10070 |
}, |
| 10071 |
|
| 10072 |
|
| 10073 |
|
| 10074 |
debounceInterval: { |
| 10075 |
type: Number, |
| 10076 |
default: DebounceInterval |
| 10077 |
}, |
| 10078 |
|
| 10079 |
|
| 10080 |
|
| 10081 |
highlightQuery: { |
| 10082 |
type: Boolean, |
| 10083 |
default: false |
| 10084 |
}, |
| 10085 |
|
| 10086 |
|
| 10087 |
|
| 10088 |
showThumbnail: { |
| 10089 |
type: Boolean, |
| 10090 |
default: false |
| 10091 |
}, |
| 10092 |
|
| 10093 |
|
| 10094 |
|
| 10095 |
|
| 10096 |
|
| 10097 |
|
| 10098 |
autoExpandWidth: { |
| 10099 |
type: Boolean, |
| 10100 |
default: false |
| 10101 |
}, |
| 10102 |
|
| 10103 |
|
| 10104 |
|
| 10105 |
|
| 10106 |
|
| 10107 |
|
| 10108 |
|
| 10109 |
visibleItemLimit: { |
| 10110 |
type: Number, |
| 10111 |
default: null |
| 10112 |
} |
| 10113 |
}, |
| 10114 |
emits: [ |
| 10115 |
|
| 10116 |
|
| 10117 |
|
| 10118 |
|
| 10119 |
|
| 10120 |
"input", |
| 10121 |
|
| 10122 |
|
| 10123 |
|
| 10124 |
|
| 10125 |
|
| 10126 |
"search-result-click", |
| 10127 |
|
| 10128 |
|
| 10129 |
|
| 10130 |
|
| 10131 |
|
| 10132 |
"submit", |
| 10133 |
|
| 10134 |
|
| 10135 |
|
| 10136 |
|
| 10137 |
|
| 10138 |
|
| 10139 |
"load-more" |
| 10140 |
], |
| 10141 |
setup(props, { attrs, emit, slots }) { |
| 10142 |
const form = ref(); |
| 10143 |
const menu = ref(); |
| 10144 |
const menuId = useGeneratedId("typeahead-search-menu"); |
| 10145 |
const translatedSearchResultsLabel = useI18n("cdx-typeahead-search-search-results-label", "Search results"); |
| 10146 |
const expanded = ref(false); |
| 10147 |
const pending = ref(false); |
| 10148 |
const showPending = ref(false); |
| 10149 |
const isActive = ref(false); |
| 10150 |
const inputValue = ref(props.initialInputValue); |
| 10151 |
const searchQuery = ref(""); |
| 10152 |
const highlightedId = computed(() => { |
| 10153 |
var _a, _b; |
| 10154 |
return (_b = (_a = menu.value) == null ? void 0 : _a.getHighlightedMenuItem()) == null ? void 0 : _b.id; |
| 10155 |
}); |
| 10156 |
const selection = ref(null); |
| 10157 |
const menuMessageClass = computed(() => ({ |
| 10158 |
"cdx-typeahead-search__menu-message--has-thumbnail": props.showThumbnail |
| 10159 |
})); |
| 10160 |
const selectedResult = computed( |
| 10161 |
() => props.searchResults.find( |
| 10162 |
(searchResult) => searchResult.value === selection.value |
| 10163 |
) |
| 10164 |
); |
| 10165 |
const footer = computed( |
| 10166 |
() => props.searchFooterUrl ? { value: MenuFooterValue, url: props.searchFooterUrl } : void 0 |
| 10167 |
); |
| 10168 |
const internalClasses = computed(() => { |
| 10169 |
return { |
| 10170 |
"cdx-typeahead-search--show-thumbnail": props.showThumbnail, |
| 10171 |
"cdx-typeahead-search--expanded": expanded.value, |
| 10172 |
"cdx-typeahead-search--auto-expand-width": props.showThumbnail && props.autoExpandWidth |
| 10173 |
}; |
| 10174 |
}); |
| 10175 |
const { |
| 10176 |
rootClasses, |
| 10177 |
rootStyle, |
| 10178 |
otherAttrs |
| 10179 |
} = useSplitAttributes(attrs, internalClasses); |
| 10180 |
function asSearchResult(menuItem) { |
| 10181 |
return menuItem; |
| 10182 |
} |
| 10183 |
const menuConfig = computed(() => { |
| 10184 |
return { |
| 10185 |
visibleItemLimit: props.visibleItemLimit, |
| 10186 |
showThumbnail: props.showThumbnail, |
| 10187 |
|
| 10188 |
boldLabel: true, |
| 10189 |
hideDescriptionOverflow: true |
| 10190 |
}; |
| 10191 |
}); |
| 10192 |
let debounceId; |
| 10193 |
let pendingDelayId; |
| 10194 |
function onUpdateInputValue(newVal, immediate = false) { |
| 10195 |
if (selectedResult.value && selectedResult.value.label !== newVal && selectedResult.value.value !== newVal) { |
| 10196 |
selection.value = null; |
| 10197 |
} |
| 10198 |
if (pendingDelayId !== void 0) { |
| 10199 |
clearTimeout(pendingDelayId); |
| 10200 |
pendingDelayId = void 0; |
| 10201 |
} |
| 10202 |
if (newVal === "") { |
| 10203 |
expanded.value = false; |
| 10204 |
} else { |
| 10205 |
pending.value = true; |
| 10206 |
if (slots["search-results-pending"]) { |
| 10207 |
pendingDelayId = setTimeout(() => { |
| 10208 |
if (isActive.value) { |
| 10209 |
expanded.value = true; |
| 10210 |
} |
| 10211 |
showPending.value = true; |
| 10212 |
}, PendingDelay); |
| 10213 |
} |
| 10214 |
} |
| 10215 |
if (debounceId !== void 0) { |
| 10216 |
clearTimeout(debounceId); |
| 10217 |
debounceId = void 0; |
| 10218 |
} |
| 10219 |
const handleUpdateInputValue = () => { |
| 10220 |
emit("input", newVal); |
| 10221 |
}; |
| 10222 |
if (immediate) { |
| 10223 |
handleUpdateInputValue(); |
| 10224 |
} else { |
| 10225 |
debounceId = setTimeout(() => { |
| 10226 |
handleUpdateInputValue(); |
| 10227 |
}, props.debounceInterval); |
| 10228 |
} |
| 10229 |
} |
| 10230 |
function onUpdateMenuSelection(newVal) { |
| 10231 |
var _a; |
| 10232 |
if (newVal === MenuFooterValue) { |
| 10233 |
selection.value = null; |
| 10234 |
inputValue.value = searchQuery.value; |
| 10235 |
return; |
| 10236 |
} |
| 10237 |
selection.value = newVal; |
| 10238 |
if (newVal !== null) { |
| 10239 |
inputValue.value = selectedResult.value ? (_a = selectedResult.value.label) != null ? _a : String(selectedResult.value.value) : ""; |
| 10240 |
} |
| 10241 |
} |
| 10242 |
function onFocus() { |
| 10243 |
isActive.value = true; |
| 10244 |
if (searchQuery.value || showPending.value) { |
| 10245 |
expanded.value = true; |
| 10246 |
} |
| 10247 |
} |
| 10248 |
function onBlur() { |
| 10249 |
isActive.value = false; |
| 10250 |
expanded.value = false; |
| 10251 |
} |
| 10252 |
function onSearchResultClick(searchResult) { |
| 10253 |
const _a = searchResult, { id } = _a, resultWithoutId = __objRest(_a, ["id"]); |
| 10254 |
if (resultWithoutId.value === MenuFooterValue) { |
| 10255 |
emit("search-result-click", { |
| 10256 |
searchResult: null, |
| 10257 |
index: props.searchResults.length, |
| 10258 |
numberOfResults: props.searchResults.length |
| 10259 |
}); |
| 10260 |
return; |
| 10261 |
} |
| 10262 |
emitSearchResultClick(resultWithoutId); |
| 10263 |
} |
| 10264 |
function emitSearchResultClick(searchResult) { |
| 10265 |
const searchResultClickEvent = { |
| 10266 |
searchResult, |
| 10267 |
index: props.searchResults.findIndex( |
| 10268 |
(r) => r.value === searchResult.value |
| 10269 |
), |
| 10270 |
numberOfResults: props.searchResults.length |
| 10271 |
}; |
| 10272 |
emit("search-result-click", searchResultClickEvent); |
| 10273 |
} |
| 10274 |
function onSearchResultKeyboardNavigation(searchResult) { |
| 10275 |
var _a; |
| 10276 |
if (searchResult.value === MenuFooterValue) { |
| 10277 |
inputValue.value = searchQuery.value; |
| 10278 |
return; |
| 10279 |
} |
| 10280 |
inputValue.value = searchResult.value ? (_a = searchResult.label) != null ? _a : String(searchResult.value) : ""; |
| 10281 |
} |
| 10282 |
function onSearchFooterClick(footerMenuItem) { |
| 10283 |
var _a; |
| 10284 |
expanded.value = false; |
| 10285 |
(_a = menu.value) == null ? void 0 : _a.clearActive(); |
| 10286 |
onSearchResultClick(footerMenuItem); |
| 10287 |
} |
| 10288 |
function onSubmit(e) { |
| 10289 |
if (selectedResult.value) { |
| 10290 |
emitSearchResultClick(selectedResult.value); |
| 10291 |
e.stopPropagation(); |
| 10292 |
window.location.assign(selectedResult.value.url); |
| 10293 |
e.preventDefault(); |
| 10294 |
} else { |
| 10295 |
const submitEvent = { |
| 10296 |
searchResult: null, |
| 10297 |
index: -1, |
| 10298 |
numberOfResults: props.searchResults.length |
| 10299 |
}; |
| 10300 |
emit("submit", submitEvent); |
| 10301 |
} |
| 10302 |
} |
| 10303 |
function onKeydown(e) { |
| 10304 |
if (!menu.value || !searchQuery.value || e.key === " ") { |
| 10305 |
return; |
| 10306 |
} |
| 10307 |
const highlightedResult = menu.value.getHighlightedMenuItem(); |
| 10308 |
const resultHighlightedViaKeyboard = menu.value.getHighlightedViaKeyboard(); |
| 10309 |
switch (e.key) { |
| 10310 |
case "Enter": |
| 10311 |
if (highlightedResult) { |
| 10312 |
if (highlightedResult.value === MenuFooterValue && resultHighlightedViaKeyboard) { |
| 10313 |
window.location.assign(props.searchFooterUrl); |
| 10314 |
} else { |
| 10315 |
menu.value.delegateKeyNavigation(e, { prevent: false }); |
| 10316 |
} |
| 10317 |
} |
| 10318 |
expanded.value = false; |
| 10319 |
break; |
| 10320 |
case "Tab": |
| 10321 |
expanded.value = false; |
| 10322 |
break; |
| 10323 |
default: |
| 10324 |
menu.value.delegateKeyNavigation(e); |
| 10325 |
break; |
| 10326 |
} |
| 10327 |
} |
| 10328 |
onMounted(() => { |
| 10329 |
if (props.initialInputValue) { |
| 10330 |
onUpdateInputValue(props.initialInputValue, true); |
| 10331 |
} |
| 10332 |
}); |
| 10333 |
watch(toRef(props, "searchResults"), () => { |
| 10334 |
searchQuery.value = inputValue.value.trim(); |
| 10335 |
if (isActive.value && pending.value && searchQuery.value.length > 0) { |
| 10336 |
expanded.value = true; |
| 10337 |
} |
| 10338 |
if (pendingDelayId !== void 0) { |
| 10339 |
clearTimeout(pendingDelayId); |
| 10340 |
pendingDelayId = void 0; |
| 10341 |
} |
| 10342 |
pending.value = false; |
| 10343 |
showPending.value = false; |
| 10344 |
}); |
| 10345 |
return { |
| 10346 |
form, |
| 10347 |
menu, |
| 10348 |
menuId, |
| 10349 |
highlightedId, |
| 10350 |
selection, |
| 10351 |
menuMessageClass, |
| 10352 |
footer, |
| 10353 |
asSearchResult, |
| 10354 |
inputValue, |
| 10355 |
searchQuery, |
| 10356 |
expanded, |
| 10357 |
showPending, |
| 10358 |
rootClasses, |
| 10359 |
rootStyle, |
| 10360 |
otherAttrs, |
| 10361 |
menuConfig, |
| 10362 |
onUpdateInputValue, |
| 10363 |
onUpdateMenuSelection, |
| 10364 |
onFocus, |
| 10365 |
onBlur, |
| 10366 |
onSearchResultClick, |
| 10367 |
onSearchResultKeyboardNavigation, |
| 10368 |
onSearchFooterClick, |
| 10369 |
onSubmit, |
| 10370 |
onKeydown, |
| 10371 |
MenuFooterValue, |
| 10372 |
articleIcon: S3, |
| 10373 |
translatedSearchResultsLabel |
| 10374 |
}; |
| 10375 |
}, |
| 10376 |
methods: { |
| 10377 |
|
| 10378 |
|
| 10379 |
|
| 10380 |
|
| 10381 |
|
| 10382 |
focus() { |
| 10383 |
const searchInput = this.$refs.searchInput; |
| 10384 |
searchInput.focus(); |
| 10385 |
} |
| 10386 |
} |
| 10387 |
}); |
| 10388 |
const _hoisted_1 = ["id", "action"]; |
| 10389 |
const _hoisted_2 = { class: "cdx-typeahead-search__menu-message__text" }; |
| 10390 |
const _hoisted_3 = { class: "cdx-typeahead-search__menu-message__text" }; |
| 10391 |
const _hoisted_4 = ["href", "onClickCapture"]; |
| 10392 |
const _hoisted_5 = { class: "cdx-menu-item__text cdx-typeahead-search__search-footer__text" }; |
| 10393 |
const _hoisted_6 = { class: "cdx-typeahead-search__search-footer__query" }; |
| 10394 |
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { |
| 10395 |
const _component_cdx_icon = resolveComponent("cdx-icon"); |
| 10396 |
const _component_cdx_menu = resolveComponent("cdx-menu"); |
| 10397 |
const _component_cdx_search_input = resolveComponent("cdx-search-input"); |
| 10398 |
return openBlock(), createElementBlock( |
| 10399 |
"div", |
| 10400 |
{ |
| 10401 |
class: normalizeClass(["cdx-typeahead-search", _ctx.rootClasses]), |
| 10402 |
style: normalizeStyle(_ctx.rootStyle) |
| 10403 |
}, |
| 10404 |
[ |
| 10405 |
createElementVNode("form", { |
| 10406 |
id: _ctx.id, |
| 10407 |
ref: "form", |
| 10408 |
class: "cdx-typeahead-search__form", |
| 10409 |
action: _ctx.formAction, |
| 10410 |
onSubmit: _cache[4] || (_cache[4] = (...args) => _ctx.onSubmit && _ctx.onSubmit(...args)) |
| 10411 |
}, [ |
| 10412 |
createVNode(_component_cdx_search_input, mergeProps({ |
| 10413 |
ref: "searchInput", |
| 10414 |
modelValue: _ctx.inputValue, |
| 10415 |
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.inputValue = $event), |
| 10416 |
"button-label": _ctx.buttonLabel, |
| 10417 |
"use-button": _ctx.useButton |
| 10418 |
}, _ctx.otherAttrs, { |
| 10419 |
class: "cdx-typeahead-search__input", |
| 10420 |
name: "search", |
| 10421 |
role: "combobox", |
| 10422 |
autocomplete: "off", |
| 10423 |
"aria-autocomplete": "list", |
| 10424 |
"aria-controls": _ctx.menuId, |
| 10425 |
"aria-expanded": _ctx.expanded, |
| 10426 |
"aria-activedescendant": _ctx.highlightedId, |
| 10427 |
"onUpdate:modelValue": _ctx.onUpdateInputValue, |
| 10428 |
onFocus: _ctx.onFocus, |
| 10429 |
onBlur: _ctx.onBlur, |
| 10430 |
onKeydown: _ctx.onKeydown |
| 10431 |
}), { |
| 10432 |
default: withCtx(() => [ |
| 10433 |
createVNode(_component_cdx_menu, mergeProps({ |
| 10434 |
id: _ctx.menuId, |
| 10435 |
ref: "menu", |
| 10436 |
expanded: _ctx.expanded, |
| 10437 |
"onUpdate:expanded": _cache[0] || (_cache[0] = ($event) => _ctx.expanded = $event), |
| 10438 |
class: "cdx-typeahead-search__menu", |
| 10439 |
"show-pending": _ctx.showPending, |
| 10440 |
selected: _ctx.selection, |
| 10441 |
"menu-items": _ctx.searchResults, |
| 10442 |
footer: _ctx.footer, |
| 10443 |
"search-query": _ctx.highlightQuery ? _ctx.searchQuery : "", |
| 10444 |
"show-no-results-slot": _ctx.searchQuery.length > 0 && _ctx.searchResults.length === 0 && _ctx.$slots["search-no-results-text"] && _ctx.$slots["search-no-results-text"]().length > 0 |
| 10445 |
}, _ctx.menuConfig, { |
| 10446 |
"aria-label": _ctx.translatedSearchResultsLabel, |
| 10447 |
"onUpdate:selected": _ctx.onUpdateMenuSelection, |
| 10448 |
onMenuItemClick: _cache[1] || (_cache[1] = (menuItem) => _ctx.onSearchResultClick(_ctx.asSearchResult(menuItem))), |
| 10449 |
onMenuItemKeyboardNavigation: _ctx.onSearchResultKeyboardNavigation, |
| 10450 |
onLoadMore: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("load-more")) |
| 10451 |
}), { |
| 10452 |
pending: withCtx(() => [ |
| 10453 |
createElementVNode( |
| 10454 |
"div", |
| 10455 |
{ |
| 10456 |
class: normalizeClass(["cdx-menu-item__content cdx-typeahead-search__menu-message", _ctx.menuMessageClass]) |
| 10457 |
}, |
| 10458 |
[ |
| 10459 |
createElementVNode("span", _hoisted_2, [ |
| 10460 |
renderSlot(_ctx.$slots, "search-results-pending") |
| 10461 |
]) |
| 10462 |
], |
| 10463 |
2 |
| 10464 |
|
| 10465 |
) |
| 10466 |
]), |
| 10467 |
"no-results": withCtx(() => [ |
| 10468 |
createElementVNode( |
| 10469 |
"div", |
| 10470 |
{ |
| 10471 |
class: normalizeClass(["cdx-menu-item__content cdx-typeahead-search__menu-message", _ctx.menuMessageClass]) |
| 10472 |
}, |
| 10473 |
[ |
| 10474 |
createElementVNode("span", _hoisted_3, [ |
| 10475 |
renderSlot(_ctx.$slots, "search-no-results-text") |
| 10476 |
]) |
| 10477 |
], |
| 10478 |
2 |
| 10479 |
|
| 10480 |
) |
| 10481 |
]), |
| 10482 |
default: withCtx(({ menuItem, active }) => [ |
| 10483 |
menuItem.value === _ctx.MenuFooterValue ? (openBlock(), createElementBlock("a", { |
| 10484 |
key: 0, |
| 10485 |
class: normalizeClass(["cdx-menu-item__content cdx-typeahead-search__search-footer", { |
| 10486 |
"cdx-typeahead-search__search-footer__active": active |
| 10487 |
}]), |
| 10488 |
href: _ctx.asSearchResult(menuItem).url, |
| 10489 |
onClickCapture: withModifiers(($event) => _ctx.onSearchFooterClick(_ctx.asSearchResult(menuItem)), ["stop"]) |
| 10490 |
}, [ |
| 10491 |
createVNode(_component_cdx_icon, { |
| 10492 |
class: "cdx-menu-item__thumbnail cdx-typeahead-search__search-footer__icon", |
| 10493 |
icon: _ctx.articleIcon |
| 10494 |
}, null, 8, ["icon"]), |
| 10495 |
createElementVNode("span", _hoisted_5, [ |
| 10496 |
renderSlot(_ctx.$slots, "search-footer-text", { searchQuery: _ctx.searchQuery }, () => [ |
| 10497 |
createElementVNode( |
| 10498 |
"strong", |
| 10499 |
_hoisted_6, |
| 10500 |
toDisplayString(_ctx.searchQuery), |
| 10501 |
1 |
| 10502 |
|
| 10503 |
) |
| 10504 |
]) |
| 10505 |
]) |
| 10506 |
], 42, _hoisted_4)) : createCommentVNode("v-if", true) |
| 10507 |
]), |
| 10508 |
_: 3 |
| 10509 |
|
| 10510 |
}, 16, ["id", "expanded", "show-pending", "selected", "menu-items", "footer", "search-query", "show-no-results-slot", "aria-label", "onUpdate:selected", "onMenuItemKeyboardNavigation"]) |
| 10511 |
]), |
| 10512 |
_: 3 |
| 10513 |
|
| 10514 |
}, 16, ["modelValue", "button-label", "use-button", "aria-controls", "aria-expanded", "aria-activedescendant", "onUpdate:modelValue", "onFocus", "onBlur", "onKeydown"]), |
| 10515 |
renderSlot(_ctx.$slots, "default") |
| 10516 |
], 40, _hoisted_1) |
| 10517 |
], |
| 10518 |
6 |
| 10519 |
|
| 10520 |
); |
| 10521 |
} |
| 10522 |
const TypeaheadSearch = _export_sfc(_sfc_main, [["render", _sfc_render]]); |
| 10523 |
export { |
| 10524 |
Accordion as CdxAccordion, |
| 10525 |
CdxButton, |
| 10526 |
ButtonGroup as CdxButtonGroup, |
| 10527 |
Card as CdxCard, |
| 10528 |
CdxCheckbox, |
| 10529 |
CdxChipInput, |
| 10530 |
Combobox as CdxCombobox, |
| 10531 |
Dialog as CdxDialog, |
| 10532 |
Field as CdxField, |
| 10533 |
CdxIcon, |
| 10534 |
InfoChip as CdxInfoChip, |
| 10535 |
CdxLabel, |
| 10536 |
Lookup as CdxLookup, |
| 10537 |
CdxMenu, |
| 10538 |
MenuButton as CdxMenuButton, |
| 10539 |
CdxMenuItem, |
| 10540 |
CdxMessage, |
| 10541 |
MultiselectLookup as CdxMultiselectLookup, |
| 10542 |
CdxProgressBar, |
| 10543 |
Radio as CdxRadio, |
| 10544 |
CdxSearchInput, |
| 10545 |
CdxSearchResultTitle, |
| 10546 |
CdxSelect, |
| 10547 |
CdxTab, |
| 10548 |
Table as CdxTable, |
| 10549 |
Tabs as CdxTabs, |
| 10550 |
TextArea as CdxTextArea, |
| 10551 |
CdxTextInput, |
| 10552 |
CdxThumbnail, |
| 10553 |
CdxToggleButton, |
| 10554 |
ToggleButtonGroup as CdxToggleButtonGroup, |
| 10555 |
ToggleSwitch as CdxToggleSwitch, |
| 10556 |
CdxTooltip, |
| 10557 |
TypeaheadSearch as CdxTypeaheadSearch, |
| 10558 |
TableRowIdentifier, |
| 10559 |
stringHelpers, |
| 10560 |
useComputedDirection, |
| 10561 |
useComputedDisabled, |
| 10562 |
useComputedLanguage, |
| 10563 |
useFieldData, |
| 10564 |
useFloatingMenu, |
| 10565 |
useGeneratedId, |
| 10566 |
useI18n, |
| 10567 |
useIntersectionObserver, |
| 10568 |
useModelWrapper, |
| 10569 |
useResizeObserver, |
| 10570 |
useSlotContents, |
| 10571 |
useSplitAttributes, |
| 10572 |
useWarnOnce |
| 10573 |
}; |