@pequity/squirrel 1.0.20-beta.1 → 1.0.20-beta.3

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 (144) hide show
  1. package/dist/cjs/chunks/_plugin-vue_export-helper.js +9 -1
  2. package/dist/cjs/chunks/p-action-bar.js +60 -1
  3. package/dist/cjs/chunks/p-card.js +28 -1
  4. package/dist/cjs/chunks/p-checkbox.js +24 -1
  5. package/dist/cjs/chunks/p-dropdown-select.js +414 -1
  6. package/dist/cjs/chunks/p-input-percent.js +53 -1
  7. package/dist/cjs/chunks/p-pagination-info.js +66 -1
  8. package/dist/cjs/chunks/p-pagination.js +122 -1
  9. package/dist/cjs/chunks/p-ring-loader.js +81 -1
  10. package/dist/cjs/chunks/p-select-btn.js +97 -1
  11. package/dist/cjs/chunks/p-select.js +123 -1
  12. package/dist/cjs/chunks/p-table-loader.js +70 -1
  13. package/dist/cjs/chunks/p-tabs.js +52 -1
  14. package/dist/cjs/config.js +105 -1
  15. package/dist/cjs/currency.js +9 -1
  16. package/dist/cjs/dom.js +27 -1
  17. package/dist/cjs/index.js +976 -1
  18. package/dist/cjs/inputClassesMixin.js +50 -1
  19. package/dist/cjs/inputClassesShared.js +76 -1
  20. package/dist/cjs/listKeyboardNavigation.js +110 -1
  21. package/dist/cjs/number.js +9 -1
  22. package/dist/cjs/object.js +4 -1
  23. package/dist/cjs/p-action-bar.js +3 -1
  24. package/dist/cjs/p-alert.js +65 -1
  25. package/dist/cjs/p-avatar.js +71 -1
  26. package/dist/cjs/p-btn.js +358 -2
  27. package/dist/cjs/p-card.js +3 -1
  28. package/dist/cjs/p-checkbox.js +3 -1
  29. package/dist/cjs/p-chips.js +110 -1
  30. package/dist/cjs/p-close-btn.js +36 -1
  31. package/dist/cjs/p-date-picker.js +139 -1
  32. package/dist/cjs/p-drawer.js +253 -1
  33. package/dist/cjs/p-dropdown-select.js +3 -1
  34. package/dist/cjs/p-dropdown.js +138 -1
  35. package/dist/cjs/p-file-upload.js +21 -1
  36. package/dist/cjs/p-info-icon.js +35 -1
  37. package/dist/cjs/p-inline-date-picker.js +142 -1
  38. package/dist/cjs/p-input-number.js +146 -1
  39. package/dist/cjs/p-input-percent.js +3 -1
  40. package/dist/cjs/p-input-search.js +110 -1
  41. package/dist/cjs/p-input.js +89 -1
  42. package/dist/cjs/p-loading.js +38 -1
  43. package/dist/cjs/p-modal.js +369 -1
  44. package/dist/cjs/p-pagination-info.js +3 -1
  45. package/dist/cjs/p-pagination.js +3 -1
  46. package/dist/cjs/p-progress-bar.js +41 -1
  47. package/dist/cjs/p-ring-loader.js +3 -1
  48. package/dist/cjs/p-select-btn.js +3 -1
  49. package/dist/cjs/p-select-list.js +4 -1
  50. package/dist/cjs/p-select-pill.js +111 -1
  51. package/dist/cjs/p-select.js +3 -1
  52. package/dist/cjs/p-skeleton-loader.js +73 -1
  53. package/dist/cjs/p-table-filter-icon.js +20 -1
  54. package/dist/cjs/p-table-header-cell.js +75 -1
  55. package/dist/cjs/p-table-loader.js +3 -1
  56. package/dist/cjs/p-table-sort.js +8 -1
  57. package/dist/cjs/p-table-td.js +88 -1
  58. package/dist/cjs/p-table.js +12 -1
  59. package/dist/cjs/p-tabs.js +3 -1
  60. package/dist/cjs/p-textarea.js +73 -1
  61. package/dist/cjs/p-toggle.js +114 -1
  62. package/dist/cjs/pagination.js +29 -1
  63. package/dist/cjs/string.js +12 -1
  64. package/dist/cjs/tailwind.js +4353 -1
  65. package/dist/cjs/text.js +16 -1
  66. package/dist/cjs/useInputClasses.js +44 -1
  67. package/dist/cjs/usePLoading.js +35 -1
  68. package/dist/cjs/usePModal.js +21 -1
  69. package/dist/cjs/usePTableColResize.js +81 -1
  70. package/dist/cjs/usePTableRowVirtualizer.js +31 -1
  71. package/dist/cjs/useSelectList.js +256 -1
  72. package/dist/es/chunks/_plugin-vue_export-helper.js +7 -6
  73. package/dist/es/chunks/p-action-bar.js +45 -36
  74. package/dist/es/chunks/p-card.js +18 -14
  75. package/dist/es/chunks/p-checkbox.js +14 -11
  76. package/dist/es/chunks/p-dropdown-select.js +232 -183
  77. package/dist/es/chunks/p-input-percent.js +34 -25
  78. package/dist/es/chunks/p-pagination-info.js +30 -24
  79. package/dist/es/chunks/p-pagination.js +78 -48
  80. package/dist/es/chunks/p-ring-loader.js +63 -40
  81. package/dist/es/chunks/p-select-btn.js +80 -59
  82. package/dist/es/chunks/p-select.js +81 -54
  83. package/dist/es/chunks/p-table-loader.js +46 -32
  84. package/dist/es/chunks/p-tabs.js +35 -29
  85. package/dist/es/config.js +2 -2
  86. package/dist/es/currency.js +3 -3
  87. package/dist/es/dom.js +24 -12
  88. package/dist/es/index.js +703 -519
  89. package/dist/es/inputClassesMixin.js +20 -14
  90. package/dist/es/inputClassesShared.js +60 -45
  91. package/dist/es/listKeyboardNavigation.js +86 -36
  92. package/dist/es/number.js +7 -2
  93. package/dist/es/object.js +2 -2
  94. package/dist/es/p-action-bar.js +2 -2
  95. package/dist/es/p-alert.js +35 -30
  96. package/dist/es/p-avatar.js +30 -27
  97. package/dist/es/p-btn.js +209 -164
  98. package/dist/es/p-card.js +2 -2
  99. package/dist/es/p-checkbox.js +2 -2
  100. package/dist/es/p-chips.js +60 -40
  101. package/dist/es/p-close-btn.js +20 -16
  102. package/dist/es/p-date-picker.js +66 -58
  103. package/dist/es/p-drawer.js +108 -89
  104. package/dist/es/p-dropdown-select.js +2 -2
  105. package/dist/es/p-dropdown.js +52 -33
  106. package/dist/es/p-file-upload.js +17 -9
  107. package/dist/es/p-info-icon.js +21 -16
  108. package/dist/es/p-inline-date-picker.js +64 -53
  109. package/dist/es/p-input-number.js +84 -66
  110. package/dist/es/p-input-percent.js +2 -2
  111. package/dist/es/p-input-search.js +43 -41
  112. package/dist/es/p-input.js +51 -45
  113. package/dist/es/p-loading.js +31 -22
  114. package/dist/es/p-modal.js +261 -174
  115. package/dist/es/p-pagination-info.js +2 -2
  116. package/dist/es/p-pagination.js +2 -2
  117. package/dist/es/p-progress-bar.js +26 -23
  118. package/dist/es/p-ring-loader.js +2 -2
  119. package/dist/es/p-select-btn.js +2 -2
  120. package/dist/es/p-select-list.js +2 -2
  121. package/dist/es/p-select-pill.js +58 -41
  122. package/dist/es/p-select.js +2 -2
  123. package/dist/es/p-skeleton-loader.js +34 -29
  124. package/dist/es/p-table-filter-icon.js +11 -11
  125. package/dist/es/p-table-header-cell.js +38 -33
  126. package/dist/es/p-table-loader.js +2 -2
  127. package/dist/es/p-table-sort.js +2 -2
  128. package/dist/es/p-table-td.js +76 -29
  129. package/dist/es/p-table.js +10 -6
  130. package/dist/es/p-tabs.js +2 -2
  131. package/dist/es/p-textarea.js +36 -34
  132. package/dist/es/p-toggle.js +53 -48
  133. package/dist/es/pagination.js +25 -8
  134. package/dist/es/string.js +10 -2
  135. package/dist/es/tailwind.js +1660 -1101
  136. package/dist/es/text.js +13 -8
  137. package/dist/es/useInputClasses.js +38 -22
  138. package/dist/es/usePLoading.js +31 -15
  139. package/dist/es/usePModal.js +15 -12
  140. package/dist/es/usePTableColResize.js +71 -39
  141. package/dist/es/usePTableRowVirtualizer.js +24 -15
  142. package/dist/es/useSelectList.js +234 -121
  143. package/dist/style.css +2124 -1
  144. package/package.json +1 -1
