@pequity/squirrel 8.4.1 → 8.4.2

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.
Files changed (53) hide show
  1. package/dist/cjs/chunks/index.js +3 -4
  2. package/dist/cjs/chunks/p-dropdown-select.js +12 -10
  3. package/dist/cjs/chunks/p-icon.js +13 -16
  4. package/dist/cjs/chunks/p-steps.js +58 -0
  5. package/dist/cjs/dom.js +1 -2
  6. package/dist/cjs/index.js +36 -89
  7. package/dist/cjs/listKeyboardNavigation.js +2 -2
  8. package/dist/cjs/p-dropdown.js +1 -2
  9. package/dist/cjs/p-file-upload.js +1 -2
  10. package/dist/cjs/p-input-search.js +1 -2
  11. package/dist/cjs/p-modal.js +4 -7
  12. package/dist/cjs/p-skeleton-loader.js +1 -4
  13. package/dist/cjs/p-steps.js +2 -0
  14. package/dist/cjs/usePLoading.js +2 -8
  15. package/dist/cjs/usePTableColResize.js +1 -2
  16. package/dist/cjs/usePTableRowVirtualizer.js +2 -2
  17. package/dist/cjs/useSelectList.js +13 -21
  18. package/dist/es/chunks/index.js +3 -4
  19. package/dist/es/chunks/p-dropdown-select.js +14 -12
  20. package/dist/es/chunks/p-icon.js +13 -16
  21. package/dist/es/chunks/p-steps.js +59 -0
  22. package/dist/es/dom.js +1 -2
  23. package/dist/es/index.js +69 -122
  24. package/dist/es/listKeyboardNavigation.js +2 -2
  25. package/dist/es/p-dropdown-select.js +1 -1
  26. package/dist/es/p-dropdown.js +1 -2
  27. package/dist/es/p-file-upload.js +1 -2
  28. package/dist/es/p-input-search.js +1 -2
  29. package/dist/es/p-modal.js +4 -7
  30. package/dist/es/p-skeleton-loader.js +1 -4
  31. package/dist/es/p-steps.js +4 -1
  32. package/dist/es/usePLoading.js +2 -8
  33. package/dist/es/usePTableColResize.js +1 -2
  34. package/dist/es/usePTableRowVirtualizer.js +2 -2
  35. package/dist/es/useSelectList.js +13 -21
  36. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +2 -2
  37. package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +2 -2
  38. package/dist/squirrel/components/p-input/p-input.vue.d.ts +1 -1
  39. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +2 -2
  40. package/dist/squirrel/components/p-link/p-link.vue.d.ts +2 -2
  41. package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +6 -6
  42. package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +2 -2
  43. package/dist/squirrel/components/p-table/p-table.vue.d.ts +1 -1
  44. package/dist/squirrel.css +74 -74
  45. package/package.json +21 -24
  46. package/squirrel/components/p-action-bar/p-action-bar.stories.js +4 -3
  47. package/squirrel/components/p-dropdown-select/p-dropdown-select.spec.js +26 -4
  48. package/squirrel/components/p-dropdown-select/p-dropdown-select.vue +3 -2
  49. package/squirrel/components/p-input-number/p-input-number.stories.js +2 -1
  50. package/squirrel/components/p-select-list/p-select-list.spec.js +22 -4
  51. package/squirrel/components/p-select-list/p-select-list.vue +3 -2
  52. package/squirrel/components/p-select-list/useSelectList.ts +2 -2
  53. package/squirrel/components/p-tabs/p-tabs.stories.js +2 -1
@@ -28,9 +28,9 @@ const createInternalValue = (modelValue, valueIsObject, multiple, itemValue, int
28
28
  const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
29
29
  const nextLoop = (ms) => new Promise((resolve) => setTimeout(resolve, ms || 0));
30
30
  const LIST_ITEM_SIZES = { sm: 32, md: 40, lg: 48 };
31
- const LIST_ITEM_CLASS = "clear-both block w-full cursor-pointer whitespace-nowrap py-1 px-3 text-left text-sm font-medium hover:bg-p-blue-10";
31
+ const LIST_ITEM_CLASS = "clear-both block w-full whitespace-nowrap py-1 px-3 text-left text-sm font-medium hover:bg-p-blue-10";
32
32
  const LIST_ITEM_ACTIVE_CLASS = "selected";
33
- const LIST_ITEM_DISABLED_CLASS = "opacity-30 pointer-events-none";
33
+ const LIST_ITEM_DISABLED_CLASS = "opacity-30 cursor-default";
34
34
  const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
35
35
  let navigationSvc = null;
36
36
  const internalItems = vue.ref([]);
@@ -65,14 +65,8 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
65
65
  };
66
66
  })
67
67
  );
