@pequity/squirrel 1.0.20 → 1.0.21

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 (146) hide show
  1. package/dist/cjs/chunks/_plugin-vue_export-helper.js +9 -0
  2. package/dist/cjs/chunks/p-action-bar.js +60 -0
  3. package/dist/cjs/chunks/p-card.js +28 -0
  4. package/dist/cjs/chunks/p-checkbox.js +24 -0
  5. package/dist/cjs/chunks/p-dropdown-select.js +414 -0
  6. package/dist/cjs/chunks/p-input-percent.js +53 -0
  7. package/dist/cjs/chunks/p-pagination-info.js +66 -0
  8. package/dist/cjs/chunks/p-pagination.js +122 -0
  9. package/dist/cjs/chunks/p-ring-loader.js +81 -0
  10. package/dist/cjs/chunks/p-select-btn.js +97 -0
  11. package/dist/cjs/chunks/p-select.js +123 -0
  12. package/dist/cjs/chunks/p-table-loader.js +70 -0
  13. package/dist/cjs/chunks/p-tabs.js +52 -0
  14. package/dist/cjs/config.js +105 -0
  15. package/dist/cjs/currency.js +9 -0
  16. package/dist/cjs/dom.js +27 -0
  17. package/dist/cjs/index.js +976 -0
  18. package/dist/cjs/inputClassesMixin.js +50 -0
  19. package/dist/cjs/inputClassesShared.js +76 -0
  20. package/dist/cjs/listKeyboardNavigation.js +110 -0
  21. package/dist/cjs/number.js +9 -0
  22. package/dist/cjs/object.js +4 -0
  23. package/dist/cjs/p-action-bar.js +3 -0
  24. package/dist/cjs/p-alert.js +65 -0
  25. package/dist/cjs/p-avatar.js +71 -0
  26. package/dist/cjs/p-btn.js +361 -0
  27. package/dist/cjs/p-card.js +3 -0
  28. package/dist/cjs/p-checkbox.js +3 -0
  29. package/dist/cjs/p-chips.js +110 -0
  30. package/dist/cjs/p-close-btn.js +36 -0
  31. package/dist/cjs/p-date-picker.js +139 -0
  32. package/dist/cjs/p-drawer.js +253 -0
  33. package/dist/cjs/p-dropdown-select.js +3 -0
  34. package/dist/cjs/p-dropdown.js +138 -0
  35. package/dist/cjs/p-file-upload.js +21 -0
  36. package/dist/cjs/p-info-icon.js +35 -0
  37. package/dist/cjs/p-inline-date-picker.js +142 -0
  38. package/dist/cjs/p-input-number.js +146 -0
  39. package/dist/cjs/p-input-percent.js +3 -0
  40. package/dist/cjs/p-input-search.js +110 -0
  41. package/dist/cjs/p-input.js +89 -0
  42. package/dist/cjs/p-loading.js +38 -0
  43. package/dist/cjs/p-modal.js +369 -0
  44. package/dist/cjs/p-pagination-info.js +3 -0
  45. package/dist/cjs/p-pagination.js +3 -0
  46. package/dist/cjs/p-progress-bar.js +41 -0
  47. package/dist/cjs/p-ring-loader.js +3 -0
  48. package/dist/cjs/p-select-btn.js +3 -0
  49. package/dist/cjs/p-select-list.js +4 -0
  50. package/dist/cjs/p-select-pill.js +111 -0
  51. package/dist/cjs/p-select.js +3 -0
  52. package/dist/cjs/p-skeleton-loader.js +73 -0
  53. package/dist/cjs/p-table-filter-icon.js +20 -0
  54. package/dist/cjs/p-table-header-cell.js +75 -0
  55. package/dist/cjs/p-table-loader.js +3 -0
  56. package/dist/cjs/p-table-sort.js +8 -0
  57. package/dist/cjs/p-table-td.js +88 -0
  58. package/dist/cjs/p-table.js +12 -0
  59. package/dist/cjs/p-tabs.js +3 -0
  60. package/dist/cjs/p-textarea.js +73 -0
  61. package/dist/cjs/p-toggle.js +114 -0
  62. package/dist/cjs/pagination.js +29 -0
  63. package/dist/cjs/string.js +12 -0
  64. package/dist/cjs/tailwind.js +4353 -0
  65. package/dist/cjs/text.js +16 -0
  66. package/dist/cjs/useInputClasses.js +44 -0
  67. package/dist/cjs/usePLoading.js +35 -0
  68. package/dist/cjs/usePModal.js +21 -0
  69. package/dist/cjs/usePTableColResize.js +81 -0
  70. package/dist/cjs/usePTableRowVirtualizer.js +31 -0
  71. package/dist/cjs/useSelectList.js +256 -0
  72. package/dist/es/chunks/_plugin-vue_export-helper.js +10 -0
  73. package/dist/es/chunks/p-action-bar.js +61 -0
  74. package/dist/es/chunks/p-card.js +29 -0
  75. package/dist/es/chunks/p-checkbox.js +25 -0
  76. package/dist/es/chunks/p-dropdown-select.js +415 -0
  77. package/dist/es/chunks/p-input-percent.js +54 -0
  78. package/dist/es/chunks/p-pagination-info.js +67 -0
  79. package/dist/es/chunks/p-pagination.js +123 -0
  80. package/dist/es/chunks/p-ring-loader.js +82 -0
  81. package/dist/es/chunks/p-select-btn.js +98 -0
  82. package/dist/es/chunks/p-select.js +124 -0
  83. package/dist/es/chunks/p-table-loader.js +71 -0
  84. package/dist/es/chunks/p-tabs.js +53 -0
  85. package/dist/es/config.js +105 -0
  86. package/dist/es/currency.js +9 -0
  87. package/dist/es/dom.js +27 -0
  88. package/dist/es/index.js +978 -0
  89. package/dist/es/inputClassesMixin.js +51 -0
  90. package/dist/es/inputClassesShared.js +76 -0
  91. package/dist/es/listKeyboardNavigation.js +110 -0
  92. package/dist/es/number.js +9 -0
  93. package/dist/es/object.js +4 -0
  94. package/dist/es/p-action-bar.js +4 -0
  95. package/dist/es/p-alert.js +66 -0
  96. package/dist/es/p-avatar.js +72 -0
  97. package/dist/es/p-btn.js +362 -0
  98. package/dist/es/p-card.js +4 -0
  99. package/dist/es/p-checkbox.js +4 -0
  100. package/dist/es/p-chips.js +111 -0
  101. package/dist/es/p-close-btn.js +37 -0
  102. package/dist/es/p-date-picker.js +140 -0
  103. package/dist/es/p-drawer.js +254 -0
  104. package/dist/es/p-dropdown-select.js +4 -0
  105. package/dist/es/p-dropdown.js +139 -0
  106. package/dist/es/p-file-upload.js +21 -0
  107. package/dist/es/p-info-icon.js +36 -0
  108. package/dist/es/p-inline-date-picker.js +143 -0
  109. package/dist/es/p-input-number.js +147 -0
  110. package/dist/es/p-input-percent.js +4 -0
  111. package/dist/es/p-input-search.js +111 -0
  112. package/dist/es/p-input.js +90 -0
  113. package/dist/es/p-loading.js +39 -0
  114. package/dist/es/p-modal.js +370 -0
  115. package/dist/es/p-pagination-info.js +4 -0
  116. package/dist/es/p-pagination.js +4 -0
  117. package/dist/es/p-progress-bar.js +42 -0
  118. package/dist/es/p-ring-loader.js +4 -0
  119. package/dist/es/p-select-btn.js +4 -0
  120. package/dist/es/p-select-list.js +4 -0
  121. package/dist/es/p-select-pill.js +112 -0
  122. package/dist/es/p-select.js +4 -0
  123. package/dist/es/p-skeleton-loader.js +74 -0
  124. package/dist/es/p-table-filter-icon.js +21 -0
  125. package/dist/es/p-table-header-cell.js +76 -0
  126. package/dist/es/p-table-loader.js +4 -0
  127. package/dist/es/p-table-sort.js +8 -0
  128. package/dist/es/p-table-td.js +89 -0
  129. package/dist/es/p-table.js +12 -0
  130. package/dist/es/p-tabs.js +4 -0
  131. package/dist/es/p-textarea.js +74 -0
  132. package/dist/es/p-toggle.js +115 -0
  133. package/dist/es/pagination.js +29 -0
  134. package/dist/es/string.js +12 -0
  135. package/dist/es/tailwind.js +4353 -0
  136. package/dist/es/text.js +16 -0
  137. package/dist/es/useInputClasses.js +44 -0
  138. package/dist/es/usePLoading.js +35 -0
  139. package/dist/es/usePModal.js +21 -0
  140. package/dist/es/usePTableColResize.js +81 -0
  141. package/dist/es/usePTableRowVirtualizer.js +31 -0
  142. package/dist/es/useSelectList.js +256 -0
  143. package/dist/style.css +2124 -1
  144. package/package.json +26 -24
  145. package/dist/squirrel.cjs.js +0 -5
  146. package/dist/squirrel.es.js +0 -8220