package/dist/cjs/text.js CHANGED
@@ -1 +1,16 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=(i,s)=>{const n=String(s).trim(),t=String(i).trim(),r=t.indexOf(n);if(r>=0){const e=t.substring(0,r),g=t.substring(r,r+n.length),o=t.substring(r+n.length);return[e,g,o]}else return[t]};exports.splitStringForHighlight=l;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const splitStringForHighlight = (textToSearchIn, searchStr) => {
4
+ const str = String(searchStr).trim();
5
+ const text = String(textToSearchIn).trim();
6
+ const index = text.indexOf(str);
7
+ if (index >= 0) {
8
+ const part1 = text.substring(0, index);
9
+ const part2 = text.substring(index, index + str.length);
10
+ const part3 = text.substring(index + str.length);
11
+ return [part1, part2, part3];
12
+ } else {
13
+ return [text];
14
+ }
15
+ };
16
+ exports.splitStringForHighlight = splitStringForHighlight;
@@ -1 +1,44 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./inputClassesShared.js"),s=require("vue"),$={size:s.ref("md"),errorMsg:s.ref(""),required:s.ref(!1),prefix:s.ref(!1),suffix:s.ref(!1)};function v(l){const n={...$,...s.toRefs(l)},{size:r,errorMsg:o,required:c,prefix:E,suffix:S}=n,u=s.computed(()=>{const t=`${e.INPUT_BASE} ${e.INPUT_SIZES[r.value]}`,a=E.value?e.SPACING_PREFIX[r.value]:e.SPACING_LEFT[r.value],_=S.value?e.SPACING_SUFFIX[r.value]:e.SPACING_RIGHT[r.value];return`${t} ${a} ${_} ${o.value?e.INPUT_ERROR:e.INPUT_NORMAL}`}),f=s.computed(()=>{const t=`${e.LABEL_BASE} ${e.LABEL_SIZES[r.value]}`;return c.value?`${t} ${e.LABEL_REQUIRED}`:t}),i=s.computed(()=>`${u.value.replace(` ${e.SPACING_RIGHT[r.value]}`,"")} ${e.SELECT_BASE} ${e.SELECT_ARROW} ${e.SELECT_SIZES[r.value]}`),I=s.computed(()=>`${u.value} ${e.TEXTAREA_BASE}`),R=s.ref(e.ERROR_MSG);return{inputClasses:u,labelClasses:f,selectClasses:i,textareaClasses:I,errorMsgClasses:R}}exports.useInputClasses=v;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const inputClassesShared = require("./inputClassesShared.js");
4
+ const vue = require("vue");
5
+ const defaults = {
6
+ size: vue.ref("md"),
7
+ errorMsg: vue.ref(""),
8
+ required: vue.ref(false),
9
+ prefix: vue.ref(false),
10
+ suffix: vue.ref(false)
11
+ };
12
+ function useInputClasses(props) {
13
+ const opts = { ...defaults, ...vue.toRefs(props) };
14
+ const { size, errorMsg, required, prefix, suffix } = opts;
15
+ const inputClasses = vue.computed(() => {
16
+ const base = `${inputClassesShared.INPUT_BASE} ${inputClassesShared.INPUT_SIZES[size.value]}`;
17
+ const spacingLeft = prefix.value ? inputClassesShared.SPACING_PREFIX[size.value] : inputClassesShared.SPACING_LEFT[size.value];
18
+ const spacingRight = suffix.value ? inputClassesShared.SPACING_SUFFIX[size.value] : inputClassesShared.SPACING_RIGHT[size.value];
19
+ const res = `${base} ${spacingLeft} ${spacingRight} ${errorMsg.value ? inputClassesShared.INPUT_ERROR : inputClassesShared.INPUT_NORMAL}`;
20
+ return res;
21
+ });
22
+ const labelClasses = vue.computed(() => {
23
+ const base = `${inputClassesShared.LABEL_BASE} ${inputClassesShared.LABEL_SIZES[size.value]}`;
24
+ const res = required.value ? `${base} ${inputClassesShared.LABEL_REQUIRED}` : base;
25
+ return res;
26
+ });
27
+ const selectClasses = vue.computed(() => {
28
+ const res = `${inputClasses.value.replace(` ${inputClassesShared.SPACING_RIGHT[size.value]}`, "")} ${inputClassesShared.SELECT_BASE} ${inputClassesShared.SELECT_ARROW} ${inputClassesShared.SELECT_SIZES[size.value]}`;
29
+ return res;
30
+ });
31
+ const textareaClasses = vue.computed(() => {
32
+ const res = `${inputClasses.value} ${inputClassesShared.TEXTAREA_BASE}`;
33
+ return res;
34
+ });
35
+ const errorMsgClasses = vue.ref(inputClassesShared.ERROR_MSG);
36
+ return {
37
+ inputClasses,
38
+ labelClasses,
39
+ selectClasses,
40
+ textareaClasses,
41
+ errorMsgClasses
42
+ };
43
+ }
44
+ exports.useInputClasses = useInputClasses;
@@ -1 +1,35 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),a=require("lodash-es"),e=t.ref(!1),o=[];let u;const c=i=>{const{delay:s}={delay:200,...i},l=t.getCurrentScope(),r=()=>{o.length===0&&s>0?u=setTimeout(()=>{e.value=!0},s):e.value=!0,o.push(a.uniqueId())},n=()=>{o.length===1&&(e.value=!1),clearTimeout(u),o.pop()};return l&&t.onScopeDispose(()=>{n()}),{show:e,loadingShow:r,loadingHide:n}};exports.usePLoading=c;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const lodashEs = require("lodash-es");
5
+ const show = vue.ref(false);
6
+ const loadingIds = [];
7
+ let timer;
8
+ const usePLoading = (options) => {
9
+ const { delay } = { delay: 200, ...options };
10
+ const scope = vue.getCurrentScope();
11
+ const loadingShow = () => {
12
+ if (loadingIds.length === 0 && delay > 0) {
13
+ timer = setTimeout(() => {
14
+ show.value = true;
15
+ }, delay);
16
+ } else {
17
+ show.value = true;
18
+ }
19
+ loadingIds.push(lodashEs.uniqueId());
20
+ };
21
+ const loadingHide = () => {
22
+ if (loadingIds.length === 1) {
23
+ show.value = false;
24
+ }
25
+ clearTimeout(timer);
26
+ loadingIds.pop();
27
+ };
28
+ if (scope) {
29
+ vue.onScopeDispose(() => {
30
+ loadingHide();
31
+ });
32
+ }
33
+ return { show, loadingShow, loadingHide };
34
+ };
35
+ exports.usePLoading = usePLoading;
@@ -1 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue"),t=l.reactive({modals:{}}),d=()=>{const s=e=>{t.modals[e]=!0},o=e=>{delete t.modals[e]};return{state:t,show:s,hide:o,hideAll:()=>{Object.keys(t.modals).forEach(e=>{o(e)})}}};exports.usePModal=d;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const state = vue.reactive({
5
+ modals: {}
6
+ });
7
+ const usePModal = () => {
8
+ const show = (name) => {
9
+ state.modals[name] = true;
10
+ };
11
+ const hide = (name) => {
12
+ delete state.modals[name];
13
+ };
14
+ const hideAll = () => {
15
+ Object.keys(state.modals).forEach((modalName) => {
16
+ hide(modalName);
17
+ });
18
+ };
19
+ return { state, show, hide, hideAll };
20
+ };
21
+ exports.usePModal = usePModal;
@@ -1 +1,81 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./p-table.js"),o=require("vue"),L=h=>{const{enabled:u,ths:r}=h,s=o.ref(!1),a=o.ref("0px"),d=o.ref(0),v=o.ref(-1),z=e=>{if(a.value=`${e.clientX}px`,s.value){document.body.classList.add("cursor-col-resize");const t=r.value[v.value],l=t.getBoundingClientRect(),i=e.clientX-l.left-t.offsetWidth,c=t.offsetWidth+i;f(c),a.value=e.clientX<l.left?"0px":`${e.clientX}px`}},p=(e,t)=>{e.detail===1&&(e.preventDefault(),s.value=!0,d.value=r.value[t].offsetWidth,v.value=t)},n=()=>{s.value&&(s.value=!1,document.body.classList.remove("cursor-col-resize"))},b=e=>{var i;s.value=!0;const t=(i=r.value[e].closest("table"))==null?void 0:i.querySelectorAll("tbody tr td:nth-child("+(e+1)+") div.w-max");if(!t)return;const l=[...t].reduce((c,g)=>{const m=g.getBoundingClientRect().width;return m>c?m:c},0);f(l),o.nextTick(()=>{s.value=!1})},f=e=>{d.value=e>R.MIN_WIDTH_COL_RESIZE?Math.ceil(e):R.MIN_WIDTH_COL_RESIZE};return o.onMounted(()=>{u.value&&document.addEventListener("mouseup",n)}),o.onBeforeUnmount(()=>{u.value&&document.removeEventListener("mouseup",n)}),o.watch(u,e=>{e?document.addEventListener("mouseup",n):document.removeEventListener("mouseup",n)}),{isColResizing:s,colResizeHandleLeft:a,colResizingIndex:v,colResizingWidth:d,colResize:z,colResizeStart:p,colResizeStop:n,colResizeFitToData:b}};exports.usePTableColResize=L;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const pTable = require("./p-table.js");
4
+ const vue = require("vue");
5
+ const usePTableColResize = (options) => {
6
+ const { enabled, ths } = options;
7
+ const isColResizing = vue.ref(false);
8
+ const colResizeHandleLeft = vue.ref("0px");
9
+ const colResizingWidth = vue.ref(0);
10
+ const colResizingIndex = vue.ref(-1);
11
+ const colResize = (e) => {
12
+ colResizeHandleLeft.value = `${e.clientX}px`;
13
+ if (isColResizing.value) {
14
+ document.body.classList.add("cursor-col-resize");
15
+ const th = ths.value[colResizingIndex.value];
16
+ const rect = th.getBoundingClientRect();
17
+ const diff = e.clientX - rect.left - th.offsetWidth;
18
+ const widthToSet = th.offsetWidth + diff;
19
+ setColResizingWidth(widthToSet);
20
+ colResizeHandleLeft.value = e.clientX < rect.left ? "0px" : `${e.clientX}px`;
21
+ }
22
+ };
23
+ const colResizeStart = (e, i) => {
24
+ if (e.detail === 1) {
25
+ e.preventDefault();
26
+ isColResizing.value = true;
27
+ colResizingWidth.value = ths.value[i].offsetWidth;
28
+ colResizingIndex.value = i;
29
+ }
30
+ };
31
+ const colResizeStop = () => {
32
+ if (!isColResizing.value) {
33
+ return;
34
+ }
35
+ isColResizing.value = false;
36
+ document.body.classList.remove("cursor-col-resize");
37
+ };
38
+ const colResizeFitToData = (colIndex) => {
39
+ var _a;
40
+ isColResizing.value = true;
41
+ const tds = (_a = ths.value[colIndex].closest("table")) == null ? void 0 : _a.querySelectorAll("tbody tr td:nth-child(" + (colIndex + 1) + ") div.w-max");
42
+ if (!tds) {
43
+ return;
44
+ }
45
+ const maxWidth = [...tds].reduce((max, td) => {
46
+ const width = td.getBoundingClientRect().width;
47
+ return width > max ? width : max;
48
+ }, 0);
49
+ setColResizingWidth(maxWidth);
50
+ vue.nextTick(() => {
51
+ isColResizing.value = false;
52
+ });
53
+ };
54
+ const setColResizingWidth = (width) => {
55
+ colResizingWidth.value = width > pTable.MIN_WIDTH_COL_RESIZE ? Math.ceil(width) : pTable.MIN_WIDTH_COL_RESIZE;
56
+ };
57
+ vue.onMounted(() => {
58
+ enabled.value && document.addEventListener("mouseup", colResizeStop);
59
+ });
60
+ vue.onBeforeUnmount(() => {
61
+ enabled.value && document.removeEventListener("mouseup", colResizeStop);
62
+ });
63
+ vue.watch(enabled, (nV) => {
64
+ if (nV) {
65
+ document.addEventListener("mouseup", colResizeStop);
66
+ } else {
67
+ document.removeEventListener("mouseup", colResizeStop);
68
+ }
69
+ });
70
+ return {
71
+ isColResizing,
72
+ colResizeHandleLeft,
73
+ colResizingIndex,
74
+ colResizingWidth,
75
+ colResize,
76
+ colResizeStart,
77
+ colResizeStop,
78
+ colResizeFitToData
79
+ };
80
+ };
81
+ exports.usePTableColResize = usePTableColResize;
@@ -1 +1,31 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),i=require("@tanstack/vue-virtual"),s=l=>{if(!l.value)return{virtualizer:null,virtualRows:e.ref([{key:0,index:0}]),paddingTop:e.ref(0),paddingBottom:e.ref(0),measureElement:()=>e.ref(void 0)};const t=i.useVirtualizer(l),u=e.computed(()=>t.value.getVirtualItems()),n=e.computed(()=>u.value.length>0?u.value[0].start:0),o=e.computed(()=>u.value.length>0?(t==null?void 0:t.value.getTotalSize())-u.value[u.value.length-1].end:0);return{virtualizer:t,virtualRows:u,paddingTop:n,paddingBottom:o,measureElement:r=>{const a=e.isRef(r)?e.unref(r):r==null?void 0:r.$el;a&&t.value.measureElement(a)}}};exports.usePTableRowVirtualizer=s;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const vueVirtual = require("@tanstack/vue-virtual");
5
+ const usePTableRowVirtualizer = (options) => {
6
+ if (!options.value) {
7
+ return {
8
+ virtualizer: null,
9
+ virtualRows: vue.ref([{ key: 0, index: 0 }]),
10
+ paddingTop: vue.ref(0),
11
+ paddingBottom: vue.ref(0),
12
+ measureElement: () => vue.ref(void 0)
13
+ };
14
+ }
15
+ const virtualizer = vueVirtual.useVirtualizer(options);
16
+ const virtualRows = vue.computed(() => virtualizer.value.getVirtualItems());
17
+ const paddingTop = vue.computed(() => virtualRows.value.length > 0 ? virtualRows.value[0].start : 0);
18
+ const paddingBottom = vue.computed(
19
+ () => virtualRows.value.length > 0 ? (virtualizer == null ? void 0 : virtualizer.value.getTotalSize()) - virtualRows.value[virtualRows.value.length - 1].end : 0
20
+ );
21
+ const measureElement = (cmp) => {
22
+ const el = vue.isRef(cmp) ? vue.unref(cmp) : cmp == null ? void 0 : cmp.$el;
23
+ if (!el) {
24
+ return;
25
+ }
26
+ virtualizer.value.measureElement(el);
27
+ return void 0;
28
+ };
29
+ return { virtualizer, virtualRows, paddingTop, paddingBottom, measureElement };
30
+ };
31
+ exports.usePTableRowVirtualizer = usePTableRowVirtualizer;
@@ -1 +1,256 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("vue"),D=require("./listKeyboardNavigation.js"),A=require("lodash-es"),F=require("./object.js"),U=require("./string.js"),Y=require("@tanstack/vue-virtual"),Z=e=>{let i=Array.isArray(e)?e.slice():[];return i.length&&!F.isObject(i[0])&&(i=i.filter((m,r,u)=>u.indexOf(m)===r).map(m=>({value:m,text:m}))),i},G=(e,i,m,r,u)=>{let n=e;return i&&F.isObject(e)&&(m?n=e.map(f=>f[r]):n=e&&e[r]),Array.isArray(n)?n:[n]},S=()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),L=e=>new Promise(i=>setTimeout(i,e||0)),y={sm:32,md:40,lg:48},H="clear-both block w-full cursor-pointer whitespace-nowrap py-1 px-3 text-left text-sm font-medium hover:bg-p-blue-10",q="selected",J=(e,i,m,r)=>{let u=null;const n=c.ref([]),s=c.ref([]),f=c.ref(""),T=c.computed(()=>n.value.filter(l=>s.value.includes(l[e.itemValue]))),d=c.computed(()=>A.cloneDeep(n.value).filter(l=>String(l[e.itemText]).toLocaleLowerCase().includes(String(f.value).toLocaleLowerCase()))),O=c.computed(()=>e.itemSize?e.itemSize:y[e.size]),E=c.computed(()=>d.value.map(t=>t[e.itemValue]).every(t=>s.value.includes(t))),I=Y.useVirtualizer(c.computed(()=>({count:d.value.length,getScrollElement:()=>m.value,getItemKey:l=>U.toString(d.value[l][e.itemValue]),estimateSize:()=>e.itemSize?e.itemSize:y[e.size],overscan:10}))),j=l=>{var t;return(t=d.value[l])==null?void 0:t[e.itemValue]},C=l=>{var t;return(t=d.value[l])==null?void 0:t[e.itemText]};c.watch(()=>e.modelValue,l=>{s.value=G(l,e.valueIsObject,e.multiple,e.itemValue,n.value)},{immediate:!0,deep:!0}),c.watch(f,async l=>{if(await P(),await S(),!u)return;const t=u.getItems().filter(a=>a.style.transform.includes("translateY(0px)"))[0];l||e.multiple?u.setFocusedItem(t):h()>-1?b():u.clearFocusedState()}),c.onUnmounted(()=>{u==null||u.destroy(),u=null});const z=()=>{if(e.selectedTopShown){const l=n.value.reduce((t,a)=>(s.value.includes(a[e.itemValue])?t[0].push(a):t[1].push(a),t),[[],[]]);n.value=l[0].sort((t,a)=>String(t[e.itemText]).localeCompare(String(a[e.itemText]),void 0,{numeric:!0,sensitivity:"base"})).concat(l[1])}},_=async(l,t)=>{var o,x;const a=l.currentTarget;e.multiple&&e.searchable&&document.activeElement!==((o=i.value)==null?void 0:o.$el.querySelector("input"))&&((x=i.value)==null||x.$el.querySelector("input").focus()),e.multiple?g(t)?r("update:modelValue",v(s.value.filter(B=>B!==t))):r("update:modelValue",v([...s.value,t])):r("update:modelValue",e.valueIsObject?w(t):t),await c.nextTick(),u==null||u.setFocusedItem(a.parentElement),r("select",t)},v=l=>e.valueIsObject?l.map(t=>w(t)):l,w=l=>n.value.find(t=>t[e.itemValue]===l),g=l=>s.value.includes(l),V=()=>{u?u.init():u=D.setupListKeyboardNavigation({itemContainer:m.value,itemSelector:"[p-select-list-option]",itemSelectSelector:"[p-select-list-option-item]",itemFocusClass:"bg-p-blue-10"})},N=()=>{u==null||u.destroy(),u=null},M=async()=>{V()},K=()=>{u==null||u.clearFocusedState()},P=async()=>{I.value.scrollToOffset(0),await S()},b=async l=>{var a;l!=null&&l.wait&&await L(l.wait);const t=h();if(m.value&&I.value&&t>-1){I.value.scrollToIndex(t,{align:"center"}),await L(),await S();const o=(a=m.value)==null?void 0:a.querySelector(`.${q}`);u==null||u.setFocusedItem(o==null?void 0:o.parentNode)}},h=()=>n.value.indexOf(T.value[0]),$=()=>{if(!e.multiple)return;const l=s.value,t=d.value.map(o=>o[e.itemValue]),a=A.uniqBy([...l,...t],o=>o);r("update:modelValue",v(a))},k=()=>{f.value="",r("update:modelValue",[])};return c.watch(()=>e.items,l=>{if(n.value=Z(l),e.multiple&&e.items.length&&s.value.length){const t=s.value.filter(a=>n.value.some(o=>o[e.itemValue]===a));t.length!==s.value.length&&(console.warn("[p-select-list] Some values in the modelValue are not in the items list."),r("update:modelValue",v(t)))}},{immediate:!0}),{LIST_ITEM_SIZES:y,LIST_ITEM_CLASS:H,LIST_ITEM_ACTIVE_CLASS:q,selectedItems:T,computedItems:d,computedItemSize:O,computedInsideSelected:E,internalItems:n,internalValue:s,search:f,rowVirtualizer:I,getValue:j,getText:C,isSelected:g,setupNavigationSvc:V,destroyNavigationSvc:N,select:_,onFocus:M,onMousemove:K,scrollToActiveItem:b,putSelectedItemsOnTop:z,selectAll:$,clearAll:k}};exports.useSelectList=J;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const listKeyboardNavigation = require("./listKeyboardNavigation.js");
5
+ const lodashEs = require("lodash-es");
6
+ const object = require("./object.js");
7
+ const string = require("./string.js");
8
+ const vueVirtual = require("@tanstack/vue-virtual");
9
+ const createInternalItems = (items) => {
10
+ let arr = Array.isArray(items) ? items.slice() : [];
11
+ if (arr.length && !object.isObject(arr[0])) {
12
+ arr = arr.filter((item, i, self) => self.indexOf(item) === i).map((item) => ({ value: item, text: item }));
13
+ }
14
+ return arr;
15
+ };
16
+ const createInternalValue = (modelValue, valueIsObject, multiple, itemValue, internalItems) => {
17
+ let val = modelValue;
18
+ if (valueIsObject && object.isObject(modelValue)) {
19
+ if (multiple) {
20
+ val = modelValue.map((v) => v[itemValue]);
21
+ } else {
22
+ val = modelValue ? modelValue[itemValue] : modelValue;
23
+ }
24
+ }
25
+ const arr = Array.isArray(val) ? val : [val];
26
+ return arr;
27
+ };
28
+ const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
29
+ const nextLoop = (ms) => new Promise((resolve) => setTimeout(resolve, ms || 0));
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";
32
+ const LIST_ITEM_ACTIVE_CLASS = "selected";
33
+ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
34
+ let navigationSvc = null;
35
+ const internalItems = vue.ref([]);
36
+ const internalValue = vue.ref([]);
37
+ const search = vue.ref("");
38
+ const selectedItems = vue.computed(() => {
39
+ return internalItems.value.filter((item) => internalValue.value.includes(item[props.itemValue]));
40
+ });
41
+ const computedItems = vue.computed(() => {
42
+ return lodashEs.cloneDeep(internalItems.value).filter((item) => {
43
+ return String(item[props.itemText]).toLocaleLowerCase().includes(String(search.value).toLocaleLowerCase());
44
+ });
45
+ });
46
+ const computedItemSize = vue.computed(() => props.itemSize ? props.itemSize : LIST_ITEM_SIZES[props.size]);
47
+ const computedInsideSelected = vue.computed(() => {
48
+ const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
49
+ return filteredItems.every((item) => internalValue.value.includes(item));
50
+ });
51
+ const rowVirtualizer = vueVirtual.useVirtualizer(
52
+ vue.computed(() => {
53
+ return {
54
+ count: computedItems.value.length,
55
+ getScrollElement: () => virtualizerRef.value,
56
+ getItemKey: (index) => string.toString(computedItems.value[index][props.itemValue]),
57
+ estimateSize: () => {
58
+ return props.itemSize ? props.itemSize : LIST_ITEM_SIZES[props.size];
59
+ },
60
+ overscan: 10
61
+ };
62
+ })
63
+ );
64
+ const getValue = (index) => {
65
+ var _a;
66
+ return (_a = computedItems.value[index]) == null ? void 0 : _a[props.itemValue];
67
+ };
68
+ const getText = (index) => {
69
+ var _a;
70
+ return (_a = computedItems.value[index]) == null ? void 0 : _a[props.itemText];
71
+ };
72
+ vue.watch(
73
+ () => props.modelValue,
74
+ (nV) => {
75
+ internalValue.value = createInternalValue(
76
+ nV,
77
+ props.valueIsObject,
78
+ props.multiple,
79
+ props.itemValue,
80
+ internalItems.value
81
+ );
82
+ },
83
+ {
84
+ immediate: true,
85
+ deep: true
86
+ }
87
+ );
88
+ vue.watch(search, async (nV) => {
89
+ await scrollScrollerToTop();
90
+ await nextFrame();
91
+ if (!navigationSvc) {
92
+ return;
93
+ }
94
+ const firstItem = navigationSvc.getItems().filter((item) => item.style.transform.includes("translateY(0px)"))[0];
95
+ if (nV) {
96
+ navigationSvc.setFocusedItem(firstItem);
97
+ } else {
98
+ if (props.multiple) {
99
+ navigationSvc.setFocusedItem(firstItem);
100
+ } else {
101
+ getActiveItemIndex() > -1 ? scrollToActiveItem() : navigationSvc.clearFocusedState();
102
+ }
103
+ }
104
+ });
105
+ vue.onUnmounted(() => {
106
+ navigationSvc == null ? void 0 : navigationSvc.destroy();
107
+ navigationSvc = null;
108
+ });
109
+ const putSelectedItemsOnTop = () => {
110
+ if (props.selectedTopShown) {
111
+ const arr = internalItems.value.reduce(
112
+ (acc, curr) => {
113
+ internalValue.value.includes(curr[props.itemValue]) ? acc[0].push(curr) : acc[1].push(curr);
114
+ return acc;
115
+ },
116
+ [[], []]
117
+ );
118
+ internalItems.value = arr[0].sort(
119
+ (a, b) => String(a[props.itemText]).localeCompare(String(b[props.itemText]), void 0, {
120
+ numeric: true,
121
+ sensitivity: "base"
122
+ })
123
+ ).concat(arr[1]);
124
+ }
125
+ };
126
+ const select = async (e, val) => {
127
+ var _a, _b;
128
+ const el = e.currentTarget;
129
+ if (props.multiple && props.searchable && document.activeElement !== ((_a = inputSearch.value) == null ? void 0 : _a.$el.querySelector("input"))) {
130
+ (_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
131
+ }
132
+ if (props.multiple) {
133
+ if (!isSelected(val)) {
134
+ emit("update:modelValue", toArrOfObjIfNeeded([...internalValue.value, val]));
135
+ } else {
136
+ emit("update:modelValue", toArrOfObjIfNeeded(internalValue.value.filter((item) => item !== val)));
137
+ }
138
+ } else {
139
+ emit("update:modelValue", props.valueIsObject ? getItemByValue(val) : val);
140
+ }
141
+ await vue.nextTick();
142
+ navigationSvc == null ? void 0 : navigationSvc.setFocusedItem(el.parentElement);
143
+ emit("select", val);
144
+ };
145
+ const toArrOfObjIfNeeded = (arr) => {
146
+ return props.valueIsObject ? arr.map((val) => getItemByValue(val)) : arr;
147
+ };
148
+ const getItemByValue = (value) => {
149
+ return internalItems.value.find((item) => item[props.itemValue] === value);
150
+ };
151
+ const isSelected = (val) => {
152
+ return internalValue.value.includes(val);
153
+ };
154
+ const setupNavigationSvc = () => {
155
+ if (navigationSvc) {
156
+ navigationSvc.init();
157
+ } else {
158
+ navigationSvc = listKeyboardNavigation.setupListKeyboardNavigation({
159
+ itemContainer: virtualizerRef.value,
160
+ itemSelector: "[p-select-list-option]",
161
+ itemSelectSelector: `[p-select-list-option-item]`,
162
+ itemFocusClass: "bg-p-blue-10"
163
+ });
164
+ }
165
+ };
166
+ const destroyNavigationSvc = () => {
167
+ navigationSvc == null ? void 0 : navigationSvc.destroy();
168
+ navigationSvc = null;
169
+ };
170
+ const onFocus = async () => {
171
+ setupNavigationSvc();
172
+ };
173
+ const onMousemove = () => {
174
+ navigationSvc == null ? void 0 : navigationSvc.clearFocusedState();
175
+ };
176
+ const scrollScrollerToTop = async () => {
177
+ rowVirtualizer.value.scrollToOffset(0);
178
+ await nextFrame();
179
+ };
180
+ const scrollToActiveItem = async (options) => {
181
+ var _a;
182
+ if (options == null ? void 0 : options.wait) {
183
+ await nextLoop(options.wait);
184
+ }
185
+ const activeIndex = getActiveItemIndex();
186
+ if (virtualizerRef.value && rowVirtualizer.value && activeIndex > -1) {
187
+ rowVirtualizer.value.scrollToIndex(activeIndex, {
188
+ align: "center"
189
+ });
190
+ await nextLoop();
191
+ await nextFrame();
192
+ const activeEl = (_a = virtualizerRef.value) == null ? void 0 : _a.querySelector(`.${LIST_ITEM_ACTIVE_CLASS}`);
193
+ navigationSvc == null ? void 0 : navigationSvc.setFocusedItem(activeEl == null ? void 0 : activeEl.parentNode);
194
+ }
195
+ };
196
+ const getActiveItemIndex = () => {
197
+ return internalItems.value.indexOf(selectedItems.value[0]);
198
+ };
199
+ const selectAll = () => {
200
+ if (!props.multiple) {
201
+ return;
202
+ }
203
+ const selectedItems2 = internalValue.value;
204
+ const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
205
+ const toEmit = lodashEs.uniqBy([...selectedItems2, ...filteredItems], (item) => item);
206
+ emit("update:modelValue", toArrOfObjIfNeeded(toEmit));
207
+ };
208
+ const clearAll = () => {
209
+ search.value = "";
210
+ emit("update:modelValue", []);
211
+ };
212
+ vue.watch(
213
+ () => props.items,
214
+ (nV) => {
215
+ internalItems.value = createInternalItems(nV);
216
+ if (props.multiple && props.items.length && internalValue.value.length) {
217
+ const internalValueFiltered = internalValue.value.filter((item) => {
218
+ return internalItems.value.some((i) => i[props.itemValue] === item);
219
+ });
220
+ if (internalValueFiltered.length !== internalValue.value.length) {
221
+ console.warn(`[p-select-list] Some values in the modelValue are not in the items list.`);
222
+ emit("update:modelValue", toArrOfObjIfNeeded(internalValueFiltered));
223
+ }
224
+ }
225
+ },
226
+ {
227
+ immediate: true
228
+ }
229
+ );
230
+ return {
231
+ LIST_ITEM_SIZES,
232
+ LIST_ITEM_CLASS,
233
+ LIST_ITEM_ACTIVE_CLASS,
234
+ selectedItems,
235
+ computedItems,
236
+ computedItemSize,
237
+ computedInsideSelected,
238
+ internalItems,
239
+ internalValue,
240
+ search,
241
+ rowVirtualizer,
242
+ getValue,
243
+ getText,
244
+ isSelected,
245
+ setupNavigationSvc,
246
+ destroyNavigationSvc,
247
+ select,
248
+ onFocus,
249
+ onMousemove,
250
+ scrollToActiveItem,
251
+ putSelectedItemsOnTop,
252
+ selectAll,
253
+ clearAll
254
+ };
255
+ };
256
+ exports.useSelectList = useSelectList;
@@ -1,9 +1,10 @@
1
- const s = (t, r) => {
2
- const o = t.__vccOpts || t;
3
- for (const [c, e] of r)
4
- o[c] = e;
5
- return o;
1
+ const _export_sfc = (sfc, props) => {
2
+ const target = sfc.__vccOpts || sfc;
3
+ for (const [key, val] of props) {
4
+ target[key] = val;
5
+ }
6
+ return target;
6
7
  };
7
8
  export {
8
- s as _
9
+ _export_sfc as _
9
10
  };
@@ -1,52 +1,61 @@
1
- import { defineComponent as a, openBlock as n, createElementBlock as s, createVNode as m, createElementVNode as t, toDisplayString as l, Fragment as d, renderList as p, createBlock as c, withCtx as u, resolveDynamicComponent as k, createCommentVNode as f } from "vue";
2
- import x from "../p-btn.js";
3
- import _ from "../p-close-btn.js";
4
- const h = {
1
+ import { defineComponent, openBlock, createElementBlock, createVNode, createElementVNode, toDisplayString, Fragment, renderList, createBlock, withCtx, resolveDynamicComponent, createCommentVNode } from "vue";
2
+ import PBtn from "../p-btn.js";
3
+ import PCloseBtn from "../p-close-btn.js";
4
+ const _hoisted_1 = {
5
5
  class: "fixed bottom-6 left-1/2 flex h-12 -translate-x-1/2 select-none flex-row items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white",
6
6
  role: "alertdialog"
7
- }, y = { class: "px-3" }, g = /* @__PURE__ */ t("div", { class: "mx-4 h-9 w-0.5 rounded bg-p-purple-50" }, null, -1), v = { class: "flex" }, C = { class: "flex items-center gap-2 px-1 py-0.5" }, N = /* @__PURE__ */ a({
7
+ };
8
+ const _hoisted_2 = { class: "px-3" };
9
+ const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "mx-4 h-9 w-0.5 rounded bg-p-purple-50" }, null, -1);
10
+ const _hoisted_4 = { class: "flex" };
11
+ const _hoisted_5 = { class: "flex items-center gap-2 px-1 py-0.5" };
12
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
13
  __name: "p-action-bar",
9
14
  props: {
10
15
  label: {
11
16
  type: String,
12
- required: !0
17
+ required: true
13
18
  },
14
19
  actions: {
15
20
  type: Array,
16
- required: !0
21
+ required: true
17
22
  }
18
23
  },
19
24
  emits: ["click:dismiss", "click:action"],
20
- setup(o) {
21
- return (i, r) => (n(), s("div", h, [
22
- m(_, {
23
- variant: "dark",
24
- onClick: r[0] || (r[0] = (e) => i.$emit("click:dismiss"))
25
- }),
26
- t("p", y, l(o.label), 1),
27
- g,
28
- t("div", v, [
29
- (n(!0), s(d, null, p(o.actions, (e) => (n(), c(x, {
30
- key: `action-${e.name}`,
31
- size: "sm",
32
- type: "secondary-ghost-dark",
33
- onClick: (b) => i.$emit("click:action", e.name)
34
- }, {
35
- default: u(() => [
36
- t("div", C, [
37
- e.icon ? (n(), c(k(e.icon), {
38
- key: 0,
39
- class: "h-4 w-4"
40
- })) : f("", !0),
41
- t("div", null, l(e.label), 1)
42
- ])
43
- ]),
44
- _: 2
45
- }, 1032, ["onClick"]))), 128))
46
- ])
47
- ]));
25
+ setup(__props) {
26
+ return (_ctx, _cache) => {
27
+ return openBlock(), createElementBlock("div", _hoisted_1, [
28
+ createVNode(PCloseBtn, {
29
+ variant: "dark",
30
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click:dismiss"))
31
+ }),
32
+ createElementVNode("p", _hoisted_2, toDisplayString(__props.label), 1),
33
+ _hoisted_3,
34
+ createElementVNode("div", _hoisted_4, [
35
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.actions, (action) => {
36
+ return openBlock(), createBlock(PBtn, {
37
+ key: `action-${action.name}`,
38
+ size: "sm",
39
+ type: "secondary-ghost-dark",
40
+ onClick: ($event) => _ctx.$emit("click:action", action.name)
41
+ }, {
42
+ default: withCtx(() => [
43
+ createElementVNode("div", _hoisted_5, [
44
+ action.icon ? (openBlock(), createBlock(resolveDynamicComponent(action.icon), {
45
+ key: 0,
46
+ class: "h-4 w-4"
47
+ })) : createCommentVNode("", true),
48
+ createElementVNode("div", null, toDisplayString(action.label), 1)
49
+ ])
50
+ ]),
51
+ _: 2
52
+ }, 1032, ["onClick"]);
53
+ }), 128))
54
+ ])
55
+ ]);
56
+ };
48
57
  }
49
58
  });
50
59
  export {
51
- N as _
60
+ _sfc_main as _
52
61
  };