68
- const getValue = (index) => {
69
- var _a;
70
- return (_a = computedItems.value[index]) == null ? void 0 : _a[props.itemValue];
71
- };
72
- const getText = (index) => {
73
- var _a;
74
- return (_a = computedItems.value[index]) == null ? void 0 : _a[props.itemText];
75
- };
68
+ const getValue = (index) => computedItems.value[index]?.[props.itemValue];
69
+ const getText = (index) => computedItems.value[index]?.[props.itemText];
76
70
  vue.watch(
77
71
  () => props.modelValue,
78
72
  (nV) => {
@@ -107,7 +101,7 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
107
101
  }
108
102
  });
109
103
  vue.onUnmounted(() => {
110
- navigationSvc == null ? void 0 : navigationSvc.destroy();
104
+ navigationSvc?.destroy();
111
105
  navigationSvc = null;
112
106
  });
113
107
  const putSelectedItemsOnTop = () => {
@@ -128,10 +122,9 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
128
122
  }
129
123
  };
130
124
  const select = async (e, val) => {
131
- var _a, _b;
132
125
  const el = e.currentTarget;
133
- if (props.multiple && props.searchable && document.activeElement !== ((_a = inputSearch.value) == null ? void 0 : _a.$el.querySelector("input"))) {
134
- (_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
126
+ if (props.multiple && props.searchable && document.activeElement !== inputSearch.value?.$el.querySelector("input")) {
127
+ inputSearch.value?.$el.querySelector("input").focus();
135
128
  }
136
129
  if (props.multiple) {
137
130
  if (!isSelected(val)) {
@@ -143,7 +136,7 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
143
136
  emit("update:modelValue", props.valueIsObject ? getItemByValue(val) : val);
144
137
  }
145
138
  await vue.nextTick();
146
- navigationSvc == null ? void 0 : navigationSvc.setFocusedItem(el.parentElement);
139
+ navigationSvc?.setFocusedItem(el.parentElement);
147
140
  emit("select", val);
148
141
  };
149
142
  const toArrOfObjIfNeeded = (arr) => {
@@ -175,22 +168,21 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
175
168
  }
176
169
  };
177
170
  const destroyNavigationSvc = () => {
178
- navigationSvc == null ? void 0 : navigationSvc.destroy();
171
+ navigationSvc?.destroy();
179
172
  navigationSvc = null;
180
173
  };
181
174
  const onFocus = async () => {
182
175
  setupNavigationSvc();
183
176
  };
184
177
  const onMousemove = () => {
185
- navigationSvc == null ? void 0 : navigationSvc.clearFocusedState();
178
+ navigationSvc?.clearFocusedState();
186
179
  };
187
180
  const scrollScrollerToTop = async () => {
188
181
  rowVirtualizer.value.scrollToOffset(0);
189
182
  await nextFrame();
190
183
  };
191
184
  const scrollToActiveItem = async (options) => {
192
- var _a;
193
- if (options == null ? void 0 : options.wait) {
185
+ if (options?.wait) {
194
186
  await nextLoop(options.wait);
195
187
  }
196
188
  const activeIndex = getActiveItemIndex();
@@ -200,8 +192,8 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
200
192
  });
201
193
  await nextLoop();
202
194
  await nextFrame();
203
- const activeEl = (_a = virtualizerRef.value) == null ? void 0 : _a.querySelector(`.${LIST_ITEM_ACTIVE_CLASS}`);
204
- navigationSvc == null ? void 0 : navigationSvc.setFocusedItem(activeEl == null ? void 0 : activeEl.parentNode);
195
+ const activeEl = virtualizerRef.value?.querySelector(`.${LIST_ITEM_ACTIVE_CLASS}`);
196
+ navigationSvc?.setFocusedItem(activeEl?.parentNode);
205
197
  }
206
198
  };
207
199
  const getActiveItemIndex = () => {
@@ -44,7 +44,6 @@ const createClassGroupUtils = (config) => {
44
44
  };
45
45
  };
46
46
  const getGroupRecursive = (classParts, classPartObject) => {
47
- var _a;
48
47
  if (classParts.length === 0) {
49
48
  return classPartObject.classGroupId;
50
49
  }
@@ -58,15 +57,15 @@ const getGroupRecursive = (classParts, classPartObject) => {
58
57
  return void 0;
59
58
  }
60
59
  const classRest = classParts.join(CLASS_PART_SEPARATOR);
61
- return (_a = classPartObject.validators.find(({
60
+ return classPartObject.validators.find(({
62
61
  validator
63
- }) => validator(classRest))) == null ? void 0 : _a.classGroupId;
62
+ }) => validator(classRest))?.classGroupId;
64
63
  };
65
64
  const arbitraryPropertyRegex = /^\[(.+)\]$/;