@@ -0,0 +1,415 @@
1
+ import { defineComponent, ref, useAttrs, computed, watch, onMounted, onUnmounted, resolveDirective, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, toDisplayString, createCommentVNode, createVNode, mergeProps, withCtx, createElementVNode, isRef, Fragment, renderList, withDirectives, renderSlot, vShow } from "vue";
2
+ import PDropdown from "../p-dropdown.js";
3
+ import PInputSearch from "../p-input-search.js";
4
+ import { SIZES } from "../p-select-list.js";
5
+ import { omit } from "lodash-es";
6
+ import { splitStringForHighlight } from "../text.js";
7
+ import { toString } from "../string.js";
8
+ import { useInputClasses } from "../useInputClasses.js";
9
+ import { useSelectList } from "../useSelectList.js";
10
+ const _imports_0 = "data:image/svg+xml,%3csvg%20width='18'%20height='12'%20viewBox='0%200%2018%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16.1383%200.166992L6.30411%209.83366L1.69828%205.27533L0.526611%206.46033L5.71578%2011.597C5.87174%2011.7509%206.08205%2011.8372%206.3012%2011.8372C6.52034%2011.8372%206.73065%2011.7509%206.88661%2011.597L17.3033%201.35366L16.1383%200.166992Z'%20fill='%231A123B'%20/%3e%3c/svg%3e";
11
+ const _hoisted_1 = ["data-has-error"];
12
+ const _hoisted_2 = {
13
+ key: 0,
14
+ class: "truncate text-left text-p-gray-40"
15
+ };
16
+ const _hoisted_3 = { class: "truncate text-left" };
17
+ const _hoisted_4 = {
18
+ key: 0,
19
+ class: "mt-3 px-3"
20
+ };
21
+ const _hoisted_5 = { class: "text-p-purple-60" };
22
+ const _hoisted_6 = { class: "flex flex-row" };
23
+ const _hoisted_7 = /* @__PURE__ */ createElementVNode("span", { class: "px-1 leading-none" }, ".", -1);
24
+ const _hoisted_8 = ["onClick"];
25
+ const _hoisted_9 = ["title"];
26
+ const _hoisted_10 = {
27
+ key: 0,
28
+ class: "ml-auto fill-p-purple-60 pl-2",
29
+ src: _imports_0
30
+ };
31
+ const _sfc_main = /* @__PURE__ */ defineComponent({
32
+ ...{
33
+ name: "PDropdownSelect",
34
+ inheritAttrs: false
35
+ },
36
+ __name: "p-dropdown-select",
37
+ props: {
38
+ modelValue: {
39
+ type: [String, Number, Boolean, Array, Object],
40
+ default: null
41
+ },
42
+ /**
43
+ * `p-dropdown-select v-model normally works with a string or an array of strings (for multiple mode).
44
+ * Setting this prop to `true` will switch the behavior to an object (or array of objects) for the v-model value.
45
+ * e.g `:value="{ value: 1, text: 'option text' }"`
46
+ */
47
+ valueIsObject: {
48
+ type: Boolean,
49
+ default: false
50
+ },
51
+ /**
52
+ * Can be an array of objects or array of strings. When using objects, will look for a text - value pair.
53
+ * This can be changed using the item-text, item-value props.
54
+ */
55
+ items: {
56
+ type: Array,
57
+ default: () => []
58
+ },
59
+ label: {
60
+ type: String,
61
+ default: ""
62
+ },
63
+ errorMsg: {
64
+ type: String,
65
+ default: ""
66
+ },
67
+ required: {
68
+ type: Boolean,
69
+ default: false
70
+ },
71
+ size: {
72
+ type: String,
73
+ default: "md",
74
+ validator(value) {
75
+ return Object.keys(SIZES).includes(value);
76
+ }
77
+ },
78
+ /**
79
+ * Set property of **items**’s text value
80
+ */
81
+ itemText: {
82
+ type: String,
83
+ default: "text"
84
+ },
85
+ /**
86
+ * Set property of **items**’s value - must be primitive.
87
+ */
88
+ itemValue: {
89
+ type: [String, Number],
90
+ default: "value"
91
+ },
92
+ /**
93
+ * itemSize sets the list item's height and it's REQUIRED if a custom item template is used
94
+ * https://github.com/Akryum/vue-virtual-scroller/tree/v1/packages/vue-virtual-scroller#props
95
+ */
96
+ itemSize: {
97
+ type: Number,
98
+ default: null
99
+ },
100
+ /**
101
+ * The number of items visible in the list
102
+ */
103
+ itemsVisible: {
104
+ type: Number,
105
+ default: 7
106
+ },
107
+ dropdownMenuAttrs: {
108
+ type: Object,
109
+ default: () => ({})
110
+ },
111
+ dropdownMenuClass: {
112
+ type: String,
113
+ default: "overflow-x-hidden"
114
+ },
115
+ dropdownMenuStyle: {
116
+ type: Object,
117
+ default: () => ({})
118
+ },
119
+ pDropdownProps: {
120
+ type: Object,
121
+ default: () => ({})
122
+ },
123
+ searchable: {
124
+ type: Boolean,
125
+ default: false
126
+ },
127
+ /**
128
+ * Enables multiple selection
129
+ */
130
+ multiple: {
131
+ type: Boolean,
132
+ default: false
133
+ },
134
+ /**
135
+ * Dropdown button text
136
+ */
137
+ placeholder: {
138
+ type: String,
139
+ default: ""
140
+ },
141
+ /**
142
+ * Placeholder for the search field
143
+ */
144
+ placeholderSearch: {
145
+ type: String,
146
+ default: ""
147
+ },
148
+ /**
149
+ * Setting it to `true` will display the selected options at the top of the list
150
+ */
151
+ selectedTopShown: {
152
+ type: Boolean,
153
+ default: false
154
+ }
155
+ },
156
+ emits: ["update:modelValue", "select"],
157
+ setup(__props, { emit: __emit }) {
158
+ const emit = __emit;
159
+ const props = __props;
160
+ const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
161
+ const nextLoop = (ms) => new Promise((resolve) => setTimeout(resolve, ms || 0));
162
+ const P_DROPDOWN_DEFAULTS = {
163
+ triggerStyle: { display: "block" },
164
+ triggers: [],
165
+ distance: 2,
166
+ placement: "bottom-end",
167
+ noAutoFocus: true,
168
+ enableArrowNavigation: false
169
+ };
170
+ const width = ref("auto");
171
+ const listItemStyle = ref({ paddingTop: 0, paddingBottom: 0 });
172
+ const dropdownShow = ref(false);
173
+ let observer = null;
174
+ const scrollerStyle = ref({ maxHeight: "none" });
175
+ const formControl = ref(null);
176
+ const inputSearch = ref(null);
177
+ const actionsContainer = ref(null);
178
+ const $attrs = useAttrs();
179
+ const virtualizerRef = ref(null);
180
+ const { labelClasses, selectClasses, errorMsgClasses } = useInputClasses(props);
181
+ const {
182
+ LIST_ITEM_CLASS,
183
+ LIST_ITEM_ACTIVE_CLASS,
184
+ selectedItems,
185
+ computedItems,
186
+ computedItemSize,
187
+ computedInsideSelected,
188
+ internalItems,
189
+ internalValue,
190
+ search,
191
+ rowVirtualizer,
192
+ getValue,
193
+ getText,
194
+ isSelected,
195
+ setupNavigationSvc,
196
+ destroyNavigationSvc,
197
+ select,
198
+ onMousemove,
199
+ scrollToActiveItem,
200
+ putSelectedItemsOnTop,
201
+ selectAll,
202
+ clearAll
203
+ } = useSelectList(props, inputSearch, virtualizerRef, emit);
204
+ const menuAttrs = computed(() => omit(props.dropdownMenuAttrs, ["class", "style"]));
205
+ const menuStyle = computed(() => ({ ...props.dropdownMenuStyle, width: width.value }));
206
+ const attrs = computed(() => {
207
+ const { class: classes, style: style2, ...rest } = $attrs;
208
+ return rest;
209
+ });
210
+ const style = computed(() => $attrs.style);
211
+ watch(
212
+ dropdownShow,
213
+ (nV) => {
214
+ nV && putSelectedItemsOnTop();
215
+ },
216
+ {
217
+ immediate: true
218
+ }
219
+ );
220
+ onMounted(() => {
221
+ observer = new ResizeObserver((entries) => {
222
+ entries.forEach((entry) => {
223
+ const rect = entry.contentRect;
224
+ width.value = rect.width + "px" || "auto";
225
+ });
226
+ });
227
+ observer.observe(formControl.value);
228
+ });
229
+ onUnmounted(() => {
230
+ formControl.value && observer && observer.unobserve(formControl.value);
231
+ });
232
+ const onShow = async () => {
233
+ var _a, _b;
234
+ const actionsContainerHeight = ((_a = actionsContainer.value) == null ? void 0 : _a.clientHeight) || 0;
235
+ scrollerStyle.value = { maxHeight: `${computedItemSize.value * props.itemsVisible - actionsContainerHeight}px` };
236
+ search.value = "";
237
+ setupNavigationSvc();
238
+ if (props.searchable) {
239
+ await nextLoop();
240
+ await nextFrame();
241
+ (_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
242
+ }
243
+ scrollToActiveItem();
244
+ };
245
+ const onHide = () => {
246
+ var _a;
247
+ dropdownShow.value = false;
248
+ destroyNavigationSvc();
249
+ ((_a = formControl.value) == null ? void 0 : _a.querySelector("button")).focus();
250
+ };
251
+ return (_ctx, _cache) => {
252
+ const _directive_close_popper = resolveDirective("close-popper");
253
+ return openBlock(), createElementBlock("div", {
254
+ ref_key: "formControl",
255
+ ref: formControl,
256
+ class: normalizeClass([{ hidden: unref($attrs).hidden }, unref($attrs).class]),
257
+ "data-has-error": !!__props.errorMsg,
258
+ style: normalizeStyle(style.value),
259
+ "aria-label": "Dropdown select"
260
+ }, [
261
+ __props.label ? (openBlock(), createElementBlock("label", {
262
+ key: 0,
263
+ class: normalizeClass(unref(labelClasses))
264
+ }, toDisplayString(__props.label), 3)) : createCommentVNode("", true),
265
+ createVNode(PDropdown, mergeProps({ shown: dropdownShow.value }, { ...P_DROPDOWN_DEFAULTS, ...__props.pDropdownProps }, {
266
+ class: "relative flex w-full items-center justify-center",
267
+ onApplyShow: onShow,
268
+ onApplyHide: onHide
269
+ }), {
270
+ popper: withCtx(() => [
271
+ createElementVNode("div", mergeProps(menuAttrs.value, {
272
+ class: __props.dropdownMenuClass,
273
+ style: menuStyle.value,
274
+ "p-select-list": "",
275
+ role: "listbox"
276
+ }), [
277
+ __props.multiple || __props.searchable ? (openBlock(), createElementBlock("div", _hoisted_4, [
278
+ __props.multiple ? (openBlock(), createElementBlock("div", {
279
+ key: 0,
280
+ ref_key: "actionsContainer",
281
+ ref: actionsContainer,
282
+ class: "flex flex-row justify-between text-xs font-semibold text-primary"
283
+ }, [
284
+ createElementVNode("p", _hoisted_5, toDisplayString(unref(computedItems).length) + " items", 1),
285
+ createElementVNode("div", _hoisted_6, [
286
+ unref(computedItems).length === unref(internalItems).length ? (openBlock(), createElementBlock("a", {
287
+ key: 0,
288
+ class: normalizeClass([
289
+ unref(selectedItems).length !== unref(internalItems).length ? "cursor-pointer" : "pointer-events-none opacity-50"
290
+ ]),
291
+ onClick: _cache[1] || (_cache[1] = //@ts-ignore
292
+ (...args) => unref(selectAll) && unref(selectAll)(...args))
293
+ }, " Select all ", 2)) : (openBlock(), createElementBlock("a", {
294
+ key: 1,
295
+ class: normalizeClass([unref(computedInsideSelected) ? "pointer-events-none opacity-50" : "cursor-pointer"]),
296
+ onClick: _cache[2] || (_cache[2] = //@ts-ignore
297
+ (...args) => unref(selectAll) && unref(selectAll)(...args))
298
+ }, " Select all filtered ", 2)),
299
+ _hoisted_7,
300
+ createElementVNode("a", {
301
+ class: normalizeClass([unref(selectedItems).length ? "cursor-pointer" : "pointer-events-none opacity-50"]),
302
+ onClick: _cache[3] || (_cache[3] = //@ts-ignore
303
+ (...args) => unref(clearAll) && unref(clearAll)(...args))
304
+ }, " Clear all ", 2)
305
+ ])
306
+ ], 512)) : createCommentVNode("", true),
307
+ __props.searchable ? (openBlock(), createElementBlock("div", {
308
+ key: 1,
309
+ class: normalizeClass([{ "mt-3": __props.multiple }])
310
+ }, [
311
+ createVNode(PInputSearch, {
312
+ ref_key: "inputSearch",
313
+ ref: inputSearch,
314
+ modelValue: unref(search),
315
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => isRef(search) ? search.value = $event : null),
316
+ size: __props.size,
317
+ placeholder: __props.placeholderSearch
318
+ }, null, 8, ["modelValue", "size", "placeholder"])
319
+ ], 2)) : createCommentVNode("", true)
320
+ ])) : createCommentVNode("", true),
321
+ createElementVNode("div", {
322
+ ref_key: "virtualizerRef",
323
+ ref: virtualizerRef,
324
+ style: normalizeStyle(scrollerStyle.value),
325
+ class: normalizeClass(["overflow-y-auto", { "mt-3": __props.multiple || __props.searchable }])
326
+ }, [
327
+ createElementVNode("div", {
328
+ class: "relative w-full",
329
+ "p-select-list-options": "",
330
+ style: normalizeStyle({ height: `${unref(rowVirtualizer).getTotalSize()}px` }),
331
+ onMousemove: _cache[5] || (_cache[5] = //@ts-ignore
332
+ (...args) => unref(onMousemove) && unref(onMousemove)(...args))
333
+ }, [
334
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(rowVirtualizer).getVirtualItems(), (row) => {
335
+ return openBlock(), createElementBlock("div", {
336
+ key: row.index,
337
+ class: "absolute left-0 top-0 w-full",
338
+ "p-select-list-option": "",
339
+ role: "option",
340
+ style: normalizeStyle({ height: `${row.size}px`, transform: `translateY(${row.start}px)` })
341
+ }, [
342
+ withDirectives((openBlock(), createElementBlock("div", {
343
+ class: normalizeClass([unref(LIST_ITEM_CLASS), { [unref(LIST_ITEM_ACTIVE_CLASS)]: unref(isSelected)(unref(getValue)(row.index)) }]),
344
+ "p-select-list-option-item": "",
345
+ style: normalizeStyle(listItemStyle.value),
346
+ onClick: ($event) => unref(select)($event, unref(getValue)(row.index))
347
+ }, [
348
+ createElementVNode("div", {
349
+ class: normalizeClass(["flex items-center", { [unref(SIZES)[__props.size]]: !__props.itemSize }])
350
+ }, [
351
+ renderSlot(_ctx.$slots, "item", {
352
+ item: unref(computedItems)[row.index],
353
+ isItemSelected: unref(isSelected)(unref(getValue)(row.index)),
354
+ itemTextSplit: unref(splitStringForHighlight)(unref(toString)(unref(getText)(row.index)), unref(search))
355
+ }, () => [
356
+ createElementVNode("div", {
357
+ class: "truncate text-p-purple-60",
358
+ title: unref(toString)(unref(getText)(row.index))
359
+ }, [
360
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(splitStringForHighlight)(unref(toString)(unref(getText)(row.index)), unref(search)), (str, index) => {
361
+ return openBlock(), createElementBlock("span", {
362
+ key: `${unref(getValue)(row.index)}_${index}`,
363
+ class: normalizeClass({ "bg-p-blue-20": index === 1 })
364
+ }, toDisplayString(str), 3);
365
+ }), 128))
366
+ ], 8, _hoisted_9)
367
+ ]),
368
+ unref(isSelected)(unref(getValue)(row.index)) ? (openBlock(), createElementBlock("img", _hoisted_10)) : createCommentVNode("", true)
369
+ ], 2)
370
+ ], 14, _hoisted_8)), [
371
+ [_directive_close_popper, !__props.multiple]
372
+ ])
373
+ ], 4);
374
+ }), 128))
375
+ ], 36),
376
+ !unref(computedItems).length ? renderSlot(_ctx.$slots, "no-items", { key: 0 }, () => [
377
+ createElementVNode("div", {
378
+ class: normalizeClass(["flex items-center justify-center", unref(SIZES)[__props.size]])
379
+ }, "No items found", 2)
380
+ ]) : createCommentVNode("", true)
381
+ ], 6)
382
+ ], 16)
383
+ ]),
384
+ default: withCtx(() => [
385
+ createElementVNode("button", mergeProps(attrs.value, {
386
+ ref: "button",
387
+ type: "button",
388
+ class: ["w-full", unref(selectClasses), dropdownShow.value ? "border-primary" : ""],
389
+ role: "button",
390
+ "aria-haspopup": "listbox",
391
+ onClick: _cache[0] || (_cache[0] = ($event) => dropdownShow.value = !dropdownShow.value)
392
+ }), [
393
+ !unref(internalValue).length || !unref(selectedItems).length ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.placeholder || " "), 1)) : renderSlot(_ctx.$slots, "selected-item", {
394
+ key: 1,
395
+ item: __props.multiple ? unref(selectedItems) : unref(selectedItems)[0]
396
+ }, () => [
397
+ createElementVNode("div", _hoisted_3, toDisplayString(__props.multiple && unref(selectedItems).length > 1 ? `${unref(selectedItems).length} option${unref(selectedItems).length > 1 ? "s" : ""} selected` : unref(selectedItems)[0][__props.itemText]), 1)
398
+ ])
399
+ ], 16)
400
+ ]),
401
+ _: 3
402
+ }, 16, ["shown"]),
403
+ withDirectives(createElementVNode("div", {
404
+ class: normalizeClass(unref(errorMsgClasses))
405
+ }, toDisplayString(__props.errorMsg), 3), [
406
+ [vShow, __props.errorMsg]
407
+ ])
408
+ ], 14, _hoisted_1);
409
+ };
410
+ }
411
+ });
412
+ export {
413
+ _imports_0 as _,
414
+ _sfc_main as a
415
+ };
@@ -0,0 +1,54 @@
1
+ import { defineComponent, computed, openBlock, createBlock, withCtx, createElementVNode, normalizeClass } from "vue";
2
+ import PInputNumber from "../p-input-number.js";
3
+ import { isNumber } from "lodash-es";
4
+ const _hoisted_1 = /* @__PURE__ */ createElementVNode("div", null, "%", -1);
5
+ const _hoisted_2 = [
6
+ _hoisted_1
7
+ ];
8
+ const _sfc_main = /* @__PURE__ */ defineComponent({
9
+ ...{
10
+ name: "PInputPercent"
11
+ },
12
+ __name: "p-input-percent",
13
+ props: {
14
+ modelValue: {
15
+ type: [Number, String],
16
+ default: null
17
+ },
18
+ size: {
19
+ type: String,
20
+ default: "md"
21
+ }
22
+ },
23
+ emits: ["update:modelValue"],
24
+ setup(__props, { emit: __emit }) {
25
+ const prefixClasses = {
26
+ sm: "text-sm h-8 left-2",
27
+ md: "text-base h-10 left-3",
28
+ lg: "text-lg h-12 left-5"
29
+ };
30
+ const props = __props;
31
+ const emit = __emit;
32
+ const convertedValue = computed({
33
+ get: () => isNumber(props.modelValue) ? props.modelValue * 100 : props.modelValue,
34
+ set: (nV) => emit("update:modelValue", isNumber(nV) ? nV / 100 : nV)
35
+ });
36
+ return (_ctx, _cache) => {
37
+ return openBlock(), createBlock(PInputNumber, {
38
+ modelValue: convertedValue.value,
39
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => convertedValue.value = $event),
40
+ size: __props.size
41
+ }, {
42
+ prefix: withCtx(() => [
43
+ createElementVNode("div", {
44
+ class: normalizeClass(["absolute flex items-center", prefixClasses[__props.size]])
45
+ }, _hoisted_2, 2)
46
+ ]),
47
+ _: 1
48
+ }, 8, ["modelValue", "size"]);
49
+ };
50
+ }
51
+ });
52
+ export {
53
+ _sfc_main as _
54
+ };
@@ -0,0 +1,67 @@
1
+ import { defineComponent, computed, openBlock, createBlock, createElementBlock, Fragment, createTextVNode, toDisplayString, renderSlot } from "vue";
2
+ import PSkeletonLoader from "../p-skeleton-loader.js";
3
+ const _hoisted_1 = {
4
+ key: 1,
5
+ class: "text-sm font-medium text-p-gray-40"
6
+ };
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ ...{ name: "PPaginationInfo" },
9
+ __name: "p-pagination-info",
10
+ props: {
11
+ /**
12
+ * The current page.
13
+ */
14
+ currentPage: {
15
+ type: Number,
16
+ default: 0
17
+ },
18
+ /**
19
+ * The amount of data pagination iterates through.
20
+ */
21
+ count: {
22
+ type: Number,
23
+ default: 0
24
+ },
25
+ /**
26
+ * The amount of data to be displayed at 1 page. Used to calculate the `from` and `to` limits.
27
+ */
28
+ pageSize: {
29
+ type: Number,
30
+ default: 0
31
+ },
32
+ /**
33
+ * Whether the pagination is loading.
34
+ */
35
+ loading: {
36
+ type: Boolean,
37
+ default: false
38
+ }
39
+ },
40
+ setup(__props) {
41
+ const props = __props;
42
+ const from = computed(() => {
43
+ const maxNumOfPages = Math.ceil(props.count / props.pageSize);
44
+ const currentPage = props.currentPage > maxNumOfPages ? maxNumOfPages : props.currentPage;
45
+ return (currentPage - 1) * props.pageSize + 1;
46
+ });
47
+ const to = computed(() => {
48
+ const to2 = props.currentPage * props.pageSize;
49
+ return to2 >= props.count ? props.count : to2;
50
+ });
51
+ return (_ctx, _cache) => {
52
+ return __props.loading ? (openBlock(), createBlock(PSkeletonLoader, {
53
+ key: 0,
54
+ class: "h-6 w-56"
55
+ })) : (openBlock(), createElementBlock("div", _hoisted_1, [
56
+ __props.count ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
57
+ createTextVNode("Showing " + toDisplayString(from.value) + " to " + toDisplayString(to.value) + " of " + toDisplayString(__props.count) + " results", 1)
58
+ ], 64)) : renderSlot(_ctx.$slots, "no-results", { key: 1 }, () => [
59
+ createTextVNode("No results found")
60
+ ])
61
+ ]));
62
+ };
63
+ }
64
+ });
65
+ export {
66
+ _sfc_main as _
67
+ };
@@ -0,0 +1,123 @@
1
+ import { defineComponent, computed, openBlock, createElementBlock, Fragment, createBlock, createCommentVNode, createElementVNode, normalizeClass, renderList, toDisplayString } from "vue";
2
+ import PSkeletonLoader from "../p-skeleton-loader.js";
3
+ import { createPagingRange } from "../pagination.js";
4
+ const _imports_0 = "data:image/svg+xml,%3csvg%20width='8'%20height='12'%20viewBox='0%200%208%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M0.25%205.99968C0.25%205.64968%200.4%205.34968%200.65%205.14968L6.25%200.249681C6.65%20-0.100319%207.2%20-0.0503187%207.55%200.349681C7.85%200.749681%207.85%201.29968%207.45%201.59968L2.55%205.89968C2.5%205.94968%202.5%205.99968%202.55%206.04968L7.45%2010.3497C7.85%2010.6997%207.9%2011.2497%207.55%2011.6497C7.2%2012.0497%206.65%2012.0997%206.25%2011.7497C6.25%2011.7497%206.25%2011.7497%206.2%2011.6997L0.65%206.84968C0.4%206.64968%200.25%206.29968%200.25%205.99968Z'%20fill='%23918da1'%20/%3e%3c/svg%3e";
5
+ const _imports_1 = "data:image/svg+xml,%3csvg%20width='8'%20height='14'%20viewBox='0%200%208%2014'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.75695%206.98136C7.75695%207.33136%207.60695%207.63136%207.35695%207.83136L1.75695%2012.7814C1.35695%2013.1314%200.756947%2013.0814%200.456947%2012.6814C0.156947%2012.2814%200.156947%2011.7314%200.556947%2011.3814L5.45695%207.08136C5.50695%207.03136%205.50695%206.98136%205.45695%206.88136L0.556947%202.58136C0.156947%202.23136%200.156947%201.63136%200.506947%201.28136C0.856947%200.931361%201.40695%200.881361%201.80695%201.18136L7.40695%206.08136C7.60695%206.33136%207.75695%206.63136%207.75695%206.98136Z'%20fill='%23918da1'%20/%3e%3c/svg%3e";
6
+ const _hoisted_1 = {
7
+ key: 1,
8
+ class: "flex text-p-gray-40"
9
+ };
10
+ const _hoisted_2 = /* @__PURE__ */ createElementVNode("img", { src: _imports_0 }, null, -1);
11
+ const _hoisted_3 = [
12
+ _hoisted_2
13
+ ];
14
+ const _hoisted_4 = ["onClick"];
15
+ const _hoisted_5 = { class: "flex" };
16
+ const _hoisted_6 = ["aria-label"];
17
+ const _hoisted_7 = /* @__PURE__ */ createElementVNode("img", { src: _imports_1 }, null, -1);
18
+ const _hoisted_8 = [
19
+ _hoisted_7
20
+ ];
21
+ const DOTS = "...";
22
+ const BTN_CLASS = "w-6 h-6 flex justify-center items-center mx-1 font-semibold text-sm leading-none";
23
+ const BTN_ACTIVE_CLASS = "text-p-purple-60 bg-p-gray-30 rounded-lg";
24
+ const BTN_INACTIVE_CLASS = "cursor-pointer";
25
+ const ARROW_ACTIVE_CLASS = "cursor-pointer";
26
+ const ARROW_INACTIVE_CLASS = "opacity-50";
27
+ const _sfc_main = /* @__PURE__ */ defineComponent({
28
+ ...{ name: "PPagination" },
29
+ __name: "p-pagination",
30
+ props: {
31
+ /**
32
+ * The current page.
33
+ */
34
+ modelValue: {
35
+ type: Number,
36
+ default: null
37
+ },
38
+ /**
39
+ * The amount of data pagination should iterate through.
40
+ */
41
+ count: {
42
+ type: Number,
43
+ default: 0
44
+ },
45
+ /**
46
+ * The amount of data to be displayed at 1 page. Used to calculate the length of pagination.
47
+ */
48
+ pageSize: {
49
+ type: Number,
50
+ default: 10
51
+ },
52
+ /**
53
+ * The amount of pages to be displayed before and after the current page.
54
+ */
55
+ pageOffset: {
56
+ type: Number,
57
+ default: 2
58
+ },
59
+ /**
60
+ * Whether the pagination is loading.
61
+ */
62
+ loading: {
63
+ type: Boolean,
64
+ default: false
65
+ }
66
+ },
67
+ emits: ["update:modelValue"],
68
+ setup(__props, { emit: __emit }) {
69
+ const emit = __emit;
70
+ const props = __props;
71
+ const pageCount = computed(() => {
72
+ return props.count && Math.ceil(props.count / props.pageSize);
73
+ });
74
+ const pages = computed(() => {
75
+ return createPagingRange(Number(props.modelValue), pageCount.value, props.pageOffset, DOTS);
76
+ });
77
+ const setPage = (page) => {
78
+ if (page >= 1 && page <= pageCount.value) {
79
+ emit("update:modelValue", page);
80
+ }
81
+ };
82
+ return (_ctx, _cache) => {
83
+ return openBlock(), createElementBlock(Fragment, null, [
84
+ __props.loading ? (openBlock(), createBlock(PSkeletonLoader, {
85
+ key: 0,
86
+ class: "h-6 w-56"
87
+ })) : createCommentVNode("", true),
88
+ !__props.loading && pages.value.length > 1 ? (openBlock(), createElementBlock("div", _hoisted_1, [
89
+ createElementVNode("div", {
90
+ class: normalizeClass([BTN_CLASS, Number(__props.modelValue) <= 1 ? ARROW_INACTIVE_CLASS : ARROW_ACTIVE_CLASS]),
91
+ "aria-label": "go to the previous page",
92
+ onClick: _cache[0] || (_cache[0] = ($event) => setPage(Number(__props.modelValue) - 1))
93
+ }, _hoisted_3, 2),
94
+ (openBlock(true), createElementBlock(Fragment, null, renderList(pages.value, (page, index) => {
95
+ return openBlock(), createElementBlock("div", {
96
+ key: index,
97
+ onClick: ($event) => setPage(Number(page))
98
+ }, [
99
+ createElementVNode("div", _hoisted_5, [
100
+ page !== DOTS ? (openBlock(), createElementBlock("div", {
101
+ key: 0,
102
+ class: normalizeClass([BTN_CLASS, page === __props.modelValue ? BTN_ACTIVE_CLASS : BTN_INACTIVE_CLASS]),
103
+ "aria-label": `go to page ${page}`
104
+ }, toDisplayString(page), 11, _hoisted_6)) : (openBlock(), createElementBlock("div", {
105
+ key: 1,
106
+ class: normalizeClass(BTN_CLASS)
107
+ }, toDisplayString(DOTS)))
108
+ ])
109
+ ], 8, _hoisted_4);
110
+ }), 128)),
111
+ createElementVNode("div", {
112
+ class: normalizeClass([BTN_CLASS, __props.modelValue === pageCount.value ? ARROW_INACTIVE_CLASS : ARROW_ACTIVE_CLASS]),
113
+ "aria-label": "go to the next page",
114
+ onClick: _cache[1] || (_cache[1] = ($event) => setPage(Number(__props.modelValue) + 1))
115
+ }, _hoisted_8, 2)
116
+ ])) : createCommentVNode("", true)
117
+ ], 64);
118
+ };
119
+ }
120
+ });
121
+ export {
122
+ _sfc_main as _
123
+ };