@pequity/squirrel 5.4.5 → 5.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  const vue = require("vue");
3
3
  const pDropdown = require("../p-dropdown.js");
4
+ const pIcon_vue_vue_type_script_setup_true_lang = require("./p-icon.js");
4
5
  const pInputSearch = require("../p-input-search.js");
5
6
  const pSelectList = require("../p-select-list.js");
6
7
  const lodashEs = require("lodash-es");
@@ -124,6 +125,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
124
125
  type: Boolean,
125
126
  default: false
126
127
  },
128
+ clearable: {
129
+ type: Boolean,
130
+ default: false
131
+ },
127
132
  /**
128
133
  * Enables multiple selection
129
134
  */
@@ -174,6 +179,11 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
174
179
  noAutoFocus: true,
175
180
  enableArrowNavigation: false
176
181
  };
182
+ const CLEAR_BUTTON_SPACING = {
183
+ sm: "right-8",
184
+ md: "right-9",
185
+ lg: "right-10"
186
+ };
177
187
  const width = vue.ref("auto");
178
188
  const listItemStyle = vue.ref({ paddingTop: 0, paddingBottom: 0 });
179
189
  const dropdownShow = vue.ref(false);
@@ -297,18 +307,18 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
297
307
  class: vue.normalizeClass([
298
308
  vue.unref(selectedItems).length !== vue.unref(internalItems).length ? "cursor-pointer" : "pointer-events-none opacity-50"
299
309
  ]),
300
- onClick: _cache[1] || (_cache[1] = //@ts-ignore
310
+ onClick: _cache[2] || (_cache[2] = //@ts-ignore
301
311
  (...args) => vue.unref(selectAll) && vue.unref(selectAll)(...args))
302
312
  }, " Select all ", 2)) : (vue.openBlock(), vue.createElementBlock("a", {
303
313
  key: 1,
304
314
  class: vue.normalizeClass([vue.unref(computedInsideSelected) ? "pointer-events-none opacity-50" : "cursor-pointer"]),
305
- onClick: _cache[2] || (_cache[2] = //@ts-ignore
315
+ onClick: _cache[3] || (_cache[3] = //@ts-ignore
306
316
  (...args) => vue.unref(selectAll) && vue.unref(selectAll)(...args))
307
317
  }, " Select all filtered ", 2)),
308
- _cache[6] || (_cache[6] = vue.createElementVNode("span", { class: "px-1 leading-none" }, ".", -1)),
318
+ _cache[7] || (_cache[7] = vue.createElementVNode("span", { class: "px-1 leading-none" }, ".", -1)),
309
319
  vue.createElementVNode("a", {
310
320
  class: vue.normalizeClass([vue.unref(selectedItems).length ? "cursor-pointer" : "pointer-events-none opacity-50"]),
311
- onClick: _cache[3] || (_cache[3] = //@ts-ignore
321
+ onClick: _cache[4] || (_cache[4] = //@ts-ignore
312
322
  (...args) => vue.unref(clearAll) && vue.unref(clearAll)(...args))
313
323
  }, " Clear all ", 2)
314
324
  ])
@@ -321,7 +331,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
321
331
  ref_key: "inputSearch",
322
332
  ref: inputSearch,
323
333
  modelValue: vue.unref(search),
324
- "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => vue.isRef(search) ? search.value = $event : null),
334
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => vue.isRef(search) ? search.value = $event : null),
325
335
  size: __props.size,
326
336
  placeholder: __props.placeholderSearch
327
337
  }, null, 8, ["modelValue", "size", "placeholder"])
@@ -337,7 +347,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
337
347
  class: "relative w-full",
338
348
  "p-select-list-options": "",
339
349
  style: vue.normalizeStyle({ height: `${vue.unref(rowVirtualizer).getTotalSize()}px` }),
340
- onMousemove: _cache[5] || (_cache[5] = //@ts-ignore
350
+ onMousemove: _cache[6] || (_cache[6] = //@ts-ignore
341
351
  (...args) => vue.unref(onMousemove) && vue.unref(onMousemove)(...args))
342
352
  }, [
343
353
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(rowVirtualizer).getVirtualItems(), (row) => {
@@ -403,14 +413,26 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
403
413
  class: ["w-full", vue.unref(selectClasses), dropdownShow.value ? "border-primary" : ""],
404
414
  role: "button",
405
415
  "aria-haspopup": "listbox",
406
- onClick: _cache[0] || (_cache[0] = ($event) => dropdownShow.value = !dropdownShow.value)
416
+ onClick: _cache[1] || (_cache[1] = ($event) => dropdownShow.value = !dropdownShow.value)
407
417
  }), [
408
418
  !vue.unref(internalValue).length || !vue.unref(selectedItems).length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, vue.toDisplayString(__props.placeholder || " "), 1)) : vue.renderSlot(_ctx.$slots, "selected-item", {
409
419
  key: 1,
410
420
  item: __props.multiple ? vue.unref(selectedItems) : vue.unref(selectedItems)[0]
411
421
  }, () => [
412
422
  vue.createElementVNode("div", _hoisted_3, vue.toDisplayString(__props.multiple && vue.unref(selectedItems).length > 1 ? `${vue.unref(selectedItems).length} option${vue.unref(selectedItems).length > 1 ? "s" : ""} selected` : vue.unref(selectedItems)[0][__props.itemText]), 1)
413
- ])
423
+ ]),
424
+ __props.clearable && vue.unref(internalValue).length ? (vue.openBlock(), vue.createElementBlock("button", {
425
+ key: 2,
426
+ class: vue.normalizeClass(["absolute top-1/2 flex -translate-y-1/2 items-center justify-center text-p-gray-40 hover:text-p-gray-60", [vue.unref(pSelectList.SIZES)[__props.size], CLEAR_BUTTON_SPACING[__props.size]]]),
427
+ "aria-label": "Clear selection",
428
+ onClick: _cache[0] || (_cache[0] = vue.withModifiers(
429
+ //@ts-ignore
430
+ (...args) => vue.unref(clearAll) && vue.unref(clearAll)(...args),
431
+ ["stop"]
432
+ ))
433
+ }, [
434
+ vue.createVNode(pIcon_vue_vue_type_script_setup_true_lang._sfc_main, { icon: "fe:close" })
435
+ ], 2)) : vue.createCommentVNode("", true)
414
436
  ], 16)
415
437
  ]),
416
438
  _: 3