66
65
  const getGroupIdForArbitraryProperty = (className) => {
67
66
  if (arbitraryPropertyRegex.test(className)) {
68
67
  const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
69
- const property = arbitraryPropertyClassName == null ? void 0 : arbitraryPropertyClassName.substring(0, arbitraryPropertyClassName.indexOf(":"));
68
+ const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(":"));
70
69
  if (property) {
71
70
  return "arbitrary.." + property;
72
71
  }
@@ -37,6 +37,10 @@ const _hoisted_12 = {
37
37
  class: "ml-auto fill-p-purple-60 pl-2",
38
38
  src: _imports_0
39
39
  };
40
+ const _hoisted_13 = {
41
+ key: 1,
42
+ class: "ml-auto h-4 w-[26px] pl-2"
43
+ };
40
44
  const _sfc_main = /* @__PURE__ */ defineComponent({
41
45
  ...{
42
46
  name: "PDropdownSelect",
@@ -281,23 +285,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
281
285
  formControl.value && observer && observer.unobserve(formControl.value);
282
286
  });
283
287
  const onShow = async () => {
284
- var _a, _b;
285
- const actionsContainerHeight = ((_a = actionsContainer.value) == null ? void 0 : _a.clientHeight) || 0;
288
+ const actionsContainerHeight = actionsContainer.value?.clientHeight || 0;
286
289
  scrollerStyle.value = { maxHeight: `${computedItemSize.value * props.itemsVisible - actionsContainerHeight}px` };
287
290
  search.value = "";
288
291
  setupNavigationSvc();
289
292
  if (props.searchable) {
290
293
  await nextLoop();
291
294
  await nextFrame();
292
- (_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
295
+ inputSearch.value?.$el.querySelector("input").focus();
293
296
  }
294
297
  scrollToActiveItem();
295
298
  };
296
299
  const onHide = () => {
297
- var _a, _b;
298
300
  dropdownShow.value = false;
299
301
  destroyNavigationSvc();
300
- (_b = (_a = formControl.value) == null ? void 0 : _a.querySelector("button")) == null ? void 0 : _b.focus();
302
+ formControl.value?.querySelector("button")?.focus();
301
303
  };
302
304
  const handleCreate = () => {
303
305
  emit("create", search.value);
@@ -398,13 +400,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
398
400
  class: normalizeClass([
399
401
  unref(LIST_ITEM_CLASS),
400
402
  {
401
- [unref(LIST_ITEM_ACTIVE_CLASS)]: unref(isSelected)(unref(getValue)(row.index)),
402
- [unref(LIST_ITEM_DISABLED_CLASS)]: unref(isDisabled)(unref(computedItems)[row.index])
403
- }
403
+ [unref(LIST_ITEM_ACTIVE_CLASS)]: unref(isSelected)(unref(getValue)(row.index))
404
+ },
405
+ unref(isDisabled)(unref(computedItems)[row.index]) ? unref(LIST_ITEM_DISABLED_CLASS) : "cursor-pointer"
404
406
  ]),
405
407
  "p-select-list-option-item": "",
406
408
  style: normalizeStyle(listItemStyle.value),
407
- onClick: ($event) => unref(select)($event, unref(getValue)(row.index))
409
+ onClick: ($event) => !unref(isDisabled)(unref(computedItems)[row.index]) && unref(select)($event, unref(getValue)(row.index))
408
410
  }, [
409
411
  createElementVNode("div", {
410
412
  class: normalizeClass(["flex items-center", { [unref(SIZES)[__props.size]]: !__props.itemSize }])
@@ -426,7 +428,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
426
428
  }), 128))
427
429
  ], 8, _hoisted_11)
428
430
  ]),
429
- unref(isSelected)(unref(getValue)(row.index)) ? (openBlock(), createElementBlock("img", _hoisted_12)) : createCommentVNode("", true)
431
+ unref(isSelected)(unref(getValue)(row.index)) ? (openBlock(), createElementBlock("img", _hoisted_12)) : (openBlock(), createElementBlock("div", _hoisted_13))
430
432
  ], 2)
431
433
  ], 14, _hoisted_10)), [
432
434
  [_directive_close_popper, !__props.multiple]
@@ -526,6 +528,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
526
528
  }
527
529
  });
528
530
  export {
529
- _sfc_main as _,
530
- _imports_0 as a
531
+ _imports_0 as _,
532
+ _sfc_main as a
531
533
  };
@@ -1,6 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
1
  import { defineComponent, createElementBlock, openBlock, unref } from "vue";
5
2
  import { P_ICON_ALIASES } from "../p-icon.js";
6
3
  /**
@@ -1741,24 +1738,24 @@ function defineIconifyIcon(name = "iconify-icon") {
1741
1738
  "flip"
1742
1739
  ];
1743
1740
  const IconifyIcon = class extends ParentClass {
1741
+ // Root
1742
+ _shadowRoot;
1743
+ // Initialised
1744
+ _initialised = false;
1745
+ // Icon state
1746
+ _state;
1747
+ // Attributes check queued
1748
+ _checkQueued = false;
1749
+ // Connected
1750
+ _connected = false;
1751
+ // Observer
1752
+ _observer = null;
1753
+ _visible = true;
1744
1754
  /**
1745
1755
  * Constructor
1746
1756
  */
1747
1757
  constructor() {
1748
1758
  super();
1749
- // Root
1750
- __publicField(this, "_shadowRoot");
1751
- // Initialised
1752
- __publicField(this, "_initialised", false);
1753
- // Icon state
1754
- __publicField(this, "_state");
1755
- // Attributes check queued
1756
- __publicField(this, "_checkQueued", false);
1757
- // Connected
1758
- __publicField(this, "_connected", false);
1759
- // Observer
1760
- __publicField(this, "_observer", null);
1761
- __publicField(this, "_visible", true);
1762
1759
  const root = this._shadowRoot = this.attachShadow({
1763
1760
  mode: "open"
1764
1761
  });
@@ -0,0 +1,59 @@
1
+ import { defineComponent, computed, createElementBlock, openBlock, Fragment, renderList, createElementVNode, createCommentVNode, normalizeClass, toDisplayString, unref, createVNode } from "vue";
2
+ import { _ as _sfc_main$1 } from "./p-icon.js";
3
+ import { startCase } from "lodash-es";
4
+ const _hoisted_1 = { class: "flex items-center gap-2" };
5
+ const _hoisted_2 = ["data-state", "onClick"];
6
+ const _hoisted_3 = {
7
+ key: 0,
8
+ class: "flex items-center"
9
+ };
10
+ const _sfc_main = /* @__PURE__ */ defineComponent({
11
+ ...{
12
+ name: "PSteps"
13
+ },
14
+ __name: "p-steps",
15
+ props: {
16
+ activeStep: { default: null },
17
+ steps: { default: () => [] },
18
+ clickable: { type: Boolean, default: false }
19
+ },
20
+ emits: ["click:step"],
21
+ setup(__props, { emit: __emit }) {
22
+ const props = __props;
23
+ const emit = __emit;
24
+ const activeStepIndex = computed(() => props.steps.findIndex((s) => s.value === props.activeStep));
25
+ const stepClasses = (step, stepIndex) => {
26
+ if (step.value === props.activeStep) {
27
+ return "border-p-blue-50 bg-p-blue-50 text-surface";
28
+ }
29
+ if (activeStepIndex.value < stepIndex) {
30
+ return "border-p-gray-30 text-p-gray-30";
31
+ }
32
+ return "border-p-blue-50 text-p-blue-50";
33
+ };
34
+ return (_ctx, _cache) => {
35
+ return openBlock(), createElementBlock("div", _hoisted_1, [
36
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.steps, (step, i) => {
37
+ return openBlock(), createElementBlock(Fragment, {
38
+ key: step.value
39
+ }, [
40
+ createElementVNode("div", {
41
+ class: normalizeClass(["text-nowrap rounded-full border px-4 py-1 text-sm font-semibold", [stepClasses(step, i), { "cursor-pointer": _ctx.clickable && !step.disabled }]]),
42
+ "data-state": step.value === _ctx.activeStep ? "active" : "inactive",
43
+ onClick: ($event) => emit("click:step", step, i)
44
+ }, toDisplayString(step.text || unref(startCase)(String(step.value))), 11, _hoisted_2),
45
+ i < _ctx.steps.length - 1 ? (openBlock(), createElementBlock("div", _hoisted_3, [
46
+ createVNode(_sfc_main$1, {
47
+ icon: "material-symbols:arrow-right-alt-rounded",
48
+ class: normalizeClass([activeStepIndex.value <= i ? "text-p-gray-30" : "text-p-blue-50"])
49
+ }, null, 8, ["class"])
50
+ ])) : createCommentVNode("", true)
51
+ ], 64);
52
+ }), 128))
53
+ ]);
54
+ };
55
+ }
56
+ });
57
+ export {
58
+ _sfc_main as _
59
+ };
package/dist/es/dom.js CHANGED
@@ -1,9 +1,8 @@
1
1
  const isVisible = (element) => {
2
- var _a;
3
2
  if (!(element instanceof Element)) {
4
3
  throw Error("You must provide a DOM element.");
5
4
  }
6
- return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length) && window.getComputedStyle(element).visibility !== "hidden" && window.getComputedStyle(element).display !== "none" && ((_a = element.style) == null ? void 0 : _a.transform.includes("translateY(-9999px)")) === false;
5
+ return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length) && window.getComputedStyle(element).visibility !== "hidden" && window.getComputedStyle(element).display !== "none" && element.style?.transform.includes("translateY(-9999px)") === false;
7
6
  };
8
7
  const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
9
8
  const listLength = list.length;